aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/Kconfig2
-rw-r--r--drivers/Makefile6
-rw-r--r--drivers/acpi/Kconfig84
-rw-r--r--drivers/acpi/Makefile25
-rw-r--r--drivers/acpi/acpi_memhotplug.c2
-rw-r--r--drivers/acpi/acpica/Makefile44
-rw-r--r--drivers/acpi/acpica/accommon.h63
-rw-r--r--drivers/acpi/acpica/acconfig.h217
-rw-r--r--drivers/acpi/acpica/acdebug.h231
-rw-r--r--drivers/acpi/acpica/acdispat.h345
-rw-r--r--drivers/acpi/acpica/acevents.h218
-rw-r--r--drivers/acpi/acpica/acglobal.h394
-rw-r--r--drivers/acpi/acpica/achware.h119
-rw-r--r--drivers/acpi/acpica/acinterp.h529
-rw-r--r--drivers/acpi/acpica/aclocal.h990
-rw-r--r--drivers/acpi/acpica/acmacros.h577
-rw-r--r--drivers/acpi/acpica/acnamesp.h324
-rw-r--r--drivers/acpi/acpica/acobject.h446
-rw-r--r--drivers/acpi/acpica/acopcode.h323
-rw-r--r--drivers/acpi/acpica/acparser.h234
-rw-r--r--drivers/acpi/acpica/acpredef.h371
-rw-r--r--drivers/acpi/acpica/acresrc.h336
-rw-r--r--drivers/acpi/acpica/acstruct.h228
-rw-r--r--drivers/acpi/acpica/actables.h117
-rw-r--r--drivers/acpi/acpica/acutils.h549
-rw-r--r--drivers/acpi/acpica/amlcode.h494
-rw-r--r--drivers/acpi/acpica/amlresrc.h311
-rw-r--r--drivers/acpi/acpica/dsfield.c (renamed from drivers/acpi/dispatcher/dsfield.c)11
-rw-r--r--drivers/acpi/acpica/dsinit.c (renamed from drivers/acpi/dispatcher/dsinit.c)7
-rw-r--r--drivers/acpi/acpica/dsmethod.c (renamed from drivers/acpi/dispatcher/dsmethod.c)14
-rw-r--r--drivers/acpi/acpica/dsmthdat.c (renamed from drivers/acpi/dispatcher/dsmthdat.c)7
-rw-r--r--drivers/acpi/acpica/dsobject.c (renamed from drivers/acpi/dispatcher/dsobject.c)11
-rw-r--r--drivers/acpi/acpica/dsopcode.c (renamed from drivers/acpi/dispatcher/dsopcode.c)66
-rw-r--r--drivers/acpi/acpica/dsutils.c (renamed from drivers/acpi/dispatcher/dsutils.c)13
-rw-r--r--drivers/acpi/acpica/dswexec.c (renamed from drivers/acpi/dispatcher/dswexec.c)13
-rw-r--r--drivers/acpi/acpica/dswload.c (renamed from drivers/acpi/dispatcher/dswload.c)13
-rw-r--r--drivers/acpi/acpica/dswscope.c (renamed from drivers/acpi/dispatcher/dswscope.c)3
-rw-r--r--drivers/acpi/acpica/dswstate.c (renamed from drivers/acpi/dispatcher/dswstate.c)7
-rw-r--r--drivers/acpi/acpica/evevent.c (renamed from drivers/acpi/events/evevent.c)17
-rw-r--r--drivers/acpi/acpica/evgpe.c (renamed from drivers/acpi/events/evgpe.c)53
-rw-r--r--drivers/acpi/acpica/evgpeblk.c (renamed from drivers/acpi/events/evgpeblk.c)82
-rw-r--r--drivers/acpi/acpica/evmisc.c (renamed from drivers/acpi/events/evmisc.c)62
-rw-r--r--drivers/acpi/acpica/evregion.c (renamed from drivers/acpi/events/evregion.c)140
-rw-r--r--drivers/acpi/acpica/evrgnini.c (renamed from drivers/acpi/events/evrgnini.c)46
-rw-r--r--drivers/acpi/acpica/evsci.c (renamed from drivers/acpi/events/evsci.c)13
-rw-r--r--drivers/acpi/acpica/evxface.c (renamed from drivers/acpi/events/evxface.c)9
-rw-r--r--drivers/acpi/acpica/evxfevnt.c (renamed from drivers/acpi/events/evxfevnt.c)170
-rw-r--r--drivers/acpi/acpica/evxfregn.c (renamed from drivers/acpi/events/evxfregn.c)5
-rw-r--r--drivers/acpi/acpica/exconfig.c (renamed from drivers/acpi/executer/exconfig.c)9
-rw-r--r--drivers/acpi/acpica/exconvrt.c (renamed from drivers/acpi/executer/exconvrt.c)5
-rw-r--r--drivers/acpi/acpica/excreate.c (renamed from drivers/acpi/executer/excreate.c)7
-rw-r--r--drivers/acpi/acpica/exdump.c (renamed from drivers/acpi/executer/exdump.c)7
-rw-r--r--drivers/acpi/acpica/exfield.c (renamed from drivers/acpi/executer/exfield.c)5
-rw-r--r--drivers/acpi/acpica/exfldio.c (renamed from drivers/acpi/executer/exfldio.c)20
-rw-r--r--drivers/acpi/acpica/exmisc.c (renamed from drivers/acpi/executer/exmisc.c)7
-rw-r--r--drivers/acpi/acpica/exmutex.c (renamed from drivers/acpi/executer/exmutex.c)5
-rw-r--r--drivers/acpi/acpica/exnames.c (renamed from drivers/acpi/executer/exnames.c)5
-rw-r--r--drivers/acpi/acpica/exoparg1.c (renamed from drivers/acpi/executer/exoparg1.c)11
-rw-r--r--drivers/acpi/acpica/exoparg2.c (renamed from drivers/acpi/executer/exoparg2.c)9
-rw-r--r--drivers/acpi/acpica/exoparg3.c (renamed from drivers/acpi/executer/exoparg3.c)7
-rw-r--r--drivers/acpi/acpica/exoparg6.c (renamed from drivers/acpi/executer/exoparg6.c)7
-rw-r--r--drivers/acpi/acpica/exprep.c (renamed from drivers/acpi/executer/exprep.c)9
-rw-r--r--drivers/acpi/acpica/exregion.c (renamed from drivers/acpi/executer/exregion.c)3
-rw-r--r--drivers/acpi/acpica/exresnte.c (renamed from drivers/acpi/executer/exresnte.c)7
-rw-r--r--drivers/acpi/acpica/exresolv.c (renamed from drivers/acpi/executer/exresolv.c)11
-rw-r--r--drivers/acpi/acpica/exresop.c (renamed from drivers/acpi/executer/exresop.c)9
-rw-r--r--drivers/acpi/acpica/exstore.c (renamed from drivers/acpi/executer/exstore.c)11
-rw-r--r--drivers/acpi/acpica/exstoren.c (renamed from drivers/acpi/executer/exstoren.c)5
-rw-r--r--drivers/acpi/acpica/exstorob.c (renamed from drivers/acpi/executer/exstorob.c)3
-rw-r--r--drivers/acpi/acpica/exsystem.c (renamed from drivers/acpi/executer/exsystem.c)3
-rw-r--r--drivers/acpi/acpica/exutils.c (renamed from drivers/acpi/executer/exutils.c)5
-rw-r--r--drivers/acpi/acpica/hwacpi.c (renamed from drivers/acpi/hardware/hwacpi.c)1
-rw-r--r--drivers/acpi/acpica/hwgpe.c (renamed from drivers/acpi/hardware/hwgpe.c)78
-rw-r--r--drivers/acpi/acpica/hwregs.c353
-rw-r--r--drivers/acpi/acpica/hwsleep.c (renamed from drivers/acpi/hardware/hwsleep.c)76
-rw-r--r--drivers/acpi/acpica/hwtimer.c (renamed from drivers/acpi/hardware/hwtimer.c)1
-rw-r--r--drivers/acpi/acpica/hwxface.c (renamed from drivers/acpi/hardware/hwregs.c)744
-rw-r--r--drivers/acpi/acpica/nsaccess.c (renamed from drivers/acpi/namespace/nsaccess.c)18
-rw-r--r--drivers/acpi/acpica/nsalloc.c (renamed from drivers/acpi/namespace/nsalloc.c)3
-rw-r--r--drivers/acpi/acpica/nsdump.c (renamed from drivers/acpi/namespace/nsdump.c)3
-rw-r--r--drivers/acpi/acpica/nsdumpdv.c (renamed from drivers/acpi/namespace/nsdumpdv.c)3
-rw-r--r--drivers/acpi/acpica/nseval.c (renamed from drivers/acpi/namespace/nseval.c)77
-rw-r--r--drivers/acpi/acpica/nsinit.c (renamed from drivers/acpi/namespace/nsinit.c)7
-rw-r--r--drivers/acpi/acpica/nsload.c (renamed from drivers/acpi/namespace/nsload.c)7
-rw-r--r--drivers/acpi/acpica/nsnames.c (renamed from drivers/acpi/namespace/nsnames.c)5
-rw-r--r--drivers/acpi/acpica/nsobject.c (renamed from drivers/acpi/namespace/nsobject.c)3
-rw-r--r--drivers/acpi/acpica/nsparse.c (renamed from drivers/acpi/namespace/nsparse.c)9
-rw-r--r--drivers/acpi/acpica/nspredef.c (renamed from drivers/acpi/namespace/nspredef.c)261
-rw-r--r--drivers/acpi/acpica/nssearch.c (renamed from drivers/acpi/namespace/nssearch.c)3
-rw-r--r--drivers/acpi/acpica/nsutils.c (renamed from drivers/acpi/namespace/nsutils.c)15
-rw-r--r--drivers/acpi/acpica/nswalk.c (renamed from drivers/acpi/namespace/nswalk.c)3
-rw-r--r--drivers/acpi/acpica/nsxfeval.c (renamed from drivers/acpi/namespace/nsxfeval.c)5
-rw-r--r--drivers/acpi/acpica/nsxfname.c (renamed from drivers/acpi/namespace/nsxfname.c)3
-rw-r--r--drivers/acpi/acpica/nsxfobj.c (renamed from drivers/acpi/namespace/nsxfobj.c)3
-rw-r--r--drivers/acpi/acpica/psargs.c (renamed from drivers/acpi/parser/psargs.c)9
-rw-r--r--drivers/acpi/acpica/psloop.c (renamed from drivers/acpi/parser/psloop.c)7
-rw-r--r--drivers/acpi/acpica/psopcode.c (renamed from drivers/acpi/parser/psopcode.c)7
-rw-r--r--drivers/acpi/acpica/psparse.c (renamed from drivers/acpi/parser/psparse.c)23
-rw-r--r--drivers/acpi/acpica/psscope.c (renamed from drivers/acpi/parser/psscope.c)3
-rw-r--r--drivers/acpi/acpica/pstree.c (renamed from drivers/acpi/parser/pstree.c)5
-rw-r--r--drivers/acpi/acpica/psutils.c (renamed from drivers/acpi/parser/psutils.c)5
-rw-r--r--drivers/acpi/acpica/pswalk.c (renamed from drivers/acpi/parser/pswalk.c)3
-rw-r--r--drivers/acpi/acpica/psxface.c (renamed from drivers/acpi/parser/psxface.c)40
-rw-r--r--drivers/acpi/acpica/rsaddr.c (renamed from drivers/acpi/resources/rsaddr.c)3
-rw-r--r--drivers/acpi/acpica/rscalc.c (renamed from drivers/acpi/resources/rscalc.c)5
-rw-r--r--drivers/acpi/acpica/rscreate.c (renamed from drivers/acpi/resources/rscreate.c)7
-rw-r--r--drivers/acpi/acpica/rsdump.c (renamed from drivers/acpi/resources/rsdump.c)3
-rw-r--r--drivers/acpi/acpica/rsinfo.c (renamed from drivers/acpi/resources/rsinfo.c)3
-rw-r--r--drivers/acpi/acpica/rsio.c (renamed from drivers/acpi/resources/rsio.c)3
-rw-r--r--drivers/acpi/acpica/rsirq.c (renamed from drivers/acpi/resources/rsirq.c)3
-rw-r--r--drivers/acpi/acpica/rslist.c (renamed from drivers/acpi/resources/rslist.c)3
-rw-r--r--drivers/acpi/acpica/rsmemory.c (renamed from drivers/acpi/resources/rsmemory.c)3
-rw-r--r--drivers/acpi/acpica/rsmisc.c (renamed from drivers/acpi/resources/rsmisc.c)3
-rw-r--r--drivers/acpi/acpica/rsutils.c (renamed from drivers/acpi/resources/rsutils.c)5
-rw-r--r--drivers/acpi/acpica/rsxface.c (renamed from drivers/acpi/resources/rsxface.c)5
-rw-r--r--drivers/acpi/acpica/tbfadt.c (renamed from drivers/acpi/tables/tbfadt.c)252
-rw-r--r--drivers/acpi/acpica/tbfind.c (renamed from drivers/acpi/tables/tbfind.c)3
-rw-r--r--drivers/acpi/acpica/tbinstal.c (renamed from drivers/acpi/tables/tbinstal.c)5
-rw-r--r--drivers/acpi/acpica/tbutils.c (renamed from drivers/acpi/tables/tbutils.c)30
-rw-r--r--drivers/acpi/acpica/tbxface.c (renamed from drivers/acpi/tables/tbxface.c)5
-rw-r--r--drivers/acpi/acpica/tbxfroot.c (renamed from drivers/acpi/tables/tbxfroot.c)3
-rw-r--r--drivers/acpi/acpica/utalloc.c (renamed from drivers/acpi/utilities/utalloc.c)3
-rw-r--r--drivers/acpi/acpica/utcopy.c (renamed from drivers/acpi/utilities/utcopy.c)3
-rw-r--r--drivers/acpi/acpica/utdebug.c (renamed from drivers/acpi/utilities/utdebug.c)95
-rw-r--r--drivers/acpi/acpica/utdelete.c (renamed from drivers/acpi/utilities/utdelete.c)7
-rw-r--r--drivers/acpi/acpica/uteval.c (renamed from drivers/acpi/utilities/uteval.c)11
-rw-r--r--drivers/acpi/acpica/utglobal.c (renamed from drivers/acpi/utilities/utglobal.c)12
-rw-r--r--drivers/acpi/acpica/utinit.c (renamed from drivers/acpi/utilities/utinit.c)7
-rw-r--r--drivers/acpi/acpica/utmath.c (renamed from drivers/acpi/utilities/utmath.c)1
-rw-r--r--drivers/acpi/acpica/utmisc.c (renamed from drivers/acpi/utilities/utmisc.c)23
-rw-r--r--drivers/acpi/acpica/utmutex.c (renamed from drivers/acpi/utilities/utmutex.c)1
-rw-r--r--drivers/acpi/acpica/utobject.c (renamed from drivers/acpi/utilities/utobject.c)7
-rw-r--r--drivers/acpi/acpica/utresrc.c (renamed from drivers/acpi/utilities/utresrc.c)3
-rw-r--r--drivers/acpi/acpica/utstate.c (renamed from drivers/acpi/utilities/utstate.c)1
-rw-r--r--drivers/acpi/acpica/utxface.c (renamed from drivers/acpi/utilities/utxface.c)18
-rw-r--r--drivers/acpi/battery.c5
-rw-r--r--drivers/acpi/cm_sbs.c3
-rw-r--r--drivers/acpi/debug.c1
-rw-r--r--drivers/acpi/dispatcher/Makefile9
-rw-r--r--drivers/acpi/ec.c106
-rw-r--r--drivers/acpi/events/Makefile9
-rw-r--r--drivers/acpi/executer/Makefile10
-rw-r--r--drivers/acpi/hardware/Makefile9
-rw-r--r--drivers/acpi/namespace/Makefile12
-rw-r--r--drivers/acpi/numa.c1
-rw-r--r--drivers/acpi/osl.c4
-rw-r--r--drivers/acpi/parser/Makefile8
-rw-r--r--drivers/acpi/pci_bind.c90
-rw-r--r--drivers/acpi/pci_irq.c472
-rw-r--r--drivers/acpi/pci_link.c6
-rw-r--r--drivers/acpi/pci_root.c20
-rw-r--r--drivers/acpi/power.c6
-rw-r--r--drivers/acpi/proc.c (renamed from drivers/acpi/sleep/proc.c)65
-rw-r--r--drivers/acpi/reboot.c2
-rw-r--r--drivers/acpi/resources/Makefile10
-rw-r--r--drivers/acpi/sbshc.c1
-rw-r--r--drivers/acpi/scan.c1
-rw-r--r--drivers/acpi/sleep.c (renamed from drivers/acpi/sleep/main.c)79
-rw-r--r--drivers/acpi/sleep.h (renamed from drivers/acpi/sleep/sleep.h)0
-rw-r--r--drivers/acpi/sleep/Makefile5
-rw-r--r--drivers/acpi/system.c63
-rw-r--r--drivers/acpi/tables/Makefile7
-rw-r--r--drivers/acpi/thermal.c16
-rw-r--r--drivers/acpi/utilities/Makefile9
-rw-r--r--drivers/acpi/utilities/utcache.c314
-rw-r--r--drivers/acpi/video.c20
-rw-r--r--drivers/acpi/video_detect.c4
-rw-r--r--drivers/acpi/wakeup.c (renamed from drivers/acpi/sleep/wakeup.c)6
-rw-r--r--drivers/amba/bus.c3
-rw-r--r--drivers/ata/Kconfig9
-rw-r--r--drivers/ata/Makefile1
-rw-r--r--drivers/ata/ahci.c13
-rw-r--r--drivers/ata/ata_piix.c51
-rw-r--r--drivers/ata/libata-acpi.c6
-rw-r--r--drivers/ata/libata-core.c201
-rw-r--r--drivers/ata/libata-scsi.c17
-rw-r--r--drivers/ata/libata-sff.c216
-rw-r--r--drivers/ata/pata_acpi.c6
-rw-r--r--drivers/ata/pata_ali.c111
-rw-r--r--drivers/ata/pata_amd.c4
-rw-r--r--drivers/ata/pata_atiixp.c32
-rw-r--r--drivers/ata/pata_hpt366.c109
-rw-r--r--drivers/ata/pata_hpt3x3.c49
-rw-r--r--drivers/ata/pata_it821x.c17
-rw-r--r--drivers/ata/pata_mpiix.c3
-rw-r--r--drivers/ata/pata_octeon_cf.c965
-rw-r--r--drivers/ata/pata_platform.c2
-rw-r--r--drivers/ata/pata_sil680.c4
-rw-r--r--drivers/ata/sata_fsl.c2
-rw-r--r--drivers/ata/sata_sil24.c7
-rw-r--r--drivers/ata/sata_via.c2
-rw-r--r--drivers/atm/iphase.c6
-rw-r--r--drivers/base/Kconfig2
-rw-r--r--drivers/base/base.h26
-rw-r--r--drivers/base/bus.c40
-rw-r--r--drivers/base/core.c45
-rw-r--r--drivers/base/dd.c13
-rw-r--r--drivers/base/driver.c13
-rw-r--r--drivers/base/topology.c1
-rw-r--r--drivers/block/amiflop.c40
-rw-r--r--drivers/block/nbd.c4
-rw-r--r--drivers/block/ps3disk.c18
-rw-r--r--drivers/block/sunvdc.c8
-rw-r--r--drivers/block/ub.c11
-rw-r--r--drivers/block/xsysace.c1
-rw-r--r--drivers/char/Kconfig1
-rw-r--r--drivers/char/amiserial.c36
-rw-r--r--drivers/char/bsr.c2
-rw-r--r--drivers/char/epca.c2
-rw-r--r--drivers/char/hvc_beat.c4
-rw-r--r--drivers/char/hvc_console.c12
-rw-r--r--drivers/char/hvc_irq.c2
-rw-r--r--drivers/char/hvc_iucv.c420
-rw-r--r--drivers/char/hw_random/n2-drv.c2
-rw-r--r--drivers/char/ps3flash.c18
-rw-r--r--drivers/char/pty.c6
-rw-r--r--drivers/char/rtc.c17
-rw-r--r--drivers/char/ser_a2232.c12
-rw-r--r--drivers/char/synclink_gt.c16
-rw-r--r--drivers/char/sysrq.c6
-rw-r--r--drivers/char/tpm/tpm_bios.c2
-rw-r--r--drivers/char/tpm/tpm_nsc.c35
-rw-r--r--drivers/char/tty_ioctl.c2
-rw-r--r--drivers/char/vme_scc.c166
-rw-r--r--drivers/char/vt.c3
-rw-r--r--drivers/cpufreq/Kconfig4
-rw-r--r--drivers/cpufreq/cpufreq.c42
-rw-r--r--drivers/cpufreq/cpufreq_conservative.c2
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c4
-rw-r--r--drivers/cpuidle/governors/menu.c10
-rw-r--r--drivers/dca/dca-core.c2
-rw-r--r--drivers/dio/dio-sysfs.c19
-rw-r--r--drivers/dio/dio.c18
-rw-r--r--drivers/dma/Kconfig2
-rw-r--r--drivers/dma/dmaengine.c778
-rw-r--r--drivers/dma/dmatest.c129
-rw-r--r--drivers/dma/dw_dmac.c119
-rw-r--r--drivers/dma/fsldma.c5
-rw-r--r--drivers/dma/ioat.c92
-rw-r--r--drivers/dma/ioat_dma.c18
-rw-r--r--drivers/dma/iop-adma.c30
-rw-r--r--drivers/dma/mv_xor.c11
-rw-r--r--drivers/firewire/fw-card.c33
-rw-r--r--drivers/firewire/fw-device.c31
-rw-r--r--drivers/firewire/fw-device.h2
-rw-r--r--drivers/firewire/fw-sbp2.c21
-rw-r--r--drivers/firewire/fw-topology.c16
-rw-r--r--drivers/firewire/fw-transaction.c2
-rw-r--r--drivers/firewire/fw-transaction.h13
-rw-r--r--drivers/firmware/dcdbas.c9
-rw-r--r--drivers/firmware/dcdbas.h2
-rw-r--r--drivers/firmware/dell_rbu.c4
-rw-r--r--drivers/firmware/memmap.c6
-rw-r--r--drivers/gpio/max7301.c6
-rw-r--r--drivers/gpio/max732x.c6
-rw-r--r--drivers/gpio/mcp23s08.c6
-rw-r--r--drivers/gpio/pca953x.c6
-rw-r--r--drivers/gpio/pcf857x.c12
-rw-r--r--drivers/gpu/drm/drm_crtc.c2
-rw-r--r--drivers/gpu/drm/drm_crtc_helper.c175
-rw-r--r--drivers/gpu/drm/drm_irq.c18
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c10
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h23
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c193
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c6
-rw-r--r--drivers/gpu/drm/i915/intel_display.c43
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c7
-rw-r--r--drivers/hid/usbhid/hid-core.c9
-rw-r--r--drivers/hid/usbhid/hiddev.c2
-rw-r--r--drivers/hwmon/Kconfig71
-rw-r--r--drivers/hwmon/Makefile5
-rw-r--r--drivers/hwmon/abituguru3.c24
-rw-r--r--drivers/hwmon/adt7475.c1221
-rw-r--r--drivers/hwmon/applesmc.c5
-rw-r--r--drivers/hwmon/asb100.c5
-rw-r--r--drivers/hwmon/dme1737.c5
-rw-r--r--drivers/hwmon/f71805f.c5
-rw-r--r--drivers/hwmon/f71882fg.c1549
-rw-r--r--drivers/hwmon/fschmd.c450
-rw-r--r--drivers/hwmon/hp_accel.c334
-rw-r--r--drivers/hwmon/i5k_amb.c7
-rw-r--r--drivers/hwmon/it87.c37
-rw-r--r--drivers/hwmon/k8temp.c55
-rw-r--r--drivers/hwmon/lis3lv02d.c273
-rw-r--r--drivers/hwmon/lis3lv02d.h35
-rw-r--r--drivers/hwmon/lm70.c91
-rw-r--r--drivers/hwmon/ltc4245.c567
-rw-r--r--drivers/hwmon/pc87360.c6
-rw-r--r--drivers/hwmon/pc87427.c5
-rw-r--r--drivers/hwmon/sis5595.c5
-rw-r--r--drivers/hwmon/smsc47b397.c5
-rw-r--r--drivers/hwmon/smsc47m1.c5
-rw-r--r--drivers/hwmon/via686a.c5
-rw-r--r--drivers/hwmon/vt1211.c5
-rw-r--r--drivers/hwmon/vt8231.c5
-rw-r--r--drivers/hwmon/w83627ehf.c8
-rw-r--r--drivers/hwmon/w83627hf.c5
-rw-r--r--drivers/hwmon/w83781d.c5
-rw-r--r--drivers/hwmon/w83791d.c5
-rw-r--r--drivers/hwmon/w83792d.c5
-rw-r--r--drivers/hwmon/w83793.c5
-rw-r--r--drivers/i2c/busses/i2c-ali1563.c4
-rw-r--r--drivers/i2c/busses/i2c-amd756-s4882.c4
-rw-r--r--drivers/i2c/busses/i2c-amd756.c5
-rw-r--r--drivers/i2c/busses/i2c-at91.c2
-rw-r--r--drivers/i2c/busses/i2c-bfin-twi.c2
-rw-r--r--drivers/i2c/busses/i2c-i801.c50
-rw-r--r--drivers/i2c/busses/i2c-pxa.c4
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c2
-rw-r--r--drivers/i2c/busses/i2c-sh7760.c2
-rw-r--r--drivers/i2c/busses/i2c-sh_mobile.c2
-rw-r--r--drivers/i2c/busses/i2c-sis5595.c4
-rw-r--r--drivers/i2c/busses/i2c-sis630.c4
-rw-r--r--drivers/i2c/chips/Kconfig23
-rw-r--r--drivers/i2c/chips/Makefile2
-rw-r--r--drivers/i2c/chips/mcu_mpc8349emitx.c209
-rw-r--r--drivers/i2c/i2c-core.c8
-rw-r--r--drivers/ide/Kconfig5
-rw-r--r--drivers/ide/ide-acpi.c6
-rw-r--r--drivers/ide/ide-disk.c2
-rw-r--r--drivers/ide/ide-iops.c2
-rw-r--r--drivers/ide/ide-pm.c12
-rw-r--r--drivers/ide/ide-probe.c2
-rw-r--r--drivers/ide/it821x.c15
-rw-r--r--drivers/ide/sl82c105.c4
-rw-r--r--drivers/ide/tx4938ide.c1
-rw-r--r--drivers/ide/via82cxxx.c2
-rw-r--r--drivers/ieee1394/csr.c12
-rw-r--r--drivers/ieee1394/csr.h10
-rw-r--r--drivers/ieee1394/csr1212.c45
-rw-r--r--drivers/ieee1394/csr1212.h9
-rw-r--r--drivers/ieee1394/dv1394-private.h44
-rw-r--r--drivers/ieee1394/dv1394.c12
-rw-r--r--drivers/ieee1394/eth1394.c82
-rw-r--r--drivers/ieee1394/eth1394.h17
-rw-r--r--drivers/ieee1394/highlevel.c9
-rw-r--r--drivers/ieee1394/highlevel.h7
-rw-r--r--drivers/ieee1394/hosts.c6
-rw-r--r--drivers/ieee1394/hosts.h2
-rw-r--r--drivers/ieee1394/ieee1394.h3
-rw-r--r--drivers/ieee1394/nodemgr.c20
-rw-r--r--drivers/ieee1394/nodemgr.h3
-rw-r--r--drivers/ieee1394/ohci1394.c26
-rw-r--r--drivers/ieee1394/pcilynx.c2
-rw-r--r--drivers/ieee1394/pcilynx.h2
-rw-r--r--drivers/ieee1394/raw1394.c2
-rw-r--r--drivers/ieee1394/sbp2.c4
-rw-r--r--drivers/infiniband/hw/ehca/ehca_cq.c16
-rw-r--r--drivers/infiniband/hw/ehca/ehca_hca.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_irq.c18
-rw-r--r--drivers/infiniband/hw/ehca/ehca_main.c8
-rw-r--r--drivers/infiniband/hw/ehca/ehca_mcast.c4
-rw-r--r--drivers/infiniband/hw/ehca/ehca_mrmw.c144
-rw-r--r--drivers/infiniband/hw/ehca/ehca_qp.c32
-rw-r--r--drivers/infiniband/hw/ehca/ehca_reqs.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_sqp.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_tools.h2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_uverbs.c2
-rw-r--r--drivers/infiniband/hw/ehca/hcp_if.c56
-rw-r--r--drivers/infiniband/hw/mlx4/cq.c2
-rw-r--r--drivers/infiniband/hw/mlx4/main.c13
-rw-r--r--drivers/infiniband/hw/mlx4/qp.c28
-rw-r--r--drivers/infiniband/hw/nes/nes_cm.c14
-rw-r--r--drivers/infiniband/hw/nes/nes_utils.c4
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c65
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_multicast.c5
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_vlan.c11
-rw-r--r--drivers/infiniband/ulp/iser/Kconfig2
-rw-r--r--drivers/input/keyboard/atkbd.c2
-rw-r--r--drivers/input/misc/Kconfig7
-rw-r--r--drivers/input/misc/Makefile1
-rw-r--r--drivers/input/misc/apanel.c81
-rw-r--r--drivers/input/misc/pcf50633-input.c132
-rw-r--r--drivers/input/mouse/pxa930_trkball.c4
-rw-r--r--drivers/input/touchscreen/da9034-ts.c1
-rw-r--r--drivers/isdn/hardware/eicon/debuglib.h2
-rw-r--r--drivers/isdn/hardware/eicon/os_4bri.c2
-rw-r--r--drivers/isdn/hardware/eicon/os_bri.c2
-rw-r--r--drivers/isdn/hardware/eicon/os_pri.c2
-rw-r--r--drivers/isdn/hardware/mISDN/Kconfig7
-rw-r--r--drivers/isdn/hardware/mISDN/Makefile1
-rw-r--r--drivers/isdn/hardware/mISDN/hfc_multi.h10
-rw-r--r--drivers/isdn/hardware/mISDN/hfc_pci.h2
-rw-r--r--drivers/isdn/hardware/mISDN/hfcmulti.c209
-rw-r--r--drivers/isdn/hardware/mISDN/hfcpci.c241
-rw-r--r--drivers/isdn/hardware/mISDN/hfcsusb.c2196
-rw-r--r--drivers/isdn/hardware/mISDN/hfcsusb.h418
-rw-r--r--drivers/isdn/hysdn/hysdn_net.c77
-rw-r--r--drivers/isdn/i4l/isdn_net.c70
-rw-r--r--drivers/isdn/mISDN/Makefile2
-rw-r--r--drivers/isdn/mISDN/clock.c216
-rw-r--r--drivers/isdn/mISDN/core.c280
-rw-r--r--drivers/isdn/mISDN/core.h2
-rw-r--r--drivers/isdn/mISDN/dsp.h2
-rw-r--r--drivers/isdn/mISDN/dsp_cmx.c149
-rw-r--r--drivers/isdn/mISDN/dsp_core.c55
-rw-r--r--drivers/isdn/mISDN/dsp_pipeline.c38
-rw-r--r--drivers/isdn/mISDN/hwchannel.c42
-rw-r--r--drivers/isdn/mISDN/l1oip_core.c25
-rw-r--r--drivers/isdn/mISDN/layer1.c2
-rw-r--r--drivers/isdn/mISDN/socket.c41
-rw-r--r--drivers/isdn/mISDN/stack.c66
-rw-r--r--drivers/isdn/mISDN/tei.c6
-rw-r--r--drivers/leds/Kconfig22
-rw-r--r--drivers/leds/Makefile3
-rw-r--r--drivers/leds/led-class.c24
-rw-r--r--drivers/leds/leds-alix2.c181
-rw-r--r--drivers/leds/leds-ams-delta.c33
-rw-r--r--drivers/leds/leds-clevo-mail.c21
-rw-r--r--drivers/leds/leds-fsg.c37
-rw-r--r--drivers/leds/leds-gpio.c36
-rw-r--r--drivers/leds/leds-hp-disk.c155
-rw-r--r--drivers/leds/leds-hp6xx.c22
-rw-r--r--drivers/leds/leds-net48xx.c21
-rw-r--r--drivers/leds/leds-pca9532.c77
-rw-r--r--drivers/leds/leds-s3c24xx.c25
-rw-r--r--drivers/leds/leds-wm8350.c311
-rw-r--r--drivers/leds/leds-wrap.c27
-rw-r--r--drivers/leds/ledtrig-timer.c5
-rw-r--r--drivers/macintosh/Kconfig2
-rw-r--r--drivers/md/bitmap.c11
-rw-r--r--drivers/md/faulty.c3
-rw-r--r--drivers/md/linear.c3
-rw-r--r--drivers/md/md.c416
-rw-r--r--drivers/md/multipath.c3
-rw-r--r--drivers/md/raid0.c178
-rw-r--r--drivers/md/raid1.c11
-rw-r--r--drivers/md/raid10.c3
-rw-r--r--drivers/md/raid5.c8
-rw-r--r--drivers/media/common/tuners/tda8290.c6
-rw-r--r--drivers/media/dvb/dm1105/Kconfig1
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c26
-rw-r--r--drivers/media/dvb/dvb-core/dvb_net.c57
-rw-r--r--drivers/media/dvb/dvb-usb/anysee.c2
-rw-r--r--drivers/media/dvb/frontends/cx24116.c2
-rw-r--r--drivers/media/dvb/frontends/lgdt3304.c10
-rw-r--r--drivers/media/dvb/frontends/s921_module.c2
-rw-r--r--drivers/media/dvb/frontends/stb0899_algo.c4
-rw-r--r--drivers/media/dvb/frontends/stb0899_drv.c6
-rw-r--r--drivers/media/dvb/ttpci/budget-ci.c4
-rw-r--r--drivers/media/video/cafe_ccic.c1
-rw-r--r--drivers/media/video/cx88/Kconfig5
-rw-r--r--drivers/media/video/cx88/Makefile3
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c46
-rw-r--r--drivers/media/video/cx88/cx88-i2c.c24
-rw-r--r--drivers/media/video/cx88/cx88-mpeg.c30
-rw-r--r--drivers/media/video/cx88/cx88.h4
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c5
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c2
-rw-r--r--drivers/media/video/em28xx/em28xx-input.c2
-rw-r--r--drivers/media/video/gspca/m5602/m5602_s5k83a.c2
-rw-r--r--drivers/media/video/ov7670.c1
-rw-r--r--drivers/media/video/ovcamchip/ovcamchip_core.c1
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c2
-rw-r--r--drivers/media/video/pxa_camera.c4
-rw-r--r--drivers/media/video/pxa_camera.h95
-rw-r--r--drivers/media/video/usbvideo/ibmcam.c2
-rw-r--r--drivers/media/video/usbvideo/konicawc.c2
-rw-r--r--drivers/media/video/usbvideo/ultracam.c2
-rw-r--r--drivers/media/video/usbvision/usbvision-video.c3
-rw-r--r--drivers/media/video/v4l2-device.c4
-rw-r--r--drivers/media/video/videobuf-dma-sg.c3
-rw-r--r--drivers/media/video/w9968cf.c1
-rw-r--r--drivers/memstick/core/mspro_block.c43
-rw-r--r--drivers/message/fusion/lsi/mpi.h7
-rw-r--r--drivers/message/fusion/lsi/mpi_cnfg.h47
-rw-r--r--drivers/message/fusion/lsi/mpi_fc.h2
-rw-r--r--drivers/message/fusion/lsi/mpi_history.txt86
-rw-r--r--drivers/message/fusion/lsi/mpi_init.h2
-rw-r--r--drivers/message/fusion/lsi/mpi_ioc.h22
-rw-r--r--drivers/message/fusion/lsi/mpi_lan.h2
-rw-r--r--drivers/message/fusion/lsi/mpi_log_fc.h2
-rw-r--r--drivers/message/fusion/lsi/mpi_log_sas.h37
-rw-r--r--drivers/message/fusion/lsi/mpi_raid.h11
-rw-r--r--drivers/message/fusion/lsi/mpi_sas.h18
-rw-r--r--drivers/message/fusion/lsi/mpi_targ.h2
-rw-r--r--drivers/message/fusion/lsi/mpi_tool.h2
-rw-r--r--drivers/message/fusion/lsi/mpi_type.h4
-rw-r--r--drivers/message/fusion/mptbase.c87
-rw-r--r--drivers/message/fusion/mptbase.h3
-rw-r--r--drivers/message/fusion/mptctl.c5
-rw-r--r--drivers/message/fusion/mptlan.c44
-rw-r--r--drivers/message/fusion/mptscsih.c3
-rw-r--r--drivers/message/i2o/i2o_scsi.c2
-rw-r--r--drivers/mfd/Kconfig23
-rw-r--r--drivers/mfd/Makefile4
-rw-r--r--drivers/mfd/dm355evm_msp.c10
-rw-r--r--drivers/mfd/pcf50633-adc.c277
-rw-r--r--drivers/mfd/pcf50633-core.c710
-rw-r--r--drivers/mfd/pcf50633-gpio.c118
-rw-r--r--drivers/mfd/sm501.c30
-rw-r--r--drivers/mfd/twl4030-core.c11
-rw-r--r--drivers/mfd/wm8350-core.c3
-rw-r--r--drivers/misc/Kconfig296
-rw-r--r--drivers/misc/Makefile13
-rw-r--r--drivers/misc/enclosure.c8
-rw-r--r--drivers/misc/ibmasm/event.c2
-rw-r--r--drivers/misc/phantom.c2
-rw-r--r--drivers/misc/sgi-xp/xpc_sn2.c2
-rw-r--r--drivers/misc/sgi-xp/xpnet.c68
-rw-r--r--drivers/mmc/host/atmel-mci.c105
-rw-r--r--drivers/mtd/Kconfig10
-rw-r--r--drivers/mtd/Makefile2
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c12
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0002.c18
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0020.c14
-rw-r--r--drivers/mtd/chips/fwh_lock.h4
-rw-r--r--drivers/mtd/devices/Kconfig7
-rw-r--r--drivers/mtd/devices/Makefile1
-rw-r--r--drivers/mtd/devices/lart.c6
-rw-r--r--drivers/mtd/devices/m25p80.c41
-rw-r--r--drivers/mtd/devices/mtd_dataflash.c24
-rw-r--r--drivers/mtd/devices/pmc551.c2
-rw-r--r--drivers/mtd/devices/ps3vram.c768
-rw-r--r--drivers/mtd/ftl.c100
-rw-r--r--drivers/mtd/inftlcore.c2
-rw-r--r--drivers/mtd/inftlmount.c4
-rw-r--r--drivers/mtd/lpddr/Kconfig22
-rw-r--r--drivers/mtd/lpddr/Makefile6
-rw-r--r--drivers/mtd/lpddr/lpddr_cmds.c796
-rw-r--r--drivers/mtd/lpddr/qinfo_probe.c255
-rw-r--r--drivers/mtd/maps/Kconfig21
-rw-r--r--drivers/mtd/maps/alchemy-flash.c2
-rw-r--r--drivers/mtd/maps/amd76xrom.c4
-rw-r--r--drivers/mtd/maps/cfi_flagadm.c2
-rw-r--r--drivers/mtd/maps/ck804xrom.c4
-rw-r--r--drivers/mtd/maps/dbox2-flash.c2
-rw-r--r--drivers/mtd/maps/edb7312.c2
-rw-r--r--drivers/mtd/maps/esb2rom.c4
-rw-r--r--drivers/mtd/maps/fortunet.c2
-rw-r--r--drivers/mtd/maps/h720x-flash.c2
-rw-r--r--drivers/mtd/maps/ichxrom.c4
-rw-r--r--drivers/mtd/maps/impa7.c2
-rw-r--r--drivers/mtd/maps/ipaq-flash.c2
-rw-r--r--drivers/mtd/maps/mbx860.c2
-rw-r--r--drivers/mtd/maps/nettel.c9
-rw-r--r--drivers/mtd/maps/octagon-5066.c2
-rw-r--r--drivers/mtd/maps/physmap.c41
-rw-r--r--drivers/mtd/maps/pmcmsp-flash.c2
-rw-r--r--drivers/mtd/maps/redwood.c2
-rw-r--r--drivers/mtd/maps/rpxlite.c2
-rw-r--r--drivers/mtd/maps/sbc8240.c2
-rw-r--r--drivers/mtd/maps/scb2_flash.c8
-rw-r--r--drivers/mtd/maps/sharpsl-flash.c2
-rw-r--r--drivers/mtd/maps/tqm8xxl.c2
-rw-r--r--drivers/mtd/maps/uclinux.c4
-rw-r--r--drivers/mtd/maps/vmax301.c2
-rw-r--r--drivers/mtd/maps/wr_sbc82xx_flash.c2
-rw-r--r--drivers/mtd/mtdchar.c6
-rw-r--r--drivers/mtd/mtdconcat.c35
-rw-r--r--drivers/mtd/mtdcore.c16
-rw-r--r--drivers/mtd/mtdoops.c9
-rw-r--r--drivers/mtd/mtdpart.c34
-rw-r--r--drivers/mtd/nand/Kconfig7
-rw-r--r--drivers/mtd/nand/alauda.c6
-rw-r--r--drivers/mtd/nand/cafe_nand.c7
-rw-r--r--drivers/mtd/nand/fsl_elbc_nand.c4
-rw-r--r--drivers/mtd/nand/nand_base.c25
-rw-r--r--drivers/mtd/nand/nand_bbt.c31
-rw-r--r--drivers/mtd/nand/nandsim.c339
-rw-r--r--drivers/mtd/nand/ndfc.c269
-rw-r--r--drivers/mtd/nand/pxa3xx_nand.c6
-rw-r--r--drivers/mtd/nand/sharpsl.c247
-rw-r--r--drivers/mtd/nftlcore.c2
-rw-r--r--drivers/mtd/nftlmount.c4
-rw-r--r--drivers/mtd/onenand/onenand_base.c8
-rw-r--r--drivers/mtd/rfd_ftl.c29
-rw-r--r--drivers/mtd/ssfdc.c7
-rw-r--r--drivers/mtd/tests/Makefile7
-rw-r--r--drivers/mtd/tests/mtd_oobtest.c742
-rw-r--r--drivers/mtd/tests/mtd_pagetest.c632
-rw-r--r--drivers/mtd/tests/mtd_readtest.c253
-rw-r--r--drivers/mtd/tests/mtd_speedtest.c502
-rw-r--r--drivers/mtd/tests/mtd_stresstest.c330
-rw-r--r--drivers/mtd/tests/mtd_subpagetest.c525
-rw-r--r--drivers/mtd/tests/mtd_torturetest.c530
-rw-r--r--drivers/mtd/ubi/build.c2
-rw-r--r--drivers/mtd/ubi/eba.c2
-rw-r--r--drivers/mtd/ubi/gluebi.c17
-rw-r--r--drivers/mtd/ubi/io.c2
-rw-r--r--drivers/mtd/ubi/kapi.c2
-rw-r--r--drivers/mtd/ubi/scan.c2
-rw-r--r--drivers/mtd/ubi/ubi-media.h4
-rw-r--r--drivers/mtd/ubi/vtbl.c2
-rw-r--r--drivers/mtd/ubi/wl.c4
-rw-r--r--drivers/net/3c503.c1
-rw-r--r--drivers/net/3c59x.c2
-rw-r--r--drivers/net/8139cp.c2
-rw-r--r--drivers/net/8139too.c2
-rw-r--r--drivers/net/8390.c1
-rw-r--r--drivers/net/8390p.c1
-rw-r--r--drivers/net/Kconfig6
-rw-r--r--drivers/net/Makefile1
-rw-r--r--drivers/net/acenic.c1
-rw-r--r--drivers/net/acenic_firmware.h9456
-rw-r--r--drivers/net/amd8111e.c35
-rw-r--r--drivers/net/appletalk/ipddp.c25
-rw-r--r--drivers/net/arm/etherh.c1
-rw-r--r--drivers/net/arm/ks8695net.c1
-rw-r--r--drivers/net/atp.c32
-rw-r--r--drivers/net/ax88796.c27
-rw-r--r--drivers/net/b44.c46
-rw-r--r--drivers/net/b44.h2
-rw-r--r--drivers/net/bnx2x.h19
-rw-r--r--drivers/net/bnx2x_link.c2
-rw-r--r--drivers/net/bnx2x_main.c181
-rw-r--r--drivers/net/bonding/bond_main.c2
-rw-r--r--drivers/net/cassini.c29
-rw-r--r--drivers/net/cxgb3/adapter.h7
-rw-r--r--drivers/net/cxgb3/cxgb3_main.c22
-rw-r--r--drivers/net/cxgb3/sge.c2
-rw-r--r--drivers/net/de600.c14
-rw-r--r--drivers/net/de620.c17
-rw-r--r--drivers/net/e100.c299
-rw-r--r--drivers/net/e1000/e1000_hw.c4
-rw-r--r--drivers/net/e1000e/ich8lan.c19
-rw-r--r--drivers/net/e1000e/netdev.c2
-rw-r--r--drivers/net/e2100.c1
-rw-r--r--drivers/net/ehea/ehea_main.c8
-rw-r--r--drivers/net/ehea/ehea_phyp.c16
-rw-r--r--drivers/net/ehea/ehea_qmr.c18
-rw-r--r--drivers/net/enc28j60.c18
-rw-r--r--drivers/net/enic/enic_main.c1
-rw-r--r--drivers/net/epic100.c21
-rw-r--r--drivers/net/fealnx.c21
-rw-r--r--drivers/net/forcedeth.c22
-rw-r--r--drivers/net/fs_enet/fs_enet-main.c1
-rw-r--r--drivers/net/gianfar.c31
-rw-r--r--drivers/net/hamachi.c1
-rw-r--r--drivers/net/hamradio/6pack.c3
-rw-r--r--drivers/net/hp-plus.c1
-rw-r--r--drivers/net/hp100.c32
-rw-r--r--drivers/net/hydra.c1
-rw-r--r--drivers/net/ibm_newemac/mal.c4
-rw-r--r--drivers/net/ibm_newemac/mal.h2
-rw-r--r--drivers/net/ibmveth.c20
-rw-r--r--drivers/net/ibmveth.h10
-rw-r--r--drivers/net/ipg.c23
-rw-r--r--drivers/net/irda/ali-ircc.c45
-rw-r--r--drivers/net/irda/ali-ircc.h1
-rw-r--r--drivers/net/irda/au1000_ircc.h1
-rw-r--r--drivers/net/irda/au1k_ir.c11
-rw-r--r--drivers/net/irda/donauboe.c8
-rw-r--r--drivers/net/irda/donauboe.h1
-rw-r--r--drivers/net/irda/irda-usb.c30
-rw-r--r--drivers/net/irda/irda-usb.h1
-rw-r--r--drivers/net/irda/kingsun-sir.c20
-rw-r--r--drivers/net/irda/ks959-sir.c22
-rw-r--r--drivers/net/irda/ksdazzle-sir.c26
-rw-r--r--drivers/net/irda/mcs7780.c49
-rw-r--r--drivers/net/irda/mcs7780.h2
-rw-r--r--drivers/net/irda/nsc-ircc.c45
-rw-r--r--drivers/net/irda/nsc-ircc.h1
-rw-r--r--drivers/net/irda/pxaficp_ir.c52
-rw-r--r--drivers/net/irda/sa1100_ir.c46
-rw-r--r--drivers/net/irda/sir-dev.h1
-rw-r--r--drivers/net/irda/sir_dev.c26
-rw-r--r--drivers/net/irda/smsc-ircc2.c38
-rw-r--r--drivers/net/irda/stir4200.c44
-rw-r--r--drivers/net/irda/via-ircc.c47
-rw-r--r--drivers/net/irda/via-ircc.h1
-rw-r--r--drivers/net/irda/vlsi_ir.c78
-rw-r--r--drivers/net/irda/vlsi_ir.h1
-rw-r--r--drivers/net/irda/w83977af_ir.c35
-rw-r--r--drivers/net/irda/w83977af_ir.h1
-rw-r--r--drivers/net/iseries_veth.c2
-rw-r--r--drivers/net/korina.c158
-rw-r--r--drivers/net/mac8390.c1
-rw-r--r--drivers/net/mlx4/en_netdev.c1
-rw-r--r--drivers/net/mlx4/en_params.c6
-rw-r--r--drivers/net/mlx4/en_tx.c59
-rw-r--r--drivers/net/mlx4/main.c4
-rw-r--r--drivers/net/mlx4/mlx4_en.h5
-rw-r--r--drivers/net/mlx4/profile.c6
-rw-r--r--drivers/net/natsemi.c29
-rw-r--r--drivers/net/ne-h8300.c1
-rw-r--r--drivers/net/ne2k-pci.c1
-rw-r--r--drivers/net/netxen/netxen_nic.h146
-rw-r--r--drivers/net/netxen/netxen_nic_ctx.c50
-rw-r--r--drivers/net/netxen/netxen_nic_ethtool.c31
-rw-r--r--drivers/net/netxen/netxen_nic_hw.c97
-rw-r--r--drivers/net/netxen/netxen_nic_init.c105
-rw-r--r--drivers/net/netxen/netxen_nic_main.c210
-rw-r--r--drivers/net/ns83820.c5
-rw-r--r--drivers/net/pasemi_mac.c6
-rw-r--r--drivers/net/pcnet32.c32
-rw-r--r--drivers/net/phy/phy_device.c9
-rw-r--r--drivers/net/plip.c13
-rw-r--r--drivers/net/ppp_generic.c43
-rw-r--r--drivers/net/qlge/qlge.h61
-rw-r--r--drivers/net/qlge/qlge_dbg.c62
-rw-r--r--drivers/net/qlge/qlge_main.c80
-rw-r--r--drivers/net/r6040.c62
-rw-r--r--drivers/net/sb1000.c16
-rw-r--r--drivers/net/sc92031.c1
-rw-r--r--drivers/net/sfc/falcon.c4
-rw-r--r--drivers/net/sfc/tenxpress.c5
-rw-r--r--drivers/net/sis190.c28
-rw-r--r--drivers/net/sis900.c9
-rw-r--r--drivers/net/slip.c28
-rw-r--r--drivers/net/slip.h2
-rw-r--r--drivers/net/smc-mca.c1
-rw-r--r--drivers/net/smc-ultra.c1
-rw-r--r--drivers/net/smsc911x.c4
-rw-r--r--drivers/net/smsc9420.c1
-rw-r--r--drivers/net/starfire.c34
-rw-r--r--drivers/net/sundance.c23
-rw-r--r--drivers/net/sungem.c22
-rw-r--r--drivers/net/sunhme.c26
-rw-r--r--drivers/net/sunvnet.c8
-rw-r--r--drivers/net/tehuti.c4
-rw-r--r--drivers/net/tlan.c26
-rw-r--r--drivers/net/tokenring/smctr.c2
-rw-r--r--drivers/net/tulip/de2104x.c19
-rw-r--r--drivers/net/tulip/de4x5.c20
-rw-r--r--drivers/net/tulip/dmfe.c62
-rw-r--r--drivers/net/tulip/tulip_core.c27
-rw-r--r--drivers/net/tulip/uli526x.c63
-rw-r--r--drivers/net/tulip/winbond-840.c23
-rw-r--r--drivers/net/tulip/xircom_cb.c43
-rw-r--r--drivers/net/typhoon.c22
-rw-r--r--drivers/net/ucc_geth.c128
-rw-r--r--drivers/net/ucc_geth.h114
-rw-r--r--drivers/net/usb/dm9601.c29
-rw-r--r--drivers/net/usb/hso.c12
-rw-r--r--drivers/net/usb/kaweth.c29
-rw-r--r--drivers/net/usb/pegasus.c33
-rw-r--r--drivers/net/via-rhine.c1
-rw-r--r--drivers/net/via-velocity.c1
-rw-r--r--drivers/net/virtio_net.c20
-rw-r--r--drivers/net/wan/ixp4xx_hss.c6
-rw-r--r--drivers/net/wd.c1
-rw-r--r--drivers/net/wimax/Kconfig17
-rw-r--r--drivers/net/wimax/Makefile5
-rw-r--r--drivers/net/wimax/i2400m/Kconfig49
-rw-r--r--drivers/net/wimax/i2400m/Makefile29
-rw-r--r--drivers/net/wimax/i2400m/control.c1291
-rw-r--r--drivers/net/wimax/i2400m/debug-levels.h45
-rw-r--r--drivers/net/wimax/i2400m/debugfs.c392
-rw-r--r--drivers/net/wimax/i2400m/driver.c728
-rw-r--r--drivers/net/wimax/i2400m/fw.c1095
-rw-r--r--drivers/net/wimax/i2400m/i2400m-sdio.h132
-rw-r--r--drivers/net/wimax/i2400m/i2400m-usb.h264
-rw-r--r--drivers/net/wimax/i2400m/i2400m.h755
-rw-r--r--drivers/net/wimax/i2400m/netdev.c524
-rw-r--r--drivers/net/wimax/i2400m/op-rfkill.c207
-rw-r--r--drivers/net/wimax/i2400m/rx.c534
-rw-r--r--drivers/net/wimax/i2400m/sdio-debug-levels.h22
-rw-r--r--drivers/net/wimax/i2400m/sdio-fw.c224
-rw-r--r--drivers/net/wimax/i2400m/sdio-rx.c255
-rw-r--r--drivers/net/wimax/i2400m/sdio-tx.c153
-rw-r--r--drivers/net/wimax/i2400m/sdio.c511
-rw-r--r--drivers/net/wimax/i2400m/tx.c817
-rw-r--r--drivers/net/wimax/i2400m/usb-debug-levels.h42
-rw-r--r--drivers/net/wimax/i2400m/usb-fw.c340
-rw-r--r--drivers/net/wimax/i2400m/usb-notif.c269
-rw-r--r--drivers/net/wimax/i2400m/usb-rx.c417
-rw-r--r--drivers/net/wimax/i2400m/usb-tx.c229
-rw-r--r--drivers/net/wimax/i2400m/usb.c597
-rw-r--r--drivers/net/wireless/Kconfig2
-rw-r--r--drivers/net/wireless/ath5k/base.c8
-rw-r--r--drivers/net/wireless/ath5k/dma.c2
-rw-r--r--drivers/net/wireless/ath5k/pcu.c4
-rw-r--r--drivers/net/wireless/ath5k/reg.h2
-rw-r--r--drivers/net/wireless/ath9k/Kconfig1
-rw-r--r--drivers/net/wireless/ath9k/main.c4
-rw-r--r--drivers/net/wireless/ath9k/xmit.c48
-rw-r--r--drivers/net/wireless/atmel.c2
-rw-r--r--drivers/net/wireless/b43/main.c2
-rw-r--r--drivers/net/wireless/b43legacy/main.c2
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2100.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-commands.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-hcmd.c1
-rw-r--r--drivers/net/wireless/libertas/main.c7
-rw-r--r--drivers/net/wireless/libertas_tf/main.c2
-rw-r--r--drivers/net/wireless/orinoco/orinoco.c28
-rw-r--r--drivers/net/wireless/orinoco/orinoco_cs.c1
-rw-r--r--drivers/net/wireless/p54/p54common.c34
-rw-r--r--drivers/net/wireless/p54/p54usb.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c23
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00crypto.c4
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c8
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00leds.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00lib.h11
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00queue.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00usb.c6
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c1
-rw-r--r--drivers/net/wireless/rtl818x/rtl8180_dev.c1
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187_dev.c5
-rw-r--r--drivers/net/wireless/strip.c2
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c2
-rw-r--r--drivers/net/xen-netfront.c17
-rw-r--r--drivers/net/yellowfin.c1
-rw-r--r--drivers/net/zorro8390.c1
-rw-r--r--drivers/of/of_i2c.c19
-rw-r--r--drivers/oprofile/buffer_sync.c188
-rw-r--r--drivers/oprofile/cpu_buffer.c316
-rw-r--r--drivers/oprofile/cpu_buffer.h89
-rw-r--r--drivers/oprofile/event_buffer.c4
-rw-r--r--drivers/oprofile/oprof.c4
-rw-r--r--drivers/oprofile/oprof.h8
-rw-r--r--drivers/oprofile/oprofile_files.c27
-rw-r--r--drivers/parisc/asp.c3
-rw-r--r--drivers/parisc/ccio-dma.c4
-rw-r--r--drivers/parisc/dino.c8
-rw-r--r--drivers/parisc/hppb.c2
-rw-r--r--drivers/parisc/iosapic.c3
-rw-r--r--drivers/parisc/lasi.c5
-rw-r--r--drivers/parisc/lba_pci.c2
-rw-r--r--drivers/parisc/sba_iommu.c9
-rw-r--r--drivers/parisc/superio.c1
-rw-r--r--drivers/parisc/wax.c3
-rw-r--r--drivers/pci/Kconfig9
-rw-r--r--drivers/pci/Makefile2
-rw-r--r--drivers/pci/access.c226
-rw-r--r--drivers/pci/bus.c87
-rw-r--r--drivers/pci/hotplug/Makefile3
-rw-r--r--drivers/pci/hotplug/acpi_pcihp.c70
-rw-r--r--drivers/pci/hotplug/acpiphp.h2
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c119
-rw-r--r--drivers/pci/hotplug/acpiphp_ibm.c2
-rw-r--r--drivers/pci/hotplug/cpqphp_ctrl.c6
-rw-r--r--drivers/pci/hotplug/cpqphp_pci.c2
-rw-r--r--drivers/pci/hotplug/fakephp.c1
-rw-r--r--drivers/pci/hotplug/pciehp.h16
-rw-r--r--drivers/pci/hotplug/pciehp_acpi.c141
-rw-r--r--drivers/pci/hotplug/pciehp_core.c1
-rw-r--r--drivers/pci/hotplug/pciehp_ctrl.c26
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c329
-rw-r--r--drivers/pci/intel-iommu.c3
-rw-r--r--drivers/pci/irq.c2
-rw-r--r--drivers/pci/msi.c31
-rw-r--r--drivers/pci/pci-acpi.c84
-rw-r--r--drivers/pci/pci-driver.c420
-rw-r--r--drivers/pci/pci-stub.c47
-rw-r--r--drivers/pci/pci-sysfs.c107
-rw-r--r--drivers/pci/pci.c505
-rw-r--r--drivers/pci/pci.h34
-rw-r--r--drivers/pci/pcie/aer/aerdrv_acpi.c1
-rw-r--r--drivers/pci/pcie/aer/aerdrv_errprint.c2
-rw-r--r--drivers/pci/pcie/aspm.c165
-rw-r--r--drivers/pci/pcie/portdrv_bus.c32
-rw-r--r--drivers/pci/pcie/portdrv_core.c240
-rw-r--r--drivers/pci/pcie/portdrv_pci.c21
-rw-r--r--drivers/pci/probe.c48
-rw-r--r--drivers/pci/proc.c18
-rw-r--r--drivers/pci/quirks.c112
-rw-r--r--drivers/pci/setup-bus.c5
-rw-r--r--drivers/pci/setup-res.c24
-rw-r--r--drivers/pci/syscall.c12
-rw-r--r--drivers/pcmcia/electra_cf.c2
-rw-r--r--drivers/platform/Kconfig5
-rw-r--r--drivers/platform/Makefile5
-rw-r--r--drivers/platform/x86/Kconfig398
-rw-r--r--drivers/platform/x86/Makefile20
-rw-r--r--drivers/platform/x86/acer-wmi.c (renamed from drivers/misc/acer-wmi.c)0
-rw-r--r--drivers/platform/x86/asus-laptop.c (renamed from drivers/misc/asus-laptop.c)0
-rw-r--r--drivers/platform/x86/asus_acpi.c (renamed from drivers/acpi/asus_acpi.c)0
-rw-r--r--drivers/platform/x86/compal-laptop.c (renamed from drivers/misc/compal-laptop.c)0
-rw-r--r--drivers/platform/x86/dell-laptop.c436
-rw-r--r--drivers/platform/x86/eeepc-laptop.c (renamed from drivers/misc/eeepc-laptop.c)4
-rw-r--r--drivers/platform/x86/fujitsu-laptop.c (renamed from drivers/misc/fujitsu-laptop.c)419
-rw-r--r--drivers/platform/x86/hp-wmi.c (renamed from drivers/misc/hp-wmi.c)15
-rw-r--r--drivers/platform/x86/intel_menlow.c (renamed from drivers/misc/intel_menlow.c)0
-rw-r--r--drivers/platform/x86/msi-laptop.c (renamed from drivers/misc/msi-laptop.c)0
-rw-r--r--drivers/platform/x86/panasonic-laptop.c (renamed from drivers/misc/panasonic-laptop.c)22
-rw-r--r--drivers/platform/x86/sony-laptop.c (renamed from drivers/misc/sony-laptop.c)15
-rw-r--r--drivers/platform/x86/tc1100-wmi.c (renamed from drivers/misc/tc1100-wmi.c)1
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c (renamed from drivers/misc/thinkpad_acpi.c)911
-rw-r--r--drivers/platform/x86/toshiba_acpi.c (renamed from drivers/acpi/toshiba_acpi.c)0
-rw-r--r--drivers/platform/x86/wmi.c (renamed from drivers/acpi/wmi.c)0
-rw-r--r--drivers/pnp/pnpacpi/core.c1
-rw-r--r--drivers/power/Kconfig6
-rw-r--r--drivers/power/Makefile1
-rw-r--r--drivers/power/pcf50633-charger.c358
-rw-r--r--drivers/ps3/ps3-lpm.c16
-rw-r--r--drivers/ps3/ps3-vuart.c32
-rw-r--r--drivers/ps3/ps3stor_lib.c14
-rw-r--r--drivers/regulator/Kconfig7
-rw-r--r--drivers/regulator/Makefile1
-rw-r--r--drivers/regulator/core.c474
-rw-r--r--drivers/regulator/da903x.c12
-rw-r--r--drivers/regulator/pcf50633-regulator.c329
-rw-r--r--drivers/regulator/wm8350-regulator.c91
-rw-r--r--drivers/regulator/wm8400-regulator.c2
-rw-r--r--drivers/rtc/Kconfig7
-rw-r--r--drivers/rtc/Makefile1
-rw-r--r--drivers/rtc/rtc-ds1307.c154
-rw-r--r--drivers/rtc/rtc-ds1511.c2
-rw-r--r--drivers/rtc/rtc-parisc.c3
-rw-r--r--drivers/rtc/rtc-pcf50633.c344
-rw-r--r--drivers/rtc/rtc-pxa.c2
-rw-r--r--drivers/rtc/rtc-stk17ta8.c2
-rw-r--r--drivers/rtc/rtc-twl4030.c49
-rw-r--r--drivers/s390/block/dasd.c21
-rw-r--r--drivers/s390/block/dasd_3990_erp.c2
-rw-r--r--drivers/s390/block/dasd_devmap.c48
-rw-r--r--drivers/s390/block/dasd_diag.c3
-rw-r--r--drivers/s390/block/dasd_eckd.c3
-rw-r--r--drivers/s390/block/dasd_eer.c4
-rw-r--r--drivers/s390/block/dasd_fba.c3
-rw-r--r--drivers/s390/block/dasd_int.h2
-rw-r--r--drivers/s390/char/Kconfig2
-rw-r--r--drivers/s390/char/tape_3590.c2
-rw-r--r--drivers/s390/char/vmlogrdr.c4
-rw-r--r--drivers/s390/cio/cio.c2
-rw-r--r--drivers/s390/cio/qdio_debug.c2
-rw-r--r--drivers/s390/cio/qdio_main.c2
-rw-r--r--drivers/s390/net/qeth_l2_main.c27
-rw-r--r--drivers/s390/net/qeth_l3_main.c69
-rw-r--r--drivers/sbus/char/display7seg.c2
-rw-r--r--drivers/scsi/Kconfig1
-rw-r--r--drivers/scsi/NCR_D700.c2
-rw-r--r--drivers/scsi/a100u2w.c2
-rw-r--r--drivers/scsi/a2091.c18
-rw-r--r--drivers/scsi/advansys.c2
-rw-r--r--drivers/scsi/aic94xx/aic94xx_tmf.c2
-rw-r--r--drivers/scsi/cxgb3i/cxgb3i_ddp.c1
-rw-r--r--drivers/scsi/gvp11.c8
-rw-r--r--drivers/scsi/hosts.c6
-rw-r--r--drivers/scsi/ibmvscsi/ibmvfc.c28
-rw-r--r--drivers/scsi/ibmvscsi/ibmvfc.h6
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.c28
-rw-r--r--drivers/scsi/ipr.c4
-rw-r--r--drivers/scsi/ipr.h2
-rw-r--r--drivers/scsi/lasi700.c3
-rw-r--r--drivers/scsi/libiscsi_tcp.c3
-rw-r--r--drivers/scsi/libsas/sas_discover.c2
-rw-r--r--drivers/scsi/libsas/sas_dump.c2
-rw-r--r--drivers/scsi/libsas/sas_host_smp.c12
-rw-r--r--drivers/scsi/libsas/sas_port.c2
-rw-r--r--drivers/scsi/libsas/sas_scsi_host.c2
-rw-r--r--drivers/scsi/lpfc/lpfc_hbadisc.c4
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c3
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c10
-rw-r--r--drivers/scsi/megaraid.c4
-rw-r--r--drivers/scsi/mvsas.c2
-rw-r--r--drivers/scsi/pcmcia/aha152x_stub.c2
-rw-r--r--drivers/scsi/ps3rom.c6
-rw-r--r--drivers/scsi/qla1280.c4
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c26
-rw-r--r--drivers/scsi/qla2xxx/qla_dbg.c462
-rw-r--r--drivers/scsi/qla2xxx/qla_dbg.h40
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h33
-rw-r--r--drivers/scsi/qla2xxx/qla_dfs.c3
-rw-r--r--drivers/scsi/qla2xxx/qla_fw.h294
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h10
-rw-r--r--drivers/scsi/qla2xxx/qla_gs.c9
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c353
-rw-r--r--drivers/scsi/qla2xxx/qla_iocb.c12
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c82
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c41
-rw-r--r--drivers/scsi/qla2xxx/qla_mid.c5
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c146
-rw-r--r--drivers/scsi/qla2xxx/qla_sup.c263
-rw-r--r--drivers/scsi/qla2xxx/qla_version.h6
-rw-r--r--drivers/scsi/qla4xxx/ql4_mbx.c2
-rw-r--r--drivers/scsi/raid_class.c3
-rw-r--r--drivers/scsi/scsi.c9
-rw-r--r--drivers/scsi/scsi_debug.c4
-rw-r--r--drivers/scsi/scsi_devinfo.c1
-rw-r--r--drivers/scsi/scsi_error.c26
-rw-r--r--drivers/scsi/scsi_ioctl.c9
-rw-r--r--drivers/scsi/scsi_lib.c119
-rw-r--r--drivers/scsi/scsi_scan.c10
-rw-r--r--drivers/scsi/scsi_sysfs.c12
-rw-r--r--drivers/scsi/scsi_transport_fc.c39
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c11
-rw-r--r--drivers/scsi/scsi_transport_sas.c42
-rw-r--r--drivers/scsi/scsi_transport_srp.c2
-rw-r--r--drivers/scsi/sd.c109
-rw-r--r--drivers/scsi/sd_dif.c17
-rw-r--r--drivers/scsi/ses.c2
-rw-r--r--drivers/scsi/sg.c2
-rw-r--r--drivers/scsi/sgiwd93.c3
-rw-r--r--drivers/scsi/sim710.c4
-rw-r--r--drivers/scsi/sni_53c710.c3
-rw-r--r--drivers/scsi/st.c492
-rw-r--r--drivers/scsi/st.h14
-rw-r--r--drivers/scsi/zalon.c4
-rw-r--r--drivers/serial/8250.c4
-rw-r--r--drivers/serial/8250_pci.c8
-rw-r--r--drivers/serial/8250_pnp.c2
-rw-r--r--drivers/serial/Kconfig21
-rw-r--r--drivers/serial/Makefile1
-rw-r--r--drivers/serial/atmel_serial.c2
-rw-r--r--drivers/serial/crisv10.c4
-rw-r--r--drivers/serial/jsm/jsm_neo.c3
-rw-r--r--drivers/serial/nwpserial.c475
-rw-r--r--drivers/serial/of_serial.c20
-rw-r--r--drivers/serial/pnx8xxx_uart.c23
-rw-r--r--drivers/spi/atmel_spi.c3
-rw-r--r--drivers/spi/spi_lm70llp.c33
-rw-r--r--drivers/spi/xilinx_spi.c137
-rw-r--r--drivers/staging/comedi/drivers.c2
-rw-r--r--drivers/staging/epl/Edrv8139.c60
-rw-r--r--drivers/staging/epl/EplSdoAsySequ.c2
-rw-r--r--drivers/staging/frontier/alphatrack.c12
-rw-r--r--drivers/staging/frontier/tranzport.c22
-rw-r--r--drivers/staging/go7007/go7007-v4l2.c3
-rw-r--r--drivers/staging/meilhaus/me0600_ext_irq.c4
-rw-r--r--drivers/staging/meilhaus/me1400_ext_irq.c2
-rw-r--r--drivers/staging/meilhaus/me1600_ao.c4
-rw-r--r--drivers/staging/meilhaus/me4600_ai.c8
-rw-r--r--drivers/staging/meilhaus/me4600_ao.c6
-rw-r--r--drivers/staging/meilhaus/me4600_ext_irq.c2
-rw-r--r--drivers/staging/meilhaus/me6000_ao.c20
-rw-r--r--drivers/staging/meilhaus/me8100_di.c6
-rw-r--r--drivers/staging/meilhaus/me8200_di.c4
-rw-r--r--drivers/staging/meilhaus/me8200_do.c2
-rw-r--r--drivers/staging/meilhaus/medebug.h10
-rw-r--r--drivers/staging/otus/80211core/cagg.c2
-rw-r--r--drivers/staging/otus/80211core/pub_zfw.h2
-rw-r--r--drivers/staging/otus/80211core/struct.h2
-rw-r--r--drivers/staging/otus/oal_marc.h12
-rw-r--r--drivers/staging/rt2860/2860_main_dev.c2
-rw-r--r--drivers/staging/rt2860/common/ba_action.c18
-rw-r--r--drivers/staging/rt2860/common/cmm_data.c2
-rw-r--r--drivers/staging/rt2860/common/cmm_data_2860.c6
-rw-r--r--drivers/staging/rt2860/common/cmm_info.c2
-rw-r--r--drivers/staging/rt2860/common/dfs.c4
-rw-r--r--drivers/staging/rt2860/common/rtmp_init.c18
-rw-r--r--drivers/staging/rt2860/common/spectrum.c44
-rw-r--r--drivers/staging/rt2860/rt_ate.c32
-rw-r--r--drivers/staging/rt2860/rt_linux.c18
-rw-r--r--drivers/staging/rt2860/rt_linux.h2
-rw-r--r--drivers/staging/rt2860/rt_profile.c12
-rw-r--r--drivers/staging/rt2860/rtmp_def.h2
-rw-r--r--drivers/staging/rt2860/sta_ioctl.c36
-rw-r--r--drivers/staging/rt2870/2870_main_dev.c6
-rw-r--r--drivers/staging/rt2870/common/2870_rtmp_init.c4
-rw-r--r--drivers/staging/rt2870/common/ba_action.c18
-rw-r--r--drivers/staging/rt2870/common/cmm_data.c2
-rw-r--r--drivers/staging/rt2870/common/cmm_info.c2
-rw-r--r--drivers/staging/rt2870/common/dfs.c4
-rw-r--r--drivers/staging/rt2870/common/rtmp_init.c20
-rw-r--r--drivers/staging/rt2870/common/rtusb_bulk.c4
-rw-r--r--drivers/staging/rt2870/common/spectrum.c44
-rw-r--r--drivers/staging/rt2870/rt_ate.c30
-rw-r--r--drivers/staging/rt2870/rt_linux.c18
-rw-r--r--drivers/staging/rt2870/rt_linux.h2
-rw-r--r--drivers/staging/rt2870/rt_main_dev.c2
-rw-r--r--drivers/staging/rt2870/rt_profile.c12
-rw-r--r--drivers/staging/rt2870/rtmp_def.h2
-rw-r--r--drivers/staging/rt2870/sta_ioctl.c36
-rw-r--r--drivers/staging/rt2870/tmp6036
-rw-r--r--drivers/staging/rt2870/tmp6136
-rw-r--r--drivers/staging/rtl8187se/ieee80211.h2
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211.h2
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c2
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c2
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c2
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c2
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c8
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c2
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c8
-rw-r--r--drivers/staging/rtl8187se/r8180_core.c12
-rw-r--r--drivers/staging/rtl8187se/r8180_rtl8225z2.c4
-rw-r--r--drivers/staging/rtl8187se/r8180_wx.c14
-rw-r--r--drivers/usb/Kconfig2
-rw-r--r--drivers/usb/class/cdc-acm.c2
-rw-r--r--drivers/usb/class/cdc-wdm.c3
-rw-r--r--drivers/usb/class/usbtmc.c9
-rw-r--r--drivers/usb/core/devio.c7
-rw-r--r--drivers/usb/core/driver.c181
-rw-r--r--drivers/usb/core/endpoint.c4
-rw-r--r--drivers/usb/core/generic.c10
-rw-r--r--drivers/usb/core/hcd-pci.c201
-rw-r--r--drivers/usb/core/hcd.c20
-rw-r--r--drivers/usb/core/hcd.h16
-rw-r--r--drivers/usb/core/hub.c144
-rw-r--r--drivers/usb/core/message.c164
-rw-r--r--drivers/usb/core/sysfs.c49
-rw-r--r--drivers/usb/core/urb.c43
-rw-r--r--drivers/usb/core/usb.c79
-rw-r--r--drivers/usb/core/usb.h24
-rw-r--r--drivers/usb/gadget/Kconfig43
-rw-r--r--drivers/usb/gadget/Makefile2
-rw-r--r--drivers/usb/gadget/ci13xxx_udc.c2830
-rw-r--r--drivers/usb/gadget/ci13xxx_udc.h195
-rw-r--r--drivers/usb/gadget/epautoconf.c2
-rw-r--r--drivers/usb/gadget/f_phonet.c12
-rw-r--r--drivers/usb/gadget/file_storage.c177
-rw-r--r--drivers/usb/gadget/fsl_qe_udc.c12
-rw-r--r--drivers/usb/gadget/gadget_chips.h8
-rw-r--r--drivers/usb/gadget/goku_udc.c2
-rw-r--r--drivers/usb/gadget/imx_udc.c1516
-rw-r--r--drivers/usb/gadget/imx_udc.h344
-rw-r--r--drivers/usb/gadget/m66592-udc.c9
-rw-r--r--drivers/usb/gadget/net2280.c2
-rw-r--r--drivers/usb/gadget/omap_udc.c4
-rw-r--r--drivers/usb/gadget/pxa25x_udc.c2
-rw-r--r--drivers/usb/gadget/pxa27x_udc.c2
-rw-r--r--drivers/usb/gadget/s3c2410_udc.c34
-rw-r--r--drivers/usb/gadget/u_ether.c16
-rw-r--r--drivers/usb/host/Kconfig13
-rw-r--r--drivers/usb/host/Makefile1
-rw-r--r--drivers/usb/host/ehci-dbg.c8
-rw-r--r--drivers/usb/host/ehci-hub.c27
-rw-r--r--drivers/usb/host/ehci-pci.c12
-rw-r--r--drivers/usb/host/ehci-ppc-of.c45
-rw-r--r--drivers/usb/host/ehci.h34
-rw-r--r--drivers/usb/host/isp1760-hcd.c13
-rw-r--r--drivers/usb/host/isp1760-hcd.h1
-rw-r--r--drivers/usb/host/isp1760-if.c116
-rw-r--r--drivers/usb/host/ohci-hcd.c12
-rw-r--r--drivers/usb/host/ohci-pci.c6
-rw-r--r--drivers/usb/host/ohci-pnx4008.c85
-rw-r--r--drivers/usb/host/ohci-ppc-of.c25
-rw-r--r--drivers/usb/host/ohci-tmio.c2
-rw-r--r--drivers/usb/host/oxu210hp-hcd.c3985
-rw-r--r--drivers/usb/host/oxu210hp.h447
-rw-r--r--drivers/usb/host/pci-quirks.c14
-rw-r--r--drivers/usb/host/r8a66597-hcd.c8
-rw-r--r--drivers/usb/host/uhci-hcd.c2
-rw-r--r--drivers/usb/image/microtek.c11
-rw-r--r--drivers/usb/misc/berry_charge.c5
-rw-r--r--drivers/usb/misc/emi26.c2
-rw-r--r--drivers/usb/misc/usbtest.c2
-rw-r--r--drivers/usb/mon/Kconfig13
-rw-r--r--drivers/usb/mon/Makefile3
-rw-r--r--drivers/usb/musb/Kconfig12
-rw-r--r--drivers/usb/musb/Makefile8
-rw-r--r--drivers/usb/musb/blackfin.c320
-rw-r--r--drivers/usb/musb/blackfin.h52
-rw-r--r--drivers/usb/musb/davinci.c18
-rw-r--r--drivers/usb/musb/musb_core.c84
-rw-r--r--drivers/usb/musb/musb_core.h73
-rw-r--r--drivers/usb/musb/musb_gadget.c2
-rw-r--r--drivers/usb/musb/musb_host.c45
-rw-r--r--drivers/usb/musb/musb_io.h26
-rw-r--r--drivers/usb/musb/musb_regs.h397
-rw-r--r--drivers/usb/musb/musbhsdma.c84
-rw-r--r--drivers/usb/musb/musbhsdma.h149
-rw-r--r--drivers/usb/musb/omap2430.c15
-rw-r--r--drivers/usb/musb/tusb6010.c7
-rw-r--r--drivers/usb/otg/Kconfig54
-rw-r--r--drivers/usb/otg/Makefile15
-rw-r--r--drivers/usb/otg/gpio_vbus.c335
-rw-r--r--drivers/usb/otg/isp1301_omap.c (renamed from drivers/i2c/chips/isp1301_omap.c)0
-rw-r--r--drivers/usb/otg/otg.c65
-rw-r--r--drivers/usb/otg/twl4030-usb.c721
-rw-r--r--drivers/usb/serial/Kconfig17
-rw-r--r--drivers/usb/serial/Makefile2
-rw-r--r--drivers/usb/serial/digi_acceleport.c28
-rw-r--r--drivers/usb/serial/ftdi_sio.c2
-rw-r--r--drivers/usb/serial/garmin_gps.c2
-rw-r--r--drivers/usb/serial/ipw.c4
-rw-r--r--drivers/usb/serial/iuu_phoenix.c38
-rw-r--r--drivers/usb/serial/mos7840.c38
-rw-r--r--drivers/usb/serial/opticon.c358
-rw-r--r--drivers/usb/serial/option.c11
-rw-r--r--drivers/usb/serial/siemens_mpi.c77
-rw-r--r--drivers/usb/serial/spcp8x5.c20
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c73
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.h8
-rw-r--r--drivers/usb/serial/usb-serial.c3
-rw-r--r--drivers/usb/serial/usb_debug.c2
-rw-r--r--drivers/usb/storage/Kconfig11
-rw-r--r--drivers/usb/storage/Makefile3
-rw-r--r--drivers/usb/storage/dpcm.c86
-rw-r--r--drivers/usb/storage/dpcm.h32
-rw-r--r--drivers/usb/storage/libusual.c7
-rw-r--r--drivers/usb/storage/option_ms.c147
-rw-r--r--drivers/usb/storage/option_ms.h4
-rw-r--r--drivers/usb/storage/protocol.c24
-rw-r--r--drivers/usb/storage/protocol.h3
-rw-r--r--drivers/usb/storage/scsiglue.c43
-rw-r--r--drivers/usb/storage/sddr09.c43
-rw-r--r--drivers/usb/storage/sddr09.h5
-rw-r--r--drivers/usb/storage/transport.c219
-rw-r--r--drivers/usb/storage/transport.h2
-rw-r--r--drivers/usb/storage/unusual_devs.h354
-rw-r--r--drivers/usb/storage/usb.c106
-rw-r--r--drivers/usb/storage/usb.h5
-rw-r--r--drivers/usb/wusbcore/rh.c2
-rw-r--r--drivers/uwb/i1480/dfu/usb.c2
-rw-r--r--drivers/uwb/i1480/i1480u-wlp/i1480u-wlp.h2
-rw-r--r--drivers/uwb/i1480/i1480u-wlp/lc.c17
-rw-r--r--drivers/uwb/i1480/i1480u-wlp/netdev.c9
-rw-r--r--drivers/uwb/i1480/i1480u-wlp/rx.c8
-rw-r--r--drivers/uwb/i1480/i1480u-wlp/tx.c6
-rw-r--r--drivers/video/Makefile4
-rw-r--r--drivers/video/amba-clcd.c1
-rw-r--r--drivers/video/amifb.c6
-rw-r--r--drivers/video/atafb.c112
-rw-r--r--drivers/video/backlight/Kconfig15
-rw-r--r--drivers/video/backlight/Makefile2
-rw-r--r--drivers/video/backlight/backlight.c73
-rw-r--r--drivers/video/backlight/corgi_bl.c169
-rw-r--r--drivers/video/backlight/cr_bllcd.c18
-rw-r--r--drivers/video/backlight/generic_bl.c147
-rw-r--r--drivers/video/backlight/hp680_bl.c20
-rw-r--r--drivers/video/backlight/mbp_nvidia_bl.c1
-rw-r--r--drivers/video/backlight/progear_bl.c20
-rw-r--r--drivers/video/backlight/tdo24m.c94
-rw-r--r--drivers/video/backlight/tosa_lcd.c27
-rw-r--r--drivers/video/backlight/vgg2432a4.c2
-rw-r--r--drivers/video/bf54x-lq043fb.c15
-rw-r--r--drivers/video/bfin-t350mcqb-fb.c15
-rw-r--r--drivers/video/c2p.c232
-rw-r--r--drivers/video/c2p.h11
-rw-r--r--drivers/video/c2p_core.h153
-rw-r--r--drivers/video/c2p_iplan2.c153
-rw-r--r--drivers/video/c2p_planar.c156
-rw-r--r--drivers/video/console/fbcon.c38
-rw-r--r--drivers/video/console/vgacon.c2
-rw-r--r--drivers/video/ps3fb.c4
-rw-r--r--drivers/w1/masters/Kconfig6
-rw-r--r--drivers/w1/masters/Makefile2
-rw-r--r--drivers/w1/masters/mxc_w1.c211
-rw-r--r--drivers/w1/w1.h1
-rw-r--r--drivers/w1/w1_io.c26
-rw-r--r--drivers/w1/w1_netlink.c261
-rw-r--r--drivers/w1/w1_netlink.h16
-rw-r--r--drivers/watchdog/Kconfig14
-rw-r--r--drivers/watchdog/Makefile2
-rw-r--r--drivers/watchdog/gef_wdt.c330
-rw-r--r--drivers/watchdog/pika_wdt.c301
-rw-r--r--drivers/watchdog/wm8350_wdt.c6
-rw-r--r--drivers/xen/Kconfig24
-rw-r--r--drivers/xen/Makefile2
-rw-r--r--drivers/xen/xenbus/xenbus_client.c3
-rw-r--r--drivers/xen/xenbus/xenbus_probe.c28
-rw-r--r--drivers/xen/xenbus/xenbus_xs.c1
-rw-r--r--drivers/xen/xenfs/Makefile3
-rw-r--r--drivers/xen/xenfs/super.c64
-rw-r--r--drivers/xen/xenfs/xenbus.c593
-rw-r--r--drivers/xen/xenfs/xenfs.h6
-rw-r--r--drivers/zorro/.gitignore2
-rw-r--r--drivers/zorro/zorro-sysfs.c20
-rw-r--r--drivers/zorro/zorro.c23
-rw-r--r--drivers/zorro/zorro.h2
1234 files changed, 68448 insertions, 24539 deletions
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 2f557f570ade..00cf9553f740 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -107,4 +107,6 @@ source "drivers/uio/Kconfig"
107source "drivers/xen/Kconfig" 107source "drivers/xen/Kconfig"
108 108
109source "drivers/staging/Kconfig" 109source "drivers/staging/Kconfig"
110
111source "drivers/platform/Kconfig"
110endmenu 112endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index fceb71a741c3..c1bf41737936 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -18,6 +18,9 @@ obj-$(CONFIG_ARM_AMBA) += amba/
18 18
19obj-$(CONFIG_XEN) += xen/ 19obj-$(CONFIG_XEN) += xen/
20 20
21# regulators early, since some subsystems rely on them to initialize
22obj-$(CONFIG_REGULATOR) += regulator/
23
21# char/ comes before serial/ etc so that the VT console is the boot-time 24# char/ comes before serial/ etc so that the VT console is the boot-time
22# default. 25# default.
23obj-y += char/ 26obj-y += char/
@@ -57,6 +60,7 @@ obj-$(CONFIG_ATA_OVER_ETH) += block/aoe/
57obj-$(CONFIG_PARIDE) += block/paride/ 60obj-$(CONFIG_PARIDE) += block/paride/
58obj-$(CONFIG_TC) += tc/ 61obj-$(CONFIG_TC) += tc/
59obj-$(CONFIG_UWB) += uwb/ 62obj-$(CONFIG_UWB) += uwb/
63obj-$(CONFIG_USB_OTG_UTILS) += usb/otg/
60obj-$(CONFIG_USB) += usb/ 64obj-$(CONFIG_USB) += usb/
61obj-$(CONFIG_USB_MUSB_HDRC) += usb/musb/ 65obj-$(CONFIG_USB_MUSB_HDRC) += usb/musb/
62obj-$(CONFIG_PCI) += usb/ 66obj-$(CONFIG_PCI) += usb/
@@ -100,5 +104,5 @@ obj-$(CONFIG_PPC_PS3) += ps3/
100obj-$(CONFIG_OF) += of/ 104obj-$(CONFIG_OF) += of/
101obj-$(CONFIG_SSB) += ssb/ 105obj-$(CONFIG_SSB) += ssb/
102obj-$(CONFIG_VIRTIO) += virtio/ 106obj-$(CONFIG_VIRTIO) += virtio/
103obj-$(CONFIG_REGULATOR) += regulator/
104obj-$(CONFIG_STAGING) += staging/ 107obj-$(CONFIG_STAGING) += staging/
108obj-y += platform/
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index b0243fd55ac0..d7f9839ba264 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -196,90 +196,6 @@ config ACPI_NUMA
196 depends on (X86 || IA64) 196 depends on (X86 || IA64)
197 default y if IA64_GENERIC || IA64_SGI_SN2 197 default y if IA64_GENERIC || IA64_SGI_SN2
198 198
199config ACPI_WMI
200 tristate "WMI (EXPERIMENTAL)"
201 depends on X86
202 depends on EXPERIMENTAL
203 help
204 This driver adds support for the ACPI-WMI (Windows Management
205 Instrumentation) mapper device (PNP0C14) found on some systems.
206
207 ACPI-WMI is a proprietary extension to ACPI to expose parts of the
208 ACPI firmware to userspace - this is done through various vendor
209 defined methods and data blocks in a PNP0C14 device, which are then
210 made available for userspace to call.
211
212 The implementation of this in Linux currently only exposes this to
213 other kernel space drivers.
214
215 This driver is a required dependency to build the firmware specific
216 drivers needed on many machines, including Acer and HP laptops.
217
218 It is safe to enable this driver even if your DSDT doesn't define
219 any ACPI-WMI devices.
220
221config ACPI_ASUS
222 tristate "ASUS/Medion Laptop Extras"
223 depends on X86
224 select BACKLIGHT_CLASS_DEVICE
225 ---help---
226 This driver provides support for extra features of ACPI-compatible
227 ASUS laptops. As some of Medion laptops are made by ASUS, it may also
228 support some Medion laptops (such as 9675 for example). It makes all
229 the extra buttons generate standard ACPI events that go through
230 /proc/acpi/events, and (on some models) adds support for changing the
231 display brightness and output, switching the LCD backlight on and off,
232 and most importantly, allows you to blink those fancy LEDs intended
233 for reporting mail and wireless status.
234
235 Note: display switching code is currently considered EXPERIMENTAL,
236 toying with these values may even lock your machine.
237
238 All settings are changed via /proc/acpi/asus directory entries. Owner
239 and group for these entries can be set with asus_uid and asus_gid
240 parameters.
241
242 More information and a userspace daemon for handling the extra buttons
243 at <http://sourceforge.net/projects/acpi4asus/>.
244
245 If you have an ACPI-compatible ASUS laptop, say Y or M here. This
246 driver is still under development, so if your laptop is unsupported or
247 something works not quite as expected, please use the mailing list
248 available on the above page (acpi4asus-user@lists.sourceforge.net).
249
250 NOTE: This driver is deprecated and will probably be removed soon,
251 use asus-laptop instead.
252
253config ACPI_TOSHIBA
254 tristate "Toshiba Laptop Extras"
255 depends on X86 && INPUT
256 select INPUT_POLLDEV
257 select NET
258 select RFKILL
259 select BACKLIGHT_CLASS_DEVICE
260 ---help---
261 This driver adds support for access to certain system settings
262 on "legacy free" Toshiba laptops. These laptops can be recognized by
263 their lack of a BIOS setup menu and APM support.
264
265 On these machines, all system configuration is handled through the
266 ACPI. This driver is required for access to controls not covered
267 by the general ACPI drivers, such as LCD brightness, video output,
268 etc.
269
270 This driver differs from the non-ACPI Toshiba laptop driver (located
271 under "Processor type and features") in several aspects.
272 Configuration is accessed by reading and writing text files in the
273 /proc tree instead of by program interface to /dev. Furthermore, no
274 power management functions are exposed, as those are handled by the
275 general ACPI drivers.
276
277 More information about this driver is available at
278 <http://memebeam.org/toys/ToshibaAcpiDriver>.
279
280 If you have a legacy free Toshiba laptop (such as the Libretto L1
281 series), say Y.
282
283config ACPI_CUSTOM_DSDT_FILE 199config ACPI_CUSTOM_DSDT_FILE
284 string "Custom DSDT Table file to include" 200 string "Custom DSDT Table file to include"
285 default "" 201 default ""
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 3c0c93300f12..65d90c720b5a 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -2,15 +2,8 @@
2# Makefile for the Linux ACPI interpreter 2# Makefile for the Linux ACPI interpreter
3# 3#
4 4
5export ACPI_CFLAGS 5ccflags-y := -Os
6 6ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT
7ACPI_CFLAGS := -Os
8
9ifdef CONFIG_ACPI_DEBUG
10 ACPI_CFLAGS += -DACPI_DEBUG_OUTPUT
11endif
12
13EXTRA_CFLAGS += $(ACPI_CFLAGS)
14 7
15# 8#
16# ACPI Boot-Time Table Parsing 9# ACPI Boot-Time Table Parsing
@@ -22,9 +15,13 @@ obj-$(CONFIG_X86) += blacklist.o
22# ACPI Core Subsystem (Interpreter) 15# ACPI Core Subsystem (Interpreter)
23# 16#
24obj-y += osl.o utils.o reboot.o\ 17obj-y += osl.o utils.o reboot.o\
25 dispatcher/ events/ executer/ hardware/ \ 18 acpica/
26 namespace/ parser/ resources/ tables/ \ 19
27 utilities/ 20# sleep related files
21obj-y += wakeup.o
22obj-y += sleep.o
23obj-$(CONFIG_ACPI_SLEEP) += proc.o
24
28 25
29# 26#
30# ACPI Bus and Device Drivers 27# ACPI Bus and Device Drivers
@@ -35,7 +32,6 @@ ifdef CONFIG_CPU_FREQ
35processor-objs += processor_perflib.o 32processor-objs += processor_perflib.o
36endif 33endif
37 34
38obj-y += sleep/
39obj-y += bus.o glue.o 35obj-y += bus.o glue.o
40obj-y += scan.o 36obj-y += scan.o
41# Keep EC driver first. Initialization of others depend on it. 37# Keep EC driver first. Initialization of others depend on it.
@@ -59,9 +55,6 @@ obj-y += power.o
59obj-$(CONFIG_ACPI_SYSTEM) += system.o event.o 55obj-$(CONFIG_ACPI_SYSTEM) += system.o event.o
60obj-$(CONFIG_ACPI_DEBUG) += debug.o 56obj-$(CONFIG_ACPI_DEBUG) += debug.o
61obj-$(CONFIG_ACPI_NUMA) += numa.o 57obj-$(CONFIG_ACPI_NUMA) += numa.o
62obj-$(CONFIG_ACPI_WMI) += wmi.o
63obj-$(CONFIG_ACPI_ASUS) += asus_acpi.o
64obj-$(CONFIG_ACPI_TOSHIBA) += toshiba_acpi.o
65obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o 58obj-$(CONFIG_ACPI_HOTPLUG_MEMORY) += acpi_memhotplug.o
66obj-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o 59obj-$(CONFIG_ACPI_PROCFS_POWER) += cm_sbs.o
67obj-$(CONFIG_ACPI_SBS) += sbshc.o 60obj-$(CONFIG_ACPI_SBS) += sbshc.o
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 63a17b55b39b..7a0f4aa4fa1e 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -20,7 +20,7 @@
20 * 20 *
21 * 21 *
22 * ACPI based HotPlug driver that supports Memory Hotplug 22 * ACPI based HotPlug driver that supports Memory Hotplug
23 * This driver fields notifications from firmare for memory add 23 * This driver fields notifications from firmware for memory add
24 * and remove operations and alerts the VM of the affected memory 24 * and remove operations and alerts the VM of the affected memory
25 * ranges. 25 * ranges.
26 */ 26 */
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
new file mode 100644
index 000000000000..3f23298ee3fd
--- /dev/null
+++ b/drivers/acpi/acpica/Makefile
@@ -0,0 +1,44 @@
1#
2# Makefile for ACPICA Core interpreter
3#
4
5ccflags-y := -Os
6ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT
7
8obj-y := dsfield.o dsmthdat.o dsopcode.o dswexec.o dswscope.o \
9 dsmethod.o dsobject.o dsutils.o dswload.o dswstate.o \
10 dsinit.o
11
12obj-y += evevent.o evregion.o evsci.o evxfevnt.o \
13 evmisc.o evrgnini.o evxface.o evxfregn.o \
14 evgpe.o evgpeblk.o
15
16obj-y += exconfig.o exfield.o exnames.o exoparg6.o exresolv.o exstorob.o\
17 exconvrt.o exfldio.o exoparg1.o exprep.o exresop.o exsystem.o\
18 excreate.o exmisc.o exoparg2.o exregion.o exstore.o exutils.o \
19 exdump.o exmutex.o exoparg3.o exresnte.o exstoren.o
20
21obj-y += hwacpi.o hwgpe.o hwregs.o hwsleep.o hwxface.o
22
23obj-$(ACPI_FUTURE_USAGE) += hwtimer.o
24
25obj-y += nsaccess.o nsload.o nssearch.o nsxfeval.o \
26 nsalloc.o nseval.o nsnames.o nsutils.o nsxfname.o \
27 nsdump.o nsinit.o nsobject.o nswalk.o nsxfobj.o \
28 nsparse.o nspredef.o
29
30obj-$(ACPI_FUTURE_USAGE) += nsdumpdv.o
31
32obj-y += psargs.o psparse.o psloop.o pstree.o pswalk.o \
33 psopcode.o psscope.o psutils.o psxface.o
34
35obj-y += rsaddr.o rscreate.o rsinfo.o rsio.o rslist.o rsmisc.o rsxface.o \
36 rscalc.o rsirq.o rsmemory.o rsutils.o
37
38obj-$(ACPI_FUTURE_USAGE) += rsdump.o
39
40obj-y += tbxface.o tbinstal.o tbutils.o tbfind.o tbfadt.o tbxfroot.o
41
42obj-y += utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \
43 utcopy.o utdelete.o utglobal.o utmath.o utobject.o \
44 utstate.o utmutex.o utobject.o utresrc.o
diff --git a/drivers/acpi/acpica/accommon.h b/drivers/acpi/acpica/accommon.h
new file mode 100644
index 000000000000..3b20786cbb0d
--- /dev/null
+++ b/drivers/acpi/acpica/accommon.h
@@ -0,0 +1,63 @@
1/******************************************************************************
2 *
3 * Name: accommon.h - Common include files for generation of ACPICA source
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACCOMMON_H__
45#define __ACCOMMON_H__
46
47/*
48 * Common set of includes for all ACPICA source files.
49 * We put them here because we don't want to duplicate them
50 * in the the source code again and again.
51 *
52 * Note: The order of these include files is important.
53 */
54#include "acconfig.h" /* Global configuration constants */
55#include "acmacros.h" /* C macros */
56#include "aclocal.h" /* Internal data types */
57#include "acobject.h" /* ACPI internal object */
58#include "acstruct.h" /* Common structures */
59#include "acglobal.h" /* All global variables */
60#include "achware.h" /* Hardware defines and interfaces */
61#include "acutils.h" /* Utility interfaces */
62
63#endif /* __ACCOMMON_H__ */
diff --git a/drivers/acpi/acpica/acconfig.h b/drivers/acpi/acpica/acconfig.h
new file mode 100644
index 000000000000..e6777fb883d2
--- /dev/null
+++ b/drivers/acpi/acpica/acconfig.h
@@ -0,0 +1,217 @@
1/******************************************************************************
2 *
3 * Name: acconfig.h - Global configuration constants
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef _ACCONFIG_H
45#define _ACCONFIG_H
46
47/******************************************************************************
48 *
49 * Configuration options
50 *
51 *****************************************************************************/
52
53/*
54 * ACPI_DEBUG_OUTPUT - This switch enables all the debug facilities of the
55 * ACPI subsystem. This includes the DEBUG_PRINT output
56 * statements. When disabled, all DEBUG_PRINT
57 * statements are compiled out.
58 *
59 * ACPI_APPLICATION - Use this switch if the subsystem is going to be run
60 * at the application level.
61 *
62 */
63
64/*
65 * OS name, used for the _OS object. The _OS object is essentially obsolete,
66 * but there is a large base of ASL/AML code in existing machines that check
67 * for the string below. The use of this string usually guarantees that
68 * the ASL will execute down the most tested code path. Also, there is some
69 * code that will not execute the _OSI method unless _OS matches the string
70 * below. Therefore, change this string at your own risk.
71 */
72#define ACPI_OS_NAME "Microsoft Windows NT"
73
74/* Maximum objects in the various object caches */
75
76#define ACPI_MAX_STATE_CACHE_DEPTH 96 /* State objects */
77#define ACPI_MAX_PARSE_CACHE_DEPTH 96 /* Parse tree objects */
78#define ACPI_MAX_EXTPARSE_CACHE_DEPTH 96 /* Parse tree objects */
79#define ACPI_MAX_OBJECT_CACHE_DEPTH 96 /* Interpreter operand objects */
80#define ACPI_MAX_NAMESPACE_CACHE_DEPTH 96 /* Namespace objects */
81
82/*
83 * Should the subsystem abort the loading of an ACPI table if the
84 * table checksum is incorrect?
85 */
86#define ACPI_CHECKSUM_ABORT FALSE
87
88/******************************************************************************
89 *
90 * Subsystem Constants
91 *
92 *****************************************************************************/
93
94/* Version of ACPI supported */
95
96#define ACPI_CA_SUPPORT_LEVEL 3
97
98/* Maximum count for a semaphore object */
99
100#define ACPI_MAX_SEMAPHORE_COUNT 256
101
102/* Maximum object reference count (detects object deletion issues) */
103
104#define ACPI_MAX_REFERENCE_COUNT 0x1000
105
106/* Size of cached memory mapping for system memory operation region */
107
108#define ACPI_SYSMEM_REGION_WINDOW_SIZE 4096
109
110/* owner_id tracking. 8 entries allows for 255 owner_ids */
111
112#define ACPI_NUM_OWNERID_MASKS 8
113
114/* Size of the root table array is increased by this increment */
115
116#define ACPI_ROOT_TABLE_SIZE_INCREMENT 4
117
118/* Maximum number of While() loop iterations before forced abort */
119
120#define ACPI_MAX_LOOP_ITERATIONS 0xFFFF
121
122/******************************************************************************
123 *
124 * ACPI Specification constants (Do not change unless the specification changes)
125 *
126 *****************************************************************************/
127
128/* Number of distinct GPE register blocks and register width */
129
130#define ACPI_MAX_GPE_BLOCKS 2
131#define ACPI_GPE_REGISTER_WIDTH 8
132
133/* Method info (in WALK_STATE), containing local variables and argumetns */
134
135#define ACPI_METHOD_NUM_LOCALS 8
136#define ACPI_METHOD_MAX_LOCAL 7
137
138#define ACPI_METHOD_NUM_ARGS 7
139#define ACPI_METHOD_MAX_ARG 6
140
141/* Length of _HID, _UID, _CID, and UUID values */
142
143#define ACPI_DEVICE_ID_LENGTH 0x09
144#define ACPI_MAX_CID_LENGTH 48
145#define ACPI_UUID_LENGTH 16
146
147/*
148 * Operand Stack (in WALK_STATE), Must be large enough to contain METHOD_MAX_ARG
149 */
150#define ACPI_OBJ_NUM_OPERANDS 8
151#define ACPI_OBJ_MAX_OPERAND 7
152
153/* Number of elements in the Result Stack frame, can be an arbitrary value */
154
155#define ACPI_RESULTS_FRAME_OBJ_NUM 8
156
157/*
158 * Maximal number of elements the Result Stack can contain,
159 * it may be an arbitray value not exceeding the types of
160 * result_size and result_count (now u8).
161 */
162#define ACPI_RESULTS_OBJ_NUM_MAX 255
163
164/* Names within the namespace are 4 bytes long */
165
166#define ACPI_NAME_SIZE 4
167#define ACPI_PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */
168#define ACPI_PATH_SEPARATOR '.'
169
170/* Sizes for ACPI table headers */
171
172#define ACPI_OEM_ID_SIZE 6
173#define ACPI_OEM_TABLE_ID_SIZE 8
174
175/* Constants used in searching for the RSDP in low memory */
176
177#define ACPI_EBDA_PTR_LOCATION 0x0000040E /* Physical Address */
178#define ACPI_EBDA_PTR_LENGTH 2
179#define ACPI_EBDA_WINDOW_SIZE 1024
180#define ACPI_HI_RSDP_WINDOW_BASE 0x000E0000 /* Physical Address */
181#define ACPI_HI_RSDP_WINDOW_SIZE 0x00020000
182#define ACPI_RSDP_SCAN_STEP 16
183
184/* Operation regions */
185
186#define ACPI_NUM_PREDEFINED_REGIONS 8
187#define ACPI_USER_REGION_BEGIN 0x80
188
189/* Maximum space_ids for Operation Regions */
190
191#define ACPI_MAX_ADDRESS_SPACE 255
192
193/* Array sizes. Used for range checking also */
194
195#define ACPI_MAX_MATCH_OPCODE 5
196
197/* RSDP checksums */
198
199#define ACPI_RSDP_CHECKSUM_LENGTH 20
200#define ACPI_RSDP_XCHECKSUM_LENGTH 36
201
202/* SMBus bidirectional buffer size */
203
204#define ACPI_SMBUS_BUFFER_SIZE 34
205
206/******************************************************************************
207 *
208 * ACPI AML Debugger
209 *
210 *****************************************************************************/
211
212#define ACPI_DEBUGGER_MAX_ARGS 8 /* Must be max method args + 1 */
213
214#define ACPI_DEBUGGER_COMMAND_PROMPT '-'
215#define ACPI_DEBUGGER_EXECUTE_PROMPT '%'
216
217#endif /* _ACCONFIG_H */
diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
new file mode 100644
index 000000000000..62c59df3b86c
--- /dev/null
+++ b/drivers/acpi/acpica/acdebug.h
@@ -0,0 +1,231 @@
1/******************************************************************************
2 *
3 * Name: acdebug.h - ACPI/AML debugger
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACDEBUG_H__
45#define __ACDEBUG_H__
46
47#define ACPI_DEBUG_BUFFER_SIZE 4196
48
49struct command_info {
50 char *name; /* Command Name */
51 u8 min_args; /* Minimum arguments required */
52};
53
54struct argument_info {
55 char *name; /* Argument Name */
56};
57
58#define PARAM_LIST(pl) pl
59#define DBTEST_OUTPUT_LEVEL(lvl) if (acpi_gbl_db_opt_verbose)
60#define VERBOSE_PRINT(fp) DBTEST_OUTPUT_LEVEL(lvl) {\
61 acpi_os_printf PARAM_LIST(fp);}
62
63#define EX_NO_SINGLE_STEP 1
64#define EX_SINGLE_STEP 2
65
66/*
67 * dbxface - external debugger interfaces
68 */
69acpi_status acpi_db_initialize(void);
70
71void acpi_db_terminate(void);
72
73acpi_status
74acpi_db_single_step(struct acpi_walk_state *walk_state,
75 union acpi_parse_object *op, u32 op_type);
76
77/*
78 * dbcmds - debug commands and output routines
79 */
80acpi_status acpi_db_disassemble_method(char *name);
81
82void acpi_db_display_table_info(char *table_arg);
83
84void acpi_db_unload_acpi_table(char *table_arg, char *instance_arg);
85
86void
87acpi_db_set_method_breakpoint(char *location,
88 struct acpi_walk_state *walk_state,
89 union acpi_parse_object *op);
90
91void acpi_db_set_method_call_breakpoint(union acpi_parse_object *op);
92
93void acpi_db_get_bus_info(void);
94
95void acpi_db_disassemble_aml(char *statements, union acpi_parse_object *op);
96
97void acpi_db_dump_namespace(char *start_arg, char *depth_arg);
98
99void acpi_db_dump_namespace_by_owner(char *owner_arg, char *depth_arg);
100
101void acpi_db_send_notify(char *name, u32 value);
102
103void acpi_db_set_method_data(char *type_arg, char *index_arg, char *value_arg);
104
105acpi_status
106acpi_db_display_objects(char *obj_type_arg, char *display_count_arg);
107
108acpi_status acpi_db_find_name_in_namespace(char *name_arg);
109
110void acpi_db_set_scope(char *name);
111
112acpi_status acpi_db_sleep(char *object_arg);
113
114void acpi_db_find_references(char *object_arg);
115
116void acpi_db_display_locks(void);
117
118void acpi_db_display_resources(char *object_arg);
119
120void acpi_db_display_gpes(void);
121
122void acpi_db_check_integrity(void);
123
124void acpi_db_generate_gpe(char *gpe_arg, char *block_arg);
125
126void acpi_db_check_predefined_names(void);
127
128void acpi_db_batch_execute(void);
129
130/*
131 * dbdisply - debug display commands
132 */
133void acpi_db_display_method_info(union acpi_parse_object *op);
134
135void acpi_db_decode_and_display_object(char *target, char *output_type);
136
137void
138acpi_db_display_result_object(union acpi_operand_object *obj_desc,
139 struct acpi_walk_state *walk_state);
140
141acpi_status acpi_db_display_all_methods(char *display_count_arg);
142
143void acpi_db_display_arguments(void);
144
145void acpi_db_display_locals(void);
146
147void acpi_db_display_results(void);
148
149void acpi_db_display_calling_tree(void);
150
151void acpi_db_display_object_type(char *object_arg);
152
153void
154acpi_db_display_argument_object(union acpi_operand_object *obj_desc,
155 struct acpi_walk_state *walk_state);
156
157void acpi_db_check_predefined_names(void);
158
159void acpi_db_batch_execute(void);
160
161/*
162 * dbexec - debugger control method execution
163 */
164void acpi_db_execute(char *name, char **args, u32 flags);
165
166void
167acpi_db_create_execution_threads(char *num_threads_arg,
168 char *num_loops_arg, char *method_name_arg);
169
170#ifdef ACPI_DBG_TRACK_ALLOCATIONS
171u32 acpi_db_get_cache_info(struct acpi_memory_list *cache);
172#endif
173
174/*
175 * dbfileio - Debugger file I/O commands
176 */
177acpi_object_type
178acpi_db_match_argument(char *user_argument, struct argument_info *arguments);
179
180void acpi_db_close_debug_file(void);
181
182void acpi_db_open_debug_file(char *name);
183
184acpi_status acpi_db_load_acpi_table(char *filename);
185
186acpi_status
187acpi_db_get_table_from_file(char *filename, struct acpi_table_header **table);
188
189acpi_status
190acpi_db_read_table_from_file(char *filename, struct acpi_table_header **table);
191
192/*
193 * dbhistry - debugger HISTORY command
194 */
195void acpi_db_add_to_history(char *command_line);
196
197void acpi_db_display_history(void);
198
199char *acpi_db_get_from_history(char *command_num_arg);
200
201/*
202 * dbinput - user front-end to the AML debugger
203 */
204acpi_status
205acpi_db_command_dispatch(char *input_buffer,
206 struct acpi_walk_state *walk_state,
207 union acpi_parse_object *op);
208
209void ACPI_SYSTEM_XFACE acpi_db_execute_thread(void *context);
210
211/*
212 * dbstats - Generation and display of ACPI table statistics
213 */
214void acpi_db_generate_statistics(union acpi_parse_object *root, u8 is_method);
215
216acpi_status acpi_db_display_statistics(char *type_arg);
217
218/*
219 * dbutils - AML debugger utilities
220 */
221void acpi_db_set_output_destination(u32 where);
222
223void acpi_db_dump_external_object(union acpi_object *obj_desc, u32 level);
224
225void acpi_db_prep_namestring(char *name);
226
227struct acpi_namespace_node *acpi_db_local_ns_lookup(char *name);
228
229void acpi_db_uint32_to_hex_string(u32 value, char *buffer);
230
231#endif /* __ACDEBUG_H__ */
diff --git a/drivers/acpi/acpica/acdispat.h b/drivers/acpi/acpica/acdispat.h
new file mode 100644
index 000000000000..6291904be01e
--- /dev/null
+++ b/drivers/acpi/acpica/acdispat.h
@@ -0,0 +1,345 @@
1/******************************************************************************
2 *
3 * Name: acdispat.h - dispatcher (parser to interpreter interface)
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef _ACDISPAT_H_
45#define _ACDISPAT_H_
46
47#define NAMEOF_LOCAL_NTE "__L0"
48#define NAMEOF_ARG_NTE "__A0"
49
50/*
51 * dsopcode - support for late evaluation
52 */
53acpi_status
54acpi_ds_get_buffer_field_arguments(union acpi_operand_object *obj_desc);
55
56acpi_status
57acpi_ds_get_bank_field_arguments(union acpi_operand_object *obj_desc);
58
59acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *rgn_desc);
60
61acpi_status acpi_ds_get_buffer_arguments(union acpi_operand_object *obj_desc);
62
63acpi_status acpi_ds_get_package_arguments(union acpi_operand_object *obj_desc);
64
65acpi_status
66acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state,
67 union acpi_parse_object *op);
68
69acpi_status
70acpi_ds_eval_region_operands(struct acpi_walk_state *walk_state,
71 union acpi_parse_object *op);
72
73acpi_status
74acpi_ds_eval_table_region_operands(struct acpi_walk_state *walk_state,
75 union acpi_parse_object *op);
76
77acpi_status
78acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state,
79 union acpi_parse_object *op,
80 union acpi_operand_object *obj_desc);
81
82acpi_status
83acpi_ds_eval_bank_field_operands(struct acpi_walk_state *walk_state,
84 union acpi_parse_object *op);
85
86acpi_status acpi_ds_initialize_region(acpi_handle obj_handle);
87
88/*
89 * dsctrl - Parser/Interpreter interface, control stack routines
90 */
91acpi_status
92acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
93 union acpi_parse_object *op);
94
95acpi_status
96acpi_ds_exec_end_control_op(struct acpi_walk_state *walk_state,
97 union acpi_parse_object *op);
98
99/*
100 * dsexec - Parser/Interpreter interface, method execution callbacks
101 */
102acpi_status
103acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state,
104 union acpi_operand_object *result_obj);
105
106acpi_status
107acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state,
108 union acpi_parse_object **out_op);
109
110acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *state);
111
112/*
113 * dsfield - Parser/Interpreter interface for AML fields
114 */
115acpi_status
116acpi_ds_create_field(union acpi_parse_object *op,
117 struct acpi_namespace_node *region_node,
118 struct acpi_walk_state *walk_state);
119
120acpi_status
121acpi_ds_create_bank_field(union acpi_parse_object *op,
122 struct acpi_namespace_node *region_node,
123 struct acpi_walk_state *walk_state);
124
125acpi_status
126acpi_ds_create_index_field(union acpi_parse_object *op,
127 struct acpi_namespace_node *region_node,
128 struct acpi_walk_state *walk_state);
129
130acpi_status
131acpi_ds_create_buffer_field(union acpi_parse_object *op,
132 struct acpi_walk_state *walk_state);
133
134acpi_status
135acpi_ds_init_field_objects(union acpi_parse_object *op,
136 struct acpi_walk_state *walk_state);
137
138/*
139 * dsload - Parser/Interpreter interface, namespace load callbacks
140 */
141acpi_status
142acpi_ds_load1_begin_op(struct acpi_walk_state *walk_state,
143 union acpi_parse_object **out_op);
144
145acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state);
146
147acpi_status
148acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
149 union acpi_parse_object **out_op);
150
151acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state);
152
153acpi_status
154acpi_ds_init_callbacks(struct acpi_walk_state *walk_state, u32 pass_number);
155
156/*
157 * dsmthdat - method data (locals/args)
158 */
159acpi_status
160acpi_ds_store_object_to_local(u8 type,
161 u32 index,
162 union acpi_operand_object *src_desc,
163 struct acpi_walk_state *walk_state);
164
165acpi_status
166acpi_ds_method_data_get_entry(u16 opcode,
167 u32 index,
168 struct acpi_walk_state *walk_state,
169 union acpi_operand_object ***node);
170
171void acpi_ds_method_data_delete_all(struct acpi_walk_state *walk_state);
172
173u8 acpi_ds_is_method_value(union acpi_operand_object *obj_desc);
174
175acpi_status
176acpi_ds_method_data_get_value(u8 type,
177 u32 index,
178 struct acpi_walk_state *walk_state,
179 union acpi_operand_object **dest_desc);
180
181acpi_status
182acpi_ds_method_data_init_args(union acpi_operand_object **params,
183 u32 max_param_count,
184 struct acpi_walk_state *walk_state);
185
186acpi_status
187acpi_ds_method_data_get_node(u8 type,
188 u32 index,
189 struct acpi_walk_state *walk_state,
190 struct acpi_namespace_node **node);
191
192void acpi_ds_method_data_init(struct acpi_walk_state *walk_state);
193
194/*
195 * dsmethod - Parser/Interpreter interface - control method parsing
196 */
197acpi_status acpi_ds_parse_method(struct acpi_namespace_node *node);
198
199acpi_status
200acpi_ds_call_control_method(struct acpi_thread_state *thread,
201 struct acpi_walk_state *walk_state,
202 union acpi_parse_object *op);
203
204acpi_status
205acpi_ds_restart_control_method(struct acpi_walk_state *walk_state,
206 union acpi_operand_object *return_desc);
207
208void
209acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,
210 struct acpi_walk_state *walk_state);
211
212acpi_status
213acpi_ds_begin_method_execution(struct acpi_namespace_node *method_node,
214 union acpi_operand_object *obj_desc,
215 struct acpi_walk_state *walk_state);
216
217acpi_status
218acpi_ds_method_error(acpi_status status, struct acpi_walk_state *walk_state);
219
220/*
221 * dsinit
222 */
223acpi_status
224acpi_ds_initialize_objects(u32 table_index,
225 struct acpi_namespace_node *start_node);
226
227/*
228 * dsobject - Parser/Interpreter interface - object initialization and conversion
229 */
230acpi_status
231acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state,
232 union acpi_parse_object *op,
233 u32 buffer_length,
234 union acpi_operand_object **obj_desc_ptr);
235
236acpi_status
237acpi_ds_build_internal_package_obj(struct acpi_walk_state *walk_state,
238 union acpi_parse_object *op,
239 u32 package_length,
240 union acpi_operand_object **obj_desc);
241
242acpi_status
243acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
244 union acpi_parse_object *op,
245 u16 opcode, union acpi_operand_object **obj_desc);
246
247acpi_status
248acpi_ds_create_node(struct acpi_walk_state *walk_state,
249 struct acpi_namespace_node *node,
250 union acpi_parse_object *op);
251
252/*
253 * dsutils - Parser/Interpreter interface utility routines
254 */
255void acpi_ds_clear_implicit_return(struct acpi_walk_state *walk_state);
256
257u8
258acpi_ds_do_implicit_return(union acpi_operand_object *return_desc,
259 struct acpi_walk_state *walk_state,
260 u8 add_reference);
261
262u8
263acpi_ds_is_result_used(union acpi_parse_object *op,
264 struct acpi_walk_state *walk_state);
265
266void
267acpi_ds_delete_result_if_not_used(union acpi_parse_object *op,
268 union acpi_operand_object *result_obj,
269 struct acpi_walk_state *walk_state);
270
271acpi_status
272acpi_ds_create_operand(struct acpi_walk_state *walk_state,
273 union acpi_parse_object *arg, u32 args_remaining);
274
275acpi_status
276acpi_ds_create_operands(struct acpi_walk_state *walk_state,
277 union acpi_parse_object *first_arg);
278
279acpi_status acpi_ds_resolve_operands(struct acpi_walk_state *walk_state);
280
281void acpi_ds_clear_operands(struct acpi_walk_state *walk_state);
282
283acpi_status acpi_ds_evaluate_name_path(struct acpi_walk_state *walk_state);
284
285/*
286 * dswscope - Scope Stack manipulation
287 */
288acpi_status
289acpi_ds_scope_stack_push(struct acpi_namespace_node *node,
290 acpi_object_type type,
291 struct acpi_walk_state *walk_state);
292
293acpi_status acpi_ds_scope_stack_pop(struct acpi_walk_state *walk_state);
294
295void acpi_ds_scope_stack_clear(struct acpi_walk_state *walk_state);
296
297/*
298 * dswstate - parser WALK_STATE management routines
299 */
300acpi_status
301acpi_ds_obj_stack_push(void *object, struct acpi_walk_state *walk_state);
302
303acpi_status
304acpi_ds_obj_stack_pop(u32 pop_count, struct acpi_walk_state *walk_state);
305
306struct acpi_walk_state *acpi_ds_create_walk_state(acpi_owner_id owner_id, union acpi_parse_object
307 *origin, union acpi_operand_object
308 *mth_desc, struct acpi_thread_state
309 *thread);
310
311acpi_status
312acpi_ds_init_aml_walk(struct acpi_walk_state *walk_state,
313 union acpi_parse_object *op,
314 struct acpi_namespace_node *method_node,
315 u8 * aml_start,
316 u32 aml_length,
317 struct acpi_evaluate_info *info, u8 pass_number);
318
319void
320acpi_ds_obj_stack_pop_and_delete(u32 pop_count,
321 struct acpi_walk_state *walk_state);
322
323void acpi_ds_delete_walk_state(struct acpi_walk_state *walk_state);
324
325struct acpi_walk_state *acpi_ds_pop_walk_state(struct acpi_thread_state
326 *thread);
327
328void
329acpi_ds_push_walk_state(struct acpi_walk_state *walk_state,
330 struct acpi_thread_state *thread);
331
332acpi_status acpi_ds_result_stack_clear(struct acpi_walk_state *walk_state);
333
334struct acpi_walk_state *acpi_ds_get_current_walk_state(struct acpi_thread_state
335 *thread);
336
337acpi_status
338acpi_ds_result_pop(union acpi_operand_object **object,
339 struct acpi_walk_state *walk_state);
340
341acpi_status
342acpi_ds_result_push(union acpi_operand_object *object,
343 struct acpi_walk_state *walk_state);
344
345#endif /* _ACDISPAT_H_ */
diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h
new file mode 100644
index 000000000000..07e20135f01b
--- /dev/null
+++ b/drivers/acpi/acpica/acevents.h
@@ -0,0 +1,218 @@
1/******************************************************************************
2 *
3 * Name: acevents.h - Event subcomponent prototypes and defines
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACEVENTS_H__
45#define __ACEVENTS_H__
46
47/*
48 * evevent
49 */
50acpi_status acpi_ev_initialize_events(void);
51
52acpi_status acpi_ev_install_xrupt_handlers(void);
53
54acpi_status acpi_ev_install_fadt_gpes(void);
55
56u32 acpi_ev_fixed_event_detect(void);
57
58/*
59 * evmisc
60 */
61u8 acpi_ev_is_notify_object(struct acpi_namespace_node *node);
62
63acpi_status acpi_ev_acquire_global_lock(u16 timeout);
64
65acpi_status acpi_ev_release_global_lock(void);
66
67acpi_status acpi_ev_init_global_lock_handler(void);
68
69u32 acpi_ev_get_gpe_number_index(u32 gpe_number);
70
71acpi_status
72acpi_ev_queue_notify_request(struct acpi_namespace_node *node,
73 u32 notify_value);
74
75/*
76 * evgpe - GPE handling and dispatch
77 */
78acpi_status
79acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info,
80 u8 type);
81
82acpi_status
83acpi_ev_enable_gpe(struct acpi_gpe_event_info *gpe_event_info,
84 u8 write_to_hardware);
85
86acpi_status acpi_ev_disable_gpe(struct acpi_gpe_event_info *gpe_event_info);
87
88struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device,
89 u32 gpe_number);
90
91/*
92 * evgpeblk
93 */
94u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info);
95
96acpi_status
97acpi_ev_walk_gpe_list(acpi_gpe_callback gpe_walk_callback, void *context);
98
99acpi_status
100acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
101 struct acpi_gpe_block_info *gpe_block,
102 void *context);
103
104acpi_status
105acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
106 struct acpi_generic_address *gpe_block_address,
107 u32 register_count,
108 u8 gpe_block_base_number,
109 u32 interrupt_number,
110 struct acpi_gpe_block_info **return_gpe_block);
111
112acpi_status
113acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device,
114 struct acpi_gpe_block_info *gpe_block);
115
116acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block);
117
118u32
119acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info,
120 u32 gpe_number);
121
122u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info *gpe_xrupt_list);
123
124acpi_status
125acpi_ev_set_gpe_type(struct acpi_gpe_event_info *gpe_event_info, u8 type);
126
127acpi_status
128acpi_ev_check_for_wake_only_gpe(struct acpi_gpe_event_info *gpe_event_info);
129
130acpi_status acpi_ev_gpe_initialize(void);
131
132/*
133 * evregion - Address Space handling
134 */
135acpi_status acpi_ev_install_region_handlers(void);
136
137acpi_status acpi_ev_initialize_op_regions(void);
138
139acpi_status
140acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
141 u32 function,
142 acpi_physical_address address,
143 u32 bit_width, acpi_integer * value);
144
145acpi_status
146acpi_ev_attach_region(union acpi_operand_object *handler_obj,
147 union acpi_operand_object *region_obj,
148 u8 acpi_ns_is_locked);
149
150void
151acpi_ev_detach_region(union acpi_operand_object *region_obj,
152 u8 acpi_ns_is_locked);
153
154acpi_status
155acpi_ev_install_space_handler(struct acpi_namespace_node *node,
156 acpi_adr_space_type space_id,
157 acpi_adr_space_handler handler,
158 acpi_adr_space_setup setup, void *context);
159
160acpi_status
161acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
162 acpi_adr_space_type space_id);
163
164acpi_status
165acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function);
166
167/*
168 * evregini - Region initialization and setup
169 */
170acpi_status
171acpi_ev_system_memory_region_setup(acpi_handle handle,
172 u32 function,
173 void *handler_context,
174 void **region_context);
175
176acpi_status
177acpi_ev_io_space_region_setup(acpi_handle handle,
178 u32 function,
179 void *handler_context, void **region_context);
180
181acpi_status
182acpi_ev_pci_config_region_setup(acpi_handle handle,
183 u32 function,
184 void *handler_context, void **region_context);
185
186acpi_status
187acpi_ev_cmos_region_setup(acpi_handle handle,
188 u32 function,
189 void *handler_context, void **region_context);
190
191acpi_status
192acpi_ev_pci_bar_region_setup(acpi_handle handle,
193 u32 function,
194 void *handler_context, void **region_context);
195
196acpi_status
197acpi_ev_default_region_setup(acpi_handle handle,
198 u32 function,
199 void *handler_context, void **region_context);
200
201acpi_status
202acpi_ev_initialize_region(union acpi_operand_object *region_obj,
203 u8 acpi_ns_locked);
204
205/*
206 * evsci - SCI (System Control Interrupt) handling/dispatch
207 */
208u32 ACPI_SYSTEM_XFACE acpi_ev_gpe_xrupt_handler(void *context);
209
210u32 acpi_ev_install_sci_handler(void);
211
212acpi_status acpi_ev_remove_sci_handler(void);
213
214u32 acpi_ev_initialize_sCI(u32 program_sCI);
215
216void acpi_ev_terminate(void);
217
218#endif /* __ACEVENTS_H__ */
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
new file mode 100644
index 000000000000..ddb40f5c68fc
--- /dev/null
+++ b/drivers/acpi/acpica/acglobal.h
@@ -0,0 +1,394 @@
1/******************************************************************************
2 *
3 * Name: acglobal.h - Declarations for global variables
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACGLOBAL_H__
45#define __ACGLOBAL_H__
46
47/*
48 * Ensure that the globals are actually defined and initialized only once.
49 *
50 * The use of these macros allows a single list of globals (here) in order
51 * to simplify maintenance of the code.
52 */
53#ifdef DEFINE_ACPI_GLOBALS
54#define ACPI_EXTERN
55#define ACPI_INIT_GLOBAL(a,b) a=b
56#else
57#define ACPI_EXTERN extern
58#define ACPI_INIT_GLOBAL(a,b) a
59#endif
60
61/*****************************************************************************
62 *
63 * Runtime configuration (static defaults that can be overriden at runtime)
64 *
65 ****************************************************************************/
66
67/*
68 * Enable "slack" in the AML interpreter? Default is FALSE, and the
69 * interpreter strictly follows the ACPI specification. Setting to TRUE
70 * allows the interpreter to ignore certain errors and/or bad AML constructs.
71 *
72 * Currently, these features are enabled by this flag:
73 *
74 * 1) Allow "implicit return" of last value in a control method
75 * 2) Allow access beyond the end of an operation region
76 * 3) Allow access to uninitialized locals/args (auto-init to integer 0)
77 * 4) Allow ANY object type to be a source operand for the Store() operator
78 * 5) Allow unresolved references (invalid target name) in package objects
79 * 6) Enable warning messages for behavior that is not ACPI spec compliant
80 */
81ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_enable_interpreter_slack, FALSE);
82
83/*
84 * Automatically serialize ALL control methods? Default is FALSE, meaning
85 * to use the Serialized/not_serialized method flags on a per method basis.
86 * Only change this if the ASL code is poorly written and cannot handle
87 * reentrancy even though methods are marked "NotSerialized".
88 */
89ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_all_methods_serialized, FALSE);
90
91/*
92 * Create the predefined _OSI method in the namespace? Default is TRUE
93 * because ACPI CA is fully compatible with other ACPI implementations.
94 * Changing this will revert ACPI CA (and machine ASL) to pre-OSI behavior.
95 */
96ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_create_osi_method, TRUE);
97
98/*
99 * Disable wakeup GPEs during runtime? Default is TRUE because WAKE and
100 * RUNTIME GPEs should never be shared, and WAKE GPEs should typically only
101 * be enabled just before going to sleep.
102 */
103ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_leave_wake_gpes_disabled, TRUE);
104
105/*
106 * Optionally use default values for the ACPI register widths. Set this to
107 * TRUE to use the defaults, if an FADT contains incorrect widths/lengths.
108 */
109ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_use_default_register_widths, TRUE);
110
111/*****************************************************************************
112 *
113 * Debug support
114 *
115 ****************************************************************************/
116
117/* Runtime configuration of debug print levels */
118
119extern u32 acpi_dbg_level;
120extern u32 acpi_dbg_layer;
121
122/* Procedure nesting level for debug output */
123
124extern u32 acpi_gbl_nesting_level;
125
126/* Support for dynamic control method tracing mechanism */
127
128ACPI_EXTERN u32 acpi_gbl_original_dbg_level;
129ACPI_EXTERN u32 acpi_gbl_original_dbg_layer;
130ACPI_EXTERN acpi_name acpi_gbl_trace_method_name;
131ACPI_EXTERN u32 acpi_gbl_trace_dbg_level;
132ACPI_EXTERN u32 acpi_gbl_trace_dbg_layer;
133ACPI_EXTERN u32 acpi_gbl_trace_flags;
134
135/*****************************************************************************
136 *
137 * ACPI Table globals
138 *
139 ****************************************************************************/
140
141/*
142 * acpi_gbl_root_table_list is the master list of ACPI tables found in the
143 * RSDT/XSDT.
144 *
145 * acpi_gbl_FADT is a local copy of the FADT, converted to a common format.
146 */
147ACPI_EXTERN struct acpi_internal_rsdt acpi_gbl_root_table_list;
148ACPI_EXTERN struct acpi_table_fadt acpi_gbl_FADT;
149ACPI_EXTERN struct acpi_table_facs *acpi_gbl_FACS;
150
151/* These addresses are calculated from FADT address values */
152
153ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1a_enable;
154ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1b_enable;
155
156/*
157 * Handle both ACPI 1.0 and ACPI 2.0 Integer widths. The integer width is
158 * determined by the revision of the DSDT: If the DSDT revision is less than
159 * 2, use only the lower 32 bits of the internal 64-bit Integer.
160 */
161ACPI_EXTERN u8 acpi_gbl_integer_bit_width;
162ACPI_EXTERN u8 acpi_gbl_integer_byte_width;
163ACPI_EXTERN u8 acpi_gbl_integer_nybble_width;
164
165/*****************************************************************************
166 *
167 * Mutual exlusion within ACPICA subsystem
168 *
169 ****************************************************************************/
170
171/*
172 * Predefined mutex objects. This array contains the
173 * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs.
174 * (The table maps local handles to the real OS handles)
175 */
176ACPI_EXTERN struct acpi_mutex_info acpi_gbl_mutex_info[ACPI_NUM_MUTEX];
177
178/*
179 * Global lock mutex is an actual AML mutex object
180 * Global lock semaphore works in conjunction with the HW global lock
181 */
182ACPI_EXTERN union acpi_operand_object *acpi_gbl_global_lock_mutex;
183ACPI_EXTERN acpi_semaphore acpi_gbl_global_lock_semaphore;
184ACPI_EXTERN u16 acpi_gbl_global_lock_handle;
185ACPI_EXTERN u8 acpi_gbl_global_lock_acquired;
186ACPI_EXTERN u8 acpi_gbl_global_lock_present;
187
188/*
189 * Spinlocks are used for interfaces that can be possibly called at
190 * interrupt level
191 */
192ACPI_EXTERN spinlock_t _acpi_gbl_gpe_lock; /* For GPE data structs and registers */
193ACPI_EXTERN spinlock_t _acpi_gbl_hardware_lock; /* For ACPI H/W except GPE registers */
194#define acpi_gbl_gpe_lock &_acpi_gbl_gpe_lock
195#define acpi_gbl_hardware_lock &_acpi_gbl_hardware_lock
196
197/*****************************************************************************
198 *
199 * Miscellaneous globals
200 *
201 ****************************************************************************/
202
203#ifdef ACPI_DBG_TRACK_ALLOCATIONS
204
205/* Lists for tracking memory allocations */
206
207ACPI_EXTERN struct acpi_memory_list *acpi_gbl_global_list;
208ACPI_EXTERN struct acpi_memory_list *acpi_gbl_ns_node_list;
209ACPI_EXTERN u8 acpi_gbl_display_final_mem_stats;
210#endif
211
212/* Object caches */
213
214ACPI_EXTERN acpi_cache_t *acpi_gbl_namespace_cache;
215ACPI_EXTERN acpi_cache_t *acpi_gbl_state_cache;
216ACPI_EXTERN acpi_cache_t *acpi_gbl_ps_node_cache;
217ACPI_EXTERN acpi_cache_t *acpi_gbl_ps_node_ext_cache;
218ACPI_EXTERN acpi_cache_t *acpi_gbl_operand_cache;
219
220/* Global handlers */
221
222ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_device_notify;
223ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_system_notify;
224ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler;
225ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler;
226ACPI_EXTERN acpi_tbl_handler acpi_gbl_table_handler;
227ACPI_EXTERN void *acpi_gbl_table_handler_context;
228ACPI_EXTERN struct acpi_walk_state *acpi_gbl_breakpoint_walk;
229
230/* Owner ID support */
231
232ACPI_EXTERN u32 acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS];
233ACPI_EXTERN u8 acpi_gbl_last_owner_id_index;
234ACPI_EXTERN u8 acpi_gbl_next_owner_id_offset;
235
236/* Misc */
237
238ACPI_EXTERN u32 acpi_gbl_original_mode;
239ACPI_EXTERN u32 acpi_gbl_rsdp_original_location;
240ACPI_EXTERN u32 acpi_gbl_ns_lookup_count;
241ACPI_EXTERN u32 acpi_gbl_ps_find_count;
242ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save;
243ACPI_EXTERN u8 acpi_gbl_debugger_configuration;
244ACPI_EXTERN u8 acpi_gbl_step_to_next_call;
245ACPI_EXTERN u8 acpi_gbl_acpi_hardware_present;
246ACPI_EXTERN u8 acpi_gbl_events_initialized;
247ACPI_EXTERN u8 acpi_gbl_system_awake_and_running;
248
249#ifndef DEFINE_ACPI_GLOBALS
250
251/* Other miscellaneous */
252
253extern u8 acpi_gbl_shutdown;
254extern u32 acpi_gbl_startup_flags;
255extern const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT];
256extern const char *acpi_gbl_highest_dstate_names[4];
257extern const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES];
258extern const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS];
259
260#endif
261
262/* Exception codes */
263
264extern char const *acpi_gbl_exception_names_env[];
265extern char const *acpi_gbl_exception_names_pgm[];
266extern char const *acpi_gbl_exception_names_tbl[];
267extern char const *acpi_gbl_exception_names_aml[];
268extern char const *acpi_gbl_exception_names_ctrl[];
269
270/*****************************************************************************
271 *
272 * Namespace globals
273 *
274 ****************************************************************************/
275
276#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
277#define NUM_PREDEFINED_NAMES 10
278#else
279#define NUM_PREDEFINED_NAMES 9
280#endif
281
282ACPI_EXTERN struct acpi_namespace_node acpi_gbl_root_node_struct;
283ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_root_node;
284ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_fadt_gpe_device;
285
286extern const u8 acpi_gbl_ns_properties[ACPI_NUM_NS_TYPES];
287extern const struct acpi_predefined_names
288 acpi_gbl_pre_defined_names[NUM_PREDEFINED_NAMES];
289
290#ifdef ACPI_DEBUG_OUTPUT
291ACPI_EXTERN u32 acpi_gbl_current_node_count;
292ACPI_EXTERN u32 acpi_gbl_current_node_size;
293ACPI_EXTERN u32 acpi_gbl_max_concurrent_node_count;
294ACPI_EXTERN acpi_size *acpi_gbl_entry_stack_pointer;
295ACPI_EXTERN acpi_size *acpi_gbl_lowest_stack_pointer;
296ACPI_EXTERN u32 acpi_gbl_deepest_nesting;
297#endif
298
299/*****************************************************************************
300 *
301 * Interpreter globals
302 *
303 ****************************************************************************/
304
305ACPI_EXTERN struct acpi_thread_state *acpi_gbl_current_walk_list;
306
307/* Control method single step flag */
308
309ACPI_EXTERN u8 acpi_gbl_cm_single_step;
310
311/*****************************************************************************
312 *
313 * Hardware globals
314 *
315 ****************************************************************************/
316
317extern struct acpi_bit_register_info
318 acpi_gbl_bit_register_info[ACPI_NUM_BITREG];
319ACPI_EXTERN u8 acpi_gbl_sleep_type_a;
320ACPI_EXTERN u8 acpi_gbl_sleep_type_b;
321
322/*****************************************************************************
323 *
324 * Event and GPE globals
325 *
326 ****************************************************************************/
327
328extern struct acpi_fixed_event_info
329 acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS];
330ACPI_EXTERN struct acpi_fixed_event_handler
331 acpi_gbl_fixed_event_handlers[ACPI_NUM_FIXED_EVENTS];
332ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head;
333ACPI_EXTERN struct acpi_gpe_block_info
334*acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS];
335ACPI_EXTERN u32 acpi_current_gpe_count;
336
337/*****************************************************************************
338 *
339 * Debugger globals
340 *
341 ****************************************************************************/
342
343ACPI_EXTERN u8 acpi_gbl_db_output_flags;
344
345#ifdef ACPI_DISASSEMBLER
346
347ACPI_EXTERN u8 acpi_gbl_db_opt_disasm;
348ACPI_EXTERN u8 acpi_gbl_db_opt_verbose;
349#endif
350
351#ifdef ACPI_DEBUGGER
352
353extern u8 acpi_gbl_method_executing;
354extern u8 acpi_gbl_abort_method;
355extern u8 acpi_gbl_db_terminate_threads;
356
357ACPI_EXTERN int optind;
358ACPI_EXTERN char *optarg;
359
360ACPI_EXTERN u8 acpi_gbl_db_opt_tables;
361ACPI_EXTERN u8 acpi_gbl_db_opt_stats;
362ACPI_EXTERN u8 acpi_gbl_db_opt_ini_methods;
363
364ACPI_EXTERN char *acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS];
365ACPI_EXTERN char acpi_gbl_db_line_buf[80];
366ACPI_EXTERN char acpi_gbl_db_parsed_buf[80];
367ACPI_EXTERN char acpi_gbl_db_scope_buf[40];
368ACPI_EXTERN char acpi_gbl_db_debug_filename[40];
369ACPI_EXTERN u8 acpi_gbl_db_output_to_file;
370ACPI_EXTERN char *acpi_gbl_db_buffer;
371ACPI_EXTERN char *acpi_gbl_db_filename;
372ACPI_EXTERN u32 acpi_gbl_db_debug_level;
373ACPI_EXTERN u32 acpi_gbl_db_console_debug_level;
374ACPI_EXTERN struct acpi_table_header *acpi_gbl_db_table_ptr;
375ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_db_scope_node;
376
377/*
378 * Statistic globals
379 */
380ACPI_EXTERN u16 acpi_gbl_obj_type_count[ACPI_TYPE_NS_NODE_MAX + 1];
381ACPI_EXTERN u16 acpi_gbl_node_type_count[ACPI_TYPE_NS_NODE_MAX + 1];
382ACPI_EXTERN u16 acpi_gbl_obj_type_count_misc;
383ACPI_EXTERN u16 acpi_gbl_node_type_count_misc;
384ACPI_EXTERN u32 acpi_gbl_num_nodes;
385ACPI_EXTERN u32 acpi_gbl_num_objects;
386
387ACPI_EXTERN u32 acpi_gbl_size_of_parse_tree;
388ACPI_EXTERN u32 acpi_gbl_size_of_method_trees;
389ACPI_EXTERN u32 acpi_gbl_size_of_node_entries;
390ACPI_EXTERN u32 acpi_gbl_size_of_acpi_objects;
391
392#endif /* ACPI_DEBUGGER */
393
394#endif /* __ACGLOBAL_H__ */
diff --git a/drivers/acpi/acpica/achware.h b/drivers/acpi/acpica/achware.h
new file mode 100644
index 000000000000..58c69dc49ab4
--- /dev/null
+++ b/drivers/acpi/acpica/achware.h
@@ -0,0 +1,119 @@
1/******************************************************************************
2 *
3 * Name: achware.h -- hardware specific interfaces
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACHWARE_H__
45#define __ACHWARE_H__
46
47/* Values for the _SST predefined method */
48
49#define ACPI_SST_INDICATOR_OFF 0
50#define ACPI_SST_WORKING 1
51#define ACPI_SST_WAKING 2
52#define ACPI_SST_SLEEPING 3
53#define ACPI_SST_SLEEP_CONTEXT 4
54
55/*
56 * hwacpi - high level functions
57 */
58acpi_status acpi_hw_set_mode(u32 mode);
59
60u32 acpi_hw_get_mode(void);
61
62/*
63 * hwregs - ACPI Register I/O
64 */
65struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id);
66
67acpi_status
68acpi_hw_register_read(u32 register_id, u32 * return_value);
69
70acpi_status acpi_hw_register_write(u32 register_id, u32 value);
71
72acpi_status acpi_hw_clear_acpi_status(void);
73
74/*
75 * hwgpe - GPE support
76 */
77acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info);
78
79acpi_status
80acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info *gpe_event_info);
81
82acpi_status
83acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
84 struct acpi_gpe_block_info *gpe_block, void *context);
85
86acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info *gpe_event_info);
87
88acpi_status
89acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
90 struct acpi_gpe_block_info *gpe_block, void *context);
91
92acpi_status
93acpi_hw_get_gpe_status(struct acpi_gpe_event_info *gpe_event_info,
94 acpi_event_status * event_status);
95
96acpi_status acpi_hw_disable_all_gpes(void);
97
98acpi_status acpi_hw_enable_all_runtime_gpes(void);
99
100acpi_status acpi_hw_enable_all_wakeup_gpes(void);
101
102acpi_status
103acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
104 struct acpi_gpe_block_info *gpe_block,
105 void *context);
106
107#ifdef ACPI_FUTURE_USAGE
108/*
109 * hwtimer - ACPI Timer prototypes
110 */
111acpi_status acpi_get_timer_resolution(u32 * resolution);
112
113acpi_status acpi_get_timer(u32 * ticks);
114
115acpi_status
116acpi_get_timer_duration(u32 start_ticks, u32 end_ticks, u32 * time_elapsed);
117#endif /* ACPI_FUTURE_USAGE */
118
119#endif /* __ACHWARE_H__ */
diff --git a/drivers/acpi/acpica/acinterp.h b/drivers/acpi/acpica/acinterp.h
new file mode 100644
index 000000000000..e8db7a3143a5
--- /dev/null
+++ b/drivers/acpi/acpica/acinterp.h
@@ -0,0 +1,529 @@
1/******************************************************************************
2 *
3 * Name: acinterp.h - Interpreter subcomponent prototypes and defines
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACINTERP_H__
45#define __ACINTERP_H__
46
47#define ACPI_WALK_OPERANDS (&(walk_state->operands [walk_state->num_operands -1]))
48
49/* Macros for tables used for debug output */
50
51#define ACPI_EXD_OFFSET(f) (u8) ACPI_OFFSET (union acpi_operand_object,f)
52#define ACPI_EXD_NSOFFSET(f) (u8) ACPI_OFFSET (struct acpi_namespace_node,f)
53#define ACPI_EXD_TABLE_SIZE(name) (sizeof(name) / sizeof (struct acpi_exdump_info))
54
55/*
56 * If possible, pack the following structures to byte alignment, since we
57 * don't care about performance for debug output. Two cases where we cannot
58 * pack the structures:
59 *
60 * 1) Hardware does not support misaligned memory transfers
61 * 2) Compiler does not support pointers within packed structures
62 */
63#if (!defined(ACPI_MISALIGNMENT_NOT_SUPPORTED) && !defined(ACPI_PACKED_POINTERS_NOT_SUPPORTED))
64#pragma pack(1)
65#endif
66
67typedef const struct acpi_exdump_info {
68 u8 opcode;
69 u8 offset;
70 char *name;
71
72} acpi_exdump_info;
73
74/* Values for the Opcode field above */
75
76#define ACPI_EXD_INIT 0
77#define ACPI_EXD_TYPE 1
78#define ACPI_EXD_UINT8 2
79#define ACPI_EXD_UINT16 3
80#define ACPI_EXD_UINT32 4
81#define ACPI_EXD_UINT64 5
82#define ACPI_EXD_LITERAL 6
83#define ACPI_EXD_POINTER 7
84#define ACPI_EXD_ADDRESS 8
85#define ACPI_EXD_STRING 9
86#define ACPI_EXD_BUFFER 10
87#define ACPI_EXD_PACKAGE 11
88#define ACPI_EXD_FIELD 12
89#define ACPI_EXD_REFERENCE 13
90
91/* restore default alignment */
92
93#pragma pack()
94
95/*
96 * exconvrt - object conversion
97 */
98acpi_status
99acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
100 union acpi_operand_object **result_desc, u32 flags);
101
102acpi_status
103acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
104 union acpi_operand_object **result_desc);
105
106acpi_status
107acpi_ex_convert_to_string(union acpi_operand_object *obj_desc,
108 union acpi_operand_object **result_desc, u32 type);
109
110/* Types for ->String conversion */
111
112#define ACPI_EXPLICIT_BYTE_COPY 0x00000000
113#define ACPI_EXPLICIT_CONVERT_HEX 0x00000001
114#define ACPI_IMPLICIT_CONVERT_HEX 0x00000002
115#define ACPI_EXPLICIT_CONVERT_DECIMAL 0x00000003
116
117acpi_status
118acpi_ex_convert_to_target_type(acpi_object_type destination_type,
119 union acpi_operand_object *source_desc,
120 union acpi_operand_object **result_desc,
121 struct acpi_walk_state *walk_state);
122
123/*
124 * exfield - ACPI AML (p-code) execution - field manipulation
125 */
126acpi_status
127acpi_ex_common_buffer_setup(union acpi_operand_object *obj_desc,
128 u32 buffer_length, u32 * datum_count);
129
130acpi_status
131acpi_ex_write_with_update_rule(union acpi_operand_object *obj_desc,
132 acpi_integer mask,
133 acpi_integer field_value,
134 u32 field_datum_byte_offset);
135
136void
137acpi_ex_get_buffer_datum(acpi_integer * datum,
138 void *buffer,
139 u32 buffer_length,
140 u32 byte_granularity, u32 buffer_offset);
141
142void
143acpi_ex_set_buffer_datum(acpi_integer merged_datum,
144 void *buffer,
145 u32 buffer_length,
146 u32 byte_granularity, u32 buffer_offset);
147
148acpi_status
149acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
150 union acpi_operand_object *obj_desc,
151 union acpi_operand_object **ret_buffer_desc);
152
153acpi_status
154acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
155 union acpi_operand_object *obj_desc,
156 union acpi_operand_object **result_desc);
157
158/*
159 * exfldio - low level field I/O
160 */
161acpi_status
162acpi_ex_extract_from_field(union acpi_operand_object *obj_desc,
163 void *buffer, u32 buffer_length);
164
165acpi_status
166acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
167 void *buffer, u32 buffer_length);
168
169acpi_status
170acpi_ex_access_region(union acpi_operand_object *obj_desc,
171 u32 field_datum_byte_offset,
172 acpi_integer * value, u32 read_write);
173
174/*
175 * exmisc - misc support routines
176 */
177acpi_status
178acpi_ex_get_object_reference(union acpi_operand_object *obj_desc,
179 union acpi_operand_object **return_desc,
180 struct acpi_walk_state *walk_state);
181
182acpi_status
183acpi_ex_concat_template(union acpi_operand_object *obj_desc,
184 union acpi_operand_object *obj_desc2,
185 union acpi_operand_object **actual_return_desc,
186 struct acpi_walk_state *walk_state);
187
188acpi_status
189acpi_ex_do_concatenate(union acpi_operand_object *obj_desc,
190 union acpi_operand_object *obj_desc2,
191 union acpi_operand_object **actual_return_desc,
192 struct acpi_walk_state *walk_state);
193
194acpi_status
195acpi_ex_do_logical_numeric_op(u16 opcode,
196 acpi_integer integer0,
197 acpi_integer integer1, u8 * logical_result);
198
199acpi_status
200acpi_ex_do_logical_op(u16 opcode,
201 union acpi_operand_object *operand0,
202 union acpi_operand_object *operand1, u8 * logical_result);
203
204acpi_integer
205acpi_ex_do_math_op(u16 opcode, acpi_integer operand0, acpi_integer operand1);
206
207acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state);
208
209acpi_status acpi_ex_create_processor(struct acpi_walk_state *walk_state);
210
211acpi_status acpi_ex_create_power_resource(struct acpi_walk_state *walk_state);
212
213acpi_status
214acpi_ex_create_region(u8 * aml_start,
215 u32 aml_length,
216 u8 region_space, struct acpi_walk_state *walk_state);
217
218acpi_status acpi_ex_create_event(struct acpi_walk_state *walk_state);
219
220acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state);
221
222acpi_status
223acpi_ex_create_method(u8 * aml_start,
224 u32 aml_length, struct acpi_walk_state *walk_state);
225
226/*
227 * exconfig - dynamic table load/unload
228 */
229acpi_status
230acpi_ex_load_op(union acpi_operand_object *obj_desc,
231 union acpi_operand_object *target,
232 struct acpi_walk_state *walk_state);
233
234acpi_status
235acpi_ex_load_table_op(struct acpi_walk_state *walk_state,
236 union acpi_operand_object **return_desc);
237
238acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle);
239
240/*
241 * exmutex - mutex support
242 */
243acpi_status
244acpi_ex_acquire_mutex(union acpi_operand_object *time_desc,
245 union acpi_operand_object *obj_desc,
246 struct acpi_walk_state *walk_state);
247
248acpi_status
249acpi_ex_acquire_mutex_object(u16 timeout,
250 union acpi_operand_object *obj_desc,
251 acpi_thread_id thread_id);
252
253acpi_status
254acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
255 struct acpi_walk_state *walk_state);
256
257acpi_status acpi_ex_release_mutex_object(union acpi_operand_object *obj_desc);
258
259void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread);
260
261void acpi_ex_unlink_mutex(union acpi_operand_object *obj_desc);
262
263/*
264 * exprep - ACPI AML execution - prep utilities
265 */
266acpi_status
267acpi_ex_prep_common_field_object(union acpi_operand_object *obj_desc,
268 u8 field_flags,
269 u8 field_attribute,
270 u32 field_bit_position, u32 field_bit_length);
271
272acpi_status acpi_ex_prep_field_value(struct acpi_create_field_info *info);
273
274/*
275 * exsystem - Interface to OS services
276 */
277acpi_status
278acpi_ex_system_do_notify_op(union acpi_operand_object *value,
279 union acpi_operand_object *obj_desc);
280
281acpi_status acpi_ex_system_do_suspend(acpi_integer time);
282
283acpi_status acpi_ex_system_do_stall(u32 time);
284
285acpi_status acpi_ex_system_signal_event(union acpi_operand_object *obj_desc);
286
287acpi_status
288acpi_ex_system_wait_event(union acpi_operand_object *time,
289 union acpi_operand_object *obj_desc);
290
291acpi_status acpi_ex_system_reset_event(union acpi_operand_object *obj_desc);
292
293acpi_status
294acpi_ex_system_wait_semaphore(acpi_semaphore semaphore, u16 timeout);
295
296acpi_status acpi_ex_system_wait_mutex(acpi_mutex mutex, u16 timeout);
297
298/*
299 * exoparg1 - ACPI AML execution, 1 operand
300 */
301acpi_status acpi_ex_opcode_0A_0T_1R(struct acpi_walk_state *walk_state);
302
303acpi_status acpi_ex_opcode_1A_0T_0R(struct acpi_walk_state *walk_state);
304
305acpi_status acpi_ex_opcode_1A_0T_1R(struct acpi_walk_state *walk_state);
306
307acpi_status acpi_ex_opcode_1A_1T_1R(struct acpi_walk_state *walk_state);
308
309acpi_status acpi_ex_opcode_1A_1T_0R(struct acpi_walk_state *walk_state);
310
311/*
312 * exoparg2 - ACPI AML execution, 2 operands
313 */
314acpi_status acpi_ex_opcode_2A_0T_0R(struct acpi_walk_state *walk_state);
315
316acpi_status acpi_ex_opcode_2A_0T_1R(struct acpi_walk_state *walk_state);
317
318acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state);
319
320acpi_status acpi_ex_opcode_2A_2T_1R(struct acpi_walk_state *walk_state);
321
322/*
323 * exoparg3 - ACPI AML execution, 3 operands
324 */
325acpi_status acpi_ex_opcode_3A_0T_0R(struct acpi_walk_state *walk_state);
326
327acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state);
328
329/*
330 * exoparg6 - ACPI AML execution, 6 operands
331 */
332acpi_status acpi_ex_opcode_6A_0T_1R(struct acpi_walk_state *walk_state);
333
334/*
335 * exresolv - Object resolution and get value functions
336 */
337acpi_status
338acpi_ex_resolve_to_value(union acpi_operand_object **stack_ptr,
339 struct acpi_walk_state *walk_state);
340
341acpi_status
342acpi_ex_resolve_multiple(struct acpi_walk_state *walk_state,
343 union acpi_operand_object *operand,
344 acpi_object_type * return_type,
345 union acpi_operand_object **return_desc);
346
347/*
348 * exresnte - resolve namespace node
349 */
350acpi_status
351acpi_ex_resolve_node_to_value(struct acpi_namespace_node **stack_ptr,
352 struct acpi_walk_state *walk_state);
353
354/*
355 * exresop - resolve operand to value
356 */
357acpi_status
358acpi_ex_resolve_operands(u16 opcode,
359 union acpi_operand_object **stack_ptr,
360 struct acpi_walk_state *walk_state);
361
362/*
363 * exdump - Interpreter debug output routines
364 */
365void acpi_ex_dump_operand(union acpi_operand_object *obj_desc, u32 depth);
366
367void
368acpi_ex_dump_operands(union acpi_operand_object **operands,
369 const char *opcode_name, u32 num_opcodes);
370
371#ifdef ACPI_FUTURE_USAGE
372void
373acpi_ex_dump_object_descriptor(union acpi_operand_object *object, u32 flags);
374
375void acpi_ex_dump_namespace_node(struct acpi_namespace_node *node, u32 flags);
376#endif /* ACPI_FUTURE_USAGE */
377
378/*
379 * exnames - AML namestring support
380 */
381acpi_status
382acpi_ex_get_name_string(acpi_object_type data_type,
383 u8 * in_aml_address,
384 char **out_name_string, u32 * out_name_length);
385
386/*
387 * exstore - Object store support
388 */
389acpi_status
390acpi_ex_store(union acpi_operand_object *val_desc,
391 union acpi_operand_object *dest_desc,
392 struct acpi_walk_state *walk_state);
393
394acpi_status
395acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
396 struct acpi_namespace_node *node,
397 struct acpi_walk_state *walk_state,
398 u8 implicit_conversion);
399
400#define ACPI_IMPLICIT_CONVERSION TRUE
401#define ACPI_NO_IMPLICIT_CONVERSION FALSE
402
403/*
404 * exstoren - resolve/store object
405 */
406acpi_status
407acpi_ex_resolve_object(union acpi_operand_object **source_desc_ptr,
408 acpi_object_type target_type,
409 struct acpi_walk_state *walk_state);
410
411acpi_status
412acpi_ex_store_object_to_object(union acpi_operand_object *source_desc,
413 union acpi_operand_object *dest_desc,
414 union acpi_operand_object **new_desc,
415 struct acpi_walk_state *walk_state);
416
417/*
418 * exstorob - store object - buffer/string
419 */
420acpi_status
421acpi_ex_store_buffer_to_buffer(union acpi_operand_object *source_desc,
422 union acpi_operand_object *target_desc);
423
424acpi_status
425acpi_ex_store_string_to_string(union acpi_operand_object *source_desc,
426 union acpi_operand_object *target_desc);
427
428/*
429 * excopy - object copy
430 */
431acpi_status
432acpi_ex_copy_integer_to_index_field(union acpi_operand_object *source_desc,
433 union acpi_operand_object *target_desc);
434
435acpi_status
436acpi_ex_copy_integer_to_bank_field(union acpi_operand_object *source_desc,
437 union acpi_operand_object *target_desc);
438
439acpi_status
440acpi_ex_copy_data_to_named_field(union acpi_operand_object *source_desc,
441 struct acpi_namespace_node *node);
442
443acpi_status
444acpi_ex_copy_integer_to_buffer_field(union acpi_operand_object *source_desc,
445 union acpi_operand_object *target_desc);
446
447/*
448 * exutils - interpreter/scanner utilities
449 */
450void acpi_ex_enter_interpreter(void);
451
452void acpi_ex_exit_interpreter(void);
453
454void acpi_ex_reacquire_interpreter(void);
455
456void acpi_ex_relinquish_interpreter(void);
457
458void acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc);
459
460void acpi_ex_acquire_global_lock(u32 rule);
461
462void acpi_ex_release_global_lock(u32 rule);
463
464void acpi_ex_eisa_id_to_string(u32 numeric_id, char *out_string);
465
466void acpi_ex_unsigned_integer_to_string(acpi_integer value, char *out_string);
467
468/*
469 * exregion - default op_region handlers
470 */
471acpi_status
472acpi_ex_system_memory_space_handler(u32 function,
473 acpi_physical_address address,
474 u32 bit_width,
475 acpi_integer * value,
476 void *handler_context,
477 void *region_context);
478
479acpi_status
480acpi_ex_system_io_space_handler(u32 function,
481 acpi_physical_address address,
482 u32 bit_width,
483 acpi_integer * value,
484 void *handler_context, void *region_context);
485
486acpi_status
487acpi_ex_pci_config_space_handler(u32 function,
488 acpi_physical_address address,
489 u32 bit_width,
490 acpi_integer * value,
491 void *handler_context, void *region_context);
492
493acpi_status
494acpi_ex_cmos_space_handler(u32 function,
495 acpi_physical_address address,
496 u32 bit_width,
497 acpi_integer * value,
498 void *handler_context, void *region_context);
499
500acpi_status
501acpi_ex_pci_bar_space_handler(u32 function,
502 acpi_physical_address address,
503 u32 bit_width,
504 acpi_integer * value,
505 void *handler_context, void *region_context);
506
507acpi_status
508acpi_ex_embedded_controller_space_handler(u32 function,
509 acpi_physical_address address,
510 u32 bit_width,
511 acpi_integer * value,
512 void *handler_context,
513 void *region_context);
514
515acpi_status
516acpi_ex_sm_bus_space_handler(u32 function,
517 acpi_physical_address address,
518 u32 bit_width,
519 acpi_integer * value,
520 void *handler_context, void *region_context);
521
522acpi_status
523acpi_ex_data_table_space_handler(u32 function,
524 acpi_physical_address address,
525 u32 bit_width,
526 acpi_integer * value,
527 void *handler_context, void *region_context);
528
529#endif /* __INTERP_H__ */
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
new file mode 100644
index 000000000000..492d02761bb7
--- /dev/null
+++ b/drivers/acpi/acpica/aclocal.h
@@ -0,0 +1,990 @@
1/******************************************************************************
2 *
3 * Name: aclocal.h - Internal data types used across the ACPI subsystem
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACLOCAL_H__
45#define __ACLOCAL_H__
46
47/* acpisrc:struct_defs -- for acpisrc conversion */
48
49#define ACPI_SERIALIZED 0xFF
50
51typedef u32 acpi_mutex_handle;
52#define ACPI_GLOBAL_LOCK (acpi_semaphore) (-1)
53
54/* Total number of aml opcodes defined */
55
56#define AML_NUM_OPCODES 0x7F
57
58/* Forward declarations */
59
60struct acpi_walk_state;
61struct acpi_obj_mutex;
62union acpi_parse_object;
63
64/*****************************************************************************
65 *
66 * Mutex typedefs and structs
67 *
68 ****************************************************************************/
69
70/*
71 * Predefined handles for the mutex objects used within the subsystem
72 * All mutex objects are automatically created by acpi_ut_mutex_initialize.
73 *
74 * The acquire/release ordering protocol is implied via this list. Mutexes
75 * with a lower value must be acquired before mutexes with a higher value.
76 *
77 * NOTE: any changes here must be reflected in the acpi_gbl_mutex_names
78 * table below also!
79 */
80#define ACPI_MTX_INTERPRETER 0 /* AML Interpreter, main lock */
81#define ACPI_MTX_NAMESPACE 1 /* ACPI Namespace */
82#define ACPI_MTX_TABLES 2 /* Data for ACPI tables */
83#define ACPI_MTX_EVENTS 3 /* Data for ACPI events */
84#define ACPI_MTX_CACHES 4 /* Internal caches, general purposes */
85#define ACPI_MTX_MEMORY 5 /* Debug memory tracking lists */
86#define ACPI_MTX_DEBUG_CMD_COMPLETE 6 /* AML debugger */
87#define ACPI_MTX_DEBUG_CMD_READY 7 /* AML debugger */
88
89#define ACPI_MAX_MUTEX 7
90#define ACPI_NUM_MUTEX ACPI_MAX_MUTEX+1
91
92#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
93#ifdef DEFINE_ACPI_GLOBALS
94
95/* Debug names for the mutexes above */
96
97static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = {
98 "ACPI_MTX_Interpreter",
99 "ACPI_MTX_Namespace",
100 "ACPI_MTX_Tables",
101 "ACPI_MTX_Events",
102 "ACPI_MTX_Caches",
103 "ACPI_MTX_Memory",
104 "ACPI_MTX_CommandComplete",
105 "ACPI_MTX_CommandReady"
106};
107
108#endif
109#endif
110
111/*
112 * Predefined handles for spinlocks used within the subsystem.
113 * These spinlocks are created by acpi_ut_mutex_initialize
114 */
115#define ACPI_LOCK_GPES 0
116#define ACPI_LOCK_HARDWARE 1
117
118#define ACPI_MAX_LOCK 1
119#define ACPI_NUM_LOCK ACPI_MAX_LOCK+1
120
121/* This Thread ID means that the mutex is not in use (unlocked) */
122
123#define ACPI_MUTEX_NOT_ACQUIRED (acpi_thread_id) 0
124
125/* Table for the global mutexes */
126
127struct acpi_mutex_info {
128 acpi_mutex mutex;
129 u32 use_count;
130 acpi_thread_id thread_id;
131};
132
133/* Lock flag parameter for various interfaces */
134
135#define ACPI_MTX_DO_NOT_LOCK 0
136#define ACPI_MTX_LOCK 1
137
138/* Field access granularities */
139
140#define ACPI_FIELD_BYTE_GRANULARITY 1
141#define ACPI_FIELD_WORD_GRANULARITY 2
142#define ACPI_FIELD_DWORD_GRANULARITY 4
143#define ACPI_FIELD_QWORD_GRANULARITY 8
144
145#define ACPI_ENTRY_NOT_FOUND NULL
146
147/*****************************************************************************
148 *
149 * Namespace typedefs and structs
150 *
151 ****************************************************************************/
152
153/* Operational modes of the AML interpreter/scanner */
154
155typedef enum {
156 ACPI_IMODE_LOAD_PASS1 = 0x01,
157 ACPI_IMODE_LOAD_PASS2 = 0x02,
158 ACPI_IMODE_EXECUTE = 0x03
159} acpi_interpreter_mode;
160
161/*
162 * The Namespace Node describes a named object that appears in the AML.
163 * descriptor_type is used to differentiate between internal descriptors.
164 *
165 * The node is optimized for both 32-bit and 64-bit platforms:
166 * 20 bytes for the 32-bit case, 32 bytes for the 64-bit case.
167 *
168 * Note: The descriptor_type and Type fields must appear in the identical
169 * position in both the struct acpi_namespace_node and union acpi_operand_object
170 * structures.
171 */
172struct acpi_namespace_node {
173 union acpi_operand_object *object; /* Interpreter object */
174 u8 descriptor_type; /* Differentiate object descriptor types */
175 u8 type; /* ACPI Type associated with this name */
176 u8 flags; /* Miscellaneous flags */
177 acpi_owner_id owner_id; /* Node creator */
178 union acpi_name_union name; /* ACPI Name, always 4 chars per ACPI spec */
179 struct acpi_namespace_node *child; /* First child */
180 struct acpi_namespace_node *peer; /* Peer. Parent if ANOBJ_END_OF_PEER_LIST set */
181
182 /*
183 * The following fields are used by the ASL compiler and disassembler only
184 */
185#ifdef ACPI_LARGE_NAMESPACE_NODE
186 union acpi_parse_object *op;
187 u32 value;
188 u32 length;
189#endif
190};
191
192/* Namespace Node flags */
193
194#define ANOBJ_END_OF_PEER_LIST 0x01 /* End-of-list, Peer field points to parent */
195#define ANOBJ_TEMPORARY 0x02 /* Node is create by a method and is temporary */
196#define ANOBJ_METHOD_ARG 0x04 /* Node is a method argument */
197#define ANOBJ_METHOD_LOCAL 0x08 /* Node is a method local */
198#define ANOBJ_SUBTREE_HAS_INI 0x10 /* Used to optimize device initialization */
199#define ANOBJ_EVALUATED 0x20 /* Set on first evaluation of node */
200
201#define ANOBJ_IS_EXTERNAL 0x08 /* i_aSL only: This object created via External() */
202#define ANOBJ_METHOD_NO_RETVAL 0x10 /* i_aSL only: Method has no return value */
203#define ANOBJ_METHOD_SOME_NO_RETVAL 0x20 /* i_aSL only: Method has at least one return value */
204#define ANOBJ_IS_BIT_OFFSET 0x40 /* i_aSL only: Reference is a bit offset */
205#define ANOBJ_IS_REFERENCED 0x80 /* i_aSL only: Object was referenced */
206
207/* One internal RSDT for table management */
208
209struct acpi_internal_rsdt {
210 struct acpi_table_desc *tables;
211 u32 count;
212 u32 size;
213 u8 flags;
214};
215
216/* Flags for above */
217
218#define ACPI_ROOT_ORIGIN_UNKNOWN (0) /* ~ORIGIN_ALLOCATED */
219#define ACPI_ROOT_ORIGIN_ALLOCATED (1)
220#define ACPI_ROOT_ALLOW_RESIZE (2)
221
222/* Predefined (fixed) table indexes */
223
224#define ACPI_TABLE_INDEX_DSDT (0)
225#define ACPI_TABLE_INDEX_FACS (1)
226
227struct acpi_find_context {
228 char *search_for;
229 acpi_handle *list;
230 u32 *count;
231};
232
233struct acpi_ns_search_data {
234 struct acpi_namespace_node *node;
235};
236
237/* Object types used during package copies */
238
239#define ACPI_COPY_TYPE_SIMPLE 0
240#define ACPI_COPY_TYPE_PACKAGE 1
241
242/* Info structure used to convert external<->internal namestrings */
243
244struct acpi_namestring_info {
245 const char *external_name;
246 const char *next_external_char;
247 char *internal_name;
248 u32 length;
249 u32 num_segments;
250 u32 num_carats;
251 u8 fully_qualified;
252};
253
254/* Field creation info */
255
256struct acpi_create_field_info {
257 struct acpi_namespace_node *region_node;
258 struct acpi_namespace_node *field_node;
259 struct acpi_namespace_node *register_node;
260 struct acpi_namespace_node *data_register_node;
261 u32 bank_value;
262 u32 field_bit_position;
263 u32 field_bit_length;
264 u8 field_flags;
265 u8 attribute;
266 u8 field_type;
267};
268
269typedef
270acpi_status(*ACPI_INTERNAL_METHOD) (struct acpi_walk_state * walk_state);
271
272/*
273 * Bitmapped ACPI types. Used internally only
274 */
275#define ACPI_BTYPE_ANY 0x00000000
276#define ACPI_BTYPE_INTEGER 0x00000001
277#define ACPI_BTYPE_STRING 0x00000002
278#define ACPI_BTYPE_BUFFER 0x00000004
279#define ACPI_BTYPE_PACKAGE 0x00000008
280#define ACPI_BTYPE_FIELD_UNIT 0x00000010
281#define ACPI_BTYPE_DEVICE 0x00000020
282#define ACPI_BTYPE_EVENT 0x00000040
283#define ACPI_BTYPE_METHOD 0x00000080
284#define ACPI_BTYPE_MUTEX 0x00000100
285#define ACPI_BTYPE_REGION 0x00000200
286#define ACPI_BTYPE_POWER 0x00000400
287#define ACPI_BTYPE_PROCESSOR 0x00000800
288#define ACPI_BTYPE_THERMAL 0x00001000
289#define ACPI_BTYPE_BUFFER_FIELD 0x00002000
290#define ACPI_BTYPE_DDB_HANDLE 0x00004000
291#define ACPI_BTYPE_DEBUG_OBJECT 0x00008000
292#define ACPI_BTYPE_REFERENCE 0x00010000
293#define ACPI_BTYPE_RESOURCE 0x00020000
294
295#define ACPI_BTYPE_COMPUTE_DATA (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER)
296
297#define ACPI_BTYPE_DATA (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_PACKAGE)
298#define ACPI_BTYPE_DATA_REFERENCE (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE)
299#define ACPI_BTYPE_DEVICE_OBJECTS (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR)
300#define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */
301#define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF
302
303/*
304 * Information structure for ACPI predefined names.
305 * Each entry in the table contains the following items:
306 *
307 * Name - The ACPI reserved name
308 * param_count - Number of arguments to the method
309 * expected_return_btypes - Allowed type(s) for the return value
310 */
311struct acpi_name_info {
312 char name[ACPI_NAME_SIZE];
313 u8 param_count;
314 u8 expected_btypes;
315};
316
317/*
318 * Secondary information structures for ACPI predefined objects that return
319 * package objects. This structure appears as the next entry in the table
320 * after the NAME_INFO structure above.
321 *
322 * The reason for this is to minimize the size of the predefined name table.
323 */
324
325/*
326 * Used for ACPI_PTYPE1_FIXED, ACPI_PTYPE1_VAR, ACPI_PTYPE2,
327 * ACPI_PTYPE2_MIN, ACPI_PTYPE2_PKG_COUNT, ACPI_PTYPE2_COUNT
328 */
329struct acpi_package_info {
330 u8 type;
331 u8 object_type1;
332 u8 count1;
333 u8 object_type2;
334 u8 count2;
335 u8 reserved;
336};
337
338/* Used for ACPI_PTYPE2_FIXED */
339
340struct acpi_package_info2 {
341 u8 type;
342 u8 count;
343 u8 object_type[4];
344};
345
346/* Used for ACPI_PTYPE1_OPTION */
347
348struct acpi_package_info3 {
349 u8 type;
350 u8 count;
351 u8 object_type[2];
352 u8 tail_object_type;
353 u8 reserved;
354};
355
356union acpi_predefined_info {
357 struct acpi_name_info info;
358 struct acpi_package_info ret_info;
359 struct acpi_package_info2 ret_info2;
360 struct acpi_package_info3 ret_info3;
361};
362
363/*
364 * Bitmapped return value types
365 * Note: the actual data types must be contiguous, a loop in nspredef.c
366 * depends on this.
367 */
368#define ACPI_RTYPE_ANY 0x00
369#define ACPI_RTYPE_NONE 0x01
370#define ACPI_RTYPE_INTEGER 0x02
371#define ACPI_RTYPE_STRING 0x04
372#define ACPI_RTYPE_BUFFER 0x08
373#define ACPI_RTYPE_PACKAGE 0x10
374#define ACPI_RTYPE_REFERENCE 0x20
375#define ACPI_RTYPE_ALL 0x3F
376
377#define ACPI_NUM_RTYPES 5 /* Number of actual object types */
378
379/*****************************************************************************
380 *
381 * Event typedefs and structs
382 *
383 ****************************************************************************/
384
385/* Dispatch info for each GPE -- either a method or handler, cannot be both */
386
387struct acpi_handler_info {
388 acpi_event_handler address; /* Address of handler, if any */
389 void *context; /* Context to be passed to handler */
390 struct acpi_namespace_node *method_node; /* Method node for this GPE level (saved) */
391};
392
393union acpi_gpe_dispatch_info {
394 struct acpi_namespace_node *method_node; /* Method node for this GPE level */
395 struct acpi_handler_info *handler;
396};
397
398/*
399 * Information about a GPE, one per each GPE in an array.
400 * NOTE: Important to keep this struct as small as possible.
401 */
402struct acpi_gpe_event_info {
403 union acpi_gpe_dispatch_info dispatch; /* Either Method or Handler */
404 struct acpi_gpe_register_info *register_info; /* Backpointer to register info */
405 u8 flags; /* Misc info about this GPE */
406 u8 gpe_number; /* This GPE */
407};
408
409/* Information about a GPE register pair, one per each status/enable pair in an array */
410
411struct acpi_gpe_register_info {
412 struct acpi_generic_address status_address; /* Address of status reg */
413 struct acpi_generic_address enable_address; /* Address of enable reg */
414 u8 enable_for_wake; /* GPEs to keep enabled when sleeping */
415 u8 enable_for_run; /* GPEs to keep enabled when running */
416 u8 base_gpe_number; /* Base GPE number for this register */
417};
418
419/*
420 * Information about a GPE register block, one per each installed block --
421 * GPE0, GPE1, and one per each installed GPE Block Device.
422 */
423struct acpi_gpe_block_info {
424 struct acpi_namespace_node *node;
425 struct acpi_gpe_block_info *previous;
426 struct acpi_gpe_block_info *next;
427 struct acpi_gpe_xrupt_info *xrupt_block; /* Backpointer to interrupt block */
428 struct acpi_gpe_register_info *register_info; /* One per GPE register pair */
429 struct acpi_gpe_event_info *event_info; /* One for each GPE */
430 struct acpi_generic_address block_address; /* Base address of the block */
431 u32 register_count; /* Number of register pairs in block */
432 u8 block_base_number; /* Base GPE number for this block */
433};
434
435/* Information about GPE interrupt handlers, one per each interrupt level used for GPEs */
436
437struct acpi_gpe_xrupt_info {
438 struct acpi_gpe_xrupt_info *previous;
439 struct acpi_gpe_xrupt_info *next;
440 struct acpi_gpe_block_info *gpe_block_list_head; /* List of GPE blocks for this xrupt */
441 u32 interrupt_number; /* System interrupt number */
442};
443
444struct acpi_gpe_walk_info {
445 struct acpi_namespace_node *gpe_device;
446 struct acpi_gpe_block_info *gpe_block;
447};
448
449struct acpi_gpe_device_info {
450 u32 index;
451 u32 next_block_base_index;
452 acpi_status status;
453 struct acpi_namespace_node *gpe_device;
454};
455
456typedef acpi_status(*acpi_gpe_callback) (struct acpi_gpe_xrupt_info *gpe_xrupt_info,
457 struct acpi_gpe_block_info *gpe_block, void *context);
458
459/* Information about each particular fixed event */
460
461struct acpi_fixed_event_handler {
462 acpi_event_handler handler; /* Address of handler. */
463 void *context; /* Context to be passed to handler */
464};
465
466struct acpi_fixed_event_info {
467 u8 status_register_id;
468 u8 enable_register_id;
469 u16 status_bit_mask;
470 u16 enable_bit_mask;
471};
472
473/* Information used during field processing */
474
475struct acpi_field_info {
476 u8 skip_field;
477 u8 field_flag;
478 u32 pkg_length;
479};
480
481/*****************************************************************************
482 *
483 * Generic "state" object for stacks
484 *
485 ****************************************************************************/
486
487#define ACPI_CONTROL_NORMAL 0xC0
488#define ACPI_CONTROL_CONDITIONAL_EXECUTING 0xC1
489#define ACPI_CONTROL_PREDICATE_EXECUTING 0xC2
490#define ACPI_CONTROL_PREDICATE_FALSE 0xC3
491#define ACPI_CONTROL_PREDICATE_TRUE 0xC4
492
493#define ACPI_STATE_COMMON \
494 void *next; \
495 u8 descriptor_type; /* To differentiate various internal objs */\
496 u8 flags; \
497 u16 value; \
498 u16 state;
499
500 /* There are 2 bytes available here until the next natural alignment boundary */
501
502struct acpi_common_state {
503ACPI_STATE_COMMON};
504
505/*
506 * Update state - used to traverse complex objects such as packages
507 */
508struct acpi_update_state {
509 ACPI_STATE_COMMON union acpi_operand_object *object;
510};
511
512/*
513 * Pkg state - used to traverse nested package structures
514 */
515struct acpi_pkg_state {
516 ACPI_STATE_COMMON u16 index;
517 union acpi_operand_object *source_object;
518 union acpi_operand_object *dest_object;
519 struct acpi_walk_state *walk_state;
520 void *this_target_obj;
521 u32 num_packages;
522};
523
524/*
525 * Control state - one per if/else and while constructs.
526 * Allows nesting of these constructs
527 */
528struct acpi_control_state {
529 ACPI_STATE_COMMON u16 opcode;
530 union acpi_parse_object *predicate_op;
531 u8 *aml_predicate_start; /* Start of if/while predicate */
532 u8 *package_end; /* End of if/while block */
533 u32 loop_count; /* While() loop counter */
534};
535
536/*
537 * Scope state - current scope during namespace lookups
538 */
539struct acpi_scope_state {
540 ACPI_STATE_COMMON struct acpi_namespace_node *node;
541};
542
543struct acpi_pscope_state {
544 ACPI_STATE_COMMON u32 arg_count; /* Number of fixed arguments */
545 union acpi_parse_object *op; /* Current op being parsed */
546 u8 *arg_end; /* Current argument end */
547 u8 *pkg_end; /* Current package end */
548 u32 arg_list; /* Next argument to parse */
549};
550
551/*
552 * Thread state - one per thread across multiple walk states. Multiple walk
553 * states are created when there are nested control methods executing.
554 */
555struct acpi_thread_state {
556 ACPI_STATE_COMMON u8 current_sync_level; /* Mutex Sync (nested acquire) level */
557 struct acpi_walk_state *walk_state_list; /* Head of list of walk_states for this thread */
558 union acpi_operand_object *acquired_mutex_list; /* List of all currently acquired mutexes */
559 acpi_thread_id thread_id; /* Running thread ID */
560};
561
562/*
563 * Result values - used to accumulate the results of nested
564 * AML arguments
565 */
566struct acpi_result_values {
567 ACPI_STATE_COMMON
568 union acpi_operand_object *obj_desc[ACPI_RESULTS_FRAME_OBJ_NUM];
569};
570
571typedef
572acpi_status(*acpi_parse_downwards) (struct acpi_walk_state * walk_state,
573 union acpi_parse_object ** out_op);
574
575typedef acpi_status(*acpi_parse_upwards) (struct acpi_walk_state * walk_state);
576
577/*
578 * Notify info - used to pass info to the deferred notify
579 * handler/dispatcher.
580 */
581struct acpi_notify_info {
582 ACPI_STATE_COMMON struct acpi_namespace_node *node;
583 union acpi_operand_object *handler_obj;
584};
585
586/* Generic state is union of structs above */
587
588union acpi_generic_state {
589 struct acpi_common_state common;
590 struct acpi_control_state control;
591 struct acpi_update_state update;
592 struct acpi_scope_state scope;
593 struct acpi_pscope_state parse_scope;
594 struct acpi_pkg_state pkg;
595 struct acpi_thread_state thread;
596 struct acpi_result_values results;
597 struct acpi_notify_info notify;
598};
599
600/*****************************************************************************
601 *
602 * Interpreter typedefs and structs
603 *
604 ****************************************************************************/
605
606typedef acpi_status(*ACPI_EXECUTE_OP) (struct acpi_walk_state * walk_state);
607
608/*****************************************************************************
609 *
610 * Parser typedefs and structs
611 *
612 ****************************************************************************/
613
614/*
615 * AML opcode, name, and argument layout
616 */
617struct acpi_opcode_info {
618#if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT)
619 char *name; /* Opcode name (disassembler/debug only) */
620#endif
621 u32 parse_args; /* Grammar/Parse time arguments */
622 u32 runtime_args; /* Interpret time arguments */
623 u16 flags; /* Misc flags */
624 u8 object_type; /* Corresponding internal object type */
625 u8 class; /* Opcode class */
626 u8 type; /* Opcode type */
627};
628
629union acpi_parse_value {
630 acpi_integer integer; /* Integer constant (Up to 64 bits) */
631 struct uint64_struct integer64; /* Structure overlay for 2 32-bit Dwords */
632 u32 size; /* bytelist or field size */
633 char *string; /* NULL terminated string */
634 u8 *buffer; /* buffer or string */
635 char *name; /* NULL terminated string */
636 union acpi_parse_object *arg; /* arguments and contained ops */
637};
638
639#ifdef ACPI_DISASSEMBLER
640#define ACPI_DISASM_ONLY_MEMBERS(a) a;
641#else
642#define ACPI_DISASM_ONLY_MEMBERS(a)
643#endif
644
645#define ACPI_PARSE_COMMON \
646 union acpi_parse_object *parent; /* Parent op */\
647 u8 descriptor_type; /* To differentiate various internal objs */\
648 u8 flags; /* Type of Op */\
649 u16 aml_opcode; /* AML opcode */\
650 u32 aml_offset; /* Offset of declaration in AML */\
651 union acpi_parse_object *next; /* Next op */\
652 struct acpi_namespace_node *node; /* For use by interpreter */\
653 union acpi_parse_value value; /* Value or args associated with the opcode */\
654 u8 arg_list_length; /* Number of elements in the arg list */\
655 ACPI_DISASM_ONLY_MEMBERS (\
656 u8 disasm_flags; /* Used during AML disassembly */\
657 u8 disasm_opcode; /* Subtype used for disassembly */\
658 char aml_op_name[16]) /* Op name (debug only) */
659
660#define ACPI_DASM_BUFFER 0x00
661#define ACPI_DASM_RESOURCE 0x01
662#define ACPI_DASM_STRING 0x02
663#define ACPI_DASM_UNICODE 0x03
664#define ACPI_DASM_EISAID 0x04
665#define ACPI_DASM_MATCHOP 0x05
666#define ACPI_DASM_LNOT_PREFIX 0x06
667#define ACPI_DASM_LNOT_SUFFIX 0x07
668#define ACPI_DASM_IGNORE 0x08
669
670/*
671 * Generic operation (for example: If, While, Store)
672 */
673struct acpi_parse_obj_common {
674ACPI_PARSE_COMMON};
675
676/*
677 * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and op_regions),
678 * and bytelists.
679 */
680struct acpi_parse_obj_named {
681 ACPI_PARSE_COMMON u8 *path;
682 u8 *data; /* AML body or bytelist data */
683 u32 length; /* AML length */
684 u32 name; /* 4-byte name or zero if no name */
685};
686
687/* This version is used by the i_aSL compiler only */
688
689#define ACPI_MAX_PARSEOP_NAME 20
690
691struct acpi_parse_obj_asl {
692 ACPI_PARSE_COMMON union acpi_parse_object *child;
693 union acpi_parse_object *parent_method;
694 char *filename;
695 char *external_name;
696 char *namepath;
697 char name_seg[4];
698 u32 extra_value;
699 u32 column;
700 u32 line_number;
701 u32 logical_line_number;
702 u32 logical_byte_offset;
703 u32 end_line;
704 u32 end_logical_line;
705 u32 acpi_btype;
706 u32 aml_length;
707 u32 aml_subtree_length;
708 u32 final_aml_length;
709 u32 final_aml_offset;
710 u32 compile_flags;
711 u16 parse_opcode;
712 u8 aml_opcode_length;
713 u8 aml_pkg_len_bytes;
714 u8 extra;
715 char parse_op_name[ACPI_MAX_PARSEOP_NAME];
716};
717
718union acpi_parse_object {
719 struct acpi_parse_obj_common common;
720 struct acpi_parse_obj_named named;
721 struct acpi_parse_obj_asl asl;
722};
723
724/*
725 * Parse state - one state per parser invocation and each control
726 * method.
727 */
728struct acpi_parse_state {
729 u8 *aml_start; /* First AML byte */
730 u8 *aml; /* Next AML byte */
731 u8 *aml_end; /* (last + 1) AML byte */
732 u8 *pkg_start; /* Current package begin */
733 u8 *pkg_end; /* Current package end */
734 union acpi_parse_object *start_op; /* Root of parse tree */
735 struct acpi_namespace_node *start_node;
736 union acpi_generic_state *scope; /* Current scope */
737 union acpi_parse_object *start_scope;
738 u32 aml_size;
739};
740
741/* Parse object flags */
742
743#define ACPI_PARSEOP_GENERIC 0x01
744#define ACPI_PARSEOP_NAMED 0x02
745#define ACPI_PARSEOP_DEFERRED 0x04
746#define ACPI_PARSEOP_BYTELIST 0x08
747#define ACPI_PARSEOP_IN_STACK 0x10
748#define ACPI_PARSEOP_TARGET 0x20
749#define ACPI_PARSEOP_IN_CACHE 0x80
750
751/* Parse object disasm_flags */
752
753#define ACPI_PARSEOP_IGNORE 0x01
754#define ACPI_PARSEOP_PARAMLIST 0x02
755#define ACPI_PARSEOP_EMPTY_TERMLIST 0x04
756#define ACPI_PARSEOP_SPECIAL 0x10
757
758/*****************************************************************************
759 *
760 * Hardware (ACPI registers) and PNP
761 *
762 ****************************************************************************/
763
764struct acpi_bit_register_info {
765 u8 parent_register;
766 u8 bit_position;
767 u16 access_bit_mask;
768};
769
770/*
771 * Some ACPI registers have bits that must be ignored -- meaning that they
772 * must be preserved.
773 */
774#define ACPI_PM1_STATUS_PRESERVED_BITS 0x0800 /* Bit 11 */
775#define ACPI_PM1_CONTROL_PRESERVED_BITS 0x0200 /* Bit 9 (whatever) */
776
777/*
778 * Register IDs
779 * These are the full ACPI registers
780 */
781#define ACPI_REGISTER_PM1_STATUS 0x01
782#define ACPI_REGISTER_PM1_ENABLE 0x02
783#define ACPI_REGISTER_PM1_CONTROL 0x03
784#define ACPI_REGISTER_PM1A_CONTROL 0x04
785#define ACPI_REGISTER_PM1B_CONTROL 0x05
786#define ACPI_REGISTER_PM2_CONTROL 0x06
787#define ACPI_REGISTER_PM_TIMER 0x07
788#define ACPI_REGISTER_PROCESSOR_BLOCK 0x08
789#define ACPI_REGISTER_SMI_COMMAND_BLOCK 0x09
790
791/* Masks used to access the bit_registers */
792
793#define ACPI_BITMASK_TIMER_STATUS 0x0001
794#define ACPI_BITMASK_BUS_MASTER_STATUS 0x0010
795#define ACPI_BITMASK_GLOBAL_LOCK_STATUS 0x0020
796#define ACPI_BITMASK_POWER_BUTTON_STATUS 0x0100
797#define ACPI_BITMASK_SLEEP_BUTTON_STATUS 0x0200
798#define ACPI_BITMASK_RT_CLOCK_STATUS 0x0400
799#define ACPI_BITMASK_PCIEXP_WAKE_STATUS 0x4000 /* ACPI 3.0 */
800#define ACPI_BITMASK_WAKE_STATUS 0x8000
801
802#define ACPI_BITMASK_ALL_FIXED_STATUS (\
803 ACPI_BITMASK_TIMER_STATUS | \
804 ACPI_BITMASK_BUS_MASTER_STATUS | \
805 ACPI_BITMASK_GLOBAL_LOCK_STATUS | \
806 ACPI_BITMASK_POWER_BUTTON_STATUS | \
807 ACPI_BITMASK_SLEEP_BUTTON_STATUS | \
808 ACPI_BITMASK_RT_CLOCK_STATUS | \
809 ACPI_BITMASK_WAKE_STATUS)
810
811#define ACPI_BITMASK_TIMER_ENABLE 0x0001
812#define ACPI_BITMASK_GLOBAL_LOCK_ENABLE 0x0020
813#define ACPI_BITMASK_POWER_BUTTON_ENABLE 0x0100
814#define ACPI_BITMASK_SLEEP_BUTTON_ENABLE 0x0200
815#define ACPI_BITMASK_RT_CLOCK_ENABLE 0x0400
816#define ACPI_BITMASK_PCIEXP_WAKE_DISABLE 0x4000 /* ACPI 3.0 */
817
818#define ACPI_BITMASK_SCI_ENABLE 0x0001
819#define ACPI_BITMASK_BUS_MASTER_RLD 0x0002
820#define ACPI_BITMASK_GLOBAL_LOCK_RELEASE 0x0004
821#define ACPI_BITMASK_SLEEP_TYPE_X 0x1C00
822#define ACPI_BITMASK_SLEEP_ENABLE 0x2000
823
824#define ACPI_BITMASK_ARB_DISABLE 0x0001
825
826/* Raw bit position of each bit_register */
827
828#define ACPI_BITPOSITION_TIMER_STATUS 0x00
829#define ACPI_BITPOSITION_BUS_MASTER_STATUS 0x04
830#define ACPI_BITPOSITION_GLOBAL_LOCK_STATUS 0x05
831#define ACPI_BITPOSITION_POWER_BUTTON_STATUS 0x08
832#define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS 0x09
833#define ACPI_BITPOSITION_RT_CLOCK_STATUS 0x0A
834#define ACPI_BITPOSITION_PCIEXP_WAKE_STATUS 0x0E /* ACPI 3.0 */
835#define ACPI_BITPOSITION_WAKE_STATUS 0x0F
836
837#define ACPI_BITPOSITION_TIMER_ENABLE 0x00
838#define ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE 0x05
839#define ACPI_BITPOSITION_POWER_BUTTON_ENABLE 0x08
840#define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE 0x09
841#define ACPI_BITPOSITION_RT_CLOCK_ENABLE 0x0A
842#define ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE 0x0E /* ACPI 3.0 */
843
844#define ACPI_BITPOSITION_SCI_ENABLE 0x00
845#define ACPI_BITPOSITION_BUS_MASTER_RLD 0x01
846#define ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE 0x02
847#define ACPI_BITPOSITION_SLEEP_TYPE_X 0x0A
848#define ACPI_BITPOSITION_SLEEP_ENABLE 0x0D
849
850#define ACPI_BITPOSITION_ARB_DISABLE 0x00
851
852/*****************************************************************************
853 *
854 * Resource descriptors
855 *
856 ****************************************************************************/
857
858/* resource_type values */
859
860#define ACPI_ADDRESS_TYPE_MEMORY_RANGE 0
861#define ACPI_ADDRESS_TYPE_IO_RANGE 1
862#define ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE 2
863
864/* Resource descriptor types and masks */
865
866#define ACPI_RESOURCE_NAME_LARGE 0x80
867#define ACPI_RESOURCE_NAME_SMALL 0x00
868
869#define ACPI_RESOURCE_NAME_SMALL_MASK 0x78 /* Bits 6:3 contain the type */
870#define ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK 0x07 /* Bits 2:0 contain the length */
871#define ACPI_RESOURCE_NAME_LARGE_MASK 0x7F /* Bits 6:0 contain the type */
872
873/*
874 * Small resource descriptor "names" as defined by the ACPI specification.
875 * Note: Bits 2:0 are used for the descriptor length
876 */
877#define ACPI_RESOURCE_NAME_IRQ 0x20
878#define ACPI_RESOURCE_NAME_DMA 0x28
879#define ACPI_RESOURCE_NAME_START_DEPENDENT 0x30
880#define ACPI_RESOURCE_NAME_END_DEPENDENT 0x38
881#define ACPI_RESOURCE_NAME_IO 0x40
882#define ACPI_RESOURCE_NAME_FIXED_IO 0x48
883#define ACPI_RESOURCE_NAME_RESERVED_S1 0x50
884#define ACPI_RESOURCE_NAME_RESERVED_S2 0x58
885#define ACPI_RESOURCE_NAME_RESERVED_S3 0x60
886#define ACPI_RESOURCE_NAME_RESERVED_S4 0x68
887#define ACPI_RESOURCE_NAME_VENDOR_SMALL 0x70
888#define ACPI_RESOURCE_NAME_END_TAG 0x78
889
890/*
891 * Large resource descriptor "names" as defined by the ACPI specification.
892 * Note: includes the Large Descriptor bit in bit[7]
893 */
894#define ACPI_RESOURCE_NAME_MEMORY24 0x81
895#define ACPI_RESOURCE_NAME_GENERIC_REGISTER 0x82
896#define ACPI_RESOURCE_NAME_RESERVED_L1 0x83
897#define ACPI_RESOURCE_NAME_VENDOR_LARGE 0x84
898#define ACPI_RESOURCE_NAME_MEMORY32 0x85
899#define ACPI_RESOURCE_NAME_FIXED_MEMORY32 0x86
900#define ACPI_RESOURCE_NAME_ADDRESS32 0x87
901#define ACPI_RESOURCE_NAME_ADDRESS16 0x88
902#define ACPI_RESOURCE_NAME_EXTENDED_IRQ 0x89
903#define ACPI_RESOURCE_NAME_ADDRESS64 0x8A
904#define ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 0x8B
905#define ACPI_RESOURCE_NAME_LARGE_MAX 0x8B
906
907/*****************************************************************************
908 *
909 * Miscellaneous
910 *
911 ****************************************************************************/
912
913#define ACPI_ASCII_ZERO 0x30
914
915/*****************************************************************************
916 *
917 * Debugger
918 *
919 ****************************************************************************/
920
921struct acpi_db_method_info {
922 acpi_handle main_thread_gate;
923 acpi_handle thread_complete_gate;
924 u32 *threads;
925 u32 num_threads;
926 u32 num_created;
927 u32 num_completed;
928
929 char *name;
930 u32 flags;
931 u32 num_loops;
932 char pathname[128];
933 char **args;
934
935 /*
936 * Arguments to be passed to method for the command
937 * Threads -
938 * the Number of threads, ID of current thread and
939 * Index of current thread inside all them created.
940 */
941 char init_args;
942 char *arguments[4];
943 char num_threads_str[11];
944 char id_of_thread_str[11];
945 char index_of_thread_str[11];
946};
947
948struct acpi_integrity_info {
949 u32 nodes;
950 u32 objects;
951};
952
953#define ACPI_DB_REDIRECTABLE_OUTPUT 0x01
954#define ACPI_DB_CONSOLE_OUTPUT 0x02
955#define ACPI_DB_DUPLICATE_OUTPUT 0x03
956
957/*****************************************************************************
958 *
959 * Debug
960 *
961 ****************************************************************************/
962
963/* Entry for a memory allocation (debug only) */
964
965#define ACPI_MEM_MALLOC 0
966#define ACPI_MEM_CALLOC 1
967#define ACPI_MAX_MODULE_NAME 16
968
969#define ACPI_COMMON_DEBUG_MEM_HEADER \
970 struct acpi_debug_mem_block *previous; \
971 struct acpi_debug_mem_block *next; \
972 u32 size; \
973 u32 component; \
974 u32 line; \
975 char module[ACPI_MAX_MODULE_NAME]; \
976 u8 alloc_type;
977
978struct acpi_debug_mem_header {
979ACPI_COMMON_DEBUG_MEM_HEADER};
980
981struct acpi_debug_mem_block {
982 ACPI_COMMON_DEBUG_MEM_HEADER u64 user_space;
983};
984
985#define ACPI_MEM_LIST_GLOBAL 0
986#define ACPI_MEM_LIST_NSNODE 1
987#define ACPI_MEM_LIST_MAX 1
988#define ACPI_NUM_MEM_LISTS 2
989
990#endif /* __ACLOCAL_H__ */
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h
new file mode 100644
index 000000000000..9c127e8e2d6d
--- /dev/null
+++ b/drivers/acpi/acpica/acmacros.h
@@ -0,0 +1,577 @@
1/******************************************************************************
2 *
3 * Name: acmacros.h - C macros for the entire subsystem.
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACMACROS_H__
45#define __ACMACROS_H__
46
47/*
48 * Extract data using a pointer. Any more than a byte and we
49 * get into potential aligment issues -- see the STORE macros below.
50 * Use with care.
51 */
52#define ACPI_GET8(ptr) *ACPI_CAST_PTR (u8, ptr)
53#define ACPI_GET16(ptr) *ACPI_CAST_PTR (u16, ptr)
54#define ACPI_GET32(ptr) *ACPI_CAST_PTR (u32, ptr)
55#define ACPI_GET64(ptr) *ACPI_CAST_PTR (u64, ptr)
56#define ACPI_SET8(ptr) *ACPI_CAST_PTR (u8, ptr)
57#define ACPI_SET16(ptr) *ACPI_CAST_PTR (u16, ptr)
58#define ACPI_SET32(ptr) *ACPI_CAST_PTR (u32, ptr)
59#define ACPI_SET64(ptr) *ACPI_CAST_PTR (u64, ptr)
60
61/*
62 * printf() format helpers
63 */
64
65/* Split 64-bit integer into two 32-bit values. Use with %8.8_x%8.8_x */
66
67#define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i), ACPI_LODWORD(i)
68
69#if ACPI_MACHINE_WIDTH == 64
70#define ACPI_FORMAT_NATIVE_UINT(i) ACPI_FORMAT_UINT64(i)
71#else
72#define ACPI_FORMAT_NATIVE_UINT(i) 0, (i)
73#endif
74
75/*
76 * Macros for moving data around to/from buffers that are possibly unaligned.
77 * If the hardware supports the transfer of unaligned data, just do the store.
78 * Otherwise, we have to move one byte at a time.
79 */
80#ifdef ACPI_BIG_ENDIAN
81/*
82 * Macros for big-endian machines
83 */
84
85/* These macros reverse the bytes during the move, converting little-endian to big endian */
86
87 /* Big Endian <== Little Endian */
88 /* Hi...Lo Lo...Hi */
89/* 16-bit source, 16/32/64 destination */
90
91#define ACPI_MOVE_16_TO_16(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[1];\
92 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[0];}
93
94#define ACPI_MOVE_16_TO_32(d, s) {(*(u32 *)(void *)(d))=0;\
95 ((u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\
96 ((u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];}
97
98#define ACPI_MOVE_16_TO_64(d, s) {(*(u64 *)(void *)(d))=0;\
99 ((u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\
100 ((u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[0];}
101
102/* 32-bit source, 16/32/64 destination */
103
104#define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
105
106#define ACPI_MOVE_32_TO_32(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[3];\
107 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[2];\
108 (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\
109 (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];}
110
111#define ACPI_MOVE_32_TO_64(d, s) {(*(u64 *)(void *)(d))=0;\
112 ((u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[3];\
113 ((u8 *)(void *)(d))[5] = ((u8 *)(void *)(s))[2];\
114 ((u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\
115 ((u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[0];}
116
117/* 64-bit source, 16/32/64 destination */
118
119#define ACPI_MOVE_64_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
120
121#define ACPI_MOVE_64_TO_32(d, s) ACPI_MOVE_32_TO_32(d, s) /* Truncate to 32 */
122
123#define ACPI_MOVE_64_TO_64(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[7];\
124 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[6];\
125 (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[5];\
126 (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[4];\
127 (( u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[3];\
128 (( u8 *)(void *)(d))[5] = ((u8 *)(void *)(s))[2];\
129 (( u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\
130 (( u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[0];}
131#else
132/*
133 * Macros for little-endian machines
134 */
135
136#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED
137
138/* The hardware supports unaligned transfers, just do the little-endian move */
139
140/* 16-bit source, 16/32/64 destination */
141
142#define ACPI_MOVE_16_TO_16(d, s) *(u16 *)(void *)(d) = *(u16 *)(void *)(s)
143#define ACPI_MOVE_16_TO_32(d, s) *(u32 *)(void *)(d) = *(u16 *)(void *)(s)
144#define ACPI_MOVE_16_TO_64(d, s) *(u64 *)(void *)(d) = *(u16 *)(void *)(s)
145
146/* 32-bit source, 16/32/64 destination */
147
148#define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
149#define ACPI_MOVE_32_TO_32(d, s) *(u32 *)(void *)(d) = *(u32 *)(void *)(s)
150#define ACPI_MOVE_32_TO_64(d, s) *(u64 *)(void *)(d) = *(u32 *)(void *)(s)
151
152/* 64-bit source, 16/32/64 destination */
153
154#define ACPI_MOVE_64_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
155#define ACPI_MOVE_64_TO_32(d, s) ACPI_MOVE_32_TO_32(d, s) /* Truncate to 32 */
156#define ACPI_MOVE_64_TO_64(d, s) *(u64 *)(void *)(d) = *(u64 *)(void *)(s)
157
158#else
159/*
160 * The hardware does not support unaligned transfers. We must move the
161 * data one byte at a time. These macros work whether the source or
162 * the destination (or both) is/are unaligned. (Little-endian move)
163 */
164
165/* 16-bit source, 16/32/64 destination */
166
167#define ACPI_MOVE_16_TO_16(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\
168 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];}
169
170#define ACPI_MOVE_16_TO_32(d, s) {(*(u32 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d, s);}
171#define ACPI_MOVE_16_TO_64(d, s) {(*(u64 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d, s);}
172
173/* 32-bit source, 16/32/64 destination */
174
175#define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
176
177#define ACPI_MOVE_32_TO_32(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\
178 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];\
179 (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[2];\
180 (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[3];}
181
182#define ACPI_MOVE_32_TO_64(d, s) {(*(u64 *)(void *)(d)) = 0; ACPI_MOVE_32_TO_32(d, s);}
183
184/* 64-bit source, 16/32/64 destination */
185
186#define ACPI_MOVE_64_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
187#define ACPI_MOVE_64_TO_32(d, s) ACPI_MOVE_32_TO_32(d, s) /* Truncate to 32 */
188#define ACPI_MOVE_64_TO_64(d, s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[0];\
189 (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[1];\
190 (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[2];\
191 (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[3];\
192 (( u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[4];\
193 (( u8 *)(void *)(d))[5] = ((u8 *)(void *)(s))[5];\
194 (( u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[6];\
195 (( u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[7];}
196#endif
197#endif
198
199/* Macros based on machine integer width */
200
201#if ACPI_MACHINE_WIDTH == 32
202#define ACPI_MOVE_SIZE_TO_16(d, s) ACPI_MOVE_32_TO_16(d, s)
203
204#elif ACPI_MACHINE_WIDTH == 64
205#define ACPI_MOVE_SIZE_TO_16(d, s) ACPI_MOVE_64_TO_16(d, s)
206
207#else
208#error unknown ACPI_MACHINE_WIDTH
209#endif
210
211/*
212 * Fast power-of-two math macros for non-optimized compilers
213 */
214#define _ACPI_DIV(value, power_of2) ((u32) ((value) >> (power_of2)))
215#define _ACPI_MUL(value, power_of2) ((u32) ((value) << (power_of2)))
216#define _ACPI_MOD(value, divisor) ((u32) ((value) & ((divisor) -1)))
217
218#define ACPI_DIV_2(a) _ACPI_DIV(a, 1)
219#define ACPI_MUL_2(a) _ACPI_MUL(a, 1)
220#define ACPI_MOD_2(a) _ACPI_MOD(a, 2)
221
222#define ACPI_DIV_4(a) _ACPI_DIV(a, 2)
223#define ACPI_MUL_4(a) _ACPI_MUL(a, 2)
224#define ACPI_MOD_4(a) _ACPI_MOD(a, 4)
225
226#define ACPI_DIV_8(a) _ACPI_DIV(a, 3)
227#define ACPI_MUL_8(a) _ACPI_MUL(a, 3)
228#define ACPI_MOD_8(a) _ACPI_MOD(a, 8)
229
230#define ACPI_DIV_16(a) _ACPI_DIV(a, 4)
231#define ACPI_MUL_16(a) _ACPI_MUL(a, 4)
232#define ACPI_MOD_16(a) _ACPI_MOD(a, 16)
233
234#define ACPI_DIV_32(a) _ACPI_DIV(a, 5)
235#define ACPI_MUL_32(a) _ACPI_MUL(a, 5)
236#define ACPI_MOD_32(a) _ACPI_MOD(a, 32)
237
238/*
239 * Rounding macros (Power of two boundaries only)
240 */
241#define ACPI_ROUND_DOWN(value, boundary) (((acpi_size)(value)) & \
242 (~(((acpi_size) boundary)-1)))
243
244#define ACPI_ROUND_UP(value, boundary) ((((acpi_size)(value)) + \
245 (((acpi_size) boundary)-1)) & \
246 (~(((acpi_size) boundary)-1)))
247
248/* Note: sizeof(acpi_size) evaluates to either 4 or 8 (32- vs 64-bit mode) */
249
250#define ACPI_ROUND_DOWN_TO_32BIT(a) ACPI_ROUND_DOWN(a, 4)
251#define ACPI_ROUND_DOWN_TO_64BIT(a) ACPI_ROUND_DOWN(a, 8)
252#define ACPI_ROUND_DOWN_TO_NATIVE_WORD(a) ACPI_ROUND_DOWN(a, sizeof(acpi_size))
253
254#define ACPI_ROUND_UP_TO_32BIT(a) ACPI_ROUND_UP(a, 4)
255#define ACPI_ROUND_UP_TO_64BIT(a) ACPI_ROUND_UP(a, 8)
256#define ACPI_ROUND_UP_TO_NATIVE_WORD(a) ACPI_ROUND_UP(a, sizeof(acpi_size))
257
258#define ACPI_ROUND_BITS_UP_TO_BYTES(a) ACPI_DIV_8((a) + 7)
259#define ACPI_ROUND_BITS_DOWN_TO_BYTES(a) ACPI_DIV_8((a))
260
261#define ACPI_ROUND_UP_TO_1K(a) (((a) + 1023) >> 10)
262
263/* Generic (non-power-of-two) rounding */
264
265#define ACPI_ROUND_UP_TO(value, boundary) (((value) + ((boundary)-1)) / (boundary))
266
267#define ACPI_IS_MISALIGNED(value) (((acpi_size) value) & (sizeof(acpi_size)-1))
268
269/*
270 * Bitmask creation
271 * Bit positions start at zero.
272 * MASK_BITS_ABOVE creates a mask starting AT the position and above
273 * MASK_BITS_BELOW creates a mask starting one bit BELOW the position
274 */
275#define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_INTEGER_MAX) << ((u32) (position))))
276#define ACPI_MASK_BITS_BELOW(position) ((ACPI_INTEGER_MAX) << ((u32) (position)))
277
278/* Bitfields within ACPI registers */
279
280#define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) ((val << pos) & mask)
281#define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val) reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask)
282
283#define ACPI_INSERT_BITS(target, mask, source) target = ((target & (~(mask))) | (source & mask))
284
285/*
286 * A struct acpi_namespace_node can appear in some contexts
287 * where a pointer to a union acpi_operand_object can also
288 * appear. This macro is used to distinguish them.
289 *
290 * The "Descriptor" field is the first field in both structures.
291 */
292#define ACPI_GET_DESCRIPTOR_TYPE(d) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type)
293#define ACPI_SET_DESCRIPTOR_TYPE(d, t) (((union acpi_descriptor *)(void *)(d))->common.descriptor_type = t)
294
295/* Macro to test the object type */
296
297#define ACPI_GET_OBJECT_TYPE(d) (((union acpi_operand_object *)(void *)(d))->common.type)
298
299/*
300 * Macros for the master AML opcode table
301 */
302#if defined (ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT)
303#define ACPI_OP(name, Pargs, Iargs, obj_type, class, type, flags) \
304 {name, (u32)(Pargs), (u32)(Iargs), (u32)(flags), obj_type, class, type}
305#else
306#define ACPI_OP(name, Pargs, Iargs, obj_type, class, type, flags) \
307 {(u32)(Pargs), (u32)(Iargs), (u32)(flags), obj_type, class, type}
308#endif
309
310#define ARG_TYPE_WIDTH 5
311#define ARG_1(x) ((u32)(x))
312#define ARG_2(x) ((u32)(x) << (1 * ARG_TYPE_WIDTH))
313#define ARG_3(x) ((u32)(x) << (2 * ARG_TYPE_WIDTH))
314#define ARG_4(x) ((u32)(x) << (3 * ARG_TYPE_WIDTH))
315#define ARG_5(x) ((u32)(x) << (4 * ARG_TYPE_WIDTH))
316#define ARG_6(x) ((u32)(x) << (5 * ARG_TYPE_WIDTH))
317
318#define ARGI_LIST1(a) (ARG_1(a))
319#define ARGI_LIST2(a, b) (ARG_1(b)|ARG_2(a))
320#define ARGI_LIST3(a, b, c) (ARG_1(c)|ARG_2(b)|ARG_3(a))
321#define ARGI_LIST4(a, b, c, d) (ARG_1(d)|ARG_2(c)|ARG_3(b)|ARG_4(a))
322#define ARGI_LIST5(a, b, c, d, e) (ARG_1(e)|ARG_2(d)|ARG_3(c)|ARG_4(b)|ARG_5(a))
323#define ARGI_LIST6(a, b, c, d, e, f) (ARG_1(f)|ARG_2(e)|ARG_3(d)|ARG_4(c)|ARG_5(b)|ARG_6(a))
324
325#define ARGP_LIST1(a) (ARG_1(a))
326#define ARGP_LIST2(a, b) (ARG_1(a)|ARG_2(b))
327#define ARGP_LIST3(a, b, c) (ARG_1(a)|ARG_2(b)|ARG_3(c))
328#define ARGP_LIST4(a, b, c, d) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d))
329#define ARGP_LIST5(a, b, c, d, e) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e))
330#define ARGP_LIST6(a, b, c, d, e, f) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)|ARG_6(f))
331
332#define GET_CURRENT_ARG_TYPE(list) (list & ((u32) 0x1F))
333#define INCREMENT_ARG_LIST(list) (list >>= ((u32) ARG_TYPE_WIDTH))
334
335/*
336 * Ascii error messages can be configured out
337 */
338#ifndef ACPI_NO_ERROR_MESSAGES
339
340/*
341 * Error reporting. Callers module and line number are inserted by AE_INFO,
342 * the plist contains a set of parens to allow variable-length lists.
343 * These macros are used for both the debug and non-debug versions of the code.
344 */
345#define ACPI_ERROR_NAMESPACE(s, e) acpi_ns_report_error (AE_INFO, s, e);
346#define ACPI_ERROR_METHOD(s, n, p, e) acpi_ns_report_method_error (AE_INFO, s, n, p, e);
347
348#else
349
350/* No error messages */
351
352#define ACPI_ERROR_NAMESPACE(s, e)
353#define ACPI_ERROR_METHOD(s, n, p, e)
354#endif /* ACPI_NO_ERROR_MESSAGES */
355
356/*
357 * Debug macros that are conditionally compiled
358 */
359#ifdef ACPI_DEBUG_OUTPUT
360
361/*
362 * Function entry tracing
363 */
364#ifdef CONFIG_ACPI_DEBUG_FUNC_TRACE
365
366#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \
367 acpi_ut_trace(ACPI_DEBUG_PARAMETERS)
368#define ACPI_FUNCTION_TRACE_PTR(a, b) ACPI_FUNCTION_NAME(a) \
369 acpi_ut_trace_ptr(ACPI_DEBUG_PARAMETERS, (void *)b)
370#define ACPI_FUNCTION_TRACE_U32(a, b) ACPI_FUNCTION_NAME(a) \
371 acpi_ut_trace_u32(ACPI_DEBUG_PARAMETERS, (u32)b)
372#define ACPI_FUNCTION_TRACE_STR(a, b) ACPI_FUNCTION_NAME(a) \
373 acpi_ut_trace_str(ACPI_DEBUG_PARAMETERS, (char *)b)
374
375#define ACPI_FUNCTION_ENTRY() acpi_ut_track_stack_ptr()
376
377/*
378 * Function exit tracing.
379 * WARNING: These macros include a return statement. This is usually considered
380 * bad form, but having a separate exit macro is very ugly and difficult to maintain.
381 * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros
382 * so that "_AcpiFunctionName" is defined.
383 *
384 * Note: the DO_WHILE0 macro is used to prevent some compilers from complaining
385 * about these constructs.
386 */
387#ifdef ACPI_USE_DO_WHILE_0
388#define ACPI_DO_WHILE0(a) do a while(0)
389#else
390#define ACPI_DO_WHILE0(a) a
391#endif
392
393#define return_VOID ACPI_DO_WHILE0 ({ \
394 acpi_ut_exit (ACPI_DEBUG_PARAMETERS); \
395 return;})
396/*
397 * There are two versions of most of the return macros. The default version is
398 * safer, since it avoids side-effects by guaranteeing that the argument will
399 * not be evaluated twice.
400 *
401 * A less-safe version of the macros is provided for optional use if the
402 * compiler uses excessive CPU stack (for example, this may happen in the
403 * debug case if code optimzation is disabled.)
404 */
405#ifndef ACPI_SIMPLE_RETURN_MACROS
406
407#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({ \
408 register acpi_status _s = (s); \
409 acpi_ut_status_exit (ACPI_DEBUG_PARAMETERS, _s); \
410 return (_s); })
411#define return_PTR(s) ACPI_DO_WHILE0 ({ \
412 register void *_s = (void *) (s); \
413 acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) _s); \
414 return (_s); })
415#define return_VALUE(s) ACPI_DO_WHILE0 ({ \
416 register acpi_integer _s = (s); \
417 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, _s); \
418 return (_s); })
419#define return_UINT8(s) ACPI_DO_WHILE0 ({ \
420 register u8 _s = (u8) (s); \
421 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (acpi_integer) _s); \
422 return (_s); })
423#define return_UINT32(s) ACPI_DO_WHILE0 ({ \
424 register u32 _s = (u32) (s); \
425 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (acpi_integer) _s); \
426 return (_s); })
427#else /* Use original less-safe macros */
428
429#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({ \
430 acpi_ut_status_exit (ACPI_DEBUG_PARAMETERS, (s)); \
431 return((s)); })
432#define return_PTR(s) ACPI_DO_WHILE0 ({ \
433 acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) (s)); \
434 return((s)); })
435#define return_VALUE(s) ACPI_DO_WHILE0 ({ \
436 acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (acpi_integer) (s)); \
437 return((s)); })
438#define return_UINT8(s) return_VALUE(s)
439#define return_UINT32(s) return_VALUE(s)
440
441#endif /* ACPI_SIMPLE_RETURN_MACROS */
442
443#else /* !CONFIG_ACPI_DEBUG_FUNC_TRACE */
444
445#define ACPI_FUNCTION_TRACE(a)
446#define ACPI_FUNCTION_TRACE_PTR(a,b)
447#define ACPI_FUNCTION_TRACE_U32(a,b)
448#define ACPI_FUNCTION_TRACE_STR(a,b)
449#define ACPI_FUNCTION_EXIT
450#define ACPI_FUNCTION_STATUS_EXIT(s)
451#define ACPI_FUNCTION_VALUE_EXIT(s)
452#define ACPI_FUNCTION_TRACE(a)
453#define ACPI_FUNCTION_ENTRY()
454
455#define return_VOID return
456#define return_ACPI_STATUS(s) return(s)
457#define return_VALUE(s) return(s)
458#define return_UINT8(s) return(s)
459#define return_UINT32(s) return(s)
460#define return_PTR(s) return(s)
461
462#endif /* CONFIG_ACPI_DEBUG_FUNC_TRACE */
463
464/* Conditional execution */
465
466#define ACPI_DEBUG_EXEC(a) a
467#define ACPI_NORMAL_EXEC(a)
468
469#define ACPI_DEBUG_DEFINE(a) a;
470#define ACPI_DEBUG_ONLY_MEMBERS(a) a;
471#define _VERBOSE_STRUCTURES
472
473/* Stack and buffer dumping */
474
475#define ACPI_DUMP_STACK_ENTRY(a) acpi_ex_dump_operand((a), 0)
476#define ACPI_DUMP_OPERANDS(a, b, c) acpi_ex_dump_operands(a, b, c)
477
478#define ACPI_DUMP_ENTRY(a, b) acpi_ns_dump_entry (a, b)
479#define ACPI_DUMP_PATHNAME(a, b, c, d) acpi_ns_dump_pathname(a, b, c, d)
480#define ACPI_DUMP_RESOURCE_LIST(a) acpi_rs_dump_resource_list(a)
481#define ACPI_DUMP_BUFFER(a, b) acpi_ut_dump_buffer((u8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT)
482
483#else
484/*
485 * This is the non-debug case -- make everything go away,
486 * leaving no executable debug code!
487 */
488#define ACPI_DEBUG_EXEC(a)
489#define ACPI_NORMAL_EXEC(a) a;
490
491#define ACPI_DEBUG_DEFINE(a) do { } while(0)
492#define ACPI_DEBUG_ONLY_MEMBERS(a) do { } while(0)
493#define ACPI_FUNCTION_TRACE(a) do { } while(0)
494#define ACPI_FUNCTION_TRACE_PTR(a, b) do { } while(0)
495#define ACPI_FUNCTION_TRACE_U32(a, b) do { } while(0)
496#define ACPI_FUNCTION_TRACE_STR(a, b) do { } while(0)
497#define ACPI_FUNCTION_EXIT do { } while(0)
498#define ACPI_FUNCTION_STATUS_EXIT(s) do { } while(0)
499#define ACPI_FUNCTION_VALUE_EXIT(s) do { } while(0)
500#define ACPI_FUNCTION_ENTRY() do { } while(0)
501#define ACPI_DUMP_STACK_ENTRY(a) do { } while(0)
502#define ACPI_DUMP_OPERANDS(a, b, c) do { } while(0)
503#define ACPI_DUMP_ENTRY(a, b) do { } while(0)
504#define ACPI_DUMP_TABLES(a, b) do { } while(0)
505#define ACPI_DUMP_PATHNAME(a, b, c, d) do { } while(0)
506#define ACPI_DUMP_RESOURCE_LIST(a) do { } while(0)
507#define ACPI_DUMP_BUFFER(a, b) do { } while(0)
508
509#define return_VOID return
510#define return_ACPI_STATUS(s) return(s)
511#define return_VALUE(s) return(s)
512#define return_UINT8(s) return(s)
513#define return_UINT32(s) return(s)
514#define return_PTR(s) return(s)
515
516#endif /* ACPI_DEBUG_OUTPUT */
517
518/*
519 * Some code only gets executed when the debugger is built in.
520 * Note that this is entirely independent of whether the
521 * DEBUG_PRINT stuff (set by ACPI_DEBUG_OUTPUT) is on, or not.
522 */
523#ifdef ACPI_DEBUGGER
524#define ACPI_DEBUGGER_EXEC(a) a
525#else
526#define ACPI_DEBUGGER_EXEC(a)
527#endif
528
529#ifdef ACPI_DEBUG_OUTPUT
530/*
531 * 1) Set name to blanks
532 * 2) Copy the object name
533 */
534#define ACPI_ADD_OBJECT_NAME(a,b) ACPI_MEMSET (a->common.name, ' ', sizeof (a->common.name));\
535 ACPI_STRNCPY (a->common.name, acpi_gbl_ns_type_names[b], sizeof (a->common.name))
536#else
537
538#define ACPI_ADD_OBJECT_NAME(a,b)
539#endif
540
541/*
542 * Memory allocation tracking (DEBUG ONLY)
543 */
544#define ACPI_MEM_PARAMETERS _COMPONENT, _acpi_module_name, __LINE__
545
546#ifndef ACPI_DBG_TRACK_ALLOCATIONS
547
548/* Memory allocation */
549
550#ifndef ACPI_ALLOCATE
551#define ACPI_ALLOCATE(a) acpi_ut_allocate((acpi_size)(a), ACPI_MEM_PARAMETERS)
552#endif
553#ifndef ACPI_ALLOCATE_ZEROED
554#define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed((acpi_size)(a), ACPI_MEM_PARAMETERS)
555#endif
556#ifndef ACPI_FREE
557#define ACPI_FREE(a) acpio_os_free(a)
558#endif
559#define ACPI_MEM_TRACKING(a)
560
561#else
562
563/* Memory allocation */
564
565#define ACPI_ALLOCATE(a) acpi_ut_allocate_and_track((acpi_size)(a), ACPI_MEM_PARAMETERS)
566#define ACPI_ALLOCATE_ZEROED(a) acpi_ut_allocate_zeroed_and_track((acpi_size)(a), ACPI_MEM_PARAMETERS)
567#define ACPI_FREE(a) acpi_ut_free_and_track(a, ACPI_MEM_PARAMETERS)
568#define ACPI_MEM_TRACKING(a) a
569
570#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
571
572/* Preemption point */
573#ifndef ACPI_PREEMPTION_POINT
574#define ACPI_PREEMPTION_POINT() /* no preemption */
575#endif
576
577#endif /* ACMACROS_H */
diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h
new file mode 100644
index 000000000000..46cb5b46d280
--- /dev/null
+++ b/drivers/acpi/acpica/acnamesp.h
@@ -0,0 +1,324 @@
1/******************************************************************************
2 *
3 * Name: acnamesp.h - Namespace subcomponent prototypes and defines
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACNAMESP_H__
45#define __ACNAMESP_H__
46
47/* To search the entire name space, pass this as search_base */
48
49#define ACPI_NS_ALL ((acpi_handle)0)
50
51/*
52 * Elements of acpi_ns_properties are bit significant
53 * and should be one-to-one with values of acpi_object_type
54 */
55#define ACPI_NS_NORMAL 0
56#define ACPI_NS_NEWSCOPE 1 /* a definition of this type opens a name scope */
57#define ACPI_NS_LOCAL 2 /* suppress search of enclosing scopes */
58
59/* Flags for acpi_ns_lookup, acpi_ns_search_and_enter */
60
61#define ACPI_NS_NO_UPSEARCH 0
62#define ACPI_NS_SEARCH_PARENT 0x01
63#define ACPI_NS_DONT_OPEN_SCOPE 0x02
64#define ACPI_NS_NO_PEER_SEARCH 0x04
65#define ACPI_NS_ERROR_IF_FOUND 0x08
66#define ACPI_NS_PREFIX_IS_SCOPE 0x10
67#define ACPI_NS_EXTERNAL 0x20
68#define ACPI_NS_TEMPORARY 0x40
69
70/* Flags for acpi_ns_walk_namespace */
71
72#define ACPI_NS_WALK_NO_UNLOCK 0
73#define ACPI_NS_WALK_UNLOCK 0x01
74#define ACPI_NS_WALK_TEMP_NODES 0x02
75
76/*
77 * nsinit - Namespace initialization
78 */
79acpi_status acpi_ns_initialize_objects(void);
80
81acpi_status acpi_ns_initialize_devices(void);
82
83/*
84 * nsload - Namespace loading
85 */
86acpi_status acpi_ns_load_namespace(void);
87
88acpi_status
89acpi_ns_load_table(u32 table_index, struct acpi_namespace_node *node);
90
91/*
92 * nswalk - walk the namespace
93 */
94acpi_status
95acpi_ns_walk_namespace(acpi_object_type type,
96 acpi_handle start_object,
97 u32 max_depth,
98 u32 flags,
99 acpi_walk_callback user_function,
100 void *context, void **return_value);
101
102struct acpi_namespace_node *acpi_ns_get_next_node(acpi_object_type type, struct acpi_namespace_node
103 *parent, struct acpi_namespace_node
104 *child);
105
106/*
107 * nsparse - table parsing
108 */
109acpi_status
110acpi_ns_parse_table(u32 table_index, struct acpi_namespace_node *start_node);
111
112acpi_status
113acpi_ns_one_complete_parse(u32 pass_number,
114 u32 table_index,
115 struct acpi_namespace_node *start_node);
116
117/*
118 * nsaccess - Top-level namespace access
119 */
120acpi_status acpi_ns_root_initialize(void);
121
122acpi_status
123acpi_ns_lookup(union acpi_generic_state *scope_info,
124 char *name,
125 acpi_object_type type,
126 acpi_interpreter_mode interpreter_mode,
127 u32 flags,
128 struct acpi_walk_state *walk_state,
129 struct acpi_namespace_node **ret_node);
130
131/*
132 * nsalloc - Named object allocation/deallocation
133 */
134struct acpi_namespace_node *acpi_ns_create_node(u32 name);
135
136void acpi_ns_delete_node(struct acpi_namespace_node *node);
137
138void
139acpi_ns_delete_namespace_subtree(struct acpi_namespace_node *parent_handle);
140
141void acpi_ns_delete_namespace_by_owner(acpi_owner_id owner_id);
142
143void acpi_ns_detach_object(struct acpi_namespace_node *node);
144
145void acpi_ns_delete_children(struct acpi_namespace_node *parent);
146
147int acpi_ns_compare_names(char *name1, char *name2);
148
149/*
150 * nsdump - Namespace dump/print utilities
151 */
152#ifdef ACPI_FUTURE_USAGE
153void acpi_ns_dump_tables(acpi_handle search_base, u32 max_depth);
154#endif /* ACPI_FUTURE_USAGE */
155
156void acpi_ns_dump_entry(acpi_handle handle, u32 debug_level);
157
158void
159acpi_ns_dump_pathname(acpi_handle handle, char *msg, u32 level, u32 component);
160
161void acpi_ns_print_pathname(u32 num_segments, char *pathname);
162
163acpi_status
164acpi_ns_dump_one_object(acpi_handle obj_handle,
165 u32 level, void *context, void **return_value);
166
167#ifdef ACPI_FUTURE_USAGE
168void
169acpi_ns_dump_objects(acpi_object_type type,
170 u8 display_type,
171 u32 max_depth,
172 acpi_owner_id owner_id, acpi_handle start_handle);
173#endif /* ACPI_FUTURE_USAGE */
174
175/*
176 * nseval - Namespace evaluation functions
177 */
178acpi_status acpi_ns_evaluate(struct acpi_evaluate_info *info);
179
180/*
181 * nspredef - Support for predefined/reserved names
182 */
183acpi_status
184acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
185 u32 user_param_count,
186 acpi_status return_status,
187 union acpi_operand_object **return_object);
188
189const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct
190 acpi_namespace_node
191 *node);
192
193void
194acpi_ns_check_parameter_count(char *pathname,
195 struct acpi_namespace_node *node,
196 u32 user_param_count,
197 const union acpi_predefined_info *info);
198
199/*
200 * nsnames - Name and Scope manipulation
201 */
202u32 acpi_ns_opens_scope(acpi_object_type type);
203
204acpi_status
205acpi_ns_build_external_path(struct acpi_namespace_node *node,
206 acpi_size size, char *name_buffer);
207
208char *acpi_ns_get_external_pathname(struct acpi_namespace_node *node);
209
210char *acpi_ns_name_of_current_scope(struct acpi_walk_state *walk_state);
211
212acpi_status
213acpi_ns_handle_to_pathname(acpi_handle target_handle,
214 struct acpi_buffer *buffer);
215
216u8
217acpi_ns_pattern_match(struct acpi_namespace_node *obj_node, char *search_for);
218
219acpi_status
220acpi_ns_get_node(struct acpi_namespace_node *prefix_node,
221 const char *external_pathname,
222 u32 flags, struct acpi_namespace_node **out_node);
223
224acpi_size acpi_ns_get_pathname_length(struct acpi_namespace_node *node);
225
226/*
227 * nsobject - Object management for namespace nodes
228 */
229acpi_status
230acpi_ns_attach_object(struct acpi_namespace_node *node,
231 union acpi_operand_object *object, acpi_object_type type);
232
233union acpi_operand_object *acpi_ns_get_attached_object(struct
234 acpi_namespace_node
235 *node);
236
237union acpi_operand_object *acpi_ns_get_secondary_object(union
238 acpi_operand_object
239 *obj_desc);
240
241acpi_status
242acpi_ns_attach_data(struct acpi_namespace_node *node,
243 acpi_object_handler handler, void *data);
244
245acpi_status
246acpi_ns_detach_data(struct acpi_namespace_node *node,
247 acpi_object_handler handler);
248
249acpi_status
250acpi_ns_get_attached_data(struct acpi_namespace_node *node,
251 acpi_object_handler handler, void **data);
252
253/*
254 * nssearch - Namespace searching and entry
255 */
256acpi_status
257acpi_ns_search_and_enter(u32 entry_name,
258 struct acpi_walk_state *walk_state,
259 struct acpi_namespace_node *node,
260 acpi_interpreter_mode interpreter_mode,
261 acpi_object_type type,
262 u32 flags, struct acpi_namespace_node **ret_node);
263
264acpi_status
265acpi_ns_search_one_scope(u32 entry_name,
266 struct acpi_namespace_node *node,
267 acpi_object_type type,
268 struct acpi_namespace_node **ret_node);
269
270void
271acpi_ns_install_node(struct acpi_walk_state *walk_state,
272 struct acpi_namespace_node *parent_node,
273 struct acpi_namespace_node *node, acpi_object_type type);
274
275/*
276 * nsutils - Utility functions
277 */
278u8 acpi_ns_valid_root_prefix(char prefix);
279
280acpi_object_type acpi_ns_get_type(struct acpi_namespace_node *node);
281
282u32 acpi_ns_local(acpi_object_type type);
283
284void
285acpi_ns_report_error(const char *module_name,
286 u32 line_number,
287 const char *internal_name, acpi_status lookup_status);
288
289void
290acpi_ns_report_method_error(const char *module_name,
291 u32 line_number,
292 const char *message,
293 struct acpi_namespace_node *node,
294 const char *path, acpi_status lookup_status);
295
296void
297acpi_ns_print_node_pathname(struct acpi_namespace_node *node, const char *msg);
298
299acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info);
300
301void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info);
302
303acpi_status
304acpi_ns_internalize_name(const char *dotted_name, char **converted_name);
305
306acpi_status
307acpi_ns_externalize_name(u32 internal_name_length,
308 const char *internal_name,
309 u32 * converted_name_length, char **converted_name);
310
311struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle);
312
313acpi_handle acpi_ns_convert_entry_to_handle(struct acpi_namespace_node *node);
314
315void acpi_ns_terminate(void);
316
317struct acpi_namespace_node *acpi_ns_get_parent_node(struct acpi_namespace_node
318 *node);
319
320struct acpi_namespace_node *acpi_ns_get_next_valid_node(struct
321 acpi_namespace_node
322 *node);
323
324#endif /* __ACNAMESP_H__ */
diff --git a/drivers/acpi/acpica/acobject.h b/drivers/acpi/acpica/acobject.h
new file mode 100644
index 000000000000..eb6f038b03d9
--- /dev/null
+++ b/drivers/acpi/acpica/acobject.h
@@ -0,0 +1,446 @@
1
2/******************************************************************************
3 *
4 * Name: acobject.h - Definition of union acpi_operand_object (Internal object only)
5 *
6 *****************************************************************************/
7
8/*
9 * Copyright (C) 2000 - 2008, Intel Corp.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
30 *
31 * NO WARRANTY
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
43 */
44
45#ifndef _ACOBJECT_H
46#define _ACOBJECT_H
47
48/* acpisrc:struct_defs -- for acpisrc conversion */
49
50/*
51 * The union acpi_operand_object is used to pass AML operands from the dispatcher
52 * to the interpreter, and to keep track of the various handlers such as
53 * address space handlers and notify handlers. The object is a constant
54 * size in order to allow it to be cached and reused.
55 *
56 * Note: The object is optimized to be aligned and will not work if it is
57 * byte-packed.
58 */
59#if ACPI_MACHINE_WIDTH == 64
60#pragma pack(8)
61#else
62#pragma pack(4)
63#endif
64
65/*******************************************************************************
66 *
67 * Common Descriptors
68 *
69 ******************************************************************************/
70
71/*
72 * Common area for all objects.
73 *
74 * descriptor_type is used to differentiate between internal descriptors, and
75 * must be in the same place across all descriptors
76 *
77 * Note: The descriptor_type and Type fields must appear in the identical
78 * position in both the struct acpi_namespace_node and union acpi_operand_object
79 * structures.
80 */
81#define ACPI_OBJECT_COMMON_HEADER \
82 union acpi_operand_object *next_object; /* Objects linked to parent NS node */\
83 u8 descriptor_type; /* To differentiate various internal objs */\
84 u8 type; /* acpi_object_type */\
85 u16 reference_count; /* For object deletion management */\
86 u8 flags;
87 /*
88 * Note: There are 3 bytes available here before the
89 * next natural alignment boundary (for both 32/64 cases)
90 */
91
92/* Values for Flag byte above */
93
94#define AOPOBJ_AML_CONSTANT 0x01
95#define AOPOBJ_STATIC_POINTER 0x02
96#define AOPOBJ_DATA_VALID 0x04
97#define AOPOBJ_OBJECT_INITIALIZED 0x08
98#define AOPOBJ_SETUP_COMPLETE 0x10
99#define AOPOBJ_SINGLE_DATUM 0x20
100#define AOPOBJ_INVALID 0x40 /* Used if host OS won't allow an op_region address */
101
102/******************************************************************************
103 *
104 * Basic data types
105 *
106 *****************************************************************************/
107
108struct acpi_object_common {
109ACPI_OBJECT_COMMON_HEADER};
110
111struct acpi_object_integer {
112 ACPI_OBJECT_COMMON_HEADER u8 fill[3]; /* Prevent warning on some compilers */
113 acpi_integer value;
114};
115
116/*
117 * Note: The String and Buffer object must be identical through the Pointer
118 * and length elements. There is code that depends on this.
119 *
120 * Fields common to both Strings and Buffers
121 */
122#define ACPI_COMMON_BUFFER_INFO(_type) \
123 _type *pointer; \
124 u32 length;
125
126struct acpi_object_string { /* Null terminated, ASCII characters only */
127 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_BUFFER_INFO(char) /* String in AML stream or allocated string */
128};
129
130struct acpi_object_buffer {
131 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_BUFFER_INFO(u8) /* Buffer in AML stream or allocated buffer */
132 u32 aml_length;
133 u8 *aml_start;
134 struct acpi_namespace_node *node; /* Link back to parent node */
135};
136
137struct acpi_object_package {
138 ACPI_OBJECT_COMMON_HEADER struct acpi_namespace_node *node; /* Link back to parent node */
139 union acpi_operand_object **elements; /* Array of pointers to acpi_objects */
140 u8 *aml_start;
141 u32 aml_length;
142 u32 count; /* # of elements in package */
143};
144
145/******************************************************************************
146 *
147 * Complex data types
148 *
149 *****************************************************************************/
150
151struct acpi_object_event {
152 ACPI_OBJECT_COMMON_HEADER acpi_semaphore os_semaphore; /* Actual OS synchronization object */
153};
154
155struct acpi_object_mutex {
156 ACPI_OBJECT_COMMON_HEADER u8 sync_level; /* 0-15, specified in Mutex() call */
157 u16 acquisition_depth; /* Allow multiple Acquires, same thread */
158 acpi_mutex os_mutex; /* Actual OS synchronization object */
159 acpi_thread_id thread_id; /* Current owner of the mutex */
160 struct acpi_thread_state *owner_thread; /* Current owner of the mutex */
161 union acpi_operand_object *prev; /* Link for list of acquired mutexes */
162 union acpi_operand_object *next; /* Link for list of acquired mutexes */
163 struct acpi_namespace_node *node; /* Containing namespace node */
164 u8 original_sync_level; /* Owner's original sync level (0-15) */
165};
166
167struct acpi_object_region {
168 ACPI_OBJECT_COMMON_HEADER u8 space_id;
169 struct acpi_namespace_node *node; /* Containing namespace node */
170 union acpi_operand_object *handler; /* Handler for region access */
171 union acpi_operand_object *next;
172 acpi_physical_address address;
173 u32 length;
174};
175
176struct acpi_object_method {
177 ACPI_OBJECT_COMMON_HEADER u8 method_flags;
178 u8 param_count;
179 u8 sync_level;
180 union acpi_operand_object *mutex;
181 u8 *aml_start;
182 ACPI_INTERNAL_METHOD implementation;
183 u32 aml_length;
184 u8 thread_count;
185 acpi_owner_id owner_id;
186};
187
188/******************************************************************************
189 *
190 * Objects that can be notified. All share a common notify_info area.
191 *
192 *****************************************************************************/
193
194/*
195 * Common fields for objects that support ASL notifications
196 */
197#define ACPI_COMMON_NOTIFY_INFO \
198 union acpi_operand_object *system_notify; /* Handler for system notifies */\
199 union acpi_operand_object *device_notify; /* Handler for driver notifies */\
200 union acpi_operand_object *handler; /* Handler for Address space */
201
202struct acpi_object_notify_common { /* COMMON NOTIFY for POWER, PROCESSOR, DEVICE, and THERMAL */
203ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO};
204
205struct acpi_object_device {
206 ACPI_OBJECT_COMMON_HEADER
207 ACPI_COMMON_NOTIFY_INFO struct acpi_gpe_block_info *gpe_block;
208};
209
210struct acpi_object_power_resource {
211 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO u32 system_level;
212 u32 resource_order;
213};
214
215struct acpi_object_processor {
216 ACPI_OBJECT_COMMON_HEADER
217 /* The next two fields take advantage of the 3-byte space before NOTIFY_INFO */
218 u8 proc_id;
219 u8 length;
220 ACPI_COMMON_NOTIFY_INFO acpi_io_address address;
221};
222
223struct acpi_object_thermal_zone {
224ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO};
225
226/******************************************************************************
227 *
228 * Fields. All share a common header/info field.
229 *
230 *****************************************************************************/
231
232/*
233 * Common bitfield for the field objects
234 * "Field Datum" -- a datum from the actual field object
235 * "Buffer Datum" -- a datum from a user buffer, read from or to be written to the field
236 */
237#define ACPI_COMMON_FIELD_INFO \
238 u8 field_flags; /* Access, update, and lock bits */\
239 u8 attribute; /* From access_as keyword */\
240 u8 access_byte_width; /* Read/Write size in bytes */\
241 struct acpi_namespace_node *node; /* Link back to parent node */\
242 u32 bit_length; /* Length of field in bits */\
243 u32 base_byte_offset; /* Byte offset within containing object */\
244 u32 value; /* Value to store into the Bank or Index register */\
245 u8 start_field_bit_offset;/* Bit offset within first field datum (0-63) */\
246 u8 access_bit_width; /* Read/Write size in bits (8-64) */
247
248struct acpi_object_field_common { /* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */
249 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_object *region_obj; /* Parent Operation Region object (REGION/BANK fields only) */
250};
251
252struct acpi_object_region_field {
253 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_object *region_obj; /* Containing op_region object */
254};
255
256struct acpi_object_bank_field {
257 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_object *region_obj; /* Containing op_region object */
258 union acpi_operand_object *bank_obj; /* bank_select Register object */
259};
260
261struct acpi_object_index_field {
262 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO
263 /*
264 * No "RegionObj" pointer needed since the Index and Data registers
265 * are each field definitions unto themselves.
266 */
267 union acpi_operand_object *index_obj; /* Index register */
268 union acpi_operand_object *data_obj; /* Data register */
269};
270
271/* The buffer_field is different in that it is part of a Buffer, not an op_region */
272
273struct acpi_object_buffer_field {
274 ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_object *buffer_obj; /* Containing Buffer object */
275};
276
277/******************************************************************************
278 *
279 * Objects for handlers
280 *
281 *****************************************************************************/
282
283struct acpi_object_notify_handler {
284 ACPI_OBJECT_COMMON_HEADER struct acpi_namespace_node *node; /* Parent device */
285 acpi_notify_handler handler;
286 void *context;
287};
288
289struct acpi_object_addr_handler {
290 ACPI_OBJECT_COMMON_HEADER u8 space_id;
291 u8 handler_flags;
292 acpi_adr_space_handler handler;
293 struct acpi_namespace_node *node; /* Parent device */
294 void *context;
295 acpi_adr_space_setup setup;
296 union acpi_operand_object *region_list; /* regions using this handler */
297 union acpi_operand_object *next;
298};
299
300/* Flags for address handler (handler_flags) */
301
302#define ACPI_ADDR_HANDLER_DEFAULT_INSTALLED 0x01
303
304/******************************************************************************
305 *
306 * Special internal objects
307 *
308 *****************************************************************************/
309
310/*
311 * The Reference object is used for these opcodes:
312 * Arg[0-6], Local[0-7], index_op, name_op, ref_of_op, load_op, load_table_op, debug_op
313 * The Reference.Class differentiates these types.
314 */
315struct acpi_object_reference {
316 ACPI_OBJECT_COMMON_HEADER u8 class; /* Reference Class */
317 u8 target_type; /* Used for Index Op */
318 u8 reserved;
319 void *object; /* name_op=>HANDLE to obj, index_op=>union acpi_operand_object */
320 struct acpi_namespace_node *node; /* ref_of or Namepath */
321 union acpi_operand_object **where; /* Target of Index */
322 u32 value; /* Used for Local/Arg/Index/ddb_handle */
323};
324
325/* Values for Reference.Class above */
326
327typedef enum {
328 ACPI_REFCLASS_LOCAL = 0, /* Method local */
329 ACPI_REFCLASS_ARG = 1, /* Method argument */
330 ACPI_REFCLASS_REFOF = 2, /* Result of ref_of() TBD: Split to Ref/Node and Ref/operand_obj? */
331 ACPI_REFCLASS_INDEX = 3, /* Result of Index() */
332 ACPI_REFCLASS_TABLE = 4, /* ddb_handle - Load(), load_table() */
333 ACPI_REFCLASS_NAME = 5, /* Reference to a named object */
334 ACPI_REFCLASS_DEBUG = 6, /* Debug object */
335
336 ACPI_REFCLASS_MAX = 6
337} ACPI_REFERENCE_CLASSES;
338
339/*
340 * Extra object is used as additional storage for types that
341 * have AML code in their declarations (term_args) that must be
342 * evaluated at run time.
343 *
344 * Currently: Region and field_unit types
345 */
346struct acpi_object_extra {
347 ACPI_OBJECT_COMMON_HEADER struct acpi_namespace_node *method_REG; /* _REG method for this region (if any) */
348 void *region_context; /* Region-specific data */
349 u8 *aml_start;
350 u32 aml_length;
351};
352
353/* Additional data that can be attached to namespace nodes */
354
355struct acpi_object_data {
356 ACPI_OBJECT_COMMON_HEADER acpi_object_handler handler;
357 void *pointer;
358};
359
360/* Structure used when objects are cached for reuse */
361
362struct acpi_object_cache_list {
363 ACPI_OBJECT_COMMON_HEADER union acpi_operand_object *next; /* Link for object cache and internal lists */
364};
365
366/******************************************************************************
367 *
368 * union acpi_operand_object Descriptor - a giant union of all of the above
369 *
370 *****************************************************************************/
371
372union acpi_operand_object {
373 struct acpi_object_common common;
374 struct acpi_object_integer integer;
375 struct acpi_object_string string;
376 struct acpi_object_buffer buffer;
377 struct acpi_object_package package;
378 struct acpi_object_event event;
379 struct acpi_object_method method;
380 struct acpi_object_mutex mutex;
381 struct acpi_object_region region;
382 struct acpi_object_notify_common common_notify;
383 struct acpi_object_device device;
384 struct acpi_object_power_resource power_resource;
385 struct acpi_object_processor processor;
386 struct acpi_object_thermal_zone thermal_zone;
387 struct acpi_object_field_common common_field;
388 struct acpi_object_region_field field;
389 struct acpi_object_buffer_field buffer_field;
390 struct acpi_object_bank_field bank_field;
391 struct acpi_object_index_field index_field;
392 struct acpi_object_notify_handler notify;
393 struct acpi_object_addr_handler address_space;
394 struct acpi_object_reference reference;
395 struct acpi_object_extra extra;
396 struct acpi_object_data data;
397 struct acpi_object_cache_list cache;
398
399 /*
400 * Add namespace node to union in order to simplify code that accepts both
401 * ACPI_OPERAND_OBJECTs and ACPI_NAMESPACE_NODEs. The structures share
402 * a common descriptor_type field in order to differentiate them.
403 */
404 struct acpi_namespace_node node;
405};
406
407/******************************************************************************
408 *
409 * union acpi_descriptor - objects that share a common descriptor identifier
410 *
411 *****************************************************************************/
412
413/* Object descriptor types */
414
415#define ACPI_DESC_TYPE_CACHED 0x01 /* Used only when object is cached */
416#define ACPI_DESC_TYPE_STATE 0x02
417#define ACPI_DESC_TYPE_STATE_UPDATE 0x03
418#define ACPI_DESC_TYPE_STATE_PACKAGE 0x04
419#define ACPI_DESC_TYPE_STATE_CONTROL 0x05
420#define ACPI_DESC_TYPE_STATE_RPSCOPE 0x06
421#define ACPI_DESC_TYPE_STATE_PSCOPE 0x07
422#define ACPI_DESC_TYPE_STATE_WSCOPE 0x08
423#define ACPI_DESC_TYPE_STATE_RESULT 0x09
424#define ACPI_DESC_TYPE_STATE_NOTIFY 0x0A
425#define ACPI_DESC_TYPE_STATE_THREAD 0x0B
426#define ACPI_DESC_TYPE_WALK 0x0C
427#define ACPI_DESC_TYPE_PARSER 0x0D
428#define ACPI_DESC_TYPE_OPERAND 0x0E
429#define ACPI_DESC_TYPE_NAMED 0x0F
430#define ACPI_DESC_TYPE_MAX 0x0F
431
432struct acpi_common_descriptor {
433 void *common_pointer;
434 u8 descriptor_type; /* To differentiate various internal objs */
435};
436
437union acpi_descriptor {
438 struct acpi_common_descriptor common;
439 union acpi_operand_object object;
440 struct acpi_namespace_node node;
441 union acpi_parse_object op;
442};
443
444#pragma pack()
445
446#endif /* _ACOBJECT_H */
diff --git a/drivers/acpi/acpica/acopcode.h b/drivers/acpi/acpica/acopcode.h
new file mode 100644
index 000000000000..dfdf63327885
--- /dev/null
+++ b/drivers/acpi/acpica/acopcode.h
@@ -0,0 +1,323 @@
1/******************************************************************************
2 *
3 * Name: acopcode.h - AML opcode information for the AML parser and interpreter
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACOPCODE_H__
45#define __ACOPCODE_H__
46
47#define MAX_EXTENDED_OPCODE 0x88
48#define NUM_EXTENDED_OPCODE (MAX_EXTENDED_OPCODE + 1)
49#define MAX_INTERNAL_OPCODE
50#define NUM_INTERNAL_OPCODE (MAX_INTERNAL_OPCODE + 1)
51
52/* Used for non-assigned opcodes */
53
54#define _UNK 0x6B
55
56/*
57 * Reserved ASCII characters. Do not use any of these for
58 * internal opcodes, since they are used to differentiate
59 * name strings from AML opcodes
60 */
61#define _ASC 0x6C
62#define _NAM 0x6C
63#define _PFX 0x6D
64
65/*
66 * All AML opcodes and the parse-time arguments for each. Used by the AML
67 * parser Each list is compressed into a 32-bit number and stored in the
68 * master opcode table (in psopcode.c).
69 */
70#define ARGP_ACCESSFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING)
71#define ARGP_ACQUIRE_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_WORDDATA)
72#define ARGP_ADD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
73#define ARGP_ALIAS_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_NAME)
74#define ARGP_ARG0 ARG_NONE
75#define ARGP_ARG1 ARG_NONE
76#define ARGP_ARG2 ARG_NONE
77#define ARGP_ARG3 ARG_NONE
78#define ARGP_ARG4 ARG_NONE
79#define ARGP_ARG5 ARG_NONE
80#define ARGP_ARG6 ARG_NONE
81#define ARGP_BANK_FIELD_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_TERMARG, ARGP_BYTEDATA, ARGP_FIELDLIST)
82#define ARGP_BIT_AND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
83#define ARGP_BIT_NAND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
84#define ARGP_BIT_NOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
85#define ARGP_BIT_NOT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
86#define ARGP_BIT_OR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
87#define ARGP_BIT_XOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
88#define ARGP_BREAK_OP ARG_NONE
89#define ARGP_BREAK_POINT_OP ARG_NONE
90#define ARGP_BUFFER_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_BYTELIST)
91#define ARGP_BYTE_OP ARGP_LIST1 (ARGP_BYTEDATA)
92#define ARGP_BYTELIST_OP ARGP_LIST1 (ARGP_NAMESTRING)
93#define ARGP_CONCAT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
94#define ARGP_CONCAT_RES_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
95#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SUPERNAME)
96#define ARGP_CONTINUE_OP ARG_NONE
97#define ARGP_COPY_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SIMPLENAME)
98#define ARGP_CREATE_BIT_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
99#define ARGP_CREATE_BYTE_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
100#define ARGP_CREATE_DWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
101#define ARGP_CREATE_FIELD_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
102#define ARGP_CREATE_QWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
103#define ARGP_CREATE_WORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME)
104#define ARGP_DATA_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG)
105#define ARGP_DEBUG_OP ARG_NONE
106#define ARGP_DECREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME)
107#define ARGP_DEREF_OF_OP ARGP_LIST1 (ARGP_TERMARG)
108#define ARGP_DEVICE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST)
109#define ARGP_DIVIDE_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET, ARGP_TARGET)
110#define ARGP_DWORD_OP ARGP_LIST1 (ARGP_DWORDDATA)
111#define ARGP_ELSE_OP ARGP_LIST2 (ARGP_PKGLENGTH, ARGP_TERMLIST)
112#define ARGP_EVENT_OP ARGP_LIST1 (ARGP_NAME)
113#define ARGP_FATAL_OP ARGP_LIST3 (ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_TERMARG)
114#define ARGP_FIELD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_BYTEDATA, ARGP_FIELDLIST)
115#define ARGP_FIND_SET_LEFT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
116#define ARGP_FIND_SET_RIGHT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
117#define ARGP_FROM_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
118#define ARGP_IF_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST)
119#define ARGP_INCREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME)
120#define ARGP_INDEX_FIELD_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_BYTEDATA, ARGP_FIELDLIST)
121#define ARGP_INDEX_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
122#define ARGP_LAND_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
123#define ARGP_LEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
124#define ARGP_LGREATER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
125#define ARGP_LGREATEREQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
126#define ARGP_LLESS_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
127#define ARGP_LLESSEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
128#define ARGP_LNOT_OP ARGP_LIST1 (ARGP_TERMARG)
129#define ARGP_LNOTEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
130#define ARGP_LOAD_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_SUPERNAME)
131#define ARGP_LOAD_TABLE_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG)
132#define ARGP_LOCAL0 ARG_NONE
133#define ARGP_LOCAL1 ARG_NONE
134#define ARGP_LOCAL2 ARG_NONE
135#define ARGP_LOCAL3 ARG_NONE
136#define ARGP_LOCAL4 ARG_NONE
137#define ARGP_LOCAL5 ARG_NONE
138#define ARGP_LOCAL6 ARG_NONE
139#define ARGP_LOCAL7 ARG_NONE
140#define ARGP_LOR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG)
141#define ARGP_MATCH_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG)
142#define ARGP_METHOD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMLIST)
143#define ARGP_METHODCALL_OP ARGP_LIST1 (ARGP_NAMESTRING)
144#define ARGP_MID_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
145#define ARGP_MOD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
146#define ARGP_MULTIPLY_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
147#define ARGP_MUTEX_OP ARGP_LIST2 (ARGP_NAME, ARGP_BYTEDATA)
148#define ARGP_NAME_OP ARGP_LIST2 (ARGP_NAME, ARGP_DATAOBJ)
149#define ARGP_NAMEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING)
150#define ARGP_NAMEPATH_OP ARGP_LIST1 (ARGP_NAMESTRING)
151#define ARGP_NOOP_OP ARG_NONE
152#define ARGP_NOTIFY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG)
153#define ARGP_ONE_OP ARG_NONE
154#define ARGP_ONES_OP ARG_NONE
155#define ARGP_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_BYTEDATA, ARGP_DATAOBJLIST)
156#define ARGP_POWER_RES_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_WORDDATA, ARGP_OBJLIST)
157#define ARGP_PROCESSOR_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_BYTEDATA, ARGP_OBJLIST)
158#define ARGP_QWORD_OP ARGP_LIST1 (ARGP_QWORDDATA)
159#define ARGP_REF_OF_OP ARGP_LIST1 (ARGP_SUPERNAME)
160#define ARGP_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG)
161#define ARGP_RELEASE_OP ARGP_LIST1 (ARGP_SUPERNAME)
162#define ARGP_RESERVEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING)
163#define ARGP_RESET_OP ARGP_LIST1 (ARGP_SUPERNAME)
164#define ARGP_RETURN_OP ARGP_LIST1 (ARGP_TERMARG)
165#define ARGP_REVISION_OP ARG_NONE
166#define ARGP_SCOPE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_TERMLIST)
167#define ARGP_SHIFT_LEFT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
168#define ARGP_SHIFT_RIGHT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
169#define ARGP_SIGNAL_OP ARGP_LIST1 (ARGP_SUPERNAME)
170#define ARGP_SIZE_OF_OP ARGP_LIST1 (ARGP_SUPERNAME)
171#define ARGP_SLEEP_OP ARGP_LIST1 (ARGP_TERMARG)
172#define ARGP_STALL_OP ARGP_LIST1 (ARGP_TERMARG)
173#define ARGP_STATICSTRING_OP ARGP_LIST1 (ARGP_NAMESTRING)
174#define ARGP_STORE_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SUPERNAME)
175#define ARGP_STRING_OP ARGP_LIST1 (ARGP_CHARLIST)
176#define ARGP_SUBTRACT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
177#define ARGP_THERMAL_ZONE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST)
178#define ARGP_TIMER_OP ARG_NONE
179#define ARGP_TO_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
180#define ARGP_TO_BUFFER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
181#define ARGP_TO_DEC_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
182#define ARGP_TO_HEX_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
183#define ARGP_TO_INTEGER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET)
184#define ARGP_TO_STRING_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET)
185#define ARGP_TYPE_OP ARGP_LIST1 (ARGP_SUPERNAME)
186#define ARGP_UNLOAD_OP ARGP_LIST1 (ARGP_SUPERNAME)
187#define ARGP_VAR_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_DATAOBJLIST)
188#define ARGP_WAIT_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG)
189#define ARGP_WHILE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST)
190#define ARGP_WORD_OP ARGP_LIST1 (ARGP_WORDDATA)
191#define ARGP_ZERO_OP ARG_NONE
192
193/*
194 * All AML opcodes and the runtime arguments for each. Used by the AML
195 * interpreter Each list is compressed into a 32-bit number and stored
196 * in the master opcode table (in psopcode.c).
197 *
198 * (Used by prep_operands procedure and the ASL Compiler)
199 */
200#define ARGI_ACCESSFIELD_OP ARGI_INVALID_OPCODE
201#define ARGI_ACQUIRE_OP ARGI_LIST2 (ARGI_MUTEX, ARGI_INTEGER)
202#define ARGI_ADD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
203#define ARGI_ALIAS_OP ARGI_INVALID_OPCODE
204#define ARGI_ARG0 ARG_NONE
205#define ARGI_ARG1 ARG_NONE
206#define ARGI_ARG2 ARG_NONE
207#define ARGI_ARG3 ARG_NONE
208#define ARGI_ARG4 ARG_NONE
209#define ARGI_ARG5 ARG_NONE
210#define ARGI_ARG6 ARG_NONE
211#define ARGI_BANK_FIELD_OP ARGI_INVALID_OPCODE
212#define ARGI_BIT_AND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
213#define ARGI_BIT_NAND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
214#define ARGI_BIT_NOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
215#define ARGI_BIT_NOT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
216#define ARGI_BIT_OR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
217#define ARGI_BIT_XOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
218#define ARGI_BREAK_OP ARG_NONE
219#define ARGI_BREAK_POINT_OP ARG_NONE
220#define ARGI_BUFFER_OP ARGI_LIST1 (ARGI_INTEGER)
221#define ARGI_BYTE_OP ARGI_INVALID_OPCODE
222#define ARGI_BYTELIST_OP ARGI_INVALID_OPCODE
223#define ARGI_CONCAT_OP ARGI_LIST3 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA, ARGI_TARGETREF)
224#define ARGI_CONCAT_RES_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_BUFFER, ARGI_TARGETREF)
225#define ARGI_COND_REF_OF_OP ARGI_LIST2 (ARGI_OBJECT_REF, ARGI_TARGETREF)
226#define ARGI_CONTINUE_OP ARGI_INVALID_OPCODE
227#define ARGI_COPY_OP ARGI_LIST2 (ARGI_ANYTYPE, ARGI_SIMPLE_TARGET)
228#define ARGI_CREATE_BIT_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
229#define ARGI_CREATE_BYTE_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
230#define ARGI_CREATE_DWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
231#define ARGI_CREATE_FIELD_OP ARGI_LIST4 (ARGI_BUFFER, ARGI_INTEGER, ARGI_INTEGER, ARGI_REFERENCE)
232#define ARGI_CREATE_QWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
233#define ARGI_CREATE_WORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE)
234#define ARGI_DATA_REGION_OP ARGI_LIST3 (ARGI_STRING, ARGI_STRING, ARGI_STRING)
235#define ARGI_DEBUG_OP ARG_NONE
236#define ARGI_DECREMENT_OP ARGI_LIST1 (ARGI_TARGETREF)
237#define ARGI_DEREF_OF_OP ARGI_LIST1 (ARGI_REF_OR_STRING)
238#define ARGI_DEVICE_OP ARGI_INVALID_OPCODE
239#define ARGI_DIVIDE_OP ARGI_LIST4 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF, ARGI_TARGETREF)
240#define ARGI_DWORD_OP ARGI_INVALID_OPCODE
241#define ARGI_ELSE_OP ARGI_INVALID_OPCODE
242#define ARGI_EVENT_OP ARGI_INVALID_OPCODE
243#define ARGI_FATAL_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER)
244#define ARGI_FIELD_OP ARGI_INVALID_OPCODE
245#define ARGI_FIND_SET_LEFT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
246#define ARGI_FIND_SET_RIGHT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF)
247#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET)
248#define ARGI_IF_OP ARGI_INVALID_OPCODE
249#define ARGI_INCREMENT_OP ARGI_LIST1 (ARGI_TARGETREF)
250#define ARGI_INDEX_FIELD_OP ARGI_INVALID_OPCODE
251#define ARGI_INDEX_OP ARGI_LIST3 (ARGI_COMPLEXOBJ, ARGI_INTEGER, ARGI_TARGETREF)
252#define ARGI_LAND_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER)
253#define ARGI_LEQUAL_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA)
254#define ARGI_LGREATER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA)
255#define ARGI_LGREATEREQUAL_OP ARGI_INVALID_OPCODE
256#define ARGI_LLESS_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA)
257#define ARGI_LLESSEQUAL_OP ARGI_INVALID_OPCODE
258#define ARGI_LNOT_OP ARGI_LIST1 (ARGI_INTEGER)
259#define ARGI_LNOTEQUAL_OP ARGI_INVALID_OPCODE
260#define ARGI_LOAD_OP ARGI_LIST2 (ARGI_REGION_OR_BUFFER,ARGI_TARGETREF)
261#define ARGI_LOAD_TABLE_OP ARGI_LIST6 (ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_ANYTYPE)
262#define ARGI_LOCAL0 ARG_NONE
263#define ARGI_LOCAL1 ARG_NONE
264#define ARGI_LOCAL2 ARG_NONE
265#define ARGI_LOCAL3 ARG_NONE
266#define ARGI_LOCAL4 ARG_NONE
267#define ARGI_LOCAL5 ARG_NONE
268#define ARGI_LOCAL6 ARG_NONE
269#define ARGI_LOCAL7 ARG_NONE
270#define ARGI_LOR_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER)
271#define ARGI_MATCH_OP ARGI_LIST6 (ARGI_PACKAGE, ARGI_INTEGER, ARGI_COMPUTEDATA, ARGI_INTEGER,ARGI_COMPUTEDATA,ARGI_INTEGER)
272#define ARGI_METHOD_OP ARGI_INVALID_OPCODE
273#define ARGI_METHODCALL_OP ARGI_INVALID_OPCODE
274#define ARGI_MID_OP ARGI_LIST4 (ARGI_BUFFER_OR_STRING,ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
275#define ARGI_MOD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
276#define ARGI_MULTIPLY_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
277#define ARGI_MUTEX_OP ARGI_INVALID_OPCODE
278#define ARGI_NAME_OP ARGI_INVALID_OPCODE
279#define ARGI_NAMEDFIELD_OP ARGI_INVALID_OPCODE
280#define ARGI_NAMEPATH_OP ARGI_INVALID_OPCODE
281#define ARGI_NOOP_OP ARG_NONE
282#define ARGI_NOTIFY_OP ARGI_LIST2 (ARGI_DEVICE_REF, ARGI_INTEGER)
283#define ARGI_ONE_OP ARG_NONE
284#define ARGI_ONES_OP ARG_NONE
285#define ARGI_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER)
286#define ARGI_POWER_RES_OP ARGI_INVALID_OPCODE
287#define ARGI_PROCESSOR_OP ARGI_INVALID_OPCODE
288#define ARGI_QWORD_OP ARGI_INVALID_OPCODE
289#define ARGI_REF_OF_OP ARGI_LIST1 (ARGI_OBJECT_REF)
290#define ARGI_REGION_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER)
291#define ARGI_RELEASE_OP ARGI_LIST1 (ARGI_MUTEX)
292#define ARGI_RESERVEDFIELD_OP ARGI_INVALID_OPCODE
293#define ARGI_RESET_OP ARGI_LIST1 (ARGI_EVENT)
294#define ARGI_RETURN_OP ARGI_INVALID_OPCODE
295#define ARGI_REVISION_OP ARG_NONE
296#define ARGI_SCOPE_OP ARGI_INVALID_OPCODE
297#define ARGI_SHIFT_LEFT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
298#define ARGI_SHIFT_RIGHT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
299#define ARGI_SIGNAL_OP ARGI_LIST1 (ARGI_EVENT)
300#define ARGI_SIZE_OF_OP ARGI_LIST1 (ARGI_DATAOBJECT)
301#define ARGI_SLEEP_OP ARGI_LIST1 (ARGI_INTEGER)
302#define ARGI_STALL_OP ARGI_LIST1 (ARGI_INTEGER)
303#define ARGI_STATICSTRING_OP ARGI_INVALID_OPCODE
304#define ARGI_STORE_OP ARGI_LIST2 (ARGI_DATAREFOBJ, ARGI_TARGETREF)
305#define ARGI_STRING_OP ARGI_INVALID_OPCODE
306#define ARGI_SUBTRACT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
307#define ARGI_THERMAL_ZONE_OP ARGI_INVALID_OPCODE
308#define ARGI_TIMER_OP ARG_NONE
309#define ARGI_TO_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET)
310#define ARGI_TO_BUFFER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
311#define ARGI_TO_DEC_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
312#define ARGI_TO_HEX_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
313#define ARGI_TO_INTEGER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
314#define ARGI_TO_STRING_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_FIXED_TARGET)
315#define ARGI_TYPE_OP ARGI_LIST1 (ARGI_ANYTYPE)
316#define ARGI_UNLOAD_OP ARGI_LIST1 (ARGI_DDBHANDLE)
317#define ARGI_VAR_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER)
318#define ARGI_WAIT_OP ARGI_LIST2 (ARGI_EVENT, ARGI_INTEGER)
319#define ARGI_WHILE_OP ARGI_INVALID_OPCODE
320#define ARGI_WORD_OP ARGI_INVALID_OPCODE
321#define ARGI_ZERO_OP ARG_NONE
322
323#endif /* __ACOPCODE_H__ */
diff --git a/drivers/acpi/acpica/acparser.h b/drivers/acpi/acpica/acparser.h
new file mode 100644
index 000000000000..23ee0fbf5619
--- /dev/null
+++ b/drivers/acpi/acpica/acparser.h
@@ -0,0 +1,234 @@
1/******************************************************************************
2 *
3 * Module Name: acparser.h - AML Parser subcomponent prototypes and defines
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACPARSER_H__
45#define __ACPARSER_H__
46
47#define OP_HAS_RETURN_VALUE 1
48
49/* Variable number of arguments. This field must be 32 bits */
50
51#define ACPI_VAR_ARGS ACPI_UINT32_MAX
52
53#define ACPI_PARSE_DELETE_TREE 0x0001
54#define ACPI_PARSE_NO_TREE_DELETE 0x0000
55#define ACPI_PARSE_TREE_MASK 0x0001
56
57#define ACPI_PARSE_LOAD_PASS1 0x0010
58#define ACPI_PARSE_LOAD_PASS2 0x0020
59#define ACPI_PARSE_EXECUTE 0x0030
60#define ACPI_PARSE_MODE_MASK 0x0030
61
62#define ACPI_PARSE_DEFERRED_OP 0x0100
63#define ACPI_PARSE_DISASSEMBLE 0x0200
64
65/******************************************************************************
66 *
67 * Parser interfaces
68 *
69 *****************************************************************************/
70
71/*
72 * psxface - Parser external interfaces
73 */
74acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info);
75
76/*
77 * psargs - Parse AML opcode arguments
78 */
79u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state);
80
81char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state);
82
83void
84acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state,
85 u32 arg_type, union acpi_parse_object *arg);
86
87acpi_status
88acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state,
89 struct acpi_parse_state *parser_state,
90 union acpi_parse_object *arg, u8 method_call);
91
92acpi_status
93acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
94 struct acpi_parse_state *parser_state,
95 u32 arg_type, union acpi_parse_object **return_arg);
96
97/*
98 * psfind
99 */
100union acpi_parse_object *acpi_ps_find_name(union acpi_parse_object *scope,
101 u32 name, u32 opcode);
102
103union acpi_parse_object *acpi_ps_get_parent(union acpi_parse_object *op);
104
105/*
106 * psopcode - AML Opcode information
107 */
108const struct acpi_opcode_info *acpi_ps_get_opcode_info(u16 opcode);
109
110char *acpi_ps_get_opcode_name(u16 opcode);
111
112u8 acpi_ps_get_argument_count(u32 op_type);
113
114/*
115 * psparse - top level parsing routines
116 */
117acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state);
118
119u32 acpi_ps_get_opcode_size(u32 opcode);
120
121u16 acpi_ps_peek_opcode(struct acpi_parse_state *state);
122
123acpi_status
124acpi_ps_complete_this_op(struct acpi_walk_state *walk_state,
125 union acpi_parse_object *op);
126
127acpi_status
128acpi_ps_next_parse_state(struct acpi_walk_state *walk_state,
129 union acpi_parse_object *op,
130 acpi_status callback_status);
131
132/*
133 * psloop - main parse loop
134 */
135acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state);
136
137/*
138 * psscope - Scope stack management routines
139 */
140acpi_status
141acpi_ps_init_scope(struct acpi_parse_state *parser_state,
142 union acpi_parse_object *root);
143
144union acpi_parse_object *acpi_ps_get_parent_scope(struct acpi_parse_state
145 *state);
146
147u8 acpi_ps_has_completed_scope(struct acpi_parse_state *parser_state);
148
149void
150acpi_ps_pop_scope(struct acpi_parse_state *parser_state,
151 union acpi_parse_object **op,
152 u32 * arg_list, u32 * arg_count);
153
154acpi_status
155acpi_ps_push_scope(struct acpi_parse_state *parser_state,
156 union acpi_parse_object *op,
157 u32 remaining_args, u32 arg_count);
158
159void acpi_ps_cleanup_scope(struct acpi_parse_state *state);
160
161/*
162 * pstree - parse tree manipulation routines
163 */
164void
165acpi_ps_append_arg(union acpi_parse_object *op, union acpi_parse_object *arg);
166
167union acpi_parse_object *acpi_ps_find(union acpi_parse_object *scope,
168 char *path, u16 opcode, u32 create);
169
170union acpi_parse_object *acpi_ps_get_arg(union acpi_parse_object *op, u32 argn);
171
172#ifdef ACPI_FUTURE_USAGE
173union acpi_parse_object *acpi_ps_get_depth_next(union acpi_parse_object *origin,
174 union acpi_parse_object *op);
175#endif /* ACPI_FUTURE_USAGE */
176
177/*
178 * pswalk - parse tree walk routines
179 */
180acpi_status
181acpi_ps_walk_parsed_aml(union acpi_parse_object *start_op,
182 union acpi_parse_object *end_op,
183 union acpi_operand_object *mth_desc,
184 struct acpi_namespace_node *start_node,
185 union acpi_operand_object **params,
186 union acpi_operand_object **caller_return_desc,
187 acpi_owner_id owner_id,
188 acpi_parse_downwards descending_callback,
189 acpi_parse_upwards ascending_callback);
190
191acpi_status
192acpi_ps_get_next_walk_op(struct acpi_walk_state *walk_state,
193 union acpi_parse_object *op,
194 acpi_parse_upwards ascending_callback);
195
196acpi_status acpi_ps_delete_completed_op(struct acpi_walk_state *walk_state);
197
198void acpi_ps_delete_parse_tree(union acpi_parse_object *root);
199
200/*
201 * psutils - parser utilities
202 */
203union acpi_parse_object *acpi_ps_create_scope_op(void);
204
205void acpi_ps_init_op(union acpi_parse_object *op, u16 opcode);
206
207union acpi_parse_object *acpi_ps_alloc_op(u16 opcode);
208
209void acpi_ps_free_op(union acpi_parse_object *op);
210
211u8 acpi_ps_is_leading_char(u32 c);
212
213u8 acpi_ps_is_prefix_char(u32 c);
214
215#ifdef ACPI_FUTURE_USAGE
216u32 acpi_ps_get_name(union acpi_parse_object *op);
217#endif /* ACPI_FUTURE_USAGE */
218
219void acpi_ps_set_name(union acpi_parse_object *op, u32 name);
220
221/*
222 * psdump - display parser tree
223 */
224u32
225acpi_ps_sprint_path(char *buffer_start,
226 u32 buffer_size, union acpi_parse_object *op);
227
228u32
229acpi_ps_sprint_op(char *buffer_start,
230 u32 buffer_size, union acpi_parse_object *op);
231
232void acpi_ps_show(union acpi_parse_object *op);
233
234#endif /* __ACPARSER_H__ */
diff --git a/drivers/acpi/acpica/acpredef.h b/drivers/acpi/acpica/acpredef.h
new file mode 100644
index 000000000000..16a9ca9a66e4
--- /dev/null
+++ b/drivers/acpi/acpica/acpredef.h
@@ -0,0 +1,371 @@
1/******************************************************************************
2 *
3 * Name: acpredef - Information table for ACPI predefined methods and objects
4 * $Revision: 1.1 $
5 *
6 *****************************************************************************/
7
8/*
9 * Copyright (C) 2000 - 2008, Intel Corp.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
30 *
31 * NO WARRANTY
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
43 */
44
45#ifndef __ACPREDEF_H__
46#define __ACPREDEF_H__
47
48/******************************************************************************
49 *
50 * Return Package types
51 *
52 * 1) PTYPE1 packages do not contain sub-packages.
53 *
54 * ACPI_PTYPE1_FIXED: Fixed length, 1 or 2 object types:
55 * object type
56 * count
57 * object type
58 * count
59 *
60 * ACPI_PTYPE1_VAR: Variable length:
61 * object type (Int/Buf/Ref)
62 *
63 * ACPI_PTYPE1_OPTION: Package has some required and some optional elements:
64 * Used for _PRW
65 *
66 *
67 * 2) PTYPE2 packages contain a variable number of sub-packages. Each of the
68 * different types describe the contents of each of the sub-packages.
69 *
70 * ACPI_PTYPE2: Each subpackage contains 1 or 2 object types:
71 * object type
72 * count
73 * object type
74 * count
75 *
76 * ACPI_PTYPE2_COUNT: Each subpackage has a count as first element:
77 * object type
78 *
79 * ACPI_PTYPE2_PKG_COUNT: Count of subpackages at start, 1 or 2 object types:
80 * object type
81 * count
82 * object type
83 * count
84 *
85 * ACPI_PTYPE2_FIXED: Each subpackage is of fixed length:
86 * Used for _PRT
87 *
88 * ACPI_PTYPE2_MIN: Each subpackage has a variable but minimum length
89 * Used for _HPX
90 *
91 *****************************************************************************/
92
93enum acpi_return_package_types {
94 ACPI_PTYPE1_FIXED = 1,
95 ACPI_PTYPE1_VAR = 2,
96 ACPI_PTYPE1_OPTION = 3,
97 ACPI_PTYPE2 = 4,
98 ACPI_PTYPE2_COUNT = 5,
99 ACPI_PTYPE2_PKG_COUNT = 6,
100 ACPI_PTYPE2_FIXED = 7,
101 ACPI_PTYPE2_MIN = 8
102};
103
104/*
105 * Predefined method/object information table.
106 *
107 * These are the names that can actually be evaluated via acpi_evaluate_object.
108 * Not present in this table are the following:
109 *
110 * 1) Predefined/Reserved names that are never evaluated via acpi_evaluate_object:
111 * _Lxx and _Exx GPE methods
112 * _Qxx EC methods
113 * _T_x compiler temporary variables
114 *
115 * 2) Predefined names that never actually exist within the AML code:
116 * Predefined resource descriptor field names
117 *
118 * 3) Predefined names that are implemented within ACPICA:
119 * _OSI
120 *
121 * 4) Some predefined names that are not documented within the ACPI spec.
122 * _WDG, _WED
123 *
124 * The main entries in the table each contain the following items:
125 *
126 * Name - The ACPI reserved name
127 * param_count - Number of arguments to the method
128 * expected_btypes - Allowed type(s) for the return value.
129 * 0 means that no return value is expected.
130 *
131 * For methods that return packages, the next entry in the table contains
132 * information about the expected structure of the package. This information
133 * is saved here (rather than in a separate table) in order to minimize the
134 * overall size of the stored data.
135 */
136static const union acpi_predefined_info predefined_names[] = {
137 {.info = {"_AC0", 0, ACPI_RTYPE_INTEGER}},
138 {.info = {"_AC1", 0, ACPI_RTYPE_INTEGER}},
139 {.info = {"_AC2", 0, ACPI_RTYPE_INTEGER}},
140 {.info = {"_AC3", 0, ACPI_RTYPE_INTEGER}},
141 {.info = {"_AC4", 0, ACPI_RTYPE_INTEGER}},
142 {.info = {"_AC5", 0, ACPI_RTYPE_INTEGER}},
143 {.info = {"_AC6", 0, ACPI_RTYPE_INTEGER}},
144 {.info = {"_AC7", 0, ACPI_RTYPE_INTEGER}},
145 {.info = {"_AC8", 0, ACPI_RTYPE_INTEGER}},
146 {.info = {"_AC9", 0, ACPI_RTYPE_INTEGER}},
147 {.info = {"_ADR", 0, ACPI_RTYPE_INTEGER}},
148 {.info = {"_AL0", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
149 {.info = {"_AL1", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
150 {.info = {"_AL2", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
151 {.info = {"_AL3", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
152 {.info = {"_AL4", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
153 {.info = {"_AL5", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
154 {.info = {"_AL6", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
155 {.info = {"_AL7", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
156 {.info = {"_AL8", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
157 {.info = {"_AL9", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
158 {.info = {"_ALC", 0, ACPI_RTYPE_INTEGER}},
159 {.info = {"_ALI", 0, ACPI_RTYPE_INTEGER}},
160 {.info = {"_ALP", 0, ACPI_RTYPE_INTEGER}},
161 {.info = {"_ALR", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 2, 0, 0, 0}}, /* variable (Pkgs) each 2 (Ints) */
162 {.info = {"_ALT", 0, ACPI_RTYPE_INTEGER}},
163 {.info = {"_BBN", 0, ACPI_RTYPE_INTEGER}},
164 {.info = {"_BCL", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0, 0, 0, 0}}, /* variable (Ints) */
165 {.info = {"_BCM", 1, 0}},
166 {.info = {"_BDN", 0, ACPI_RTYPE_INTEGER}},
167 {.info = {"_BFS", 1, 0}},
168 {.info = {"_BIF", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER,
169 9,
170 ACPI_RTYPE_STRING | ACPI_RTYPE_BUFFER, 4, 0}}, /* fixed (9 Int),(4 Str) */
171 {.info = {"_BLT", 3, 0}},
172 {.info = {"_BMC", 1, 0}},
173 {.info = {"_BMD", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 5, 0, 0, 0}}, /* fixed (5 Int) */
174 {.info = {"_BQC", 0, ACPI_RTYPE_INTEGER}},
175 {.info = {"_BST", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4, 0, 0, 0}}, /* fixed (4 Int) */
176 {.info = {"_BTM", 1, ACPI_RTYPE_INTEGER}},
177 {.info = {"_BTP", 1, 0}},
178 {.info = {"_CBA", 0, ACPI_RTYPE_INTEGER}}, /* see PCI firmware spec 3.0 */
179 {.info = {"_CID", 0,
180 ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING | ACPI_RTYPE_PACKAGE}},
181 {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING, 0, 0, 0, 0}}, /* variable (Ints/Strs) */
182 {.info = {"_CRS", 0, ACPI_RTYPE_BUFFER}},
183 {.info = {"_CRT", 0, ACPI_RTYPE_INTEGER}},
184 {.info = {"_CSD", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER, 0, 0, 0, 0}}, /* variable (1 Int(n), n-1 Int) */
185 {.info = {"_CST", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2_PKG_COUNT,
186 ACPI_RTYPE_BUFFER, 1,
187 ACPI_RTYPE_INTEGER, 3, 0}}, /* variable (1 Int(n), n Pkg (1 Buf/3 Int) */
188 {.info = {"_DCK", 1, ACPI_RTYPE_INTEGER}},
189 {.info = {"_DCS", 0, ACPI_RTYPE_INTEGER}},
190 {.info = {"_DDC", 1, ACPI_RTYPE_INTEGER | ACPI_RTYPE_BUFFER}},
191 {.info = {"_DDN", 0, ACPI_RTYPE_STRING}},
192 {.info = {"_DGS", 0, ACPI_RTYPE_INTEGER}},
193 {.info = {"_DIS", 0, 0}},
194 {.info = {"_DMA", 0, ACPI_RTYPE_BUFFER}},
195 {.info = {"_DOD", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0, 0, 0, 0}}, /* variable (Ints) */
196 {.info = {"_DOS", 1, 0}},
197 {.info = {"_DSM", 4, ACPI_RTYPE_ALL}}, /* Must return a type, but it can be of any type */
198 {.info = {"_DSS", 1, 0}},
199 {.info = {"_DSW", 3, 0}},
200 {.info = {"_EC_", 0, ACPI_RTYPE_INTEGER}},
201 {.info = {"_EDL", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
202 {.info = {"_EJ0", 1, 0}},
203 {.info = {"_EJ1", 1, 0}},
204 {.info = {"_EJ2", 1, 0}},
205 {.info = {"_EJ3", 1, 0}},
206 {.info = {"_EJ4", 1, 0}},
207 {.info = {"_EJD", 0, ACPI_RTYPE_STRING}},
208 {.info = {"_FDE", 0, ACPI_RTYPE_BUFFER}},
209 {.info = {"_FDI", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 16, 0, 0, 0}}, /* fixed (16 Int) */
210 {.info = {"_FDM", 1, 0}},
211 {.info = {"_FIX", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0, 0, 0, 0}}, /* variable (Ints) */
212 {.info = {"_GLK", 0, ACPI_RTYPE_INTEGER}},
213 {.info = {"_GPD", 0, ACPI_RTYPE_INTEGER}},
214 {.info = {"_GPE", 0, ACPI_RTYPE_INTEGER}}, /* _GPE method, not _GPE scope */
215 {.info = {"_GSB", 0, ACPI_RTYPE_INTEGER}},
216 {.info = {"_GTF", 0, ACPI_RTYPE_BUFFER}},
217 {.info = {"_GTM", 0, ACPI_RTYPE_BUFFER}},
218 {.info = {"_GTS", 1, 0}},
219 {.info = {"_HID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING}},
220 {.info = {"_HOT", 0, ACPI_RTYPE_INTEGER}},
221 {.info = {"_HPP", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4, 0, 0, 0}}, /* fixed (4 Int) */
222
223 /*
224 * For _HPX, a single package is returned, containing a variable number of sub-packages.
225 * Each sub-package contains a PCI record setting. There are several different type of
226 * record settings, of different lengths, but all elements of all settings are Integers.
227 */
228 {.info = {"_HPX", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2_MIN, ACPI_RTYPE_INTEGER, 5, 0, 0, 0}}, /* variable (Pkgs) each (var Ints) */
229 {.info = {"_IFT", 0, ACPI_RTYPE_INTEGER}}, /* see IPMI spec */
230 {.info = {"_INI", 0, 0}},
231 {.info = {"_IRC", 0, 0}},
232 {.info = {"_LCK", 1, 0}},
233 {.info = {"_LID", 0, ACPI_RTYPE_INTEGER}},
234 {.info = {"_MAT", 0, ACPI_RTYPE_BUFFER}},
235 {.info = {"_MLS", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2, ACPI_RTYPE_STRING, 2, 0, 0, 0}}, /* variable (Pkgs) each (2 Str) */
236 {.info = {"_MSG", 1, 0}},
237 {.info = {"_OFF", 0, 0}},
238 {.info = {"_ON_", 0, 0}},
239 {.info = {"_OS_", 0, ACPI_RTYPE_STRING}},
240 {.info = {"_OSC", 4, ACPI_RTYPE_BUFFER}},
241 {.info = {"_OST", 3, 0}},
242 {.info = {"_PCL", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
243 {.info = {"_PCT", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_BUFFER, 2, 0, 0, 0}}, /* fixed (2 Buf) */
244 {.info = {"_PDC", 1, 0}},
245 {.info = {"_PIC", 1, 0}},
246 {.info = {"_PLD", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_BUFFER, 0, 0, 0, 0}}, /* variable (Bufs) */
247 {.info = {"_PPC", 0, ACPI_RTYPE_INTEGER}},
248 {.info = {"_PPE", 0, ACPI_RTYPE_INTEGER}}, /* see dig64 spec */
249 {.info = {"_PR0", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
250 {.info = {"_PR1", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
251 {.info = {"_PR2", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
252 {.info = {"_PRS", 0, ACPI_RTYPE_BUFFER}},
253
254 /*
255 * For _PRT, many BIOSs reverse the 2nd and 3rd Package elements. This bug is so prevalent that there
256 * is code in the ACPICA Resource Manager to detect this and switch them back. For now, do not allow
257 * and issue a warning. To allow this and eliminate the warning, add the ACPI_RTYPE_REFERENCE
258 * type to the 2nd element (index 1) in the statement below.
259 */
260 {.info = {"_PRT", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2_FIXED, 4,
261 ACPI_RTYPE_INTEGER,
262 ACPI_RTYPE_INTEGER,
263 ACPI_RTYPE_INTEGER | ACPI_RTYPE_REFERENCE, ACPI_RTYPE_INTEGER}}, /* variable (Pkgs) each (4): Int,Int,Int/Ref,Int */
264
265 {.info = {"_PRW", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_OPTION, 2,
266 ACPI_RTYPE_INTEGER |
267 ACPI_RTYPE_PACKAGE,
268 ACPI_RTYPE_INTEGER, ACPI_RTYPE_REFERENCE, 0}}, /* variable (Pkgs) each: Pkg/Int,Int,[variable Refs] (Pkg is Ref/Int) */
269
270 {.info = {"_PS0", 0, 0}},
271 {.info = {"_PS1", 0, 0}},
272 {.info = {"_PS2", 0, 0}},
273 {.info = {"_PS3", 0, 0}},
274 {.info = {"_PSC", 0, ACPI_RTYPE_INTEGER}},
275 {.info = {"_PSD", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER, 0, 0, 0, 0}}, /* variable (Pkgs) each (5 Int) with count */
276 {.info = {"_PSL", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
277 {.info = {"_PSR", 0, ACPI_RTYPE_INTEGER}},
278 {.info = {"_PSS", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 6, 0, 0, 0}}, /* variable (Pkgs) each (6 Int) */
279 {.info = {"_PSV", 0, ACPI_RTYPE_INTEGER}},
280 {.info = {"_PSW", 1, 0}},
281 {.info = {"_PTC", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_BUFFER, 2, 0, 0, 0}}, /* fixed (2 Buf) */
282 {.info = {"_PTS", 1, 0}},
283 {.info = {"_PXM", 0, ACPI_RTYPE_INTEGER}},
284 {.info = {"_REG", 2, 0}},
285 {.info = {"_REV", 0, ACPI_RTYPE_INTEGER}},
286 {.info = {"_RMV", 0, ACPI_RTYPE_INTEGER}},
287 {.info = {"_ROM", 2, ACPI_RTYPE_BUFFER}},
288 {.info = {"_RTV", 0, ACPI_RTYPE_INTEGER}},
289
290 /*
291 * For _S0_ through _S5_, the ACPI spec defines a return Package containing 1 Integer,
292 * but most DSDTs have it wrong - 2,3, or 4 integers. Allow this by making the objects "variable length",
293 * but all elements must be Integers.
294 */
295 {.info = {"_S0_", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0}}, /* fixed (1 Int) */
296 {.info = {"_S1_", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0}}, /* fixed (1 Int) */
297 {.info = {"_S2_", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0}}, /* fixed (1 Int) */
298 {.info = {"_S3_", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0}}, /* fixed (1 Int) */
299 {.info = {"_S4_", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0}}, /* fixed (1 Int) */
300 {.info = {"_S5_", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1, 0, 0, 0}}, /* fixed (1 Int) */
301
302 {.info = {"_S1D", 0, ACPI_RTYPE_INTEGER}},
303 {.info = {"_S2D", 0, ACPI_RTYPE_INTEGER}},
304 {.info = {"_S3D", 0, ACPI_RTYPE_INTEGER}},
305 {.info = {"_S4D", 0, ACPI_RTYPE_INTEGER}},
306 {.info = {"_S0W", 0, ACPI_RTYPE_INTEGER}},
307 {.info = {"_S1W", 0, ACPI_RTYPE_INTEGER}},
308 {.info = {"_S2W", 0, ACPI_RTYPE_INTEGER}},
309 {.info = {"_S3W", 0, ACPI_RTYPE_INTEGER}},
310 {.info = {"_S4W", 0, ACPI_RTYPE_INTEGER}},
311 {.info = {"_SBS", 0, ACPI_RTYPE_INTEGER}},
312 {.info = {"_SCP", 0x13, 0}}, /* Acpi 1.0 allowed 1 arg. Acpi 3.0 expanded to 3 args. Allow both. */
313 /* Note: the 3-arg definition may be removed for ACPI 4.0 */
314 {.info = {"_SDD", 1, 0}},
315 {.info = {"_SEG", 0, ACPI_RTYPE_INTEGER}},
316 {.info = {"_SLI", 0, ACPI_RTYPE_BUFFER}},
317 {.info = {"_SPD", 1, ACPI_RTYPE_INTEGER}},
318 {.info = {"_SRS", 1, 0}},
319 {.info = {"_SRV", 0, ACPI_RTYPE_INTEGER}}, /* see IPMI spec */
320 {.info = {"_SST", 1, 0}},
321 {.info = {"_STA", 0, ACPI_RTYPE_INTEGER}},
322 {.info = {"_STM", 3, 0}},
323 {.info = {"_STR", 0, ACPI_RTYPE_BUFFER}},
324 {.info = {"_SUN", 0, ACPI_RTYPE_INTEGER}},
325 {.info = {"_SWS", 0, ACPI_RTYPE_INTEGER}},
326 {.info = {"_TC1", 0, ACPI_RTYPE_INTEGER}},
327 {.info = {"_TC2", 0, ACPI_RTYPE_INTEGER}},
328 {.info = {"_TMP", 0, ACPI_RTYPE_INTEGER}},
329 {.info = {"_TPC", 0, ACPI_RTYPE_INTEGER}},
330 {.info = {"_TPT", 1, 0}},
331 {.info = {"_TRT", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2, ACPI_RTYPE_REFERENCE, 2,
332 ACPI_RTYPE_INTEGER, 6, 0}}, /* variable (Pkgs) each 2_ref/6_int */
333 {.info = {"_TSD", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER, 5, 0, 0, 0}}, /* variable (Pkgs) each 5_int with count */
334 {.info = {"_TSP", 0, ACPI_RTYPE_INTEGER}},
335 {.info = {"_TSS", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 5, 0, 0, 0}}, /* variable (Pkgs) each 5_int */
336 {.info = {"_TST", 0, ACPI_RTYPE_INTEGER}},
337 {.info = {"_TTS", 1, 0}},
338 {.info = {"_TZD", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0, 0, 0, 0}}, /* variable (Refs) */
339 {.info = {"_TZM", 0, ACPI_RTYPE_REFERENCE}},
340 {.info = {"_TZP", 0, ACPI_RTYPE_INTEGER}},
341 {.info = {"_UID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING}},
342 {.info = {"_UPC", 0, ACPI_RTYPE_PACKAGE}}, {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4, 0, 0, 0}}, /* fixed (4 Int) */
343 {.info = {"_UPD", 0, ACPI_RTYPE_INTEGER}},
344 {.info = {"_UPP", 0, ACPI_RTYPE_INTEGER}},
345 {.info = {"_VPO", 0, ACPI_RTYPE_INTEGER}},
346
347 /* Acpi 1.0 defined _WAK with no return value. Later, it was changed to return a package */
348
349 {.info = {"_WAK", 1, ACPI_RTYPE_NONE | ACPI_RTYPE_INTEGER | ACPI_RTYPE_PACKAGE}},
350 {.ret_info = {ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 2, 0, 0, 0}}, /* fixed (2 Int), but is optional */
351 {.ret_info = {0, 0, 0, 0, 0, 0}} /* Table terminator */
352};
353
354#if 0
355 /* Not implemented */
356
357{
358"_WDG", 0, ACPI_RTYPE_BUFFER}, /* MS Extension */
359
360{
361"_WED", 1, ACPI_RTYPE_PACKAGE}, /* MS Extension */
362
363 /* This is an internally implemented control method, no need to check */
364{
365"_OSI", 1, ACPI_RTYPE_INTEGER},
366
367 /* TBD: */
368 _PRT - currently ignore reversed entries.attempt to fix here ?
369 think about code that attempts to fix package elements like _BIF, etc.
370#endif
371#endif
diff --git a/drivers/acpi/acpica/acresrc.h b/drivers/acpi/acpica/acresrc.h
new file mode 100644
index 000000000000..eef5bd7a59fa
--- /dev/null
+++ b/drivers/acpi/acpica/acresrc.h
@@ -0,0 +1,336 @@
1/******************************************************************************
2 *
3 * Name: acresrc.h - Resource Manager function prototypes
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACRESRC_H__
45#define __ACRESRC_H__
46
47/* Need the AML resource descriptor structs */
48
49#include "amlresrc.h"
50
51/*
52 * If possible, pack the following structures to byte alignment, since we
53 * don't care about performance for debug output. Two cases where we cannot
54 * pack the structures:
55 *
56 * 1) Hardware does not support misaligned memory transfers
57 * 2) Compiler does not support pointers within packed structures
58 */
59#if (!defined(ACPI_MISALIGNMENT_NOT_SUPPORTED) && !defined(ACPI_PACKED_POINTERS_NOT_SUPPORTED))
60#pragma pack(1)
61#endif
62
63/*
64 * Individual entry for the resource conversion tables
65 */
66typedef const struct acpi_rsconvert_info {
67 u8 opcode;
68 u8 resource_offset;
69 u8 aml_offset;
70 u8 value;
71
72} acpi_rsconvert_info;
73
74/* Resource conversion opcodes */
75
76#define ACPI_RSC_INITGET 0
77#define ACPI_RSC_INITSET 1
78#define ACPI_RSC_FLAGINIT 2
79#define ACPI_RSC_1BITFLAG 3
80#define ACPI_RSC_2BITFLAG 4
81#define ACPI_RSC_COUNT 5
82#define ACPI_RSC_COUNT16 6
83#define ACPI_RSC_LENGTH 7
84#define ACPI_RSC_MOVE8 8
85#define ACPI_RSC_MOVE16 9
86#define ACPI_RSC_MOVE32 10
87#define ACPI_RSC_MOVE64 11
88#define ACPI_RSC_SET8 12
89#define ACPI_RSC_DATA8 13
90#define ACPI_RSC_ADDRESS 14
91#define ACPI_RSC_SOURCE 15
92#define ACPI_RSC_SOURCEX 16
93#define ACPI_RSC_BITMASK 17
94#define ACPI_RSC_BITMASK16 18
95#define ACPI_RSC_EXIT_NE 19
96#define ACPI_RSC_EXIT_LE 20
97#define ACPI_RSC_EXIT_EQ 21
98
99/* Resource Conversion sub-opcodes */
100
101#define ACPI_RSC_COMPARE_AML_LENGTH 0
102#define ACPI_RSC_COMPARE_VALUE 1
103
104#define ACPI_RSC_TABLE_SIZE(d) (sizeof (d) / sizeof (struct acpi_rsconvert_info))
105
106#define ACPI_RS_OFFSET(f) (u8) ACPI_OFFSET (struct acpi_resource,f)
107#define AML_OFFSET(f) (u8) ACPI_OFFSET (union aml_resource,f)
108
109typedef const struct acpi_rsdump_info {
110 u8 opcode;
111 u8 offset;
112 char *name;
113 const char **pointer;
114
115} acpi_rsdump_info;
116
117/* Values for the Opcode field above */
118
119#define ACPI_RSD_TITLE 0
120#define ACPI_RSD_LITERAL 1
121#define ACPI_RSD_STRING 2
122#define ACPI_RSD_UINT8 3
123#define ACPI_RSD_UINT16 4
124#define ACPI_RSD_UINT32 5
125#define ACPI_RSD_UINT64 6
126#define ACPI_RSD_1BITFLAG 7
127#define ACPI_RSD_2BITFLAG 8
128#define ACPI_RSD_SHORTLIST 9
129#define ACPI_RSD_LONGLIST 10
130#define ACPI_RSD_DWORDLIST 11
131#define ACPI_RSD_ADDRESS 12
132#define ACPI_RSD_SOURCE 13
133
134/* restore default alignment */
135
136#pragma pack()
137
138/* Resource tables indexed by internal resource type */
139
140extern const u8 acpi_gbl_aml_resource_sizes[];
141extern struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[];
142
143/* Resource tables indexed by raw AML resource descriptor type */
144
145extern const u8 acpi_gbl_resource_struct_sizes[];
146extern struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[];
147
148struct acpi_vendor_walk_info {
149 struct acpi_vendor_uuid *uuid;
150 struct acpi_buffer *buffer;
151 acpi_status status;
152};
153
154/*
155 * rscreate
156 */
157acpi_status
158acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
159 struct acpi_buffer *output_buffer);
160
161acpi_status
162acpi_rs_create_aml_resources(struct acpi_resource *linked_list_buffer,
163 struct acpi_buffer *output_buffer);
164
165acpi_status
166acpi_rs_create_pci_routing_table(union acpi_operand_object *package_object,
167 struct acpi_buffer *output_buffer);
168
169/*
170 * rsutils
171 */
172
173acpi_status
174acpi_rs_get_prt_method_data(struct acpi_namespace_node *node,
175 struct acpi_buffer *ret_buffer);
176
177acpi_status
178acpi_rs_get_crs_method_data(struct acpi_namespace_node *node,
179 struct acpi_buffer *ret_buffer);
180
181acpi_status
182acpi_rs_get_prs_method_data(struct acpi_namespace_node *node,
183 struct acpi_buffer *ret_buffer);
184
185acpi_status
186acpi_rs_get_method_data(acpi_handle handle,
187 char *path, struct acpi_buffer *ret_buffer);
188
189acpi_status
190acpi_rs_set_srs_method_data(struct acpi_namespace_node *node,
191 struct acpi_buffer *ret_buffer);
192
193/*
194 * rscalc
195 */
196acpi_status
197acpi_rs_get_list_length(u8 * aml_buffer,
198 u32 aml_buffer_length, acpi_size * size_needed);
199
200acpi_status
201acpi_rs_get_aml_length(struct acpi_resource *linked_list_buffer,
202 acpi_size * size_needed);
203
204acpi_status
205acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
206 acpi_size * buffer_size_needed);
207
208acpi_status
209acpi_rs_convert_aml_to_resources(u8 * aml,
210 u32 length,
211 u32 offset, u8 resource_index, void **context);
212
213acpi_status
214acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
215 acpi_size aml_size_needed, u8 * output_buffer);
216
217/*
218 * rsaddr
219 */
220void
221acpi_rs_set_address_common(union aml_resource *aml,
222 struct acpi_resource *resource);
223
224u8
225acpi_rs_get_address_common(struct acpi_resource *resource,
226 union aml_resource *aml);
227
228/*
229 * rsmisc
230 */
231acpi_status
232acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
233 union aml_resource *aml,
234 struct acpi_rsconvert_info *info);
235
236acpi_status
237acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
238 union aml_resource *aml,
239 struct acpi_rsconvert_info *info);
240
241/*
242 * rsutils
243 */
244void
245acpi_rs_move_data(void *destination,
246 void *source, u16 item_count, u8 move_type);
247
248u8 acpi_rs_decode_bitmask(u16 mask, u8 * list);
249
250u16 acpi_rs_encode_bitmask(u8 * list, u8 count);
251
252acpi_rs_length
253acpi_rs_get_resource_source(acpi_rs_length resource_length,
254 acpi_rs_length minimum_length,
255 struct acpi_resource_source *resource_source,
256 union aml_resource *aml, char *string_ptr);
257
258acpi_rsdesc_size
259acpi_rs_set_resource_source(union aml_resource *aml,
260 acpi_rs_length minimum_length,
261 struct acpi_resource_source *resource_source);
262
263void
264acpi_rs_set_resource_header(u8 descriptor_type,
265 acpi_rsdesc_size total_length,
266 union aml_resource *aml);
267
268void
269acpi_rs_set_resource_length(acpi_rsdesc_size total_length,
270 union aml_resource *aml);
271
272/*
273 * rsdump
274 */
275void acpi_rs_dump_resource_list(struct acpi_resource *resource);
276
277void acpi_rs_dump_irq_list(u8 * route_table);
278
279/*
280 * Resource conversion tables
281 */
282extern struct acpi_rsconvert_info acpi_rs_convert_dma[];
283extern struct acpi_rsconvert_info acpi_rs_convert_end_dpf[];
284extern struct acpi_rsconvert_info acpi_rs_convert_io[];
285extern struct acpi_rsconvert_info acpi_rs_convert_fixed_io[];
286extern struct acpi_rsconvert_info acpi_rs_convert_end_tag[];
287extern struct acpi_rsconvert_info acpi_rs_convert_memory24[];
288extern struct acpi_rsconvert_info acpi_rs_convert_generic_reg[];
289extern struct acpi_rsconvert_info acpi_rs_convert_memory32[];
290extern struct acpi_rsconvert_info acpi_rs_convert_fixed_memory32[];
291extern struct acpi_rsconvert_info acpi_rs_convert_address32[];
292extern struct acpi_rsconvert_info acpi_rs_convert_address16[];
293extern struct acpi_rsconvert_info acpi_rs_convert_ext_irq[];
294extern struct acpi_rsconvert_info acpi_rs_convert_address64[];
295extern struct acpi_rsconvert_info acpi_rs_convert_ext_address64[];
296
297/* These resources require separate get/set tables */
298
299extern struct acpi_rsconvert_info acpi_rs_get_irq[];
300extern struct acpi_rsconvert_info acpi_rs_get_start_dpf[];
301extern struct acpi_rsconvert_info acpi_rs_get_vendor_small[];
302extern struct acpi_rsconvert_info acpi_rs_get_vendor_large[];
303
304extern struct acpi_rsconvert_info acpi_rs_set_irq[];
305extern struct acpi_rsconvert_info acpi_rs_set_start_dpf[];
306extern struct acpi_rsconvert_info acpi_rs_set_vendor[];
307
308#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
309/*
310 * rsinfo
311 */
312extern struct acpi_rsdump_info *acpi_gbl_dump_resource_dispatch[];
313
314/*
315 * rsdump
316 */
317extern struct acpi_rsdump_info acpi_rs_dump_irq[];
318extern struct acpi_rsdump_info acpi_rs_dump_dma[];
319extern struct acpi_rsdump_info acpi_rs_dump_start_dpf[];
320extern struct acpi_rsdump_info acpi_rs_dump_end_dpf[];
321extern struct acpi_rsdump_info acpi_rs_dump_io[];
322extern struct acpi_rsdump_info acpi_rs_dump_fixed_io[];
323extern struct acpi_rsdump_info acpi_rs_dump_vendor[];
324extern struct acpi_rsdump_info acpi_rs_dump_end_tag[];
325extern struct acpi_rsdump_info acpi_rs_dump_memory24[];
326extern struct acpi_rsdump_info acpi_rs_dump_memory32[];
327extern struct acpi_rsdump_info acpi_rs_dump_fixed_memory32[];
328extern struct acpi_rsdump_info acpi_rs_dump_address16[];
329extern struct acpi_rsdump_info acpi_rs_dump_address32[];
330extern struct acpi_rsdump_info acpi_rs_dump_address64[];
331extern struct acpi_rsdump_info acpi_rs_dump_ext_address64[];
332extern struct acpi_rsdump_info acpi_rs_dump_ext_irq[];
333extern struct acpi_rsdump_info acpi_rs_dump_generic_reg[];
334#endif
335
336#endif /* __ACRESRC_H__ */
diff --git a/drivers/acpi/acpica/acstruct.h b/drivers/acpi/acpica/acstruct.h
new file mode 100644
index 000000000000..7980a26bad35
--- /dev/null
+++ b/drivers/acpi/acpica/acstruct.h
@@ -0,0 +1,228 @@
1/******************************************************************************
2 *
3 * Name: acstruct.h - Internal structs
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACSTRUCT_H__
45#define __ACSTRUCT_H__
46
47/* acpisrc:struct_defs -- for acpisrc conversion */
48
49/*****************************************************************************
50 *
51 * Tree walking typedefs and structs
52 *
53 ****************************************************************************/
54
55/*
56 * Walk state - current state of a parse tree walk. Used for both a leisurely
57 * stroll through the tree (for whatever reason), and for control method
58 * execution.
59 */
60#define ACPI_NEXT_OP_DOWNWARD 1
61#define ACPI_NEXT_OP_UPWARD 2
62
63/*
64 * Groups of definitions for walk_type used for different implementations of
65 * walkers (never simultaneously) - flags for interpreter:
66 */
67#define ACPI_WALK_NON_METHOD 0
68#define ACPI_WALK_METHOD 0x01
69#define ACPI_WALK_METHOD_RESTART 0x02
70
71/* Flags for i_aSL compiler only */
72
73#define ACPI_WALK_CONST_REQUIRED 0x10
74#define ACPI_WALK_CONST_OPTIONAL 0x20
75
76struct acpi_walk_state {
77 struct acpi_walk_state *next; /* Next walk_state in list */
78 u8 descriptor_type; /* To differentiate various internal objs */
79 u8 walk_type;
80 u16 opcode; /* Current AML opcode */
81 u8 next_op_info; /* Info about next_op */
82 u8 num_operands; /* Stack pointer for Operands[] array */
83 u8 operand_index; /* Index into operand stack, to be used by acpi_ds_obj_stack_push */
84 acpi_owner_id owner_id; /* Owner of objects created during the walk */
85 u8 last_predicate; /* Result of last predicate */
86 u8 current_result;
87 u8 return_used;
88 u8 scope_depth;
89 u8 pass_number; /* Parse pass during table load */
90 u8 result_size; /* Total elements for the result stack */
91 u8 result_count; /* Current number of occupied elements of result stack */
92 u32 aml_offset;
93 u32 arg_types;
94 u32 method_breakpoint; /* For single stepping */
95 u32 user_breakpoint; /* User AML breakpoint */
96 u32 parse_flags;
97
98 struct acpi_parse_state parser_state; /* Current state of parser */
99 u32 prev_arg_types;
100 u32 arg_count; /* push for fixed or var args */
101
102 struct acpi_namespace_node arguments[ACPI_METHOD_NUM_ARGS]; /* Control method arguments */
103 struct acpi_namespace_node local_variables[ACPI_METHOD_NUM_LOCALS]; /* Control method locals */
104 union acpi_operand_object *operands[ACPI_OBJ_NUM_OPERANDS + 1]; /* Operands passed to the interpreter (+1 for NULL terminator) */
105 union acpi_operand_object **params;
106
107 u8 *aml_last_while;
108 union acpi_operand_object **caller_return_desc;
109 union acpi_generic_state *control_state; /* List of control states (nested IFs) */
110 struct acpi_namespace_node *deferred_node; /* Used when executing deferred opcodes */
111 union acpi_operand_object *implicit_return_obj;
112 struct acpi_namespace_node *method_call_node; /* Called method Node */
113 union acpi_parse_object *method_call_op; /* method_call Op if running a method */
114 union acpi_operand_object *method_desc; /* Method descriptor if running a method */
115 struct acpi_namespace_node *method_node; /* Method node if running a method. */
116 union acpi_parse_object *op; /* Current parser op */
117 const struct acpi_opcode_info *op_info; /* Info on current opcode */
118 union acpi_parse_object *origin; /* Start of walk [Obsolete] */
119 union acpi_operand_object *result_obj;
120 union acpi_generic_state *results; /* Stack of accumulated results */
121 union acpi_operand_object *return_desc; /* Return object, if any */
122 union acpi_generic_state *scope_info; /* Stack of nested scopes */
123 union acpi_parse_object *prev_op; /* Last op that was processed */
124 union acpi_parse_object *next_op; /* next op to be processed */
125 struct acpi_thread_state *thread;
126 acpi_parse_downwards descending_callback;
127 acpi_parse_upwards ascending_callback;
128};
129
130/* Info used by acpi_ps_init_objects */
131
132struct acpi_init_walk_info {
133 u16 method_count;
134 u16 device_count;
135 u16 op_region_count;
136 u16 field_count;
137 u16 buffer_count;
138 u16 package_count;
139 u16 op_region_init;
140 u16 field_init;
141 u16 buffer_init;
142 u16 package_init;
143 u16 object_count;
144 acpi_owner_id owner_id;
145 u32 table_index;
146};
147
148struct acpi_get_devices_info {
149 acpi_walk_callback user_function;
150 void *context;
151 const char *hid;
152};
153
154union acpi_aml_operands {
155 union acpi_operand_object *operands[7];
156
157 struct {
158 struct acpi_object_integer *type;
159 struct acpi_object_integer *code;
160 struct acpi_object_integer *argument;
161
162 } fatal;
163
164 struct {
165 union acpi_operand_object *source;
166 struct acpi_object_integer *index;
167 union acpi_operand_object *target;
168
169 } index;
170
171 struct {
172 union acpi_operand_object *source;
173 struct acpi_object_integer *index;
174 struct acpi_object_integer *length;
175 union acpi_operand_object *target;
176
177 } mid;
178};
179
180/*
181 * Structure used to pass object evaluation parameters.
182 * Purpose is to reduce CPU stack use.
183 */
184struct acpi_evaluate_info {
185 struct acpi_namespace_node *prefix_node;
186 char *pathname;
187 union acpi_operand_object *obj_desc;
188 union acpi_operand_object **parameters;
189 struct acpi_namespace_node *resolved_node;
190 union acpi_operand_object *return_object;
191 u8 param_count;
192 u8 pass_number;
193 u8 return_object_type;
194 u8 flags;
195};
196
197/* Values for Flags above */
198
199#define ACPI_IGNORE_RETURN_VALUE 1
200
201/* Info used by acpi_ns_initialize_devices */
202
203struct acpi_device_walk_info {
204 u16 device_count;
205 u16 num_STA;
206 u16 num_INI;
207 struct acpi_table_desc *table_desc;
208 struct acpi_evaluate_info *evaluate_info;
209};
210
211/* TBD: [Restructure] Merge with struct above */
212
213struct acpi_walk_info {
214 u32 debug_level;
215 u32 count;
216 acpi_owner_id owner_id;
217 u8 display_type;
218};
219
220/* Display Types */
221
222#define ACPI_DISPLAY_SUMMARY (u8) 0
223#define ACPI_DISPLAY_OBJECTS (u8) 1
224#define ACPI_DISPLAY_MASK (u8) 1
225
226#define ACPI_DISPLAY_SHORT (u8) 2
227
228#endif
diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h
new file mode 100644
index 000000000000..7ce6e33c7f78
--- /dev/null
+++ b/drivers/acpi/acpica/actables.h
@@ -0,0 +1,117 @@
1/******************************************************************************
2 *
3 * Name: actables.h - ACPI table management
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef __ACTABLES_H__
45#define __ACTABLES_H__
46
47acpi_status acpi_allocate_root_table(u32 initial_table_count);
48
49/*
50 * tbfadt - FADT parse/convert/validate
51 */
52void acpi_tb_parse_fadt(u32 table_index, u8 flags);
53
54void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length);
55
56/*
57 * tbfind - find ACPI table
58 */
59acpi_status
60acpi_tb_find_table(char *signature,
61 char *oem_id, char *oem_table_id, u32 *table_index);
62
63/*
64 * tbinstal - Table removal and deletion
65 */
66acpi_status acpi_tb_resize_root_table_list(void);
67
68acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc);
69
70acpi_status
71acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index);
72
73acpi_status
74acpi_tb_store_table(acpi_physical_address address,
75 struct acpi_table_header *table,
76 u32 length, u8 flags, u32 *table_index);
77
78void acpi_tb_delete_table(struct acpi_table_desc *table_desc);
79
80void acpi_tb_terminate(void);
81
82void acpi_tb_delete_namespace_by_owner(u32 table_index);
83
84acpi_status acpi_tb_allocate_owner_id(u32 table_index);
85
86acpi_status acpi_tb_release_owner_id(u32 table_index);
87
88acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id *owner_id);
89
90u8 acpi_tb_is_table_loaded(u32 table_index);
91
92void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded);
93
94/*
95 * tbutils - table manager utilities
96 */
97acpi_status acpi_tb_initialize_facs(void);
98
99u8 acpi_tb_tables_loaded(void);
100
101void
102acpi_tb_print_table_header(acpi_physical_address address,
103 struct acpi_table_header *header);
104
105u8 acpi_tb_checksum(u8 *buffer, u32 length);
106
107acpi_status
108acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length);
109
110void
111acpi_tb_install_table(acpi_physical_address address,
112 u8 flags, char *signature, u32 table_index);
113
114acpi_status
115acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags);
116
117#endif /* __ACTABLES_H__ */
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
new file mode 100644
index 000000000000..80d8813484fe
--- /dev/null
+++ b/drivers/acpi/acpica/acutils.h
@@ -0,0 +1,549 @@
1/******************************************************************************
2 *
3 * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#ifndef _ACUTILS_H
45#define _ACUTILS_H
46
47extern const u8 acpi_gbl_resource_aml_sizes[];
48
49/* Strings used by the disassembler and debugger resource dump routines */
50
51#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER)
52
53extern const char *acpi_gbl_bm_decode[];
54extern const char *acpi_gbl_config_decode[];
55extern const char *acpi_gbl_consume_decode[];
56extern const char *acpi_gbl_dec_decode[];
57extern const char *acpi_gbl_he_decode[];
58extern const char *acpi_gbl_io_decode[];
59extern const char *acpi_gbl_ll_decode[];
60extern const char *acpi_gbl_max_decode[];
61extern const char *acpi_gbl_mem_decode[];
62extern const char *acpi_gbl_min_decode[];
63extern const char *acpi_gbl_mtp_decode[];
64extern const char *acpi_gbl_rng_decode[];
65extern const char *acpi_gbl_rw_decode[];
66extern const char *acpi_gbl_shr_decode[];
67extern const char *acpi_gbl_siz_decode[];
68extern const char *acpi_gbl_trs_decode[];
69extern const char *acpi_gbl_ttp_decode[];
70extern const char *acpi_gbl_typ_decode[];
71#endif
72
73/* Types for Resource descriptor entries */
74
75#define ACPI_INVALID_RESOURCE 0
76#define ACPI_FIXED_LENGTH 1
77#define ACPI_VARIABLE_LENGTH 2
78#define ACPI_SMALL_VARIABLE_LENGTH 3
79
80typedef
81acpi_status(*acpi_walk_aml_callback) (u8 * aml,
82 u32 length,
83 u32 offset,
84 u8 resource_index, void **context);
85
86typedef
87acpi_status(*acpi_pkg_callback) (u8 object_type,
88 union acpi_operand_object * source_object,
89 union acpi_generic_state * state,
90 void *context);
91
92struct acpi_pkg_info {
93 u8 *free_space;
94 acpi_size length;
95 u32 object_space;
96 u32 num_packages;
97};
98
99#define REF_INCREMENT (u16) 0
100#define REF_DECREMENT (u16) 1
101#define REF_FORCE_DELETE (u16) 2
102
103/* acpi_ut_dump_buffer */
104
105#define DB_BYTE_DISPLAY 1
106#define DB_WORD_DISPLAY 2
107#define DB_DWORD_DISPLAY 4
108#define DB_QWORD_DISPLAY 8
109
110/*
111 * utglobal - Global data structures and procedures
112 */
113acpi_status acpi_ut_init_globals(void);
114
115#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
116
117char *acpi_ut_get_mutex_name(u32 mutex_id);
118
119const char *acpi_ut_get_notify_name(u32 notify_value);
120
121#endif
122
123char *acpi_ut_get_type_name(acpi_object_type type);
124
125char *acpi_ut_get_node_name(void *object);
126
127char *acpi_ut_get_descriptor_name(void *object);
128
129const char *acpi_ut_get_reference_name(union acpi_operand_object *object);
130
131char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc);
132
133char *acpi_ut_get_region_name(u8 space_id);
134
135char *acpi_ut_get_event_name(u32 event_id);
136
137char acpi_ut_hex_to_ascii_char(acpi_integer integer, u32 position);
138
139u8 acpi_ut_valid_object_type(acpi_object_type type);
140
141/*
142 * utinit - miscellaneous initialization and shutdown
143 */
144acpi_status acpi_ut_hardware_initialize(void);
145
146void acpi_ut_subsystem_shutdown(void);
147
148/*
149 * utclib - Local implementations of C library functions
150 */
151#ifndef ACPI_USE_SYSTEM_CLIBRARY
152
153acpi_size acpi_ut_strlen(const char *string);
154
155char *acpi_ut_strcpy(char *dst_string, const char *src_string);
156
157char *acpi_ut_strncpy(char *dst_string,
158 const char *src_string, acpi_size count);
159
160int acpi_ut_memcmp(const char *buffer1, const char *buffer2, acpi_size count);
161
162int acpi_ut_strncmp(const char *string1, const char *string2, acpi_size count);
163
164int acpi_ut_strcmp(const char *string1, const char *string2);
165
166char *acpi_ut_strcat(char *dst_string, const char *src_string);
167
168char *acpi_ut_strncat(char *dst_string,
169 const char *src_string, acpi_size count);
170
171u32 acpi_ut_strtoul(const char *string, char **terminator, u32 base);
172
173char *acpi_ut_strstr(char *string1, char *string2);
174
175void *acpi_ut_memcpy(void *dest, const void *src, acpi_size count);
176
177void *acpi_ut_memset(void *dest, u8 value, acpi_size count);
178
179int acpi_ut_to_upper(int c);
180
181int acpi_ut_to_lower(int c);
182
183extern const u8 _acpi_ctype[];
184
185#define _ACPI_XA 0x00 /* extra alphabetic - not supported */
186#define _ACPI_XS 0x40 /* extra space */
187#define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */
188#define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */
189#define _ACPI_DI 0x04 /* '0'-'9' */
190#define _ACPI_LO 0x02 /* 'a'-'z' */
191#define _ACPI_PU 0x10 /* punctuation */
192#define _ACPI_SP 0x08 /* space */
193#define _ACPI_UP 0x01 /* 'A'-'Z' */
194#define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */
195
196#define ACPI_IS_DIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI))
197#define ACPI_IS_SPACE(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP))
198#define ACPI_IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD))
199#define ACPI_IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP))
200#define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO))
201#define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU))
202#define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP))
203
204#endif /* ACPI_USE_SYSTEM_CLIBRARY */
205
206/*
207 * utcopy - Object construction and conversion interfaces
208 */
209acpi_status
210acpi_ut_build_simple_object(union acpi_operand_object *obj,
211 union acpi_object *user_obj,
212 u8 * data_space, u32 * buffer_space_used);
213
214acpi_status
215acpi_ut_build_package_object(union acpi_operand_object *obj,
216 u8 * buffer, u32 * space_used);
217
218acpi_status
219acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *obj,
220 struct acpi_buffer *ret_buffer);
221
222acpi_status
223acpi_ut_copy_eobject_to_iobject(union acpi_object *obj,
224 union acpi_operand_object **internal_obj);
225
226acpi_status
227acpi_ut_copy_isimple_to_isimple(union acpi_operand_object *source_obj,
228 union acpi_operand_object *dest_obj);
229
230acpi_status
231acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc,
232 union acpi_operand_object **dest_desc,
233 struct acpi_walk_state *walk_state);
234
235/*
236 * utcreate - Object creation
237 */
238acpi_status
239acpi_ut_update_object_reference(union acpi_operand_object *object, u16 action);
240
241/*
242 * utdebug - Debug interfaces
243 */
244void acpi_ut_init_stack_ptr_trace(void);
245
246void acpi_ut_track_stack_ptr(void);
247
248void
249acpi_ut_trace(u32 line_number,
250 const char *function_name,
251 const char *module_name, u32 component_id);
252
253void
254acpi_ut_trace_ptr(u32 line_number,
255 const char *function_name,
256 const char *module_name, u32 component_id, void *pointer);
257
258void
259acpi_ut_trace_u32(u32 line_number,
260 const char *function_name,
261 const char *module_name, u32 component_id, u32 integer);
262
263void
264acpi_ut_trace_str(u32 line_number,
265 const char *function_name,
266 const char *module_name, u32 component_id, char *string);
267
268void
269acpi_ut_exit(u32 line_number,
270 const char *function_name,
271 const char *module_name, u32 component_id);
272
273void
274acpi_ut_status_exit(u32 line_number,
275 const char *function_name,
276 const char *module_name,
277 u32 component_id, acpi_status status);
278
279void
280acpi_ut_value_exit(u32 line_number,
281 const char *function_name,
282 const char *module_name,
283 u32 component_id, acpi_integer value);
284
285void
286acpi_ut_ptr_exit(u32 line_number,
287 const char *function_name,
288 const char *module_name, u32 component_id, u8 *ptr);
289
290void acpi_ut_dump_buffer(u8 * buffer, u32 count, u32 display, u32 component_id);
291
292void acpi_ut_dump_buffer2(u8 * buffer, u32 count, u32 display);
293
294void acpi_ut_report_error(char *module_name, u32 line_number);
295
296void acpi_ut_report_info(char *module_name, u32 line_number);
297
298void acpi_ut_report_warning(char *module_name, u32 line_number);
299
300/*
301 * utdelete - Object deletion and reference counts
302 */
303void acpi_ut_add_reference(union acpi_operand_object *object);
304
305void acpi_ut_remove_reference(union acpi_operand_object *object);
306
307void acpi_ut_delete_internal_package_object(union acpi_operand_object *object);
308
309void acpi_ut_delete_internal_simple_object(union acpi_operand_object *object);
310
311void acpi_ut_delete_internal_object_list(union acpi_operand_object **obj_list);
312
313/*
314 * uteval - object evaluation
315 */
316acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state);
317
318acpi_status
319acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
320 char *path,
321 u32 expected_return_btypes,
322 union acpi_operand_object **return_desc);
323
324acpi_status
325acpi_ut_evaluate_numeric_object(char *object_name,
326 struct acpi_namespace_node *device_node,
327 acpi_integer * address);
328
329acpi_status
330acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
331 struct acpica_device_id *hid);
332
333acpi_status
334acpi_ut_execute_CID(struct acpi_namespace_node *device_node,
335 struct acpi_compatible_id_list **return_cid_list);
336
337acpi_status
338acpi_ut_execute_STA(struct acpi_namespace_node *device_node,
339 u32 * status_flags);
340
341acpi_status
342acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
343 struct acpica_device_id *uid);
344
345acpi_status
346acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest);
347
348/*
349 * utobject - internal object create/delete/cache routines
350 */
351union acpi_operand_object *acpi_ut_create_internal_object_dbg(const char
352 *module_name,
353 u32 line_number,
354 u32 component_id,
355 acpi_object_type
356 type);
357
358void *acpi_ut_allocate_object_desc_dbg(const char *module_name,
359 u32 line_number, u32 component_id);
360
361#define acpi_ut_create_internal_object(t) acpi_ut_create_internal_object_dbg (_acpi_module_name,__LINE__,_COMPONENT,t)
362#define acpi_ut_allocate_object_desc() acpi_ut_allocate_object_desc_dbg (_acpi_module_name,__LINE__,_COMPONENT)
363
364void acpi_ut_delete_object_desc(union acpi_operand_object *object);
365
366u8 acpi_ut_valid_internal_object(void *object);
367
368union acpi_operand_object *acpi_ut_create_package_object(u32 count);
369
370union acpi_operand_object *acpi_ut_create_buffer_object(acpi_size buffer_size);
371
372union acpi_operand_object *acpi_ut_create_string_object(acpi_size string_size);
373
374acpi_status
375acpi_ut_get_object_size(union acpi_operand_object *obj, acpi_size * obj_length);
376
377/*
378 * utstate - Generic state creation/cache routines
379 */
380void
381acpi_ut_push_generic_state(union acpi_generic_state **list_head,
382 union acpi_generic_state *state);
383
384union acpi_generic_state *acpi_ut_pop_generic_state(union acpi_generic_state
385 **list_head);
386
387union acpi_generic_state *acpi_ut_create_generic_state(void);
388
389struct acpi_thread_state *acpi_ut_create_thread_state(void);
390
391union acpi_generic_state *acpi_ut_create_update_state(union acpi_operand_object
392 *object, u16 action);
393
394union acpi_generic_state *acpi_ut_create_pkg_state(void *internal_object,
395 void *external_object,
396 u16 index);
397
398acpi_status
399acpi_ut_create_update_state_and_push(union acpi_operand_object *object,
400 u16 action,
401 union acpi_generic_state **state_list);
402
403#ifdef ACPI_FUTURE_USAGE
404acpi_status
405acpi_ut_create_pkg_state_and_push(void *internal_object,
406 void *external_object,
407 u16 index,
408 union acpi_generic_state **state_list);
409#endif /* ACPI_FUTURE_USAGE */
410
411union acpi_generic_state *acpi_ut_create_control_state(void);
412
413void acpi_ut_delete_generic_state(union acpi_generic_state *state);
414
415/*
416 * utmath
417 */
418acpi_status
419acpi_ut_divide(acpi_integer in_dividend,
420 acpi_integer in_divisor,
421 acpi_integer * out_quotient, acpi_integer * out_remainder);
422
423acpi_status
424acpi_ut_short_divide(acpi_integer in_dividend,
425 u32 divisor,
426 acpi_integer * out_quotient, u32 * out_remainder);
427
428/*
429 * utmisc
430 */
431const char *acpi_ut_validate_exception(acpi_status status);
432
433u8 acpi_ut_is_aml_table(struct acpi_table_header *table);
434
435acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id);
436
437void acpi_ut_release_owner_id(acpi_owner_id * owner_id);
438
439acpi_status
440acpi_ut_walk_package_tree(union acpi_operand_object *source_object,
441 void *target_object,
442 acpi_pkg_callback walk_callback, void *context);
443
444void acpi_ut_strupr(char *src_string);
445
446void acpi_ut_print_string(char *string, u8 max_length);
447
448u8 acpi_ut_valid_acpi_name(u32 name);
449
450acpi_name acpi_ut_repair_name(char *name);
451
452u8 acpi_ut_valid_acpi_char(char character, u32 position);
453
454acpi_status
455acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer);
456
457/* Values for Base above (16=Hex, 10=Decimal) */
458
459#define ACPI_ANY_BASE 0
460
461u32 acpi_ut_dword_byte_swap(u32 value);
462
463void acpi_ut_set_integer_width(u8 revision);
464
465#ifdef ACPI_DEBUG_OUTPUT
466void
467acpi_ut_display_init_pathname(u8 type,
468 struct acpi_namespace_node *obj_handle,
469 char *path);
470#endif
471
472/*
473 * utresrc
474 */
475acpi_status
476acpi_ut_walk_aml_resources(u8 * aml,
477 acpi_size aml_length,
478 acpi_walk_aml_callback user_function,
479 void **context);
480
481acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index);
482
483u32 acpi_ut_get_descriptor_length(void *aml);
484
485u16 acpi_ut_get_resource_length(void *aml);
486
487u8 acpi_ut_get_resource_header_length(void *aml);
488
489u8 acpi_ut_get_resource_type(void *aml);
490
491acpi_status
492acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc,
493 u8 ** end_tag);
494
495/*
496 * utmutex - mutex support
497 */
498acpi_status acpi_ut_mutex_initialize(void);
499
500void acpi_ut_mutex_terminate(void);
501
502acpi_status acpi_ut_acquire_mutex(acpi_mutex_handle mutex_id);
503
504acpi_status acpi_ut_release_mutex(acpi_mutex_handle mutex_id);
505
506/*
507 * utalloc - memory allocation and object caching
508 */
509acpi_status acpi_ut_create_caches(void);
510
511acpi_status acpi_ut_delete_caches(void);
512
513acpi_status acpi_ut_validate_buffer(struct acpi_buffer *buffer);
514
515acpi_status
516acpi_ut_initialize_buffer(struct acpi_buffer *buffer,
517 acpi_size required_length);
518
519void *acpi_ut_allocate(acpi_size size,
520 u32 component, const char *module, u32 line);
521
522void *acpi_ut_allocate_zeroed(acpi_size size,
523 u32 component, const char *module, u32 line);
524
525#ifdef ACPI_DBG_TRACK_ALLOCATIONS
526void *acpi_ut_allocate_and_track(acpi_size size,
527 u32 component, const char *module, u32 line);
528
529void *acpi_ut_allocate_zeroed_and_track(acpi_size size,
530 u32 component,
531 const char *module, u32 line);
532
533void
534acpi_ut_free_and_track(void *address,
535 u32 component, const char *module, u32 line);
536
537#ifdef ACPI_FUTURE_USAGE
538void acpi_ut_dump_allocation_info(void);
539#endif /* ACPI_FUTURE_USAGE */
540
541void acpi_ut_dump_allocations(u32 component, const char *module);
542
543acpi_status
544acpi_ut_create_list(char *list_name,
545 u16 object_size, struct acpi_memory_list **return_cache);
546
547#endif
548
549#endif /* _ACUTILS_H */
diff --git a/drivers/acpi/acpica/amlcode.h b/drivers/acpi/acpica/amlcode.h
new file mode 100644
index 000000000000..ff851c5df698
--- /dev/null
+++ b/drivers/acpi/acpica/amlcode.h
@@ -0,0 +1,494 @@
1/******************************************************************************
2 *
3 * Name: amlcode.h - Definitions for AML, as included in "definition blocks"
4 * Declarations and definitions contained herein are derived
5 * directly from the ACPI specification.
6 *
7 *****************************************************************************/
8
9/*
10 * Copyright (C) 2000 - 2008, Intel Corp.
11 * All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions, and the following disclaimer,
18 * without modification.
19 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
20 * substantially similar to the "NO WARRANTY" disclaimer below
21 * ("Disclaimer") and any redistribution must be conditioned upon
22 * including a substantially similar Disclaimer requirement for further
23 * binary redistribution.
24 * 3. Neither the names of the above-listed copyright holders nor the names
25 * of any contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * Alternatively, this software may be distributed under the terms of the
29 * GNU General Public License ("GPL") version 2 as published by the Free
30 * Software Foundation.
31 *
32 * NO WARRANTY
33 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
34 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
35 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
36 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
37 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
38 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
39 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
41 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
42 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
43 * POSSIBILITY OF SUCH DAMAGES.
44 */
45
46#ifndef __AMLCODE_H__
47#define __AMLCODE_H__
48
49/* primary opcodes */
50
51#define AML_NULL_CHAR (u16) 0x00
52
53#define AML_ZERO_OP (u16) 0x00
54#define AML_ONE_OP (u16) 0x01
55#define AML_UNASSIGNED (u16) 0x02
56#define AML_ALIAS_OP (u16) 0x06
57#define AML_NAME_OP (u16) 0x08
58#define AML_BYTE_OP (u16) 0x0a
59#define AML_WORD_OP (u16) 0x0b
60#define AML_DWORD_OP (u16) 0x0c
61#define AML_STRING_OP (u16) 0x0d
62#define AML_QWORD_OP (u16) 0x0e /* ACPI 2.0 */
63#define AML_SCOPE_OP (u16) 0x10
64#define AML_BUFFER_OP (u16) 0x11
65#define AML_PACKAGE_OP (u16) 0x12
66#define AML_VAR_PACKAGE_OP (u16) 0x13 /* ACPI 2.0 */
67#define AML_METHOD_OP (u16) 0x14
68#define AML_DUAL_NAME_PREFIX (u16) 0x2e
69#define AML_MULTI_NAME_PREFIX_OP (u16) 0x2f
70#define AML_NAME_CHAR_SUBSEQ (u16) 0x30
71#define AML_NAME_CHAR_FIRST (u16) 0x41
72#define AML_EXTENDED_OP_PREFIX (u16) 0x5b
73#define AML_ROOT_PREFIX (u16) 0x5c
74#define AML_PARENT_PREFIX (u16) 0x5e
75#define AML_LOCAL_OP (u16) 0x60
76#define AML_LOCAL0 (u16) 0x60
77#define AML_LOCAL1 (u16) 0x61
78#define AML_LOCAL2 (u16) 0x62
79#define AML_LOCAL3 (u16) 0x63
80#define AML_LOCAL4 (u16) 0x64
81#define AML_LOCAL5 (u16) 0x65
82#define AML_LOCAL6 (u16) 0x66
83#define AML_LOCAL7 (u16) 0x67
84#define AML_ARG_OP (u16) 0x68
85#define AML_ARG0 (u16) 0x68
86#define AML_ARG1 (u16) 0x69
87#define AML_ARG2 (u16) 0x6a
88#define AML_ARG3 (u16) 0x6b
89#define AML_ARG4 (u16) 0x6c
90#define AML_ARG5 (u16) 0x6d
91#define AML_ARG6 (u16) 0x6e
92#define AML_STORE_OP (u16) 0x70
93#define AML_REF_OF_OP (u16) 0x71
94#define AML_ADD_OP (u16) 0x72
95#define AML_CONCAT_OP (u16) 0x73
96#define AML_SUBTRACT_OP (u16) 0x74
97#define AML_INCREMENT_OP (u16) 0x75
98#define AML_DECREMENT_OP (u16) 0x76
99#define AML_MULTIPLY_OP (u16) 0x77
100#define AML_DIVIDE_OP (u16) 0x78
101#define AML_SHIFT_LEFT_OP (u16) 0x79
102#define AML_SHIFT_RIGHT_OP (u16) 0x7a
103#define AML_BIT_AND_OP (u16) 0x7b
104#define AML_BIT_NAND_OP (u16) 0x7c
105#define AML_BIT_OR_OP (u16) 0x7d
106#define AML_BIT_NOR_OP (u16) 0x7e
107#define AML_BIT_XOR_OP (u16) 0x7f
108#define AML_BIT_NOT_OP (u16) 0x80
109#define AML_FIND_SET_LEFT_BIT_OP (u16) 0x81
110#define AML_FIND_SET_RIGHT_BIT_OP (u16) 0x82
111#define AML_DEREF_OF_OP (u16) 0x83
112#define AML_CONCAT_RES_OP (u16) 0x84 /* ACPI 2.0 */
113#define AML_MOD_OP (u16) 0x85 /* ACPI 2.0 */
114#define AML_NOTIFY_OP (u16) 0x86
115#define AML_SIZE_OF_OP (u16) 0x87
116#define AML_INDEX_OP (u16) 0x88
117#define AML_MATCH_OP (u16) 0x89
118#define AML_CREATE_DWORD_FIELD_OP (u16) 0x8a
119#define AML_CREATE_WORD_FIELD_OP (u16) 0x8b
120#define AML_CREATE_BYTE_FIELD_OP (u16) 0x8c
121#define AML_CREATE_BIT_FIELD_OP (u16) 0x8d
122#define AML_TYPE_OP (u16) 0x8e
123#define AML_CREATE_QWORD_FIELD_OP (u16) 0x8f /* ACPI 2.0 */
124#define AML_LAND_OP (u16) 0x90
125#define AML_LOR_OP (u16) 0x91
126#define AML_LNOT_OP (u16) 0x92
127#define AML_LEQUAL_OP (u16) 0x93
128#define AML_LGREATER_OP (u16) 0x94
129#define AML_LLESS_OP (u16) 0x95
130#define AML_TO_BUFFER_OP (u16) 0x96 /* ACPI 2.0 */
131#define AML_TO_DECSTRING_OP (u16) 0x97 /* ACPI 2.0 */
132#define AML_TO_HEXSTRING_OP (u16) 0x98 /* ACPI 2.0 */
133#define AML_TO_INTEGER_OP (u16) 0x99 /* ACPI 2.0 */
134#define AML_TO_STRING_OP (u16) 0x9c /* ACPI 2.0 */
135#define AML_COPY_OP (u16) 0x9d /* ACPI 2.0 */
136#define AML_MID_OP (u16) 0x9e /* ACPI 2.0 */
137#define AML_CONTINUE_OP (u16) 0x9f /* ACPI 2.0 */
138#define AML_IF_OP (u16) 0xa0
139#define AML_ELSE_OP (u16) 0xa1
140#define AML_WHILE_OP (u16) 0xa2
141#define AML_NOOP_OP (u16) 0xa3
142#define AML_RETURN_OP (u16) 0xa4
143#define AML_BREAK_OP (u16) 0xa5
144#define AML_BREAK_POINT_OP (u16) 0xcc
145#define AML_ONES_OP (u16) 0xff
146
147/* prefixed opcodes */
148
149#define AML_EXTENDED_OPCODE (u16) 0x5b00 /* prefix for 2-byte opcodes */
150
151#define AML_MUTEX_OP (u16) 0x5b01
152#define AML_EVENT_OP (u16) 0x5b02
153#define AML_SHIFT_RIGHT_BIT_OP (u16) 0x5b10
154#define AML_SHIFT_LEFT_BIT_OP (u16) 0x5b11
155#define AML_COND_REF_OF_OP (u16) 0x5b12
156#define AML_CREATE_FIELD_OP (u16) 0x5b13
157#define AML_LOAD_TABLE_OP (u16) 0x5b1f /* ACPI 2.0 */
158#define AML_LOAD_OP (u16) 0x5b20
159#define AML_STALL_OP (u16) 0x5b21
160#define AML_SLEEP_OP (u16) 0x5b22
161#define AML_ACQUIRE_OP (u16) 0x5b23
162#define AML_SIGNAL_OP (u16) 0x5b24
163#define AML_WAIT_OP (u16) 0x5b25
164#define AML_RESET_OP (u16) 0x5b26
165#define AML_RELEASE_OP (u16) 0x5b27
166#define AML_FROM_BCD_OP (u16) 0x5b28
167#define AML_TO_BCD_OP (u16) 0x5b29
168#define AML_UNLOAD_OP (u16) 0x5b2a
169#define AML_REVISION_OP (u16) 0x5b30
170#define AML_DEBUG_OP (u16) 0x5b31
171#define AML_FATAL_OP (u16) 0x5b32
172#define AML_TIMER_OP (u16) 0x5b33 /* ACPI 3.0 */
173#define AML_REGION_OP (u16) 0x5b80
174#define AML_FIELD_OP (u16) 0x5b81
175#define AML_DEVICE_OP (u16) 0x5b82
176#define AML_PROCESSOR_OP (u16) 0x5b83
177#define AML_POWER_RES_OP (u16) 0x5b84
178#define AML_THERMAL_ZONE_OP (u16) 0x5b85
179#define AML_INDEX_FIELD_OP (u16) 0x5b86
180#define AML_BANK_FIELD_OP (u16) 0x5b87
181#define AML_DATA_REGION_OP (u16) 0x5b88 /* ACPI 2.0 */
182
183/*
184 * Combination opcodes (actually two one-byte opcodes)
185 * Used by the disassembler and i_aSL compiler
186 */
187#define AML_LGREATEREQUAL_OP (u16) 0x9295
188#define AML_LLESSEQUAL_OP (u16) 0x9294
189#define AML_LNOTEQUAL_OP (u16) 0x9293
190
191/*
192 * Internal opcodes
193 * Use only "Unknown" AML opcodes, don't attempt to use
194 * any valid ACPI ASCII values (A-Z, 0-9, '-')
195 */
196#define AML_INT_NAMEPATH_OP (u16) 0x002d
197#define AML_INT_NAMEDFIELD_OP (u16) 0x0030
198#define AML_INT_RESERVEDFIELD_OP (u16) 0x0031
199#define AML_INT_ACCESSFIELD_OP (u16) 0x0032
200#define AML_INT_BYTELIST_OP (u16) 0x0033
201#define AML_INT_STATICSTRING_OP (u16) 0x0034
202#define AML_INT_METHODCALL_OP (u16) 0x0035
203#define AML_INT_RETURN_VALUE_OP (u16) 0x0036
204#define AML_INT_EVAL_SUBTREE_OP (u16) 0x0037
205
206#define ARG_NONE 0x0
207
208/*
209 * Argument types for the AML Parser
210 * Each field in the arg_types u32 is 5 bits, allowing for a maximum of 6 arguments.
211 * There can be up to 31 unique argument types
212 * Zero is reserved as end-of-list indicator
213 */
214#define ARGP_BYTEDATA 0x01
215#define ARGP_BYTELIST 0x02
216#define ARGP_CHARLIST 0x03
217#define ARGP_DATAOBJ 0x04
218#define ARGP_DATAOBJLIST 0x05
219#define ARGP_DWORDDATA 0x06
220#define ARGP_FIELDLIST 0x07
221#define ARGP_NAME 0x08
222#define ARGP_NAMESTRING 0x09
223#define ARGP_OBJLIST 0x0A
224#define ARGP_PKGLENGTH 0x0B
225#define ARGP_SUPERNAME 0x0C
226#define ARGP_TARGET 0x0D
227#define ARGP_TERMARG 0x0E
228#define ARGP_TERMLIST 0x0F
229#define ARGP_WORDDATA 0x10
230#define ARGP_QWORDDATA 0x11
231#define ARGP_SIMPLENAME 0x12
232
233/*
234 * Resolved argument types for the AML Interpreter
235 * Each field in the arg_types u32 is 5 bits, allowing for a maximum of 6 arguments.
236 * There can be up to 31 unique argument types (0 is end-of-arg-list indicator)
237 *
238 * Note1: These values are completely independent from the ACPI_TYPEs
239 * i.e., ARGI_INTEGER != ACPI_TYPE_INTEGER
240 *
241 * Note2: If and when 5 bits becomes insufficient, it would probably be best
242 * to convert to a 6-byte array of argument types, allowing 8 bits per argument.
243 */
244
245/* Single, simple types */
246
247#define ARGI_ANYTYPE 0x01 /* Don't care */
248#define ARGI_PACKAGE 0x02
249#define ARGI_EVENT 0x03
250#define ARGI_MUTEX 0x04
251#define ARGI_DDBHANDLE 0x05
252
253/* Interchangeable types (via implicit conversion) */
254
255#define ARGI_INTEGER 0x06
256#define ARGI_STRING 0x07
257#define ARGI_BUFFER 0x08
258#define ARGI_BUFFER_OR_STRING 0x09 /* Used by MID op only */
259#define ARGI_COMPUTEDATA 0x0A /* Buffer, String, or Integer */
260
261/* Reference objects */
262
263#define ARGI_INTEGER_REF 0x0B
264#define ARGI_OBJECT_REF 0x0C
265#define ARGI_DEVICE_REF 0x0D
266#define ARGI_REFERENCE 0x0E
267#define ARGI_TARGETREF 0x0F /* Target, subject to implicit conversion */
268#define ARGI_FIXED_TARGET 0x10 /* Target, no implicit conversion */
269#define ARGI_SIMPLE_TARGET 0x11 /* Name, Local, Arg -- no implicit conversion */
270
271/* Multiple/complex types */
272
273#define ARGI_DATAOBJECT 0x12 /* Buffer, String, package or reference to a Node - Used only by size_of operator */
274#define ARGI_COMPLEXOBJ 0x13 /* Buffer, String, or package (Used by INDEX op only) */
275#define ARGI_REF_OR_STRING 0x14 /* Reference or String (Used by DEREFOF op only) */
276#define ARGI_REGION_OR_BUFFER 0x15 /* Used by LOAD op only */
277#define ARGI_DATAREFOBJ 0x16
278
279/* Note: types above can expand to 0x1F maximum */
280
281#define ARGI_INVALID_OPCODE 0xFFFFFFFF
282
283/*
284 * hash offsets
285 */
286#define AML_EXTOP_HASH_OFFSET 22
287#define AML_LNOT_HASH_OFFSET 19
288
289/*
290 * opcode groups and types
291 */
292#define OPGRP_NAMED 0x01
293#define OPGRP_FIELD 0x02
294#define OPGRP_BYTELIST 0x04
295
296/*
297 * Opcode information
298 */
299
300/* Opcode flags */
301
302#define AML_LOGICAL 0x0001
303#define AML_LOGICAL_NUMERIC 0x0002
304#define AML_MATH 0x0004
305#define AML_CREATE 0x0008
306#define AML_FIELD 0x0010
307#define AML_DEFER 0x0020
308#define AML_NAMED 0x0040
309#define AML_NSNODE 0x0080
310#define AML_NSOPCODE 0x0100
311#define AML_NSOBJECT 0x0200
312#define AML_HAS_RETVAL 0x0400
313#define AML_HAS_TARGET 0x0800
314#define AML_HAS_ARGS 0x1000
315#define AML_CONSTANT 0x2000
316#define AML_NO_OPERAND_RESOLVE 0x4000
317
318/* Convenient flag groupings */
319
320#define AML_FLAGS_EXEC_0A_0T_1R AML_HAS_RETVAL
321#define AML_FLAGS_EXEC_1A_0T_0R AML_HAS_ARGS /* Monadic1 */
322#define AML_FLAGS_EXEC_1A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Monadic2 */
323#define AML_FLAGS_EXEC_1A_1T_0R AML_HAS_ARGS | AML_HAS_TARGET
324#define AML_FLAGS_EXEC_1A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* monadic2_r */
325#define AML_FLAGS_EXEC_2A_0T_0R AML_HAS_ARGS /* Dyadic1 */
326#define AML_FLAGS_EXEC_2A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Dyadic2 */
327#define AML_FLAGS_EXEC_2A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* dyadic2_r */
328#define AML_FLAGS_EXEC_2A_2T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL
329#define AML_FLAGS_EXEC_3A_0T_0R AML_HAS_ARGS
330#define AML_FLAGS_EXEC_3A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL
331#define AML_FLAGS_EXEC_6A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL
332
333/*
334 * The opcode Type is used in a dispatch table, do not change
335 * without updating the table.
336 */
337#define AML_TYPE_EXEC_0A_0T_1R 0x00
338#define AML_TYPE_EXEC_1A_0T_0R 0x01 /* Monadic1 */
339#define AML_TYPE_EXEC_1A_0T_1R 0x02 /* Monadic2 */
340#define AML_TYPE_EXEC_1A_1T_0R 0x03
341#define AML_TYPE_EXEC_1A_1T_1R 0x04 /* monadic2_r */
342#define AML_TYPE_EXEC_2A_0T_0R 0x05 /* Dyadic1 */
343#define AML_TYPE_EXEC_2A_0T_1R 0x06 /* Dyadic2 */
344#define AML_TYPE_EXEC_2A_1T_1R 0x07 /* dyadic2_r */
345#define AML_TYPE_EXEC_2A_2T_1R 0x08
346#define AML_TYPE_EXEC_3A_0T_0R 0x09
347#define AML_TYPE_EXEC_3A_1T_1R 0x0A
348#define AML_TYPE_EXEC_6A_0T_1R 0x0B
349/* End of types used in dispatch table */
350
351#define AML_TYPE_LITERAL 0x0B
352#define AML_TYPE_CONSTANT 0x0C
353#define AML_TYPE_METHOD_ARGUMENT 0x0D
354#define AML_TYPE_LOCAL_VARIABLE 0x0E
355#define AML_TYPE_DATA_TERM 0x0F
356
357/* Generic for an op that returns a value */
358
359#define AML_TYPE_METHOD_CALL 0x10
360
361/* Misc */
362
363#define AML_TYPE_CREATE_FIELD 0x11
364#define AML_TYPE_CREATE_OBJECT 0x12
365#define AML_TYPE_CONTROL 0x13
366#define AML_TYPE_NAMED_NO_OBJ 0x14
367#define AML_TYPE_NAMED_FIELD 0x15
368#define AML_TYPE_NAMED_SIMPLE 0x16
369#define AML_TYPE_NAMED_COMPLEX 0x17
370#define AML_TYPE_RETURN 0x18
371
372#define AML_TYPE_UNDEFINED 0x19
373#define AML_TYPE_BOGUS 0x1A
374
375/* AML Package Length encodings */
376
377#define ACPI_AML_PACKAGE_TYPE1 0x40
378#define ACPI_AML_PACKAGE_TYPE2 0x4000
379#define ACPI_AML_PACKAGE_TYPE3 0x400000
380#define ACPI_AML_PACKAGE_TYPE4 0x40000000
381
382/*
383 * Opcode classes
384 */
385#define AML_CLASS_EXECUTE 0x00
386#define AML_CLASS_CREATE 0x01
387#define AML_CLASS_ARGUMENT 0x02
388#define AML_CLASS_NAMED_OBJECT 0x03
389#define AML_CLASS_CONTROL 0x04
390#define AML_CLASS_ASCII 0x05
391#define AML_CLASS_PREFIX 0x06
392#define AML_CLASS_INTERNAL 0x07
393#define AML_CLASS_RETURN_VALUE 0x08
394#define AML_CLASS_METHOD_CALL 0x09
395#define AML_CLASS_UNKNOWN 0x0A
396
397/* Predefined Operation Region space_iDs */
398
399typedef enum {
400 REGION_MEMORY = 0,
401 REGION_IO,
402 REGION_PCI_CONFIG,
403 REGION_EC,
404 REGION_SMBUS,
405 REGION_CMOS,
406 REGION_PCI_BAR,
407 REGION_DATA_TABLE, /* Internal use only */
408 REGION_FIXED_HW = 0x7F
409} AML_REGION_TYPES;
410
411/* Comparison operation codes for match_op operator */
412
413typedef enum {
414 MATCH_MTR = 0,
415 MATCH_MEQ = 1,
416 MATCH_MLE = 2,
417 MATCH_MLT = 3,
418 MATCH_MGE = 4,
419 MATCH_MGT = 5
420} AML_MATCH_OPERATOR;
421
422#define MAX_MATCH_OPERATOR 5
423
424/*
425 * field_flags
426 *
427 * This byte is extracted from the AML and includes three separate
428 * pieces of information about the field:
429 * 1) The field access type
430 * 2) The field update rule
431 * 3) The lock rule for the field
432 *
433 * Bits 00 - 03 : access_type (any_acc, byte_acc, etc.)
434 * 04 : lock_rule (1 == Lock)
435 * 05 - 06 : update_rule
436 */
437#define AML_FIELD_ACCESS_TYPE_MASK 0x0F
438#define AML_FIELD_LOCK_RULE_MASK 0x10
439#define AML_FIELD_UPDATE_RULE_MASK 0x60
440
441/* 1) Field Access Types */
442
443typedef enum {
444 AML_FIELD_ACCESS_ANY = 0x00,
445 AML_FIELD_ACCESS_BYTE = 0x01,
446 AML_FIELD_ACCESS_WORD = 0x02,
447 AML_FIELD_ACCESS_DWORD = 0x03,
448 AML_FIELD_ACCESS_QWORD = 0x04, /* ACPI 2.0 */
449 AML_FIELD_ACCESS_BUFFER = 0x05 /* ACPI 2.0 */
450} AML_ACCESS_TYPE;
451
452/* 2) Field Lock Rules */
453
454typedef enum {
455 AML_FIELD_LOCK_NEVER = 0x00,
456 AML_FIELD_LOCK_ALWAYS = 0x10
457} AML_LOCK_RULE;
458
459/* 3) Field Update Rules */
460
461typedef enum {
462 AML_FIELD_UPDATE_PRESERVE = 0x00,
463 AML_FIELD_UPDATE_WRITE_AS_ONES = 0x20,
464 AML_FIELD_UPDATE_WRITE_AS_ZEROS = 0x40
465} AML_UPDATE_RULE;
466
467/*
468 * Field Access Attributes.
469 * This byte is extracted from the AML via the
470 * access_as keyword
471 */
472typedef enum {
473 AML_FIELD_ATTRIB_SMB_QUICK = 0x02,
474 AML_FIELD_ATTRIB_SMB_SEND_RCV = 0x04,
475 AML_FIELD_ATTRIB_SMB_BYTE = 0x06,
476 AML_FIELD_ATTRIB_SMB_WORD = 0x08,
477 AML_FIELD_ATTRIB_SMB_BLOCK = 0x0A,
478 AML_FIELD_ATTRIB_SMB_WORD_CALL = 0x0C,
479 AML_FIELD_ATTRIB_SMB_BLOCK_CALL = 0x0D
480} AML_ACCESS_ATTRIBUTE;
481
482/* Bit fields in method_flags byte */
483
484#define AML_METHOD_ARG_COUNT 0x07
485#define AML_METHOD_SERIALIZED 0x08
486#define AML_METHOD_SYNCH_LEVEL 0xF0
487
488/* METHOD_FLAGS_ARG_COUNT is not used internally, define additional flags */
489
490#define AML_METHOD_INTERNAL_ONLY 0x01
491#define AML_METHOD_RESERVED1 0x02
492#define AML_METHOD_RESERVED2 0x04
493
494#endif /* __AMLCODE_H__ */
diff --git a/drivers/acpi/acpica/amlresrc.h b/drivers/acpi/acpica/amlresrc.h
new file mode 100644
index 000000000000..7b070e42b7c5
--- /dev/null
+++ b/drivers/acpi/acpica/amlresrc.h
@@ -0,0 +1,311 @@
1
2/******************************************************************************
3 *
4 * Module Name: amlresrc.h - AML resource descriptors
5 *
6 *****************************************************************************/
7
8/*
9 * Copyright (C) 2000 - 2008, Intel Corp.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
30 *
31 * NO WARRANTY
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
43 */
44
45/* acpisrc:struct_defs -- for acpisrc conversion */
46
47#ifndef __AMLRESRC_H
48#define __AMLRESRC_H
49
50/*
51 * Resource descriptor tags, as defined in the ACPI specification.
52 * Used to symbolically reference fields within a descriptor.
53 */
54#define ACPI_RESTAG_ADDRESS "_ADR"
55#define ACPI_RESTAG_ALIGNMENT "_ALN"
56#define ACPI_RESTAG_ADDRESSSPACE "_ASI"
57#define ACPI_RESTAG_ACCESSSIZE "_ASZ"
58#define ACPI_RESTAG_TYPESPECIFICATTRIBUTES "_ATT"
59#define ACPI_RESTAG_BASEADDRESS "_BAS"
60#define ACPI_RESTAG_BUSMASTER "_BM_" /* Master(1), Slave(0) */
61#define ACPI_RESTAG_DECODE "_DEC"
62#define ACPI_RESTAG_DMA "_DMA"
63#define ACPI_RESTAG_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */
64#define ACPI_RESTAG_GRANULARITY "_GRA"
65#define ACPI_RESTAG_INTERRUPT "_INT"
66#define ACPI_RESTAG_INTERRUPTLEVEL "_LL_" /* active_lo(1), active_hi(0) */
67#define ACPI_RESTAG_INTERRUPTSHARE "_SHR" /* Shareable(1), no_share(0) */
68#define ACPI_RESTAG_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */
69#define ACPI_RESTAG_LENGTH "_LEN"
70#define ACPI_RESTAG_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */
71#define ACPI_RESTAG_MEMTYPE "_MEM" /* non_cache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */
72#define ACPI_RESTAG_MAXADDR "_MAX"
73#define ACPI_RESTAG_MINADDR "_MIN"
74#define ACPI_RESTAG_MAXTYPE "_MAF"
75#define ACPI_RESTAG_MINTYPE "_MIF"
76#define ACPI_RESTAG_REGISTERBITOFFSET "_RBO"
77#define ACPI_RESTAG_REGISTERBITWIDTH "_RBW"
78#define ACPI_RESTAG_RANGETYPE "_RNG"
79#define ACPI_RESTAG_READWRITETYPE "_RW_" /* read_only(0), Writeable (1) */
80#define ACPI_RESTAG_TRANSLATION "_TRA"
81#define ACPI_RESTAG_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */
82#define ACPI_RESTAG_TYPE "_TTP" /* Translation(1), Static (0) */
83#define ACPI_RESTAG_XFERTYPE "_SIZ" /* 8(0), 8_and16(1), 16(2) */
84
85/* Default sizes for "small" resource descriptors */
86
87#define ASL_RDESC_IRQ_SIZE 0x02
88#define ASL_RDESC_DMA_SIZE 0x02
89#define ASL_RDESC_ST_DEPEND_SIZE 0x00
90#define ASL_RDESC_END_DEPEND_SIZE 0x00
91#define ASL_RDESC_IO_SIZE 0x07
92#define ASL_RDESC_FIXED_IO_SIZE 0x03
93#define ASL_RDESC_END_TAG_SIZE 0x01
94
95struct asl_resource_node {
96 u32 buffer_length;
97 void *buffer;
98 struct asl_resource_node *next;
99};
100
101/* Macros used to generate AML resource length fields */
102
103#define ACPI_AML_SIZE_LARGE(r) (sizeof (r) - sizeof (struct aml_resource_large_header))
104#define ACPI_AML_SIZE_SMALL(r) (sizeof (r) - sizeof (struct aml_resource_small_header))
105
106/*
107 * Resource descriptors defined in the ACPI specification.
108 *
109 * Packing/alignment must be BYTE because these descriptors
110 * are used to overlay the raw AML byte stream.
111 */
112#pragma pack(1)
113
114/*
115 * SMALL descriptors
116 */
117#define AML_RESOURCE_SMALL_HEADER_COMMON \
118 u8 descriptor_type;
119
120struct aml_resource_small_header {
121AML_RESOURCE_SMALL_HEADER_COMMON};
122
123struct aml_resource_irq {
124 AML_RESOURCE_SMALL_HEADER_COMMON u16 irq_mask;
125 u8 flags;
126};
127
128struct aml_resource_irq_noflags {
129 AML_RESOURCE_SMALL_HEADER_COMMON u16 irq_mask;
130};
131
132struct aml_resource_dma {
133 AML_RESOURCE_SMALL_HEADER_COMMON u8 dma_channel_mask;
134 u8 flags;
135};
136
137struct aml_resource_start_dependent {
138 AML_RESOURCE_SMALL_HEADER_COMMON u8 flags;
139};
140
141struct aml_resource_start_dependent_noprio {
142AML_RESOURCE_SMALL_HEADER_COMMON};
143
144struct aml_resource_end_dependent {
145AML_RESOURCE_SMALL_HEADER_COMMON};
146
147struct aml_resource_io {
148 AML_RESOURCE_SMALL_HEADER_COMMON u8 flags;
149 u16 minimum;
150 u16 maximum;
151 u8 alignment;
152 u8 address_length;
153};
154
155struct aml_resource_fixed_io {
156 AML_RESOURCE_SMALL_HEADER_COMMON u16 address;
157 u8 address_length;
158};
159
160struct aml_resource_vendor_small {
161AML_RESOURCE_SMALL_HEADER_COMMON};
162
163struct aml_resource_end_tag {
164 AML_RESOURCE_SMALL_HEADER_COMMON u8 checksum;
165};
166
167/*
168 * LARGE descriptors
169 */
170#define AML_RESOURCE_LARGE_HEADER_COMMON \
171 u8 descriptor_type;\
172 u16 resource_length;
173
174struct aml_resource_large_header {
175AML_RESOURCE_LARGE_HEADER_COMMON};
176
177struct aml_resource_memory24 {
178 AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
179 u16 minimum;
180 u16 maximum;
181 u16 alignment;
182 u16 address_length;
183};
184
185struct aml_resource_vendor_large {
186AML_RESOURCE_LARGE_HEADER_COMMON};
187
188struct aml_resource_memory32 {
189 AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
190 u32 minimum;
191 u32 maximum;
192 u32 alignment;
193 u32 address_length;
194};
195
196struct aml_resource_fixed_memory32 {
197 AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
198 u32 address;
199 u32 address_length;
200};
201
202#define AML_RESOURCE_ADDRESS_COMMON \
203 u8 resource_type; \
204 u8 flags; \
205 u8 specific_flags;
206
207struct aml_resource_address {
208AML_RESOURCE_LARGE_HEADER_COMMON AML_RESOURCE_ADDRESS_COMMON};
209
210struct aml_resource_extended_address64 {
211 AML_RESOURCE_LARGE_HEADER_COMMON
212 AML_RESOURCE_ADDRESS_COMMON u8 revision_iD;
213 u8 reserved;
214 u64 granularity;
215 u64 minimum;
216 u64 maximum;
217 u64 translation_offset;
218 u64 address_length;
219 u64 type_specific;
220};
221
222#define AML_RESOURCE_EXTENDED_ADDRESS_REVISION 1 /* ACPI 3.0 */
223
224struct aml_resource_address64 {
225 AML_RESOURCE_LARGE_HEADER_COMMON
226 AML_RESOURCE_ADDRESS_COMMON u64 granularity;
227 u64 minimum;
228 u64 maximum;
229 u64 translation_offset;
230 u64 address_length;
231};
232
233struct aml_resource_address32 {
234 AML_RESOURCE_LARGE_HEADER_COMMON
235 AML_RESOURCE_ADDRESS_COMMON u32 granularity;
236 u32 minimum;
237 u32 maximum;
238 u32 translation_offset;
239 u32 address_length;
240};
241
242struct aml_resource_address16 {
243 AML_RESOURCE_LARGE_HEADER_COMMON
244 AML_RESOURCE_ADDRESS_COMMON u16 granularity;
245 u16 minimum;
246 u16 maximum;
247 u16 translation_offset;
248 u16 address_length;
249};
250
251struct aml_resource_extended_irq {
252 AML_RESOURCE_LARGE_HEADER_COMMON u8 flags;
253 u8 interrupt_count;
254 u32 interrupts[1];
255 /* res_source_index, res_source optional fields follow */
256};
257
258struct aml_resource_generic_register {
259 AML_RESOURCE_LARGE_HEADER_COMMON u8 address_space_id;
260 u8 bit_width;
261 u8 bit_offset;
262 u8 access_size; /* ACPI 3.0, was previously Reserved */
263 u64 address;
264};
265
266/* restore default alignment */
267
268#pragma pack()
269
270/* Union of all resource descriptors, so we can allocate the worst case */
271
272union aml_resource {
273 /* Descriptor headers */
274
275 u8 descriptor_type;
276 struct aml_resource_small_header small_header;
277 struct aml_resource_large_header large_header;
278
279 /* Small resource descriptors */
280
281 struct aml_resource_irq irq;
282 struct aml_resource_dma dma;
283 struct aml_resource_start_dependent start_dpf;
284 struct aml_resource_end_dependent end_dpf;
285 struct aml_resource_io io;
286 struct aml_resource_fixed_io fixed_io;
287 struct aml_resource_vendor_small vendor_small;
288 struct aml_resource_end_tag end_tag;
289
290 /* Large resource descriptors */
291
292 struct aml_resource_memory24 memory24;
293 struct aml_resource_generic_register generic_reg;
294 struct aml_resource_vendor_large vendor_large;
295 struct aml_resource_memory32 memory32;
296 struct aml_resource_fixed_memory32 fixed_memory32;
297 struct aml_resource_address16 address16;
298 struct aml_resource_address32 address32;
299 struct aml_resource_address64 address64;
300 struct aml_resource_extended_address64 ext_address64;
301 struct aml_resource_extended_irq extended_irq;
302
303 /* Utility overlays */
304
305 struct aml_resource_address address;
306 u32 dword_item;
307 u16 word_item;
308 u8 byte_item;
309};
310
311#endif
diff --git a/drivers/acpi/dispatcher/dsfield.c b/drivers/acpi/acpica/dsfield.c
index f988a5e7d2b4..53e27bc5a734 100644
--- a/drivers/acpi/dispatcher/dsfield.c
+++ b/drivers/acpi/acpica/dsfield.c
@@ -42,11 +42,12 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/amlcode.h> 45#include "accommon.h"
46#include <acpi/acdispat.h> 46#include "amlcode.h"
47#include <acpi/acinterp.h> 47#include "acdispat.h"
48#include <acpi/acnamesp.h> 48#include "acinterp.h"
49#include <acpi/acparser.h> 49#include "acnamesp.h"
50#include "acparser.h"
50 51
51#define _COMPONENT ACPI_DISPATCHER 52#define _COMPONENT ACPI_DISPATCHER
52ACPI_MODULE_NAME("dsfield") 53ACPI_MODULE_NAME("dsfield")
diff --git a/drivers/acpi/dispatcher/dsinit.c b/drivers/acpi/acpica/dsinit.c
index 949f7c75029e..eb144b13d8fa 100644
--- a/drivers/acpi/dispatcher/dsinit.c
+++ b/drivers/acpi/acpica/dsinit.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acdispat.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acdispat.h"
47#include <acpi/actables.h> 47#include "acnamesp.h"
48#include "actables.h"
48 49
49#define _COMPONENT ACPI_DISPATCHER 50#define _COMPONENT ACPI_DISPATCHER
50ACPI_MODULE_NAME("dsinit") 51ACPI_MODULE_NAME("dsinit")
diff --git a/drivers/acpi/dispatcher/dsmethod.c b/drivers/acpi/acpica/dsmethod.c
index 279a5a60a0dd..14b8b8ed8023 100644
--- a/drivers/acpi/dispatcher/dsmethod.c
+++ b/drivers/acpi/acpica/dsmethod.c
@@ -42,11 +42,14 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/amlcode.h> 45#include "accommon.h"
46#include <acpi/acdispat.h> 46#include "amlcode.h"
47#include <acpi/acinterp.h> 47#include "acdispat.h"
48#include <acpi/acnamesp.h> 48#include "acinterp.h"
49#include "acnamesp.h"
50#ifdef ACPI_DISASSEMBLER
49#include <acpi/acdisasm.h> 51#include <acpi/acdisasm.h>
52#endif
50 53
51#define _COMPONENT ACPI_DISPATCHER 54#define _COMPONENT ACPI_DISPATCHER
52ACPI_MODULE_NAME("dsmethod") 55ACPI_MODULE_NAME("dsmethod")
@@ -412,6 +415,9 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread,
412 415
413 if (obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) { 416 if (obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) {
414 status = obj_desc->method.implementation(next_walk_state); 417 status = obj_desc->method.implementation(next_walk_state);
418 if (status == AE_OK) {
419 status = AE_CTRL_TERMINATE;
420 }
415 } 421 }
416 422
417 return_ACPI_STATUS(status); 423 return_ACPI_STATUS(status);
diff --git a/drivers/acpi/dispatcher/dsmthdat.c b/drivers/acpi/acpica/dsmthdat.c
index d03f81bd1bcb..da0f5468184c 100644
--- a/drivers/acpi/dispatcher/dsmthdat.c
+++ b/drivers/acpi/acpica/dsmthdat.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acdispat.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acdispat.h"
47#include <acpi/acinterp.h> 47#include "acnamesp.h"
48#include "acinterp.h"
48 49
49#define _COMPONENT ACPI_DISPATCHER 50#define _COMPONENT ACPI_DISPATCHER
50ACPI_MODULE_NAME("dsmthdat") 51ACPI_MODULE_NAME("dsmthdat")
diff --git a/drivers/acpi/dispatcher/dsobject.c b/drivers/acpi/acpica/dsobject.c
index 4f08e599d07e..15c628e6aa00 100644
--- a/drivers/acpi/dispatcher/dsobject.c
+++ b/drivers/acpi/acpica/dsobject.c
@@ -42,11 +42,12 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include <acpi/amlcode.h> 46#include "acparser.h"
47#include <acpi/acdispat.h> 47#include "amlcode.h"
48#include <acpi/acnamesp.h> 48#include "acdispat.h"
49#include <acpi/acinterp.h> 49#include "acnamesp.h"
50#include "acinterp.h"
50 51
51#define _COMPONENT ACPI_DISPATCHER 52#define _COMPONENT ACPI_DISPATCHER
52ACPI_MODULE_NAME("dsobject") 53ACPI_MODULE_NAME("dsobject")
diff --git a/drivers/acpi/dispatcher/dsopcode.c b/drivers/acpi/acpica/dsopcode.c
index 69fae5905bb8..0c3b4dd60e8a 100644
--- a/drivers/acpi/dispatcher/dsopcode.c
+++ b/drivers/acpi/acpica/dsopcode.c
@@ -43,13 +43,14 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acparser.h> 46#include "accommon.h"
47#include <acpi/amlcode.h> 47#include "acparser.h"
48#include <acpi/acdispat.h> 48#include "amlcode.h"
49#include <acpi/acinterp.h> 49#include "acdispat.h"
50#include <acpi/acnamesp.h> 50#include "acinterp.h"
51#include <acpi/acevents.h> 51#include "acnamesp.h"
52#include <acpi/actables.h> 52#include "acevents.h"
53#include "actables.h"
53 54
54#define _COMPONENT ACPI_DISPATCHER 55#define _COMPONENT ACPI_DISPATCHER
55ACPI_MODULE_NAME("dsopcode") 56ACPI_MODULE_NAME("dsopcode")
@@ -1140,10 +1141,29 @@ acpi_ds_exec_begin_control_op(struct acpi_walk_state *walk_state,
1140 op->common.aml_opcode, walk_state)); 1141 op->common.aml_opcode, walk_state));
1141 1142
1142 switch (op->common.aml_opcode) { 1143 switch (op->common.aml_opcode) {
1143 case AML_IF_OP:
1144 case AML_WHILE_OP: 1144 case AML_WHILE_OP:
1145 1145
1146 /* 1146 /*
1147 * If this is an additional iteration of a while loop, continue.
1148 * There is no need to allocate a new control state.
1149 */
1150 if (walk_state->control_state) {
1151 if (walk_state->control_state->control.aml_predicate_start
1152 == (walk_state->parser_state.aml - 1)) {
1153
1154 /* Reset the state to start-of-loop */
1155
1156 walk_state->control_state->common.state =
1157 ACPI_CONTROL_CONDITIONAL_EXECUTING;
1158 break;
1159 }
1160 }
1161
1162 /*lint -fallthrough */
1163
1164 case AML_IF_OP:
1165
1166 /*
1147 * IF/WHILE: Create a new control state to manage these 1167 * IF/WHILE: Create a new control state to manage these
1148 * constructs. We need to manage these as a stack, in order 1168 * constructs. We need to manage these as a stack, in order
1149 * to handle nesting. 1169 * to handle nesting.
@@ -1243,13 +1263,36 @@ acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state,
1243 1263
1244 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op)); 1264 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", op));
1245 1265
1246 if (walk_state->control_state->common.value) { 1266 control_state = walk_state->control_state;
1267 if (control_state->common.value) {
1247 1268
1248 /* Predicate was true, go back and evaluate it again! */ 1269 /* Predicate was true, the body of the loop was just executed */
1249 1270
1271 /*
1272 * This loop counter mechanism allows the interpreter to escape
1273 * possibly infinite loops. This can occur in poorly written AML
1274 * when the hardware does not respond within a while loop and the
1275 * loop does not implement a timeout.
1276 */
1277 control_state->control.loop_count++;
1278 if (control_state->control.loop_count >
1279 ACPI_MAX_LOOP_ITERATIONS) {
1280 status = AE_AML_INFINITE_LOOP;
1281 break;
1282 }
1283
1284 /*
1285 * Go back and evaluate the predicate and maybe execute the loop
1286 * another time
1287 */
1250 status = AE_CTRL_PENDING; 1288 status = AE_CTRL_PENDING;
1289 walk_state->aml_last_while =
1290 control_state->control.aml_predicate_start;
1291 break;
1251 } 1292 }
1252 1293
1294 /* Predicate was false, terminate this while loop */
1295
1253 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, 1296 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
1254 "[WHILE_OP] termination! Op=%p\n", op)); 1297 "[WHILE_OP] termination! Op=%p\n", op));
1255 1298
@@ -1257,9 +1300,6 @@ acpi_ds_exec_end_control_op(struct acpi_walk_state * walk_state,
1257 1300
1258 control_state = 1301 control_state =
1259 acpi_ut_pop_generic_state(&walk_state->control_state); 1302 acpi_ut_pop_generic_state(&walk_state->control_state);
1260
1261 walk_state->aml_last_while =
1262 control_state->control.aml_predicate_start;
1263 acpi_ut_delete_generic_state(control_state); 1303 acpi_ut_delete_generic_state(control_state);
1264 break; 1304 break;
1265 1305
diff --git a/drivers/acpi/dispatcher/dsutils.c b/drivers/acpi/acpica/dsutils.c
index b398982f0d8b..dabc23a46176 100644
--- a/drivers/acpi/dispatcher/dsutils.c
+++ b/drivers/acpi/acpica/dsutils.c
@@ -42,12 +42,13 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include <acpi/amlcode.h> 46#include "acparser.h"
47#include <acpi/acdispat.h> 47#include "amlcode.h"
48#include <acpi/acinterp.h> 48#include "acdispat.h"
49#include <acpi/acnamesp.h> 49#include "acinterp.h"
50#include <acpi/acdebug.h> 50#include "acnamesp.h"
51#include "acdebug.h"
51 52
52#define _COMPONENT ACPI_DISPATCHER 53#define _COMPONENT ACPI_DISPATCHER
53ACPI_MODULE_NAME("dsutils") 54ACPI_MODULE_NAME("dsutils")
diff --git a/drivers/acpi/dispatcher/dswexec.c b/drivers/acpi/acpica/dswexec.c
index 396fe12078cd..350e6656bc89 100644
--- a/drivers/acpi/dispatcher/dswexec.c
+++ b/drivers/acpi/acpica/dswexec.c
@@ -43,12 +43,13 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acparser.h> 46#include "accommon.h"
47#include <acpi/amlcode.h> 47#include "acparser.h"
48#include <acpi/acdispat.h> 48#include "amlcode.h"
49#include <acpi/acinterp.h> 49#include "acdispat.h"
50#include <acpi/acnamesp.h> 50#include "acinterp.h"
51#include <acpi/acdebug.h> 51#include "acnamesp.h"
52#include "acdebug.h"
52 53
53#define _COMPONENT ACPI_DISPATCHER 54#define _COMPONENT ACPI_DISPATCHER
54ACPI_MODULE_NAME("dswexec") 55ACPI_MODULE_NAME("dswexec")
diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/acpica/dswload.c
index dff7a3e445a8..3023ceaa8d54 100644
--- a/drivers/acpi/dispatcher/dswload.c
+++ b/drivers/acpi/acpica/dswload.c
@@ -42,12 +42,13 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include <acpi/amlcode.h> 46#include "acparser.h"
47#include <acpi/acdispat.h> 47#include "amlcode.h"
48#include <acpi/acinterp.h> 48#include "acdispat.h"
49#include <acpi/acnamesp.h> 49#include "acinterp.h"
50#include <acpi/acevents.h> 50#include "acnamesp.h"
51#include "acevents.h"
51 52
52#ifdef ACPI_ASL_COMPILER 53#ifdef ACPI_ASL_COMPILER
53#include <acpi/acdisasm.h> 54#include <acpi/acdisasm.h>
diff --git a/drivers/acpi/dispatcher/dswscope.c b/drivers/acpi/acpica/dswscope.c
index 9e6073265873..908645e72f03 100644
--- a/drivers/acpi/dispatcher/dswscope.c
+++ b/drivers/acpi/acpica/dswscope.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acdispat.h> 45#include "accommon.h"
46#include "acdispat.h"
46 47
47#define _COMPONENT ACPI_DISPATCHER 48#define _COMPONENT ACPI_DISPATCHER
48ACPI_MODULE_NAME("dswscope") 49ACPI_MODULE_NAME("dswscope")
diff --git a/drivers/acpi/dispatcher/dswstate.c b/drivers/acpi/acpica/dswstate.c
index b00d4af791aa..40f92bf7dce5 100644
--- a/drivers/acpi/dispatcher/dswstate.c
+++ b/drivers/acpi/acpica/dswstate.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include <acpi/acdispat.h> 46#include "acparser.h"
47#include <acpi/acnamesp.h> 47#include "acdispat.h"
48#include "acnamesp.h"
48 49
49#define _COMPONENT ACPI_DISPATCHER 50#define _COMPONENT ACPI_DISPATCHER
50ACPI_MODULE_NAME("dswstate") 51ACPI_MODULE_NAME("dswstate")
diff --git a/drivers/acpi/events/evevent.c b/drivers/acpi/acpica/evevent.c
index c56c5c6ea77b..803edd9e3f6a 100644
--- a/drivers/acpi/events/evevent.c
+++ b/drivers/acpi/acpica/evevent.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acevents.h> 45#include "accommon.h"
46#include "acevents.h"
46 47
47#define _COMPONENT ACPI_EVENTS 48#define _COMPONENT ACPI_EVENTS
48ACPI_MODULE_NAME("evevent") 49ACPI_MODULE_NAME("evevent")
@@ -72,8 +73,8 @@ acpi_status acpi_ev_initialize_events(void)
72 73
73 /* 74 /*
74 * Initialize the Fixed and General Purpose Events. This is done prior to 75 * Initialize the Fixed and General Purpose Events. This is done prior to
75 * enabling SCIs to prevent interrupts from occurring before the handlers are 76 * enabling SCIs to prevent interrupts from occurring before the handlers
76 * installed. 77 * are installed.
77 */ 78 */
78 status = acpi_ev_fixed_event_initialize(); 79 status = acpi_ev_fixed_event_initialize();
79 if (ACPI_FAILURE(status)) { 80 if (ACPI_FAILURE(status)) {
@@ -192,8 +193,8 @@ static acpi_status acpi_ev_fixed_event_initialize(void)
192 acpi_status status; 193 acpi_status status;
193 194
194 /* 195 /*
195 * Initialize the structure that keeps track of fixed event handlers 196 * Initialize the structure that keeps track of fixed event handlers and
196 * and enable the fixed events. 197 * enable the fixed events.
197 */ 198 */
198 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { 199 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
199 acpi_gbl_fixed_event_handlers[i].handler = NULL; 200 acpi_gbl_fixed_event_handlers[i].handler = NULL;
@@ -237,7 +238,7 @@ u32 acpi_ev_fixed_event_detect(void)
237 238
238 /* 239 /*
239 * Read the fixed feature status and enable registers, as all the cases 240 * Read the fixed feature status and enable registers, as all the cases
240 * depend on their values. Ignore errors here. 241 * depend on their values. Ignore errors here.
241 */ 242 */
242 (void)acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS, &fixed_status); 243 (void)acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS, &fixed_status);
243 (void)acpi_hw_register_read(ACPI_REGISTER_PM1_ENABLE, &fixed_enable); 244 (void)acpi_hw_register_read(ACPI_REGISTER_PM1_ENABLE, &fixed_enable);
@@ -291,8 +292,8 @@ static u32 acpi_ev_fixed_event_dispatch(u32 event)
291 status_register_id, 1); 292 status_register_id, 1);
292 293
293 /* 294 /*
294 * Make sure we've got a handler. If not, report an error. 295 * Make sure we've got a handler. If not, report an error. The event is
295 * The event is disabled to prevent further interrupts. 296 * disabled to prevent further interrupts.
296 */ 297 */
297 if (NULL == acpi_gbl_fixed_event_handlers[event].handler) { 298 if (NULL == acpi_gbl_fixed_event_handlers[event].handler) {
298 (void)acpi_set_register(acpi_gbl_fixed_event_info[event]. 299 (void)acpi_set_register(acpi_gbl_fixed_event_info[event].
diff --git a/drivers/acpi/events/evgpe.c b/drivers/acpi/acpica/evgpe.c
index f45c74fe745e..f345ced36477 100644
--- a/drivers/acpi/events/evgpe.c
+++ b/drivers/acpi/acpica/evgpe.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acevents.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acevents.h"
47#include "acnamesp.h"
47 48
48#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
49ACPI_MODULE_NAME("evgpe") 50ACPI_MODULE_NAME("evgpe")
@@ -125,7 +126,7 @@ acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info,
125 (1 << 126 (1 <<
126 (gpe_event_info->gpe_number - gpe_register_info->base_gpe_number)); 127 (gpe_event_info->gpe_number - gpe_register_info->base_gpe_number));
127 128
128 /* 1) Disable case. Simply clear all enable bits */ 129 /* 1) Disable case. Simply clear all enable bits */
129 130
130 if (type == ACPI_GPE_DISABLE) { 131 if (type == ACPI_GPE_DISABLE) {
131 ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake, 132 ACPI_CLEAR_BIT(gpe_register_info->enable_for_wake,
@@ -134,7 +135,7 @@ acpi_ev_update_gpe_enable_masks(struct acpi_gpe_event_info *gpe_event_info,
134 return_ACPI_STATUS(AE_OK); 135 return_ACPI_STATUS(AE_OK);
135 } 136 }
136 137
137 /* 2) Enable case. Set/Clear the appropriate enable bits */ 138 /* 2) Enable case. Set/Clear the appropriate enable bits */
138 139
139 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) { 140 switch (gpe_event_info->flags & ACPI_GPE_TYPE_MASK) {
140 case ACPI_GPE_TYPE_WAKE: 141 case ACPI_GPE_TYPE_WAKE:
@@ -295,7 +296,7 @@ acpi_status acpi_ev_disable_gpe(struct acpi_gpe_event_info *gpe_event_info)
295 * 296 *
296 * FUNCTION: acpi_ev_get_gpe_event_info 297 * FUNCTION: acpi_ev_get_gpe_event_info
297 * 298 *
298 * PARAMETERS: gpe_device - Device node. NULL for GPE0/GPE1 299 * PARAMETERS: gpe_device - Device node. NULL for GPE0/GPE1
299 * gpe_number - Raw GPE number 300 * gpe_number - Raw GPE number
300 * 301 *
301 * RETURN: A GPE event_info struct. NULL if not a valid GPE 302 * RETURN: A GPE event_info struct. NULL if not a valid GPE
@@ -372,7 +373,7 @@ struct acpi_gpe_event_info *acpi_ev_get_gpe_event_info(acpi_handle gpe_device,
372 * 373 *
373 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED 374 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
374 * 375 *
375 * DESCRIPTION: Detect if any GP events have occurred. This function is 376 * DESCRIPTION: Detect if any GP events have occurred. This function is
376 * executed at interrupt level. 377 * executed at interrupt level.
377 * 378 *
378 ******************************************************************************/ 379 ******************************************************************************/
@@ -400,8 +401,8 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
400 401
401 /* 402 /*
402 * We need to obtain the GPE lock for both the data structs and registers 403 * We need to obtain the GPE lock for both the data structs and registers
403 * Note: Not necessary to obtain the hardware lock, since the GPE registers 404 * Note: Not necessary to obtain the hardware lock, since the GPE
404 * are owned by the gpe_lock. 405 * registers are owned by the gpe_lock.
405 */ 406 */
406 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); 407 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
407 408
@@ -410,9 +411,8 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
410 gpe_block = gpe_xrupt_list->gpe_block_list_head; 411 gpe_block = gpe_xrupt_list->gpe_block_list_head;
411 while (gpe_block) { 412 while (gpe_block) {
412 /* 413 /*
413 * Read all of the 8-bit GPE status and enable registers 414 * Read all of the 8-bit GPE status and enable registers in this GPE
414 * in this GPE block, saving all of them. 415 * block, saving all of them. Find all currently active GP events.
415 * Find all currently active GP events.
416 */ 416 */
417 for (i = 0; i < gpe_block->register_count; i++) { 417 for (i = 0; i < gpe_block->register_count; i++) {
418 418
@@ -423,10 +423,8 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
423 /* Read the Status Register */ 423 /* Read the Status Register */
424 424
425 status = 425 status =
426 acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH, 426 acpi_read(&status_reg,
427 &status_reg, 427 &gpe_register_info->status_address);
428 &gpe_register_info->
429 status_address);
430 if (ACPI_FAILURE(status)) { 428 if (ACPI_FAILURE(status)) {
431 goto unlock_and_exit; 429 goto unlock_and_exit;
432 } 430 }
@@ -434,10 +432,8 @@ u32 acpi_ev_gpe_detect(struct acpi_gpe_xrupt_info * gpe_xrupt_list)
434 /* Read the Enable Register */ 432 /* Read the Enable Register */
435 433
436 status = 434 status =
437 acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH, 435 acpi_read(&enable_reg,
438 &enable_reg, 436 &gpe_register_info->enable_address);
439 &gpe_register_info->
440 enable_address);
441 if (ACPI_FAILURE(status)) { 437 if (ACPI_FAILURE(status)) {
442 goto unlock_and_exit; 438 goto unlock_and_exit;
443 } 439 }
@@ -527,8 +523,8 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
527 (void)acpi_ev_enable_gpe(gpe_event_info, FALSE); 523 (void)acpi_ev_enable_gpe(gpe_event_info, FALSE);
528 524
529 /* 525 /*
530 * Take a snapshot of the GPE info for this level - we copy the 526 * Take a snapshot of the GPE info for this level - we copy the info to
531 * info to prevent a race condition with remove_handler/remove_block. 527 * prevent a race condition with remove_handler/remove_block.
532 */ 528 */
533 ACPI_MEMCPY(&local_gpe_event_info, gpe_event_info, 529 ACPI_MEMCPY(&local_gpe_event_info, gpe_event_info,
534 sizeof(struct acpi_gpe_event_info)); 530 sizeof(struct acpi_gpe_event_info));
@@ -539,8 +535,8 @@ static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context)
539 } 535 }
540 536
541 /* 537 /*
542 * Must check for control method type dispatch one more 538 * Must check for control method type dispatch one more time to avoid a
543 * time to avoid race with ev_gpe_install_handler 539 * race with ev_gpe_install_handler
544 */ 540 */
545 if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) == 541 if ((local_gpe_event_info.flags & ACPI_GPE_DISPATCH_MASK) ==
546 ACPI_GPE_DISPATCH_METHOD) { 542 ACPI_GPE_DISPATCH_METHOD) {
@@ -584,8 +580,8 @@ static void acpi_ev_asynch_enable_gpe(void *context)
584 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == 580 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
585 ACPI_GPE_LEVEL_TRIGGERED) { 581 ACPI_GPE_LEVEL_TRIGGERED) {
586 /* 582 /*
587 * GPE is level-triggered, we clear the GPE status bit after 583 * GPE is level-triggered, we clear the GPE status bit after handling
588 * handling the event. 584 * the event.
589 */ 585 */
590 status = acpi_hw_clear_gpe(gpe_event_info); 586 status = acpi_hw_clear_gpe(gpe_event_info);
591 if (ACPI_FAILURE(status)) { 587 if (ACPI_FAILURE(status)) {
@@ -624,7 +620,7 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
624 acpi_os_gpe_count(gpe_number); 620 acpi_os_gpe_count(gpe_number);
625 621
626 /* 622 /*
627 * If edge-triggered, clear the GPE status bit now. Note that 623 * If edge-triggered, clear the GPE status bit now. Note that
628 * level-triggered events are cleared after the GPE is serviced. 624 * level-triggered events are cleared after the GPE is serviced.
629 */ 625 */
630 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) == 626 if ((gpe_event_info->flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
@@ -650,7 +646,8 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
650 646
651 /* 647 /*
652 * Invoke the installed handler (at interrupt level) 648 * Invoke the installed handler (at interrupt level)
653 * Ignore return status for now. TBD: leave GPE disabled on error? 649 * Ignore return status for now.
650 * TBD: leave GPE disabled on error?
654 */ 651 */
655 (void)gpe_event_info->dispatch.handler->address(gpe_event_info-> 652 (void)gpe_event_info->dispatch.handler->address(gpe_event_info->
656 dispatch. 653 dispatch.
@@ -708,7 +705,7 @@ acpi_ev_gpe_dispatch(struct acpi_gpe_event_info *gpe_event_info, u32 gpe_number)
708 gpe_number)); 705 gpe_number));
709 706
710 /* 707 /*
711 * Disable the GPE. The GPE will remain disabled until the ACPI 708 * Disable the GPE. The GPE will remain disabled until the ACPICA
712 * Core Subsystem is restarted, or a handler is installed. 709 * Core Subsystem is restarted, or a handler is installed.
713 */ 710 */
714 status = acpi_ev_disable_gpe(gpe_event_info); 711 status = acpi_ev_disable_gpe(gpe_event_info);
diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c
index 73c058e2f5c2..484cc0565d5b 100644
--- a/drivers/acpi/events/evgpeblk.c
+++ b/drivers/acpi/acpica/evgpeblk.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acevents.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acevents.h"
47#include "acnamesp.h"
47 48
48#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
49ACPI_MODULE_NAME("evgpeblk") 50ACPI_MODULE_NAME("evgpeblk")
@@ -124,6 +125,7 @@ u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info)
124 * FUNCTION: acpi_ev_walk_gpe_list 125 * FUNCTION: acpi_ev_walk_gpe_list
125 * 126 *
126 * PARAMETERS: gpe_walk_callback - Routine called for each GPE block 127 * PARAMETERS: gpe_walk_callback - Routine called for each GPE block
128 * Context - Value passed to callback
127 * 129 *
128 * RETURN: Status 130 * RETURN: Status
129 * 131 *
@@ -131,7 +133,8 @@ u8 acpi_ev_valid_gpe_event(struct acpi_gpe_event_info *gpe_event_info)
131 * 133 *
132 ******************************************************************************/ 134 ******************************************************************************/
133 135
134acpi_status acpi_ev_walk_gpe_list(acpi_gpe_callback gpe_walk_callback) 136acpi_status
137acpi_ev_walk_gpe_list(acpi_gpe_callback gpe_walk_callback, void *context)
135{ 138{
136 struct acpi_gpe_block_info *gpe_block; 139 struct acpi_gpe_block_info *gpe_block;
137 struct acpi_gpe_xrupt_info *gpe_xrupt_info; 140 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
@@ -154,8 +157,13 @@ acpi_status acpi_ev_walk_gpe_list(acpi_gpe_callback gpe_walk_callback)
154 157
155 /* One callback per GPE block */ 158 /* One callback per GPE block */
156 159
157 status = gpe_walk_callback(gpe_xrupt_info, gpe_block); 160 status =
161 gpe_walk_callback(gpe_xrupt_info, gpe_block,
162 context);
158 if (ACPI_FAILURE(status)) { 163 if (ACPI_FAILURE(status)) {
164 if (status == AE_CTRL_END) { /* Callback abort */
165 status = AE_OK;
166 }
159 goto unlock_and_exit; 167 goto unlock_and_exit;
160 } 168 }
161 169
@@ -186,7 +194,8 @@ acpi_status acpi_ev_walk_gpe_list(acpi_gpe_callback gpe_walk_callback)
186 194
187acpi_status 195acpi_status
188acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info, 196acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
189 struct acpi_gpe_block_info *gpe_block) 197 struct acpi_gpe_block_info *gpe_block,
198 void *context)
190{ 199{
191 struct acpi_gpe_event_info *gpe_event_info; 200 struct acpi_gpe_event_info *gpe_event_info;
192 u32 i; 201 u32 i;
@@ -309,17 +318,17 @@ acpi_ev_save_method_info(acpi_handle obj_handle,
309 (gpe_block->block_base_number + 318 (gpe_block->block_base_number +
310 (gpe_block->register_count * 8)))) { 319 (gpe_block->register_count * 8)))) {
311 /* 320 /*
312 * Not valid for this GPE block, just ignore it 321 * Not valid for this GPE block, just ignore it. However, it may be
313 * However, it may be valid for a different GPE block, since GPE0 and GPE1 322 * valid for a different GPE block, since GPE0 and GPE1 methods both
314 * methods both appear under \_GPE. 323 * appear under \_GPE.
315 */ 324 */
316 return_ACPI_STATUS(AE_OK); 325 return_ACPI_STATUS(AE_OK);
317 } 326 }
318 327
319 /* 328 /*
320 * Now we can add this information to the gpe_event_info block 329 * Now we can add this information to the gpe_event_info block for use
321 * for use during dispatch of this GPE. Default type is RUNTIME, although 330 * during dispatch of this GPE. Default type is RUNTIME, although this may
322 * this may change when the _PRW methods are executed later. 331 * change when the _PRW methods are executed later.
323 */ 332 */
324 gpe_event_info = 333 gpe_event_info =
325 &gpe_block->event_info[gpe_number - gpe_block->block_base_number]; 334 &gpe_block->event_info[gpe_number - gpe_block->block_base_number];
@@ -394,8 +403,8 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
394 gpe_block = gpe_info->gpe_block; 403 gpe_block = gpe_info->gpe_block;
395 404
396 /* 405 /*
397 * The _PRW object must return a package, we are only interested 406 * The _PRW object must return a package, we are only interested in the
398 * in the first element 407 * first element
399 */ 408 */
400 obj_desc = pkg_desc->package.elements[0]; 409 obj_desc = pkg_desc->package.elements[0];
401 410
@@ -434,7 +443,7 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
434 /* 443 /*
435 * Is this GPE within this block? 444 * Is this GPE within this block?
436 * 445 *
437 * TRUE iff these conditions are true: 446 * TRUE if and only if these conditions are true:
438 * 1) The GPE devices match. 447 * 1) The GPE devices match.
439 * 2) The GPE index(number) is within the range of the Gpe Block 448 * 2) The GPE index(number) is within the range of the Gpe Block
440 * associated with the GPE device. 449 * associated with the GPE device.
@@ -457,6 +466,7 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
457 if (ACPI_FAILURE(status)) { 466 if (ACPI_FAILURE(status)) {
458 goto cleanup; 467 goto cleanup;
459 } 468 }
469
460 status = 470 status =
461 acpi_ev_update_gpe_enable_masks(gpe_event_info, 471 acpi_ev_update_gpe_enable_masks(gpe_event_info,
462 ACPI_GPE_DISABLE); 472 ACPI_GPE_DISABLE);
@@ -476,9 +486,9 @@ acpi_ev_match_prw_and_gpe(acpi_handle obj_handle,
476 * RETURN: A GPE interrupt block 486 * RETURN: A GPE interrupt block
477 * 487 *
478 * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt 488 * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt
479 * block per unique interrupt level used for GPEs. 489 * block per unique interrupt level used for GPEs. Should be
480 * Should be called only when the GPE lists are semaphore locked 490 * called only when the GPE lists are semaphore locked and not
481 * and not subject to change. 491 * subject to change.
482 * 492 *
483 ******************************************************************************/ 493 ******************************************************************************/
484 494
@@ -608,8 +618,9 @@ acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt)
608 * 618 *
609 * FUNCTION: acpi_ev_install_gpe_block 619 * FUNCTION: acpi_ev_install_gpe_block
610 * 620 *
611 * PARAMETERS: gpe_block - New GPE block 621 * PARAMETERS: gpe_block - New GPE block
612 * interrupt_number - Xrupt to be associated with this GPE block 622 * interrupt_number - Xrupt to be associated with this
623 * GPE block
613 * 624 *
614 * RETURN: Status 625 * RETURN: Status
615 * 626 *
@@ -666,7 +677,7 @@ acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
666 * 677 *
667 * FUNCTION: acpi_ev_delete_gpe_block 678 * FUNCTION: acpi_ev_delete_gpe_block
668 * 679 *
669 * PARAMETERS: gpe_block - Existing GPE block 680 * PARAMETERS: gpe_block - Existing GPE block
670 * 681 *
671 * RETURN: Status 682 * RETURN: Status
672 * 683 *
@@ -688,7 +699,8 @@ acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block)
688 699
689 /* Disable all GPEs in this block */ 700 /* Disable all GPEs in this block */
690 701
691 status = acpi_hw_disable_gpe_block(gpe_block->xrupt_block, gpe_block); 702 status =
703 acpi_hw_disable_gpe_block(gpe_block->xrupt_block, gpe_block, NULL);
692 704
693 if (!gpe_block->previous && !gpe_block->next) { 705 if (!gpe_block->previous && !gpe_block->next) {
694 706
@@ -715,6 +727,9 @@ acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block)
715 acpi_os_release_lock(acpi_gbl_gpe_lock, flags); 727 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
716 } 728 }
717 729
730 acpi_current_gpe_count -=
731 gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH;
732
718 /* Free the gpe_block */ 733 /* Free the gpe_block */
719 734
720 ACPI_FREE(gpe_block->register_info); 735 ACPI_FREE(gpe_block->register_info);
@@ -786,9 +801,9 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
786 801
787 /* 802 /*
788 * Initialize the GPE Register and Event structures. A goal of these 803 * Initialize the GPE Register and Event structures. A goal of these
789 * tables is to hide the fact that there are two separate GPE register sets 804 * tables is to hide the fact that there are two separate GPE register
790 * in a given GPE hardware block, the status registers occupy the first half, 805 * sets in a given GPE hardware block, the status registers occupy the
791 * and the enable registers occupy the second half. 806 * first half, and the enable registers occupy the second half.
792 */ 807 */
793 this_register = gpe_register_info; 808 this_register = gpe_register_info;
794 this_event = gpe_event_info; 809 this_event = gpe_event_info;
@@ -816,10 +831,8 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
816 ACPI_GPE_REGISTER_WIDTH; 831 ACPI_GPE_REGISTER_WIDTH;
817 this_register->enable_address.bit_width = 832 this_register->enable_address.bit_width =
818 ACPI_GPE_REGISTER_WIDTH; 833 ACPI_GPE_REGISTER_WIDTH;
819 this_register->status_address.bit_offset = 834 this_register->status_address.bit_offset = 0;
820 ACPI_GPE_REGISTER_WIDTH; 835 this_register->enable_address.bit_offset = 0;
821 this_register->enable_address.bit_offset =
822 ACPI_GPE_REGISTER_WIDTH;
823 836
824 /* Init the event_info for each GPE within this register */ 837 /* Init the event_info for each GPE within this register */
825 838
@@ -832,18 +845,14 @@ acpi_ev_create_gpe_info_blocks(struct acpi_gpe_block_info *gpe_block)
832 845
833 /* Disable all GPEs within this register */ 846 /* Disable all GPEs within this register */
834 847
835 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0x00, 848 status = acpi_write(0x00, &this_register->enable_address);
836 &this_register->
837 enable_address);
838 if (ACPI_FAILURE(status)) { 849 if (ACPI_FAILURE(status)) {
839 goto error_exit; 850 goto error_exit;
840 } 851 }
841 852
842 /* Clear any pending GPE events within this register */ 853 /* Clear any pending GPE events within this register */
843 854
844 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, 0xFF, 855 status = acpi_write(0xFF, &this_register->status_address);
845 &this_register->
846 status_address);
847 if (ACPI_FAILURE(status)) { 856 if (ACPI_FAILURE(status)) {
848 goto error_exit; 857 goto error_exit;
849 } 858 }
@@ -956,6 +965,9 @@ acpi_ev_create_gpe_block(struct acpi_namespace_node *gpe_device,
956 gpe_device->name.ascii, gpe_block->register_count, 965 gpe_device->name.ascii, gpe_block->register_count,
957 interrupt_number)); 966 interrupt_number));
958 967
968 /* Update global count of currently available GPEs */
969
970 acpi_current_gpe_count += register_count * ACPI_GPE_REGISTER_WIDTH;
959 return_ACPI_STATUS(AE_OK); 971 return_ACPI_STATUS(AE_OK);
960} 972}
961 973
@@ -1055,7 +1067,7 @@ acpi_ev_initialize_gpe_block(struct acpi_namespace_node *gpe_device,
1055 1067
1056 /* Enable all valid runtime GPEs found above */ 1068 /* Enable all valid runtime GPEs found above */
1057 1069
1058 status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block); 1070 status = acpi_hw_enable_runtime_gpe_block(NULL, gpe_block, NULL);
1059 if (ACPI_FAILURE(status)) { 1071 if (ACPI_FAILURE(status)) {
1060 ACPI_ERROR((AE_INFO, "Could not enable GPEs in GpeBlock %p", 1072 ACPI_ERROR((AE_INFO, "Could not enable GPEs in GpeBlock %p",
1061 gpe_block)); 1073 gpe_block));
diff --git a/drivers/acpi/events/evmisc.c b/drivers/acpi/acpica/evmisc.c
index 1d5670be729a..5f893057bcc6 100644
--- a/drivers/acpi/events/evmisc.c
+++ b/drivers/acpi/acpica/evmisc.c
@@ -42,18 +42,15 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acevents.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acevents.h"
47#include <acpi/acinterp.h> 47#include "acnamesp.h"
48#include "acinterp.h"
48 49
49#define _COMPONENT ACPI_EVENTS 50#define _COMPONENT ACPI_EVENTS
50ACPI_MODULE_NAME("evmisc") 51ACPI_MODULE_NAME("evmisc")
51 52
52/* Pointer to FACS needed for the Global Lock */
53static struct acpi_table_facs *facs = NULL;
54
55/* Local prototypes */ 53/* Local prototypes */
56
57static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context); 54static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context);
58 55
59static u32 acpi_ev_global_lock_handler(void *context); 56static u32 acpi_ev_global_lock_handler(void *context);
@@ -152,7 +149,9 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node,
152 break; 149 break;
153 150
154 default: 151 default:
152
155 /* All other types are not supported */ 153 /* All other types are not supported */
154
156 return (AE_TYPE); 155 return (AE_TYPE);
157 } 156 }
158 } 157 }
@@ -193,9 +192,8 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node,
193 acpi_ut_delete_generic_state(notify_info); 192 acpi_ut_delete_generic_state(notify_info);
194 } 193 }
195 } else { 194 } else {
196 /* 195 /* There is no notify handler (per-device or system) for this device */
197 * There is no notify handler (per-device or system) for this device. 196
198 */
199 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 197 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
200 "No notify handler for Notify (%4.4s, %X) node %p\n", 198 "No notify handler for Notify (%4.4s, %X) node %p\n",
201 acpi_ut_get_node_name(node), notify_value, 199 acpi_ut_get_node_name(node), notify_value,
@@ -229,9 +227,8 @@ static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context)
229 ACPI_FUNCTION_ENTRY(); 227 ACPI_FUNCTION_ENTRY();
230 228
231 /* 229 /*
232 * We will invoke a global notify handler if installed. 230 * We will invoke a global notify handler if installed. This is done
233 * This is done _before_ we invoke the per-device handler attached 231 * _before_ we invoke the per-device handler attached to the device.
234 * to the device.
235 */ 232 */
236 if (notify_info->notify.value <= ACPI_MAX_SYS_NOTIFY) { 233 if (notify_info->notify.value <= ACPI_MAX_SYS_NOTIFY) {
237 234
@@ -299,7 +296,7 @@ static u32 acpi_ev_global_lock_handler(void *context)
299 * If we don't get it now, it will be marked pending and we will 296 * If we don't get it now, it will be marked pending and we will
300 * take another interrupt when it becomes free. 297 * take another interrupt when it becomes free.
301 */ 298 */
302 ACPI_ACQUIRE_GLOBAL_LOCK(facs, acquired); 299 ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_FACS, acquired);
303 if (acquired) { 300 if (acquired) {
304 301
305 /* Got the lock, now wake all threads waiting for it */ 302 /* Got the lock, now wake all threads waiting for it */
@@ -336,34 +333,27 @@ acpi_status acpi_ev_init_global_lock_handler(void)
336 333
337 ACPI_FUNCTION_TRACE(ev_init_global_lock_handler); 334 ACPI_FUNCTION_TRACE(ev_init_global_lock_handler);
338 335
339 status = acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS, 336 /* Attempt installation of the global lock handler */
340 ACPI_CAST_INDIRECT_PTR(struct
341 acpi_table_header,
342 &facs));
343 if (ACPI_FAILURE(status)) {
344 return_ACPI_STATUS(status);
345 }
346 337
347 acpi_gbl_global_lock_present = TRUE;
348 status = acpi_install_fixed_event_handler(ACPI_EVENT_GLOBAL, 338 status = acpi_install_fixed_event_handler(ACPI_EVENT_GLOBAL,
349 acpi_ev_global_lock_handler, 339 acpi_ev_global_lock_handler,
350 NULL); 340 NULL);
351 341
352 /* 342 /*
353 * If the global lock does not exist on this platform, the attempt 343 * If the global lock does not exist on this platform, the attempt to
354 * to enable GBL_STATUS will fail (the GBL_ENABLE bit will not stick) 344 * enable GBL_STATUS will fail (the GBL_ENABLE bit will not stick).
355 * Map to AE_OK, but mark global lock as not present. 345 * Map to AE_OK, but mark global lock as not present. Any attempt to
356 * Any attempt to actually use the global lock will be flagged 346 * actually use the global lock will be flagged with an error.
357 * with an error.
358 */ 347 */
359 if (status == AE_NO_HARDWARE_RESPONSE) { 348 if (status == AE_NO_HARDWARE_RESPONSE) {
360 ACPI_ERROR((AE_INFO, 349 ACPI_ERROR((AE_INFO,
361 "No response from Global Lock hardware, disabling lock")); 350 "No response from Global Lock hardware, disabling lock"));
362 351
363 acpi_gbl_global_lock_present = FALSE; 352 acpi_gbl_global_lock_present = FALSE;
364 status = AE_OK; 353 return_ACPI_STATUS(AE_OK);
365 } 354 }
366 355
356 acpi_gbl_global_lock_present = TRUE;
367 return_ACPI_STATUS(status); 357 return_ACPI_STATUS(status);
368} 358}
369 359
@@ -462,8 +452,8 @@ acpi_status acpi_ev_acquire_global_lock(u16 timeout)
462 } 452 }
463 453
464 /* 454 /*
465 * Make sure that a global lock actually exists. If not, just treat 455 * Make sure that a global lock actually exists. If not, just treat the
466 * the lock as a standard mutex. 456 * lock as a standard mutex.
467 */ 457 */
468 if (!acpi_gbl_global_lock_present) { 458 if (!acpi_gbl_global_lock_present) {
469 acpi_gbl_global_lock_acquired = TRUE; 459 acpi_gbl_global_lock_acquired = TRUE;
@@ -472,7 +462,7 @@ acpi_status acpi_ev_acquire_global_lock(u16 timeout)
472 462
473 /* Attempt to acquire the actual hardware lock */ 463 /* Attempt to acquire the actual hardware lock */
474 464
475 ACPI_ACQUIRE_GLOBAL_LOCK(facs, acquired); 465 ACPI_ACQUIRE_GLOBAL_LOCK(acpi_gbl_FACS, acquired);
476 if (acquired) { 466 if (acquired) {
477 467
478 /* We got the lock */ 468 /* We got the lock */
@@ -536,7 +526,7 @@ acpi_status acpi_ev_release_global_lock(void)
536 526
537 /* Allow any thread to release the lock */ 527 /* Allow any thread to release the lock */
538 528
539 ACPI_RELEASE_GLOBAL_LOCK(facs, pending); 529 ACPI_RELEASE_GLOBAL_LOCK(acpi_gbl_FACS, pending);
540 530
541 /* 531 /*
542 * If the pending bit was set, we must write GBL_RLS to the control 532 * If the pending bit was set, we must write GBL_RLS to the control
@@ -582,8 +572,8 @@ void acpi_ev_terminate(void)
582 572
583 if (acpi_gbl_events_initialized) { 573 if (acpi_gbl_events_initialized) {
584 /* 574 /*
585 * Disable all event-related functionality. 575 * Disable all event-related functionality. In all cases, on error,
586 * In all cases, on error, print a message but obviously we don't abort. 576 * print a message but obviously we don't abort.
587 */ 577 */
588 578
589 /* Disable all fixed events */ 579 /* Disable all fixed events */
@@ -599,7 +589,7 @@ void acpi_ev_terminate(void)
599 589
600 /* Disable all GPEs in all GPE blocks */ 590 /* Disable all GPEs in all GPE blocks */
601 591
602 status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block); 592 status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block, NULL);
603 593
604 /* Remove SCI handler */ 594 /* Remove SCI handler */
605 595
@@ -617,7 +607,7 @@ void acpi_ev_terminate(void)
617 607
618 /* Deallocate all handler objects installed within GPE info structs */ 608 /* Deallocate all handler objects installed within GPE info structs */
619 609
620 status = acpi_ev_walk_gpe_list(acpi_ev_delete_gpe_handlers); 610 status = acpi_ev_walk_gpe_list(acpi_ev_delete_gpe_handlers, NULL);
621 611
622 /* Return to original mode if necessary */ 612 /* Return to original mode if necessary */
623 613
diff --git a/drivers/acpi/events/evregion.c b/drivers/acpi/acpica/evregion.c
index 236fbd1ca438..665c0887ab4d 100644
--- a/drivers/acpi/events/evregion.c
+++ b/drivers/acpi/acpica/evregion.c
@@ -42,22 +42,15 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acevents.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acevents.h"
47#include <acpi/acinterp.h> 47#include "acnamesp.h"
48#include "acinterp.h"
48 49
49#define _COMPONENT ACPI_EVENTS 50#define _COMPONENT ACPI_EVENTS
50ACPI_MODULE_NAME("evregion") 51ACPI_MODULE_NAME("evregion")
51#define ACPI_NUM_DEFAULT_SPACES 4
52static u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = {
53 ACPI_ADR_SPACE_SYSTEM_MEMORY,
54 ACPI_ADR_SPACE_SYSTEM_IO,
55 ACPI_ADR_SPACE_PCI_CONFIG,
56 ACPI_ADR_SPACE_DATA_TABLE
57};
58 52
59/* Local prototypes */ 53/* Local prototypes */
60
61static acpi_status 54static acpi_status
62acpi_ev_reg_run(acpi_handle obj_handle, 55acpi_ev_reg_run(acpi_handle obj_handle,
63 u32 level, void *context, void **return_value); 56 u32 level, void *context, void **return_value);
@@ -66,6 +59,17 @@ static acpi_status
66acpi_ev_install_handler(acpi_handle obj_handle, 59acpi_ev_install_handler(acpi_handle obj_handle,
67 u32 level, void *context, void **return_value); 60 u32 level, void *context, void **return_value);
68 61
62/* These are the address spaces that will get default handlers */
63
64#define ACPI_NUM_DEFAULT_SPACES 4
65
66static u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = {
67 ACPI_ADR_SPACE_SYSTEM_MEMORY,
68 ACPI_ADR_SPACE_SYSTEM_IO,
69 ACPI_ADR_SPACE_PCI_CONFIG,
70 ACPI_ADR_SPACE_DATA_TABLE
71};
72
69/******************************************************************************* 73/*******************************************************************************
70 * 74 *
71 * FUNCTION: acpi_ev_install_region_handlers 75 * FUNCTION: acpi_ev_install_region_handlers
@@ -91,18 +95,19 @@ acpi_status acpi_ev_install_region_handlers(void)
91 } 95 }
92 96
93 /* 97 /*
94 * All address spaces (PCI Config, EC, SMBus) are scope dependent 98 * All address spaces (PCI Config, EC, SMBus) are scope dependent and
95 * and registration must occur for a specific device. 99 * registration must occur for a specific device.
96 * 100 *
97 * In the case of the system memory and IO address spaces there is currently 101 * In the case of the system memory and IO address spaces there is
98 * no device associated with the address space. For these we use the root. 102 * currently no device associated with the address space. For these we
103 * use the root.
99 * 104 *
100 * We install the default PCI config space handler at the root so 105 * We install the default PCI config space handler at the root so that
101 * that this space is immediately available even though the we have 106 * this space is immediately available even though the we have not
102 * not enumerated all the PCI Root Buses yet. This is to conform 107 * enumerated all the PCI Root Buses yet. This is to conform to the ACPI
103 * to the ACPI specification which states that the PCI config 108 * specification which states that the PCI config space must be always
104 * space must be always available -- even though we are nowhere 109 * available -- even though we are nowhere near ready to find the PCI root
105 * near ready to find the PCI root buses at this point. 110 * buses at this point.
106 * 111 *
107 * NOTE: We ignore AE_ALREADY_EXISTS because this means that a handler 112 * NOTE: We ignore AE_ALREADY_EXISTS because this means that a handler
108 * has already been installed (via acpi_install_address_space_handler). 113 * has already been installed (via acpi_install_address_space_handler).
@@ -160,12 +165,11 @@ acpi_status acpi_ev_initialize_op_regions(void)
160 return_ACPI_STATUS(status); 165 return_ACPI_STATUS(status);
161 } 166 }
162 167
163 /* 168 /* Run the _REG methods for op_regions in each default address space */
164 * Run the _REG methods for op_regions in each default address space
165 */
166 for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) {
167 169
168 /* TBD: Make sure handler is the DEFAULT handler, otherwise 170 for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) {
171 /*
172 * TBD: Make sure handler is the DEFAULT handler, otherwise
169 * _REG will have already been run. 173 * _REG will have already been run.
170 */ 174 */
171 status = acpi_ev_execute_reg_methods(acpi_gbl_root_node, 175 status = acpi_ev_execute_reg_methods(acpi_gbl_root_node,
@@ -318,13 +322,13 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
318 } 322 }
319 323
320 /* 324 /*
321 * It may be the case that the region has never been initialized 325 * It may be the case that the region has never been initialized.
322 * Some types of regions require special init code 326 * Some types of regions require special init code
323 */ 327 */
324 if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE)) { 328 if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE)) {
325 /* 329
326 * This region has not been initialized yet, do it 330 /* This region has not been initialized yet, do it */
327 */ 331
328 region_setup = handler_desc->address_space.setup; 332 region_setup = handler_desc->address_space.setup;
329 if (!region_setup) { 333 if (!region_setup) {
330 334
@@ -339,9 +343,9 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
339 } 343 }
340 344
341 /* 345 /*
342 * We must exit the interpreter because the region 346 * We must exit the interpreter because the region setup will
343 * setup will potentially execute control methods 347 * potentially execute control methods (for example, the _REG method
344 * (e.g., _REG method for this region) 348 * for this region)
345 */ 349 */
346 acpi_ex_exit_interpreter(); 350 acpi_ex_exit_interpreter();
347 351
@@ -364,9 +368,8 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
364 return_ACPI_STATUS(status); 368 return_ACPI_STATUS(status);
365 } 369 }
366 370
367 /* 371 /* Region initialization may have been completed by region_setup */
368 * Region initialization may have been completed by region_setup 372
369 */
370 if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE)) { 373 if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE)) {
371 region_obj->region.flags |= AOPOBJ_SETUP_COMPLETE; 374 region_obj->region.flags |= AOPOBJ_SETUP_COMPLETE;
372 375
@@ -521,8 +524,8 @@ acpi_ev_detach_region(union acpi_operand_object *region_obj,
521 } 524 }
522 525
523 /* 526 /*
524 * If the region has been activated, call the setup handler 527 * If the region has been activated, call the setup handler with
525 * with the deactivate notification 528 * the deactivate notification
526 */ 529 */
527 if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) { 530 if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) {
528 region_setup = handler_obj->address_space.setup; 531 region_setup = handler_obj->address_space.setup;
@@ -668,8 +671,8 @@ acpi_ev_install_handler(acpi_handle obj_handle,
668 } 671 }
669 672
670 /* 673 /*
671 * We only care about regions.and objects 674 * We only care about regions and objects that are allowed to have
672 * that are allowed to have address space handlers 675 * address space handlers
673 */ 676 */
674 if ((node->type != ACPI_TYPE_DEVICE) && 677 if ((node->type != ACPI_TYPE_DEVICE) &&
675 (node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) { 678 (node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) {
@@ -710,9 +713,9 @@ acpi_ev_install_handler(acpi_handle obj_handle,
710 /* 713 /*
711 * Since the object we found it on was a device, then it 714 * Since the object we found it on was a device, then it
712 * means that someone has already installed a handler for 715 * means that someone has already installed a handler for
713 * the branch of the namespace from this device on. Just 716 * the branch of the namespace from this device on. Just
714 * bail out telling the walk routine to not traverse this 717 * bail out telling the walk routine to not traverse this
715 * branch. This preserves the scoping rule for handlers. 718 * branch. This preserves the scoping rule for handlers.
716 */ 719 */
717 return (AE_CTRL_DEPTH); 720 return (AE_CTRL_DEPTH);
718 } 721 }
@@ -723,9 +726,8 @@ acpi_ev_install_handler(acpi_handle obj_handle,
723 } 726 }
724 727
725 /* 728 /*
726 * As long as the device didn't have a handler for this 729 * As long as the device didn't have a handler for this space we
727 * space we don't care about it. We just ignore it and 730 * don't care about it. We just ignore it and proceed.
728 * proceed.
729 */ 731 */
730 return (AE_OK); 732 return (AE_OK);
731 } 733 }
@@ -733,16 +735,14 @@ acpi_ev_install_handler(acpi_handle obj_handle,
733 /* Object is a Region */ 735 /* Object is a Region */
734 736
735 if (obj_desc->region.space_id != handler_obj->address_space.space_id) { 737 if (obj_desc->region.space_id != handler_obj->address_space.space_id) {
736 /* 738
737 * This region is for a different address space 739 /* This region is for a different address space, just ignore it */
738 * -- just ignore it 740
739 */
740 return (AE_OK); 741 return (AE_OK);
741 } 742 }
742 743
743 /* 744 /*
744 * Now we have a region and it is for the handler's address 745 * Now we have a region and it is for the handler's address space type.
745 * space type.
746 * 746 *
747 * First disconnect region for any previous handler (if any) 747 * First disconnect region for any previous handler (if any)
748 */ 748 */
@@ -786,9 +786,8 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node,
786 ACPI_FUNCTION_TRACE(ev_install_space_handler); 786 ACPI_FUNCTION_TRACE(ev_install_space_handler);
787 787
788 /* 788 /*
789 * This registration is valid for only the types below 789 * This registration is valid for only the types below and the root. This
790 * and the root. This is where the default handlers 790 * is where the default handlers get placed.
791 * get placed.
792 */ 791 */
793 if ((node->type != ACPI_TYPE_DEVICE) && 792 if ((node->type != ACPI_TYPE_DEVICE) &&
794 (node->type != ACPI_TYPE_PROCESSOR) && 793 (node->type != ACPI_TYPE_PROCESSOR) &&
@@ -848,8 +847,8 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node,
848 obj_desc = acpi_ns_get_attached_object(node); 847 obj_desc = acpi_ns_get_attached_object(node);
849 if (obj_desc) { 848 if (obj_desc) {
850 /* 849 /*
851 * The attached device object already exists. 850 * The attached device object already exists. Make sure the handler
852 * Make sure the handler is not already installed. 851 * is not already installed.
853 */ 852 */
854 handler_obj = obj_desc->device.handler; 853 handler_obj = obj_desc->device.handler;
855 854
@@ -864,8 +863,8 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node,
864 handler) { 863 handler) {
865 /* 864 /*
866 * It is (relatively) OK to attempt to install the SAME 865 * It is (relatively) OK to attempt to install the SAME
867 * handler twice. This can easily happen 866 * handler twice. This can easily happen with the
868 * with PCI_Config space. 867 * PCI_Config space.
869 */ 868 */
870 status = AE_SAME_HANDLER; 869 status = AE_SAME_HANDLER;
871 goto unlock_and_exit; 870 goto unlock_and_exit;
@@ -925,9 +924,8 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node,
925 /* 924 /*
926 * Install the handler 925 * Install the handler
927 * 926 *
928 * At this point there is no existing handler. 927 * At this point there is no existing handler. Just allocate the object
929 * Just allocate the object for the handler and link it 928 * for the handler and link it into the list.
930 * into the list.
931 */ 929 */
932 handler_obj = 930 handler_obj =
933 acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_ADDRESS_HANDLER); 931 acpi_ut_create_internal_object(ACPI_TYPE_LOCAL_ADDRESS_HANDLER);
@@ -1000,11 +998,10 @@ acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
1000 ACPI_FUNCTION_TRACE(ev_execute_reg_methods); 998 ACPI_FUNCTION_TRACE(ev_execute_reg_methods);
1001 999
1002 /* 1000 /*
1003 * Run all _REG methods for all Operation Regions for this 1001 * Run all _REG methods for all Operation Regions for this space ID. This
1004 * space ID. This is a separate walk in order to handle any 1002 * is a separate walk in order to handle any interdependencies between
1005 * interdependencies between regions and _REG methods. (i.e. handlers 1003 * regions and _REG methods. (i.e. handlers must be installed for all
1006 * must be installed for all regions of this Space ID before we 1004 * regions of this Space ID before we can run any _REG methods)
1007 * can run any _REG methods)
1008 */ 1005 */
1009 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX, 1006 status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX,
1010 ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run, 1007 ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run,
@@ -1042,8 +1039,8 @@ acpi_ev_reg_run(acpi_handle obj_handle,
1042 } 1039 }
1043 1040
1044 /* 1041 /*
1045 * We only care about regions.and objects 1042 * We only care about regions.and objects that are allowed to have address
1046 * that are allowed to have address space handlers 1043 * space handlers
1047 */ 1044 */
1048 if ((node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) { 1045 if ((node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) {
1049 return (AE_OK); 1046 return (AE_OK);
@@ -1062,10 +1059,9 @@ acpi_ev_reg_run(acpi_handle obj_handle,
1062 /* Object is a Region */ 1059 /* Object is a Region */
1063 1060
1064 if (obj_desc->region.space_id != space_id) { 1061 if (obj_desc->region.space_id != space_id) {
1065 /* 1062
1066 * This region is for a different address space 1063 /* This region is for a different address space, just ignore it */
1067 * -- just ignore it 1064
1068 */
1069 return (AE_OK); 1065 return (AE_OK);
1070 } 1066 }
1071 1067
diff --git a/drivers/acpi/events/evrgnini.c b/drivers/acpi/acpica/evrgnini.c
index 6b94b38df07d..f3f1fb45c3dc 100644
--- a/drivers/acpi/events/evrgnini.c
+++ b/drivers/acpi/acpica/evrgnini.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acevents.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acevents.h"
47#include "acnamesp.h"
47 48
48#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
49ACPI_MODULE_NAME("evrgnini") 50ACPI_MODULE_NAME("evrgnini")
@@ -233,9 +234,9 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
233 if (ACPI_FAILURE(status)) { 234 if (ACPI_FAILURE(status)) {
234 if (status == AE_SAME_HANDLER) { 235 if (status == AE_SAME_HANDLER) {
235 /* 236 /*
236 * It is OK if the handler is already installed on the root 237 * It is OK if the handler is already installed on the
237 * bridge. Still need to return a context object for the 238 * root bridge. Still need to return a context object
238 * new PCI_Config operation region, however. 239 * for the new PCI_Config operation region, however.
239 */ 240 */
240 status = AE_OK; 241 status = AE_OK;
241 } else { 242 } else {
@@ -272,8 +273,8 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
272 } 273 }
273 274
274 /* 275 /*
275 * For PCI_Config space access, we need the segment, bus, 276 * For PCI_Config space access, we need the segment, bus, device and
276 * device and function numbers. Acquire them here. 277 * function numbers. Acquire them here.
277 * 278 *
278 * Find the parent device object. (This allows the operation region to be 279 * Find the parent device object. (This allows the operation region to be
279 * within a subscope under the device, such as a control method.) 280 * within a subscope under the device, such as a control method.)
@@ -289,16 +290,16 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
289 } 290 }
290 291
291 /* 292 /*
292 * Get the PCI device and function numbers from the _ADR object 293 * Get the PCI device and function numbers from the _ADR object contained
293 * contained in the parent's scope. 294 * in the parent's scope.
294 */ 295 */
295 status = 296 status =
296 acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, pci_device_node, 297 acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, pci_device_node,
297 &pci_value); 298 &pci_value);
298 299
299 /* 300 /*
300 * The default is zero, and since the allocation above zeroed 301 * The default is zero, and since the allocation above zeroed the data,
301 * the data, just do nothing on failure. 302 * just do nothing on failure.
302 */ 303 */
303 if (ACPI_SUCCESS(status)) { 304 if (ACPI_SUCCESS(status)) {
304 pci_id->device = ACPI_HIWORD(ACPI_LODWORD(pci_value)); 305 pci_id->device = ACPI_HIWORD(ACPI_LODWORD(pci_value));
@@ -382,9 +383,8 @@ static u8 acpi_ev_is_pci_root_bridge(struct acpi_namespace_node *node)
382 struct acpi_compatible_id_list *cid; 383 struct acpi_compatible_id_list *cid;
383 u32 i; 384 u32 i;
384 385
385 /* 386 /* Get the _HID and check for a PCI Root Bridge */
386 * Get the _HID and check for a PCI Root Bridge 387
387 */
388 status = acpi_ut_execute_HID(node, &hid); 388 status = acpi_ut_execute_HID(node, &hid);
389 if (ACPI_FAILURE(status)) { 389 if (ACPI_FAILURE(status)) {
390 return (FALSE); 390 return (FALSE);
@@ -394,10 +394,8 @@ static u8 acpi_ev_is_pci_root_bridge(struct acpi_namespace_node *node)
394 return (TRUE); 394 return (TRUE);
395 } 395 }
396 396
397 /* 397 /* The _HID did not match. Get the _CID and check for a PCI Root Bridge */
398 * The _HID did not match. 398
399 * Get the _CID and check for a PCI Root Bridge
400 */
401 status = acpi_ut_execute_CID(node, &cid); 399 status = acpi_ut_execute_CID(node, &cid);
402 if (ACPI_FAILURE(status)) { 400 if (ACPI_FAILURE(status)) {
403 return (FALSE); 401 return (FALSE);
@@ -516,9 +514,9 @@ acpi_ev_default_region_setup(acpi_handle handle,
516 * Get the appropriate address space handler for a newly 514 * Get the appropriate address space handler for a newly
517 * created region. 515 * created region.
518 * 516 *
519 * This also performs address space specific initialization. For 517 * This also performs address space specific initialization. For
520 * example, PCI regions must have an _ADR object that contains 518 * example, PCI regions must have an _ADR object that contains
521 * a PCI address in the scope of the definition. This address is 519 * a PCI address in the scope of the definition. This address is
522 * required to perform an access to PCI config space. 520 * required to perform an access to PCI config space.
523 * 521 *
524 * MUTEX: Interpreter should be unlocked, because we may run the _REG 522 * MUTEX: Interpreter should be unlocked, because we may run the _REG
@@ -572,7 +570,7 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj,
572 if (ACPI_SUCCESS(status)) { 570 if (ACPI_SUCCESS(status)) {
573 /* 571 /*
574 * The _REG method is optional and there can be only one per region 572 * The _REG method is optional and there can be only one per region
575 * definition. This will be executed when the handler is attached 573 * definition. This will be executed when the handler is attached
576 * or removed 574 * or removed
577 */ 575 */
578 region_obj2->extra.method_REG = method_node; 576 region_obj2->extra.method_REG = method_node;
@@ -670,10 +668,8 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj,
670 } 668 }
671 } 669 }
672 670
673 /* 671 /* This node does not have the handler we need; Pop up one level */
674 * This node does not have the handler we need; 672
675 * Pop up one level
676 */
677 node = acpi_ns_get_parent_node(node); 673 node = acpi_ns_get_parent_node(node);
678 } 674 }
679 675
diff --git a/drivers/acpi/events/evsci.c b/drivers/acpi/acpica/evsci.c
index 2a8b77877610..567b356c85af 100644
--- a/drivers/acpi/events/evsci.c
+++ b/drivers/acpi/acpica/evsci.c
@@ -43,7 +43,8 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acevents.h> 46#include "accommon.h"
47#include "acevents.h"
47 48
48#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
49ACPI_MODULE_NAME("evsci") 50ACPI_MODULE_NAME("evsci")
@@ -115,10 +116,8 @@ u32 ACPI_SYSTEM_XFACE acpi_ev_gpe_xrupt_handler(void *context)
115 * if this interrupt handler is installed, ACPI is enabled. 116 * if this interrupt handler is installed, ACPI is enabled.
116 */ 117 */
117 118
118 /* 119 /* GPEs: Check for and dispatch any GPEs that have occurred */
119 * GPEs: 120
120 * Check for and dispatch any GPEs that have occurred
121 */
122 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); 121 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);
123 122
124 return_UINT32(interrupt_handled); 123 return_UINT32(interrupt_handled);
@@ -158,11 +157,11 @@ u32 acpi_ev_install_sci_handler(void)
158 * RETURN: E_OK if handler uninstalled OK, E_ERROR if handler was not 157 * RETURN: E_OK if handler uninstalled OK, E_ERROR if handler was not
159 * installed to begin with 158 * installed to begin with
160 * 159 *
161 * DESCRIPTION: Remove the SCI interrupt handler. No further SCIs will be 160 * DESCRIPTION: Remove the SCI interrupt handler. No further SCIs will be
162 * taken. 161 * taken.
163 * 162 *
164 * Note: It doesn't seem important to disable all events or set the event 163 * Note: It doesn't seem important to disable all events or set the event
165 * enable registers to their original values. The OS should disable 164 * enable registers to their original values. The OS should disable
166 * the SCI interrupt level when the handler is removed, so no more 165 * the SCI interrupt level when the handler is removed, so no more
167 * events will come in. 166 * events will come in.
168 * 167 *
diff --git a/drivers/acpi/events/evxface.c b/drivers/acpi/acpica/evxface.c
index 94a6efe020be..3aca9010a11e 100644
--- a/drivers/acpi/events/evxface.c
+++ b/drivers/acpi/acpica/evxface.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include <acpi/acevents.h> 46#include "acnamesp.h"
47#include <acpi/acinterp.h> 47#include "acevents.h"
48#include "acinterp.h"
48 49
49#define _COMPONENT ACPI_EVENTS 50#define _COMPONENT ACPI_EVENTS
50ACPI_MODULE_NAME("evxface") 51ACPI_MODULE_NAME("evxface")
@@ -267,7 +268,7 @@ acpi_install_notify_handler(acpi_handle device,
267 /* 268 /*
268 * Root Object: 269 * Root Object:
269 * Registering a notify handler on the root object indicates that the 270 * Registering a notify handler on the root object indicates that the
270 * caller wishes to receive notifications for all objects. Note that 271 * caller wishes to receive notifications for all objects. Note that
271 * only one <external> global handler can be regsitered (per notify type). 272 * only one <external> global handler can be regsitered (per notify type).
272 */ 273 */
273 if (device == ACPI_ROOT_OBJECT) { 274 if (device == ACPI_ROOT_OBJECT) {
diff --git a/drivers/acpi/events/evxfevnt.c b/drivers/acpi/acpica/evxfevnt.c
index 41554f736b68..35485e4b60a6 100644
--- a/drivers/acpi/events/evxfevnt.c
+++ b/drivers/acpi/acpica/evxfevnt.c
@@ -42,13 +42,19 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acevents.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acevents.h"
47#include <acpi/actables.h> 47#include "acnamesp.h"
48#include "actables.h"
48 49
49#define _COMPONENT ACPI_EVENTS 50#define _COMPONENT ACPI_EVENTS
50ACPI_MODULE_NAME("evxfevnt") 51ACPI_MODULE_NAME("evxfevnt")
51 52
53/* Local prototypes */
54acpi_status
55acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
56 struct acpi_gpe_block_info *gpe_block, void *context);
57
52/******************************************************************************* 58/*******************************************************************************
53 * 59 *
54 * FUNCTION: acpi_enable 60 * FUNCTION: acpi_enable
@@ -60,6 +66,7 @@ ACPI_MODULE_NAME("evxfevnt")
60 * DESCRIPTION: Transfers the system into ACPI mode. 66 * DESCRIPTION: Transfers the system into ACPI mode.
61 * 67 *
62 ******************************************************************************/ 68 ******************************************************************************/
69
63acpi_status acpi_enable(void) 70acpi_status acpi_enable(void)
64{ 71{
65 acpi_status status = AE_OK; 72 acpi_status status = AE_OK;
@@ -161,8 +168,8 @@ acpi_status acpi_enable_event(u32 event, u32 flags)
161 } 168 }
162 169
163 /* 170 /*
164 * Enable the requested fixed event (by writing a one to the 171 * Enable the requested fixed event (by writing a one to the enable
165 * enable register bit) 172 * register bit)
166 */ 173 */
167 status = 174 status =
168 acpi_set_register(acpi_gbl_fixed_event_info[event]. 175 acpi_set_register(acpi_gbl_fixed_event_info[event].
@@ -343,8 +350,8 @@ acpi_status acpi_disable_event(u32 event, u32 flags)
343 } 350 }
344 351
345 /* 352 /*
346 * Disable the requested fixed event (by writing a zero to the 353 * Disable the requested fixed event (by writing a zero to the enable
347 * enable register bit) 354 * register bit)
348 */ 355 */
349 status = 356 status =
350 acpi_set_register(acpi_gbl_fixed_event_info[event]. 357 acpi_set_register(acpi_gbl_fixed_event_info[event].
@@ -396,8 +403,8 @@ acpi_status acpi_clear_event(u32 event)
396 } 403 }
397 404
398 /* 405 /*
399 * Clear the requested fixed event (By writing a one to the 406 * Clear the requested fixed event (By writing a one to the status
400 * status register bit) 407 * register bit)
401 */ 408 */
402 status = 409 status =
403 acpi_set_register(acpi_gbl_fixed_event_info[event]. 410 acpi_set_register(acpi_gbl_fixed_event_info[event].
@@ -717,3 +724,148 @@ acpi_status acpi_remove_gpe_block(acpi_handle gpe_device)
717} 724}
718 725
719ACPI_EXPORT_SYMBOL(acpi_remove_gpe_block) 726ACPI_EXPORT_SYMBOL(acpi_remove_gpe_block)
727
728/*******************************************************************************
729 *
730 * FUNCTION: acpi_get_gpe_device
731 *
732 * PARAMETERS: Index - System GPE index (0-current_gpe_count)
733 * gpe_device - Where the parent GPE Device is returned
734 *
735 * RETURN: Status
736 *
737 * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
738 * gpe device indicates that the gpe number is contained in one of
739 * the FADT-defined gpe blocks. Otherwise, the GPE block device.
740 *
741 ******************************************************************************/
742acpi_status
743acpi_get_gpe_device(u32 index, acpi_handle *gpe_device)
744{
745 struct acpi_gpe_device_info info;
746 acpi_status status;
747
748 ACPI_FUNCTION_TRACE(acpi_get_gpe_device);
749
750 if (!gpe_device) {
751 return_ACPI_STATUS(AE_BAD_PARAMETER);
752 }
753
754 if (index >= acpi_current_gpe_count) {
755 return_ACPI_STATUS(AE_NOT_EXIST);
756 }
757
758 /* Setup and walk the GPE list */
759
760 info.index = index;
761 info.status = AE_NOT_EXIST;
762 info.gpe_device = NULL;
763 info.next_block_base_index = 0;
764
765 status = acpi_ev_walk_gpe_list(acpi_ev_get_gpe_device, &info);
766 if (ACPI_FAILURE(status)) {
767 return_ACPI_STATUS(status);
768 }
769
770 *gpe_device = info.gpe_device;
771 return_ACPI_STATUS(info.status);
772}
773
774ACPI_EXPORT_SYMBOL(acpi_get_gpe_device)
775
776/*******************************************************************************
777 *
778 * FUNCTION: acpi_ev_get_gpe_device
779 *
780 * PARAMETERS: GPE_WALK_CALLBACK
781 *
782 * RETURN: Status
783 *
784 * DESCRIPTION: Matches the input GPE index (0-current_gpe_count) with a GPE
785 * block device. NULL if the GPE is one of the FADT-defined GPEs.
786 *
787 ******************************************************************************/
788acpi_status
789acpi_ev_get_gpe_device(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
790 struct acpi_gpe_block_info *gpe_block, void *context)
791{
792 struct acpi_gpe_device_info *info = context;
793
794 /* Increment Index by the number of GPEs in this block */
795
796 info->next_block_base_index +=
797 (gpe_block->register_count * ACPI_GPE_REGISTER_WIDTH);
798
799 if (info->index < info->next_block_base_index) {
800 /*
801 * The GPE index is within this block, get the node. Leave the node
802 * NULL for the FADT-defined GPEs
803 */
804 if ((gpe_block->node)->type == ACPI_TYPE_DEVICE) {
805 info->gpe_device = gpe_block->node;
806 }
807
808 info->status = AE_OK;
809 return (AE_CTRL_END);
810 }
811
812 return (AE_OK);
813}
814
815/******************************************************************************
816 *
817 * FUNCTION: acpi_disable_all_gpes
818 *
819 * PARAMETERS: None
820 *
821 * RETURN: Status
822 *
823 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
824 *
825 ******************************************************************************/
826
827acpi_status acpi_disable_all_gpes(void)
828{
829 acpi_status status;
830
831 ACPI_FUNCTION_TRACE(acpi_disable_all_gpes);
832
833 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
834 if (ACPI_FAILURE(status)) {
835 return_ACPI_STATUS(status);
836 }
837
838 status = acpi_hw_disable_all_gpes();
839 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
840
841 return_ACPI_STATUS(status);
842}
843
844/******************************************************************************
845 *
846 * FUNCTION: acpi_enable_all_runtime_gpes
847 *
848 * PARAMETERS: None
849 *
850 * RETURN: Status
851 *
852 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
853 *
854 ******************************************************************************/
855
856acpi_status acpi_enable_all_runtime_gpes(void)
857{
858 acpi_status status;
859
860 ACPI_FUNCTION_TRACE(acpi_enable_all_runtime_gpes);
861
862 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
863 if (ACPI_FAILURE(status)) {
864 return_ACPI_STATUS(status);
865 }
866
867 status = acpi_hw_enable_all_runtime_gpes();
868 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
869
870 return_ACPI_STATUS(status);
871}
diff --git a/drivers/acpi/events/evxfregn.c b/drivers/acpi/acpica/evxfregn.c
index e8750807e57d..479e7a3721be 100644
--- a/drivers/acpi/events/evxfregn.c
+++ b/drivers/acpi/acpica/evxfregn.c
@@ -43,8 +43,9 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 46#include "accommon.h"
47#include <acpi/acevents.h> 47#include "acnamesp.h"
48#include "acevents.h"
48 49
49#define _COMPONENT ACPI_EVENTS 50#define _COMPONENT ACPI_EVENTS
50ACPI_MODULE_NAME("evxfregn") 51ACPI_MODULE_NAME("evxfregn")
diff --git a/drivers/acpi/executer/exconfig.c b/drivers/acpi/acpica/exconfig.c
index 74da6fa52ef1..932bbc26aa04 100644
--- a/drivers/acpi/executer/exconfig.c
+++ b/drivers/acpi/acpica/exconfig.c
@@ -42,10 +42,11 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acinterp.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acinterp.h"
47#include <acpi/actables.h> 47#include "acnamesp.h"
48#include <acpi/acdispat.h> 48#include "actables.h"
49#include "acdispat.h"
49 50
50#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
51ACPI_MODULE_NAME("exconfig") 52ACPI_MODULE_NAME("exconfig")
diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/acpica/exconvrt.c
index 1d1f35adddde..0be10188316e 100644
--- a/drivers/acpi/executer/exconvrt.c
+++ b/drivers/acpi/acpica/exconvrt.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acinterp.h> 45#include "accommon.h"
46#include <acpi/amlcode.h> 46#include "acinterp.h"
47#include "amlcode.h"
47 48
48#define _COMPONENT ACPI_EXECUTER 49#define _COMPONENT ACPI_EXECUTER
49ACPI_MODULE_NAME("exconvrt") 50ACPI_MODULE_NAME("exconvrt")
diff --git a/drivers/acpi/executer/excreate.c b/drivers/acpi/acpica/excreate.c
index ad09696d5069..a57ad2564ab0 100644
--- a/drivers/acpi/executer/excreate.c
+++ b/drivers/acpi/acpica/excreate.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acinterp.h> 45#include "accommon.h"
46#include <acpi/amlcode.h> 46#include "acinterp.h"
47#include <acpi/acnamesp.h> 47#include "amlcode.h"
48#include "acnamesp.h"
48 49
49#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
50ACPI_MODULE_NAME("excreate") 51ACPI_MODULE_NAME("excreate")
diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/acpica/exdump.c
index d087a7d28aa5..aa313574b0df 100644
--- a/drivers/acpi/executer/exdump.c
+++ b/drivers/acpi/acpica/exdump.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acinterp.h> 45#include "accommon.h"
46#include <acpi/amlcode.h> 46#include "acinterp.h"
47#include <acpi/acnamesp.h> 47#include "amlcode.h"
48#include "acnamesp.h"
48 49
49#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
50ACPI_MODULE_NAME("exdump") 51ACPI_MODULE_NAME("exdump")
diff --git a/drivers/acpi/executer/exfield.c b/drivers/acpi/acpica/exfield.c
index 3e440d84226a..a352d0233857 100644
--- a/drivers/acpi/executer/exfield.c
+++ b/drivers/acpi/acpica/exfield.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acdispat.h> 45#include "accommon.h"
46#include <acpi/acinterp.h> 46#include "acdispat.h"
47#include "acinterp.h"
47 48
48#define _COMPONENT ACPI_EXECUTER 49#define _COMPONENT ACPI_EXECUTER
49ACPI_MODULE_NAME("exfield") 50ACPI_MODULE_NAME("exfield")
diff --git a/drivers/acpi/executer/exfldio.c b/drivers/acpi/acpica/exfldio.c
index 9ff9d1f4615d..ef58ac4e687b 100644
--- a/drivers/acpi/executer/exfldio.c
+++ b/drivers/acpi/acpica/exfldio.c
@@ -42,10 +42,11 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acinterp.h> 45#include "accommon.h"
46#include <acpi/amlcode.h> 46#include "acinterp.h"
47#include <acpi/acevents.h> 47#include "amlcode.h"
48#include <acpi/acdispat.h> 48#include "acevents.h"
49#include "acdispat.h"
49 50
50#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
51ACPI_MODULE_NAME("exfldio") 52ACPI_MODULE_NAME("exfldio")
@@ -498,14 +499,13 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
498 return_ACPI_STATUS(status); 499 return_ACPI_STATUS(status);
499 } 500 }
500 501
501 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
502 "I/O to Data Register: ValuePtr %p\n",
503 value));
504
505 if (read_write == ACPI_READ) { 502 if (read_write == ACPI_READ) {
506 503
507 /* Read the datum from the data_register */ 504 /* Read the datum from the data_register */
508 505
506 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
507 "Read from Data Register\n"));
508
509 status = 509 status =
510 acpi_ex_extract_from_field(obj_desc->index_field. 510 acpi_ex_extract_from_field(obj_desc->index_field.
511 data_obj, value, 511 data_obj, value,
@@ -513,6 +513,10 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
513 } else { 513 } else {
514 /* Write the datum to the data_register */ 514 /* Write the datum to the data_register */
515 515
516 ACPI_DEBUG_PRINT((ACPI_DB_BFIELD,
517 "Write to Data Register: Value %8.8X%8.8X\n",
518 ACPI_FORMAT_UINT64(*value)));
519
516 status = 520 status =
517 acpi_ex_insert_into_field(obj_desc->index_field. 521 acpi_ex_insert_into_field(obj_desc->index_field.
518 data_obj, value, 522 data_obj, value,
diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/acpica/exmisc.c
index efb191340059..6b0747ac683b 100644
--- a/drivers/acpi/executer/exmisc.c
+++ b/drivers/acpi/acpica/exmisc.c
@@ -43,9 +43,10 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 46#include "accommon.h"
47#include <acpi/amlcode.h> 47#include "acinterp.h"
48#include <acpi/amlresrc.h> 48#include "amlcode.h"
49#include "amlresrc.h"
49 50
50#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
51ACPI_MODULE_NAME("exmisc") 52ACPI_MODULE_NAME("exmisc")
diff --git a/drivers/acpi/executer/exmutex.c b/drivers/acpi/acpica/exmutex.c
index a8bf3d713e28..d301c1f363ef 100644
--- a/drivers/acpi/executer/exmutex.c
+++ b/drivers/acpi/acpica/exmutex.c
@@ -43,8 +43,9 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 46#include "accommon.h"
47#include <acpi/acevents.h> 47#include "acinterp.h"
48#include "acevents.h"
48 49
49#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
50ACPI_MODULE_NAME("exmutex") 51ACPI_MODULE_NAME("exmutex")
diff --git a/drivers/acpi/executer/exnames.c b/drivers/acpi/acpica/exnames.c
index 817e67be3697..ffdae122d94a 100644
--- a/drivers/acpi/executer/exnames.c
+++ b/drivers/acpi/acpica/exnames.c
@@ -43,8 +43,9 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 46#include "accommon.h"
47#include <acpi/amlcode.h> 47#include "acinterp.h"
48#include "amlcode.h"
48 49
49#define _COMPONENT ACPI_EXECUTER 50#define _COMPONENT ACPI_EXECUTER
50ACPI_MODULE_NAME("exnames") 51ACPI_MODULE_NAME("exnames")
diff --git a/drivers/acpi/executer/exoparg1.c b/drivers/acpi/acpica/exoparg1.c
index f622f9eac8a1..b530480cc7d5 100644
--- a/drivers/acpi/executer/exoparg1.c
+++ b/drivers/acpi/acpica/exoparg1.c
@@ -43,11 +43,12 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acparser.h> 46#include "accommon.h"
47#include <acpi/acdispat.h> 47#include "acparser.h"
48#include <acpi/acinterp.h> 48#include "acdispat.h"
49#include <acpi/amlcode.h> 49#include "acinterp.h"
50#include <acpi/acnamesp.h> 50#include "amlcode.h"
51#include "acnamesp.h"
51 52
52#define _COMPONENT ACPI_EXECUTER 53#define _COMPONENT ACPI_EXECUTER
53ACPI_MODULE_NAME("exoparg1") 54ACPI_MODULE_NAME("exoparg1")
diff --git a/drivers/acpi/executer/exoparg2.c b/drivers/acpi/acpica/exoparg2.c
index 368def5dffce..0b4f513ca885 100644
--- a/drivers/acpi/executer/exoparg2.c
+++ b/drivers/acpi/acpica/exoparg2.c
@@ -42,10 +42,11 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include <acpi/acinterp.h> 46#include "acparser.h"
47#include <acpi/acevents.h> 47#include "acinterp.h"
48#include <acpi/amlcode.h> 48#include "acevents.h"
49#include "amlcode.h"
49 50
50#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
51ACPI_MODULE_NAME("exoparg2") 52ACPI_MODULE_NAME("exoparg2")
diff --git a/drivers/acpi/executer/exoparg3.c b/drivers/acpi/acpica/exoparg3.c
index 9cb4197681af..c6520bbf882b 100644
--- a/drivers/acpi/executer/exoparg3.c
+++ b/drivers/acpi/acpica/exoparg3.c
@@ -43,9 +43,10 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 46#include "accommon.h"
47#include <acpi/acparser.h> 47#include "acinterp.h"
48#include <acpi/amlcode.h> 48#include "acparser.h"
49#include "amlcode.h"
49 50
50#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
51ACPI_MODULE_NAME("exoparg3") 52ACPI_MODULE_NAME("exoparg3")
diff --git a/drivers/acpi/executer/exoparg6.c b/drivers/acpi/acpica/exoparg6.c
index 67d48737af53..ae43f7670a6c 100644
--- a/drivers/acpi/executer/exoparg6.c
+++ b/drivers/acpi/acpica/exoparg6.c
@@ -43,9 +43,10 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 46#include "accommon.h"
47#include <acpi/acparser.h> 47#include "acinterp.h"
48#include <acpi/amlcode.h> 48#include "acparser.h"
49#include "amlcode.h"
49 50
50#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
51ACPI_MODULE_NAME("exoparg6") 52ACPI_MODULE_NAME("exoparg6")
diff --git a/drivers/acpi/executer/exprep.c b/drivers/acpi/acpica/exprep.c
index 5d438c32989d..a226f74d4a5c 100644
--- a/drivers/acpi/executer/exprep.c
+++ b/drivers/acpi/acpica/exprep.c
@@ -43,9 +43,10 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 46#include "accommon.h"
47#include <acpi/amlcode.h> 47#include "acinterp.h"
48#include <acpi/acnamesp.h> 48#include "amlcode.h"
49#include "acnamesp.h"
49 50
50#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
51ACPI_MODULE_NAME("exprep") 52ACPI_MODULE_NAME("exprep")
@@ -404,7 +405,7 @@ acpi_ex_prep_common_field_object(union acpi_operand_object *obj_desc,
404 * 405 *
405 * RETURN: Status 406 * RETURN: Status
406 * 407 *
407 * DESCRIPTION: Construct an union acpi_operand_object of type def_field and 408 * DESCRIPTION: Construct a union acpi_operand_object of type def_field and
408 * connect it to the parent Node. 409 * connect it to the parent Node.
409 * 410 *
410 ******************************************************************************/ 411 ******************************************************************************/
diff --git a/drivers/acpi/executer/exregion.c b/drivers/acpi/acpica/exregion.c
index 7a41c409ae4d..76ec8ff903b8 100644
--- a/drivers/acpi/executer/exregion.c
+++ b/drivers/acpi/acpica/exregion.c
@@ -43,7 +43,8 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 46#include "accommon.h"
47#include "acinterp.h"
47 48
48#define _COMPONENT ACPI_EXECUTER 49#define _COMPONENT ACPI_EXECUTER
49ACPI_MODULE_NAME("exregion") 50ACPI_MODULE_NAME("exregion")
diff --git a/drivers/acpi/executer/exresnte.c b/drivers/acpi/acpica/exresnte.c
index 423ad3635f3d..a063a74006f6 100644
--- a/drivers/acpi/executer/exresnte.c
+++ b/drivers/acpi/acpica/exresnte.c
@@ -43,9 +43,10 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acdispat.h> 46#include "accommon.h"
47#include <acpi/acinterp.h> 47#include "acdispat.h"
48#include <acpi/acnamesp.h> 48#include "acinterp.h"
49#include "acnamesp.h"
49 50
50#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
51ACPI_MODULE_NAME("exresnte") 52ACPI_MODULE_NAME("exresnte")
diff --git a/drivers/acpi/executer/exresolv.c b/drivers/acpi/acpica/exresolv.c
index 89571b92a522..f6105a6d6126 100644
--- a/drivers/acpi/executer/exresolv.c
+++ b/drivers/acpi/acpica/exresolv.c
@@ -43,10 +43,11 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/amlcode.h> 46#include "accommon.h"
47#include <acpi/acdispat.h> 47#include "amlcode.h"
48#include <acpi/acinterp.h> 48#include "acdispat.h"
49#include <acpi/acnamesp.h> 49#include "acinterp.h"
50#include "acnamesp.h"
50 51
51#define _COMPONENT ACPI_EXECUTER 52#define _COMPONENT ACPI_EXECUTER
52ACPI_MODULE_NAME("exresolv") 53ACPI_MODULE_NAME("exresolv")
@@ -146,7 +147,7 @@ acpi_ex_resolve_object_to_value(union acpi_operand_object **stack_ptr,
146 147
147 stack_desc = *stack_ptr; 148 stack_desc = *stack_ptr;
148 149
149 /* This is an union acpi_operand_object */ 150 /* This is a union acpi_operand_object */
150 151
151 switch (ACPI_GET_OBJECT_TYPE(stack_desc)) { 152 switch (ACPI_GET_OBJECT_TYPE(stack_desc)) {
152 case ACPI_TYPE_LOCAL_REFERENCE: 153 case ACPI_TYPE_LOCAL_REFERENCE:
diff --git a/drivers/acpi/executer/exresop.c b/drivers/acpi/acpica/exresop.c
index 0bb82593da72..3c3802764bfb 100644
--- a/drivers/acpi/executer/exresop.c
+++ b/drivers/acpi/acpica/exresop.c
@@ -43,10 +43,11 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/amlcode.h> 46#include "accommon.h"
47#include <acpi/acparser.h> 47#include "amlcode.h"
48#include <acpi/acinterp.h> 48#include "acparser.h"
49#include <acpi/acnamesp.h> 49#include "acinterp.h"
50#include "acnamesp.h"
50 51
51#define _COMPONENT ACPI_EXECUTER 52#define _COMPONENT ACPI_EXECUTER
52ACPI_MODULE_NAME("exresop") 53ACPI_MODULE_NAME("exresop")
diff --git a/drivers/acpi/executer/exstore.c b/drivers/acpi/acpica/exstore.c
index 3318df4cbd98..e35e9b4f6a4e 100644
--- a/drivers/acpi/executer/exstore.c
+++ b/drivers/acpi/acpica/exstore.c
@@ -43,10 +43,11 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acdispat.h> 46#include "accommon.h"
47#include <acpi/acinterp.h> 47#include "acdispat.h"
48#include <acpi/amlcode.h> 48#include "acinterp.h"
49#include <acpi/acnamesp.h> 49#include "amlcode.h"
50#include "acnamesp.h"
50 51
51#define _COMPONENT ACPI_EXECUTER 52#define _COMPONENT ACPI_EXECUTER
52ACPI_MODULE_NAME("exstore") 53ACPI_MODULE_NAME("exstore")
@@ -274,7 +275,7 @@ acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
274 * 275 *
275 * PARAMETERS: *source_desc - Value to be stored 276 * PARAMETERS: *source_desc - Value to be stored
276 * *dest_desc - Where to store it. Must be an NS node 277 * *dest_desc - Where to store it. Must be an NS node
277 * or an union acpi_operand_object of type 278 * or a union acpi_operand_object of type
278 * Reference; 279 * Reference;
279 * walk_state - Current walk state 280 * walk_state - Current walk state
280 * 281 *
diff --git a/drivers/acpi/executer/exstoren.c b/drivers/acpi/acpica/exstoren.c
index eef61a00803e..145d15305f70 100644
--- a/drivers/acpi/executer/exstoren.c
+++ b/drivers/acpi/acpica/exstoren.c
@@ -44,8 +44,9 @@
44 */ 44 */
45 45
46#include <acpi/acpi.h> 46#include <acpi/acpi.h>
47#include <acpi/acinterp.h> 47#include "accommon.h"
48#include <acpi/amlcode.h> 48#include "acinterp.h"
49#include "amlcode.h"
49 50
50#define _COMPONENT ACPI_EXECUTER 51#define _COMPONENT ACPI_EXECUTER
51ACPI_MODULE_NAME("exstoren") 52ACPI_MODULE_NAME("exstoren")
diff --git a/drivers/acpi/executer/exstorob.c b/drivers/acpi/acpica/exstorob.c
index 9a75ff09fb0c..67340cc70142 100644
--- a/drivers/acpi/executer/exstorob.c
+++ b/drivers/acpi/acpica/exstorob.c
@@ -43,7 +43,8 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 46#include "accommon.h"
47#include "acinterp.h"
47 48
48#define _COMPONENT ACPI_EXECUTER 49#define _COMPONENT ACPI_EXECUTER
49ACPI_MODULE_NAME("exstorob") 50ACPI_MODULE_NAME("exstorob")
diff --git a/drivers/acpi/executer/exsystem.c b/drivers/acpi/acpica/exsystem.c
index 68990f1df371..3d00b9357233 100644
--- a/drivers/acpi/executer/exsystem.c
+++ b/drivers/acpi/acpica/exsystem.c
@@ -43,7 +43,8 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acinterp.h> 46#include "accommon.h"
47#include "acinterp.h"
47 48
48#define _COMPONENT ACPI_EXECUTER 49#define _COMPONENT ACPI_EXECUTER
49ACPI_MODULE_NAME("exsystem") 50ACPI_MODULE_NAME("exsystem")
diff --git a/drivers/acpi/executer/exutils.c b/drivers/acpi/acpica/exutils.c
index 86c03880b523..32b85d68e756 100644
--- a/drivers/acpi/executer/exutils.c
+++ b/drivers/acpi/acpica/exutils.c
@@ -59,8 +59,9 @@
59#define DEFINE_AML_GLOBALS 59#define DEFINE_AML_GLOBALS
60 60
61#include <acpi/acpi.h> 61#include <acpi/acpi.h>
62#include <acpi/acinterp.h> 62#include "accommon.h"
63#include <acpi/amlcode.h> 63#include "acinterp.h"
64#include "amlcode.h"
64 65
65#define _COMPONENT ACPI_EXECUTER 66#define _COMPONENT ACPI_EXECUTER
66ACPI_MODULE_NAME("exutils") 67ACPI_MODULE_NAME("exutils")
diff --git a/drivers/acpi/hardware/hwacpi.c b/drivers/acpi/acpica/hwacpi.c
index 816894ea839e..a9d4fea4167f 100644
--- a/drivers/acpi/hardware/hwacpi.c
+++ b/drivers/acpi/acpica/hwacpi.c
@@ -43,6 +43,7 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include "accommon.h"
46 47
47#define _COMPONENT ACPI_HARDWARE 48#define _COMPONENT ACPI_HARDWARE
48ACPI_MODULE_NAME("hwacpi") 49ACPI_MODULE_NAME("hwacpi")
diff --git a/drivers/acpi/hardware/hwgpe.c b/drivers/acpi/acpica/hwgpe.c
index 0b80db9d9197..2013b66745d2 100644
--- a/drivers/acpi/hardware/hwgpe.c
+++ b/drivers/acpi/acpica/hwgpe.c
@@ -43,7 +43,8 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acevents.h> 46#include "accommon.h"
47#include "acevents.h"
47 48
48#define _COMPONENT ACPI_HARDWARE 49#define _COMPONENT ACPI_HARDWARE
49ACPI_MODULE_NAME("hwgpe") 50ACPI_MODULE_NAME("hwgpe")
@@ -51,7 +52,8 @@ ACPI_MODULE_NAME("hwgpe")
51/* Local prototypes */ 52/* Local prototypes */
52static acpi_status 53static acpi_status
53acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, 54acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
54 struct acpi_gpe_block_info *gpe_block); 55 struct acpi_gpe_block_info *gpe_block,
56 void *context);
55 57
56/****************************************************************************** 58/******************************************************************************
57 * 59 *
@@ -80,8 +82,7 @@ acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info)
80 82
81 /* Get current value of the enable register that contains this GPE */ 83 /* Get current value of the enable register that contains this GPE */
82 84
83 status = acpi_hw_low_level_read(ACPI_GPE_REGISTER_WIDTH, &enable_mask, 85 status = acpi_read(&enable_mask, &gpe_register_info->enable_address);
84 &gpe_register_info->enable_address);
85 if (ACPI_FAILURE(status)) { 86 if (ACPI_FAILURE(status)) {
86 return (status); 87 return (status);
87 } 88 }
@@ -95,9 +96,7 @@ acpi_status acpi_hw_low_disable_gpe(struct acpi_gpe_event_info *gpe_event_info)
95 96
96 /* Write the updated enable mask */ 97 /* Write the updated enable mask */
97 98
98 status = acpi_hw_low_level_write(ACPI_GPE_REGISTER_WIDTH, enable_mask, 99 status = acpi_write(enable_mask, &gpe_register_info->enable_address);
99 &gpe_register_info->enable_address);
100
101 return (status); 100 return (status);
102} 101}
103 102
@@ -132,8 +131,8 @@ acpi_hw_write_gpe_enable_reg(struct acpi_gpe_event_info * gpe_event_info)
132 131
133 /* Write the entire GPE (runtime) enable register */ 132 /* Write the entire GPE (runtime) enable register */
134 133
135 status = acpi_hw_low_level_write(8, gpe_register_info->enable_for_run, 134 status = acpi_write(gpe_register_info->enable_for_run,
136 &gpe_register_info->enable_address); 135 &gpe_register_info->enable_address);
137 136
138 return (status); 137 return (status);
139} 138}
@@ -166,9 +165,8 @@ acpi_status acpi_hw_clear_gpe(struct acpi_gpe_event_info * gpe_event_info)
166 * Write a one to the appropriate bit in the status register to 165 * Write a one to the appropriate bit in the status register to
167 * clear this GPE. 166 * clear this GPE.
168 */ 167 */
169 status = acpi_hw_low_level_write(8, register_bit, 168 status = acpi_write(register_bit,
170 &gpe_event_info->register_info-> 169 &gpe_event_info->register_info->status_address);
171 status_address);
172 170
173 return (status); 171 return (status);
174} 172}
@@ -227,9 +225,7 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
227 225
228 /* GPE currently active (status bit == 1)? */ 226 /* GPE currently active (status bit == 1)? */
229 227
230 status = 228 status = acpi_read(&in_byte, &gpe_register_info->status_address);
231 acpi_hw_low_level_read(8, &in_byte,
232 &gpe_register_info->status_address);
233 if (ACPI_FAILURE(status)) { 229 if (ACPI_FAILURE(status)) {
234 goto unlock_and_exit; 230 goto unlock_and_exit;
235 } 231 }
@@ -260,8 +256,8 @@ acpi_hw_get_gpe_status(struct acpi_gpe_event_info * gpe_event_info,
260 ******************************************************************************/ 256 ******************************************************************************/
261 257
262acpi_status 258acpi_status
263acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info, 259acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
264 struct acpi_gpe_block_info * gpe_block) 260 struct acpi_gpe_block_info *gpe_block, void *context)
265{ 261{
266 u32 i; 262 u32 i;
267 acpi_status status; 263 acpi_status status;
@@ -272,9 +268,9 @@ acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info,
272 268
273 /* Disable all GPEs in this register */ 269 /* Disable all GPEs in this register */
274 270
275 status = acpi_hw_low_level_write(8, 0x00, 271 status =
276 &gpe_block->register_info[i]. 272 acpi_write(0x00,
277 enable_address); 273 &gpe_block->register_info[i].enable_address);
278 if (ACPI_FAILURE(status)) { 274 if (ACPI_FAILURE(status)) {
279 return (status); 275 return (status);
280 } 276 }
@@ -297,8 +293,8 @@ acpi_hw_disable_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info,
297 ******************************************************************************/ 293 ******************************************************************************/
298 294
299acpi_status 295acpi_status
300acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info, 296acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
301 struct acpi_gpe_block_info * gpe_block) 297 struct acpi_gpe_block_info *gpe_block, void *context)
302{ 298{
303 u32 i; 299 u32 i;
304 acpi_status status; 300 acpi_status status;
@@ -309,9 +305,9 @@ acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info,
309 305
310 /* Clear status on all GPEs in this register */ 306 /* Clear status on all GPEs in this register */
311 307
312 status = acpi_hw_low_level_write(8, 0xFF, 308 status =
313 &gpe_block->register_info[i]. 309 acpi_write(0xFF,
314 status_address); 310 &gpe_block->register_info[i].status_address);
315 if (ACPI_FAILURE(status)) { 311 if (ACPI_FAILURE(status)) {
316 return (status); 312 return (status);
317 } 313 }
@@ -335,8 +331,8 @@ acpi_hw_clear_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info,
335 ******************************************************************************/ 331 ******************************************************************************/
336 332
337acpi_status 333acpi_status
338acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info, 334acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
339 struct acpi_gpe_block_info * gpe_block) 335 struct acpi_gpe_block_info *gpe_block, void *context)
340{ 336{
341 u32 i; 337 u32 i;
342 acpi_status status; 338 acpi_status status;
@@ -352,12 +348,9 @@ acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info,
352 348
353 /* Enable all "runtime" GPEs in this register */ 349 /* Enable all "runtime" GPEs in this register */
354 350
355 status = 351 status = acpi_write(gpe_block->register_info[i].enable_for_run,
356 acpi_hw_low_level_write(8, 352 &gpe_block->register_info[i].
357 gpe_block->register_info[i]. 353 enable_address);
358 enable_for_run,
359 &gpe_block->register_info[i].
360 enable_address);
361 if (ACPI_FAILURE(status)) { 354 if (ACPI_FAILURE(status)) {
362 return (status); 355 return (status);
363 } 356 }
@@ -382,7 +375,8 @@ acpi_hw_enable_runtime_gpe_block(struct acpi_gpe_xrupt_info * gpe_xrupt_info,
382 375
383static acpi_status 376static acpi_status
384acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, 377acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
385 struct acpi_gpe_block_info *gpe_block) 378 struct acpi_gpe_block_info *gpe_block,
379 void *context)
386{ 380{
387 u32 i; 381 u32 i;
388 acpi_status status; 382 acpi_status status;
@@ -396,11 +390,9 @@ acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
396 390
397 /* Enable all "wake" GPEs in this register */ 391 /* Enable all "wake" GPEs in this register */
398 392
399 status = acpi_hw_low_level_write(8, 393 status = acpi_write(gpe_block->register_info[i].enable_for_wake,
400 gpe_block->register_info[i]. 394 &gpe_block->register_info[i].
401 enable_for_wake, 395 enable_address);
402 &gpe_block->register_info[i].
403 enable_address);
404 if (ACPI_FAILURE(status)) { 396 if (ACPI_FAILURE(status)) {
405 return (status); 397 return (status);
406 } 398 }
@@ -427,8 +419,8 @@ acpi_status acpi_hw_disable_all_gpes(void)
427 419
428 ACPI_FUNCTION_TRACE(hw_disable_all_gpes); 420 ACPI_FUNCTION_TRACE(hw_disable_all_gpes);
429 421
430 status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block); 422 status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block, NULL);
431 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block); 423 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL);
432 return_ACPI_STATUS(status); 424 return_ACPI_STATUS(status);
433} 425}
434 426
@@ -450,7 +442,7 @@ acpi_status acpi_hw_enable_all_runtime_gpes(void)
450 442
451 ACPI_FUNCTION_TRACE(hw_enable_all_runtime_gpes); 443 ACPI_FUNCTION_TRACE(hw_enable_all_runtime_gpes);
452 444
453 status = acpi_ev_walk_gpe_list(acpi_hw_enable_runtime_gpe_block); 445 status = acpi_ev_walk_gpe_list(acpi_hw_enable_runtime_gpe_block, NULL);
454 return_ACPI_STATUS(status); 446 return_ACPI_STATUS(status);
455} 447}
456 448
@@ -472,6 +464,6 @@ acpi_status acpi_hw_enable_all_wakeup_gpes(void)
472 464
473 ACPI_FUNCTION_TRACE(hw_enable_all_wakeup_gpes); 465 ACPI_FUNCTION_TRACE(hw_enable_all_wakeup_gpes);
474 466
475 status = acpi_ev_walk_gpe_list(acpi_hw_enable_wakeup_gpe_block); 467 status = acpi_ev_walk_gpe_list(acpi_hw_enable_wakeup_gpe_block, NULL);
476 return_ACPI_STATUS(status); 468 return_ACPI_STATUS(status);
477} 469}
diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c
new file mode 100644
index 000000000000..4dc43b018517
--- /dev/null
+++ b/drivers/acpi/acpica/hwregs.c
@@ -0,0 +1,353 @@
1
2/*******************************************************************************
3 *
4 * Module Name: hwregs - Read/write access functions for the various ACPI
5 * control and status registers.
6 *
7 ******************************************************************************/
8
9/*
10 * Copyright (C) 2000 - 2008, Intel Corp.
11 * All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions, and the following disclaimer,
18 * without modification.
19 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
20 * substantially similar to the "NO WARRANTY" disclaimer below
21 * ("Disclaimer") and any redistribution must be conditioned upon
22 * including a substantially similar Disclaimer requirement for further
23 * binary redistribution.
24 * 3. Neither the names of the above-listed copyright holders nor the names
25 * of any contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
27 *
28 * Alternatively, this software may be distributed under the terms of the
29 * GNU General Public License ("GPL") version 2 as published by the Free
30 * Software Foundation.
31 *
32 * NO WARRANTY
33 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
34 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
35 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
36 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
37 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
38 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
39 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
41 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
42 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
43 * POSSIBILITY OF SUCH DAMAGES.
44 */
45
46#include <acpi/acpi.h>
47#include "accommon.h"
48#include "acnamesp.h"
49#include "acevents.h"
50
51#define _COMPONENT ACPI_HARDWARE
52ACPI_MODULE_NAME("hwregs")
53
54/*******************************************************************************
55 *
56 * FUNCTION: acpi_hw_clear_acpi_status
57 *
58 * PARAMETERS: None
59 *
60 * RETURN: Status
61 *
62 * DESCRIPTION: Clears all fixed and general purpose status bits
63 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
64 *
65 ******************************************************************************/
66acpi_status acpi_hw_clear_acpi_status(void)
67{
68 acpi_status status;
69 acpi_cpu_flags lock_flags = 0;
70
71 ACPI_FUNCTION_TRACE(hw_clear_acpi_status);
72
73 ACPI_DEBUG_PRINT((ACPI_DB_IO, "About to write %04X to %04X\n",
74 ACPI_BITMASK_ALL_FIXED_STATUS,
75 (u16) acpi_gbl_FADT.xpm1a_event_block.address));
76
77 lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);
78
79 status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS,
80 ACPI_BITMASK_ALL_FIXED_STATUS);
81 if (ACPI_FAILURE(status)) {
82 goto unlock_and_exit;
83 }
84
85 /* Clear the fixed events */
86
87 if (acpi_gbl_FADT.xpm1b_event_block.address) {
88 status = acpi_write(ACPI_BITMASK_ALL_FIXED_STATUS,
89 &acpi_gbl_FADT.xpm1b_event_block);
90 if (ACPI_FAILURE(status)) {
91 goto unlock_and_exit;
92 }
93 }
94
95 /* Clear the GPE Bits in all GPE registers in all GPE blocks */
96
97 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block, NULL);
98
99 unlock_and_exit:
100 acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags);
101 return_ACPI_STATUS(status);
102}
103
104/*******************************************************************************
105 *
106 * FUNCTION: acpi_hw_get_register_bit_mask
107 *
108 * PARAMETERS: register_id - Index of ACPI Register to access
109 *
110 * RETURN: The bitmask to be used when accessing the register
111 *
112 * DESCRIPTION: Map register_id into a register bitmask.
113 *
114 ******************************************************************************/
115
116struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id)
117{
118 ACPI_FUNCTION_ENTRY();
119
120 if (register_id > ACPI_BITREG_MAX) {
121 ACPI_ERROR((AE_INFO, "Invalid BitRegister ID: %X",
122 register_id));
123 return (NULL);
124 }
125
126 return (&acpi_gbl_bit_register_info[register_id]);
127}
128
129/******************************************************************************
130 *
131 * FUNCTION: acpi_hw_register_read
132 *
133 * PARAMETERS: register_id - ACPI Register ID
134 * return_value - Where the register value is returned
135 *
136 * RETURN: Status and the value read.
137 *
138 * DESCRIPTION: Read from the specified ACPI register
139 *
140 ******************************************************************************/
141acpi_status
142acpi_hw_register_read(u32 register_id, u32 * return_value)
143{
144 u32 value1 = 0;
145 u32 value2 = 0;
146 acpi_status status;
147
148 ACPI_FUNCTION_TRACE(hw_register_read);
149
150 switch (register_id) {
151 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
152
153 status = acpi_read(&value1, &acpi_gbl_FADT.xpm1a_event_block);
154 if (ACPI_FAILURE(status)) {
155 goto exit;
156 }
157
158 /* PM1B is optional */
159
160 status = acpi_read(&value2, &acpi_gbl_FADT.xpm1b_event_block);
161 value1 |= value2;
162 break;
163
164 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */
165
166 status = acpi_read(&value1, &acpi_gbl_xpm1a_enable);
167 if (ACPI_FAILURE(status)) {
168 goto exit;
169 }
170
171 /* PM1B is optional */
172
173 status = acpi_read(&value2, &acpi_gbl_xpm1b_enable);
174 value1 |= value2;
175 break;
176
177 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
178
179 status = acpi_read(&value1, &acpi_gbl_FADT.xpm1a_control_block);
180 if (ACPI_FAILURE(status)) {
181 goto exit;
182 }
183
184 status = acpi_read(&value2, &acpi_gbl_FADT.xpm1b_control_block);
185 value1 |= value2;
186 break;
187
188 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
189
190 status = acpi_read(&value1, &acpi_gbl_FADT.xpm2_control_block);
191 break;
192
193 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
194
195 status = acpi_read(&value1, &acpi_gbl_FADT.xpm_timer_block);
196 break;
197
198 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
199
200 status =
201 acpi_os_read_port(acpi_gbl_FADT.smi_command, &value1, 8);
202 break;
203
204 default:
205 ACPI_ERROR((AE_INFO, "Unknown Register ID: %X", register_id));
206 status = AE_BAD_PARAMETER;
207 break;
208 }
209
210 exit:
211
212 if (ACPI_SUCCESS(status)) {
213 *return_value = value1;
214 }
215
216 return_ACPI_STATUS(status);
217}
218
219/******************************************************************************
220 *
221 * FUNCTION: acpi_hw_register_write
222 *
223 * PARAMETERS: register_id - ACPI Register ID
224 * Value - The value to write
225 *
226 * RETURN: Status
227 *
228 * DESCRIPTION: Write to the specified ACPI register
229 *
230 * NOTE: In accordance with the ACPI specification, this function automatically
231 * preserves the value of the following bits, meaning that these bits cannot be
232 * changed via this interface:
233 *
234 * PM1_CONTROL[0] = SCI_EN
235 * PM1_CONTROL[9]
236 * PM1_STATUS[11]
237 *
238 * ACPI References:
239 * 1) Hardware Ignored Bits: When software writes to a register with ignored
240 * bit fields, it preserves the ignored bit fields
241 * 2) SCI_EN: OSPM always preserves this bit position
242 *
243 ******************************************************************************/
244
245acpi_status acpi_hw_register_write(u32 register_id, u32 value)
246{
247 acpi_status status;
248 u32 read_value;
249
250 ACPI_FUNCTION_TRACE(hw_register_write);
251
252 switch (register_id) {
253 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
254
255 /* Perform a read first to preserve certain bits (per ACPI spec) */
256
257 status = acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS,
258 &read_value);
259 if (ACPI_FAILURE(status)) {
260 goto exit;
261 }
262
263 /* Insert the bits to be preserved */
264
265 ACPI_INSERT_BITS(value, ACPI_PM1_STATUS_PRESERVED_BITS,
266 read_value);
267
268 /* Now we can write the data */
269
270 status = acpi_write(value, &acpi_gbl_FADT.xpm1a_event_block);
271 if (ACPI_FAILURE(status)) {
272 goto exit;
273 }
274
275 /* PM1B is optional */
276
277 status = acpi_write(value, &acpi_gbl_FADT.xpm1b_event_block);
278 break;
279
280 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */
281
282 status = acpi_write(value, &acpi_gbl_xpm1a_enable);
283 if (ACPI_FAILURE(status)) {
284 goto exit;
285 }
286
287 /* PM1B is optional */
288
289 status = acpi_write(value, &acpi_gbl_xpm1b_enable);
290 break;
291
292 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
293
294 /*
295 * Perform a read first to preserve certain bits (per ACPI spec)
296 */
297 status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
298 &read_value);
299 if (ACPI_FAILURE(status)) {
300 goto exit;
301 }
302
303 /* Insert the bits to be preserved */
304
305 ACPI_INSERT_BITS(value, ACPI_PM1_CONTROL_PRESERVED_BITS,
306 read_value);
307
308 /* Now we can write the data */
309
310 status = acpi_write(value, &acpi_gbl_FADT.xpm1a_control_block);
311 if (ACPI_FAILURE(status)) {
312 goto exit;
313 }
314
315 status = acpi_write(value, &acpi_gbl_FADT.xpm1b_control_block);
316 break;
317
318 case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */
319
320 status = acpi_write(value, &acpi_gbl_FADT.xpm1a_control_block);
321 break;
322
323 case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */
324
325 status = acpi_write(value, &acpi_gbl_FADT.xpm1b_control_block);
326 break;
327
328 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
329
330 status = acpi_write(value, &acpi_gbl_FADT.xpm2_control_block);
331 break;
332
333 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
334
335 status = acpi_write(value, &acpi_gbl_FADT.xpm_timer_block);
336 break;
337
338 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
339
340 /* SMI_CMD is currently always in IO space */
341
342 status =
343 acpi_os_write_port(acpi_gbl_FADT.smi_command, value, 8);
344 break;
345
346 default:
347 status = AE_BAD_PARAMETER;
348 break;
349 }
350
351 exit:
352 return_ACPI_STATUS(status);
353}
diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/acpica/hwsleep.c
index 25dccdf179b9..a2af2a4f2f26 100644
--- a/drivers/acpi/hardware/hwsleep.c
+++ b/drivers/acpi/acpica/hwsleep.c
@@ -43,7 +43,8 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/actables.h> 46#include "accommon.h"
47#include "actables.h"
47 48
48#define _COMPONENT ACPI_HARDWARE 49#define _COMPONENT ACPI_HARDWARE
49ACPI_MODULE_NAME("hwsleep") 50ACPI_MODULE_NAME("hwsleep")
@@ -52,31 +53,19 @@ ACPI_MODULE_NAME("hwsleep")
52 * 53 *
53 * FUNCTION: acpi_set_firmware_waking_vector 54 * FUNCTION: acpi_set_firmware_waking_vector
54 * 55 *
55 * PARAMETERS: physical_address - Physical address of ACPI real mode 56 * PARAMETERS: physical_address - 32-bit physical address of ACPI real mode
56 * entry point. 57 * entry point.
57 * 58 *
58 * RETURN: Status 59 * RETURN: Status
59 * 60 *
60 * DESCRIPTION: Access function for the firmware_waking_vector field in FACS 61 * DESCRIPTION: Sets the 32-bit firmware_waking_vector field of the FACS
61 * 62 *
62 ******************************************************************************/ 63 ******************************************************************************/
63acpi_status 64acpi_status
64acpi_set_firmware_waking_vector(acpi_physical_address physical_address) 65acpi_set_firmware_waking_vector(u32 physical_address)
65{ 66{
66 struct acpi_table_facs *facs;
67 acpi_status status;
68
69 ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector); 67 ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector);
70 68
71 /* Get the FACS */
72
73 status = acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS,
74 ACPI_CAST_INDIRECT_PTR(struct
75 acpi_table_header,
76 &facs));
77 if (ACPI_FAILURE(status)) {
78 return_ACPI_STATUS(status);
79 }
80 69
81 /* 70 /*
82 * According to the ACPI specification 2.0c and later, the 64-bit 71 * According to the ACPI specification 2.0c and later, the 64-bit
@@ -85,10 +74,16 @@ acpi_set_firmware_waking_vector(acpi_physical_address physical_address)
85 * Protected Mode. Some systems (for example HP dv5-1004nr) are known 74 * Protected Mode. Some systems (for example HP dv5-1004nr) are known
86 * to fail to resume if the 64-bit vector is used. 75 * to fail to resume if the 64-bit vector is used.
87 */ 76 */
88 if (facs->version >= 1)
89 facs->xfirmware_waking_vector = 0;
90 77
91 facs->firmware_waking_vector = (u32)physical_address; 78 /* Set the 32-bit vector */
79
80 acpi_gbl_FACS->firmware_waking_vector = physical_address;
81
82 /* Clear the 64-bit vector if it exists */
83
84 if ((acpi_gbl_FACS->length > 32) && (acpi_gbl_FACS->version >= 1)) {
85 acpi_gbl_FACS->xfirmware_waking_vector = 0;
86 }
92 87
93 return_ACPI_STATUS(AE_OK); 88 return_ACPI_STATUS(AE_OK);
94} 89}
@@ -97,48 +92,39 @@ ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector)
97 92
98/******************************************************************************* 93/*******************************************************************************
99 * 94 *
100 * FUNCTION: acpi_get_firmware_waking_vector 95 * FUNCTION: acpi_set_firmware_waking_vector64
101 * 96 *
102 * PARAMETERS: *physical_address - Where the contents of 97 * PARAMETERS: physical_address - 64-bit physical address of ACPI protected
103 * the firmware_waking_vector field of 98 * mode entry point.
104 * the FACS will be returned.
105 * 99 *
106 * RETURN: Status, vector 100 * RETURN: Status
107 * 101 *
108 * DESCRIPTION: Access function for the firmware_waking_vector field in FACS 102 * DESCRIPTION: Sets the 64-bit X_firmware_waking_vector field of the FACS, if
103 * it exists in the table.
109 * 104 *
110 ******************************************************************************/ 105 ******************************************************************************/
111#ifdef ACPI_FUTURE_USAGE
112acpi_status 106acpi_status
113acpi_get_firmware_waking_vector(acpi_physical_address * physical_address) 107acpi_set_firmware_waking_vector64(u64 physical_address)
114{ 108{
115 struct acpi_table_facs *facs; 109 ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector64);
116 acpi_status status;
117 110
118 ACPI_FUNCTION_TRACE(acpi_get_firmware_waking_vector);
119
120 if (!physical_address) {
121 return_ACPI_STATUS(AE_BAD_PARAMETER);
122 }
123 111
124 /* Get the FACS */ 112 /* Determine if the 64-bit vector actually exists */
125 113
126 status = acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS, 114 if ((acpi_gbl_FACS->length <= 32) || (acpi_gbl_FACS->version < 1)) {
127 ACPI_CAST_INDIRECT_PTR(struct 115 return_ACPI_STATUS(AE_NOT_EXIST);
128 acpi_table_header,
129 &facs));
130 if (ACPI_FAILURE(status)) {
131 return_ACPI_STATUS(status);
132 } 116 }
133 117
134 /* Get the vector */ 118 /* Clear 32-bit vector, set the 64-bit X_ vector */
135 *physical_address = (acpi_physical_address)facs->firmware_waking_vector; 119
120 acpi_gbl_FACS->firmware_waking_vector = 0;
121 acpi_gbl_FACS->xfirmware_waking_vector = physical_address;
136 122
137 return_ACPI_STATUS(AE_OK); 123 return_ACPI_STATUS(AE_OK);
138} 124}
139 125
140ACPI_EXPORT_SYMBOL(acpi_get_firmware_waking_vector) 126ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector64)
141#endif 127
142/******************************************************************************* 128/*******************************************************************************
143 * 129 *
144 * FUNCTION: acpi_enter_sleep_state_prep 130 * FUNCTION: acpi_enter_sleep_state_prep
diff --git a/drivers/acpi/hardware/hwtimer.c b/drivers/acpi/acpica/hwtimer.c
index b53d575491b9..b7f522c8f023 100644
--- a/drivers/acpi/hardware/hwtimer.c
+++ b/drivers/acpi/acpica/hwtimer.c
@@ -43,6 +43,7 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include "accommon.h"
46 47
47#define _COMPONENT ACPI_HARDWARE 48#define _COMPONENT ACPI_HARDWARE
48ACPI_MODULE_NAME("hwtimer") 49ACPI_MODULE_NAME("hwtimer")
diff --git a/drivers/acpi/hardware/hwregs.c b/drivers/acpi/acpica/hwxface.c
index ddf792adcf96..ae597c0ab53f 100644
--- a/drivers/acpi/hardware/hwregs.c
+++ b/drivers/acpi/acpica/hwxface.c
@@ -1,10 +1,9 @@
1 1
2/******************************************************************************* 2/******************************************************************************
3 * 3 *
4 * Module Name: hwregs - Read/write access functions for the various ACPI 4 * Module Name: hwxface - Public ACPICA hardware interfaces
5 * control and status registers.
6 * 5 *
7 ******************************************************************************/ 6 *****************************************************************************/
8 7
9/* 8/*
10 * Copyright (C) 2000 - 2008, Intel Corp. 9 * Copyright (C) 2000 - 2008, Intel Corp.
@@ -44,209 +43,208 @@
44 */ 43 */
45 44
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acnamesp.h> 46#include "accommon.h"
48#include <acpi/acevents.h> 47#include "acnamesp.h"
49 48
50#define _COMPONENT ACPI_HARDWARE 49#define _COMPONENT ACPI_HARDWARE
51ACPI_MODULE_NAME("hwregs") 50ACPI_MODULE_NAME("hwxface")
52 51
53/******************************************************************************* 52/******************************************************************************
54 * 53 *
55 * FUNCTION: acpi_hw_clear_acpi_status 54 * FUNCTION: acpi_reset
56 * 55 *
57 * PARAMETERS: None 56 * PARAMETERS: None
58 * 57 *
59 * RETURN: None 58 * RETURN: Status
60 * 59 *
61 * DESCRIPTION: Clears all fixed and general purpose status bits 60 * DESCRIPTION: Set reset register in memory or IO space. Note: Does not
62 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED 61 * support reset register in PCI config space, this must be
62 * handled separately.
63 * 63 *
64 ******************************************************************************/ 64 ******************************************************************************/
65acpi_status acpi_hw_clear_acpi_status(void) 65acpi_status acpi_reset(void)
66{ 66{
67 struct acpi_generic_address *reset_reg;
67 acpi_status status; 68 acpi_status status;
68 acpi_cpu_flags lock_flags = 0;
69 69
70 ACPI_FUNCTION_TRACE(hw_clear_acpi_status); 70 ACPI_FUNCTION_TRACE(acpi_reset);
71 71
72 ACPI_DEBUG_PRINT((ACPI_DB_IO, "About to write %04X to %04X\n", 72 reset_reg = &acpi_gbl_FADT.reset_register;
73 ACPI_BITMASK_ALL_FIXED_STATUS,
74 (u16) acpi_gbl_FADT.xpm1a_event_block.address));
75 73
76 lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); 74 /* Check if the reset register is supported */
77 75
78 status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS, 76 if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER) ||
79 ACPI_BITMASK_ALL_FIXED_STATUS); 77 !reset_reg->address) {
80 if (ACPI_FAILURE(status)) { 78 return_ACPI_STATUS(AE_NOT_EXIST);
81 goto unlock_and_exit;
82 } 79 }
83 80
84 /* Clear the fixed events */ 81 /* Write the reset value to the reset register */
85
86 if (acpi_gbl_FADT.xpm1b_event_block.address) {
87 status =
88 acpi_hw_low_level_write(16, ACPI_BITMASK_ALL_FIXED_STATUS,
89 &acpi_gbl_FADT.xpm1b_event_block);
90 if (ACPI_FAILURE(status)) {
91 goto unlock_and_exit;
92 }
93 }
94
95 /* Clear the GPE Bits in all GPE registers in all GPE blocks */
96
97 status = acpi_ev_walk_gpe_list(acpi_hw_clear_gpe_block);
98 82
99 unlock_and_exit: 83 status = acpi_write(acpi_gbl_FADT.reset_value, reset_reg);
100 acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags);
101 return_ACPI_STATUS(status); 84 return_ACPI_STATUS(status);
102} 85}
103 86
104/******************************************************************************* 87ACPI_EXPORT_SYMBOL(acpi_reset)
88
89/******************************************************************************
105 * 90 *
106 * FUNCTION: acpi_get_sleep_type_data 91 * FUNCTION: acpi_read
107 * 92 *
108 * PARAMETERS: sleep_state - Numeric sleep state 93 * PARAMETERS: Value - Where the value is returned
109 * *sleep_type_a - Where SLP_TYPa is returned 94 * Reg - GAS register structure
110 * *sleep_type_b - Where SLP_TYPb is returned
111 * 95 *
112 * RETURN: Status - ACPI status 96 * RETURN: Status
113 * 97 *
114 * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep 98 * DESCRIPTION: Read from either memory or IO space.
115 * state.
116 * 99 *
117 ******************************************************************************/ 100 ******************************************************************************/
118 101acpi_status acpi_read(u32 *value, struct acpi_generic_address *reg)
119acpi_status
120acpi_get_sleep_type_data(u8 sleep_state, u8 * sleep_type_a, u8 * sleep_type_b)
121{ 102{
122 acpi_status status = AE_OK; 103 u32 width;
123 struct acpi_evaluate_info *info; 104 u64 address;
124 105 acpi_status status;
125 ACPI_FUNCTION_TRACE(acpi_get_sleep_type_data);
126
127 /* Validate parameters */
128
129 if ((sleep_state > ACPI_S_STATES_MAX) || !sleep_type_a || !sleep_type_b) {
130 return_ACPI_STATUS(AE_BAD_PARAMETER);
131 }
132 106
133 /* Allocate the evaluation information block */ 107 ACPI_FUNCTION_NAME(acpi_read);
134 108
135 info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info)); 109 /*
136 if (!info) { 110 * Must have a valid pointer to a GAS structure, and
137 return_ACPI_STATUS(AE_NO_MEMORY); 111 * a non-zero address within. However, don't return an error
112 * because the PM1A/B code must not fail if B isn't present.
113 */
114 if (!reg) {
115 return (AE_OK);
138 } 116 }
139 117
140 info->pathname = 118 /* Get a local copy of the address. Handles possible alignment issues */
141 ACPI_CAST_PTR(char, acpi_gbl_sleep_state_names[sleep_state]);
142
143 /* Evaluate the namespace object containing the values for this state */
144
145 status = acpi_ns_evaluate(info);
146 if (ACPI_FAILURE(status)) {
147 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
148 "%s while evaluating SleepState [%s]\n",
149 acpi_format_exception(status),
150 info->pathname));
151 119
152 goto cleanup; 120 ACPI_MOVE_64_TO_64(&address, &reg->address);
121 if (!address) {
122 return (AE_OK);
153 } 123 }
154 124
155 /* Must have a return object */ 125 /* Supported widths are 8/16/32 */
156 126
157 if (!info->return_object) { 127 width = reg->bit_width;
158 ACPI_ERROR((AE_INFO, "No Sleep State object returned from [%s]", 128 if ((width != 8) && (width != 16) && (width != 32)) {
159 info->pathname)); 129 return (AE_SUPPORT);
160 status = AE_NOT_EXIST;
161 } 130 }
162 131
163 /* It must be of type Package */ 132 /* Initialize entire 32-bit return value to zero */
164 133
165 else if (ACPI_GET_OBJECT_TYPE(info->return_object) != ACPI_TYPE_PACKAGE) { 134 *value = 0;
166 ACPI_ERROR((AE_INFO,
167 "Sleep State return object is not a Package"));
168 status = AE_AML_OPERAND_TYPE;
169 }
170 135
171 /* 136 /*
172 * The package must have at least two elements. NOTE (March 2005): This 137 * Two address spaces supported: Memory or IO.
173 * goes against the current ACPI spec which defines this object as a 138 * PCI_Config is not supported here because the GAS struct is insufficient
174 * package with one encoded DWORD element. However, existing practice
175 * by BIOS vendors seems to be to have 2 or more elements, at least
176 * one per sleep type (A/B).
177 */ 139 */
178 else if (info->return_object->package.count < 2) { 140 switch (reg->space_id) {
179 ACPI_ERROR((AE_INFO, 141 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
180 "Sleep State return package does not have at least two elements"));
181 status = AE_AML_NO_OPERAND;
182 }
183 142
184 /* The first two elements must both be of type Integer */ 143 status = acpi_os_read_memory((acpi_physical_address) address,
144 value, width);
145 break;
185 146
186 else if ((ACPI_GET_OBJECT_TYPE(info->return_object->package.elements[0]) 147 case ACPI_ADR_SPACE_SYSTEM_IO:
187 != ACPI_TYPE_INTEGER) ||
188 (ACPI_GET_OBJECT_TYPE(info->return_object->package.elements[1])
189 != ACPI_TYPE_INTEGER)) {
190 ACPI_ERROR((AE_INFO,
191 "Sleep State return package elements are not both Integers (%s, %s)",
192 acpi_ut_get_object_type_name(info->return_object->
193 package.elements[0]),
194 acpi_ut_get_object_type_name(info->return_object->
195 package.elements[1])));
196 status = AE_AML_OPERAND_TYPE;
197 } else {
198 /* Valid _Sx_ package size, type, and value */
199 148
200 *sleep_type_a = (u8) 149 status =
201 (info->return_object->package.elements[0])->integer.value; 150 acpi_os_read_port((acpi_io_address) address, value, width);
202 *sleep_type_b = (u8) 151 break;
203 (info->return_object->package.elements[1])->integer.value;
204 }
205 152
206 if (ACPI_FAILURE(status)) { 153 default:
207 ACPI_EXCEPTION((AE_INFO, status, 154 ACPI_ERROR((AE_INFO,
208 "While evaluating SleepState [%s], bad Sleep object %p type %s", 155 "Unsupported address space: %X", reg->space_id));
209 info->pathname, info->return_object, 156 return (AE_BAD_PARAMETER);
210 acpi_ut_get_object_type_name(info->
211 return_object)));
212 } 157 }
213 158
214 acpi_ut_remove_reference(info->return_object); 159 ACPI_DEBUG_PRINT((ACPI_DB_IO,
160 "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n",
161 *value, width, ACPI_FORMAT_UINT64(address),
162 acpi_ut_get_region_name(reg->space_id)));
215 163
216 cleanup: 164 return (status);
217 ACPI_FREE(info);
218 return_ACPI_STATUS(status);
219} 165}
220 166
221ACPI_EXPORT_SYMBOL(acpi_get_sleep_type_data) 167ACPI_EXPORT_SYMBOL(acpi_read)
222 168
223/******************************************************************************* 169/******************************************************************************
224 * 170 *
225 * FUNCTION: acpi_hw_get_register_bit_mask 171 * FUNCTION: acpi_write
226 * 172 *
227 * PARAMETERS: register_id - Index of ACPI Register to access 173 * PARAMETERS: Value - To be written
174 * Reg - GAS register structure
228 * 175 *
229 * RETURN: The bitmask to be used when accessing the register 176 * RETURN: Status
230 * 177 *
231 * DESCRIPTION: Map register_id into a register bitmask. 178 * DESCRIPTION: Write to either memory or IO space.
232 * 179 *
233 ******************************************************************************/ 180 ******************************************************************************/
234struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id) 181acpi_status acpi_write(u32 value, struct acpi_generic_address *reg)
235{ 182{
236 ACPI_FUNCTION_ENTRY(); 183 u32 width;
184 u64 address;
185 acpi_status status;
237 186
238 if (register_id > ACPI_BITREG_MAX) { 187 ACPI_FUNCTION_NAME(acpi_write);
239 ACPI_ERROR((AE_INFO, "Invalid BitRegister ID: %X", 188
240 register_id)); 189 /*
241 return (NULL); 190 * Must have a valid pointer to a GAS structure, and
191 * a non-zero address within. However, don't return an error
192 * because the PM1A/B code must not fail if B isn't present.
193 */
194 if (!reg) {
195 return (AE_OK);
242 } 196 }
243 197
244 return (&acpi_gbl_bit_register_info[register_id]); 198 /* Get a local copy of the address. Handles possible alignment issues */
199
200 ACPI_MOVE_64_TO_64(&address, &reg->address);
201 if (!address) {
202 return (AE_OK);
203 }
204
205 /* Supported widths are 8/16/32 */
206
207 width = reg->bit_width;
208 if ((width != 8) && (width != 16) && (width != 32)) {
209 return (AE_SUPPORT);
210 }
211
212 /*
213 * Two address spaces supported: Memory or IO.
214 * PCI_Config is not supported here because the GAS struct is insufficient
215 */
216 switch (reg->space_id) {
217 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
218
219 status = acpi_os_write_memory((acpi_physical_address) address,
220 value, width);
221 break;
222
223 case ACPI_ADR_SPACE_SYSTEM_IO:
224
225 status = acpi_os_write_port((acpi_io_address) address, value,
226 width);
227 break;
228
229 default:
230 ACPI_ERROR((AE_INFO,
231 "Unsupported address space: %X", reg->space_id));
232 return (AE_BAD_PARAMETER);
233 }
234
235 ACPI_DEBUG_PRINT((ACPI_DB_IO,
236 "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n",
237 value, width, ACPI_FORMAT_UINT64(address),
238 acpi_ut_get_region_name(reg->space_id)));
239
240 return (status);
245} 241}
246 242
243ACPI_EXPORT_SYMBOL(acpi_write)
244
247/******************************************************************************* 245/*******************************************************************************
248 * 246 *
249 * FUNCTION: acpi_get_register 247 * FUNCTION: acpi_get_register_unlocked
250 * 248 *
251 * PARAMETERS: register_id - ID of ACPI bit_register to access 249 * PARAMETERS: register_id - ID of ACPI bit_register to access
252 * return_value - Value that was read from the register 250 * return_value - Value that was read from the register
@@ -254,17 +252,16 @@ struct acpi_bit_register_info *acpi_hw_get_bit_register_info(u32 register_id)
254 * RETURN: Status and the value read from specified Register. Value 252 * RETURN: Status and the value read from specified Register. Value
255 * returned is normalized to bit0 (is shifted all the way right) 253 * returned is normalized to bit0 (is shifted all the way right)
256 * 254 *
257 * DESCRIPTION: ACPI bit_register read function. 255 * DESCRIPTION: ACPI bit_register read function. Does not acquire the HW lock.
258 * 256 *
259 ******************************************************************************/ 257 ******************************************************************************/
260 258acpi_status acpi_get_register_unlocked(u32 register_id, u32 *return_value)
261acpi_status acpi_get_register_unlocked(u32 register_id, u32 * return_value)
262{ 259{
263 u32 register_value = 0; 260 u32 register_value = 0;
264 struct acpi_bit_register_info *bit_reg_info; 261 struct acpi_bit_register_info *bit_reg_info;
265 acpi_status status; 262 acpi_status status;
266 263
267 ACPI_FUNCTION_TRACE(acpi_get_register); 264 ACPI_FUNCTION_TRACE(acpi_get_register_unlocked);
268 265
269 /* Get the info structure corresponding to the requested ACPI Register */ 266 /* Get the info structure corresponding to the requested ACPI Register */
270 267
@@ -296,14 +293,31 @@ acpi_status acpi_get_register_unlocked(u32 register_id, u32 * return_value)
296 return_ACPI_STATUS(status); 293 return_ACPI_STATUS(status);
297} 294}
298 295
299acpi_status acpi_get_register(u32 register_id, u32 * return_value) 296ACPI_EXPORT_SYMBOL(acpi_get_register_unlocked)
297
298/*******************************************************************************
299 *
300 * FUNCTION: acpi_get_register
301 *
302 * PARAMETERS: register_id - ID of ACPI bit_register to access
303 * return_value - Value that was read from the register
304 *
305 * RETURN: Status and the value read from specified Register. Value
306 * returned is normalized to bit0 (is shifted all the way right)
307 *
308 * DESCRIPTION: ACPI bit_register read function.
309 *
310 ******************************************************************************/
311acpi_status acpi_get_register(u32 register_id, u32 *return_value)
300{ 312{
301 acpi_status status; 313 acpi_status status;
302 acpi_cpu_flags flags; 314 acpi_cpu_flags flags;
315
303 flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); 316 flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock);
304 status = acpi_get_register_unlocked(register_id, return_value); 317 status = acpi_get_register_unlocked(register_id, return_value);
305 acpi_os_release_lock(acpi_gbl_hardware_lock, flags); 318 acpi_os_release_lock(acpi_gbl_hardware_lock, flags);
306 return status; 319
320 return (status);
307} 321}
308 322
309ACPI_EXPORT_SYMBOL(acpi_get_register) 323ACPI_EXPORT_SYMBOL(acpi_get_register)
@@ -370,8 +384,9 @@ acpi_status acpi_set_register(u32 register_id, u32 value)
370 bit_reg_info-> 384 bit_reg_info->
371 access_bit_mask); 385 access_bit_mask);
372 if (value) { 386 if (value) {
373 status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS, 387 status =
374 (u16) value); 388 acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS,
389 (u16) value);
375 register_value = 0; 390 register_value = 0;
376 } 391 }
377 break; 392 break;
@@ -459,399 +474,120 @@ acpi_status acpi_set_register(u32 register_id, u32 value)
459 474
460ACPI_EXPORT_SYMBOL(acpi_set_register) 475ACPI_EXPORT_SYMBOL(acpi_set_register)
461 476
462/****************************************************************************** 477/*******************************************************************************
463 * 478 *
464 * FUNCTION: acpi_hw_register_read 479 * FUNCTION: acpi_get_sleep_type_data
465 * 480 *
466 * PARAMETERS: register_id - ACPI Register ID 481 * PARAMETERS: sleep_state - Numeric sleep state
467 * return_value - Where the register value is returned 482 * *sleep_type_a - Where SLP_TYPa is returned
483 * *sleep_type_b - Where SLP_TYPb is returned
468 * 484 *
469 * RETURN: Status and the value read. 485 * RETURN: Status - ACPI status
470 * 486 *
471 * DESCRIPTION: Read from the specified ACPI register 487 * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep
488 * state.
472 * 489 *
473 ******************************************************************************/ 490 ******************************************************************************/
474acpi_status 491acpi_status
475acpi_hw_register_read(u32 register_id, u32 * return_value) 492acpi_get_sleep_type_data(u8 sleep_state, u8 *sleep_type_a, u8 *sleep_type_b)
476{ 493{
477 u32 value1 = 0; 494 acpi_status status = AE_OK;
478 u32 value2 = 0; 495 struct acpi_evaluate_info *info;
479 acpi_status status;
480
481 ACPI_FUNCTION_TRACE(hw_register_read);
482
483 switch (register_id) {
484 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
485
486 status =
487 acpi_hw_low_level_read(16, &value1,
488 &acpi_gbl_FADT.xpm1a_event_block);
489 if (ACPI_FAILURE(status)) {
490 goto exit;
491 }
492
493 /* PM1B is optional */
494
495 status =
496 acpi_hw_low_level_read(16, &value2,
497 &acpi_gbl_FADT.xpm1b_event_block);
498 value1 |= value2;
499 break;
500
501 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */
502
503 status =
504 acpi_hw_low_level_read(16, &value1, &acpi_gbl_xpm1a_enable);
505 if (ACPI_FAILURE(status)) {
506 goto exit;
507 }
508
509 /* PM1B is optional */
510
511 status =
512 acpi_hw_low_level_read(16, &value2, &acpi_gbl_xpm1b_enable);
513 value1 |= value2;
514 break;
515
516 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
517
518 status =
519 acpi_hw_low_level_read(16, &value1,
520 &acpi_gbl_FADT.xpm1a_control_block);
521 if (ACPI_FAILURE(status)) {
522 goto exit;
523 }
524
525 status =
526 acpi_hw_low_level_read(16, &value2,
527 &acpi_gbl_FADT.xpm1b_control_block);
528 value1 |= value2;
529 break;
530
531 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
532
533 status =
534 acpi_hw_low_level_read(8, &value1,
535 &acpi_gbl_FADT.xpm2_control_block);
536 break;
537
538 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
539
540 status =
541 acpi_hw_low_level_read(32, &value1,
542 &acpi_gbl_FADT.xpm_timer_block);
543 break;
544 496
545 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ 497 ACPI_FUNCTION_TRACE(acpi_get_sleep_type_data);
546 498
547 status = 499 /* Validate parameters */
548 acpi_os_read_port(acpi_gbl_FADT.smi_command, &value1, 8);
549 break;
550 500
551 default: 501 if ((sleep_state > ACPI_S_STATES_MAX) || !sleep_type_a || !sleep_type_b) {
552 ACPI_ERROR((AE_INFO, "Unknown Register ID: %X", register_id)); 502 return_ACPI_STATUS(AE_BAD_PARAMETER);
553 status = AE_BAD_PARAMETER;
554 break;
555 } 503 }
556 504
557 exit: 505 /* Allocate the evaluation information block */
558 506
559 if (ACPI_SUCCESS(status)) { 507 info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
560 *return_value = value1; 508 if (!info) {
509 return_ACPI_STATUS(AE_NO_MEMORY);
561 } 510 }
562 511
563 return_ACPI_STATUS(status); 512 info->pathname =
564} 513 ACPI_CAST_PTR(char, acpi_gbl_sleep_state_names[sleep_state]);
565
566/******************************************************************************
567 *
568 * FUNCTION: acpi_hw_register_write
569 *
570 * PARAMETERS: register_id - ACPI Register ID
571 * Value - The value to write
572 *
573 * RETURN: Status
574 *
575 * DESCRIPTION: Write to the specified ACPI register
576 *
577 * NOTE: In accordance with the ACPI specification, this function automatically
578 * preserves the value of the following bits, meaning that these bits cannot be
579 * changed via this interface:
580 *
581 * PM1_CONTROL[0] = SCI_EN
582 * PM1_CONTROL[9]
583 * PM1_STATUS[11]
584 *
585 * ACPI References:
586 * 1) Hardware Ignored Bits: When software writes to a register with ignored
587 * bit fields, it preserves the ignored bit fields
588 * 2) SCI_EN: OSPM always preserves this bit position
589 *
590 ******************************************************************************/
591
592acpi_status acpi_hw_register_write(u32 register_id, u32 value)
593{
594 acpi_status status;
595 u32 read_value;
596
597 ACPI_FUNCTION_TRACE(hw_register_write);
598
599 switch (register_id) {
600 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
601
602 /* Perform a read first to preserve certain bits (per ACPI spec) */
603
604 status = acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS,
605 &read_value);
606 if (ACPI_FAILURE(status)) {
607 goto exit;
608 }
609
610 /* Insert the bits to be preserved */
611
612 ACPI_INSERT_BITS(value, ACPI_PM1_STATUS_PRESERVED_BITS,
613 read_value);
614
615 /* Now we can write the data */
616
617 status =
618 acpi_hw_low_level_write(16, value,
619 &acpi_gbl_FADT.xpm1a_event_block);
620 if (ACPI_FAILURE(status)) {
621 goto exit;
622 }
623
624 /* PM1B is optional */
625
626 status =
627 acpi_hw_low_level_write(16, value,
628 &acpi_gbl_FADT.xpm1b_event_block);
629 break;
630
631 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */
632
633 status =
634 acpi_hw_low_level_write(16, value, &acpi_gbl_xpm1a_enable);
635 if (ACPI_FAILURE(status)) {
636 goto exit;
637 }
638
639 /* PM1B is optional */
640
641 status =
642 acpi_hw_low_level_write(16, value, &acpi_gbl_xpm1b_enable);
643 break;
644
645 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
646
647 /*
648 * Perform a read first to preserve certain bits (per ACPI spec)
649 */
650 status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
651 &read_value);
652 if (ACPI_FAILURE(status)) {
653 goto exit;
654 }
655
656 /* Insert the bits to be preserved */
657
658 ACPI_INSERT_BITS(value, ACPI_PM1_CONTROL_PRESERVED_BITS,
659 read_value);
660
661 /* Now we can write the data */
662
663 status =
664 acpi_hw_low_level_write(16, value,
665 &acpi_gbl_FADT.xpm1a_control_block);
666 if (ACPI_FAILURE(status)) {
667 goto exit;
668 }
669
670 status =
671 acpi_hw_low_level_write(16, value,
672 &acpi_gbl_FADT.xpm1b_control_block);
673 break;
674
675 case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */
676
677 status =
678 acpi_hw_low_level_write(16, value,
679 &acpi_gbl_FADT.xpm1a_control_block);
680 break;
681
682 case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */
683
684 status =
685 acpi_hw_low_level_write(16, value,
686 &acpi_gbl_FADT.xpm1b_control_block);
687 break;
688
689 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
690
691 status =
692 acpi_hw_low_level_write(8, value,
693 &acpi_gbl_FADT.xpm2_control_block);
694 break;
695
696 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
697
698 status =
699 acpi_hw_low_level_write(32, value,
700 &acpi_gbl_FADT.xpm_timer_block);
701 break;
702
703 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
704 514
705 /* SMI_CMD is currently always in IO space */ 515 /* Evaluate the namespace object containing the values for this state */
706 516
707 status = 517 status = acpi_ns_evaluate(info);
708 acpi_os_write_port(acpi_gbl_FADT.smi_command, value, 8); 518 if (ACPI_FAILURE(status)) {
709 break; 519 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
520 "%s while evaluating SleepState [%s]\n",
521 acpi_format_exception(status),
522 info->pathname));
710 523
711 default: 524 goto cleanup;
712 status = AE_BAD_PARAMETER;
713 break;
714 } 525 }
715 526
716 exit: 527 /* Must have a return object */
717 return_ACPI_STATUS(status);
718}
719
720/******************************************************************************
721 *
722 * FUNCTION: acpi_hw_low_level_read
723 *
724 * PARAMETERS: Width - 8, 16, or 32
725 * Value - Where the value is returned
726 * Reg - GAS register structure
727 *
728 * RETURN: Status
729 *
730 * DESCRIPTION: Read from either memory or IO space.
731 *
732 ******************************************************************************/
733
734acpi_status
735acpi_hw_low_level_read(u32 width, u32 * value, struct acpi_generic_address *reg)
736{
737 u64 address;
738 acpi_status status;
739
740 ACPI_FUNCTION_NAME(hw_low_level_read);
741 528
742 /* 529 if (!info->return_object) {
743 * Must have a valid pointer to a GAS structure, and 530 ACPI_ERROR((AE_INFO, "No Sleep State object returned from [%s]",
744 * a non-zero address within. However, don't return an error 531 info->pathname));
745 * because the PM1A/B code must not fail if B isn't present. 532 status = AE_NOT_EXIST;
746 */
747 if (!reg) {
748 return (AE_OK);
749 } 533 }
750 534
751 /* Get a local copy of the address. Handles possible alignment issues */ 535 /* It must be of type Package */
752 536
753 ACPI_MOVE_64_TO_64(&address, &reg->address); 537 else if (ACPI_GET_OBJECT_TYPE(info->return_object) != ACPI_TYPE_PACKAGE) {
754 if (!address) { 538 ACPI_ERROR((AE_INFO,
755 return (AE_OK); 539 "Sleep State return object is not a Package"));
540 status = AE_AML_OPERAND_TYPE;
756 } 541 }
757 *value = 0;
758 542
759 /* 543 /*
760 * Two address spaces supported: Memory or IO. 544 * The package must have at least two elements. NOTE (March 2005): This
761 * PCI_Config is not supported here because the GAS struct is insufficient 545 * goes against the current ACPI spec which defines this object as a
546 * package with one encoded DWORD element. However, existing practice
547 * by BIOS vendors seems to be to have 2 or more elements, at least
548 * one per sleep type (A/B).
762 */ 549 */
763 switch (reg->space_id) { 550 else if (info->return_object->package.count < 2) {
764 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
765
766 status = acpi_os_read_memory((acpi_physical_address) address,
767 value, width);
768 break;
769
770 case ACPI_ADR_SPACE_SYSTEM_IO:
771
772 status =
773 acpi_os_read_port((acpi_io_address) address, value, width);
774 break;
775
776 default:
777 ACPI_ERROR((AE_INFO, 551 ACPI_ERROR((AE_INFO,
778 "Unsupported address space: %X", reg->space_id)); 552 "Sleep State return package does not have at least two elements"));
779 return (AE_BAD_PARAMETER); 553 status = AE_AML_NO_OPERAND;
780 } 554 }
781 555
782 ACPI_DEBUG_PRINT((ACPI_DB_IO, 556 /* The first two elements must both be of type Integer */
783 "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n",
784 *value, width, ACPI_FORMAT_UINT64(address),
785 acpi_ut_get_region_name(reg->space_id)));
786
787 return (status);
788}
789
790/******************************************************************************
791 *
792 * FUNCTION: acpi_hw_low_level_write
793 *
794 * PARAMETERS: Width - 8, 16, or 32
795 * Value - To be written
796 * Reg - GAS register structure
797 *
798 * RETURN: Status
799 *
800 * DESCRIPTION: Write to either memory or IO space.
801 *
802 ******************************************************************************/
803
804acpi_status
805acpi_hw_low_level_write(u32 width, u32 value, struct acpi_generic_address * reg)
806{
807 u64 address;
808 acpi_status status;
809
810 ACPI_FUNCTION_NAME(hw_low_level_write);
811
812 /*
813 * Must have a valid pointer to a GAS structure, and
814 * a non-zero address within. However, don't return an error
815 * because the PM1A/B code must not fail if B isn't present.
816 */
817 if (!reg) {
818 return (AE_OK);
819 }
820 557
821 /* Get a local copy of the address. Handles possible alignment issues */ 558 else if ((ACPI_GET_OBJECT_TYPE(info->return_object->package.elements[0])
559 != ACPI_TYPE_INTEGER) ||
560 (ACPI_GET_OBJECT_TYPE(info->return_object->package.elements[1])
561 != ACPI_TYPE_INTEGER)) {
562 ACPI_ERROR((AE_INFO,
563 "Sleep State return package elements are not both Integers (%s, %s)",
564 acpi_ut_get_object_type_name(info->return_object->
565 package.elements[0]),
566 acpi_ut_get_object_type_name(info->return_object->
567 package.elements[1])));
568 status = AE_AML_OPERAND_TYPE;
569 } else {
570 /* Valid _Sx_ package size, type, and value */
822 571
823 ACPI_MOVE_64_TO_64(&address, &reg->address); 572 *sleep_type_a = (u8)
824 if (!address) { 573 (info->return_object->package.elements[0])->integer.value;
825 return (AE_OK); 574 *sleep_type_b = (u8)
575 (info->return_object->package.elements[1])->integer.value;
826 } 576 }
827 577
828 /* 578 if (ACPI_FAILURE(status)) {
829 * Two address spaces supported: Memory or IO. 579 ACPI_EXCEPTION((AE_INFO, status,
830 * PCI_Config is not supported here because the GAS struct is insufficient 580 "While evaluating SleepState [%s], bad Sleep object %p type %s",
831 */ 581 info->pathname, info->return_object,
832 switch (reg->space_id) { 582 acpi_ut_get_object_type_name(info->
833 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 583 return_object)));
834
835 status = acpi_os_write_memory((acpi_physical_address) address,
836 value, width);
837 break;
838
839 case ACPI_ADR_SPACE_SYSTEM_IO:
840
841 status = acpi_os_write_port((acpi_io_address) address, value,
842 width);
843 break;
844
845 default:
846 ACPI_ERROR((AE_INFO,
847 "Unsupported address space: %X", reg->space_id));
848 return (AE_BAD_PARAMETER);
849 } 584 }
850 585
851 ACPI_DEBUG_PRINT((ACPI_DB_IO, 586 acpi_ut_remove_reference(info->return_object);
852 "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n",
853 value, width, ACPI_FORMAT_UINT64(address),
854 acpi_ut_get_region_name(reg->space_id)));
855 587
856 return (status); 588 cleanup:
589 ACPI_FREE(info);
590 return_ACPI_STATUS(status);
857} 591}
592
593ACPI_EXPORT_SYMBOL(acpi_get_sleep_type_data)
diff --git a/drivers/acpi/namespace/nsaccess.c b/drivers/acpi/acpica/nsaccess.c
index c39a7f68b889..88303ebe924c 100644
--- a/drivers/acpi/namespace/nsaccess.c
+++ b/drivers/acpi/acpica/nsaccess.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/amlcode.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "amlcode.h"
47#include <acpi/acdispat.h> 47#include "acnamesp.h"
48#include "acdispat.h"
48 49
49#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
50ACPI_MODULE_NAME("nsaccess") 51ACPI_MODULE_NAME("nsaccess")
@@ -165,12 +166,9 @@ acpi_status acpi_ns_root_initialize(void)
165 166
166 obj_desc->method.method_flags = 167 obj_desc->method.method_flags =
167 AML_METHOD_INTERNAL_ONLY; 168 AML_METHOD_INTERNAL_ONLY;
168
169#ifndef ACPI_DUMP_APP
170 obj_desc->method.implementation = 169 obj_desc->method.implementation =
171 acpi_ut_osi_implementation; 170 acpi_ut_osi_implementation;
172#endif 171#endif
173#endif
174 break; 172 break;
175 173
176 case ACPI_TYPE_INTEGER: 174 case ACPI_TYPE_INTEGER:
@@ -521,11 +519,11 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
521 } 519 }
522 520
523 /* 521 /*
524 * Search namespace for each segment of the name. Loop through and 522 * Search namespace for each segment of the name. Loop through and
525 * verify (or add to the namespace) each name segment. 523 * verify (or add to the namespace) each name segment.
526 * 524 *
527 * The object type is significant only at the last name 525 * The object type is significant only at the last name
528 * segment. (We don't care about the types along the path, only 526 * segment. (We don't care about the types along the path, only
529 * the type of the final target object.) 527 * the type of the final target object.)
530 */ 528 */
531 this_search_type = ACPI_TYPE_ANY; 529 this_search_type = ACPI_TYPE_ANY;
@@ -591,6 +589,10 @@ acpi_ns_lookup(union acpi_generic_state *scope_info,
591 * segments). 589 * segments).
592 */ 590 */
593 if (this_node->type == ACPI_TYPE_LOCAL_ALIAS) { 591 if (this_node->type == ACPI_TYPE_LOCAL_ALIAS) {
592 if (!this_node->object) {
593 return_ACPI_STATUS(AE_NOT_EXIST);
594 }
595
594 if (acpi_ns_opens_scope 596 if (acpi_ns_opens_scope
595 (((struct acpi_namespace_node *)this_node-> 597 (((struct acpi_namespace_node *)this_node->
596 object)->type)) { 598 object)->type)) {
diff --git a/drivers/acpi/namespace/nsalloc.c b/drivers/acpi/acpica/nsalloc.c
index 3a1740ac2edc..f976d848fe82 100644
--- a/drivers/acpi/namespace/nsalloc.c
+++ b/drivers/acpi/acpica/nsalloc.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include "acnamesp.h"
46 47
47#define _COMPONENT ACPI_NAMESPACE 48#define _COMPONENT ACPI_NAMESPACE
48ACPI_MODULE_NAME("nsalloc") 49ACPI_MODULE_NAME("nsalloc")
diff --git a/drivers/acpi/namespace/nsdump.c b/drivers/acpi/acpica/nsdump.c
index cc0ae39440e4..0da33c8e9ba2 100644
--- a/drivers/acpi/namespace/nsdump.c
+++ b/drivers/acpi/acpica/nsdump.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include "acnamesp.h"
46 47
47#define _COMPONENT ACPI_NAMESPACE 48#define _COMPONENT ACPI_NAMESPACE
48ACPI_MODULE_NAME("nsdump") 49ACPI_MODULE_NAME("nsdump")
diff --git a/drivers/acpi/namespace/nsdumpdv.c b/drivers/acpi/acpica/nsdumpdv.c
index 428f50fde11a..41994fe7fbb8 100644
--- a/drivers/acpi/namespace/nsdumpdv.c
+++ b/drivers/acpi/acpica/nsdumpdv.c
@@ -42,6 +42,7 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include "accommon.h"
45 46
46/* TBD: This entire module is apparently obsolete and should be removed */ 47/* TBD: This entire module is apparently obsolete and should be removed */
47 48
@@ -49,7 +50,7 @@
49ACPI_MODULE_NAME("nsdumpdv") 50ACPI_MODULE_NAME("nsdumpdv")
50#ifdef ACPI_OBSOLETE_FUNCTIONS 51#ifdef ACPI_OBSOLETE_FUNCTIONS
51#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 52#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
52#include <acpi/acnamesp.h> 53#include "acnamesp.h"
53/******************************************************************************* 54/*******************************************************************************
54 * 55 *
55 * FUNCTION: acpi_ns_dump_one_device 56 * FUNCTION: acpi_ns_dump_one_device
diff --git a/drivers/acpi/namespace/nseval.c b/drivers/acpi/acpica/nseval.c
index 4cdf03ac2b46..0f3d5f9b5966 100644
--- a/drivers/acpi/namespace/nseval.c
+++ b/drivers/acpi/acpica/nseval.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include <acpi/acinterp.h> 46#include "acparser.h"
47#include <acpi/acnamesp.h> 47#include "acinterp.h"
48#include "acnamesp.h"
48 49
49#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
50ACPI_MODULE_NAME("nseval") 51ACPI_MODULE_NAME("nseval")
@@ -89,6 +90,7 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
89 /* Initialize the return value to an invalid object */ 90 /* Initialize the return value to an invalid object */
90 91
91 info->return_object = NULL; 92 info->return_object = NULL;
93 info->param_count = 0;
92 94
93 /* 95 /*
94 * Get the actual namespace node for the target object. Handles these cases: 96 * Get the actual namespace node for the target object. Handles these cases:
@@ -141,41 +143,17 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
141 return_ACPI_STATUS(AE_NULL_OBJECT); 143 return_ACPI_STATUS(AE_NULL_OBJECT);
142 } 144 }
143 145
144 /* 146 /* Count the number of arguments being passed to the method */
145 * Calculate the number of arguments being passed to the method
146 */
147 147
148 info->param_count = 0;
149 if (info->parameters) { 148 if (info->parameters) {
150 while (info->parameters[info->param_count]) 149 while (info->parameters[info->param_count]) {
150 if (info->param_count > ACPI_METHOD_MAX_ARG) {
151 return_ACPI_STATUS(AE_LIMIT);
152 }
151 info->param_count++; 153 info->param_count++;
154 }
152 } 155 }
153 156
154 /*
155 * Warning if too few or too many arguments have been passed by the
156 * caller. We don't want to abort here with an error because an
157 * incorrect number of arguments may not cause the method to fail.
158 * However, the method will fail if there are too few arguments passed
159 * and the method attempts to use one of the missing ones.
160 */
161
162 if (info->param_count < info->obj_desc->method.param_count) {
163 ACPI_WARNING((AE_INFO,
164 "Insufficient arguments - "
165 "method [%4.4s] needs %d, found %d",
166 acpi_ut_get_node_name(info->resolved_node),
167 info->obj_desc->method.param_count,
168 info->param_count));
169 } else if (info->param_count >
170 info->obj_desc->method.param_count) {
171 ACPI_WARNING((AE_INFO,
172 "Excess arguments - "
173 "method [%4.4s] needs %d, found %d",
174 acpi_ut_get_node_name(info->
175 resolved_node),
176 info->obj_desc->method.param_count,
177 info->param_count));
178 }
179 157
180 ACPI_DUMP_PATHNAME(info->resolved_node, "Execute Method:", 158 ACPI_DUMP_PATHNAME(info->resolved_node, "Execute Method:",
181 ACPI_LV_INFO, _COMPONENT); 159 ACPI_LV_INFO, _COMPONENT);
@@ -264,32 +242,13 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
264 } 242 }
265 } 243 }
266 244
267 /* Validation of return values for ACPI-predefined methods and objects */ 245 /*
268 246 * Check input argument count against the ASL-defined count for a method.
269 if ((status == AE_OK) || (status == AE_CTRL_RETURN_VALUE)) { 247 * Also check predefined names: argument count and return value against
270 /* 248 * the ACPI specification. Some incorrect return value types are repaired.
271 * If this is the first evaluation, check the return value. This 249 */
272 * ensures that any warnings will only be emitted during the very 250 (void)acpi_ns_check_predefined_names(node, info->param_count,
273 * first evaluation of the object. 251 status, &info->return_object);
274 */
275 if (!(node->flags & ANOBJ_EVALUATED)) {
276 /*
277 * Check for a predefined ACPI name. If found, validate the
278 * returned object.
279 *
280 * Note: Ignore return status for now, emit warnings if there are
281 * problems with the returned object. May change later to abort
282 * the method on invalid return object.
283 */
284 (void)acpi_ns_check_predefined_names(node,
285 info->
286 return_object);
287 }
288
289 /* Mark the node as having been evaluated */
290
291 node->flags |= ANOBJ_EVALUATED;
292 }
293 252
294 /* Check if there is a return value that must be dealt with */ 253 /* Check if there is a return value that must be dealt with */
295 254
diff --git a/drivers/acpi/namespace/nsinit.c b/drivers/acpi/acpica/nsinit.c
index e4c57510d798..13501cb81863 100644
--- a/drivers/acpi/namespace/nsinit.c
+++ b/drivers/acpi/acpica/nsinit.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include <acpi/acdispat.h> 46#include "acnamesp.h"
47#include <acpi/acinterp.h> 47#include "acdispat.h"
48#include "acinterp.h"
48#include <linux/nmi.h> 49#include <linux/nmi.h>
49 50
50#define _COMPONENT ACPI_NAMESPACE 51#define _COMPONENT ACPI_NAMESPACE
diff --git a/drivers/acpi/namespace/nsload.c b/drivers/acpi/acpica/nsload.c
index a4a412b7c029..a0ba9e12379e 100644
--- a/drivers/acpi/namespace/nsload.c
+++ b/drivers/acpi/acpica/nsload.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include <acpi/acdispat.h> 46#include "acnamesp.h"
47#include <acpi/actables.h> 47#include "acdispat.h"
48#include "actables.h"
48 49
49#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
50ACPI_MODULE_NAME("nsload") 51ACPI_MODULE_NAME("nsload")
diff --git a/drivers/acpi/namespace/nsnames.c b/drivers/acpi/acpica/nsnames.c
index 42a39a7c96e9..ae3dc10a7e81 100644
--- a/drivers/acpi/namespace/nsnames.c
+++ b/drivers/acpi/acpica/nsnames.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/amlcode.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "amlcode.h"
47#include "acnamesp.h"
47 48
48#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
49ACPI_MODULE_NAME("nsnames") 50ACPI_MODULE_NAME("nsnames")
diff --git a/drivers/acpi/namespace/nsobject.c b/drivers/acpi/acpica/nsobject.c
index 15fe09e24f71..08a97a57f8f9 100644
--- a/drivers/acpi/namespace/nsobject.c
+++ b/drivers/acpi/acpica/nsobject.c
@@ -43,7 +43,8 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 46#include "accommon.h"
47#include "acnamesp.h"
47 48
48#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
49ACPI_MODULE_NAME("nsobject") 50ACPI_MODULE_NAME("nsobject")
diff --git a/drivers/acpi/namespace/nsparse.c b/drivers/acpi/acpica/nsparse.c
index a82271a9dbb3..b9e8d0070b6f 100644
--- a/drivers/acpi/namespace/nsparse.c
+++ b/drivers/acpi/acpica/nsparse.c
@@ -42,10 +42,11 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include <acpi/acparser.h> 46#include "acnamesp.h"
47#include <acpi/acdispat.h> 47#include "acparser.h"
48#include <acpi/actables.h> 48#include "acdispat.h"
49#include "actables.h"
49 50
50#define _COMPONENT ACPI_NAMESPACE 51#define _COMPONENT ACPI_NAMESPACE
51ACPI_MODULE_NAME("nsparse") 52ACPI_MODULE_NAME("nsparse")
diff --git a/drivers/acpi/namespace/nspredef.c b/drivers/acpi/acpica/nspredef.c
index 0f17cf0898c9..452703290d35 100644
--- a/drivers/acpi/namespace/nspredef.c
+++ b/drivers/acpi/acpica/nspredef.c
@@ -43,8 +43,9 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 46#include "accommon.h"
47#include <acpi/acpredef.h> 47#include "acnamesp.h"
48#include "acpredef.h"
48 49
49#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
50ACPI_MODULE_NAME("nspredef") 51ACPI_MODULE_NAME("nspredef")
@@ -72,7 +73,7 @@ ACPI_MODULE_NAME("nspredef")
72/* Local prototypes */ 73/* Local prototypes */
73static acpi_status 74static acpi_status
74acpi_ns_check_package(char *pathname, 75acpi_ns_check_package(char *pathname,
75 union acpi_operand_object *return_object, 76 union acpi_operand_object **return_object_ptr,
76 const union acpi_predefined_info *predefined); 77 const union acpi_predefined_info *predefined);
77 78
78static acpi_status 79static acpi_status
@@ -82,13 +83,18 @@ acpi_ns_check_package_elements(char *pathname,
82 83
83static acpi_status 84static acpi_status
84acpi_ns_check_object_type(char *pathname, 85acpi_ns_check_object_type(char *pathname,
85 union acpi_operand_object *return_object, 86 union acpi_operand_object **return_object_ptr,
86 u32 expected_btypes, u32 package_index); 87 u32 expected_btypes, u32 package_index);
87 88
88static acpi_status 89static acpi_status
89acpi_ns_check_reference(char *pathname, 90acpi_ns_check_reference(char *pathname,
90 union acpi_operand_object *return_object); 91 union acpi_operand_object *return_object);
91 92
93static acpi_status
94acpi_ns_repair_object(u32 expected_btypes,
95 u32 package_index,
96 union acpi_operand_object **return_object_ptr);
97
92/* 98/*
93 * Names for the types that can be returned by the predefined objects. 99 * Names for the types that can be returned by the predefined objects.
94 * Used for warning messages. Must be in the same order as the ACPI_RTYPEs 100 * Used for warning messages. Must be in the same order as the ACPI_RTYPEs
@@ -108,8 +114,8 @@ static const char *acpi_rtype_names[] = {
108 * FUNCTION: acpi_ns_check_predefined_names 114 * FUNCTION: acpi_ns_check_predefined_names
109 * 115 *
110 * PARAMETERS: Node - Namespace node for the method/object 116 * PARAMETERS: Node - Namespace node for the method/object
111 * return_object - Object returned from the evaluation of this 117 * return_object_ptr - Pointer to the object returned from the
112 * method/object 118 * evaluation of a method or object
113 * 119 *
114 * RETURN: Status 120 * RETURN: Status
115 * 121 *
@@ -119,8 +125,11 @@ static const char *acpi_rtype_names[] = {
119 125
120acpi_status 126acpi_status
121acpi_ns_check_predefined_names(struct acpi_namespace_node *node, 127acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
122 union acpi_operand_object *return_object) 128 u32 user_param_count,
129 acpi_status return_status,
130 union acpi_operand_object **return_object_ptr)
123{ 131{
132 union acpi_operand_object *return_object = *return_object_ptr;
124 acpi_status status = AE_OK; 133 acpi_status status = AE_OK;
125 const union acpi_predefined_info *predefined; 134 const union acpi_predefined_info *predefined;
126 char *pathname; 135 char *pathname;
@@ -128,12 +137,6 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
128 /* Match the name for this method/object against the predefined list */ 137 /* Match the name for this method/object against the predefined list */
129 138
130 predefined = acpi_ns_check_for_predefined_name(node); 139 predefined = acpi_ns_check_for_predefined_name(node);
131 if (!predefined) {
132
133 /* Name was not one of the predefined names */
134
135 return (AE_OK);
136 }
137 140
138 /* Get the full pathname to the object, for use in error messages */ 141 /* Get the full pathname to the object, for use in error messages */
139 142
@@ -143,10 +146,37 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
143 } 146 }
144 147
145 /* 148 /*
146 * Check that the parameter count for this method is in accordance 149 * Check that the parameter count for this method matches the ASL
147 * with the ACPI specification. 150 * definition. For predefined names, ensure that both the caller and
151 * the method itself are in accordance with the ACPI specification.
148 */ 152 */
149 acpi_ns_check_parameter_count(pathname, node, predefined); 153 acpi_ns_check_parameter_count(pathname, node, user_param_count,
154 predefined);
155
156 /* If not a predefined name, we cannot validate the return object */
157
158 if (!predefined) {
159 goto exit;
160 }
161
162 /* If the method failed, we cannot validate the return object */
163
164 if ((return_status != AE_OK) && (return_status != AE_CTRL_RETURN_VALUE)) {
165 goto exit;
166 }
167
168 /*
169 * Only validate the return value on the first successful evaluation of
170 * the method. This ensures that any warnings will only be emitted during
171 * the very first evaluation of the method/object.
172 */
173 if (node->flags & ANOBJ_EVALUATED) {
174 goto exit;
175 }
176
177 /* Mark the node as having been successfully evaluated */
178
179 node->flags |= ANOBJ_EVALUATED;
150 180
151 /* 181 /*
152 * If there is no return value, check if we require a return value for 182 * If there is no return value, check if we require a return value for
@@ -171,7 +201,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
171 * We have a return value, but if one wasn't expected, just exit, this is 201 * We have a return value, but if one wasn't expected, just exit, this is
172 * not a problem 202 * not a problem
173 * 203 *
174 * For example, if "Implicit return value" is enabled, methods will 204 * For example, if the "Implicit Return" feature is enabled, methods will
175 * always return a value 205 * always return a value
176 */ 206 */
177 if (!predefined->info.expected_btypes) { 207 if (!predefined->info.expected_btypes) {
@@ -182,7 +212,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
182 * Check that the type of the return object is what is expected for 212 * Check that the type of the return object is what is expected for
183 * this predefined name 213 * this predefined name
184 */ 214 */
185 status = acpi_ns_check_object_type(pathname, return_object, 215 status = acpi_ns_check_object_type(pathname, return_object_ptr,
186 predefined->info.expected_btypes, 216 predefined->info.expected_btypes,
187 ACPI_NOT_PACKAGE); 217 ACPI_NOT_PACKAGE);
188 if (ACPI_FAILURE(status)) { 218 if (ACPI_FAILURE(status)) {
@@ -193,11 +223,12 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
193 223
194 if (ACPI_GET_OBJECT_TYPE(return_object) == ACPI_TYPE_PACKAGE) { 224 if (ACPI_GET_OBJECT_TYPE(return_object) == ACPI_TYPE_PACKAGE) {
195 status = 225 status =
196 acpi_ns_check_package(pathname, return_object, predefined); 226 acpi_ns_check_package(pathname, return_object_ptr,
227 predefined);
197 } 228 }
198 229
199 exit: 230 exit:
200 if (pathname) { 231 if (pathname != predefined->info.name) {
201 ACPI_FREE(pathname); 232 ACPI_FREE(pathname);
202 } 233 }
203 234
@@ -210,6 +241,7 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
210 * 241 *
211 * PARAMETERS: Pathname - Full pathname to the node (for error msgs) 242 * PARAMETERS: Pathname - Full pathname to the node (for error msgs)
212 * Node - Namespace node for the method/object 243 * Node - Namespace node for the method/object
244 * user_param_count - Number of args passed in by the caller
213 * Predefined - Pointer to entry in predefined name table 245 * Predefined - Pointer to entry in predefined name table
214 * 246 *
215 * RETURN: None 247 * RETURN: None
@@ -223,32 +255,76 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
223void 255void
224acpi_ns_check_parameter_count(char *pathname, 256acpi_ns_check_parameter_count(char *pathname,
225 struct acpi_namespace_node *node, 257 struct acpi_namespace_node *node,
258 u32 user_param_count,
226 const union acpi_predefined_info *predefined) 259 const union acpi_predefined_info *predefined)
227{ 260{
228 u32 param_count; 261 u32 param_count;
229 u32 required_params_current; 262 u32 required_params_current;
230 u32 required_params_old; 263 u32 required_params_old;
231 264
232 /* 265 /* Methods have 0-7 parameters. All other types have zero. */
233 * Check that the ASL-defined parameter count is what is expected for 266
234 * this predefined name.
235 *
236 * Methods have 0-7 parameters. All other types have zero.
237 */
238 param_count = 0; 267 param_count = 0;
239 if (node->type == ACPI_TYPE_METHOD) { 268 if (node->type == ACPI_TYPE_METHOD) {
240 param_count = node->object->method.param_count; 269 param_count = node->object->method.param_count;
241 } 270 }
242 271
243 /* Validate parameter count - allow two different legal counts (_SCP) */ 272 /* Argument count check for non-predefined methods/objects */
273
274 if (!predefined) {
275 /*
276 * Warning if too few or too many arguments have been passed by the
277 * caller. An incorrect number of arguments may not cause the method
278 * to fail. However, the method will fail if there are too few
279 * arguments and the method attempts to use one of the missing ones.
280 */
281 if (user_param_count < param_count) {
282 ACPI_WARNING((AE_INFO,
283 "%s: Insufficient arguments - needs %d, found %d",
284 pathname, param_count, user_param_count));
285 } else if (user_param_count > param_count) {
286 ACPI_WARNING((AE_INFO,
287 "%s: Excess arguments - needs %d, found %d",
288 pathname, param_count, user_param_count));
289 }
290 return;
291 }
292
293 /* Allow two different legal argument counts (_SCP, etc.) */
244 294
245 required_params_current = predefined->info.param_count & 0x0F; 295 required_params_current = predefined->info.param_count & 0x0F;
246 required_params_old = predefined->info.param_count >> 4; 296 required_params_old = predefined->info.param_count >> 4;
247 297
298 if (user_param_count != ACPI_UINT32_MAX) {
299
300 /* Validate the user-supplied parameter count */
301
302 if ((user_param_count != required_params_current) &&
303 (user_param_count != required_params_old)) {
304 ACPI_WARNING((AE_INFO,
305 "%s: Parameter count mismatch - caller passed %d, ACPI requires %d",
306 pathname, user_param_count,
307 required_params_current));
308 }
309 }
310
311 /*
312 * Only validate the argument count on the first successful evaluation of
313 * the method. This ensures that any warnings will only be emitted during
314 * the very first evaluation of the method/object.
315 */
316 if (node->flags & ANOBJ_EVALUATED) {
317 return;
318 }
319
320 /*
321 * Check that the ASL-defined parameter count is what is expected for
322 * this predefined name.
323 */
248 if ((param_count != required_params_current) && 324 if ((param_count != required_params_current) &&
249 (param_count != required_params_old)) { 325 (param_count != required_params_old)) {
250 ACPI_WARNING((AE_INFO, 326 ACPI_WARNING((AE_INFO,
251 "%s: Parameter count mismatch - ASL declared %d, expected %d", 327 "%s: Parameter count mismatch - ASL declared %d, ACPI requires %d",
252 pathname, param_count, required_params_current)); 328 pathname, param_count, required_params_current));
253 } 329 }
254} 330}
@@ -307,8 +383,8 @@ const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct
307 * FUNCTION: acpi_ns_check_package 383 * FUNCTION: acpi_ns_check_package
308 * 384 *
309 * PARAMETERS: Pathname - Full pathname to the node (for error msgs) 385 * PARAMETERS: Pathname - Full pathname to the node (for error msgs)
310 * return_object - Object returned from the evaluation of a 386 * return_object_ptr - Pointer to the object returned from the
311 * method or object 387 * evaluation of a method or object
312 * Predefined - Pointer to entry in predefined name table 388 * Predefined - Pointer to entry in predefined name table
313 * 389 *
314 * RETURN: Status 390 * RETURN: Status
@@ -320,9 +396,10 @@ const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct
320 396
321static acpi_status 397static acpi_status
322acpi_ns_check_package(char *pathname, 398acpi_ns_check_package(char *pathname,
323 union acpi_operand_object *return_object, 399 union acpi_operand_object **return_object_ptr,
324 const union acpi_predefined_info *predefined) 400 const union acpi_predefined_info *predefined)
325{ 401{
402 union acpi_operand_object *return_object = *return_object_ptr;
326 const union acpi_predefined_info *package; 403 const union acpi_predefined_info *package;
327 union acpi_operand_object *sub_package; 404 union acpi_operand_object *sub_package;
328 union acpi_operand_object **elements; 405 union acpi_operand_object **elements;
@@ -408,7 +485,7 @@ acpi_ns_check_package(char *pathname,
408 * elements must be of the same type 485 * elements must be of the same type
409 */ 486 */
410 for (i = 0; i < count; i++) { 487 for (i = 0; i < count; i++) {
411 status = acpi_ns_check_object_type(pathname, *elements, 488 status = acpi_ns_check_object_type(pathname, elements,
412 package->ret_info. 489 package->ret_info.
413 object_type1, i); 490 object_type1, i);
414 if (ACPI_FAILURE(status)) { 491 if (ACPI_FAILURE(status)) {
@@ -441,7 +518,7 @@ acpi_ns_check_package(char *pathname,
441 518
442 status = 519 status =
443 acpi_ns_check_object_type(pathname, 520 acpi_ns_check_object_type(pathname,
444 *elements, 521 elements,
445 package-> 522 package->
446 ret_info3. 523 ret_info3.
447 object_type[i], 524 object_type[i],
@@ -454,7 +531,7 @@ acpi_ns_check_package(char *pathname,
454 531
455 status = 532 status =
456 acpi_ns_check_object_type(pathname, 533 acpi_ns_check_object_type(pathname,
457 *elements, 534 elements,
458 package-> 535 package->
459 ret_info3. 536 ret_info3.
460 tail_object_type, 537 tail_object_type,
@@ -471,7 +548,7 @@ acpi_ns_check_package(char *pathname,
471 548
472 /* First element is the (Integer) count of sub-packages to follow */ 549 /* First element is the (Integer) count of sub-packages to follow */
473 550
474 status = acpi_ns_check_object_type(pathname, *elements, 551 status = acpi_ns_check_object_type(pathname, elements,
475 ACPI_RTYPE_INTEGER, 0); 552 ACPI_RTYPE_INTEGER, 0);
476 if (ACPI_FAILURE(status)) { 553 if (ACPI_FAILURE(status)) {
477 return (status); 554 return (status);
@@ -509,7 +586,7 @@ acpi_ns_check_package(char *pathname,
509 /* Each sub-object must be of type Package */ 586 /* Each sub-object must be of type Package */
510 587
511 status = 588 status =
512 acpi_ns_check_object_type(pathname, sub_package, 589 acpi_ns_check_object_type(pathname, &sub_package,
513 ACPI_RTYPE_PACKAGE, i); 590 ACPI_RTYPE_PACKAGE, i);
514 if (ACPI_FAILURE(status)) { 591 if (ACPI_FAILURE(status)) {
515 return (status); 592 return (status);
@@ -567,12 +644,8 @@ acpi_ns_check_package(char *pathname,
567 for (j = 0; j < expected_count; j++) { 644 for (j = 0; j < expected_count; j++) {
568 status = 645 status =
569 acpi_ns_check_object_type(pathname, 646 acpi_ns_check_object_type(pathname,
570 sub_elements 647 &sub_elements[j],
571 [j], 648 package->ret_info2.object_type[j], j);
572 package->
573 ret_info2.
574 object_type
575 [j], j);
576 if (ACPI_FAILURE(status)) { 649 if (ACPI_FAILURE(status)) {
577 return (status); 650 return (status);
578 } 651 }
@@ -611,7 +684,7 @@ acpi_ns_check_package(char *pathname,
611 684
612 status = 685 status =
613 acpi_ns_check_object_type(pathname, 686 acpi_ns_check_object_type(pathname,
614 *sub_elements, 687 sub_elements,
615 ACPI_RTYPE_INTEGER, 688 ACPI_RTYPE_INTEGER,
616 0); 689 0);
617 if (ACPI_FAILURE(status)) { 690 if (ACPI_FAILURE(status)) {
@@ -708,7 +781,7 @@ acpi_ns_check_package_elements(char *pathname,
708 * The second group can have a count of zero. 781 * The second group can have a count of zero.
709 */ 782 */
710 for (i = 0; i < count1; i++) { 783 for (i = 0; i < count1; i++) {
711 status = acpi_ns_check_object_type(pathname, *this_element, 784 status = acpi_ns_check_object_type(pathname, this_element,
712 type1, i); 785 type1, i);
713 if (ACPI_FAILURE(status)) { 786 if (ACPI_FAILURE(status)) {
714 return (status); 787 return (status);
@@ -717,7 +790,7 @@ acpi_ns_check_package_elements(char *pathname,
717 } 790 }
718 791
719 for (i = 0; i < count2; i++) { 792 for (i = 0; i < count2; i++) {
720 status = acpi_ns_check_object_type(pathname, *this_element, 793 status = acpi_ns_check_object_type(pathname, this_element,
721 type2, (i + count1)); 794 type2, (i + count1));
722 if (ACPI_FAILURE(status)) { 795 if (ACPI_FAILURE(status)) {
723 return (status); 796 return (status);
@@ -733,8 +806,8 @@ acpi_ns_check_package_elements(char *pathname,
733 * FUNCTION: acpi_ns_check_object_type 806 * FUNCTION: acpi_ns_check_object_type
734 * 807 *
735 * PARAMETERS: Pathname - Full pathname to the node (for error msgs) 808 * PARAMETERS: Pathname - Full pathname to the node (for error msgs)
736 * return_object - Object return from the execution of this 809 * return_object_ptr - Pointer to the object returned from the
737 * method/object 810 * evaluation of a method or object
738 * expected_btypes - Bitmap of expected return type(s) 811 * expected_btypes - Bitmap of expected return type(s)
739 * package_index - Index of object within parent package (if 812 * package_index - Index of object within parent package (if
740 * applicable - ACPI_NOT_PACKAGE otherwise) 813 * applicable - ACPI_NOT_PACKAGE otherwise)
@@ -748,9 +821,10 @@ acpi_ns_check_package_elements(char *pathname,
748 821
749static acpi_status 822static acpi_status
750acpi_ns_check_object_type(char *pathname, 823acpi_ns_check_object_type(char *pathname,
751 union acpi_operand_object *return_object, 824 union acpi_operand_object **return_object_ptr,
752 u32 expected_btypes, u32 package_index) 825 u32 expected_btypes, u32 package_index)
753{ 826{
827 union acpi_operand_object *return_object = *return_object_ptr;
754 acpi_status status = AE_OK; 828 acpi_status status = AE_OK;
755 u32 return_btype; 829 u32 return_btype;
756 char type_buffer[48]; /* Room for 5 types */ 830 char type_buffer[48]; /* Room for 5 types */
@@ -814,6 +888,14 @@ acpi_ns_check_object_type(char *pathname,
814 /* Is the object one of the expected types? */ 888 /* Is the object one of the expected types? */
815 889
816 if (!(return_btype & expected_btypes)) { 890 if (!(return_btype & expected_btypes)) {
891
892 /* Type mismatch -- attempt repair of the returned object */
893
894 status = acpi_ns_repair_object(expected_btypes, package_index,
895 return_object_ptr);
896 if (ACPI_SUCCESS(status)) {
897 return (status);
898 }
817 goto type_error_exit; 899 goto type_error_exit;
818 } 900 }
819 901
@@ -898,3 +980,86 @@ acpi_ns_check_reference(char *pathname,
898 980
899 return (AE_AML_OPERAND_TYPE); 981 return (AE_AML_OPERAND_TYPE);
900} 982}
983
984/*******************************************************************************
985 *
986 * FUNCTION: acpi_ns_repair_object
987 *
988 * PARAMETERS: Pathname - Full pathname to the node (for error msgs)
989 * package_index - Used to determine if target is in a package
990 * return_object_ptr - Pointer to the object returned from the
991 * evaluation of a method or object
992 *
993 * RETURN: Status. AE_OK if repair was successful.
994 *
995 * DESCRIPTION: Attempt to repair/convert a return object of a type that was
996 * not expected.
997 *
998 ******************************************************************************/
999
1000static acpi_status
1001acpi_ns_repair_object(u32 expected_btypes,
1002 u32 package_index,
1003 union acpi_operand_object **return_object_ptr)
1004{
1005 union acpi_operand_object *return_object = *return_object_ptr;
1006 union acpi_operand_object *new_object;
1007 acpi_size length;
1008
1009 switch (ACPI_GET_OBJECT_TYPE(return_object)) {
1010 case ACPI_TYPE_BUFFER:
1011
1012 if (!(expected_btypes & ACPI_RTYPE_STRING)) {
1013 return (AE_AML_OPERAND_TYPE);
1014 }
1015
1016 /*
1017 * Have a Buffer, expected a String, convert. Use a to_string
1018 * conversion, no transform performed on the buffer data. The best
1019 * example of this is the _BIF method, where the string data from
1020 * the battery is often (incorrectly) returned as buffer object(s).
1021 */
1022 length = 0;
1023 while ((length < return_object->buffer.length) &&
1024 (return_object->buffer.pointer[length])) {
1025 length++;
1026 }
1027
1028 /* Allocate a new string object */
1029
1030 new_object = acpi_ut_create_string_object(length);
1031 if (!new_object) {
1032 return (AE_NO_MEMORY);
1033 }
1034
1035 /*
1036 * Copy the raw buffer data with no transform. String is already NULL
1037 * terminated at Length+1.
1038 */
1039 ACPI_MEMCPY(new_object->string.pointer,
1040 return_object->buffer.pointer, length);
1041
1042 /* Install the new return object */
1043
1044 acpi_ut_remove_reference(return_object);
1045 *return_object_ptr = new_object;
1046
1047 /*
1048 * If the object is a package element, we need to:
1049 * 1. Decrement the reference count of the orignal object, it was
1050 * incremented when building the package
1051 * 2. Increment the reference count of the new object, it will be
1052 * decremented when releasing the package
1053 */
1054 if (package_index != ACPI_NOT_PACKAGE) {
1055 acpi_ut_remove_reference(return_object);
1056 acpi_ut_add_reference(new_object);
1057 }
1058 return (AE_OK);
1059
1060 default:
1061 break;
1062 }
1063
1064 return (AE_AML_OPERAND_TYPE);
1065}
diff --git a/drivers/acpi/namespace/nssearch.c b/drivers/acpi/acpica/nssearch.c
index a9a80bf811b3..6fea13f3f52d 100644
--- a/drivers/acpi/namespace/nssearch.c
+++ b/drivers/acpi/acpica/nssearch.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include "acnamesp.h"
46 47
47#define _COMPONENT ACPI_NAMESPACE 48#define _COMPONENT ACPI_NAMESPACE
48ACPI_MODULE_NAME("nssearch") 49ACPI_MODULE_NAME("nssearch")
diff --git a/drivers/acpi/namespace/nsutils.c b/drivers/acpi/acpica/nsutils.c
index b0817e1127b1..3e1149bf4aa5 100644
--- a/drivers/acpi/namespace/nsutils.c
+++ b/drivers/acpi/acpica/nsutils.c
@@ -43,9 +43,10 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 46#include "accommon.h"
47#include <acpi/amlcode.h> 47#include "acnamesp.h"
48#include <acpi/actables.h> 48#include "amlcode.h"
49#include "actables.h"
49 50
50#define _COMPONENT ACPI_NAMESPACE 51#define _COMPONENT ACPI_NAMESPACE
51ACPI_MODULE_NAME("nsutils") 52ACPI_MODULE_NAME("nsutils")
@@ -314,9 +315,15 @@ void acpi_ns_get_internal_name_length(struct acpi_namestring_info *info)
314 * 315 *
315 * strlen() + 1 covers the first name_seg, which has no path separator 316 * strlen() + 1 covers the first name_seg, which has no path separator
316 */ 317 */
317 if (acpi_ns_valid_root_prefix(next_external_char[0])) { 318 if (acpi_ns_valid_root_prefix(*next_external_char)) {
318 info->fully_qualified = TRUE; 319 info->fully_qualified = TRUE;
319 next_external_char++; 320 next_external_char++;
321
322 /* Skip redundant root_prefix, like \\_SB.PCI0.SBRG.EC0 */
323
324 while (acpi_ns_valid_root_prefix(*next_external_char)) {
325 next_external_char++;
326 }
320 } else { 327 } else {
321 /* 328 /*
322 * Handle Carat prefixes 329 * Handle Carat prefixes
diff --git a/drivers/acpi/namespace/nswalk.c b/drivers/acpi/acpica/nswalk.c
index 3c905ce26d7d..200895fa2728 100644
--- a/drivers/acpi/namespace/nswalk.c
+++ b/drivers/acpi/acpica/nswalk.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include "acnamesp.h"
46 47
47#define _COMPONENT ACPI_NAMESPACE 48#define _COMPONENT ACPI_NAMESPACE
48ACPI_MODULE_NAME("nswalk") 49ACPI_MODULE_NAME("nswalk")
diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c
index a085cc39c055..22a7171ac1ed 100644
--- a/drivers/acpi/namespace/nsxfeval.c
+++ b/drivers/acpi/acpica/nsxfeval.c
@@ -43,8 +43,9 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 46#include "accommon.h"
47#include <acpi/acinterp.h> 47#include "acnamesp.h"
48#include "acinterp.h"
48 49
49#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
50ACPI_MODULE_NAME("nsxfeval") 51ACPI_MODULE_NAME("nsxfeval")
diff --git a/drivers/acpi/namespace/nsxfname.c b/drivers/acpi/acpica/nsxfname.c
index 5efa4e7ddb0b..9589fea24997 100644
--- a/drivers/acpi/namespace/nsxfname.c
+++ b/drivers/acpi/acpica/nsxfname.c
@@ -43,7 +43,8 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 46#include "accommon.h"
47#include "acnamesp.h"
47 48
48#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
49ACPI_MODULE_NAME("nsxfname") 50ACPI_MODULE_NAME("nsxfname")
diff --git a/drivers/acpi/namespace/nsxfobj.c b/drivers/acpi/acpica/nsxfobj.c
index 2b375ee80cef..1c7efc15225f 100644
--- a/drivers/acpi/namespace/nsxfobj.c
+++ b/drivers/acpi/acpica/nsxfobj.c
@@ -43,7 +43,8 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 46#include "accommon.h"
47#include "acnamesp.h"
47 48
48#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
49ACPI_MODULE_NAME("nsxfobj") 50ACPI_MODULE_NAME("nsxfobj")
diff --git a/drivers/acpi/parser/psargs.c b/drivers/acpi/acpica/psargs.c
index d830b29b85b1..b161f3544b51 100644
--- a/drivers/acpi/parser/psargs.c
+++ b/drivers/acpi/acpica/psargs.c
@@ -42,10 +42,11 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include <acpi/amlcode.h> 46#include "acparser.h"
47#include <acpi/acnamesp.h> 47#include "amlcode.h"
48#include <acpi/acdispat.h> 48#include "acnamesp.h"
49#include "acdispat.h"
49 50
50#define _COMPONENT ACPI_PARSER 51#define _COMPONENT ACPI_PARSER
51ACPI_MODULE_NAME("psargs") 52ACPI_MODULE_NAME("psargs")
diff --git a/drivers/acpi/parser/psloop.c b/drivers/acpi/acpica/psloop.c
index 4647039a0d8a..c5f6ce19a401 100644
--- a/drivers/acpi/parser/psloop.c
+++ b/drivers/acpi/acpica/psloop.c
@@ -50,9 +50,10 @@
50 */ 50 */
51 51
52#include <acpi/acpi.h> 52#include <acpi/acpi.h>
53#include <acpi/acparser.h> 53#include "accommon.h"
54#include <acpi/acdispat.h> 54#include "acparser.h"
55#include <acpi/amlcode.h> 55#include "acdispat.h"
56#include "amlcode.h"
56 57
57#define _COMPONENT ACPI_PARSER 58#define _COMPONENT ACPI_PARSER
58ACPI_MODULE_NAME("psloop") 59ACPI_MODULE_NAME("psloop")
diff --git a/drivers/acpi/parser/psopcode.c b/drivers/acpi/acpica/psopcode.c
index f425ab30eae8..3bc3a60194d6 100644
--- a/drivers/acpi/parser/psopcode.c
+++ b/drivers/acpi/acpica/psopcode.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include <acpi/acopcode.h> 46#include "acparser.h"
47#include <acpi/amlcode.h> 47#include "acopcode.h"
48#include "amlcode.h"
48 49
49#define _COMPONENT ACPI_PARSER 50#define _COMPONENT ACPI_PARSER
50ACPI_MODULE_NAME("psopcode") 51ACPI_MODULE_NAME("psopcode")
diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/acpica/psparse.c
index 68e932f215ea..70838e9b608c 100644
--- a/drivers/acpi/parser/psparse.c
+++ b/drivers/acpi/acpica/psparse.c
@@ -51,11 +51,12 @@
51 */ 51 */
52 52
53#include <acpi/acpi.h> 53#include <acpi/acpi.h>
54#include <acpi/acparser.h> 54#include "accommon.h"
55#include <acpi/acdispat.h> 55#include "acparser.h"
56#include <acpi/amlcode.h> 56#include "acdispat.h"
57#include <acpi/acnamesp.h> 57#include "amlcode.h"
58#include <acpi/acinterp.h> 58#include "acnamesp.h"
59#include "acinterp.h"
59 60
60#define _COMPONENT ACPI_PARSER 61#define _COMPONENT ACPI_PARSER
61ACPI_MODULE_NAME("psparse") 62ACPI_MODULE_NAME("psparse")
@@ -447,10 +448,22 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
447 walk_state, walk_state->parser_state.aml, 448 walk_state, walk_state->parser_state.aml,
448 walk_state->parser_state.aml_size)); 449 walk_state->parser_state.aml_size));
449 450
451 if (!walk_state->parser_state.aml) {
452 return_ACPI_STATUS(AE_NULL_OBJECT);
453 }
454
450 /* Create and initialize a new thread state */ 455 /* Create and initialize a new thread state */
451 456
452 thread = acpi_ut_create_thread_state(); 457 thread = acpi_ut_create_thread_state();
453 if (!thread) { 458 if (!thread) {
459 if (walk_state->method_desc) {
460
461 /* Executing a control method - additional cleanup */
462
463 acpi_ds_terminate_control_method(
464 walk_state->method_desc, walk_state);
465 }
466
454 acpi_ds_delete_walk_state(walk_state); 467 acpi_ds_delete_walk_state(walk_state);
455 return_ACPI_STATUS(AE_NO_MEMORY); 468 return_ACPI_STATUS(AE_NO_MEMORY);
456 } 469 }
diff --git a/drivers/acpi/parser/psscope.c b/drivers/acpi/acpica/psscope.c
index ee50e67c9443..2feca5ca9581 100644
--- a/drivers/acpi/parser/psscope.c
+++ b/drivers/acpi/acpica/psscope.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include "acparser.h"
46 47
47#define _COMPONENT ACPI_PARSER 48#define _COMPONENT ACPI_PARSER
48ACPI_MODULE_NAME("psscope") 49ACPI_MODULE_NAME("psscope")
diff --git a/drivers/acpi/parser/pstree.c b/drivers/acpi/acpica/pstree.c
index 1dd355ddd182..4d3389118ec3 100644
--- a/drivers/acpi/parser/pstree.c
+++ b/drivers/acpi/acpica/pstree.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include <acpi/amlcode.h> 46#include "acparser.h"
47#include "amlcode.h"
47 48
48#define _COMPONENT ACPI_PARSER 49#define _COMPONENT ACPI_PARSER
49ACPI_MODULE_NAME("pstree") 50ACPI_MODULE_NAME("pstree")
diff --git a/drivers/acpi/parser/psutils.c b/drivers/acpi/acpica/psutils.c
index 7cf1f65cd5bb..e636e078ad3d 100644
--- a/drivers/acpi/parser/psutils.c
+++ b/drivers/acpi/acpica/psutils.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include <acpi/amlcode.h> 46#include "acparser.h"
47#include "amlcode.h"
47 48
48#define _COMPONENT ACPI_PARSER 49#define _COMPONENT ACPI_PARSER
49ACPI_MODULE_NAME("psutils") 50ACPI_MODULE_NAME("psutils")
diff --git a/drivers/acpi/parser/pswalk.c b/drivers/acpi/acpica/pswalk.c
index 8b86ad5a3201..78b8b791f2ae 100644
--- a/drivers/acpi/parser/pswalk.c
+++ b/drivers/acpi/acpica/pswalk.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include "acparser.h"
46 47
47#define _COMPONENT ACPI_PARSER 48#define _COMPONENT ACPI_PARSER
48ACPI_MODULE_NAME("pswalk") 49ACPI_MODULE_NAME("pswalk")
diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/acpica/psxface.c
index 270469aae842..ff06032c0f06 100644
--- a/drivers/acpi/parser/psxface.c
+++ b/drivers/acpi/acpica/psxface.c
@@ -42,9 +42,11 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acparser.h> 45#include "accommon.h"
46#include <acpi/acdispat.h> 46#include "acparser.h"
47#include <acpi/acinterp.h> 47#include "acdispat.h"
48#include "acinterp.h"
49#include "amlcode.h"
48 50
49#define _COMPONENT ACPI_PARSER 51#define _COMPONENT ACPI_PARSER
50ACPI_MODULE_NAME("psxface") 52ACPI_MODULE_NAME("psxface")
@@ -278,6 +280,38 @@ acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info)
278 goto cleanup; 280 goto cleanup;
279 } 281 }
280 282
283 /* Invoke an internal method if necessary */
284
285 if (info->obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) {
286 status = info->obj_desc->method.implementation(walk_state);
287 info->return_object = walk_state->return_desc;
288
289 /* Cleanup states */
290
291 acpi_ds_scope_stack_clear(walk_state);
292 acpi_ps_cleanup_scope(&walk_state->parser_state);
293 acpi_ds_terminate_control_method(walk_state->method_desc,
294 walk_state);
295 acpi_ds_delete_walk_state(walk_state);
296 goto cleanup;
297 }
298
299 /*
300 * Start method evaluation with an implicit return of zero.
301 * This is done for Windows compatibility.
302 */
303 if (acpi_gbl_enable_interpreter_slack) {
304 walk_state->implicit_return_obj =
305 acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
306 if (!walk_state->implicit_return_obj) {
307 status = AE_NO_MEMORY;
308 acpi_ds_delete_walk_state(walk_state);
309 goto cleanup;
310 }
311
312 walk_state->implicit_return_obj->integer.value = 0;
313 }
314
281 /* Parse the AML */ 315 /* Parse the AML */
282 316
283 status = acpi_ps_parse_aml(walk_state); 317 status = acpi_ps_parse_aml(walk_state);
diff --git a/drivers/acpi/resources/rsaddr.c b/drivers/acpi/acpica/rsaddr.c
index 7f96332822bf..1e437bfd8db5 100644
--- a/drivers/acpi/resources/rsaddr.c
+++ b/drivers/acpi/acpica/rsaddr.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include "accommon.h"
46#include "acresrc.h"
46 47
47#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsaddr") 49ACPI_MODULE_NAME("rsaddr")
diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/acpica/rscalc.c
index 8eaaecf92009..52865ee6bc77 100644
--- a/drivers/acpi/resources/rscalc.c
+++ b/drivers/acpi/acpica/rscalc.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acresrc.h"
47#include "acnamesp.h"
47 48
48#define _COMPONENT ACPI_RESOURCES 49#define _COMPONENT ACPI_RESOURCES
49ACPI_MODULE_NAME("rscalc") 50ACPI_MODULE_NAME("rscalc")
diff --git a/drivers/acpi/resources/rscreate.c b/drivers/acpi/acpica/rscreate.c
index c0bbfa2c4193..61566b1a0616 100644
--- a/drivers/acpi/resources/rscreate.c
+++ b/drivers/acpi/acpica/rscreate.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acresrc.h"
47#include "acnamesp.h"
47 48
48#define _COMPONENT ACPI_RESOURCES 49#define _COMPONENT ACPI_RESOURCES
49ACPI_MODULE_NAME("rscreate") 50ACPI_MODULE_NAME("rscreate")
@@ -124,7 +125,7 @@ acpi_rs_create_resource_list(union acpi_operand_object *aml_buffer,
124 * 125 *
125 * FUNCTION: acpi_rs_create_pci_routing_table 126 * FUNCTION: acpi_rs_create_pci_routing_table
126 * 127 *
127 * PARAMETERS: package_object - Pointer to an union acpi_operand_object 128 * PARAMETERS: package_object - Pointer to a union acpi_operand_object
128 * package 129 * package
129 * output_buffer - Pointer to the user's buffer 130 * output_buffer - Pointer to the user's buffer
130 * 131 *
diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/acpica/rsdump.c
index 6bbbb7b8941a..3f0ca5a12d34 100644
--- a/drivers/acpi/resources/rsdump.c
+++ b/drivers/acpi/acpica/rsdump.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include "accommon.h"
46#include "acresrc.h"
46 47
47#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsdump") 49ACPI_MODULE_NAME("rsdump")
diff --git a/drivers/acpi/resources/rsinfo.c b/drivers/acpi/acpica/rsinfo.c
index 3f0a1fedbe0e..77b25fdb459c 100644
--- a/drivers/acpi/resources/rsinfo.c
+++ b/drivers/acpi/acpica/rsinfo.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include "accommon.h"
46#include "acresrc.h"
46 47
47#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsinfo") 49ACPI_MODULE_NAME("rsinfo")
diff --git a/drivers/acpi/resources/rsio.c b/drivers/acpi/acpica/rsio.c
index b66d42e7402e..35a49aa95609 100644
--- a/drivers/acpi/resources/rsio.c
+++ b/drivers/acpi/acpica/rsio.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include "accommon.h"
46#include "acresrc.h"
46 47
47#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsio") 49ACPI_MODULE_NAME("rsio")
diff --git a/drivers/acpi/resources/rsirq.c b/drivers/acpi/acpica/rsirq.c
index a8805efc0366..2e0256983aa6 100644
--- a/drivers/acpi/resources/rsirq.c
+++ b/drivers/acpi/acpica/rsirq.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include "accommon.h"
46#include "acresrc.h"
46 47
47#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsirq") 49ACPI_MODULE_NAME("rsirq")
diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/acpica/rslist.c
index b78c7e797a19..1b1dbc69f087 100644
--- a/drivers/acpi/resources/rslist.c
+++ b/drivers/acpi/acpica/rslist.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include "accommon.h"
46#include "acresrc.h"
46 47
47#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rslist") 49ACPI_MODULE_NAME("rslist")
diff --git a/drivers/acpi/resources/rsmemory.c b/drivers/acpi/acpica/rsmemory.c
index 63b21abd90bb..ddc76cebdc92 100644
--- a/drivers/acpi/resources/rsmemory.c
+++ b/drivers/acpi/acpica/rsmemory.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include "accommon.h"
46#include "acresrc.h"
46 47
47#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsmemory") 49ACPI_MODULE_NAME("rsmemory")
diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/acpica/rsmisc.c
index 96a6c0353255..5bc49a553284 100644
--- a/drivers/acpi/resources/rsmisc.c
+++ b/drivers/acpi/acpica/rsmisc.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include "accommon.h"
46#include "acresrc.h"
46 47
47#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsmisc") 49ACPI_MODULE_NAME("rsmisc")
diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/acpica/rsutils.c
index f7b3bcd59ba7..bc03d5966829 100644
--- a/drivers/acpi/resources/rsutils.c
+++ b/drivers/acpi/acpica/rsutils.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include <acpi/acresrc.h> 46#include "acnamesp.h"
47#include "acresrc.h"
47 48
48#define _COMPONENT ACPI_RESOURCES 49#define _COMPONENT ACPI_RESOURCES
49ACPI_MODULE_NAME("rsutils") 50ACPI_MODULE_NAME("rsutils")
diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/acpica/rsxface.c
index f59f4c4e034c..69a2aa5b5d83 100644
--- a/drivers/acpi/resources/rsxface.c
+++ b/drivers/acpi/acpica/rsxface.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acresrc.h"
47#include "acnamesp.h"
47 48
48#define _COMPONENT ACPI_RESOURCES 49#define _COMPONENT ACPI_RESOURCES
49ACPI_MODULE_NAME("rsxface") 50ACPI_MODULE_NAME("rsxface")
diff --git a/drivers/acpi/tables/tbfadt.c b/drivers/acpi/acpica/tbfadt.c
index 2817158fb6a1..3636e4f8fb73 100644
--- a/drivers/acpi/tables/tbfadt.c
+++ b/drivers/acpi/acpica/tbfadt.c
@@ -42,15 +42,16 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/actables.h> 45#include "accommon.h"
46#include "actables.h"
46 47
47#define _COMPONENT ACPI_TABLES 48#define _COMPONENT ACPI_TABLES
48ACPI_MODULE_NAME("tbfadt") 49ACPI_MODULE_NAME("tbfadt")
49 50
50/* Local prototypes */ 51/* Local prototypes */
51static void inline 52static inline void
52acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, 53acpi_tb_init_generic_address(struct acpi_generic_address *generic_address,
53 u8 byte_width, u64 address); 54 u8 space_id, u8 byte_width, u64 address);
54 55
55static void acpi_tb_convert_fadt(void); 56static void acpi_tb_convert_fadt(void);
56 57
@@ -60,9 +61,10 @@ static void acpi_tb_validate_fadt(void);
60 61
61typedef struct acpi_fadt_info { 62typedef struct acpi_fadt_info {
62 char *name; 63 char *name;
63 u8 target; 64 u8 address64;
64 u8 source; 65 u8 address32;
65 u8 length; 66 u8 length;
67 u8 default_length;
66 u8 type; 68 u8 type;
67 69
68} acpi_fadt_info; 70} acpi_fadt_info;
@@ -71,37 +73,61 @@ typedef struct acpi_fadt_info {
71#define ACPI_FADT_SEPARATE_LENGTH 2 73#define ACPI_FADT_SEPARATE_LENGTH 2
72 74
73static struct acpi_fadt_info fadt_info_table[] = { 75static struct acpi_fadt_info fadt_info_table[] = {
74 {"Pm1aEventBlock", ACPI_FADT_OFFSET(xpm1a_event_block), 76 {"Pm1aEventBlock",
77 ACPI_FADT_OFFSET(xpm1a_event_block),
75 ACPI_FADT_OFFSET(pm1a_event_block), 78 ACPI_FADT_OFFSET(pm1a_event_block),
76 ACPI_FADT_OFFSET(pm1_event_length), ACPI_FADT_REQUIRED}, 79 ACPI_FADT_OFFSET(pm1_event_length),
80 ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */
81 ACPI_FADT_REQUIRED},
77 82
78 {"Pm1bEventBlock", ACPI_FADT_OFFSET(xpm1b_event_block), 83 {"Pm1bEventBlock",
84 ACPI_FADT_OFFSET(xpm1b_event_block),
79 ACPI_FADT_OFFSET(pm1b_event_block), 85 ACPI_FADT_OFFSET(pm1b_event_block),
80 ACPI_FADT_OFFSET(pm1_event_length), 0}, 86 ACPI_FADT_OFFSET(pm1_event_length),
87 ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */
88 0},
81 89
82 {"Pm1aControlBlock", ACPI_FADT_OFFSET(xpm1a_control_block), 90 {"Pm1aControlBlock",
91 ACPI_FADT_OFFSET(xpm1a_control_block),
83 ACPI_FADT_OFFSET(pm1a_control_block), 92 ACPI_FADT_OFFSET(pm1a_control_block),
84 ACPI_FADT_OFFSET(pm1_control_length), ACPI_FADT_REQUIRED}, 93 ACPI_FADT_OFFSET(pm1_control_length),
94 ACPI_PM1_REGISTER_WIDTH,
95 ACPI_FADT_REQUIRED},
85 96
86 {"Pm1bControlBlock", ACPI_FADT_OFFSET(xpm1b_control_block), 97 {"Pm1bControlBlock",
98 ACPI_FADT_OFFSET(xpm1b_control_block),
87 ACPI_FADT_OFFSET(pm1b_control_block), 99 ACPI_FADT_OFFSET(pm1b_control_block),
88 ACPI_FADT_OFFSET(pm1_control_length), 0}, 100 ACPI_FADT_OFFSET(pm1_control_length),
101 ACPI_PM1_REGISTER_WIDTH,
102 0},
89 103
90 {"Pm2ControlBlock", ACPI_FADT_OFFSET(xpm2_control_block), 104 {"Pm2ControlBlock",
105 ACPI_FADT_OFFSET(xpm2_control_block),
91 ACPI_FADT_OFFSET(pm2_control_block), 106 ACPI_FADT_OFFSET(pm2_control_block),
92 ACPI_FADT_OFFSET(pm2_control_length), ACPI_FADT_SEPARATE_LENGTH}, 107 ACPI_FADT_OFFSET(pm2_control_length),
108 ACPI_PM2_REGISTER_WIDTH,
109 ACPI_FADT_SEPARATE_LENGTH},
93 110
94 {"PmTimerBlock", ACPI_FADT_OFFSET(xpm_timer_block), 111 {"PmTimerBlock",
112 ACPI_FADT_OFFSET(xpm_timer_block),
95 ACPI_FADT_OFFSET(pm_timer_block), 113 ACPI_FADT_OFFSET(pm_timer_block),
96 ACPI_FADT_OFFSET(pm_timer_length), ACPI_FADT_REQUIRED}, 114 ACPI_FADT_OFFSET(pm_timer_length),
115 ACPI_PM_TIMER_WIDTH,
116 ACPI_FADT_REQUIRED},
97 117
98 {"Gpe0Block", ACPI_FADT_OFFSET(xgpe0_block), 118 {"Gpe0Block",
119 ACPI_FADT_OFFSET(xgpe0_block),
99 ACPI_FADT_OFFSET(gpe0_block), 120 ACPI_FADT_OFFSET(gpe0_block),
100 ACPI_FADT_OFFSET(gpe0_block_length), ACPI_FADT_SEPARATE_LENGTH}, 121 ACPI_FADT_OFFSET(gpe0_block_length),
122 0,
123 ACPI_FADT_SEPARATE_LENGTH},
101 124
102 {"Gpe1Block", ACPI_FADT_OFFSET(xgpe1_block), 125 {"Gpe1Block",
126 ACPI_FADT_OFFSET(xgpe1_block),
103 ACPI_FADT_OFFSET(gpe1_block), 127 ACPI_FADT_OFFSET(gpe1_block),
104 ACPI_FADT_OFFSET(gpe1_block_length), ACPI_FADT_SEPARATE_LENGTH} 128 ACPI_FADT_OFFSET(gpe1_block_length),
129 0,
130 ACPI_FADT_SEPARATE_LENGTH}
105}; 131};
106 132
107#define ACPI_FADT_INFO_ENTRIES (sizeof (fadt_info_table) / sizeof (struct acpi_fadt_info)) 133#define ACPI_FADT_INFO_ENTRIES (sizeof (fadt_info_table) / sizeof (struct acpi_fadt_info))
@@ -122,9 +148,9 @@ static struct acpi_fadt_info fadt_info_table[] = {
122 * 148 *
123 ******************************************************************************/ 149 ******************************************************************************/
124 150
125static void inline 151static inline void
126acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, 152acpi_tb_init_generic_address(struct acpi_generic_address *generic_address,
127 u8 byte_width, u64 address) 153 u8 space_id, u8 byte_width, u64 address)
128{ 154{
129 155
130 /* 156 /*
@@ -135,10 +161,10 @@ acpi_tb_init_generic_address(struct acpi_generic_address *generic_address,
135 161
136 /* All other fields are byte-wide */ 162 /* All other fields are byte-wide */
137 163
138 generic_address->space_id = ACPI_ADR_SPACE_SYSTEM_IO; 164 generic_address->space_id = space_id;
139 generic_address->bit_width = byte_width << 3; 165 generic_address->bit_width = (u8)ACPI_MUL_8(byte_width);
140 generic_address->bit_offset = 0; 166 generic_address->bit_offset = 0;
141 generic_address->access_width = 0; 167 generic_address->access_width = 0; /* Access width ANY */
142} 168}
143 169
144/******************************************************************************* 170/*******************************************************************************
@@ -225,7 +251,8 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
225 */ 251 */
226 if (length > sizeof(struct acpi_table_fadt)) { 252 if (length > sizeof(struct acpi_table_fadt)) {
227 ACPI_WARNING((AE_INFO, 253 ACPI_WARNING((AE_INFO,
228 "FADT (revision %u) is longer than ACPI 2.0 version, truncating length 0x%X to 0x%zX", 254 "FADT (revision %u) is longer than ACPI 2.0 version, "
255 "truncating length 0x%X to 0x%zX",
229 table->revision, (unsigned)length, 256 table->revision, (unsigned)length,
230 sizeof(struct acpi_table_fadt))); 257 sizeof(struct acpi_table_fadt)));
231 } 258 }
@@ -244,7 +271,6 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
244 * 2) Validate some of the important values within the FADT 271 * 2) Validate some of the important values within the FADT
245 */ 272 */
246 acpi_tb_convert_fadt(); 273 acpi_tb_convert_fadt();
247 acpi_tb_validate_fadt();
248} 274}
249 275
250/******************************************************************************* 276/*******************************************************************************
@@ -278,22 +304,36 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
278 304
279static void acpi_tb_convert_fadt(void) 305static void acpi_tb_convert_fadt(void)
280{ 306{
281 u8 pm1_register_length; 307 u8 pm1_register_bit_width;
282 struct acpi_generic_address *target; 308 u8 pm1_register_byte_width;
309 struct acpi_generic_address *target64;
283 u32 i; 310 u32 i;
284 311
285 /* Update the local FADT table header length */ 312 /* Update the local FADT table header length */
286 313
287 acpi_gbl_FADT.header.length = sizeof(struct acpi_table_fadt); 314 acpi_gbl_FADT.header.length = sizeof(struct acpi_table_fadt);
288 315
289 /* Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary */ 316 /*
290 317 * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary.
318 * Later code will always use the X 64-bit field. Also, check for an
319 * address mismatch between the 32-bit and 64-bit address fields
320 * (FIRMWARE_CTRL/X_FIRMWARE_CTRL, DSDT/X_DSDT) which would indicate
321 * the presence of two FACS or two DSDT tables.
322 */
291 if (!acpi_gbl_FADT.Xfacs) { 323 if (!acpi_gbl_FADT.Xfacs) {
292 acpi_gbl_FADT.Xfacs = (u64) acpi_gbl_FADT.facs; 324 acpi_gbl_FADT.Xfacs = (u64) acpi_gbl_FADT.facs;
325 } else if (acpi_gbl_FADT.facs &&
326 (acpi_gbl_FADT.Xfacs != (u64) acpi_gbl_FADT.facs)) {
327 ACPI_WARNING((AE_INFO,
328 "32/64 FACS address mismatch in FADT - two FACS tables!"));
293 } 329 }
294 330
295 if (!acpi_gbl_FADT.Xdsdt) { 331 if (!acpi_gbl_FADT.Xdsdt) {
296 acpi_gbl_FADT.Xdsdt = (u64) acpi_gbl_FADT.dsdt; 332 acpi_gbl_FADT.Xdsdt = (u64) acpi_gbl_FADT.dsdt;
333 } else if (acpi_gbl_FADT.dsdt &&
334 (acpi_gbl_FADT.Xdsdt != (u64) acpi_gbl_FADT.dsdt)) {
335 ACPI_WARNING((AE_INFO,
336 "32/64 DSDT address mismatch in FADT - two DSDT tables!"));
297 } 337 }
298 338
299 /* 339 /*
@@ -312,18 +352,23 @@ static void acpi_tb_convert_fadt(void)
312 } 352 }
313 353
314 /* 354 /*
315 * Expand the ACPI 1.0 32-bit V1.0 addresses to the ACPI 2.0 64-bit "X" 355 * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X"
316 * generic address structures as necessary. 356 * generic address structures as necessary. Later code will always use
357 * the 64-bit address structures.
317 */ 358 */
318 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { 359 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) {
319 target = 360 target64 =
320 ACPI_ADD_PTR(struct acpi_generic_address, &acpi_gbl_FADT, 361 ACPI_ADD_PTR(struct acpi_generic_address, &acpi_gbl_FADT,
321 fadt_info_table[i].target); 362 fadt_info_table[i].address64);
322 363
323 /* Expand only if the X target is null */ 364 /* Expand only if the 64-bit X target is null */
324 365
325 if (!target->address) { 366 if (!target64->address) {
326 acpi_tb_init_generic_address(target, 367
368 /* The space_id is always I/O for the 32-bit legacy address fields */
369
370 acpi_tb_init_generic_address(target64,
371 ACPI_ADR_SPACE_SYSTEM_IO,
327 *ACPI_ADD_PTR(u8, 372 *ACPI_ADD_PTR(u8,
328 &acpi_gbl_FADT, 373 &acpi_gbl_FADT,
329 fadt_info_table 374 fadt_info_table
@@ -332,11 +377,64 @@ static void acpi_tb_convert_fadt(void)
332 &acpi_gbl_FADT, 377 &acpi_gbl_FADT,
333 fadt_info_table 378 fadt_info_table
334 [i]. 379 [i].
335 source)); 380 address32));
381 }
382 }
383
384 /* Validate FADT values now, before we make any changes */
385
386 acpi_tb_validate_fadt();
387
388 /*
389 * Optionally check all register lengths against the default values and
390 * update them if they are incorrect.
391 */
392 if (acpi_gbl_use_default_register_widths) {
393 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) {
394 target64 =
395 ACPI_ADD_PTR(struct acpi_generic_address,
396 &acpi_gbl_FADT,
397 fadt_info_table[i].address64);
398
399 /*
400 * If a valid register (Address != 0) and the (default_length > 0)
401 * (Not a GPE register), then check the width against the default.
402 */
403 if ((target64->address) &&
404 (fadt_info_table[i].default_length > 0) &&
405 (fadt_info_table[i].default_length !=
406 target64->bit_width)) {
407 ACPI_WARNING((AE_INFO,
408 "Invalid length for %s: %d, using default %d",
409 fadt_info_table[i].name,
410 target64->bit_width,
411 fadt_info_table[i].
412 default_length));
413
414 /* Incorrect size, set width to the default */
415
416 target64->bit_width =
417 fadt_info_table[i].default_length;
418 }
336 } 419 }
337 } 420 }
338 421
339 /* 422 /*
423 * Get the length of the individual PM1 registers (enable and status).
424 * Each register is defined to be (event block length / 2).
425 */
426 pm1_register_bit_width =
427 (u8)ACPI_DIV_2(acpi_gbl_FADT.xpm1a_event_block.bit_width);
428 pm1_register_byte_width = (u8)ACPI_DIV_8(pm1_register_bit_width);
429
430 /*
431 * Adjust the lengths of the PM1 Event Blocks so that they can be used to
432 * access the PM1 status register(s). Use (width / 2)
433 */
434 acpi_gbl_FADT.xpm1a_event_block.bit_width = pm1_register_bit_width;
435 acpi_gbl_FADT.xpm1b_event_block.bit_width = pm1_register_bit_width;
436
437 /*
340 * Calculate separate GAS structs for the PM1 Enable registers. 438 * Calculate separate GAS structs for the PM1 Enable registers.
341 * These addresses do not appear (directly) in the FADT, so it is 439 * These addresses do not appear (directly) in the FADT, so it is
342 * useful to calculate them once, here. 440 * useful to calculate them once, here.
@@ -356,14 +454,14 @@ static void acpi_tb_convert_fadt(void)
356 " PM1_EVT_LEN (%u)\n", 454 " PM1_EVT_LEN (%u)\n",
357 acpi_gbl_FADT.xpm1a_event_block.bit_width, 455 acpi_gbl_FADT.xpm1a_event_block.bit_width,
358 acpi_gbl_FADT.pm1_event_length); 456 acpi_gbl_FADT.pm1_event_length);
359 pm1_register_length = (u8) ACPI_DIV_2(acpi_gbl_FADT.pm1_event_length);
360 457
361 /* The PM1A register block is required */ 458 /* The PM1A register block is required */
362 459
363 acpi_tb_init_generic_address(&acpi_gbl_xpm1a_enable, 460 acpi_tb_init_generic_address(&acpi_gbl_xpm1a_enable,
364 pm1_register_length, 461 acpi_gbl_FADT.xpm1a_event_block.space_id,
462 pm1_register_byte_width,
365 (acpi_gbl_FADT.xpm1a_event_block.address + 463 (acpi_gbl_FADT.xpm1a_event_block.address +
366 pm1_register_length)); 464 pm1_register_byte_width));
367 /* Don't forget to copy space_id of the GAS */ 465 /* Don't forget to copy space_id of the GAS */
368 acpi_gbl_xpm1a_enable.space_id = 466 acpi_gbl_xpm1a_enable.space_id =
369 acpi_gbl_FADT.xpm1a_event_block.space_id; 467 acpi_gbl_FADT.xpm1a_event_block.space_id;
@@ -379,9 +477,10 @@ static void acpi_tb_convert_fadt(void)
379 acpi_gbl_FADT.xpm1b_event_block.bit_width, 477 acpi_gbl_FADT.xpm1b_event_block.bit_width,
380 acpi_gbl_FADT.pm1_event_length); 478 acpi_gbl_FADT.pm1_event_length);
381 acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable, 479 acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable,
382 pm1_register_length, 480 acpi_gbl_FADT.xpm1b_event_block.space_id,
481 pm1_register_byte_width,
383 (acpi_gbl_FADT.xpm1b_event_block. 482 (acpi_gbl_FADT.xpm1b_event_block.
384 address + pm1_register_length)); 483 address + pm1_register_byte_width));
385 /* Don't forget to copy space_id of the GAS */ 484 /* Don't forget to copy space_id of the GAS */
386 acpi_gbl_xpm1b_enable.space_id = 485 acpi_gbl_xpm1b_enable.space_id =
387 acpi_gbl_FADT.xpm1b_event_block.space_id; 486 acpi_gbl_FADT.xpm1b_event_block.space_id;
@@ -411,26 +510,63 @@ static void acpi_tb_convert_fadt(void)
411 510
412static void acpi_tb_validate_fadt(void) 511static void acpi_tb_validate_fadt(void)
413{ 512{
513 char *name;
414 u32 *address32; 514 u32 *address32;
415 struct acpi_generic_address *address64; 515 struct acpi_generic_address *address64;
416 u8 length; 516 u8 length;
417 u32 i; 517 u32 i;
418 518
419 /* Examine all of the 64-bit extended address fields (X fields) */ 519 /*
520 * Check for FACS and DSDT address mismatches. An address mismatch between
521 * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and
522 * DSDT/X_DSDT) would indicate the presence of two FACS or two DSDT tables.
523 */
524 if (acpi_gbl_FADT.facs &&
525 (acpi_gbl_FADT.Xfacs != (u64) acpi_gbl_FADT.facs)) {
526 ACPI_WARNING((AE_INFO,
527 "32/64X FACS address mismatch in FADT - "
528 "two FACS tables! %8.8X/%8.8X%8.8X",
529 acpi_gbl_FADT.facs,
530 ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xfacs)));
531 }
420 532
421 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { 533 if (acpi_gbl_FADT.dsdt &&
534 (acpi_gbl_FADT.Xdsdt != (u64) acpi_gbl_FADT.dsdt)) {
535 ACPI_WARNING((AE_INFO,
536 "32/64X DSDT address mismatch in FADT - "
537 "two DSDT tables! %8.8X/%8.8X%8.8X",
538 acpi_gbl_FADT.dsdt,
539 ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xdsdt)));
540 }
422 541
423 /* Generate pointers to the 32-bit and 64-bit addresses and get the length */ 542 /* Examine all of the 64-bit extended address fields (X fields) */
424 543
425 address64 = 544 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) {
426 ACPI_ADD_PTR(struct acpi_generic_address, &acpi_gbl_FADT, 545 /*
427 fadt_info_table[i].target); 546 * Generate pointers to the 32-bit and 64-bit addresses, get the
547 * register length (width), and the register name
548 */
549 address64 = ACPI_ADD_PTR(struct acpi_generic_address,
550 &acpi_gbl_FADT,
551 fadt_info_table[i].address64);
428 address32 = 552 address32 =
429 ACPI_ADD_PTR(u32, &acpi_gbl_FADT, 553 ACPI_ADD_PTR(u32, &acpi_gbl_FADT,
430 fadt_info_table[i].source); 554 fadt_info_table[i].address32);
431 length = 555 length =
432 *ACPI_ADD_PTR(u8, &acpi_gbl_FADT, 556 *ACPI_ADD_PTR(u8, &acpi_gbl_FADT,
433 fadt_info_table[i].length); 557 fadt_info_table[i].length);
558 name = fadt_info_table[i].name;
559
560 /*
561 * For each extended field, check for length mismatch between the
562 * legacy length field and the corresponding 64-bit X length field.
563 */
564 if (address64 && (address64->bit_width != ACPI_MUL_8(length))) {
565 ACPI_WARNING((AE_INFO,
566 "32/64X length mismatch in %s: %d/%d",
567 name, ACPI_MUL_8(length),
568 address64->bit_width));
569 }
434 570
435 if (fadt_info_table[i].type & ACPI_FADT_REQUIRED) { 571 if (fadt_info_table[i].type & ACPI_FADT_REQUIRED) {
436 /* 572 /*
@@ -439,8 +575,8 @@ static void acpi_tb_validate_fadt(void)
439 */ 575 */
440 if (!address64->address || !length) { 576 if (!address64->address || !length) {
441 ACPI_ERROR((AE_INFO, 577 ACPI_ERROR((AE_INFO,
442 "Required field \"%s\" has zero address and/or length: %8.8X%8.8X/%X", 578 "Required field %s has zero address and/or length: %8.8X%8.8X/%X",
443 fadt_info_table[i].name, 579 name,
444 ACPI_FORMAT_UINT64(address64-> 580 ACPI_FORMAT_UINT64(address64->
445 address), 581 address),
446 length)); 582 length));
@@ -453,8 +589,8 @@ static void acpi_tb_validate_fadt(void)
453 if ((address64->address && !length) 589 if ((address64->address && !length)
454 || (!address64->address && length)) { 590 || (!address64->address && length)) {
455 ACPI_WARNING((AE_INFO, 591 ACPI_WARNING((AE_INFO,
456 "Optional field \"%s\" has zero address or length: %8.8X%8.8X/%X", 592 "Optional field %s has zero address or length: %8.8X%8.8X/%X",
457 fadt_info_table[i].name, 593 name,
458 ACPI_FORMAT_UINT64(address64-> 594 ACPI_FORMAT_UINT64(address64->
459 address), 595 address),
460 length)); 596 length));
@@ -466,8 +602,8 @@ static void acpi_tb_validate_fadt(void)
466 if (address64->address && *address32 && 602 if (address64->address && *address32 &&
467 (address64->address != (u64) * address32)) { 603 (address64->address != (u64) * address32)) {
468 ACPI_ERROR((AE_INFO, 604 ACPI_ERROR((AE_INFO,
469 "32/64X address mismatch in \"%s\": [%8.8X] [%8.8X%8.8X], using 64X", 605 "32/64X address mismatch in %s: %8.8X/%8.8X%8.8X, using 64X",
470 fadt_info_table[i].name, *address32, 606 name, *address32,
471 ACPI_FORMAT_UINT64(address64->address))); 607 ACPI_FORMAT_UINT64(address64->address)));
472 } 608 }
473 } 609 }
diff --git a/drivers/acpi/tables/tbfind.c b/drivers/acpi/acpica/tbfind.c
index 531584defbb8..1054dfd49207 100644
--- a/drivers/acpi/tables/tbfind.c
+++ b/drivers/acpi/acpica/tbfind.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/actables.h> 45#include "accommon.h"
46#include "actables.h"
46 47
47#define _COMPONENT ACPI_TABLES 48#define _COMPONENT ACPI_TABLES
48ACPI_MODULE_NAME("tbfind") 49ACPI_MODULE_NAME("tbfind")
diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index 18747ce8dd2f..37374b21969d 100644
--- a/drivers/acpi/tables/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include <acpi/actables.h> 46#include "acnamesp.h"
47#include "actables.h"
47 48
48#define _COMPONENT ACPI_TABLES 49#define _COMPONENT ACPI_TABLES
49ACPI_MODULE_NAME("tbinstal") 50ACPI_MODULE_NAME("tbinstal")
diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/acpica/tbutils.c
index 0cc92ef5236f..9684cc827930 100644
--- a/drivers/acpi/tables/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/actables.h> 45#include "accommon.h"
46#include "actables.h"
46 47
47#define _COMPONENT ACPI_TABLES 48#define _COMPONENT ACPI_TABLES
48ACPI_MODULE_NAME("tbutils") 49ACPI_MODULE_NAME("tbutils")
@@ -113,6 +114,30 @@ acpi_tb_check_xsdt(acpi_physical_address address)
113 114
114/******************************************************************************* 115/*******************************************************************************
115 * 116 *
117 * FUNCTION: acpi_tb_initialize_facs
118 *
119 * PARAMETERS: None
120 *
121 * RETURN: Status
122 *
123 * DESCRIPTION: Create a permanent mapping for the FADT and save it in a global
124 * for accessing the Global Lock and Firmware Waking Vector
125 *
126 ******************************************************************************/
127
128acpi_status acpi_tb_initialize_facs(void)
129{
130 acpi_status status;
131
132 status = acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS,
133 ACPI_CAST_INDIRECT_PTR(struct
134 acpi_table_header,
135 &acpi_gbl_FACS));
136 return status;
137}
138
139/*******************************************************************************
140 *
116 * FUNCTION: acpi_tb_tables_loaded 141 * FUNCTION: acpi_tb_tables_loaded
117 * 142 *
118 * PARAMETERS: None 143 * PARAMETERS: None
@@ -420,7 +445,8 @@ acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags)
420 445
421 /* Differentiate between RSDT and XSDT root tables */ 446 /* Differentiate between RSDT and XSDT root tables */
422 447
423 if (rsdp->revision > 1 && rsdp->xsdt_physical_address) { 448 if (rsdp->revision > 1 && rsdp->xsdt_physical_address
449 && !acpi_rsdt_forced) {
424 /* 450 /*
425 * Root table is an XSDT (64-bit physical addresses). We must use the 451 * Root table is an XSDT (64-bit physical addresses). We must use the
426 * XSDT if the revision is > 1 and the XSDT pointer is present, as per 452 * XSDT if the revision is > 1 and the XSDT pointer is present, as per
diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/acpica/tbxface.c
index fd7770aa1061..c3e841f3cde9 100644
--- a/drivers/acpi/tables/tbxface.c
+++ b/drivers/acpi/acpica/tbxface.c
@@ -43,8 +43,9 @@
43 */ 43 */
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include <acpi/acnamesp.h> 46#include "accommon.h"
47#include <acpi/actables.h> 47#include "acnamesp.h"
48#include "actables.h"
48 49
49#define _COMPONENT ACPI_TABLES 50#define _COMPONENT ACPI_TABLES
50ACPI_MODULE_NAME("tbxface") 51ACPI_MODULE_NAME("tbxface")
diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/acpica/tbxfroot.c
index 2d157e0f98d2..b7fc8dd43341 100644
--- a/drivers/acpi/tables/tbxfroot.c
+++ b/drivers/acpi/acpica/tbxfroot.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/actables.h> 45#include "accommon.h"
46#include "actables.h"
46 47
47#define _COMPONENT ACPI_TABLES 48#define _COMPONENT ACPI_TABLES
48ACPI_MODULE_NAME("tbxfroot") 49ACPI_MODULE_NAME("tbxfroot")
diff --git a/drivers/acpi/utilities/utalloc.c b/drivers/acpi/acpica/utalloc.c
index 241c535c1753..7580f6b3069e 100644
--- a/drivers/acpi/utilities/utalloc.c
+++ b/drivers/acpi/acpica/utalloc.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acdebug.h> 45#include "accommon.h"
46#include "acdebug.h"
46 47
47#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
48ACPI_MODULE_NAME("utalloc") 49ACPI_MODULE_NAME("utalloc")
diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/acpica/utcopy.c
index 5b2f7c27b705..b0dcfd3c872a 100644
--- a/drivers/acpi/utilities/utcopy.c
+++ b/drivers/acpi/acpica/utcopy.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include "acnamesp.h"
46 47
47 48
48#define _COMPONENT ACPI_UTILITIES 49#define _COMPONENT ACPI_UTILITIES
diff --git a/drivers/acpi/utilities/utdebug.c b/drivers/acpi/acpica/utdebug.c
index fd66ecb6741e..38821f53042c 100644
--- a/drivers/acpi/utilities/utdebug.c
+++ b/drivers/acpi/acpica/utdebug.c
@@ -42,6 +42,7 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include "accommon.h"
45 46
46#define _COMPONENT ACPI_UTILITIES 47#define _COMPONENT ACPI_UTILITIES
47ACPI_MODULE_NAME("utdebug") 48ACPI_MODULE_NAME("utdebug")
@@ -136,7 +137,7 @@ static const char *acpi_ut_trim_function_name(const char *function_name)
136 137
137/******************************************************************************* 138/*******************************************************************************
138 * 139 *
139 * FUNCTION: acpi_ut_debug_print 140 * FUNCTION: acpi_debug_print
140 * 141 *
141 * PARAMETERS: requested_debug_level - Requested debug print level 142 * PARAMETERS: requested_debug_level - Requested debug print level
142 * line_number - Caller's line number (for error output) 143 * line_number - Caller's line number (for error output)
@@ -154,11 +155,11 @@ static const char *acpi_ut_trim_function_name(const char *function_name)
154 ******************************************************************************/ 155 ******************************************************************************/
155 156
156void ACPI_INTERNAL_VAR_XFACE 157void ACPI_INTERNAL_VAR_XFACE
157acpi_ut_debug_print(u32 requested_debug_level, 158acpi_debug_print(u32 requested_debug_level,
158 u32 line_number, 159 u32 line_number,
159 const char *function_name, 160 const char *function_name,
160 const char *module_name, 161 const char *module_name,
161 u32 component_id, const char *format, ...) 162 u32 component_id, const char *format, ...)
162{ 163{
163 acpi_thread_id thread_id; 164 acpi_thread_id thread_id;
164 va_list args; 165 va_list args;
@@ -205,11 +206,11 @@ acpi_ut_debug_print(u32 requested_debug_level,
205 va_end(args); 206 va_end(args);
206} 207}
207 208
208ACPI_EXPORT_SYMBOL(acpi_ut_debug_print) 209ACPI_EXPORT_SYMBOL(acpi_debug_print)
209 210
210/******************************************************************************* 211/*******************************************************************************
211 * 212 *
212 * FUNCTION: acpi_ut_debug_print_raw 213 * FUNCTION: acpi_debug_print_raw
213 * 214 *
214 * PARAMETERS: requested_debug_level - Requested debug print level 215 * PARAMETERS: requested_debug_level - Requested debug print level
215 * line_number - Caller's line number 216 * line_number - Caller's line number
@@ -226,11 +227,11 @@ ACPI_EXPORT_SYMBOL(acpi_ut_debug_print)
226 * 227 *
227 ******************************************************************************/ 228 ******************************************************************************/
228void ACPI_INTERNAL_VAR_XFACE 229void ACPI_INTERNAL_VAR_XFACE
229acpi_ut_debug_print_raw(u32 requested_debug_level, 230acpi_debug_print_raw(u32 requested_debug_level,
230 u32 line_number, 231 u32 line_number,
231 const char *function_name, 232 const char *function_name,
232 const char *module_name, 233 const char *module_name,
233 u32 component_id, const char *format, ...) 234 u32 component_id, const char *format, ...)
234{ 235{
235 va_list args; 236 va_list args;
236 237
@@ -244,7 +245,7 @@ acpi_ut_debug_print_raw(u32 requested_debug_level,
244 va_end(args); 245 va_end(args);
245} 246}
246 247
247ACPI_EXPORT_SYMBOL(acpi_ut_debug_print_raw) 248ACPI_EXPORT_SYMBOL(acpi_debug_print_raw)
248 249
249/******************************************************************************* 250/*******************************************************************************
250 * 251 *
@@ -270,9 +271,9 @@ acpi_ut_trace(u32 line_number,
270 acpi_gbl_nesting_level++; 271 acpi_gbl_nesting_level++;
271 acpi_ut_track_stack_ptr(); 272 acpi_ut_track_stack_ptr();
272 273
273 acpi_ut_debug_print(ACPI_LV_FUNCTIONS, 274 acpi_debug_print(ACPI_LV_FUNCTIONS,
274 line_number, function_name, module_name, 275 line_number, function_name, module_name, component_id,
275 component_id, "%s\n", acpi_gbl_fn_entry_str); 276 "%s\n", acpi_gbl_fn_entry_str);
276} 277}
277 278
278ACPI_EXPORT_SYMBOL(acpi_ut_trace) 279ACPI_EXPORT_SYMBOL(acpi_ut_trace)
@@ -301,10 +302,9 @@ acpi_ut_trace_ptr(u32 line_number,
301 acpi_gbl_nesting_level++; 302 acpi_gbl_nesting_level++;
302 acpi_ut_track_stack_ptr(); 303 acpi_ut_track_stack_ptr();
303 304
304 acpi_ut_debug_print(ACPI_LV_FUNCTIONS, 305 acpi_debug_print(ACPI_LV_FUNCTIONS,
305 line_number, function_name, module_name, 306 line_number, function_name, module_name, component_id,
306 component_id, "%s %p\n", acpi_gbl_fn_entry_str, 307 "%s %p\n", acpi_gbl_fn_entry_str, pointer);
307 pointer);
308} 308}
309 309
310/******************************************************************************* 310/*******************************************************************************
@@ -333,10 +333,9 @@ acpi_ut_trace_str(u32 line_number,
333 acpi_gbl_nesting_level++; 333 acpi_gbl_nesting_level++;
334 acpi_ut_track_stack_ptr(); 334 acpi_ut_track_stack_ptr();
335 335
336 acpi_ut_debug_print(ACPI_LV_FUNCTIONS, 336 acpi_debug_print(ACPI_LV_FUNCTIONS,
337 line_number, function_name, module_name, 337 line_number, function_name, module_name, component_id,
338 component_id, "%s %s\n", acpi_gbl_fn_entry_str, 338 "%s %s\n", acpi_gbl_fn_entry_str, string);
339 string);
340} 339}
341 340
342/******************************************************************************* 341/*******************************************************************************
@@ -365,10 +364,9 @@ acpi_ut_trace_u32(u32 line_number,
365 acpi_gbl_nesting_level++; 364 acpi_gbl_nesting_level++;
366 acpi_ut_track_stack_ptr(); 365 acpi_ut_track_stack_ptr();
367 366
368 acpi_ut_debug_print(ACPI_LV_FUNCTIONS, 367 acpi_debug_print(ACPI_LV_FUNCTIONS,
369 line_number, function_name, module_name, 368 line_number, function_name, module_name, component_id,
370 component_id, "%s %08X\n", acpi_gbl_fn_entry_str, 369 "%s %08X\n", acpi_gbl_fn_entry_str, integer);
371 integer);
372} 370}
373 371
374/******************************************************************************* 372/*******************************************************************************
@@ -393,9 +391,9 @@ acpi_ut_exit(u32 line_number,
393 const char *module_name, u32 component_id) 391 const char *module_name, u32 component_id)
394{ 392{
395 393
396 acpi_ut_debug_print(ACPI_LV_FUNCTIONS, 394 acpi_debug_print(ACPI_LV_FUNCTIONS,
397 line_number, function_name, module_name, 395 line_number, function_name, module_name, component_id,
398 component_id, "%s\n", acpi_gbl_fn_exit_str); 396 "%s\n", acpi_gbl_fn_exit_str);
399 397
400 acpi_gbl_nesting_level--; 398 acpi_gbl_nesting_level--;
401} 399}
@@ -426,17 +424,16 @@ acpi_ut_status_exit(u32 line_number,
426{ 424{
427 425
428 if (ACPI_SUCCESS(status)) { 426 if (ACPI_SUCCESS(status)) {
429 acpi_ut_debug_print(ACPI_LV_FUNCTIONS, 427 acpi_debug_print(ACPI_LV_FUNCTIONS,
430 line_number, function_name, module_name, 428 line_number, function_name, module_name,
431 component_id, "%s %s\n", 429 component_id, "%s %s\n", acpi_gbl_fn_exit_str,
432 acpi_gbl_fn_exit_str, 430 acpi_format_exception(status));
433 acpi_format_exception(status));
434 } else { 431 } else {
435 acpi_ut_debug_print(ACPI_LV_FUNCTIONS, 432 acpi_debug_print(ACPI_LV_FUNCTIONS,
436 line_number, function_name, module_name, 433 line_number, function_name, module_name,
437 component_id, "%s ****Exception****: %s\n", 434 component_id, "%s ****Exception****: %s\n",
438 acpi_gbl_fn_exit_str, 435 acpi_gbl_fn_exit_str,
439 acpi_format_exception(status)); 436 acpi_format_exception(status));
440 } 437 }
441 438
442 acpi_gbl_nesting_level--; 439 acpi_gbl_nesting_level--;
@@ -467,10 +464,10 @@ acpi_ut_value_exit(u32 line_number,
467 u32 component_id, acpi_integer value) 464 u32 component_id, acpi_integer value)
468{ 465{
469 466
470 acpi_ut_debug_print(ACPI_LV_FUNCTIONS, 467 acpi_debug_print(ACPI_LV_FUNCTIONS,
471 line_number, function_name, module_name, 468 line_number, function_name, module_name, component_id,
472 component_id, "%s %8.8X%8.8X\n", 469 "%s %8.8X%8.8X\n", acpi_gbl_fn_exit_str,
473 acpi_gbl_fn_exit_str, ACPI_FORMAT_UINT64(value)); 470 ACPI_FORMAT_UINT64(value));
474 471
475 acpi_gbl_nesting_level--; 472 acpi_gbl_nesting_level--;
476} 473}
@@ -499,9 +496,9 @@ acpi_ut_ptr_exit(u32 line_number,
499 const char *module_name, u32 component_id, u8 *ptr) 496 const char *module_name, u32 component_id, u8 *ptr)
500{ 497{
501 498
502 acpi_ut_debug_print(ACPI_LV_FUNCTIONS, 499 acpi_debug_print(ACPI_LV_FUNCTIONS,
503 line_number, function_name, module_name, 500 line_number, function_name, module_name, component_id,
504 component_id, "%s %p\n", acpi_gbl_fn_exit_str, ptr); 501 "%s %p\n", acpi_gbl_fn_exit_str, ptr);
505 502
506 acpi_gbl_nesting_level--; 503 acpi_gbl_nesting_level--;
507} 504}
diff --git a/drivers/acpi/utilities/utdelete.c b/drivers/acpi/acpica/utdelete.c
index d197c6b29e17..a0be9e39531e 100644
--- a/drivers/acpi/utilities/utdelete.c
+++ b/drivers/acpi/acpica/utdelete.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acinterp.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acinterp.h"
47#include <acpi/acevents.h> 47#include "acnamesp.h"
48#include "acevents.h"
48 49
49#define _COMPONENT ACPI_UTILITIES 50#define _COMPONENT ACPI_UTILITIES
50ACPI_MODULE_NAME("utdelete") 51ACPI_MODULE_NAME("utdelete")
diff --git a/drivers/acpi/utilities/uteval.c b/drivers/acpi/acpica/uteval.c
index 352747e49c7a..da9450bc60f7 100644
--- a/drivers/acpi/utilities/uteval.c
+++ b/drivers/acpi/acpica/uteval.c
@@ -42,8 +42,9 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include <acpi/acinterp.h> 46#include "acnamesp.h"
47#include "acinterp.h"
47 48
48#define _COMPONENT ACPI_UTILITIES 49#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("uteval") 50ACPI_MODULE_NAME("uteval")
@@ -129,7 +130,7 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
129 130
130 /* The interface is supported */ 131 /* The interface is supported */
131 132
132 return_ACPI_STATUS(AE_CTRL_TERMINATE); 133 return_ACPI_STATUS(AE_OK);
133 } 134 }
134 } 135 }
135 136
@@ -143,13 +144,13 @@ acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
143 144
144 /* The interface is supported */ 145 /* The interface is supported */
145 146
146 return_ACPI_STATUS(AE_CTRL_TERMINATE); 147 return_ACPI_STATUS(AE_OK);
147 } 148 }
148 149
149 /* The interface is not supported */ 150 /* The interface is not supported */
150 151
151 return_desc->integer.value = 0; 152 return_desc->integer.value = 0;
152 return_ACPI_STATUS(AE_CTRL_TERMINATE); 153 return_ACPI_STATUS(AE_OK);
153} 154}
154 155
155/******************************************************************************* 156/*******************************************************************************
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/acpica/utglobal.c
index 17ed5ac840f7..a3ab9d9da299 100644
--- a/drivers/acpi/utilities/utglobal.c
+++ b/drivers/acpi/acpica/utglobal.c
@@ -44,11 +44,11 @@
44#define DEFINE_ACPI_GLOBALS 44#define DEFINE_ACPI_GLOBALS
45 45
46#include <acpi/acpi.h> 46#include <acpi/acpi.h>
47#include <acpi/acnamesp.h> 47#include "accommon.h"
48#include "acnamesp.h"
48 49
49ACPI_EXPORT_SYMBOL(acpi_gbl_FADT)
50#define _COMPONENT ACPI_UTILITIES 50#define _COMPONENT ACPI_UTILITIES
51 ACPI_MODULE_NAME("utglobal") 51ACPI_MODULE_NAME("utglobal")
52 52
53/******************************************************************************* 53/*******************************************************************************
54 * 54 *
@@ -352,7 +352,7 @@ const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = {
352 "PCI_Config", 352 "PCI_Config",
353 "EmbeddedControl", 353 "EmbeddedControl",
354 "SMBus", 354 "SMBus",
355 "CMOS", 355 "SystemCMOS",
356 "PCIBARTarget", 356 "PCIBARTarget",
357 "DataTable" 357 "DataTable"
358}; 358};
@@ -756,6 +756,7 @@ acpi_status acpi_ut_init_globals(void)
756 acpi_gbl_gpe_xrupt_list_head = NULL; 756 acpi_gbl_gpe_xrupt_list_head = NULL;
757 acpi_gbl_gpe_fadt_blocks[0] = NULL; 757 acpi_gbl_gpe_fadt_blocks[0] = NULL;
758 acpi_gbl_gpe_fadt_blocks[1] = NULL; 758 acpi_gbl_gpe_fadt_blocks[1] = NULL;
759 acpi_current_gpe_count = 0;
759 760
760 /* Global handlers */ 761 /* Global handlers */
761 762
@@ -771,6 +772,7 @@ acpi_status acpi_ut_init_globals(void)
771 acpi_gbl_global_lock_mutex = NULL; 772 acpi_gbl_global_lock_mutex = NULL;
772 acpi_gbl_global_lock_acquired = FALSE; 773 acpi_gbl_global_lock_acquired = FALSE;
773 acpi_gbl_global_lock_handle = 0; 774 acpi_gbl_global_lock_handle = 0;
775 acpi_gbl_global_lock_present = FALSE;
774 776
775 /* Miscellaneous variables */ 777 /* Miscellaneous variables */
776 778
@@ -815,5 +817,7 @@ acpi_status acpi_ut_init_globals(void)
815 return_ACPI_STATUS(AE_OK); 817 return_ACPI_STATUS(AE_OK);
816} 818}
817 819
820ACPI_EXPORT_SYMBOL(acpi_gbl_FADT)
818ACPI_EXPORT_SYMBOL(acpi_dbg_level) 821ACPI_EXPORT_SYMBOL(acpi_dbg_level)
819ACPI_EXPORT_SYMBOL(acpi_dbg_layer) 822ACPI_EXPORT_SYMBOL(acpi_dbg_layer)
823ACPI_EXPORT_SYMBOL(acpi_current_gpe_count)
diff --git a/drivers/acpi/utilities/utinit.c b/drivers/acpi/acpica/utinit.c
index cae515fc02d3..a54ca84eb362 100644
--- a/drivers/acpi/utilities/utinit.c
+++ b/drivers/acpi/acpica/utinit.c
@@ -42,9 +42,10 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include <acpi/acevents.h> 46#include "acnamesp.h"
47#include <acpi/actables.h> 47#include "acevents.h"
48#include "actables.h"
48 49
49#define _COMPONENT ACPI_UTILITIES 50#define _COMPONENT ACPI_UTILITIES
50ACPI_MODULE_NAME("utinit") 51ACPI_MODULE_NAME("utinit")
diff --git a/drivers/acpi/utilities/utmath.c b/drivers/acpi/acpica/utmath.c
index c927324fdd26..c9f682d640ef 100644
--- a/drivers/acpi/utilities/utmath.c
+++ b/drivers/acpi/acpica/utmath.c
@@ -42,6 +42,7 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include "accommon.h"
45 46
46#define _COMPONENT ACPI_UTILITIES 47#define _COMPONENT ACPI_UTILITIES
47ACPI_MODULE_NAME("utmath") 48ACPI_MODULE_NAME("utmath")
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/acpica/utmisc.c
index 9089a158a874..c1f7f4e1a72d 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/acpica/utmisc.c
@@ -44,7 +44,8 @@
44#include <linux/module.h> 44#include <linux/module.h>
45 45
46#include <acpi/acpi.h> 46#include <acpi/acpi.h>
47#include <acpi/acnamesp.h> 47#include "accommon.h"
48#include "acnamesp.h"
48 49
49#define _COMPONENT ACPI_UTILITIES 50#define _COMPONENT ACPI_UTILITIES
50ACPI_MODULE_NAME("utmisc") 51ACPI_MODULE_NAME("utmisc")
@@ -1016,7 +1017,7 @@ acpi_ut_walk_package_tree(union acpi_operand_object * source_object,
1016 1017
1017/******************************************************************************* 1018/*******************************************************************************
1018 * 1019 *
1019 * FUNCTION: acpi_ut_error, acpi_ut_warning, acpi_ut_info 1020 * FUNCTION: acpi_error, acpi_exception, acpi_warning, acpi_info
1020 * 1021 *
1021 * PARAMETERS: module_name - Caller's module name (for error output) 1022 * PARAMETERS: module_name - Caller's module name (for error output)
1022 * line_number - Caller's line number (for error output) 1023 * line_number - Caller's line number (for error output)
@@ -1029,7 +1030,7 @@ acpi_ut_walk_package_tree(union acpi_operand_object * source_object,
1029 ******************************************************************************/ 1030 ******************************************************************************/
1030 1031
1031void ACPI_INTERNAL_VAR_XFACE 1032void ACPI_INTERNAL_VAR_XFACE
1032acpi_ut_error(const char *module_name, u32 line_number, const char *format, ...) 1033acpi_error(const char *module_name, u32 line_number, const char *format, ...)
1033{ 1034{
1034 va_list args; 1035 va_list args;
1035 1036
@@ -1042,8 +1043,8 @@ acpi_ut_error(const char *module_name, u32 line_number, const char *format, ...)
1042} 1043}
1043 1044
1044void ACPI_INTERNAL_VAR_XFACE 1045void ACPI_INTERNAL_VAR_XFACE
1045acpi_ut_exception(const char *module_name, 1046acpi_exception(const char *module_name,
1046 u32 line_number, acpi_status status, const char *format, ...) 1047 u32 line_number, acpi_status status, const char *format, ...)
1047{ 1048{
1048 va_list args; 1049 va_list args;
1049 1050
@@ -1056,11 +1057,8 @@ acpi_ut_exception(const char *module_name,
1056 va_end(args); 1057 va_end(args);
1057} 1058}
1058 1059
1059EXPORT_SYMBOL(acpi_ut_exception);
1060
1061void ACPI_INTERNAL_VAR_XFACE 1060void ACPI_INTERNAL_VAR_XFACE
1062acpi_ut_warning(const char *module_name, 1061acpi_warning(const char *module_name, u32 line_number, const char *format, ...)
1063 u32 line_number, const char *format, ...)
1064{ 1062{
1065 va_list args; 1063 va_list args;
1066 1064
@@ -1073,7 +1071,7 @@ acpi_ut_warning(const char *module_name,
1073} 1071}
1074 1072
1075void ACPI_INTERNAL_VAR_XFACE 1073void ACPI_INTERNAL_VAR_XFACE
1076acpi_ut_info(const char *module_name, u32 line_number, const char *format, ...) 1074acpi_info(const char *module_name, u32 line_number, const char *format, ...)
1077{ 1075{
1078 va_list args; 1076 va_list args;
1079 1077
@@ -1088,3 +1086,8 @@ acpi_ut_info(const char *module_name, u32 line_number, const char *format, ...)
1088 acpi_os_printf("\n"); 1086 acpi_os_printf("\n");
1089 va_end(args); 1087 va_end(args);
1090} 1088}
1089
1090ACPI_EXPORT_SYMBOL(acpi_error)
1091ACPI_EXPORT_SYMBOL(acpi_exception)
1092ACPI_EXPORT_SYMBOL(acpi_warning)
1093ACPI_EXPORT_SYMBOL(acpi_info)
diff --git a/drivers/acpi/utilities/utmutex.c b/drivers/acpi/acpica/utmutex.c
index 7331dde9e1b3..14eb52c4d647 100644
--- a/drivers/acpi/utilities/utmutex.c
+++ b/drivers/acpi/acpica/utmutex.c
@@ -42,6 +42,7 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include "accommon.h"
45 46
46#define _COMPONENT ACPI_UTILITIES 47#define _COMPONENT ACPI_UTILITIES
47ACPI_MODULE_NAME("utmutex") 48ACPI_MODULE_NAME("utmutex")
diff --git a/drivers/acpi/utilities/utobject.c b/drivers/acpi/acpica/utobject.c
index c354e7a42bcd..fd5ea7543e5b 100644
--- a/drivers/acpi/utilities/utobject.c
+++ b/drivers/acpi/acpica/utobject.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acnamesp.h> 45#include "accommon.h"
46#include "acnamesp.h"
46 47
47#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
48ACPI_MODULE_NAME("utobject") 49ACPI_MODULE_NAME("utobject")
@@ -297,7 +298,7 @@ union acpi_operand_object *acpi_ut_create_string_object(acpi_size string_size)
297 * 298 *
298 * RETURN: TRUE if object is valid, FALSE otherwise 299 * RETURN: TRUE if object is valid, FALSE otherwise
299 * 300 *
300 * DESCRIPTION: Validate a pointer to be an union acpi_operand_object 301 * DESCRIPTION: Validate a pointer to be a union acpi_operand_object
301 * 302 *
302 ******************************************************************************/ 303 ******************************************************************************/
303 304
@@ -389,7 +390,7 @@ void acpi_ut_delete_object_desc(union acpi_operand_object *object)
389{ 390{
390 ACPI_FUNCTION_TRACE_PTR(ut_delete_object_desc, object); 391 ACPI_FUNCTION_TRACE_PTR(ut_delete_object_desc, object);
391 392
392 /* Object must be an union acpi_operand_object */ 393 /* Object must be a union acpi_operand_object */
393 394
394 if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) { 395 if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND) {
395 ACPI_ERROR((AE_INFO, 396 ACPI_ERROR((AE_INFO,
diff --git a/drivers/acpi/utilities/utresrc.c b/drivers/acpi/acpica/utresrc.c
index c3e3e1308edc..91b7c00236f4 100644
--- a/drivers/acpi/utilities/utresrc.c
+++ b/drivers/acpi/acpica/utresrc.c
@@ -42,7 +42,8 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/amlresrc.h> 45#include "accommon.h"
46#include "amlresrc.h"
46 47
47#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
48ACPI_MODULE_NAME("utresrc") 49ACPI_MODULE_NAME("utresrc")
diff --git a/drivers/acpi/utilities/utstate.c b/drivers/acpi/acpica/utstate.c
index 63a6d3d77d88..0440c958f5a4 100644
--- a/drivers/acpi/utilities/utstate.c
+++ b/drivers/acpi/acpica/utstate.c
@@ -42,6 +42,7 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include "accommon.h"
45 46
46#define _COMPONENT ACPI_UTILITIES 47#define _COMPONENT ACPI_UTILITIES
47ACPI_MODULE_NAME("utstate") 48ACPI_MODULE_NAME("utstate")
diff --git a/drivers/acpi/utilities/utxface.c b/drivers/acpi/acpica/utxface.c
index c198a4d40583..078a22728c6b 100644
--- a/drivers/acpi/utilities/utxface.c
+++ b/drivers/acpi/acpica/utxface.c
@@ -42,9 +42,11 @@
42 */ 42 */
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acevents.h> 45#include "accommon.h"
46#include <acpi/acnamesp.h> 46#include "acevents.h"
47#include <acpi/acdebug.h> 47#include "acnamesp.h"
48#include "acdebug.h"
49#include "actables.h"
48 50
49#define _COMPONENT ACPI_UTILITIES 51#define _COMPONENT ACPI_UTILITIES
50ACPI_MODULE_NAME("utxface") 52ACPI_MODULE_NAME("utxface")
@@ -148,6 +150,16 @@ acpi_status acpi_enable_subsystem(u32 flags)
148 } 150 }
149 151
150 /* 152 /*
153 * Obtain a permanent mapping for the FACS. This is required for the
154 * Global Lock and the Firmware Waking Vector
155 */
156 status = acpi_tb_initialize_facs();
157 if (ACPI_FAILURE(status)) {
158 ACPI_WARNING((AE_INFO, "Could not map the FACS table"));
159 return_ACPI_STATUS(status);
160 }
161
162 /*
151 * Install the default op_region handlers. These are installed unless 163 * Install the default op_region handlers. These are installed unless
152 * other handlers have already been installed via the 164 * other handlers have already been installed via the
153 * install_address_space_handler interface. 165 * install_address_space_handler interface.
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 1423b0c0cd2e..65132f920459 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -471,7 +471,7 @@ static void sysfs_remove_battery(struct acpi_battery *battery)
471 471
472static int acpi_battery_update(struct acpi_battery *battery) 472static int acpi_battery_update(struct acpi_battery *battery)
473{ 473{
474 int result; 474 int result, old_present = acpi_battery_present(battery);
475 result = acpi_battery_get_status(battery); 475 result = acpi_battery_get_status(battery);
476 if (result) 476 if (result)
477 return result; 477 return result;
@@ -482,7 +482,8 @@ static int acpi_battery_update(struct acpi_battery *battery)
482 return 0; 482 return 0;
483 } 483 }
484#endif 484#endif
485 if (!battery->update_time) { 485 if (!battery->update_time ||
486 old_present != acpi_battery_present(battery)) {
486 result = acpi_battery_get_info(battery); 487 result = acpi_battery_get_info(battery);
487 if (result) 488 if (result)
488 return result; 489 return result;
diff --git a/drivers/acpi/cm_sbs.c b/drivers/acpi/cm_sbs.c
index 307963bd1043..332fe4b21708 100644
--- a/drivers/acpi/cm_sbs.c
+++ b/drivers/acpi/cm_sbs.c
@@ -27,9 +27,6 @@
27#include <linux/seq_file.h> 27#include <linux/seq_file.h>
28#include <acpi/acpi_bus.h> 28#include <acpi/acpi_bus.h>
29#include <acpi/acpi_drivers.h> 29#include <acpi/acpi_drivers.h>
30#include <acpi/acmacros.h>
31#include <acpi/actypes.h>
32#include <acpi/acutils.h>
33 30
34ACPI_MODULE_NAME("cm_sbs"); 31ACPI_MODULE_NAME("cm_sbs");
35#define ACPI_AC_CLASS "ac_adapter" 32#define ACPI_AC_CLASS "ac_adapter"
diff --git a/drivers/acpi/debug.c b/drivers/acpi/debug.c
index c48396892008..20223cbd0d1c 100644
--- a/drivers/acpi/debug.c
+++ b/drivers/acpi/debug.c
@@ -9,7 +9,6 @@
9#include <linux/moduleparam.h> 9#include <linux/moduleparam.h>
10#include <asm/uaccess.h> 10#include <asm/uaccess.h>
11#include <acpi/acpi_drivers.h> 11#include <acpi/acpi_drivers.h>
12#include <acpi/acglobal.h>
13 12
14#define _COMPONENT ACPI_SYSTEM_COMPONENT 13#define _COMPONENT ACPI_SYSTEM_COMPONENT
15ACPI_MODULE_NAME("debug"); 14ACPI_MODULE_NAME("debug");
diff --git a/drivers/acpi/dispatcher/Makefile b/drivers/acpi/dispatcher/Makefile
deleted file mode 100644
index eb7e602a83cd..000000000000
--- a/drivers/acpi/dispatcher/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
1#
2# Makefile for all Linux ACPI interpreter subdirectories
3#
4
5obj-y := dsfield.o dsmthdat.o dsopcode.o dswexec.o dswscope.o \
6 dsmethod.o dsobject.o dsutils.o dswload.o dswstate.o \
7 dsinit.o
8
9EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 30f3ef236ecb..a2b82c90a683 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -42,7 +42,6 @@
42#include <asm/io.h> 42#include <asm/io.h>
43#include <acpi/acpi_bus.h> 43#include <acpi/acpi_bus.h>
44#include <acpi/acpi_drivers.h> 44#include <acpi/acpi_drivers.h>
45#include <acpi/actypes.h>
46 45
47#define ACPI_EC_CLASS "embedded_controller" 46#define ACPI_EC_CLASS "embedded_controller"
48#define ACPI_EC_DEVICE_NAME "Embedded Controller" 47#define ACPI_EC_DEVICE_NAME "Embedded Controller"
@@ -121,31 +120,6 @@ static struct acpi_ec {
121 spinlock_t curr_lock; 120 spinlock_t curr_lock;
122} *boot_ec, *first_ec; 121} *boot_ec, *first_ec;
123 122
124/*
125 * Some Asus system have exchanged ECDT data/command IO addresses.
126 */
127static int print_ecdt_error(const struct dmi_system_id *id)
128{
129 printk(KERN_NOTICE PREFIX "%s detected - "
130 "ECDT has exchanged control/data I/O address\n",
131 id->ident);
132 return 0;
133}
134
135static struct dmi_system_id __cpuinitdata ec_dmi_table[] = {
136 {
137 print_ecdt_error, "Asus L4R", {
138 DMI_MATCH(DMI_BIOS_VERSION, "1008.006"),
139 DMI_MATCH(DMI_PRODUCT_NAME, "L4R"),
140 DMI_MATCH(DMI_BOARD_NAME, "L4R") }, NULL},
141 {
142 print_ecdt_error, "Asus M6R", {
143 DMI_MATCH(DMI_BIOS_VERSION, "0207"),
144 DMI_MATCH(DMI_PRODUCT_NAME, "M6R"),
145 DMI_MATCH(DMI_BOARD_NAME, "M6R") }, NULL},
146 {},
147};
148
149/* -------------------------------------------------------------------------- 123/* --------------------------------------------------------------------------
150 Transaction Management 124 Transaction Management
151 -------------------------------------------------------------------------- */ 125 -------------------------------------------------------------------------- */
@@ -370,7 +344,7 @@ unlock:
370 * Note: samsung nv5000 doesn't work with ec burst mode. 344 * Note: samsung nv5000 doesn't work with ec burst mode.
371 * http://bugzilla.kernel.org/show_bug.cgi?id=4980 345 * http://bugzilla.kernel.org/show_bug.cgi?id=4980
372 */ 346 */
373int acpi_ec_burst_enable(struct acpi_ec *ec) 347static int acpi_ec_burst_enable(struct acpi_ec *ec)
374{ 348{
375 u8 d; 349 u8 d;
376 struct transaction t = {.command = ACPI_EC_BURST_ENABLE, 350 struct transaction t = {.command = ACPI_EC_BURST_ENABLE,
@@ -380,7 +354,7 @@ int acpi_ec_burst_enable(struct acpi_ec *ec)
380 return acpi_ec_transaction(ec, &t, 0); 354 return acpi_ec_transaction(ec, &t, 0);
381} 355}
382 356
383int acpi_ec_burst_disable(struct acpi_ec *ec) 357static int acpi_ec_burst_disable(struct acpi_ec *ec)
384{ 358{
385 struct transaction t = {.command = ACPI_EC_BURST_DISABLE, 359 struct transaction t = {.command = ACPI_EC_BURST_DISABLE,
386 .wdata = NULL, .rdata = NULL, 360 .wdata = NULL, .rdata = NULL,
@@ -756,10 +730,15 @@ static acpi_status
756acpi_ec_register_query_methods(acpi_handle handle, u32 level, 730acpi_ec_register_query_methods(acpi_handle handle, u32 level,
757 void *context, void **return_value) 731 void *context, void **return_value)
758{ 732{
759 struct acpi_namespace_node *node = handle; 733 char node_name[5];
734 struct acpi_buffer buffer = { sizeof(node_name), node_name };
760 struct acpi_ec *ec = context; 735 struct acpi_ec *ec = context;
761 int value = 0; 736 int value = 0;
762 if (sscanf(node->name.ascii, "_Q%x", &value) == 1) { 737 acpi_status status;
738
739 status = acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer);
740
741 if (ACPI_SUCCESS(status) && sscanf(node_name, "_Q%x", &value) == 1) {
763 acpi_ec_add_query_handler(ec, value, handle, NULL, NULL); 742 acpi_ec_add_query_handler(ec, value, handle, NULL, NULL);
764 } 743 }
765 return AE_OK; 744 return AE_OK;
@@ -978,8 +957,8 @@ static const struct acpi_device_id ec_device_ids[] = {
978 957
979int __init acpi_ec_ecdt_probe(void) 958int __init acpi_ec_ecdt_probe(void)
980{ 959{
981 int ret;
982 acpi_status status; 960 acpi_status status;
961 struct acpi_ec *saved_ec = NULL;
983 struct acpi_table_ecdt *ecdt_ptr; 962 struct acpi_table_ecdt *ecdt_ptr;
984 963
985 boot_ec = make_acpi_ec(); 964 boot_ec = make_acpi_ec();
@@ -994,42 +973,55 @@ int __init acpi_ec_ecdt_probe(void)
994 pr_info(PREFIX "EC description table is found, configuring boot EC\n"); 973 pr_info(PREFIX "EC description table is found, configuring boot EC\n");
995 boot_ec->command_addr = ecdt_ptr->control.address; 974 boot_ec->command_addr = ecdt_ptr->control.address;
996 boot_ec->data_addr = ecdt_ptr->data.address; 975 boot_ec->data_addr = ecdt_ptr->data.address;
997 if (dmi_check_system(ec_dmi_table)) {
998 /*
999 * If the board falls into ec_dmi_table, it means
1000 * that ECDT table gives the incorrect command/status
1001 * & data I/O address. Just fix it.
1002 */
1003 boot_ec->data_addr = ecdt_ptr->control.address;
1004 boot_ec->command_addr = ecdt_ptr->data.address;
1005 }
1006 boot_ec->gpe = ecdt_ptr->gpe; 976 boot_ec->gpe = ecdt_ptr->gpe;
1007 boot_ec->handle = ACPI_ROOT_OBJECT; 977 boot_ec->handle = ACPI_ROOT_OBJECT;
1008 acpi_get_handle(ACPI_ROOT_OBJECT, ecdt_ptr->id, &boot_ec->handle); 978 acpi_get_handle(ACPI_ROOT_OBJECT, ecdt_ptr->id, &boot_ec->handle);
979 /* Don't trust ECDT, which comes from ASUSTek */
980 if (!dmi_name_in_vendors("ASUS"))
981 goto install;
982 saved_ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
983 if (!saved_ec)
984 return -ENOMEM;
985 memcpy(&saved_ec, boot_ec, sizeof(saved_ec));
986 /* fall through */
987 }
988 /* This workaround is needed only on some broken machines,
989 * which require early EC, but fail to provide ECDT */
990 printk(KERN_DEBUG PREFIX "Look up EC in DSDT\n");
991 status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device,
992 boot_ec, NULL);
993 /* Check that acpi_get_devices actually find something */
994 if (ACPI_FAILURE(status) || !boot_ec->handle)
995 goto error;
996 if (saved_ec) {
997 /* try to find good ECDT from ASUSTek */
998 if (saved_ec->command_addr != boot_ec->command_addr ||
999 saved_ec->data_addr != boot_ec->data_addr ||
1000 saved_ec->gpe != boot_ec->gpe ||
1001 saved_ec->handle != boot_ec->handle)
1002 pr_info(PREFIX "ASUSTek keeps feeding us with broken "
1003 "ECDT tables, which are very hard to workaround. "
1004 "Trying to use DSDT EC info instead. Please send "
1005 "output of acpidump to linux-acpi@vger.kernel.org\n");
1006 kfree(saved_ec);
1007 saved_ec = NULL;
1009 } else { 1008 } else {
1010 /* This workaround is needed only on some broken machines,
1011 * which require early EC, but fail to provide ECDT */
1012 acpi_handle x;
1013 printk(KERN_DEBUG PREFIX "Look up EC in DSDT\n");
1014 status = acpi_get_devices(ec_device_ids[0].id, ec_parse_device,
1015 boot_ec, NULL);
1016 /* Check that acpi_get_devices actually find something */
1017 if (ACPI_FAILURE(status) || !boot_ec->handle)
1018 goto error;
1019 /* We really need to limit this workaround, the only ASUS, 1009 /* We really need to limit this workaround, the only ASUS,
1020 * which needs it, has fake EC._INI method, so use it as flag. 1010 * which needs it, has fake EC._INI method, so use it as flag.
1021 * Keep boot_ec struct as it will be needed soon. 1011 * Keep boot_ec struct as it will be needed soon.
1022 */ 1012 */
1023 if (ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI", &x))) 1013 acpi_handle dummy;
1014 if (!dmi_name_in_vendors("ASUS") ||
1015 ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI",
1016 &dummy)))
1024 return -ENODEV; 1017 return -ENODEV;
1025 } 1018 }
1026 1019install:
1027 ret = ec_install_handlers(boot_ec); 1020 if (!ec_install_handlers(boot_ec)) {
1028 if (!ret) {
1029 first_ec = boot_ec; 1021 first_ec = boot_ec;
1030 return 0; 1022 return 0;
1031 } 1023 }
1032 error: 1024error:
1033 kfree(boot_ec); 1025 kfree(boot_ec);
1034 boot_ec = NULL; 1026 boot_ec = NULL;
1035 return -ENODEV; 1027 return -ENODEV;
diff --git a/drivers/acpi/events/Makefile b/drivers/acpi/events/Makefile
deleted file mode 100644
index d29f2ee449cc..000000000000
--- a/drivers/acpi/events/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
1#
2# Makefile for all Linux ACPI interpreter subdirectories
3#
4
5obj-y := evevent.o evregion.o evsci.o evxfevnt.o \
6 evmisc.o evrgnini.o evxface.o evxfregn.o \
7 evgpe.o evgpeblk.o
8
9EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/executer/Makefile b/drivers/acpi/executer/Makefile
deleted file mode 100644
index e09998aa012f..000000000000
--- a/drivers/acpi/executer/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
1#
2# Makefile for all Linux ACPI interpreter subdirectories
3#
4
5obj-y := exconfig.o exfield.o exnames.o exoparg6.o exresolv.o exstorob.o\
6 exconvrt.o exfldio.o exoparg1.o exprep.o exresop.o exsystem.o\
7 excreate.o exmisc.o exoparg2.o exregion.o exstore.o exutils.o \
8 exdump.o exmutex.o exoparg3.o exresnte.o exstoren.o
9
10EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/hardware/Makefile b/drivers/acpi/hardware/Makefile
deleted file mode 100644
index 438ad373b9ad..000000000000
--- a/drivers/acpi/hardware/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
1#
2# Makefile for all Linux ACPI interpreter subdirectories
3#
4
5obj-y := hwacpi.o hwgpe.o hwregs.o hwsleep.o
6
7obj-$(ACPI_FUTURE_USAGE) += hwtimer.o
8
9EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/namespace/Makefile b/drivers/acpi/namespace/Makefile
deleted file mode 100644
index 371a2daf837f..000000000000
--- a/drivers/acpi/namespace/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
1#
2# Makefile for all Linux ACPI interpreter subdirectories
3#
4
5obj-y := nsaccess.o nsload.o nssearch.o nsxfeval.o \
6 nsalloc.o nseval.o nsnames.o nsutils.o nsxfname.o \
7 nsdump.o nsinit.o nsobject.o nswalk.o nsxfobj.o \
8 nsparse.o nspredef.o
9
10obj-$(ACPI_FUTURE_USAGE) += nsdumpdv.o
11
12EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
index 25ceae9191ef..c5e292aab0e3 100644
--- a/drivers/acpi/numa.c
+++ b/drivers/acpi/numa.c
@@ -29,7 +29,6 @@
29#include <linux/errno.h> 29#include <linux/errno.h>
30#include <linux/acpi.h> 30#include <linux/acpi.h>
31#include <acpi/acpi_bus.h> 31#include <acpi/acpi_bus.h>
32#include <acpi/acmacros.h>
33 32
34#define ACPI_NUMA 0x80000000 33#define ACPI_NUMA 0x80000000
35#define _COMPONENT ACPI_NUMA 34#define _COMPONENT ACPI_NUMA
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index c8111424dcb8..6729a4992f2b 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -726,7 +726,7 @@ static acpi_status __acpi_os_execute(acpi_execute_type type,
726 726
727 dpc = kmalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC); 727 dpc = kmalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC);
728 if (!dpc) 728 if (!dpc)
729 return_ACPI_STATUS(AE_NO_MEMORY); 729 return AE_NO_MEMORY;
730 730
731 dpc->function = function; 731 dpc->function = function;
732 dpc->context = context; 732 dpc->context = context;
@@ -747,7 +747,7 @@ static acpi_status __acpi_os_execute(acpi_execute_type type,
747 status = AE_ERROR; 747 status = AE_ERROR;
748 kfree(dpc); 748 kfree(dpc);
749 } 749 }
750 return_ACPI_STATUS(status); 750 return status;
751} 751}
752 752
753acpi_status acpi_os_execute(acpi_execute_type type, 753acpi_status acpi_os_execute(acpi_execute_type type,
diff --git a/drivers/acpi/parser/Makefile b/drivers/acpi/parser/Makefile
deleted file mode 100644
index db24ee09cf11..000000000000
--- a/drivers/acpi/parser/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
1#
2# Makefile for all Linux ACPI interpreter subdirectories
3#
4
5obj-y := psargs.o psparse.o psloop.o pstree.o pswalk.o \
6 psopcode.o psscope.o psutils.o psxface.o
7
8EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c
index 4b252ea0e952..95650f83ce2e 100644
--- a/drivers/acpi/pci_bind.c
+++ b/drivers/acpi/pci_bind.c
@@ -99,7 +99,7 @@ acpi_status acpi_get_pci_id(acpi_handle handle, struct acpi_pci_id *id)
99 */ 99 */
100 100
101 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 101 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
102 "Device %s has PCI address %02x:%02x:%02x.%02x\n", 102 "Device %s has PCI address %04x:%02x:%02x.%d\n",
103 acpi_device_bid(device), id->segment, id->bus, 103 acpi_device_bid(device), id->segment, id->bus,
104 id->device, id->function)); 104 id->device, id->function));
105 105
@@ -111,12 +111,11 @@ EXPORT_SYMBOL(acpi_get_pci_id);
111int acpi_pci_bind(struct acpi_device *device) 111int acpi_pci_bind(struct acpi_device *device)
112{ 112{
113 int result = 0; 113 int result = 0;
114 acpi_status status = AE_OK; 114 acpi_status status;
115 struct acpi_pci_data *data = NULL; 115 struct acpi_pci_data *data;
116 struct acpi_pci_data *pdata = NULL; 116 struct acpi_pci_data *pdata;
117 char *pathname = NULL; 117 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
118 struct acpi_buffer buffer = { 0, NULL }; 118 acpi_handle handle;
119 acpi_handle handle = NULL;
120 struct pci_dev *dev; 119 struct pci_dev *dev;
121 struct pci_bus *bus; 120 struct pci_bus *bus;
122 121
@@ -124,21 +123,18 @@ int acpi_pci_bind(struct acpi_device *device)
124 if (!device || !device->parent) 123 if (!device || !device->parent)
125 return -EINVAL; 124 return -EINVAL;
126 125
127 pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
128 if (!pathname)
129 return -ENOMEM;
130 buffer.length = ACPI_PATHNAME_MAX;
131 buffer.pointer = pathname;
132
133 data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); 126 data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
134 if (!data) { 127 if (!data)
135 kfree(pathname);
136 return -ENOMEM; 128 return -ENOMEM;
129
130 status = acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
131 if (ACPI_FAILURE(status)) {
132 kfree(data);
133 return -ENODEV;
137 } 134 }
138 135
139 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
140 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n", 136 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n",
141 pathname)); 137 (char *)buffer.pointer));
142 138
143 /* 139 /*
144 * Segment & Bus 140 * Segment & Bus
@@ -166,7 +162,7 @@ int acpi_pci_bind(struct acpi_device *device)
166 data->id.device = device->pnp.bus_address >> 16; 162 data->id.device = device->pnp.bus_address >> 16;
167 data->id.function = device->pnp.bus_address & 0xFFFF; 163 data->id.function = device->pnp.bus_address & 0xFFFF;
168 164
169 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "...to %02x:%02x:%02x.%02x\n", 165 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "...to %04x:%02x:%02x.%d\n",
170 data->id.segment, data->id.bus, data->id.device, 166 data->id.segment, data->id.bus, data->id.device,
171 data->id.function)); 167 data->id.function));
172 168
@@ -196,7 +192,7 @@ int acpi_pci_bind(struct acpi_device *device)
196 } 192 }
197 if (!data->dev) { 193 if (!data->dev) {
198 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 194 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
199 "Device %02x:%02x:%02x.%02x not present in PCI namespace\n", 195 "Device %04x:%02x:%02x.%d not present in PCI namespace\n",
200 data->id.segment, data->id.bus, 196 data->id.segment, data->id.bus,
201 data->id.device, data->id.function)); 197 data->id.device, data->id.function));
202 result = -ENODEV; 198 result = -ENODEV;
@@ -204,7 +200,7 @@ int acpi_pci_bind(struct acpi_device *device)
204 } 200 }
205 if (!data->dev->bus) { 201 if (!data->dev->bus) {
206 printk(KERN_ERR PREFIX 202 printk(KERN_ERR PREFIX
207 "Device %02x:%02x:%02x.%02x has invalid 'bus' field\n", 203 "Device %04x:%02x:%02x.%d has invalid 'bus' field\n",
208 data->id.segment, data->id.bus, 204 data->id.segment, data->id.bus,
209 data->id.device, data->id.function); 205 data->id.device, data->id.function);
210 result = -ENODEV; 206 result = -ENODEV;
@@ -219,7 +215,7 @@ int acpi_pci_bind(struct acpi_device *device)
219 */ 215 */
220 if (data->dev->subordinate) { 216 if (data->dev->subordinate) {
221 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 217 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
222 "Device %02x:%02x:%02x.%02x is a PCI bridge\n", 218 "Device %04x:%02x:%02x.%d is a PCI bridge\n",
223 data->id.segment, data->id.bus, 219 data->id.segment, data->id.bus,
224 data->id.device, data->id.function)); 220 data->id.device, data->id.function));
225 data->bus = data->dev->subordinate; 221 data->bus = data->dev->subordinate;
@@ -262,7 +258,7 @@ int acpi_pci_bind(struct acpi_device *device)
262 } 258 }
263 259
264 end: 260 end:
265 kfree(pathname); 261 kfree(buffer.pointer);
266 if (result) 262 if (result)
267 kfree(data); 263 kfree(data);
268 264
@@ -272,25 +268,21 @@ int acpi_pci_bind(struct acpi_device *device)
272static int acpi_pci_unbind(struct acpi_device *device) 268static int acpi_pci_unbind(struct acpi_device *device)
273{ 269{
274 int result = 0; 270 int result = 0;
275 acpi_status status = AE_OK; 271 acpi_status status;
276 struct acpi_pci_data *data = NULL; 272 struct acpi_pci_data *data;
277 char *pathname = NULL; 273 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
278 struct acpi_buffer buffer = { 0, NULL };
279 274
280 275
281 if (!device || !device->parent) 276 if (!device || !device->parent)
282 return -EINVAL; 277 return -EINVAL;
283 278
284 pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); 279 status = acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
285 if (!pathname) 280 if (ACPI_FAILURE(status))
286 return -ENOMEM; 281 return -ENODEV;
287 282
288 buffer.length = ACPI_PATHNAME_MAX;
289 buffer.pointer = pathname;
290 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
291 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unbinding PCI device [%s]...\n", 283 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unbinding PCI device [%s]...\n",
292 pathname)); 284 (char *) buffer.pointer));
293 kfree(pathname); 285 kfree(buffer.pointer);
294 286
295 status = 287 status =
296 acpi_get_data(device->handle, acpi_pci_data_handler, 288 acpi_get_data(device->handle, acpi_pci_data_handler,
@@ -322,50 +314,44 @@ acpi_pci_bind_root(struct acpi_device *device,
322 struct acpi_pci_id *id, struct pci_bus *bus) 314 struct acpi_pci_id *id, struct pci_bus *bus)
323{ 315{
324 int result = 0; 316 int result = 0;
325 acpi_status status = AE_OK; 317 acpi_status status;
326 struct acpi_pci_data *data = NULL; 318 struct acpi_pci_data *data = NULL;
327 char *pathname = NULL; 319 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
328 struct acpi_buffer buffer = { 0, NULL };
329
330 pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
331 if (!pathname)
332 return -ENOMEM;
333
334 buffer.length = ACPI_PATHNAME_MAX;
335 buffer.pointer = pathname;
336 320
337 if (!device || !id || !bus) { 321 if (!device || !id || !bus) {
338 kfree(pathname);
339 return -EINVAL; 322 return -EINVAL;
340 } 323 }
341 324
342 data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); 325 data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
343 if (!data) { 326 if (!data)
344 kfree(pathname);
345 return -ENOMEM; 327 return -ENOMEM;
346 }
347 328
348 data->id = *id; 329 data->id = *id;
349 data->bus = bus; 330 data->bus = bus;
350 device->ops.bind = acpi_pci_bind; 331 device->ops.bind = acpi_pci_bind;
351 device->ops.unbind = acpi_pci_unbind; 332 device->ops.unbind = acpi_pci_unbind;
352 333
353 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer); 334 status = acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
335 if (ACPI_FAILURE(status)) {
336 kfree (data);
337 return -ENODEV;
338 }
354 339
355 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI root bridge [%s] to " 340 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI root bridge [%s] to "
356 "%02x:%02x\n", pathname, id->segment, id->bus)); 341 "%04x:%02x\n", (char *)buffer.pointer,
342 id->segment, id->bus));
357 343
358 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data); 344 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data);
359 if (ACPI_FAILURE(status)) { 345 if (ACPI_FAILURE(status)) {
360 ACPI_EXCEPTION((AE_INFO, status, 346 ACPI_EXCEPTION((AE_INFO, status,
361 "Unable to attach ACPI-PCI context to device %s", 347 "Unable to attach ACPI-PCI context to device %s",
362 pathname)); 348 (char *)buffer.pointer));
363 result = -ENODEV; 349 result = -ENODEV;
364 goto end; 350 goto end;
365 } 351 }
366 352
367 end: 353 end:
368 kfree(pathname); 354 kfree(buffer.pointer);
369 if (result != 0) 355 if (result != 0)
370 kfree(data); 356 kfree(data);
371 357
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index bf79d83bdfbb..891bdf6679f3 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -4,6 +4,8 @@
4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> 4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> 5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 * Copyright (C) 2002 Dominik Brodowski <devel@brodo.de> 6 * Copyright (C) 2002 Dominik Brodowski <devel@brodo.de>
7 * (c) Copyright 2008 Hewlett-Packard Development Company, L.P.
8 * Bjorn Helgaas <bjorn.helgaas@hp.com>
7 * 9 *
8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 10 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 * 11 *
@@ -41,29 +43,36 @@
41#define _COMPONENT ACPI_PCI_COMPONENT 43#define _COMPONENT ACPI_PCI_COMPONENT
42ACPI_MODULE_NAME("pci_irq"); 44ACPI_MODULE_NAME("pci_irq");
43 45
44static struct acpi_prt_list acpi_prt; 46struct acpi_prt_entry {
47 struct list_head list;
48 struct acpi_pci_id id;
49 u8 pin;
50 acpi_handle link;
51 u32 index; /* GSI, or link _CRS index */
52};
53
54static LIST_HEAD(acpi_prt_list);
45static DEFINE_SPINLOCK(acpi_prt_lock); 55static DEFINE_SPINLOCK(acpi_prt_lock);
46 56
57static inline char pin_name(int pin)
58{
59 return 'A' + pin - 1;
60}
61
47/* -------------------------------------------------------------------------- 62/* --------------------------------------------------------------------------
48 PCI IRQ Routing Table (PRT) Support 63 PCI IRQ Routing Table (PRT) Support
49 -------------------------------------------------------------------------- */ 64 -------------------------------------------------------------------------- */
50 65
51static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(int segment, 66static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(struct pci_dev *dev,
52 int bus, 67 int pin)
53 int device, int pin)
54{ 68{
55 struct acpi_prt_entry *entry = NULL; 69 struct acpi_prt_entry *entry;
56 70 int segment = pci_domain_nr(dev->bus);
57 if (!acpi_prt.count) 71 int bus = dev->bus->number;
58 return NULL; 72 int device = PCI_SLOT(dev->devfn);
59 73
60 /*
61 * Parse through all PRT entries looking for a match on the specified
62 * PCI device's segment, bus, device, and pin (don't care about func).
63 *
64 */
65 spin_lock(&acpi_prt_lock); 74 spin_lock(&acpi_prt_lock);
66 list_for_each_entry(entry, &acpi_prt.entries, node) { 75 list_for_each_entry(entry, &acpi_prt_list, list) {
67 if ((segment == entry->id.segment) 76 if ((segment == entry->id.segment)
68 && (bus == entry->id.bus) 77 && (bus == entry->id.bus)
69 && (device == entry->id.device) 78 && (device == entry->id.device)
@@ -72,7 +81,6 @@ static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(int segment,
72 return entry; 81 return entry;
73 } 82 }
74 } 83 }
75
76 spin_unlock(&acpi_prt_lock); 84 spin_unlock(&acpi_prt_lock);
77 return NULL; 85 return NULL;
78} 86}
@@ -124,25 +132,27 @@ struct prt_quirk {
124 char *actual_source; 132 char *actual_source;
125}; 133};
126 134
135#define PCI_INTX_PIN(c) (c - 'A' + 1)
136
127/* 137/*
128 * These systems have incorrect _PRT entries. The BIOS claims the PCI 138 * These systems have incorrect _PRT entries. The BIOS claims the PCI
129 * interrupt at the listed segment/bus/device/pin is connected to the first 139 * interrupt at the listed segment/bus/device/pin is connected to the first
130 * link device, but it is actually connected to the second. 140 * link device, but it is actually connected to the second.
131 */ 141 */
132static struct prt_quirk prt_quirks[] = { 142static struct prt_quirk prt_quirks[] = {
133 { medion_md9580, 0, 0, 9, 'A', 143 { medion_md9580, 0, 0, 9, PCI_INTX_PIN('A'),
134 "\\_SB_.PCI0.ISA_.LNKA", 144 "\\_SB_.PCI0.ISA_.LNKA",
135 "\\_SB_.PCI0.ISA_.LNKB"}, 145 "\\_SB_.PCI0.ISA_.LNKB"},
136 { dell_optiplex, 0, 0, 0xd, 'A', 146 { dell_optiplex, 0, 0, 0xd, PCI_INTX_PIN('A'),
137 "\\_SB_.LNKB", 147 "\\_SB_.LNKB",
138 "\\_SB_.LNKA"}, 148 "\\_SB_.LNKA"},
139 { hp_t5710, 0, 0, 1, 'A', 149 { hp_t5710, 0, 0, 1, PCI_INTX_PIN('A'),
140 "\\_SB_.PCI0.LNK1", 150 "\\_SB_.PCI0.LNK1",
141 "\\_SB_.PCI0.LNK3"}, 151 "\\_SB_.PCI0.LNK3"},
142}; 152};
143 153
144static void 154static void do_prt_fixups(struct acpi_prt_entry *entry,
145do_prt_fixups(struct acpi_prt_entry *entry, struct acpi_pci_routing_table *prt) 155 struct acpi_pci_routing_table *prt)
146{ 156{
147 int i; 157 int i;
148 struct prt_quirk *quirk; 158 struct prt_quirk *quirk;
@@ -158,42 +168,43 @@ do_prt_fixups(struct acpi_prt_entry *entry, struct acpi_pci_routing_table *prt)
158 entry->id.segment == quirk->segment && 168 entry->id.segment == quirk->segment &&
159 entry->id.bus == quirk->bus && 169 entry->id.bus == quirk->bus &&
160 entry->id.device == quirk->device && 170 entry->id.device == quirk->device &&
161 entry->pin + 'A' == quirk->pin && 171 entry->pin == quirk->pin &&
162 !strcmp(prt->source, quirk->source) && 172 !strcmp(prt->source, quirk->source) &&
163 strlen(prt->source) >= strlen(quirk->actual_source)) { 173 strlen(prt->source) >= strlen(quirk->actual_source)) {
164 printk(KERN_WARNING PREFIX "firmware reports " 174 printk(KERN_WARNING PREFIX "firmware reports "
165 "%04x:%02x:%02x PCI INT %c connected to %s; " 175 "%04x:%02x:%02x PCI INT %c connected to %s; "
166 "changing to %s\n", 176 "changing to %s\n",
167 entry->id.segment, entry->id.bus, 177 entry->id.segment, entry->id.bus,
168 entry->id.device, 'A' + entry->pin, 178 entry->id.device, pin_name(entry->pin),
169 prt->source, quirk->actual_source); 179 prt->source, quirk->actual_source);
170 strcpy(prt->source, quirk->actual_source); 180 strcpy(prt->source, quirk->actual_source);
171 } 181 }
172 } 182 }
173} 183}
174 184
175static int 185static int acpi_pci_irq_add_entry(acpi_handle handle, int segment, int bus,
176acpi_pci_irq_add_entry(acpi_handle handle, 186 struct acpi_pci_routing_table *prt)
177 int segment, int bus, struct acpi_pci_routing_table *prt)
178{ 187{
179 struct acpi_prt_entry *entry = NULL; 188 struct acpi_prt_entry *entry;
180
181
182 if (!prt)
183 return -EINVAL;
184 189
185 entry = kzalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL); 190 entry = kzalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL);
186 if (!entry) 191 if (!entry)
187 return -ENOMEM; 192 return -ENOMEM;
188 193
194 /*
195 * Note that the _PRT uses 0=INTA, 1=INTB, etc, while PCI uses
196 * 1=INTA, 2=INTB. We use the PCI encoding throughout, so convert
197 * it here.
198 */
189 entry->id.segment = segment; 199 entry->id.segment = segment;
190 entry->id.bus = bus; 200 entry->id.bus = bus;
191 entry->id.device = (prt->address >> 16) & 0xFFFF; 201 entry->id.device = (prt->address >> 16) & 0xFFFF;
192 entry->id.function = prt->address & 0xFFFF; 202 entry->pin = prt->pin + 1;
193 entry->pin = prt->pin;
194 203
195 do_prt_fixups(entry, prt); 204 do_prt_fixups(entry, prt);
196 205
206 entry->index = prt->source_index;
207
197 /* 208 /*
198 * Type 1: Dynamic 209 * Type 1: Dynamic
199 * --------------- 210 * ---------------
@@ -207,10 +218,9 @@ acpi_pci_irq_add_entry(acpi_handle handle,
207 * (e.g. exists somewhere 'below' this _PRT entry in the ACPI 218 * (e.g. exists somewhere 'below' this _PRT entry in the ACPI
208 * namespace). 219 * namespace).
209 */ 220 */
210 if (prt->source[0]) { 221 if (prt->source[0])
211 acpi_get_handle(handle, prt->source, &entry->link.handle); 222 acpi_get_handle(handle, prt->source, &entry->link);
212 entry->link.index = prt->source_index; 223
213 }
214 /* 224 /*
215 * Type 2: Static 225 * Type 2: Static
216 * -------------- 226 * --------------
@@ -218,84 +228,38 @@ acpi_pci_irq_add_entry(acpi_handle handle,
218 * the IRQ value, which is hardwired to specific interrupt inputs on 228 * the IRQ value, which is hardwired to specific interrupt inputs on
219 * the interrupt controller. 229 * the interrupt controller.
220 */ 230 */
221 else
222 entry->link.index = prt->source_index;
223 231
224 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO, 232 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO,
225 " %02X:%02X:%02X[%c] -> %s[%d]\n", 233 " %04x:%02x:%02x[%c] -> %s[%d]\n",
226 entry->id.segment, entry->id.bus, 234 entry->id.segment, entry->id.bus,
227 entry->id.device, ('A' + entry->pin), prt->source, 235 entry->id.device, pin_name(entry->pin),
228 entry->link.index)); 236 prt->source, entry->index));
229 237
230 spin_lock(&acpi_prt_lock); 238 spin_lock(&acpi_prt_lock);
231 list_add_tail(&entry->node, &acpi_prt.entries); 239 list_add_tail(&entry->list, &acpi_prt_list);
232 acpi_prt.count++;
233 spin_unlock(&acpi_prt_lock); 240 spin_unlock(&acpi_prt_lock);
234 241
235 return 0; 242 return 0;
236} 243}
237 244
238static void
239acpi_pci_irq_del_entry(int segment, int bus, struct acpi_prt_entry *entry)
240{
241 if (segment == entry->id.segment && bus == entry->id.bus) {
242 acpi_prt.count--;
243 list_del(&entry->node);
244 kfree(entry);
245 }
246}
247
248int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus) 245int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
249{ 246{
250 acpi_status status = AE_OK; 247 acpi_status status;
251 char *pathname = NULL; 248 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
252 struct acpi_buffer buffer = { 0, NULL }; 249 struct acpi_pci_routing_table *entry;
253 struct acpi_pci_routing_table *prt = NULL;
254 struct acpi_pci_routing_table *entry = NULL;
255 static int first_time = 1;
256
257
258 pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
259 if (!pathname)
260 return -ENOMEM;
261
262 if (first_time) {
263 acpi_prt.count = 0;
264 INIT_LIST_HEAD(&acpi_prt.entries);
265 first_time = 0;
266 }
267
268 /*
269 * NOTE: We're given a 'handle' to the _PRT object's parent device
270 * (either a PCI root bridge or PCI-PCI bridge).
271 */
272 250
273 buffer.length = ACPI_PATHNAME_MAX; 251 /* 'handle' is the _PRT's parent (root bridge or PCI-PCI bridge) */
274 buffer.pointer = pathname; 252 status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
275 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); 253 if (ACPI_FAILURE(status))
254 return -ENODEV;
276 255
277 printk(KERN_DEBUG "ACPI: PCI Interrupt Routing Table [%s._PRT]\n", 256 printk(KERN_DEBUG "ACPI: PCI Interrupt Routing Table [%s._PRT]\n",
278 pathname); 257 (char *) buffer.pointer);
279 258
280 /* 259 kfree(buffer.pointer);
281 * Evaluate this _PRT and add its entries to our global list (acpi_prt).
282 */
283 260
284 buffer.length = 0; 261 buffer.length = ACPI_ALLOCATE_BUFFER;
285 buffer.pointer = NULL; 262 buffer.pointer = NULL;
286 kfree(pathname);
287 status = acpi_get_irq_routing_table(handle, &buffer);
288 if (status != AE_BUFFER_OVERFLOW) {
289 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRT [%s]",
290 acpi_format_exception(status)));
291 return -ENODEV;
292 }
293
294 prt = kzalloc(buffer.length, GFP_KERNEL);
295 if (!prt) {
296 return -ENOMEM;
297 }
298 buffer.pointer = prt;
299 263
300 status = acpi_get_irq_routing_table(handle, &buffer); 264 status = acpi_get_irq_routing_table(handle, &buffer);
301 if (ACPI_FAILURE(status)) { 265 if (ACPI_FAILURE(status)) {
@@ -305,36 +269,30 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
305 return -ENODEV; 269 return -ENODEV;
306 } 270 }
307 271
308 entry = prt; 272 entry = buffer.pointer;
309
310 while (entry && (entry->length > 0)) { 273 while (entry && (entry->length > 0)) {
311 acpi_pci_irq_add_entry(handle, segment, bus, entry); 274 acpi_pci_irq_add_entry(handle, segment, bus, entry);
312 entry = (struct acpi_pci_routing_table *) 275 entry = (struct acpi_pci_routing_table *)
313 ((unsigned long)entry + entry->length); 276 ((unsigned long)entry + entry->length);
314 } 277 }
315 278
316 kfree(prt); 279 kfree(buffer.pointer);
317
318 return 0; 280 return 0;
319} 281}
320 282
321void acpi_pci_irq_del_prt(int segment, int bus) 283void acpi_pci_irq_del_prt(int segment, int bus)
322{ 284{
323 struct list_head *node = NULL, *n = NULL; 285 struct acpi_prt_entry *entry, *tmp;
324 struct acpi_prt_entry *entry = NULL;
325
326 if (!acpi_prt.count) {
327 return;
328 }
329 286
330 printk(KERN_DEBUG 287 printk(KERN_DEBUG
331 "ACPI: Delete PCI Interrupt Routing Table for %x:%x\n", segment, 288 "ACPI: Delete PCI Interrupt Routing Table for %04x:%02x\n",
332 bus); 289 segment, bus);
333 spin_lock(&acpi_prt_lock); 290 spin_lock(&acpi_prt_lock);
334 list_for_each_safe(node, n, &acpi_prt.entries) { 291 list_for_each_entry_safe(entry, tmp, &acpi_prt_list, list) {
335 entry = list_entry(node, struct acpi_prt_entry, node); 292 if (segment == entry->id.segment && bus == entry->id.bus) {
336 293 list_del(&entry->list);
337 acpi_pci_irq_del_entry(segment, bus, entry); 294 kfree(entry);
295 }
338 } 296 }
339 spin_unlock(&acpi_prt_lock); 297 spin_unlock(&acpi_prt_lock);
340} 298}
@@ -342,162 +300,26 @@ void acpi_pci_irq_del_prt(int segment, int bus)
342/* -------------------------------------------------------------------------- 300/* --------------------------------------------------------------------------
343 PCI Interrupt Routing Support 301 PCI Interrupt Routing Support
344 -------------------------------------------------------------------------- */ 302 -------------------------------------------------------------------------- */
345typedef int (*irq_lookup_func) (struct acpi_prt_entry *, int *, int *, char **); 303static struct acpi_prt_entry *acpi_pci_irq_lookup(struct pci_dev *dev, int pin)
346
347static int
348acpi_pci_allocate_irq(struct acpi_prt_entry *entry,
349 int *triggering, int *polarity, char **link)
350{
351 int irq;
352
353
354 if (entry->link.handle) {
355 irq = acpi_pci_link_allocate_irq(entry->link.handle,
356 entry->link.index, triggering,
357 polarity, link);
358 if (irq < 0) {
359 printk(KERN_WARNING PREFIX
360 "Invalid IRQ link routing entry\n");
361 return -1;
362 }
363 } else {
364 irq = entry->link.index;
365 *triggering = ACPI_LEVEL_SENSITIVE;
366 *polarity = ACPI_ACTIVE_LOW;
367 }
368
369 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found IRQ %d\n", irq));
370 return irq;
371}
372
373static int
374acpi_pci_free_irq(struct acpi_prt_entry *entry,
375 int *triggering, int *polarity, char **link)
376{
377 int irq;
378
379 if (entry->link.handle) {
380 irq = acpi_pci_link_free_irq(entry->link.handle);
381 } else {
382 irq = entry->link.index;
383 }
384 return irq;
385}
386
387#ifdef CONFIG_X86_IO_APIC
388extern int noioapicquirk;
389
390static int bridge_has_boot_interrupt_variant(struct pci_bus *bus)
391{ 304{
392 struct pci_bus *bus_it; 305 struct acpi_prt_entry *entry;
393 306 struct pci_dev *bridge;
394 for (bus_it = bus ; bus_it ; bus_it = bus_it->parent) { 307 u8 bridge_pin, orig_pin = pin;
395 if (!bus_it->self) 308
396 return 0; 309 entry = acpi_pci_irq_find_prt_entry(dev, pin);
397 310 if (entry) {
398 printk(KERN_INFO "vendor=%04x device=%04x\n", bus_it->self->vendor, 311 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %s[%c] _PRT entry\n",
399 bus_it->self->device); 312 pci_name(dev), pin_name(pin)));
400 313 return entry;
401 if (bus_it->self->irq_reroute_variant)
402 return bus_it->self->irq_reroute_variant;
403 }
404 return 0;
405}
406#endif /* CONFIG_X86_IO_APIC */
407
408/*
409 * acpi_pci_irq_lookup
410 * success: return IRQ >= 0
411 * failure: return -1
412 */
413static int
414acpi_pci_irq_lookup(struct pci_bus *bus,
415 int device,
416 int pin,
417 int *triggering,
418 int *polarity, char **link, irq_lookup_func func)
419{
420 struct acpi_prt_entry *entry = NULL;
421 int segment = pci_domain_nr(bus);
422 int bus_nr = bus->number;
423 int ret;
424
425
426 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
427 "Searching for PRT entry for %02x:%02x:%02x[%c]\n",
428 segment, bus_nr, device, ('A' + pin)));
429
430 entry = acpi_pci_irq_find_prt_entry(segment, bus_nr, device, pin);
431 if (!entry) {
432 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "PRT entry not found\n"));
433 return -1;
434 }
435
436 ret = func(entry, triggering, polarity, link);
437
438#ifdef CONFIG_X86_IO_APIC
439 /*
440 * Some chipsets (e.g. intel 6700PXH) generate a legacy INTx when the
441 * IRQ entry in the chipset's IO-APIC is masked (as, e.g. the RT kernel
442 * does during interrupt handling). When this INTx generation cannot be
443 * disabled, we reroute these interrupts to their legacy equivalent to
444 * get rid of spurious interrupts.
445 */
446 if (!noioapicquirk) {
447 switch (bridge_has_boot_interrupt_variant(bus)) {
448 case 0:
449 /* no rerouting necessary */
450 break;
451
452 case INTEL_IRQ_REROUTE_VARIANT:
453 /*
454 * Remap according to INTx routing table in 6700PXH
455 * specs, intel order number 302628-002, section
456 * 2.15.2. Other chipsets (80332, ...) have the same
457 * mapping and are handled here as well.
458 */
459 printk(KERN_INFO "pci irq %d -> rerouted to legacy "
460 "irq %d\n", ret, (ret % 4) + 16);
461 ret = (ret % 4) + 16;
462 break;
463
464 default:
465 printk(KERN_INFO "not rerouting irq %d to legacy irq: "
466 "unknown mapping\n", ret);
467 break;
468 }
469 } 314 }
470#endif /* CONFIG_X86_IO_APIC */
471
472 return ret;
473}
474
475/*
476 * acpi_pci_irq_derive
477 * success: return IRQ >= 0
478 * failure: return < 0
479 */
480static int
481acpi_pci_irq_derive(struct pci_dev *dev,
482 int pin,
483 int *triggering,
484 int *polarity, char **link, irq_lookup_func func)
485{
486 struct pci_dev *bridge = dev;
487 int irq = -1;
488 u8 bridge_pin = 0, orig_pin = pin;
489
490
491 if (!dev)
492 return -EINVAL;
493 315
494 /* 316 /*
495 * Attempt to derive an IRQ for this device from a parent bridge's 317 * Attempt to derive an IRQ for this device from a parent bridge's
496 * PCI interrupt routing entry (eg. yenta bridge and add-in card bridge). 318 * PCI interrupt routing entry (eg. yenta bridge and add-in card bridge).
497 */ 319 */
498 while (irq < 0 && bridge->bus->self) { 320 bridge = dev->bus->self;
499 pin = (pin + PCI_SLOT(bridge->devfn)) % 4; 321 while (bridge) {
500 bridge = bridge->bus->self; 322 pin = (((pin - 1) + PCI_SLOT(dev->devfn)) % 4) + 1;
501 323
502 if ((bridge->class >> 8) == PCI_CLASS_BRIDGE_CARDBUS) { 324 if ((bridge->class >> 8) == PCI_CLASS_BRIDGE_CARDBUS) {
503 /* PC card has the same IRQ as its cardbridge */ 325 /* PC card has the same IRQ as its cardbridge */
@@ -506,50 +328,40 @@ acpi_pci_irq_derive(struct pci_dev *dev,
506 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 328 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
507 "No interrupt pin configured for device %s\n", 329 "No interrupt pin configured for device %s\n",
508 pci_name(bridge))); 330 pci_name(bridge)));
509 return -1; 331 return NULL;
510 } 332 }
511 /* Pin is from 0 to 3 */
512 bridge_pin--;
513 pin = bridge_pin; 333 pin = bridge_pin;
514 } 334 }
515 335
516 irq = acpi_pci_irq_lookup(bridge->bus, PCI_SLOT(bridge->devfn), 336 entry = acpi_pci_irq_find_prt_entry(bridge, pin);
517 pin, triggering, polarity, 337 if (entry) {
518 link, func); 338 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
519 } 339 "Derived GSI for %s INT %c from %s\n",
340 pci_name(dev), pin_name(orig_pin),
341 pci_name(bridge)));
342 return entry;
343 }
520 344
521 if (irq < 0) { 345 dev = bridge;
522 dev_warn(&dev->dev, "can't derive routing for PCI INT %c\n", 346 bridge = dev->bus->self;
523 'A' + orig_pin);
524 return -1;
525 } 347 }
526 348
527 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Derive IRQ %d for device %s from %s\n", 349 dev_warn(&dev->dev, "can't derive routing for PCI INT %c\n",
528 irq, pci_name(dev), pci_name(bridge))); 350 pin_name(orig_pin));
529 351 return NULL;
530 return irq;
531} 352}
532 353
533/*
534 * acpi_pci_irq_enable
535 * success: return 0
536 * failure: return < 0
537 */
538
539int acpi_pci_irq_enable(struct pci_dev *dev) 354int acpi_pci_irq_enable(struct pci_dev *dev)
540{ 355{
541 int irq = 0; 356 struct acpi_prt_entry *entry;
542 u8 pin = 0; 357 int gsi;
358 u8 pin;
543 int triggering = ACPI_LEVEL_SENSITIVE; 359 int triggering = ACPI_LEVEL_SENSITIVE;
544 int polarity = ACPI_ACTIVE_LOW; 360 int polarity = ACPI_ACTIVE_LOW;
545 char *link = NULL; 361 char *link = NULL;
546 char link_desc[16]; 362 char link_desc[16];
547 int rc; 363 int rc;
548 364
549
550 if (!dev)
551 return -EINVAL;
552
553 pin = dev->pin; 365 pin = dev->pin;
554 if (!pin) { 366 if (!pin) {
555 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 367 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -557,31 +369,9 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
557 pci_name(dev))); 369 pci_name(dev)));
558 return 0; 370 return 0;
559 } 371 }
560 pin--;
561
562 if (!dev->bus) {
563 dev_err(&dev->dev, "invalid (NULL) 'bus' field\n");
564 return -ENODEV;
565 }
566
567 /*
568 * First we check the PCI IRQ routing table (PRT) for an IRQ. PRT
569 * values override any BIOS-assigned IRQs set during boot.
570 */
571 irq = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
572 &triggering, &polarity, &link,
573 acpi_pci_allocate_irq);
574
575 /*
576 * If no PRT entry was found, we'll try to derive an IRQ from the
577 * device's parent bridge.
578 */
579 if (irq < 0)
580 irq = acpi_pci_irq_derive(dev, pin, &triggering,
581 &polarity, &link,
582 acpi_pci_allocate_irq);
583 372
584 if (irq < 0) { 373 entry = acpi_pci_irq_lookup(dev, pin);
374 if (!entry) {
585 /* 375 /*
586 * IDE legacy mode controller IRQs are magic. Why do compat 376 * IDE legacy mode controller IRQs are magic. Why do compat
587 * extensions always make such a nasty mess. 377 * extensions always make such a nasty mess.
@@ -590,12 +380,24 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
590 (dev->class & 0x05) == 0) 380 (dev->class & 0x05) == 0)
591 return 0; 381 return 0;
592 } 382 }
383
384 if (entry) {
385 if (entry->link)
386 gsi = acpi_pci_link_allocate_irq(entry->link,
387 entry->index,
388 &triggering, &polarity,
389 &link);
390 else
391 gsi = entry->index;
392 } else
393 gsi = -1;
394
593 /* 395 /*
594 * No IRQ known to the ACPI subsystem - maybe the BIOS / 396 * No IRQ known to the ACPI subsystem - maybe the BIOS /
595 * driver reported one, then use it. Exit in any case. 397 * driver reported one, then use it. Exit in any case.
596 */ 398 */
597 if (irq < 0) { 399 if (gsi < 0) {
598 dev_warn(&dev->dev, "PCI INT %c: no GSI", 'A' + pin); 400 dev_warn(&dev->dev, "PCI INT %c: no GSI", pin_name(pin));
599 /* Interrupt Line values above 0xF are forbidden */ 401 /* Interrupt Line values above 0xF are forbidden */
600 if (dev->irq > 0 && (dev->irq <= 0xF)) { 402 if (dev->irq > 0 && (dev->irq <= 0xF)) {
601 printk(" - using IRQ %d\n", dev->irq); 403 printk(" - using IRQ %d\n", dev->irq);
@@ -608,10 +410,10 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
608 } 410 }
609 } 411 }
610 412
611 rc = acpi_register_gsi(irq, triggering, polarity); 413 rc = acpi_register_gsi(gsi, triggering, polarity);
612 if (rc < 0) { 414 if (rc < 0) {
613 dev_warn(&dev->dev, "PCI INT %c: failed to register GSI\n", 415 dev_warn(&dev->dev, "PCI INT %c: failed to register GSI\n",
614 'A' + pin); 416 pin_name(pin));
615 return rc; 417 return rc;
616 } 418 }
617 dev->irq = rc; 419 dev->irq = rc;
@@ -622,7 +424,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
622 link_desc[0] = '\0'; 424 link_desc[0] = '\0';
623 425
624 dev_info(&dev->dev, "PCI INT %c%s -> GSI %u (%s, %s) -> IRQ %d\n", 426 dev_info(&dev->dev, "PCI INT %c%s -> GSI %u (%s, %s) -> IRQ %d\n",
625 'A' + pin, link_desc, irq, 427 pin_name(pin), link_desc, gsi,
626 (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge", 428 (triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge",
627 (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq); 429 (polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq);
628 430
@@ -636,42 +438,28 @@ void __attribute__ ((weak)) acpi_unregister_gsi(u32 i)
636 438
637void acpi_pci_irq_disable(struct pci_dev *dev) 439void acpi_pci_irq_disable(struct pci_dev *dev)
638{ 440{
639 int gsi = 0; 441 struct acpi_prt_entry *entry;
640 u8 pin = 0; 442 int gsi;
641 int triggering = ACPI_LEVEL_SENSITIVE; 443 u8 pin;
642 int polarity = ACPI_ACTIVE_LOW;
643
644
645 if (!dev || !dev->bus)
646 return;
647 444
648 pin = dev->pin; 445 pin = dev->pin;
649 if (!pin) 446 if (!pin)
650 return; 447 return;
651 pin--;
652 448
653 /* 449 entry = acpi_pci_irq_lookup(dev, pin);
654 * First we check the PCI IRQ routing table (PRT) for an IRQ. 450 if (!entry)
655 */
656 gsi = acpi_pci_irq_lookup(dev->bus, PCI_SLOT(dev->devfn), pin,
657 &triggering, &polarity, NULL,
658 acpi_pci_free_irq);
659 /*
660 * If no PRT entry was found, we'll try to derive an IRQ from the
661 * device's parent bridge.
662 */
663 if (gsi < 0)
664 gsi = acpi_pci_irq_derive(dev, pin,
665 &triggering, &polarity, NULL,
666 acpi_pci_free_irq);
667 if (gsi < 0)
668 return; 451 return;
669 452
453 if (entry->link)
454 gsi = acpi_pci_link_free_irq(entry->link);
455 else
456 gsi = entry->index;
457
670 /* 458 /*
671 * TBD: It might be worth clearing dev->irq by magic constant 459 * TBD: It might be worth clearing dev->irq by magic constant
672 * (e.g. PCI_UNDEFINED_IRQ). 460 * (e.g. PCI_UNDEFINED_IRQ).
673 */ 461 */
674 462
675 dev_info(&dev->dev, "PCI INT %c disabled\n", 'A' + pin); 463 dev_info(&dev->dev, "PCI INT %c disabled\n", pin_name(pin));
676 acpi_unregister_gsi(gsi); 464 acpi_unregister_gsi(gsi);
677} 465}
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index e52ad91ce2dc..1c6e73c7865e 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -796,10 +796,6 @@ static int irqrouter_resume(struct sys_device *dev)
796 struct list_head *node = NULL; 796 struct list_head *node = NULL;
797 struct acpi_pci_link *link = NULL; 797 struct acpi_pci_link *link = NULL;
798 798
799
800 /* Make sure SCI is enabled again (Apple firmware bug?) */
801 acpi_set_register(ACPI_BITREG_SCI_ENABLE, 1);
802
803 list_for_each(node, &acpi_link.entries) { 799 list_for_each(node, &acpi_link.entries) {
804 link = list_entry(node, struct acpi_pci_link, node); 800 link = list_entry(node, struct acpi_pci_link, node);
805 if (!link) { 801 if (!link) {
@@ -912,7 +908,7 @@ static int __init acpi_irq_nobalance_set(char *str)
912 908
913__setup("acpi_irq_nobalance", acpi_irq_nobalance_set); 909__setup("acpi_irq_nobalance", acpi_irq_nobalance_set);
914 910
915int __init acpi_irq_balance_set(char *str) 911static int __init acpi_irq_balance_set(char *str)
916{ 912{
917 acpi_irq_balance = 1; 913 acpi_irq_balance = 1;
918 return 1; 914 return 1;
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 642554b1b60c..5b38a026d122 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -31,6 +31,7 @@
31#include <linux/spinlock.h> 31#include <linux/spinlock.h>
32#include <linux/pm.h> 32#include <linux/pm.h>
33#include <linux/pci.h> 33#include <linux/pci.h>
34#include <linux/pci-acpi.h>
34#include <linux/acpi.h> 35#include <linux/acpi.h>
35#include <acpi/acpi_bus.h> 36#include <acpi/acpi_bus.h>
36#include <acpi/acpi_drivers.h> 37#include <acpi/acpi_drivers.h>
@@ -193,6 +194,7 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
193 unsigned long long value = 0; 194 unsigned long long value = 0;
194 acpi_handle handle = NULL; 195 acpi_handle handle = NULL;
195 struct acpi_device *child; 196 struct acpi_device *child;
197 u32 flags, base_flags;
196 198
197 199
198 if (!device) 200 if (!device)
@@ -210,6 +212,13 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
210 212
211 device->ops.bind = acpi_pci_bind; 213 device->ops.bind = acpi_pci_bind;
212 214
215 /*
216 * All supported architectures that use ACPI have support for
217 * PCI domains, so we indicate this in _OSC support capabilities.
218 */
219 flags = base_flags = OSC_PCI_SEGMENT_GROUPS_SUPPORT;
220 pci_acpi_osc_support(device->handle, flags);
221
213 /* 222 /*
214 * Segment 223 * Segment
215 * ------- 224 * -------
@@ -335,6 +344,17 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
335 list_for_each_entry(child, &device->children, node) 344 list_for_each_entry(child, &device->children, node)
336 acpi_pci_bridge_scan(child); 345 acpi_pci_bridge_scan(child);
337 346
347 /* Indicate support for various _OSC capabilities. */
348 if (pci_ext_cfg_avail(root->bus->self))
349 flags |= OSC_EXT_PCI_CONFIG_SUPPORT;
350 if (pcie_aspm_enabled())
351 flags |= OSC_ACTIVE_STATE_PWR_SUPPORT |
352 OSC_CLOCK_PWR_CAPABILITY_SUPPORT;
353 if (pci_msi_enabled())
354 flags |= OSC_MSI_SUPPORT;
355 if (flags != base_flags)
356 pci_acpi_osc_support(device->handle, flags);
357
338 end: 358 end:
339 if (result) { 359 if (result) {
340 if (!list_empty(&root->node)) 360 if (!list_empty(&root->node))
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index bb7d50dd2818..c926e7d4a0d6 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -139,6 +139,8 @@ static int acpi_power_get_state(acpi_handle handle, int *state)
139{ 139{
140 acpi_status status = AE_OK; 140 acpi_status status = AE_OK;
141 unsigned long long sta = 0; 141 unsigned long long sta = 0;
142 char node_name[5];
143 struct acpi_buffer buffer = { sizeof(node_name), node_name };
142 144
143 145
144 if (!handle || !state) 146 if (!handle || !state)
@@ -151,8 +153,10 @@ static int acpi_power_get_state(acpi_handle handle, int *state)
151 *state = (sta & 0x01)?ACPI_POWER_RESOURCE_STATE_ON: 153 *state = (sta & 0x01)?ACPI_POWER_RESOURCE_STATE_ON:
152 ACPI_POWER_RESOURCE_STATE_OFF; 154 ACPI_POWER_RESOURCE_STATE_OFF;
153 155
156 acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer);
157
154 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n", 158 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n",
155 acpi_ut_get_node_name(handle), 159 node_name,
156 *state ? "on" : "off")); 160 *state ? "on" : "off"));
157 161
158 return 0; 162 return 0;
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/proc.c
index 4dbc2271acf5..428c911dba08 100644
--- a/drivers/acpi/sleep/proc.c
+++ b/drivers/acpi/proc.c
@@ -28,8 +28,6 @@ static int acpi_system_sleep_seq_show(struct seq_file *seq, void *offset)
28{ 28{
29 int i; 29 int i;
30 30
31 ACPI_FUNCTION_TRACE("acpi_system_sleep_seq_show");
32
33 for (i = 0; i <= ACPI_STATE_S5; i++) { 31 for (i = 0; i <= ACPI_STATE_S5; i++) {
34 if (sleep_states[i]) { 32 if (sleep_states[i]) {
35 seq_printf(seq, "S%d ", i); 33 seq_printf(seq, "S%d ", i);
@@ -86,49 +84,44 @@ acpi_system_write_sleep(struct file *file,
86 84
87#ifdef HAVE_ACPI_LEGACY_ALARM 85#ifdef HAVE_ACPI_LEGACY_ALARM
88 86
87static u32 cmos_bcd_read(int offset, int rtc_control);
88
89static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset) 89static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset)
90{ 90{
91 u32 sec, min, hr; 91 u32 sec, min, hr;
92 u32 day, mo, yr, cent = 0; 92 u32 day, mo, yr, cent = 0;
93 u32 today = 0;
93 unsigned char rtc_control = 0; 94 unsigned char rtc_control = 0;
94 unsigned long flags; 95 unsigned long flags;
95 96
96 ACPI_FUNCTION_TRACE("acpi_system_alarm_seq_show");
97
98 spin_lock_irqsave(&rtc_lock, flags); 97 spin_lock_irqsave(&rtc_lock, flags);
99 98
100 sec = CMOS_READ(RTC_SECONDS_ALARM);
101 min = CMOS_READ(RTC_MINUTES_ALARM);
102 hr = CMOS_READ(RTC_HOURS_ALARM);
103 rtc_control = CMOS_READ(RTC_CONTROL); 99 rtc_control = CMOS_READ(RTC_CONTROL);
100 sec = cmos_bcd_read(RTC_SECONDS_ALARM, rtc_control);
101 min = cmos_bcd_read(RTC_MINUTES_ALARM, rtc_control);
102 hr = cmos_bcd_read(RTC_HOURS_ALARM, rtc_control);
104 103
105 /* If we ever get an FACP with proper values... */ 104 /* If we ever get an FACP with proper values... */
106 if (acpi_gbl_FADT.day_alarm) 105 if (acpi_gbl_FADT.day_alarm) {
107 /* ACPI spec: only low 6 its should be cared */ 106 /* ACPI spec: only low 6 its should be cared */
108 day = CMOS_READ(acpi_gbl_FADT.day_alarm) & 0x3F; 107 day = CMOS_READ(acpi_gbl_FADT.day_alarm) & 0x3F;
109 else 108 if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
110 day = CMOS_READ(RTC_DAY_OF_MONTH); 109 day = bcd2bin(day);
110 } else
111 day = cmos_bcd_read(RTC_DAY_OF_MONTH, rtc_control);
111 if (acpi_gbl_FADT.month_alarm) 112 if (acpi_gbl_FADT.month_alarm)
112 mo = CMOS_READ(acpi_gbl_FADT.month_alarm); 113 mo = cmos_bcd_read(acpi_gbl_FADT.month_alarm, rtc_control);
113 else 114 else {
114 mo = CMOS_READ(RTC_MONTH); 115 mo = cmos_bcd_read(RTC_MONTH, rtc_control);
116 today = cmos_bcd_read(RTC_DAY_OF_MONTH, rtc_control);
117 }
115 if (acpi_gbl_FADT.century) 118 if (acpi_gbl_FADT.century)
116 cent = CMOS_READ(acpi_gbl_FADT.century); 119 cent = cmos_bcd_read(acpi_gbl_FADT.century, rtc_control);
117 120
118 yr = CMOS_READ(RTC_YEAR); 121 yr = cmos_bcd_read(RTC_YEAR, rtc_control);
119 122
120 spin_unlock_irqrestore(&rtc_lock, flags); 123 spin_unlock_irqrestore(&rtc_lock, flags);
121 124
122 if (!(rtc_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
123 sec = bcd2bin(sec);
124 min = bcd2bin(min);
125 hr = bcd2bin(hr);
126 day = bcd2bin(day);
127 mo = bcd2bin(mo);
128 yr = bcd2bin(yr);
129 cent = bcd2bin(cent);
130 }
131
132 /* we're trusting the FADT (see above) */ 125 /* we're trusting the FADT (see above) */
133 if (!acpi_gbl_FADT.century) 126 if (!acpi_gbl_FADT.century)
134 /* If we're not trusting the FADT, we should at least make it 127 /* If we're not trusting the FADT, we should at least make it
@@ -153,6 +146,20 @@ static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset)
153 else 146 else
154 yr += cent * 100; 147 yr += cent * 100;
155 148
149 /*
150 * Show correct dates for alarms up to a month into the future.
151 * This solves issues for nearly all situations with the common
152 * 30-day alarm clocks in PC hardware.
153 */
154 if (day < today) {
155 if (mo < 12) {
156 mo += 1;
157 } else {
158 mo = 1;
159 yr += 1;
160 }
161 }
162
156 seq_printf(seq, "%4.4u-", yr); 163 seq_printf(seq, "%4.4u-", yr);
157 (mo > 12) ? seq_puts(seq, "**-") : seq_printf(seq, "%2.2u-", mo); 164 (mo > 12) ? seq_puts(seq, "**-") : seq_printf(seq, "%2.2u-", mo);
158 (day > 31) ? seq_puts(seq, "** ") : seq_printf(seq, "%2.2u ", day); 165 (day > 31) ? seq_puts(seq, "** ") : seq_printf(seq, "%2.2u ", day);
@@ -227,13 +234,11 @@ acpi_system_write_alarm(struct file *file,
227 int adjust = 0; 234 int adjust = 0;
228 unsigned char rtc_control = 0; 235 unsigned char rtc_control = 0;
229 236
230 ACPI_FUNCTION_TRACE("acpi_system_write_alarm");
231
232 if (count > sizeof(alarm_string) - 1) 237 if (count > sizeof(alarm_string) - 1)
233 return_VALUE(-EINVAL); 238 return -EINVAL;
234 239
235 if (copy_from_user(alarm_string, buffer, count)) 240 if (copy_from_user(alarm_string, buffer, count))
236 return_VALUE(-EFAULT); 241 return -EFAULT;
237 242
238 alarm_string[count] = '\0'; 243 alarm_string[count] = '\0';
239 244
@@ -334,7 +339,7 @@ acpi_system_write_alarm(struct file *file,
334 339
335 result = 0; 340 result = 0;
336 end: 341 end:
337 return_VALUE(result ? result : count); 342 return result ? result : count;
338} 343}
339#endif /* HAVE_ACPI_LEGACY_ALARM */ 344#endif /* HAVE_ACPI_LEGACY_ALARM */
340 345
diff --git a/drivers/acpi/reboot.c b/drivers/acpi/reboot.c
index a6b662c00b67..93f91142d7ad 100644
--- a/drivers/acpi/reboot.c
+++ b/drivers/acpi/reboot.c
@@ -42,7 +42,7 @@ void acpi_reboot(void)
42 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 42 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
43 case ACPI_ADR_SPACE_SYSTEM_IO: 43 case ACPI_ADR_SPACE_SYSTEM_IO:
44 printk(KERN_DEBUG "ACPI MEMORY or I/O RESET_REG.\n"); 44 printk(KERN_DEBUG "ACPI MEMORY or I/O RESET_REG.\n");
45 acpi_hw_low_level_write(8, reset_value, rr); 45 acpi_reset();
46 break; 46 break;
47 } 47 }
48 /* Wait ten seconds */ 48 /* Wait ten seconds */
diff --git a/drivers/acpi/resources/Makefile b/drivers/acpi/resources/Makefile
deleted file mode 100644
index 8de4f69dfa09..000000000000
--- a/drivers/acpi/resources/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
1#
2# Makefile for all Linux ACPI interpreter subdirectories
3#
4
5obj-y := rsaddr.o rscreate.o rsinfo.o rsio.o rslist.o rsmisc.o rsxface.o \
6 rscalc.o rsirq.o rsmemory.o rsutils.o
7
8obj-$(ACPI_FUTURE_USAGE) += rsdump.o
9
10EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/sbshc.c b/drivers/acpi/sbshc.c
index e53e590252c0..0619734895b2 100644
--- a/drivers/acpi/sbshc.c
+++ b/drivers/acpi/sbshc.c
@@ -10,7 +10,6 @@
10 10
11#include <acpi/acpi_bus.h> 11#include <acpi/acpi_bus.h>
12#include <acpi/acpi_drivers.h> 12#include <acpi/acpi_drivers.h>
13#include <acpi/actypes.h>
14#include <linux/wait.h> 13#include <linux/wait.h>
15#include <linux/delay.h> 14#include <linux/delay.h>
16#include <linux/interrupt.h> 15#include <linux/interrupt.h>
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 39b7233c3485..c54d7b6c4066 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -10,7 +10,6 @@
10#include <linux/kthread.h> 10#include <linux/kthread.h>
11 11
12#include <acpi/acpi_drivers.h> 12#include <acpi/acpi_drivers.h>
13#include <acpi/acinterp.h> /* for acpi_ex_eisa_id_to_string() */
14 13
15#define _COMPONENT ACPI_BUS_COMPONENT 14#define _COMPONENT ACPI_BUS_COMPONENT
16ACPI_MODULE_NAME("scan"); 15ACPI_MODULE_NAME("scan");
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep.c
index 28a691cc625e..7e3c609cbef2 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep.c
@@ -101,13 +101,26 @@ void __init acpi_old_suspend_ordering(void)
101 * cases. 101 * cases.
102 */ 102 */
103static bool set_sci_en_on_resume; 103static bool set_sci_en_on_resume;
104/*
105 * The ACPI specification wants us to save NVS memory regions during hibernation
106 * and to restore them during the subsequent resume. However, it is not certain
107 * if this mechanism is going to work on all machines, so we allow the user to
108 * disable this mechanism using the 'acpi_sleep=s4_nonvs' kernel command line
109 * option.
110 */
111static bool s4_no_nvs;
112
113void __init acpi_s4_no_nvs(void)
114{
115 s4_no_nvs = true;
116}
104 117
105/** 118/**
106 * acpi_pm_disable_gpes - Disable the GPEs. 119 * acpi_pm_disable_gpes - Disable the GPEs.
107 */ 120 */
108static int acpi_pm_disable_gpes(void) 121static int acpi_pm_disable_gpes(void)
109{ 122{
110 acpi_hw_disable_all_gpes(); 123 acpi_disable_all_gpes();
111 return 0; 124 return 0;
112} 125}
113 126
@@ -135,7 +148,7 @@ static int acpi_pm_prepare(void)
135 int error = __acpi_pm_prepare(); 148 int error = __acpi_pm_prepare();
136 149
137 if (!error) 150 if (!error)
138 acpi_hw_disable_all_gpes(); 151 acpi_disable_all_gpes();
139 return error; 152 return error;
140} 153}
141 154
@@ -267,7 +280,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
267 * (like wakeup GPE) haven't handler, this can avoid such GPE misfire. 280 * (like wakeup GPE) haven't handler, this can avoid such GPE misfire.
268 * acpi_leave_sleep_state will reenable specific GPEs later 281 * acpi_leave_sleep_state will reenable specific GPEs later
269 */ 282 */
270 acpi_hw_disable_all_gpes(); 283 acpi_disable_all_gpes();
271 284
272 local_irq_restore(flags); 285 local_irq_restore(flags);
273 printk(KERN_DEBUG "Back to C!\n"); 286 printk(KERN_DEBUG "Back to C!\n");
@@ -394,9 +407,25 @@ void __init acpi_no_s4_hw_signature(void)
394 407
395static int acpi_hibernation_begin(void) 408static int acpi_hibernation_begin(void)
396{ 409{
397 acpi_target_sleep_state = ACPI_STATE_S4; 410 int error;
398 acpi_sleep_tts_switch(acpi_target_sleep_state); 411
399 return 0; 412 error = s4_no_nvs ? 0 : hibernate_nvs_alloc();
413 if (!error) {
414 acpi_target_sleep_state = ACPI_STATE_S4;
415 acpi_sleep_tts_switch(acpi_target_sleep_state);
416 }
417
418 return error;
419}
420
421static int acpi_hibernation_pre_snapshot(void)
422{
423 int error = acpi_pm_prepare();
424
425 if (!error)
426 hibernate_nvs_save();
427
428 return error;
400} 429}
401 430
402static int acpi_hibernation_enter(void) 431static int acpi_hibernation_enter(void)
@@ -417,6 +446,12 @@ static int acpi_hibernation_enter(void)
417 return ACPI_SUCCESS(status) ? 0 : -EFAULT; 446 return ACPI_SUCCESS(status) ? 0 : -EFAULT;
418} 447}
419 448
449static void acpi_hibernation_finish(void)
450{
451 hibernate_nvs_free();
452 acpi_pm_finish();
453}
454
420static void acpi_hibernation_leave(void) 455static void acpi_hibernation_leave(void)
421{ 456{
422 /* 457 /*
@@ -432,18 +467,20 @@ static void acpi_hibernation_leave(void)
432 "cannot resume!\n"); 467 "cannot resume!\n");
433 panic("ACPI S4 hardware signature mismatch"); 468 panic("ACPI S4 hardware signature mismatch");
434 } 469 }
470 /* Restore the NVS memory area */
471 hibernate_nvs_restore();
435} 472}
436 473
437static void acpi_pm_enable_gpes(void) 474static void acpi_pm_enable_gpes(void)
438{ 475{
439 acpi_hw_enable_all_runtime_gpes(); 476 acpi_enable_all_runtime_gpes();
440} 477}
441 478
442static struct platform_hibernation_ops acpi_hibernation_ops = { 479static struct platform_hibernation_ops acpi_hibernation_ops = {
443 .begin = acpi_hibernation_begin, 480 .begin = acpi_hibernation_begin,
444 .end = acpi_pm_end, 481 .end = acpi_pm_end,
445 .pre_snapshot = acpi_pm_prepare, 482 .pre_snapshot = acpi_hibernation_pre_snapshot,
446 .finish = acpi_pm_finish, 483 .finish = acpi_hibernation_finish,
447 .prepare = acpi_pm_prepare, 484 .prepare = acpi_pm_prepare,
448 .enter = acpi_hibernation_enter, 485 .enter = acpi_hibernation_enter,
449 .leave = acpi_hibernation_leave, 486 .leave = acpi_hibernation_leave,
@@ -469,8 +506,22 @@ static int acpi_hibernation_begin_old(void)
469 506
470 error = acpi_sleep_prepare(ACPI_STATE_S4); 507 error = acpi_sleep_prepare(ACPI_STATE_S4);
471 508
509 if (!error) {
510 if (!s4_no_nvs)
511 error = hibernate_nvs_alloc();
512 if (!error)
513 acpi_target_sleep_state = ACPI_STATE_S4;
514 }
515 return error;
516}
517
518static int acpi_hibernation_pre_snapshot_old(void)
519{
520 int error = acpi_pm_disable_gpes();
521
472 if (!error) 522 if (!error)
473 acpi_target_sleep_state = ACPI_STATE_S4; 523 hibernate_nvs_save();
524
474 return error; 525 return error;
475} 526}
476 527
@@ -481,8 +532,8 @@ static int acpi_hibernation_begin_old(void)
481static struct platform_hibernation_ops acpi_hibernation_ops_old = { 532static struct platform_hibernation_ops acpi_hibernation_ops_old = {
482 .begin = acpi_hibernation_begin_old, 533 .begin = acpi_hibernation_begin_old,
483 .end = acpi_pm_end, 534 .end = acpi_pm_end,
484 .pre_snapshot = acpi_pm_disable_gpes, 535 .pre_snapshot = acpi_hibernation_pre_snapshot_old,
485 .finish = acpi_pm_finish, 536 .finish = acpi_hibernation_finish,
486 .prepare = acpi_pm_disable_gpes, 537 .prepare = acpi_pm_disable_gpes,
487 .enter = acpi_hibernation_enter, 538 .enter = acpi_hibernation_enter,
488 .leave = acpi_hibernation_leave, 539 .leave = acpi_hibernation_leave,
@@ -622,7 +673,7 @@ static void acpi_power_off_prepare(void)
622{ 673{
623 /* Prepare to power off the system */ 674 /* Prepare to power off the system */
624 acpi_sleep_prepare(ACPI_STATE_S5); 675 acpi_sleep_prepare(ACPI_STATE_S5);
625 acpi_hw_disable_all_gpes(); 676 acpi_disable_all_gpes();
626} 677}
627 678
628static void acpi_power_off(void) 679static void acpi_power_off(void)
@@ -671,7 +722,7 @@ int __init acpi_sleep_init(void)
671 sleep_states[ACPI_STATE_S4] = 1; 722 sleep_states[ACPI_STATE_S4] = 1;
672 printk(" S4"); 723 printk(" S4");
673 if (!nosigcheck) { 724 if (!nosigcheck) {
674 acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS, 725 acpi_get_table(ACPI_SIG_FACS, 1,
675 (struct acpi_table_header **)&facs); 726 (struct acpi_table_header **)&facs);
676 if (facs) 727 if (facs)
677 s4_hardware_signature = 728 s4_hardware_signature =
diff --git a/drivers/acpi/sleep/sleep.h b/drivers/acpi/sleep.h
index cfaf8f5b0a14..cfaf8f5b0a14 100644
--- a/drivers/acpi/sleep/sleep.h
+++ b/drivers/acpi/sleep.h
diff --git a/drivers/acpi/sleep/Makefile b/drivers/acpi/sleep/Makefile
deleted file mode 100644
index f1fb888c2d29..000000000000
--- a/drivers/acpi/sleep/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
1obj-y := wakeup.o
2obj-y += main.o
3obj-$(CONFIG_ACPI_SLEEP) += proc.o
4
5EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c
index 6e4107f82403..391d0358a592 100644
--- a/drivers/acpi/system.c
+++ b/drivers/acpi/system.c
@@ -192,65 +192,6 @@ static struct attribute_group interrupt_stats_attr_group = {
192}; 192};
193static struct kobj_attribute *counter_attrs; 193static struct kobj_attribute *counter_attrs;
194 194
195static int count_num_gpes(void)
196{
197 int count = 0;
198 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
199 struct acpi_gpe_block_info *gpe_block;
200 acpi_cpu_flags flags;
201
202 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
203
204 gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
205 while (gpe_xrupt_info) {
206 gpe_block = gpe_xrupt_info->gpe_block_list_head;
207 while (gpe_block) {
208 count += gpe_block->register_count *
209 ACPI_GPE_REGISTER_WIDTH;
210 gpe_block = gpe_block->next;
211 }
212 gpe_xrupt_info = gpe_xrupt_info->next;
213 }
214 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
215
216 return count;
217}
218
219static int get_gpe_device(int index, acpi_handle *handle)
220{
221 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
222 struct acpi_gpe_block_info *gpe_block;
223 acpi_cpu_flags flags;
224 struct acpi_namespace_node *node;
225
226 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
227
228 gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
229 while (gpe_xrupt_info) {
230 gpe_block = gpe_xrupt_info->gpe_block_list_head;
231 node = gpe_block->node;
232 while (gpe_block) {
233 index -= gpe_block->register_count *
234 ACPI_GPE_REGISTER_WIDTH;
235 if (index < 0) {
236 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
237 /* return NULL if it's FADT GPE */
238 if (node->type != ACPI_TYPE_DEVICE)
239 *handle = NULL;
240 else
241 *handle = node;
242 return 0;
243 }
244 node = gpe_block->node;
245 gpe_block = gpe_block->next;
246 }
247 gpe_xrupt_info = gpe_xrupt_info->next;
248 }
249 acpi_os_release_lock(acpi_gbl_gpe_lock, flags);
250
251 return -ENODEV;
252}
253
254static void delete_gpe_attr_array(void) 195static void delete_gpe_attr_array(void)
255{ 196{
256 struct event_counter *tmp = all_counters; 197 struct event_counter *tmp = all_counters;
@@ -309,7 +250,7 @@ static int get_status(u32 index, acpi_event_status *status, acpi_handle *handle)
309 goto end; 250 goto end;
310 251
311 if (index < num_gpes) { 252 if (index < num_gpes) {
312 result = get_gpe_device(index, handle); 253 result = acpi_get_gpe_device(index, handle);
313 if (result) { 254 if (result) {
314 ACPI_EXCEPTION((AE_INFO, AE_NOT_FOUND, 255 ACPI_EXCEPTION((AE_INFO, AE_NOT_FOUND,
315 "Invalid GPE 0x%x\n", index)); 256 "Invalid GPE 0x%x\n", index));
@@ -436,7 +377,7 @@ void acpi_irq_stats_init(void)
436 if (all_counters) 377 if (all_counters)
437 return; 378 return;
438 379
439 num_gpes = count_num_gpes(); 380 num_gpes = acpi_current_gpe_count;
440 num_counters = num_gpes + ACPI_NUM_FIXED_EVENTS + NUM_COUNTERS_EXTRA; 381 num_counters = num_gpes + ACPI_NUM_FIXED_EVENTS + NUM_COUNTERS_EXTRA;
441 382
442 all_attrs = kzalloc(sizeof(struct attribute *) * (num_counters + 1), 383 all_attrs = kzalloc(sizeof(struct attribute *) * (num_counters + 1),
diff --git a/drivers/acpi/tables/Makefile b/drivers/acpi/tables/Makefile
deleted file mode 100644
index 7385efa61622..000000000000
--- a/drivers/acpi/tables/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
1#
2# Makefile for all Linux ACPI interpreter subdirectories
3#
4
5obj-y := tbxface.o tbinstal.o tbutils.o tbfind.o tbfadt.o tbxfroot.o
6
7EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 073ff09218a9..99e6f1f8ea45 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -416,7 +416,8 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
416 } 416 }
417 417
418 /* Passive (optional) */ 418 /* Passive (optional) */
419 if (flag & ACPI_TRIPS_PASSIVE) { 419 if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips.passive.flags.valid) ||
420 (flag == ACPI_TRIPS_INIT)) {
420 valid = tz->trips.passive.flags.valid; 421 valid = tz->trips.passive.flags.valid;
421 if (psv == -1) { 422 if (psv == -1) {
422 status = AE_SUPPORT; 423 status = AE_SUPPORT;
@@ -462,8 +463,11 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
462 memset(&devices, 0, sizeof(struct acpi_handle_list)); 463 memset(&devices, 0, sizeof(struct acpi_handle_list));
463 status = acpi_evaluate_reference(tz->device->handle, "_PSL", 464 status = acpi_evaluate_reference(tz->device->handle, "_PSL",
464 NULL, &devices); 465 NULL, &devices);
465 if (ACPI_FAILURE(status)) 466 if (ACPI_FAILURE(status)) {
467 printk(KERN_WARNING PREFIX
468 "Invalid passive threshold\n");
466 tz->trips.passive.flags.valid = 0; 469 tz->trips.passive.flags.valid = 0;
470 }
467 else 471 else
468 tz->trips.passive.flags.valid = 1; 472 tz->trips.passive.flags.valid = 1;
469 473
@@ -487,7 +491,8 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
487 if (act == -1) 491 if (act == -1)
488 break; /* disable all active trip points */ 492 break; /* disable all active trip points */
489 493
490 if (flag & ACPI_TRIPS_ACTIVE) { 494 if ((flag == ACPI_TRIPS_INIT) || ((flag & ACPI_TRIPS_ACTIVE) &&
495 tz->trips.active[i].flags.valid)) {
491 status = acpi_evaluate_integer(tz->device->handle, 496 status = acpi_evaluate_integer(tz->device->handle,
492 name, NULL, &tmp); 497 name, NULL, &tmp);
493 if (ACPI_FAILURE(status)) { 498 if (ACPI_FAILURE(status)) {
@@ -521,8 +526,11 @@ static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
521 memset(&devices, 0, sizeof(struct acpi_handle_list)); 526 memset(&devices, 0, sizeof(struct acpi_handle_list));
522 status = acpi_evaluate_reference(tz->device->handle, 527 status = acpi_evaluate_reference(tz->device->handle,
523 name, NULL, &devices); 528 name, NULL, &devices);
524 if (ACPI_FAILURE(status)) 529 if (ACPI_FAILURE(status)) {
530 printk(KERN_WARNING PREFIX
531 "Invalid active%d threshold\n", i);
525 tz->trips.active[i].flags.valid = 0; 532 tz->trips.active[i].flags.valid = 0;
533 }
526 else 534 else
527 tz->trips.active[i].flags.valid = 1; 535 tz->trips.active[i].flags.valid = 1;
528 536
diff --git a/drivers/acpi/utilities/Makefile b/drivers/acpi/utilities/Makefile
deleted file mode 100644
index 88eff14c4894..000000000000
--- a/drivers/acpi/utilities/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
1#
2# Makefile for all Linux ACPI interpreter subdirectories
3#
4
5obj-y := utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \
6 utcopy.o utdelete.o utglobal.o utmath.o utobject.o \
7 utstate.o utmutex.o utobject.o utcache.o utresrc.o
8
9EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/utilities/utcache.c b/drivers/acpi/utilities/utcache.c
deleted file mode 100644
index 245fa80cf600..000000000000
--- a/drivers/acpi/utilities/utcache.c
+++ /dev/null
@@ -1,314 +0,0 @@
1/******************************************************************************
2 *
3 * Module Name: utcache - local cache allocation routines
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2008, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45
46#define _COMPONENT ACPI_UTILITIES
47ACPI_MODULE_NAME("utcache")
48#ifdef ACPI_USE_LOCAL_CACHE
49/*******************************************************************************
50 *
51 * FUNCTION: acpi_os_create_cache
52 *
53 * PARAMETERS: cache_name - Ascii name for the cache
54 * object_size - Size of each cached object
55 * max_depth - Maximum depth of the cache (in objects)
56 * return_cache - Where the new cache object is returned
57 *
58 * RETURN: Status
59 *
60 * DESCRIPTION: Create a cache object
61 *
62 ******************************************************************************/
63acpi_status
64acpi_os_create_cache(char *cache_name,
65 u16 object_size,
66 u16 max_depth, struct acpi_memory_list ** return_cache)
67{
68 struct acpi_memory_list *cache;
69
70 ACPI_FUNCTION_ENTRY();
71
72 if (!cache_name || !return_cache || (object_size < 16)) {
73 return (AE_BAD_PARAMETER);
74 }
75
76 /* Create the cache object */
77
78 cache = acpi_os_allocate(sizeof(struct acpi_memory_list));
79 if (!cache) {
80 return (AE_NO_MEMORY);
81 }
82
83 /* Populate the cache object and return it */
84
85 ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list));
86 cache->link_offset = 8;
87 cache->list_name = cache_name;
88 cache->object_size = object_size;
89 cache->max_depth = max_depth;
90
91 *return_cache = cache;
92 return (AE_OK);
93}
94
95/*******************************************************************************
96 *
97 * FUNCTION: acpi_os_purge_cache
98 *
99 * PARAMETERS: Cache - Handle to cache object
100 *
101 * RETURN: Status
102 *
103 * DESCRIPTION: Free all objects within the requested cache.
104 *
105 ******************************************************************************/
106
107acpi_status acpi_os_purge_cache(struct acpi_memory_list * cache)
108{
109 char *next;
110
111 ACPI_FUNCTION_ENTRY();
112
113 if (!cache) {
114 return (AE_BAD_PARAMETER);
115 }
116
117 /* Walk the list of objects in this cache */
118
119 while (cache->list_head) {
120
121 /* Delete and unlink one cached state object */
122
123 next = *(ACPI_CAST_INDIRECT_PTR(char,
124 &(((char *)cache->
125 list_head)[cache->
126 link_offset])));
127 ACPI_FREE(cache->list_head);
128
129 cache->list_head = next;
130 cache->current_depth--;
131 }
132
133 return (AE_OK);
134}
135
136/*******************************************************************************
137 *
138 * FUNCTION: acpi_os_delete_cache
139 *
140 * PARAMETERS: Cache - Handle to cache object
141 *
142 * RETURN: Status
143 *
144 * DESCRIPTION: Free all objects within the requested cache and delete the
145 * cache object.
146 *
147 ******************************************************************************/
148
149acpi_status acpi_os_delete_cache(struct acpi_memory_list * cache)
150{
151 acpi_status status;
152
153 ACPI_FUNCTION_ENTRY();
154
155 /* Purge all objects in the cache */
156
157 status = acpi_os_purge_cache(cache);
158 if (ACPI_FAILURE(status)) {
159 return (status);
160 }
161
162 /* Now we can delete the cache object */
163
164 ACPI_FREE(cache);
165 return (AE_OK);
166}
167
168/*******************************************************************************
169 *
170 * FUNCTION: acpi_os_release_object
171 *
172 * PARAMETERS: Cache - Handle to cache object
173 * Object - The object to be released
174 *
175 * RETURN: None
176 *
177 * DESCRIPTION: Release an object to the specified cache. If cache is full,
178 * the object is deleted.
179 *
180 ******************************************************************************/
181
182acpi_status
183acpi_os_release_object(struct acpi_memory_list * cache, void *object)
184{
185 acpi_status status;
186
187 ACPI_FUNCTION_ENTRY();
188
189 if (!cache || !object) {
190 return (AE_BAD_PARAMETER);
191 }
192
193 /* If cache is full, just free this object */
194
195 if (cache->current_depth >= cache->max_depth) {
196 ACPI_FREE(object);
197 ACPI_MEM_TRACKING(cache->total_freed++);
198 }
199
200 /* Otherwise put this object back into the cache */
201
202 else {
203 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
204 if (ACPI_FAILURE(status)) {
205 return (status);
206 }
207
208 /* Mark the object as cached */
209
210 ACPI_MEMSET(object, 0xCA, cache->object_size);
211 ACPI_SET_DESCRIPTOR_TYPE(object, ACPI_DESC_TYPE_CACHED);
212
213 /* Put the object at the head of the cache list */
214
215 *(ACPI_CAST_INDIRECT_PTR(char,
216 &(((char *)object)[cache->
217 link_offset]))) =
218 cache->list_head;
219 cache->list_head = object;
220 cache->current_depth++;
221
222 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
223 }
224
225 return (AE_OK);
226}
227
228/*******************************************************************************
229 *
230 * FUNCTION: acpi_os_acquire_object
231 *
232 * PARAMETERS: Cache - Handle to cache object
233 *
234 * RETURN: the acquired object. NULL on error
235 *
236 * DESCRIPTION: Get an object from the specified cache. If cache is empty,
237 * the object is allocated.
238 *
239 ******************************************************************************/
240
241void *acpi_os_acquire_object(struct acpi_memory_list *cache)
242{
243 acpi_status status;
244 void *object;
245
246 ACPI_FUNCTION_NAME(os_acquire_object);
247
248 if (!cache) {
249 return (NULL);
250 }
251
252 status = acpi_ut_acquire_mutex(ACPI_MTX_CACHES);
253 if (ACPI_FAILURE(status)) {
254 return (NULL);
255 }
256
257 ACPI_MEM_TRACKING(cache->requests++);
258
259 /* Check the cache first */
260
261 if (cache->list_head) {
262
263 /* There is an object available, use it */
264
265 object = cache->list_head;
266 cache->list_head = *(ACPI_CAST_INDIRECT_PTR(char,
267 &(((char *)
268 object)[cache->
269 link_offset])));
270
271 cache->current_depth--;
272
273 ACPI_MEM_TRACKING(cache->hits++);
274 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
275 "Object %p from %s cache\n", object,
276 cache->list_name));
277
278 status = acpi_ut_release_mutex(ACPI_MTX_CACHES);
279 if (ACPI_FAILURE(status)) {
280 return (NULL);
281 }
282
283 /* Clear (zero) the previously used Object */
284
285 ACPI_MEMSET(object, 0, cache->object_size);
286 } else {
287 /* The cache is empty, create a new object */
288
289 ACPI_MEM_TRACKING(cache->total_allocated++);
290
291#ifdef ACPI_DBG_TRACK_ALLOCATIONS
292 if ((cache->total_allocated - cache->total_freed) >
293 cache->max_occupied) {
294 cache->max_occupied =
295 cache->total_allocated - cache->total_freed;
296 }
297#endif
298
299 /* Avoid deadlock with ACPI_ALLOCATE_ZEROED */
300
301 status = acpi_ut_release_mutex(ACPI_MTX_CACHES);
302 if (ACPI_FAILURE(status)) {
303 return (NULL);
304 }
305
306 object = ACPI_ALLOCATE_ZEROED(cache->object_size);
307 if (!object) {
308 return (NULL);
309 }
310 }
311
312 return (object);
313}
314#endif /* ACPI_USE_LOCAL_CACHE */
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index baa441929720..f261737636da 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -36,6 +36,7 @@
36#include <linux/backlight.h> 36#include <linux/backlight.h>
37#include <linux/thermal.h> 37#include <linux/thermal.h>
38#include <linux/video_output.h> 38#include <linux/video_output.h>
39#include <linux/sort.h>
39#include <asm/uaccess.h> 40#include <asm/uaccess.h>
40 41
41#include <acpi/acpi_bus.h> 42#include <acpi/acpi_bus.h>
@@ -481,6 +482,7 @@ acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
481 int status = AE_OK; 482 int status = AE_OK;
482 union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 483 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
483 struct acpi_object_list args = { 1, &arg0 }; 484 struct acpi_object_list args = { 1, &arg0 };
485 int state;
484 486
485 487
486 arg0.integer.value = level; 488 arg0.integer.value = level;
@@ -489,6 +491,10 @@ acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
489 status = acpi_evaluate_object(device->dev->handle, "_BCM", 491 status = acpi_evaluate_object(device->dev->handle, "_BCM",
490 &args, NULL); 492 &args, NULL);
491 device->brightness->curr = level; 493 device->brightness->curr = level;
494 for (state = 2; state < device->brightness->count; state++)
495 if (level == device->brightness->levels[state])
496 device->backlight->props.brightness = state - 2;
497
492 return status; 498 return status;
493} 499}
494 500
@@ -626,6 +632,16 @@ acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
626} 632}
627 633
628/* 634/*
635 * Simple comparison function used to sort backlight levels.
636 */
637
638static int
639acpi_video_cmp_level(const void *a, const void *b)
640{
641 return *(int *)a - *(int *)b;
642}
643
644/*
629 * Arg: 645 * Arg:
630 * device : video output device (LCD, CRT, ..) 646 * device : video output device (LCD, CRT, ..)
631 * 647 *
@@ -676,6 +692,10 @@ acpi_video_init_brightness(struct acpi_video_device *device)
676 count++; 692 count++;
677 } 693 }
678 694
695 /* don't sort the first two brightness levels */
696 sort(&br->levels[2], count - 2, sizeof(br->levels[2]),
697 acpi_video_cmp_level, NULL);
698
679 if (count < 2) 699 if (count < 2)
680 goto out_free_levels; 700 goto out_free_levels;
681 701
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
index f022eb6f5637..50e3d2dbf3af 100644
--- a/drivers/acpi/video_detect.c
+++ b/drivers/acpi/video_detect.c
@@ -234,7 +234,7 @@ EXPORT_SYMBOL(acpi_video_display_switch_support);
234 * To force that backlight or display output switching is processed by vendor 234 * To force that backlight or display output switching is processed by vendor
235 * specific acpi drivers or video.ko driver. 235 * specific acpi drivers or video.ko driver.
236 */ 236 */
237int __init acpi_backlight(char *str) 237static int __init acpi_backlight(char *str)
238{ 238{
239 if (str == NULL || *str == '\0') 239 if (str == NULL || *str == '\0')
240 return 1; 240 return 1;
@@ -250,7 +250,7 @@ int __init acpi_backlight(char *str)
250} 250}
251__setup("acpi_backlight=", acpi_backlight); 251__setup("acpi_backlight=", acpi_backlight);
252 252
253int __init acpi_display_output(char *str) 253static int __init acpi_display_output(char *str)
254{ 254{
255 if (str == NULL || *str == '\0') 255 if (str == NULL || *str == '\0')
256 return 1; 256 return 1;
diff --git a/drivers/acpi/sleep/wakeup.c b/drivers/acpi/wakeup.c
index dea4c23df764..2d34806d45dd 100644
--- a/drivers/acpi/sleep/wakeup.c
+++ b/drivers/acpi/wakeup.c
@@ -8,7 +8,6 @@
8#include <acpi/acpi_drivers.h> 8#include <acpi/acpi_drivers.h>
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/types.h> 10#include <linux/types.h>
11#include <acpi/acevents.h>
12#include "sleep.h" 11#include "sleep.h"
13 12
14#define _COMPONENT ACPI_SYSTEM_COMPONENT 13#define _COMPONENT ACPI_SYSTEM_COMPONENT
@@ -28,8 +27,6 @@ void acpi_enable_wakeup_device_prep(u8 sleep_state)
28{ 27{
29 struct list_head *node, *next; 28 struct list_head *node, *next;
30 29
31 ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device_prep");
32
33 spin_lock(&acpi_device_lock); 30 spin_lock(&acpi_device_lock);
34 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 31 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
35 struct acpi_device *dev = container_of(node, 32 struct acpi_device *dev = container_of(node,
@@ -61,7 +58,6 @@ void acpi_enable_wakeup_device(u8 sleep_state)
61 * Caution: this routine must be invoked when interrupt is disabled 58 * Caution: this routine must be invoked when interrupt is disabled
62 * Refer ACPI2.0: P212 59 * Refer ACPI2.0: P212
63 */ 60 */
64 ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device");
65 spin_lock(&acpi_device_lock); 61 spin_lock(&acpi_device_lock);
66 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 62 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
67 struct acpi_device *dev = 63 struct acpi_device *dev =
@@ -103,8 +99,6 @@ void acpi_disable_wakeup_device(u8 sleep_state)
103{ 99{
104 struct list_head *node, *next; 100 struct list_head *node, *next;
105 101
106 ACPI_FUNCTION_TRACE("acpi_disable_wakeup_device");
107
108 spin_lock(&acpi_device_lock); 102 spin_lock(&acpi_device_lock);
109 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 103 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
110 struct acpi_device *dev = 104 struct acpi_device *dev =
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index 6b94fb7be5f2..00c46e0b40e4 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -12,9 +12,10 @@
12#include <linux/device.h> 12#include <linux/device.h>
13#include <linux/string.h> 13#include <linux/string.h>
14#include <linux/slab.h> 14#include <linux/slab.h>
15#include <linux/io.h>
15#include <linux/amba/bus.h> 16#include <linux/amba/bus.h>
16 17
17#include <asm/io.h> 18#include <asm/irq.h>
18#include <asm/sizes.h> 19#include <asm/sizes.h>
19 20
20#define to_amba_device(d) container_of(d, struct amba_device, dev) 21#define to_amba_device(d) container_of(d, struct amba_device, dev)
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 1a7be96d627b..503a908afc80 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -698,6 +698,15 @@ config PATA_IXP4XX_CF
698 698
699 If unsure, say N. 699 If unsure, say N.
700 700
701config PATA_OCTEON_CF
702 tristate "OCTEON Boot Bus Compact Flash support"
703 depends on CPU_CAVIUM_OCTEON
704 help
705 This option enables a polled compact flash driver for use with
706 compact flash cards attached to the OCTEON boot bus.
707
708 If unsure, say N.
709
701config PATA_SCC 710config PATA_SCC
702 tristate "Toshiba's Cell Reference Set IDE support" 711 tristate "Toshiba's Cell Reference Set IDE support"
703 depends on PCI && PPC_CELLEB 712 depends on PCI && PPC_CELLEB
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 674965fa326d..7f1ecf99528c 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -69,6 +69,7 @@ obj-$(CONFIG_PATA_IXP4XX_CF) += pata_ixp4xx_cf.o
69obj-$(CONFIG_PATA_SCC) += pata_scc.o 69obj-$(CONFIG_PATA_SCC) += pata_scc.o
70obj-$(CONFIG_PATA_SCH) += pata_sch.o 70obj-$(CONFIG_PATA_SCH) += pata_sch.o
71obj-$(CONFIG_PATA_BF54X) += pata_bf54x.o 71obj-$(CONFIG_PATA_BF54X) += pata_bf54x.o
72obj-$(CONFIG_PATA_OCTEON_CF) += pata_octeon_cf.o
72obj-$(CONFIG_PATA_PLATFORM) += pata_platform.o 73obj-$(CONFIG_PATA_PLATFORM) += pata_platform.o
73obj-$(CONFIG_PATA_OF_PLATFORM) += pata_of_platform.o 74obj-$(CONFIG_PATA_OF_PLATFORM) += pata_of_platform.o
74obj-$(CONFIG_PATA_ICSIDE) += pata_icside.o 75obj-$(CONFIG_PATA_ICSIDE) += pata_icside.o
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 656448c7fef9..96039671e3b9 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -105,7 +105,7 @@ enum {
105 board_ahci_ign_iferr = 2, 105 board_ahci_ign_iferr = 2,
106 board_ahci_sb600 = 3, 106 board_ahci_sb600 = 3,
107 board_ahci_mv = 4, 107 board_ahci_mv = 4,
108 board_ahci_sb700 = 5, 108 board_ahci_sb700 = 5, /* for SB700 and SB800 */
109 board_ahci_mcp65 = 6, 109 board_ahci_mcp65 = 6,
110 board_ahci_nopmp = 7, 110 board_ahci_nopmp = 7,
111 111
@@ -439,7 +439,7 @@ static const struct ata_port_info ahci_port_info[] = {
439 .udma_mask = ATA_UDMA6, 439 .udma_mask = ATA_UDMA6,
440 .port_ops = &ahci_ops, 440 .port_ops = &ahci_ops,
441 }, 441 },
442 /* board_ahci_sb700 */ 442 /* board_ahci_sb700, for SB700 and SB800 */
443 { 443 {
444 AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL), 444 AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL),
445 .flags = AHCI_FLAG_COMMON, 445 .flags = AHCI_FLAG_COMMON,
@@ -2446,6 +2446,8 @@ static void ahci_print_info(struct ata_host *host)
2446 speed_s = "1.5"; 2446 speed_s = "1.5";
2447 else if (speed == 2) 2447 else if (speed == 2)
2448 speed_s = "3"; 2448 speed_s = "3";
2449 else if (speed == 3)
2450 speed_s = "6";
2449 else 2451 else
2450 speed_s = "?"; 2452 speed_s = "?";
2451 2453
@@ -2610,6 +2612,10 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2610 (pdev->revision == 0xa1 || pdev->revision == 0xa2)) 2612 (pdev->revision == 0xa1 || pdev->revision == 0xa2))
2611 hpriv->flags |= AHCI_HFLAG_NO_MSI; 2613 hpriv->flags |= AHCI_HFLAG_NO_MSI;
2612 2614
2615 /* SB800 does NOT need the workaround to ignore SERR_INTERNAL */
2616 if (board_id == board_ahci_sb700 && pdev->revision >= 0x40)
2617 hpriv->flags &= ~AHCI_HFLAG_IGN_SERR_INTERNAL;
2618
2613 if ((hpriv->flags & AHCI_HFLAG_NO_MSI) || pci_enable_msi(pdev)) 2619 if ((hpriv->flags & AHCI_HFLAG_NO_MSI) || pci_enable_msi(pdev))
2614 pci_intx(pdev, 1); 2620 pci_intx(pdev, 1);
2615 2621
@@ -2654,6 +2660,9 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2654 host->iomap = pcim_iomap_table(pdev); 2660 host->iomap = pcim_iomap_table(pdev);
2655 host->private_data = hpriv; 2661 host->private_data = hpriv;
2656 2662
2663 if (!(hpriv->cap & HOST_CAP_SSS))
2664 host->flags |= ATA_HOST_PARALLEL_SCAN;
2665
2657 if (pi.flags & ATA_FLAG_EM) 2666 if (pi.flags & ATA_FLAG_EM)
2658 ahci_reset_em(host); 2667 ahci_reset_em(host);
2659 2668
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 5fdf1678d0cc..887d8f46a287 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -154,11 +154,13 @@ struct piix_map_db {
154 154
155struct piix_host_priv { 155struct piix_host_priv {
156 const int *map; 156 const int *map;
157 u32 saved_iocfg;
157 void __iomem *sidpr; 158 void __iomem *sidpr;
158}; 159};
159 160
160static int piix_init_one(struct pci_dev *pdev, 161static int piix_init_one(struct pci_dev *pdev,
161 const struct pci_device_id *ent); 162 const struct pci_device_id *ent);
163static void piix_remove_one(struct pci_dev *pdev);
162static int piix_pata_prereset(struct ata_link *link, unsigned long deadline); 164static int piix_pata_prereset(struct ata_link *link, unsigned long deadline);
163static void piix_set_piomode(struct ata_port *ap, struct ata_device *adev); 165static void piix_set_piomode(struct ata_port *ap, struct ata_device *adev);
164static void piix_set_dmamode(struct ata_port *ap, struct ata_device *adev); 166static void piix_set_dmamode(struct ata_port *ap, struct ata_device *adev);
@@ -296,7 +298,7 @@ static struct pci_driver piix_pci_driver = {
296 .name = DRV_NAME, 298 .name = DRV_NAME,
297 .id_table = piix_pci_tbl, 299 .id_table = piix_pci_tbl,
298 .probe = piix_init_one, 300 .probe = piix_init_one,
299 .remove = ata_pci_remove_one, 301 .remove = piix_remove_one,
300#ifdef CONFIG_PM 302#ifdef CONFIG_PM
301 .suspend = piix_pci_device_suspend, 303 .suspend = piix_pci_device_suspend,
302 .resume = piix_pci_device_resume, 304 .resume = piix_pci_device_resume,
@@ -308,7 +310,7 @@ static struct scsi_host_template piix_sht = {
308}; 310};
309 311
310static struct ata_port_operations piix_pata_ops = { 312static struct ata_port_operations piix_pata_ops = {
311 .inherits = &ata_bmdma_port_ops, 313 .inherits = &ata_bmdma32_port_ops,
312 .cable_detect = ata_cable_40wire, 314 .cable_detect = ata_cable_40wire,
313 .set_piomode = piix_set_piomode, 315 .set_piomode = piix_set_piomode,
314 .set_dmamode = piix_set_dmamode, 316 .set_dmamode = piix_set_dmamode,
@@ -610,8 +612,9 @@ static const struct ich_laptop ich_laptop[] = {
610static int ich_pata_cable_detect(struct ata_port *ap) 612static int ich_pata_cable_detect(struct ata_port *ap)
611{ 613{
612 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 614 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
615 struct piix_host_priv *hpriv = ap->host->private_data;
613 const struct ich_laptop *lap = &ich_laptop[0]; 616 const struct ich_laptop *lap = &ich_laptop[0];
614 u8 tmp, mask; 617 u8 mask;
615 618
616 /* Check for specials - Acer Aspire 5602WLMi */ 619 /* Check for specials - Acer Aspire 5602WLMi */
617 while (lap->device) { 620 while (lap->device) {
@@ -625,8 +628,7 @@ static int ich_pata_cable_detect(struct ata_port *ap)
625 628
626 /* check BIOS cable detect results */ 629 /* check BIOS cable detect results */
627 mask = ap->port_no == 0 ? PIIX_80C_PRI : PIIX_80C_SEC; 630 mask = ap->port_no == 0 ? PIIX_80C_PRI : PIIX_80C_SEC;
628 pci_read_config_byte(pdev, PIIX_IOCFG, &tmp); 631 if ((hpriv->saved_iocfg & mask) == 0)
629 if ((tmp & mask) == 0)
630 return ATA_CBL_PATA40; 632 return ATA_CBL_PATA40;
631 return ATA_CBL_PATA80; 633 return ATA_CBL_PATA80;
632} 634}
@@ -1350,7 +1352,7 @@ static int __devinit piix_init_sidpr(struct ata_host *host)
1350 return 0; 1352 return 0;
1351} 1353}
1352 1354
1353static void piix_iocfg_bit18_quirk(struct pci_dev *pdev) 1355static void piix_iocfg_bit18_quirk(struct ata_host *host)
1354{ 1356{
1355 static const struct dmi_system_id sysids[] = { 1357 static const struct dmi_system_id sysids[] = {
1356 { 1358 {
@@ -1367,7 +1369,8 @@ static void piix_iocfg_bit18_quirk(struct pci_dev *pdev)
1367 1369
1368 { } /* terminate list */ 1370 { } /* terminate list */
1369 }; 1371 };
1370 u32 iocfg; 1372 struct pci_dev *pdev = to_pci_dev(host->dev);
1373 struct piix_host_priv *hpriv = host->private_data;
1371 1374
1372 if (!dmi_check_system(sysids)) 1375 if (!dmi_check_system(sysids))
1373 return; 1376 return;
@@ -1376,12 +1379,11 @@ static void piix_iocfg_bit18_quirk(struct pci_dev *pdev)
1376 * seem to use it to disable a channel. Clear the bit on the 1379 * seem to use it to disable a channel. Clear the bit on the
1377 * affected systems. 1380 * affected systems.
1378 */ 1381 */
1379 pci_read_config_dword(pdev, PIIX_IOCFG, &iocfg); 1382 if (hpriv->saved_iocfg & (1 << 18)) {
1380 if (iocfg & (1 << 18)) {
1381 dev_printk(KERN_INFO, &pdev->dev, 1383 dev_printk(KERN_INFO, &pdev->dev,
1382 "applying IOCFG bit18 quirk\n"); 1384 "applying IOCFG bit18 quirk\n");
1383 iocfg &= ~(1 << 18); 1385 pci_write_config_dword(pdev, PIIX_IOCFG,
1384 pci_write_config_dword(pdev, PIIX_IOCFG, iocfg); 1386 hpriv->saved_iocfg & ~(1 << 18));
1385 } 1387 }
1386} 1388}
1387 1389
@@ -1430,6 +1432,17 @@ static int __devinit piix_init_one(struct pci_dev *pdev,
1430 if (rc) 1432 if (rc)
1431 return rc; 1433 return rc;
1432 1434
1435 hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
1436 if (!hpriv)
1437 return -ENOMEM;
1438
1439 /* Save IOCFG, this will be used for cable detection, quirk
1440 * detection and restoration on detach. This is necessary
1441 * because some ACPI implementations mess up cable related
1442 * bits on _STM. Reported on kernel bz#11879.
1443 */
1444 pci_read_config_dword(pdev, PIIX_IOCFG, &hpriv->saved_iocfg);
1445
1433 /* ICH6R may be driven by either ata_piix or ahci driver 1446 /* ICH6R may be driven by either ata_piix or ahci driver
1434 * regardless of BIOS configuration. Make sure AHCI mode is 1447 * regardless of BIOS configuration. Make sure AHCI mode is
1435 * off. 1448 * off.
@@ -1441,10 +1454,6 @@ static int __devinit piix_init_one(struct pci_dev *pdev,
1441 } 1454 }
1442 1455
1443 /* SATA map init can change port_info, do it before prepping host */ 1456 /* SATA map init can change port_info, do it before prepping host */
1444 hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
1445 if (!hpriv)
1446 return -ENOMEM;
1447
1448 if (port_flags & ATA_FLAG_SATA) 1457 if (port_flags & ATA_FLAG_SATA)
1449 hpriv->map = piix_init_sata_map(pdev, port_info, 1458 hpriv->map = piix_init_sata_map(pdev, port_info,
1450 piix_map_db_table[ent->driver_data]); 1459 piix_map_db_table[ent->driver_data]);
@@ -1463,7 +1472,7 @@ static int __devinit piix_init_one(struct pci_dev *pdev,
1463 } 1472 }
1464 1473
1465 /* apply IOCFG bit18 quirk */ 1474 /* apply IOCFG bit18 quirk */
1466 piix_iocfg_bit18_quirk(pdev); 1475 piix_iocfg_bit18_quirk(host);
1467 1476
1468 /* On ICH5, some BIOSen disable the interrupt using the 1477 /* On ICH5, some BIOSen disable the interrupt using the
1469 * PCI_COMMAND_INTX_DISABLE bit added in PCI 2.3. 1478 * PCI_COMMAND_INTX_DISABLE bit added in PCI 2.3.
@@ -1488,6 +1497,16 @@ static int __devinit piix_init_one(struct pci_dev *pdev,
1488 return ata_pci_sff_activate_host(host, ata_sff_interrupt, &piix_sht); 1497 return ata_pci_sff_activate_host(host, ata_sff_interrupt, &piix_sht);
1489} 1498}
1490 1499
1500static void piix_remove_one(struct pci_dev *pdev)
1501{
1502 struct ata_host *host = dev_get_drvdata(&pdev->dev);
1503 struct piix_host_priv *hpriv = host->private_data;
1504
1505 pci_write_config_dword(pdev, PIIX_IOCFG, hpriv->saved_iocfg);
1506
1507 ata_pci_remove_one(pdev);
1508}
1509
1491static int __init piix_init(void) 1510static int __init piix_init(void)
1492{ 1511{
1493 int rc; 1512 int rc;
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index ef02e488d468..6273d98d00eb 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -19,12 +19,6 @@
19#include "libata.h" 19#include "libata.h"
20 20
21#include <acpi/acpi_bus.h> 21#include <acpi/acpi_bus.h>
22#include <acpi/acnames.h>
23#include <acpi/acnamesp.h>
24#include <acpi/acparser.h>
25#include <acpi/acexcep.h>
26#include <acpi/acmacros.h>
27#include <acpi/actypes.h>
28 22
29enum { 23enum {
30 ATA_ACPI_FILTER_SETXFER = 1 << 0, 24 ATA_ACPI_FILTER_SETXFER = 1 << 0,
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index fecca4223f8e..88c242856dae 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -56,6 +56,7 @@
56#include <linux/workqueue.h> 56#include <linux/workqueue.h>
57#include <linux/scatterlist.h> 57#include <linux/scatterlist.h>
58#include <linux/io.h> 58#include <linux/io.h>
59#include <linux/async.h>
59#include <scsi/scsi.h> 60#include <scsi/scsi.h>
60#include <scsi/scsi_cmnd.h> 61#include <scsi/scsi_cmnd.h>
61#include <scsi/scsi_host.h> 62#include <scsi/scsi_host.h>
@@ -1006,6 +1007,7 @@ static const char *sata_spd_string(unsigned int spd)
1006 static const char * const spd_str[] = { 1007 static const char * const spd_str[] = {
1007 "1.5 Gbps", 1008 "1.5 Gbps",
1008 "3.0 Gbps", 1009 "3.0 Gbps",
1010 "6.0 Gbps",
1009 }; 1011 };
1010 1012
1011 if (spd == 0 || (spd - 1) >= ARRAY_SIZE(spd_str)) 1013 if (spd == 0 || (spd - 1) >= ARRAY_SIZE(spd_str))
@@ -1999,6 +2001,10 @@ unsigned int ata_pio_need_iordy(const struct ata_device *adev)
1999 as the caller should know this */ 2001 as the caller should know this */
2000 if (adev->link->ap->flags & ATA_FLAG_NO_IORDY) 2002 if (adev->link->ap->flags & ATA_FLAG_NO_IORDY)
2001 return 0; 2003 return 0;
2004 /* CF spec. r4.1 Table 22 says no iordy on PIO5 and PIO6. */
2005 if (ata_id_is_cfa(adev->id)
2006 && (adev->pio_mode == XFER_PIO_5 || adev->pio_mode == XFER_PIO_6))
2007 return 0;
2002 /* PIO3 and higher it is mandatory */ 2008 /* PIO3 and higher it is mandatory */
2003 if (adev->pio_mode > XFER_PIO_2) 2009 if (adev->pio_mode > XFER_PIO_2)
2004 return 1; 2010 return 1;
@@ -3023,33 +3029,33 @@ int sata_set_spd(struct ata_link *link)
3023 */ 3029 */
3024 3030
3025static const struct ata_timing ata_timing[] = { 3031static const struct ata_timing ata_timing[] = {
3026/* { XFER_PIO_SLOW, 120, 290, 240, 960, 290, 240, 960, 0 }, */ 3032/* { XFER_PIO_SLOW, 120, 290, 240, 960, 290, 240, 0, 960, 0 }, */
3027 { XFER_PIO_0, 70, 290, 240, 600, 165, 150, 600, 0 }, 3033 { XFER_PIO_0, 70, 290, 240, 600, 165, 150, 0, 600, 0 },
3028 { XFER_PIO_1, 50, 290, 93, 383, 125, 100, 383, 0 }, 3034 { XFER_PIO_1, 50, 290, 93, 383, 125, 100, 0, 383, 0 },
3029 { XFER_PIO_2, 30, 290, 40, 330, 100, 90, 240, 0 }, 3035 { XFER_PIO_2, 30, 290, 40, 330, 100, 90, 0, 240, 0 },
3030 { XFER_PIO_3, 30, 80, 70, 180, 80, 70, 180, 0 }, 3036 { XFER_PIO_3, 30, 80, 70, 180, 80, 70, 0, 180, 0 },
3031 { XFER_PIO_4, 25, 70, 25, 120, 70, 25, 120, 0 }, 3037 { XFER_PIO_4, 25, 70, 25, 120, 70, 25, 0, 120, 0 },
3032 { XFER_PIO_5, 15, 65, 25, 100, 65, 25, 100, 0 }, 3038 { XFER_PIO_5, 15, 65, 25, 100, 65, 25, 0, 100, 0 },
3033 { XFER_PIO_6, 10, 55, 20, 80, 55, 20, 80, 0 }, 3039 { XFER_PIO_6, 10, 55, 20, 80, 55, 20, 0, 80, 0 },
3034 3040
3035 { XFER_SW_DMA_0, 120, 0, 0, 0, 480, 480, 960, 0 }, 3041 { XFER_SW_DMA_0, 120, 0, 0, 0, 480, 480, 50, 960, 0 },
3036 { XFER_SW_DMA_1, 90, 0, 0, 0, 240, 240, 480, 0 }, 3042 { XFER_SW_DMA_1, 90, 0, 0, 0, 240, 240, 30, 480, 0 },
3037 { XFER_SW_DMA_2, 60, 0, 0, 0, 120, 120, 240, 0 }, 3043 { XFER_SW_DMA_2, 60, 0, 0, 0, 120, 120, 20, 240, 0 },
3038 3044
3039 { XFER_MW_DMA_0, 60, 0, 0, 0, 215, 215, 480, 0 }, 3045 { XFER_MW_DMA_0, 60, 0, 0, 0, 215, 215, 20, 480, 0 },
3040 { XFER_MW_DMA_1, 45, 0, 0, 0, 80, 50, 150, 0 }, 3046 { XFER_MW_DMA_1, 45, 0, 0, 0, 80, 50, 5, 150, 0 },
3041 { XFER_MW_DMA_2, 25, 0, 0, 0, 70, 25, 120, 0 }, 3047 { XFER_MW_DMA_2, 25, 0, 0, 0, 70, 25, 5, 120, 0 },
3042 { XFER_MW_DMA_3, 25, 0, 0, 0, 65, 25, 100, 0 }, 3048 { XFER_MW_DMA_3, 25, 0, 0, 0, 65, 25, 5, 100, 0 },
3043 { XFER_MW_DMA_4, 25, 0, 0, 0, 55, 20, 80, 0 }, 3049 { XFER_MW_DMA_4, 25, 0, 0, 0, 55, 20, 5, 80, 0 },
3044 3050
3045/* { XFER_UDMA_SLOW, 0, 0, 0, 0, 0, 0, 0, 150 }, */ 3051/* { XFER_UDMA_SLOW, 0, 0, 0, 0, 0, 0, 0, 0, 150 }, */
3046 { XFER_UDMA_0, 0, 0, 0, 0, 0, 0, 0, 120 }, 3052 { XFER_UDMA_0, 0, 0, 0, 0, 0, 0, 0, 0, 120 },
3047 { XFER_UDMA_1, 0, 0, 0, 0, 0, 0, 0, 80 }, 3053 { XFER_UDMA_1, 0, 0, 0, 0, 0, 0, 0, 0, 80 },
3048 { XFER_UDMA_2, 0, 0, 0, 0, 0, 0, 0, 60 }, 3054 { XFER_UDMA_2, 0, 0, 0, 0, 0, 0, 0, 0, 60 },
3049 { XFER_UDMA_3, 0, 0, 0, 0, 0, 0, 0, 45 }, 3055 { XFER_UDMA_3, 0, 0, 0, 0, 0, 0, 0, 0, 45 },
3050 { XFER_UDMA_4, 0, 0, 0, 0, 0, 0, 0, 30 }, 3056 { XFER_UDMA_4, 0, 0, 0, 0, 0, 0, 0, 0, 30 },
3051 { XFER_UDMA_5, 0, 0, 0, 0, 0, 0, 0, 20 }, 3057 { XFER_UDMA_5, 0, 0, 0, 0, 0, 0, 0, 0, 20 },
3052 { XFER_UDMA_6, 0, 0, 0, 0, 0, 0, 0, 15 }, 3058 { XFER_UDMA_6, 0, 0, 0, 0, 0, 0, 0, 0, 15 },
3053 3059
3054 { 0xFF } 3060 { 0xFF }
3055}; 3061};
@@ -3059,14 +3065,15 @@ static const struct ata_timing ata_timing[] = {
3059 3065
3060static void ata_timing_quantize(const struct ata_timing *t, struct ata_timing *q, int T, int UT) 3066static void ata_timing_quantize(const struct ata_timing *t, struct ata_timing *q, int T, int UT)
3061{ 3067{
3062 q->setup = EZ(t->setup * 1000, T); 3068 q->setup = EZ(t->setup * 1000, T);
3063 q->act8b = EZ(t->act8b * 1000, T); 3069 q->act8b = EZ(t->act8b * 1000, T);
3064 q->rec8b = EZ(t->rec8b * 1000, T); 3070 q->rec8b = EZ(t->rec8b * 1000, T);
3065 q->cyc8b = EZ(t->cyc8b * 1000, T); 3071 q->cyc8b = EZ(t->cyc8b * 1000, T);
3066 q->active = EZ(t->active * 1000, T); 3072 q->active = EZ(t->active * 1000, T);
3067 q->recover = EZ(t->recover * 1000, T); 3073 q->recover = EZ(t->recover * 1000, T);
3068 q->cycle = EZ(t->cycle * 1000, T); 3074 q->dmack_hold = EZ(t->dmack_hold * 1000, T);
3069 q->udma = EZ(t->udma * 1000, UT); 3075 q->cycle = EZ(t->cycle * 1000, T);
3076 q->udma = EZ(t->udma * 1000, UT);
3070} 3077}
3071 3078
3072void ata_timing_merge(const struct ata_timing *a, const struct ata_timing *b, 3079void ata_timing_merge(const struct ata_timing *a, const struct ata_timing *b,
@@ -3078,6 +3085,7 @@ void ata_timing_merge(const struct ata_timing *a, const struct ata_timing *b,
3078 if (what & ATA_TIMING_CYC8B ) m->cyc8b = max(a->cyc8b, b->cyc8b); 3085 if (what & ATA_TIMING_CYC8B ) m->cyc8b = max(a->cyc8b, b->cyc8b);
3079 if (what & ATA_TIMING_ACTIVE ) m->active = max(a->active, b->active); 3086 if (what & ATA_TIMING_ACTIVE ) m->active = max(a->active, b->active);
3080 if (what & ATA_TIMING_RECOVER) m->recover = max(a->recover, b->recover); 3087 if (what & ATA_TIMING_RECOVER) m->recover = max(a->recover, b->recover);
3088 if (what & ATA_TIMING_DMACK_HOLD) m->dmack_hold = max(a->dmack_hold, b->dmack_hold);
3081 if (what & ATA_TIMING_CYCLE ) m->cycle = max(a->cycle, b->cycle); 3089 if (what & ATA_TIMING_CYCLE ) m->cycle = max(a->cycle, b->cycle);
3082 if (what & ATA_TIMING_UDMA ) m->udma = max(a->udma, b->udma); 3090 if (what & ATA_TIMING_UDMA ) m->udma = max(a->udma, b->udma);
3083} 3091}
@@ -4550,7 +4558,7 @@ void ata_sg_clean(struct ata_queued_cmd *qc)
4550 struct scatterlist *sg = qc->sg; 4558 struct scatterlist *sg = qc->sg;
4551 int dir = qc->dma_dir; 4559 int dir = qc->dma_dir;
4552 4560
4553 WARN_ON(sg == NULL); 4561 WARN_ON_ONCE(sg == NULL);
4554 4562
4555 VPRINTK("unmapping %u sg elements\n", qc->n_elem); 4563 VPRINTK("unmapping %u sg elements\n", qc->n_elem);
4556 4564
@@ -4770,7 +4778,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
4770 struct ata_port *ap = qc->ap; 4778 struct ata_port *ap = qc->ap;
4771 unsigned int tag; 4779 unsigned int tag;
4772 4780
4773 WARN_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */ 4781 WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
4774 4782
4775 qc->flags = 0; 4783 qc->flags = 0;
4776 tag = qc->tag; 4784 tag = qc->tag;
@@ -4785,8 +4793,8 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
4785 struct ata_port *ap = qc->ap; 4793 struct ata_port *ap = qc->ap;
4786 struct ata_link *link = qc->dev->link; 4794 struct ata_link *link = qc->dev->link;
4787 4795
4788 WARN_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */ 4796 WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
4789 WARN_ON(!(qc->flags & ATA_QCFLAG_ACTIVE)); 4797 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
4790 4798
4791 if (likely(qc->flags & ATA_QCFLAG_DMAMAP)) 4799 if (likely(qc->flags & ATA_QCFLAG_DMAMAP))
4792 ata_sg_clean(qc); 4800 ata_sg_clean(qc);
@@ -4872,7 +4880,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
4872 struct ata_device *dev = qc->dev; 4880 struct ata_device *dev = qc->dev;
4873 struct ata_eh_info *ehi = &dev->link->eh_info; 4881 struct ata_eh_info *ehi = &dev->link->eh_info;
4874 4882
4875 WARN_ON(ap->pflags & ATA_PFLAG_FROZEN); 4883 WARN_ON_ONCE(ap->pflags & ATA_PFLAG_FROZEN);
4876 4884
4877 if (unlikely(qc->err_mask)) 4885 if (unlikely(qc->err_mask))
4878 qc->flags |= ATA_QCFLAG_FAILED; 4886 qc->flags |= ATA_QCFLAG_FAILED;
@@ -4994,16 +5002,16 @@ void ata_qc_issue(struct ata_queued_cmd *qc)
4994 * check is skipped for old EH because it reuses active qc to 5002 * check is skipped for old EH because it reuses active qc to
4995 * request ATAPI sense. 5003 * request ATAPI sense.
4996 */ 5004 */
4997 WARN_ON(ap->ops->error_handler && ata_tag_valid(link->active_tag)); 5005 WARN_ON_ONCE(ap->ops->error_handler && ata_tag_valid(link->active_tag));
4998 5006
4999 if (ata_is_ncq(prot)) { 5007 if (ata_is_ncq(prot)) {
5000 WARN_ON(link->sactive & (1 << qc->tag)); 5008 WARN_ON_ONCE(link->sactive & (1 << qc->tag));
5001 5009
5002 if (!link->sactive) 5010 if (!link->sactive)
5003 ap->nr_active_links++; 5011 ap->nr_active_links++;
5004 link->sactive |= 1 << qc->tag; 5012 link->sactive |= 1 << qc->tag;
5005 } else { 5013 } else {
5006 WARN_ON(link->sactive); 5014 WARN_ON_ONCE(link->sactive);
5007 5015
5008 ap->nr_active_links++; 5016 ap->nr_active_links++;
5009 link->active_tag = qc->tag; 5017 link->active_tag = qc->tag;
@@ -5909,6 +5917,65 @@ void ata_host_init(struct ata_host *host, struct device *dev,
5909 host->ops = ops; 5917 host->ops = ops;
5910} 5918}
5911 5919
5920
5921static void async_port_probe(void *data, async_cookie_t cookie)
5922{
5923 int rc;
5924 struct ata_port *ap = data;
5925
5926 /*
5927 * If we're not allowed to scan this host in parallel,
5928 * we need to wait until all previous scans have completed
5929 * before going further.
5930 * Jeff Garzik says this is only within a controller, so we
5931 * don't need to wait for port 0, only for later ports.
5932 */
5933 if (!(ap->host->flags & ATA_HOST_PARALLEL_SCAN) && ap->port_no != 0)
5934 async_synchronize_cookie(cookie);
5935
5936 /* probe */
5937 if (ap->ops->error_handler) {
5938 struct ata_eh_info *ehi = &ap->link.eh_info;
5939 unsigned long flags;
5940
5941 ata_port_probe(ap);
5942
5943 /* kick EH for boot probing */
5944 spin_lock_irqsave(ap->lock, flags);
5945
5946 ehi->probe_mask |= ATA_ALL_DEVICES;
5947 ehi->action |= ATA_EH_RESET | ATA_EH_LPM;
5948 ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET;
5949
5950 ap->pflags &= ~ATA_PFLAG_INITIALIZING;
5951 ap->pflags |= ATA_PFLAG_LOADING;
5952 ata_port_schedule_eh(ap);
5953
5954 spin_unlock_irqrestore(ap->lock, flags);
5955
5956 /* wait for EH to finish */
5957 ata_port_wait_eh(ap);
5958 } else {
5959 DPRINTK("ata%u: bus probe begin\n", ap->print_id);
5960 rc = ata_bus_probe(ap);
5961 DPRINTK("ata%u: bus probe end\n", ap->print_id);
5962
5963 if (rc) {
5964 /* FIXME: do something useful here?
5965 * Current libata behavior will
5966 * tear down everything when
5967 * the module is removed
5968 * or the h/w is unplugged.
5969 */
5970 }
5971 }
5972
5973 /* in order to keep device order, we need to synchronize at this point */
5974 async_synchronize_cookie(cookie);
5975
5976 ata_scsi_scan_host(ap, 1);
5977
5978}
5912/** 5979/**
5913 * ata_host_register - register initialized ATA host 5980 * ata_host_register - register initialized ATA host
5914 * @host: ATA host to register 5981 * @host: ATA host to register
@@ -5988,52 +6055,9 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
5988 DPRINTK("probe begin\n"); 6055 DPRINTK("probe begin\n");
5989 for (i = 0; i < host->n_ports; i++) { 6056 for (i = 0; i < host->n_ports; i++) {
5990 struct ata_port *ap = host->ports[i]; 6057 struct ata_port *ap = host->ports[i];
5991 6058 async_schedule(async_port_probe, ap);
5992 /* probe */
5993 if (ap->ops->error_handler) {
5994 struct ata_eh_info *ehi = &ap->link.eh_info;
5995 unsigned long flags;
5996
5997 ata_port_probe(ap);
5998
5999 /* kick EH for boot probing */
6000 spin_lock_irqsave(ap->lock, flags);
6001
6002 ehi->probe_mask |= ATA_ALL_DEVICES;
6003 ehi->action |= ATA_EH_RESET | ATA_EH_LPM;
6004 ehi->flags |= ATA_EHI_NO_AUTOPSY | ATA_EHI_QUIET;
6005
6006 ap->pflags &= ~ATA_PFLAG_INITIALIZING;
6007 ap->pflags |= ATA_PFLAG_LOADING;
6008 ata_port_schedule_eh(ap);
6009
6010 spin_unlock_irqrestore(ap->lock, flags);
6011
6012 /* wait for EH to finish */
6013 ata_port_wait_eh(ap);
6014 } else {
6015 DPRINTK("ata%u: bus probe begin\n", ap->print_id);
6016 rc = ata_bus_probe(ap);
6017 DPRINTK("ata%u: bus probe end\n", ap->print_id);
6018
6019 if (rc) {
6020 /* FIXME: do something useful here?
6021 * Current libata behavior will
6022 * tear down everything when
6023 * the module is removed
6024 * or the h/w is unplugged.
6025 */
6026 }
6027 }
6028 }
6029
6030 /* probes are done, now scan each port's disk(s) */
6031 DPRINTK("host probe begin\n");
6032 for (i = 0; i < host->n_ports; i++) {
6033 struct ata_port *ap = host->ports[i];
6034
6035 ata_scsi_scan_host(ap, 1);
6036 } 6059 }
6060 DPRINTK("probe end\n");
6037 6061
6038 return 0; 6062 return 0;
6039} 6063}
@@ -6616,7 +6640,6 @@ EXPORT_SYMBOL_GPL(ata_dev_pair);
6616EXPORT_SYMBOL_GPL(ata_port_disable); 6640EXPORT_SYMBOL_GPL(ata_port_disable);
6617EXPORT_SYMBOL_GPL(ata_ratelimit); 6641EXPORT_SYMBOL_GPL(ata_ratelimit);
6618EXPORT_SYMBOL_GPL(ata_wait_register); 6642EXPORT_SYMBOL_GPL(ata_wait_register);
6619EXPORT_SYMBOL_GPL(ata_scsi_ioctl);
6620EXPORT_SYMBOL_GPL(ata_scsi_queuecmd); 6643EXPORT_SYMBOL_GPL(ata_scsi_queuecmd);
6621EXPORT_SYMBOL_GPL(ata_scsi_slave_config); 6644EXPORT_SYMBOL_GPL(ata_scsi_slave_config);
6622EXPORT_SYMBOL_GPL(ata_scsi_slave_destroy); 6645EXPORT_SYMBOL_GPL(ata_scsi_slave_destroy);
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 9e92107691f2..a1a6e6298c33 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -423,9 +423,9 @@ int ata_std_bios_param(struct scsi_device *sdev, struct block_device *bdev,
423 * RETURNS: 423 * RETURNS:
424 * Zero on success, negative errno on error. 424 * Zero on success, negative errno on error.
425 */ 425 */
426static int ata_get_identity(struct scsi_device *sdev, void __user *arg) 426static int ata_get_identity(struct ata_port *ap, struct scsi_device *sdev,
427 void __user *arg)
427{ 428{
428 struct ata_port *ap = ata_shost_to_port(sdev->host);
429 struct ata_device *dev = ata_scsi_find_dev(ap, sdev); 429 struct ata_device *dev = ata_scsi_find_dev(ap, sdev);
430 u16 __user *dst = arg; 430 u16 __user *dst = arg;
431 char buf[40]; 431 char buf[40];
@@ -645,7 +645,8 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg)
645 return rc; 645 return rc;
646} 646}
647 647
648int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg) 648int ata_sas_scsi_ioctl(struct ata_port *ap, struct scsi_device *scsidev,
649 int cmd, void __user *arg)
649{ 650{
650 int val = -EINVAL, rc = -EINVAL; 651 int val = -EINVAL, rc = -EINVAL;
651 652
@@ -663,7 +664,7 @@ int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg)
663 return 0; 664 return 0;
664 665
665 case HDIO_GET_IDENTITY: 666 case HDIO_GET_IDENTITY:
666 return ata_get_identity(scsidev, arg); 667 return ata_get_identity(ap, scsidev, arg);
667 668
668 case HDIO_DRIVE_CMD: 669 case HDIO_DRIVE_CMD:
669 if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) 670 if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
@@ -682,6 +683,14 @@ int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg)
682 683
683 return rc; 684 return rc;
684} 685}
686EXPORT_SYMBOL_GPL(ata_sas_scsi_ioctl);
687
688int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg)
689{
690 return ata_sas_scsi_ioctl(ata_shost_to_port(scsidev->host),
691 scsidev, cmd, arg);
692}
693EXPORT_SYMBOL_GPL(ata_scsi_ioctl);
685 694
686/** 695/**
687 * ata_scsi_qc_new - acquire new ata_queued_cmd reference 696 * ata_scsi_qc_new - acquire new ata_queued_cmd reference
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 9033d164c4ec..5a4aad123c42 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -66,6 +66,7 @@ const struct ata_port_operations ata_sff_port_ops = {
66 66
67 .port_start = ata_sff_port_start, 67 .port_start = ata_sff_port_start,
68}; 68};
69EXPORT_SYMBOL_GPL(ata_sff_port_ops);
69 70
70const struct ata_port_operations ata_bmdma_port_ops = { 71const struct ata_port_operations ata_bmdma_port_ops = {
71 .inherits = &ata_sff_port_ops, 72 .inherits = &ata_sff_port_ops,
@@ -77,6 +78,14 @@ const struct ata_port_operations ata_bmdma_port_ops = {
77 .bmdma_stop = ata_bmdma_stop, 78 .bmdma_stop = ata_bmdma_stop,
78 .bmdma_status = ata_bmdma_status, 79 .bmdma_status = ata_bmdma_status,
79}; 80};
81EXPORT_SYMBOL_GPL(ata_bmdma_port_ops);
82
83const struct ata_port_operations ata_bmdma32_port_ops = {
84 .inherits = &ata_bmdma_port_ops,
85
86 .sff_data_xfer = ata_sff_data_xfer32,
87};
88EXPORT_SYMBOL_GPL(ata_bmdma32_port_ops);
80 89
81/** 90/**
82 * ata_fill_sg - Fill PCI IDE PRD table 91 * ata_fill_sg - Fill PCI IDE PRD table
@@ -166,8 +175,9 @@ static void ata_fill_sg_dumb(struct ata_queued_cmd *qc)
166 blen = len & 0xffff; 175 blen = len & 0xffff;
167 ap->prd[pi].addr = cpu_to_le32(addr); 176 ap->prd[pi].addr = cpu_to_le32(addr);
168 if (blen == 0) { 177 if (blen == 0) {
169 /* Some PATA chipsets like the CS5530 can't 178 /* Some PATA chipsets like the CS5530 can't
170 cope with 0x0000 meaning 64K as the spec says */ 179 cope with 0x0000 meaning 64K as the spec
180 says */
171 ap->prd[pi].flags_len = cpu_to_le32(0x8000); 181 ap->prd[pi].flags_len = cpu_to_le32(0x8000);
172 blen = 0x8000; 182 blen = 0x8000;
173 ap->prd[++pi].addr = cpu_to_le32(addr + 0x8000); 183 ap->prd[++pi].addr = cpu_to_le32(addr + 0x8000);
@@ -200,6 +210,7 @@ void ata_sff_qc_prep(struct ata_queued_cmd *qc)
200 210
201 ata_fill_sg(qc); 211 ata_fill_sg(qc);
202} 212}
213EXPORT_SYMBOL_GPL(ata_sff_qc_prep);
203 214
204/** 215/**
205 * ata_sff_dumb_qc_prep - Prepare taskfile for submission 216 * ata_sff_dumb_qc_prep - Prepare taskfile for submission
@@ -217,6 +228,7 @@ void ata_sff_dumb_qc_prep(struct ata_queued_cmd *qc)
217 228
218 ata_fill_sg_dumb(qc); 229 ata_fill_sg_dumb(qc);
219} 230}
231EXPORT_SYMBOL_GPL(ata_sff_dumb_qc_prep);
220 232
221/** 233/**
222 * ata_sff_check_status - Read device status reg & clear interrupt 234 * ata_sff_check_status - Read device status reg & clear interrupt
@@ -233,6 +245,7 @@ u8 ata_sff_check_status(struct ata_port *ap)
233{ 245{
234 return ioread8(ap->ioaddr.status_addr); 246 return ioread8(ap->ioaddr.status_addr);
235} 247}
248EXPORT_SYMBOL_GPL(ata_sff_check_status);
236 249
237/** 250/**
238 * ata_sff_altstatus - Read device alternate status reg 251 * ata_sff_altstatus - Read device alternate status reg
@@ -275,7 +288,7 @@ static u8 ata_sff_irq_status(struct ata_port *ap)
275 status = ata_sff_altstatus(ap); 288 status = ata_sff_altstatus(ap);
276 /* Not us: We are busy */ 289 /* Not us: We are busy */
277 if (status & ATA_BUSY) 290 if (status & ATA_BUSY)
278 return status; 291 return status;
279 } 292 }
280 /* Clear INTRQ latch */ 293 /* Clear INTRQ latch */
281 status = ap->ops->sff_check_status(ap); 294 status = ap->ops->sff_check_status(ap);
@@ -319,6 +332,7 @@ void ata_sff_pause(struct ata_port *ap)
319 ata_sff_sync(ap); 332 ata_sff_sync(ap);
320 ndelay(400); 333 ndelay(400);
321} 334}
335EXPORT_SYMBOL_GPL(ata_sff_pause);
322 336
323/** 337/**
324 * ata_sff_dma_pause - Pause before commencing DMA 338 * ata_sff_dma_pause - Pause before commencing DMA
@@ -327,7 +341,7 @@ void ata_sff_pause(struct ata_port *ap)
327 * Perform I/O fencing and ensure sufficient cycle delays occur 341 * Perform I/O fencing and ensure sufficient cycle delays occur
328 * for the HDMA1:0 transition 342 * for the HDMA1:0 transition
329 */ 343 */
330 344
331void ata_sff_dma_pause(struct ata_port *ap) 345void ata_sff_dma_pause(struct ata_port *ap)
332{ 346{
333 if (ap->ops->sff_check_altstatus || ap->ioaddr.altstatus_addr) { 347 if (ap->ops->sff_check_altstatus || ap->ioaddr.altstatus_addr) {
@@ -341,6 +355,7 @@ void ata_sff_dma_pause(struct ata_port *ap)
341 corruption. */ 355 corruption. */
342 BUG(); 356 BUG();
343} 357}
358EXPORT_SYMBOL_GPL(ata_sff_dma_pause);
344 359
345/** 360/**
346 * ata_sff_busy_sleep - sleep until BSY clears, or timeout 361 * ata_sff_busy_sleep - sleep until BSY clears, or timeout
@@ -396,6 +411,7 @@ int ata_sff_busy_sleep(struct ata_port *ap,
396 411
397 return 0; 412 return 0;
398} 413}
414EXPORT_SYMBOL_GPL(ata_sff_busy_sleep);
399 415
400static int ata_sff_check_ready(struct ata_link *link) 416static int ata_sff_check_ready(struct ata_link *link)
401{ 417{
@@ -422,6 +438,7 @@ int ata_sff_wait_ready(struct ata_link *link, unsigned long deadline)
422{ 438{
423 return ata_wait_ready(link, deadline, ata_sff_check_ready); 439 return ata_wait_ready(link, deadline, ata_sff_check_ready);
424} 440}
441EXPORT_SYMBOL_GPL(ata_sff_wait_ready);
425 442
426/** 443/**
427 * ata_sff_dev_select - Select device 0/1 on ATA bus 444 * ata_sff_dev_select - Select device 0/1 on ATA bus
@@ -449,6 +466,7 @@ void ata_sff_dev_select(struct ata_port *ap, unsigned int device)
449 iowrite8(tmp, ap->ioaddr.device_addr); 466 iowrite8(tmp, ap->ioaddr.device_addr);
450 ata_sff_pause(ap); /* needed; also flushes, for mmio */ 467 ata_sff_pause(ap); /* needed; also flushes, for mmio */
451} 468}
469EXPORT_SYMBOL_GPL(ata_sff_dev_select);
452 470
453/** 471/**
454 * ata_dev_select - Select device 0/1 on ATA bus 472 * ata_dev_select - Select device 0/1 on ATA bus
@@ -513,6 +531,7 @@ u8 ata_sff_irq_on(struct ata_port *ap)
513 531
514 return tmp; 532 return tmp;
515} 533}
534EXPORT_SYMBOL_GPL(ata_sff_irq_on);
516 535
517/** 536/**
518 * ata_sff_irq_clear - Clear PCI IDE BMDMA interrupt. 537 * ata_sff_irq_clear - Clear PCI IDE BMDMA interrupt.
@@ -534,6 +553,7 @@ void ata_sff_irq_clear(struct ata_port *ap)
534 553
535 iowrite8(ioread8(mmio + ATA_DMA_STATUS), mmio + ATA_DMA_STATUS); 554 iowrite8(ioread8(mmio + ATA_DMA_STATUS), mmio + ATA_DMA_STATUS);
536} 555}
556EXPORT_SYMBOL_GPL(ata_sff_irq_clear);
537 557
538/** 558/**
539 * ata_sff_tf_load - send taskfile registers to host controller 559 * ata_sff_tf_load - send taskfile registers to host controller
@@ -558,7 +578,7 @@ void ata_sff_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
558 } 578 }
559 579
560 if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) { 580 if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) {
561 WARN_ON(!ioaddr->ctl_addr); 581 WARN_ON_ONCE(!ioaddr->ctl_addr);
562 iowrite8(tf->hob_feature, ioaddr->feature_addr); 582 iowrite8(tf->hob_feature, ioaddr->feature_addr);
563 iowrite8(tf->hob_nsect, ioaddr->nsect_addr); 583 iowrite8(tf->hob_nsect, ioaddr->nsect_addr);
564 iowrite8(tf->hob_lbal, ioaddr->lbal_addr); 584 iowrite8(tf->hob_lbal, ioaddr->lbal_addr);
@@ -593,6 +613,7 @@ void ata_sff_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
593 613
594 ata_wait_idle(ap); 614 ata_wait_idle(ap);
595} 615}
616EXPORT_SYMBOL_GPL(ata_sff_tf_load);
596 617
597/** 618/**
598 * ata_sff_tf_read - input device's ATA taskfile shadow registers 619 * ata_sff_tf_read - input device's ATA taskfile shadow registers
@@ -630,9 +651,10 @@ void ata_sff_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
630 iowrite8(tf->ctl, ioaddr->ctl_addr); 651 iowrite8(tf->ctl, ioaddr->ctl_addr);
631 ap->last_ctl = tf->ctl; 652 ap->last_ctl = tf->ctl;
632 } else 653 } else
633 WARN_ON(1); 654 WARN_ON_ONCE(1);
634 } 655 }
635} 656}
657EXPORT_SYMBOL_GPL(ata_sff_tf_read);
636 658
637/** 659/**
638 * ata_sff_exec_command - issue ATA command to host controller 660 * ata_sff_exec_command - issue ATA command to host controller
@@ -652,6 +674,7 @@ void ata_sff_exec_command(struct ata_port *ap, const struct ata_taskfile *tf)
652 iowrite8(tf->command, ap->ioaddr.command_addr); 674 iowrite8(tf->command, ap->ioaddr.command_addr);
653 ata_sff_pause(ap); 675 ata_sff_pause(ap);
654} 676}
677EXPORT_SYMBOL_GPL(ata_sff_exec_command);
655 678
656/** 679/**
657 * ata_tf_to_host - issue ATA taskfile to host controller 680 * ata_tf_to_host - issue ATA taskfile to host controller
@@ -717,6 +740,53 @@ unsigned int ata_sff_data_xfer(struct ata_device *dev, unsigned char *buf,
717 740
718 return words << 1; 741 return words << 1;
719} 742}
743EXPORT_SYMBOL_GPL(ata_sff_data_xfer);
744
745/**
746 * ata_sff_data_xfer32 - Transfer data by PIO
747 * @dev: device to target
748 * @buf: data buffer
749 * @buflen: buffer length
750 * @rw: read/write
751 *
752 * Transfer data from/to the device data register by PIO using 32bit
753 * I/O operations.
754 *
755 * LOCKING:
756 * Inherited from caller.
757 *
758 * RETURNS:
759 * Bytes consumed.
760 */
761
762unsigned int ata_sff_data_xfer32(struct ata_device *dev, unsigned char *buf,
763 unsigned int buflen, int rw)
764{
765 struct ata_port *ap = dev->link->ap;
766 void __iomem *data_addr = ap->ioaddr.data_addr;
767 unsigned int words = buflen >> 2;
768 int slop = buflen & 3;
769
770 /* Transfer multiple of 4 bytes */
771 if (rw == READ)
772 ioread32_rep(data_addr, buf, words);
773 else
774 iowrite32_rep(data_addr, buf, words);
775
776 if (unlikely(slop)) {
777 __le32 pad;
778 if (rw == READ) {
779 pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr));
780 memcpy(buf + buflen - slop, &pad, slop);
781 } else {
782 memcpy(&pad, buf + buflen - slop, slop);
783 iowrite32(le32_to_cpu(pad), ap->ioaddr.data_addr);
784 }
785 words++;
786 }
787 return words << 2;
788}
789EXPORT_SYMBOL_GPL(ata_sff_data_xfer32);
720 790
721/** 791/**
722 * ata_sff_data_xfer_noirq - Transfer data by PIO 792 * ata_sff_data_xfer_noirq - Transfer data by PIO
@@ -746,6 +816,7 @@ unsigned int ata_sff_data_xfer_noirq(struct ata_device *dev, unsigned char *buf,
746 816
747 return consumed; 817 return consumed;
748} 818}
819EXPORT_SYMBOL_GPL(ata_sff_data_xfer_noirq);
749 820
750/** 821/**
751 * ata_pio_sector - Transfer a sector of data. 822 * ata_pio_sector - Transfer a sector of data.
@@ -820,7 +891,7 @@ static void ata_pio_sectors(struct ata_queued_cmd *qc)
820 /* READ/WRITE MULTIPLE */ 891 /* READ/WRITE MULTIPLE */
821 unsigned int nsect; 892 unsigned int nsect;
822 893
823 WARN_ON(qc->dev->multi_count == 0); 894 WARN_ON_ONCE(qc->dev->multi_count == 0);
824 895
825 nsect = min((qc->nbytes - qc->curbytes) / qc->sect_size, 896 nsect = min((qc->nbytes - qc->curbytes) / qc->sect_size,
826 qc->dev->multi_count); 897 qc->dev->multi_count);
@@ -847,7 +918,7 @@ static void atapi_send_cdb(struct ata_port *ap, struct ata_queued_cmd *qc)
847{ 918{
848 /* send SCSI cdb */ 919 /* send SCSI cdb */
849 DPRINTK("send cdb\n"); 920 DPRINTK("send cdb\n");
850 WARN_ON(qc->dev->cdb_len < 12); 921 WARN_ON_ONCE(qc->dev->cdb_len < 12);
851 922
852 ap->ops->sff_data_xfer(qc->dev, qc->cdb, qc->dev->cdb_len, 1); 923 ap->ops->sff_data_xfer(qc->dev, qc->cdb, qc->dev->cdb_len, 1);
853 ata_sff_sync(ap); 924 ata_sff_sync(ap);
@@ -922,13 +993,15 @@ next_sg:
922 buf = kmap_atomic(page, KM_IRQ0); 993 buf = kmap_atomic(page, KM_IRQ0);
923 994
924 /* do the actual data transfer */ 995 /* do the actual data transfer */
925 consumed = ap->ops->sff_data_xfer(dev, buf + offset, count, rw); 996 consumed = ap->ops->sff_data_xfer(dev, buf + offset,
997 count, rw);
926 998
927 kunmap_atomic(buf, KM_IRQ0); 999 kunmap_atomic(buf, KM_IRQ0);
928 local_irq_restore(flags); 1000 local_irq_restore(flags);
929 } else { 1001 } else {
930 buf = page_address(page); 1002 buf = page_address(page);
931 consumed = ap->ops->sff_data_xfer(dev, buf + offset, count, rw); 1003 consumed = ap->ops->sff_data_xfer(dev, buf + offset,
1004 count, rw);
932 } 1005 }
933 1006
934 bytes -= min(bytes, consumed); 1007 bytes -= min(bytes, consumed);
@@ -940,9 +1013,12 @@ next_sg:
940 qc->cursg_ofs = 0; 1013 qc->cursg_ofs = 0;
941 } 1014 }
942 1015
943 /* consumed can be larger than count only for the last transfer */ 1016 /*
944 WARN_ON(qc->cursg && count != consumed); 1017 * There used to be a WARN_ON_ONCE(qc->cursg && count != consumed);
945 1018 * Unfortunately __atapi_pio_bytes doesn't know enough to do the WARN
1019 * check correctly as it doesn't know if it is the last request being
1020 * made. Somebody should implement a proper sanity check.
1021 */
946 if (bytes) 1022 if (bytes)
947 goto next_sg; 1023 goto next_sg;
948 return 0; 1024 return 0;
@@ -1013,18 +1089,19 @@ static void atapi_pio_bytes(struct ata_queued_cmd *qc)
1013 * RETURNS: 1089 * RETURNS:
1014 * 1 if ok in workqueue, 0 otherwise. 1090 * 1 if ok in workqueue, 0 otherwise.
1015 */ 1091 */
1016static inline int ata_hsm_ok_in_wq(struct ata_port *ap, struct ata_queued_cmd *qc) 1092static inline int ata_hsm_ok_in_wq(struct ata_port *ap,
1093 struct ata_queued_cmd *qc)
1017{ 1094{
1018 if (qc->tf.flags & ATA_TFLAG_POLLING) 1095 if (qc->tf.flags & ATA_TFLAG_POLLING)
1019 return 1; 1096 return 1;
1020 1097
1021 if (ap->hsm_task_state == HSM_ST_FIRST) { 1098 if (ap->hsm_task_state == HSM_ST_FIRST) {
1022 if (qc->tf.protocol == ATA_PROT_PIO && 1099 if (qc->tf.protocol == ATA_PROT_PIO &&
1023 (qc->tf.flags & ATA_TFLAG_WRITE)) 1100 (qc->tf.flags & ATA_TFLAG_WRITE))
1024 return 1; 1101 return 1;
1025 1102
1026 if (ata_is_atapi(qc->tf.protocol) && 1103 if (ata_is_atapi(qc->tf.protocol) &&
1027 !(qc->dev->flags & ATA_DFLAG_CDB_INTR)) 1104 !(qc->dev->flags & ATA_DFLAG_CDB_INTR))
1028 return 1; 1105 return 1;
1029 } 1106 }
1030 1107
@@ -1098,13 +1175,13 @@ int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
1098 unsigned long flags = 0; 1175 unsigned long flags = 0;
1099 int poll_next; 1176 int poll_next;
1100 1177
1101 WARN_ON((qc->flags & ATA_QCFLAG_ACTIVE) == 0); 1178 WARN_ON_ONCE((qc->flags & ATA_QCFLAG_ACTIVE) == 0);
1102 1179
1103 /* Make sure ata_sff_qc_issue() does not throw things 1180 /* Make sure ata_sff_qc_issue() does not throw things
1104 * like DMA polling into the workqueue. Notice that 1181 * like DMA polling into the workqueue. Notice that
1105 * in_wq is not equivalent to (qc->tf.flags & ATA_TFLAG_POLLING). 1182 * in_wq is not equivalent to (qc->tf.flags & ATA_TFLAG_POLLING).
1106 */ 1183 */
1107 WARN_ON(in_wq != ata_hsm_ok_in_wq(ap, qc)); 1184 WARN_ON_ONCE(in_wq != ata_hsm_ok_in_wq(ap, qc));
1108 1185
1109fsm_start: 1186fsm_start:
1110 DPRINTK("ata%u: protocol %d task_state %d (dev_stat 0x%X)\n", 1187 DPRINTK("ata%u: protocol %d task_state %d (dev_stat 0x%X)\n",
@@ -1313,7 +1390,7 @@ fsm_start:
1313 DPRINTK("ata%u: dev %u command complete, drv_stat 0x%x\n", 1390 DPRINTK("ata%u: dev %u command complete, drv_stat 0x%x\n",
1314 ap->print_id, qc->dev->devno, status); 1391 ap->print_id, qc->dev->devno, status);
1315 1392
1316 WARN_ON(qc->err_mask & (AC_ERR_DEV | AC_ERR_HSM)); 1393 WARN_ON_ONCE(qc->err_mask & (AC_ERR_DEV | AC_ERR_HSM));
1317 1394
1318 ap->hsm_task_state = HSM_ST_IDLE; 1395 ap->hsm_task_state = HSM_ST_IDLE;
1319 1396
@@ -1338,6 +1415,7 @@ fsm_start:
1338 1415
1339 return poll_next; 1416 return poll_next;
1340} 1417}
1418EXPORT_SYMBOL_GPL(ata_sff_hsm_move);
1341 1419
1342void ata_pio_task(struct work_struct *work) 1420void ata_pio_task(struct work_struct *work)
1343{ 1421{
@@ -1348,7 +1426,7 @@ void ata_pio_task(struct work_struct *work)
1348 int poll_next; 1426 int poll_next;
1349 1427
1350fsm_start: 1428fsm_start:
1351 WARN_ON(ap->hsm_task_state == HSM_ST_IDLE); 1429 WARN_ON_ONCE(ap->hsm_task_state == HSM_ST_IDLE);
1352 1430
1353 /* 1431 /*
1354 * This is purely heuristic. This is a fast path. 1432 * This is purely heuristic. This is a fast path.
@@ -1437,7 +1515,7 @@ unsigned int ata_sff_qc_issue(struct ata_queued_cmd *qc)
1437 break; 1515 break;
1438 1516
1439 case ATA_PROT_DMA: 1517 case ATA_PROT_DMA:
1440 WARN_ON(qc->tf.flags & ATA_TFLAG_POLLING); 1518 WARN_ON_ONCE(qc->tf.flags & ATA_TFLAG_POLLING);
1441 1519
1442 ap->ops->sff_tf_load(ap, &qc->tf); /* load tf registers */ 1520 ap->ops->sff_tf_load(ap, &qc->tf); /* load tf registers */
1443 ap->ops->bmdma_setup(qc); /* set up bmdma */ 1521 ap->ops->bmdma_setup(qc); /* set up bmdma */
@@ -1489,7 +1567,7 @@ unsigned int ata_sff_qc_issue(struct ata_queued_cmd *qc)
1489 break; 1567 break;
1490 1568
1491 case ATAPI_PROT_DMA: 1569 case ATAPI_PROT_DMA:
1492 WARN_ON(qc->tf.flags & ATA_TFLAG_POLLING); 1570 WARN_ON_ONCE(qc->tf.flags & ATA_TFLAG_POLLING);
1493 1571
1494 ap->ops->sff_tf_load(ap, &qc->tf); /* load tf registers */ 1572 ap->ops->sff_tf_load(ap, &qc->tf); /* load tf registers */
1495 ap->ops->bmdma_setup(qc); /* set up bmdma */ 1573 ap->ops->bmdma_setup(qc); /* set up bmdma */
@@ -1501,12 +1579,13 @@ unsigned int ata_sff_qc_issue(struct ata_queued_cmd *qc)
1501 break; 1579 break;
1502 1580
1503 default: 1581 default:
1504 WARN_ON(1); 1582 WARN_ON_ONCE(1);
1505 return AC_ERR_SYSTEM; 1583 return AC_ERR_SYSTEM;
1506 } 1584 }
1507 1585
1508 return 0; 1586 return 0;
1509} 1587}
1588EXPORT_SYMBOL_GPL(ata_sff_qc_issue);
1510 1589
1511/** 1590/**
1512 * ata_sff_qc_fill_rtf - fill result TF using ->sff_tf_read 1591 * ata_sff_qc_fill_rtf - fill result TF using ->sff_tf_read
@@ -1526,6 +1605,7 @@ bool ata_sff_qc_fill_rtf(struct ata_queued_cmd *qc)
1526 qc->ap->ops->sff_tf_read(qc->ap, &qc->result_tf); 1605 qc->ap->ops->sff_tf_read(qc->ap, &qc->result_tf);
1527 return true; 1606 return true;
1528} 1607}
1608EXPORT_SYMBOL_GPL(ata_sff_qc_fill_rtf);
1529 1609
1530/** 1610/**
1531 * ata_sff_host_intr - Handle host interrupt for given (port, task) 1611 * ata_sff_host_intr - Handle host interrupt for given (port, task)
@@ -1623,6 +1703,7 @@ idle_irq:
1623#endif 1703#endif
1624 return 0; /* irq not handled */ 1704 return 0; /* irq not handled */
1625} 1705}
1706EXPORT_SYMBOL_GPL(ata_sff_host_intr);
1626 1707
1627/** 1708/**
1628 * ata_sff_interrupt - Default ATA host interrupt handler 1709 * ata_sff_interrupt - Default ATA host interrupt handler
@@ -1667,6 +1748,7 @@ irqreturn_t ata_sff_interrupt(int irq, void *dev_instance)
1667 1748
1668 return IRQ_RETVAL(handled); 1749 return IRQ_RETVAL(handled);
1669} 1750}
1751EXPORT_SYMBOL_GPL(ata_sff_interrupt);
1670 1752
1671/** 1753/**
1672 * ata_sff_freeze - Freeze SFF controller port 1754 * ata_sff_freeze - Freeze SFF controller port
@@ -1695,6 +1777,7 @@ void ata_sff_freeze(struct ata_port *ap)
1695 1777
1696 ap->ops->sff_irq_clear(ap); 1778 ap->ops->sff_irq_clear(ap);
1697} 1779}
1780EXPORT_SYMBOL_GPL(ata_sff_freeze);
1698 1781
1699/** 1782/**
1700 * ata_sff_thaw - Thaw SFF controller port 1783 * ata_sff_thaw - Thaw SFF controller port
@@ -1712,6 +1795,7 @@ void ata_sff_thaw(struct ata_port *ap)
1712 ap->ops->sff_irq_clear(ap); 1795 ap->ops->sff_irq_clear(ap);
1713 ap->ops->sff_irq_on(ap); 1796 ap->ops->sff_irq_on(ap);
1714} 1797}
1798EXPORT_SYMBOL_GPL(ata_sff_thaw);
1715 1799
1716/** 1800/**
1717 * ata_sff_prereset - prepare SFF link for reset 1801 * ata_sff_prereset - prepare SFF link for reset
@@ -1753,6 +1837,7 @@ int ata_sff_prereset(struct ata_link *link, unsigned long deadline)
1753 1837
1754 return 0; 1838 return 0;
1755} 1839}
1840EXPORT_SYMBOL_GPL(ata_sff_prereset);
1756 1841
1757/** 1842/**
1758 * ata_devchk - PATA device presence detection 1843 * ata_devchk - PATA device presence detection
@@ -1865,6 +1950,7 @@ unsigned int ata_sff_dev_classify(struct ata_device *dev, int present,
1865 1950
1866 return class; 1951 return class;
1867} 1952}
1953EXPORT_SYMBOL_GPL(ata_sff_dev_classify);
1868 1954
1869/** 1955/**
1870 * ata_sff_wait_after_reset - wait for devices to become ready after reset 1956 * ata_sff_wait_after_reset - wait for devices to become ready after reset
@@ -1941,6 +2027,7 @@ int ata_sff_wait_after_reset(struct ata_link *link, unsigned int devmask,
1941 2027
1942 return ret; 2028 return ret;
1943} 2029}
2030EXPORT_SYMBOL_GPL(ata_sff_wait_after_reset);
1944 2031
1945static int ata_bus_softreset(struct ata_port *ap, unsigned int devmask, 2032static int ata_bus_softreset(struct ata_port *ap, unsigned int devmask,
1946 unsigned long deadline) 2033 unsigned long deadline)
@@ -2013,6 +2100,7 @@ int ata_sff_softreset(struct ata_link *link, unsigned int *classes,
2013 DPRINTK("EXIT, classes[0]=%u [1]=%u\n", classes[0], classes[1]); 2100 DPRINTK("EXIT, classes[0]=%u [1]=%u\n", classes[0], classes[1]);
2014 return 0; 2101 return 0;
2015} 2102}
2103EXPORT_SYMBOL_GPL(ata_sff_softreset);
2016 2104
2017/** 2105/**
2018 * sata_sff_hardreset - reset host port via SATA phy reset 2106 * sata_sff_hardreset - reset host port via SATA phy reset
@@ -2045,6 +2133,7 @@ int sata_sff_hardreset(struct ata_link *link, unsigned int *class,
2045 DPRINTK("EXIT, class=%u\n", *class); 2133 DPRINTK("EXIT, class=%u\n", *class);
2046 return rc; 2134 return rc;
2047} 2135}
2136EXPORT_SYMBOL_GPL(sata_sff_hardreset);
2048 2137
2049/** 2138/**
2050 * ata_sff_postreset - SFF postreset callback 2139 * ata_sff_postreset - SFF postreset callback
@@ -2080,6 +2169,7 @@ void ata_sff_postreset(struct ata_link *link, unsigned int *classes)
2080 if (ap->ioaddr.ctl_addr) 2169 if (ap->ioaddr.ctl_addr)
2081 iowrite8(ap->ctl, ap->ioaddr.ctl_addr); 2170 iowrite8(ap->ctl, ap->ioaddr.ctl_addr);
2082} 2171}
2172EXPORT_SYMBOL_GPL(ata_sff_postreset);
2083 2173
2084/** 2174/**
2085 * ata_sff_error_handler - Stock error handler for BMDMA controller 2175 * ata_sff_error_handler - Stock error handler for BMDMA controller
@@ -2152,6 +2242,7 @@ void ata_sff_error_handler(struct ata_port *ap)
2152 ata_do_eh(ap, ap->ops->prereset, softreset, hardreset, 2242 ata_do_eh(ap, ap->ops->prereset, softreset, hardreset,
2153 ap->ops->postreset); 2243 ap->ops->postreset);
2154} 2244}
2245EXPORT_SYMBOL_GPL(ata_sff_error_handler);
2155 2246
2156/** 2247/**
2157 * ata_sff_post_internal_cmd - Stock post_internal_cmd for SFF controller 2248 * ata_sff_post_internal_cmd - Stock post_internal_cmd for SFF controller
@@ -2174,6 +2265,7 @@ void ata_sff_post_internal_cmd(struct ata_queued_cmd *qc)
2174 2265
2175 spin_unlock_irqrestore(ap->lock, flags); 2266 spin_unlock_irqrestore(ap->lock, flags);
2176} 2267}
2268EXPORT_SYMBOL_GPL(ata_sff_post_internal_cmd);
2177 2269
2178/** 2270/**
2179 * ata_sff_port_start - Set port up for dma. 2271 * ata_sff_port_start - Set port up for dma.
@@ -2194,6 +2286,7 @@ int ata_sff_port_start(struct ata_port *ap)
2194 return ata_port_start(ap); 2286 return ata_port_start(ap);
2195 return 0; 2287 return 0;
2196} 2288}
2289EXPORT_SYMBOL_GPL(ata_sff_port_start);
2197 2290
2198/** 2291/**
2199 * ata_sff_std_ports - initialize ioaddr with standard port offsets. 2292 * ata_sff_std_ports - initialize ioaddr with standard port offsets.
@@ -2219,6 +2312,7 @@ void ata_sff_std_ports(struct ata_ioports *ioaddr)
2219 ioaddr->status_addr = ioaddr->cmd_addr + ATA_REG_STATUS; 2312 ioaddr->status_addr = ioaddr->cmd_addr + ATA_REG_STATUS;
2220 ioaddr->command_addr = ioaddr->cmd_addr + ATA_REG_CMD; 2313 ioaddr->command_addr = ioaddr->cmd_addr + ATA_REG_CMD;
2221} 2314}
2315EXPORT_SYMBOL_GPL(ata_sff_std_ports);
2222 2316
2223unsigned long ata_bmdma_mode_filter(struct ata_device *adev, 2317unsigned long ata_bmdma_mode_filter(struct ata_device *adev,
2224 unsigned long xfer_mask) 2318 unsigned long xfer_mask)
@@ -2230,6 +2324,7 @@ unsigned long ata_bmdma_mode_filter(struct ata_device *adev,
2230 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA); 2324 xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
2231 return xfer_mask; 2325 return xfer_mask;
2232} 2326}
2327EXPORT_SYMBOL_GPL(ata_bmdma_mode_filter);
2233 2328
2234/** 2329/**
2235 * ata_bmdma_setup - Set up PCI IDE BMDMA transaction 2330 * ata_bmdma_setup - Set up PCI IDE BMDMA transaction
@@ -2258,6 +2353,7 @@ void ata_bmdma_setup(struct ata_queued_cmd *qc)
2258 /* issue r/w command */ 2353 /* issue r/w command */
2259 ap->ops->sff_exec_command(ap, &qc->tf); 2354 ap->ops->sff_exec_command(ap, &qc->tf);
2260} 2355}
2356EXPORT_SYMBOL_GPL(ata_bmdma_setup);
2261 2357
2262/** 2358/**
2263 * ata_bmdma_start - Start a PCI IDE BMDMA transaction 2359 * ata_bmdma_start - Start a PCI IDE BMDMA transaction
@@ -2290,6 +2386,7 @@ void ata_bmdma_start(struct ata_queued_cmd *qc)
2290 * unneccessarily delayed for MMIO 2386 * unneccessarily delayed for MMIO
2291 */ 2387 */
2292} 2388}
2389EXPORT_SYMBOL_GPL(ata_bmdma_start);
2293 2390
2294/** 2391/**
2295 * ata_bmdma_stop - Stop PCI IDE BMDMA transfer 2392 * ata_bmdma_stop - Stop PCI IDE BMDMA transfer
@@ -2314,6 +2411,7 @@ void ata_bmdma_stop(struct ata_queued_cmd *qc)
2314 /* one-PIO-cycle guaranteed wait, per spec, for HDMA1:0 transition */ 2411 /* one-PIO-cycle guaranteed wait, per spec, for HDMA1:0 transition */
2315 ata_sff_dma_pause(ap); 2412 ata_sff_dma_pause(ap);
2316} 2413}
2414EXPORT_SYMBOL_GPL(ata_bmdma_stop);
2317 2415
2318/** 2416/**
2319 * ata_bmdma_status - Read PCI IDE BMDMA status 2417 * ata_bmdma_status - Read PCI IDE BMDMA status
@@ -2330,6 +2428,7 @@ u8 ata_bmdma_status(struct ata_port *ap)
2330{ 2428{
2331 return ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS); 2429 return ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
2332} 2430}
2431EXPORT_SYMBOL_GPL(ata_bmdma_status);
2333 2432
2334/** 2433/**
2335 * ata_bus_reset - reset host port and associated ATA channel 2434 * ata_bus_reset - reset host port and associated ATA channel
@@ -2422,6 +2521,7 @@ err_out:
2422 2521
2423 DPRINTK("EXIT\n"); 2522 DPRINTK("EXIT\n");
2424} 2523}
2524EXPORT_SYMBOL_GPL(ata_bus_reset);
2425 2525
2426#ifdef CONFIG_PCI 2526#ifdef CONFIG_PCI
2427 2527
@@ -2449,6 +2549,7 @@ int ata_pci_bmdma_clear_simplex(struct pci_dev *pdev)
2449 return -EOPNOTSUPP; 2549 return -EOPNOTSUPP;
2450 return 0; 2550 return 0;
2451} 2551}
2552EXPORT_SYMBOL_GPL(ata_pci_bmdma_clear_simplex);
2452 2553
2453/** 2554/**
2454 * ata_pci_bmdma_init - acquire PCI BMDMA resources and init ATA host 2555 * ata_pci_bmdma_init - acquire PCI BMDMA resources and init ATA host
@@ -2501,11 +2602,12 @@ int ata_pci_bmdma_init(struct ata_host *host)
2501 host->flags |= ATA_HOST_SIMPLEX; 2602 host->flags |= ATA_HOST_SIMPLEX;
2502 2603
2503 ata_port_desc(ap, "bmdma 0x%llx", 2604 ata_port_desc(ap, "bmdma 0x%llx",
2504 (unsigned long long)pci_resource_start(pdev, 4) + 8 * i); 2605 (unsigned long long)pci_resource_start(pdev, 4) + 8 * i);
2505 } 2606 }
2506 2607
2507 return 0; 2608 return 0;
2508} 2609}
2610EXPORT_SYMBOL_GPL(ata_pci_bmdma_init);
2509 2611
2510static int ata_resources_present(struct pci_dev *pdev, int port) 2612static int ata_resources_present(struct pci_dev *pdev, int port)
2511{ 2613{
@@ -2513,7 +2615,7 @@ static int ata_resources_present(struct pci_dev *pdev, int port)
2513 2615
2514 /* Check the PCI resources for this channel are enabled */ 2616 /* Check the PCI resources for this channel are enabled */
2515 port = port * 2; 2617 port = port * 2;
2516 for (i = 0; i < 2; i ++) { 2618 for (i = 0; i < 2; i++) {
2517 if (pci_resource_start(pdev, port + i) == 0 || 2619 if (pci_resource_start(pdev, port + i) == 0 ||
2518 pci_resource_len(pdev, port + i) == 0) 2620 pci_resource_len(pdev, port + i) == 0)
2519 return 0; 2621 return 0;
@@ -2598,6 +2700,7 @@ int ata_pci_sff_init_host(struct ata_host *host)
2598 2700
2599 return 0; 2701 return 0;
2600} 2702}
2703EXPORT_SYMBOL_GPL(ata_pci_sff_init_host);
2601 2704
2602/** 2705/**
2603 * ata_pci_sff_prepare_host - helper to prepare native PCI ATA host 2706 * ata_pci_sff_prepare_host - helper to prepare native PCI ATA host
@@ -2615,7 +2718,7 @@ int ata_pci_sff_init_host(struct ata_host *host)
2615 * 0 on success, -errno otherwise. 2718 * 0 on success, -errno otherwise.
2616 */ 2719 */
2617int ata_pci_sff_prepare_host(struct pci_dev *pdev, 2720int ata_pci_sff_prepare_host(struct pci_dev *pdev,
2618 const struct ata_port_info * const * ppi, 2721 const struct ata_port_info * const *ppi,
2619 struct ata_host **r_host) 2722 struct ata_host **r_host)
2620{ 2723{
2621 struct ata_host *host; 2724 struct ata_host *host;
@@ -2645,17 +2748,18 @@ int ata_pci_sff_prepare_host(struct pci_dev *pdev,
2645 *r_host = host; 2748 *r_host = host;
2646 return 0; 2749 return 0;
2647 2750
2648 err_bmdma: 2751err_bmdma:
2649 /* This is necessary because PCI and iomap resources are 2752 /* This is necessary because PCI and iomap resources are
2650 * merged and releasing the top group won't release the 2753 * merged and releasing the top group won't release the
2651 * acquired resources if some of those have been acquired 2754 * acquired resources if some of those have been acquired
2652 * before entering this function. 2755 * before entering this function.
2653 */ 2756 */
2654 pcim_iounmap_regions(pdev, 0xf); 2757 pcim_iounmap_regions(pdev, 0xf);
2655 err_out: 2758err_out:
2656 devres_release_group(&pdev->dev, NULL); 2759 devres_release_group(&pdev->dev, NULL);
2657 return rc; 2760 return rc;
2658} 2761}
2762EXPORT_SYMBOL_GPL(ata_pci_sff_prepare_host);
2659 2763
2660/** 2764/**
2661 * ata_pci_sff_activate_host - start SFF host, request IRQ and register it 2765 * ata_pci_sff_activate_host - start SFF host, request IRQ and register it
@@ -2741,7 +2845,7 @@ int ata_pci_sff_activate_host(struct ata_host *host,
2741 } 2845 }
2742 2846
2743 rc = ata_host_register(host, sht); 2847 rc = ata_host_register(host, sht);
2744 out: 2848out:
2745 if (rc == 0) 2849 if (rc == 0)
2746 devres_remove_group(dev, NULL); 2850 devres_remove_group(dev, NULL);
2747 else 2851 else
@@ -2749,6 +2853,7 @@ int ata_pci_sff_activate_host(struct ata_host *host,
2749 2853
2750 return rc; 2854 return rc;
2751} 2855}
2856EXPORT_SYMBOL_GPL(ata_pci_sff_activate_host);
2752 2857
2753/** 2858/**
2754 * ata_pci_sff_init_one - Initialize/register PCI IDE host controller 2859 * ata_pci_sff_init_one - Initialize/register PCI IDE host controller
@@ -2776,7 +2881,7 @@ int ata_pci_sff_activate_host(struct ata_host *host,
2776 * Zero on success, negative on errno-based value on error. 2881 * Zero on success, negative on errno-based value on error.
2777 */ 2882 */
2778int ata_pci_sff_init_one(struct pci_dev *pdev, 2883int ata_pci_sff_init_one(struct pci_dev *pdev,
2779 const struct ata_port_info * const * ppi, 2884 const struct ata_port_info * const *ppi,
2780 struct scsi_host_template *sht, void *host_priv) 2885 struct scsi_host_template *sht, void *host_priv)
2781{ 2886{
2782 struct device *dev = &pdev->dev; 2887 struct device *dev = &pdev->dev;
@@ -2815,7 +2920,7 @@ int ata_pci_sff_init_one(struct pci_dev *pdev,
2815 2920
2816 pci_set_master(pdev); 2921 pci_set_master(pdev);
2817 rc = ata_pci_sff_activate_host(host, ata_sff_interrupt, sht); 2922 rc = ata_pci_sff_activate_host(host, ata_sff_interrupt, sht);
2818 out: 2923out:
2819 if (rc == 0) 2924 if (rc == 0)
2820 devres_remove_group(&pdev->dev, NULL); 2925 devres_remove_group(&pdev->dev, NULL);
2821 else 2926 else
@@ -2823,54 +2928,7 @@ int ata_pci_sff_init_one(struct pci_dev *pdev,
2823 2928
2824 return rc; 2929 return rc;
2825} 2930}
2931EXPORT_SYMBOL_GPL(ata_pci_sff_init_one);
2826 2932
2827#endif /* CONFIG_PCI */ 2933#endif /* CONFIG_PCI */
2828 2934
2829EXPORT_SYMBOL_GPL(ata_sff_port_ops);
2830EXPORT_SYMBOL_GPL(ata_bmdma_port_ops);
2831EXPORT_SYMBOL_GPL(ata_sff_qc_prep);
2832EXPORT_SYMBOL_GPL(ata_sff_dumb_qc_prep);
2833EXPORT_SYMBOL_GPL(ata_sff_dev_select);
2834EXPORT_SYMBOL_GPL(ata_sff_check_status);
2835EXPORT_SYMBOL_GPL(ata_sff_dma_pause);
2836EXPORT_SYMBOL_GPL(ata_sff_pause);
2837EXPORT_SYMBOL_GPL(ata_sff_busy_sleep);
2838EXPORT_SYMBOL_GPL(ata_sff_wait_ready);
2839EXPORT_SYMBOL_GPL(ata_sff_tf_load);
2840EXPORT_SYMBOL_GPL(ata_sff_tf_read);
2841EXPORT_SYMBOL_GPL(ata_sff_exec_command);
2842EXPORT_SYMBOL_GPL(ata_sff_data_xfer);
2843EXPORT_SYMBOL_GPL(ata_sff_data_xfer_noirq);
2844EXPORT_SYMBOL_GPL(ata_sff_irq_on);
2845EXPORT_SYMBOL_GPL(ata_sff_irq_clear);
2846EXPORT_SYMBOL_GPL(ata_sff_hsm_move);
2847EXPORT_SYMBOL_GPL(ata_sff_qc_issue);
2848EXPORT_SYMBOL_GPL(ata_sff_qc_fill_rtf);
2849EXPORT_SYMBOL_GPL(ata_sff_host_intr);
2850EXPORT_SYMBOL_GPL(ata_sff_interrupt);
2851EXPORT_SYMBOL_GPL(ata_sff_freeze);
2852EXPORT_SYMBOL_GPL(ata_sff_thaw);
2853EXPORT_SYMBOL_GPL(ata_sff_prereset);
2854EXPORT_SYMBOL_GPL(ata_sff_dev_classify);
2855EXPORT_SYMBOL_GPL(ata_sff_wait_after_reset);
2856EXPORT_SYMBOL_GPL(ata_sff_softreset);
2857EXPORT_SYMBOL_GPL(sata_sff_hardreset);
2858EXPORT_SYMBOL_GPL(ata_sff_postreset);
2859EXPORT_SYMBOL_GPL(ata_sff_error_handler);
2860EXPORT_SYMBOL_GPL(ata_sff_post_internal_cmd);
2861EXPORT_SYMBOL_GPL(ata_sff_port_start);
2862EXPORT_SYMBOL_GPL(ata_sff_std_ports);
2863EXPORT_SYMBOL_GPL(ata_bmdma_mode_filter);
2864EXPORT_SYMBOL_GPL(ata_bmdma_setup);
2865EXPORT_SYMBOL_GPL(ata_bmdma_start);
2866EXPORT_SYMBOL_GPL(ata_bmdma_stop);
2867EXPORT_SYMBOL_GPL(ata_bmdma_status);
2868EXPORT_SYMBOL_GPL(ata_bus_reset);
2869#ifdef CONFIG_PCI
2870EXPORT_SYMBOL_GPL(ata_pci_bmdma_clear_simplex);
2871EXPORT_SYMBOL_GPL(ata_pci_bmdma_init);
2872EXPORT_SYMBOL_GPL(ata_pci_sff_init_host);
2873EXPORT_SYMBOL_GPL(ata_pci_sff_prepare_host);
2874EXPORT_SYMBOL_GPL(ata_pci_sff_activate_host);
2875EXPORT_SYMBOL_GPL(ata_pci_sff_init_one);
2876#endif /* CONFIG_PCI */
diff --git a/drivers/ata/pata_acpi.c b/drivers/ata/pata_acpi.c
index e2e332d8ff95..8b77a9802df1 100644
--- a/drivers/ata/pata_acpi.c
+++ b/drivers/ata/pata_acpi.c
@@ -13,12 +13,6 @@
13#include <linux/device.h> 13#include <linux/device.h>
14#include <scsi/scsi_host.h> 14#include <scsi/scsi_host.h>
15#include <acpi/acpi_bus.h> 15#include <acpi/acpi_bus.h>
16#include <acpi/acnames.h>
17#include <acpi/acnamesp.h>
18#include <acpi/acparser.h>
19#include <acpi/acexcep.h>
20#include <acpi/acmacros.h>
21#include <acpi/actypes.h>
22 16
23#include <linux/libata.h> 17#include <linux/libata.h>
24#include <linux/ata.h> 18#include <linux/ata.h>
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
index 73c466e452ca..eb99dbe78081 100644
--- a/drivers/ata/pata_ali.c
+++ b/drivers/ata/pata_ali.c
@@ -19,7 +19,9 @@
19 * 19 *
20 * TODO/CHECK 20 * TODO/CHECK
21 * Cannot have ATAPI on both master & slave for rev < c2 (???) but 21 * Cannot have ATAPI on both master & slave for rev < c2 (???) but
22 * otherwise should do atapi DMA. 22 * otherwise should do atapi DMA (For now for old we do PIO only for
23 * ATAPI)
24 * Review Sunblade workaround.
23 */ 25 */
24 26
25#include <linux/kernel.h> 27#include <linux/kernel.h>
@@ -33,12 +35,14 @@
33#include <linux/dmi.h> 35#include <linux/dmi.h>
34 36
35#define DRV_NAME "pata_ali" 37#define DRV_NAME "pata_ali"
36#define DRV_VERSION "0.7.5" 38#define DRV_VERSION "0.7.8"
37 39
38static int ali_atapi_dma = 0; 40static int ali_atapi_dma = 0;
39module_param_named(atapi_dma, ali_atapi_dma, int, 0644); 41module_param_named(atapi_dma, ali_atapi_dma, int, 0644);
40MODULE_PARM_DESC(atapi_dma, "Enable ATAPI DMA (0=disable, 1=enable)"); 42MODULE_PARM_DESC(atapi_dma, "Enable ATAPI DMA (0=disable, 1=enable)");
41 43
44static struct pci_dev *ali_isa_bridge;
45
42/* 46/*
43 * Cable special cases 47 * Cable special cases
44 */ 48 */
@@ -147,8 +151,7 @@ static void ali_fifo_control(struct ata_port *ap, struct ata_device *adev, int o
147 151
148 pci_read_config_byte(pdev, pio_fifo, &fifo); 152 pci_read_config_byte(pdev, pio_fifo, &fifo);
149 fifo &= ~(0x0F << shift); 153 fifo &= ~(0x0F << shift);
150 if (on) 154 fifo |= (on << shift);
151 fifo |= (on << shift);
152 pci_write_config_byte(pdev, pio_fifo, fifo); 155 pci_write_config_byte(pdev, pio_fifo, fifo);
153} 156}
154 157
@@ -337,6 +340,23 @@ static int ali_check_atapi_dma(struct ata_queued_cmd *qc)
337 return 0; 340 return 0;
338} 341}
339 342
343static void ali_c2_c3_postreset(struct ata_link *link, unsigned int *classes)
344{
345 u8 r;
346 int port_bit = 4 << link->ap->port_no;
347
348 /* If our bridge is an ALI 1533 then do the extra work */
349 if (ali_isa_bridge) {
350 /* Tristate and re-enable the bus signals */
351 pci_read_config_byte(ali_isa_bridge, 0x58, &r);
352 r &= ~port_bit;
353 pci_write_config_byte(ali_isa_bridge, 0x58, r);
354 r |= port_bit;
355 pci_write_config_byte(ali_isa_bridge, 0x58, r);
356 }
357 ata_sff_postreset(link, classes);
358}
359
340static struct scsi_host_template ali_sht = { 360static struct scsi_host_template ali_sht = {
341 ATA_BMDMA_SHT(DRV_NAME), 361 ATA_BMDMA_SHT(DRV_NAME),
342}; 362};
@@ -349,10 +369,11 @@ static struct ata_port_operations ali_early_port_ops = {
349 .inherits = &ata_sff_port_ops, 369 .inherits = &ata_sff_port_ops,
350 .cable_detect = ata_cable_40wire, 370 .cable_detect = ata_cable_40wire,
351 .set_piomode = ali_set_piomode, 371 .set_piomode = ali_set_piomode,
372 .sff_data_xfer = ata_sff_data_xfer32,
352}; 373};
353 374
354static const struct ata_port_operations ali_dma_base_ops = { 375static const struct ata_port_operations ali_dma_base_ops = {
355 .inherits = &ata_bmdma_port_ops, 376 .inherits = &ata_bmdma32_port_ops,
356 .set_piomode = ali_set_piomode, 377 .set_piomode = ali_set_piomode,
357 .set_dmamode = ali_set_dmamode, 378 .set_dmamode = ali_set_dmamode,
358}; 379};
@@ -377,6 +398,17 @@ static struct ata_port_operations ali_c2_port_ops = {
377 .check_atapi_dma = ali_check_atapi_dma, 398 .check_atapi_dma = ali_check_atapi_dma,
378 .cable_detect = ali_c2_cable_detect, 399 .cable_detect = ali_c2_cable_detect,
379 .dev_config = ali_lock_sectors, 400 .dev_config = ali_lock_sectors,
401 .postreset = ali_c2_c3_postreset,
402};
403
404/*
405 * Port operations for DMA capable ALi with cable detect
406 */
407static struct ata_port_operations ali_c4_port_ops = {
408 .inherits = &ali_dma_base_ops,
409 .check_atapi_dma = ali_check_atapi_dma,
410 .cable_detect = ali_c2_cable_detect,
411 .dev_config = ali_lock_sectors,
380}; 412};
381 413
382/* 414/*
@@ -401,52 +433,49 @@ static struct ata_port_operations ali_c5_port_ops = {
401static void ali_init_chipset(struct pci_dev *pdev) 433static void ali_init_chipset(struct pci_dev *pdev)
402{ 434{
403 u8 tmp; 435 u8 tmp;
404 struct pci_dev *north, *isa_bridge; 436 struct pci_dev *north;
405 437
406 /* 438 /*
407 * The chipset revision selects the driver operations and 439 * The chipset revision selects the driver operations and
408 * mode data. 440 * mode data.
409 */ 441 */
410 442
411 if (pdev->revision >= 0x20 && pdev->revision < 0xC2) { 443 if (pdev->revision <= 0x20) {
412 /* 1543-E/F, 1543C-C, 1543C-D, 1543C-E */ 444 pci_read_config_byte(pdev, 0x53, &tmp);
413 pci_read_config_byte(pdev, 0x4B, &tmp); 445 tmp |= 0x03;
414 /* Clear CD-ROM DMA write bit */ 446 pci_write_config_byte(pdev, 0x53, tmp);
415 tmp &= 0x7F; 447 } else {
416 pci_write_config_byte(pdev, 0x4B, tmp); 448 pci_read_config_byte(pdev, 0x4a, &tmp);
417 } else if (pdev->revision >= 0xC2) { 449 pci_write_config_byte(pdev, 0x4a, tmp | 0x20);
418 /* Enable cable detection logic */
419 pci_read_config_byte(pdev, 0x4B, &tmp); 450 pci_read_config_byte(pdev, 0x4B, &tmp);
420 pci_write_config_byte(pdev, 0x4B, tmp | 0x08); 451 if (pdev->revision < 0xC2)
421 } 452 /* 1543-E/F, 1543C-C, 1543C-D, 1543C-E */
422 north = pci_get_bus_and_slot(0, PCI_DEVFN(0,0)); 453 /* Clear CD-ROM DMA write bit */
423 isa_bridge = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); 454 tmp &= 0x7F;
424 455 /* Cable and UDMA */
425 if (north && north->vendor == PCI_VENDOR_ID_AL && isa_bridge) { 456 pci_write_config_byte(pdev, 0x4B, tmp | 0x09);
426 /* Configure the ALi bridge logic. For non ALi rely on BIOS.
427 Set the south bridge enable bit */
428 pci_read_config_byte(isa_bridge, 0x79, &tmp);
429 if (pdev->revision == 0xC2)
430 pci_write_config_byte(isa_bridge, 0x79, tmp | 0x04);
431 else if (pdev->revision > 0xC2 && pdev->revision < 0xC5)
432 pci_write_config_byte(isa_bridge, 0x79, tmp | 0x02);
433 }
434 if (pdev->revision >= 0x20) {
435 /* 457 /*
436 * CD_ROM DMA on (0x53 bit 0). Enable this even if we want 458 * CD_ROM DMA on (0x53 bit 0). Enable this even if we want
437 * to use PIO. 0x53 bit 1 (rev 20 only) - enable FIFO control 459 * to use PIO. 0x53 bit 1 (rev 20 only) - enable FIFO control
438 * via 0x54/55. 460 * via 0x54/55.
439 */ 461 */
440 pci_read_config_byte(pdev, 0x53, &tmp); 462 pci_read_config_byte(pdev, 0x53, &tmp);
441 if (pdev->revision <= 0x20)
442 tmp &= ~0x02;
443 if (pdev->revision >= 0xc7) 463 if (pdev->revision >= 0xc7)
444 tmp |= 0x03; 464 tmp |= 0x03;
445 else 465 else
446 tmp |= 0x01; /* CD_ROM enable for DMA */ 466 tmp |= 0x01; /* CD_ROM enable for DMA */
447 pci_write_config_byte(pdev, 0x53, tmp); 467 pci_write_config_byte(pdev, 0x53, tmp);
448 } 468 }
449 pci_dev_put(isa_bridge); 469 north = pci_get_bus_and_slot(0, PCI_DEVFN(0,0));
470 if (north && north->vendor == PCI_VENDOR_ID_AL && ali_isa_bridge) {
471 /* Configure the ALi bridge logic. For non ALi rely on BIOS.
472 Set the south bridge enable bit */
473 pci_read_config_byte(ali_isa_bridge, 0x79, &tmp);
474 if (pdev->revision == 0xC2)
475 pci_write_config_byte(ali_isa_bridge, 0x79, tmp | 0x04);
476 else if (pdev->revision > 0xC2 && pdev->revision < 0xC5)
477 pci_write_config_byte(ali_isa_bridge, 0x79, tmp | 0x02);
478 }
450 pci_dev_put(north); 479 pci_dev_put(north);
451 ata_pci_bmdma_clear_simplex(pdev); 480 ata_pci_bmdma_clear_simplex(pdev);
452} 481}
@@ -503,7 +532,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
503 .pio_mask = 0x1f, 532 .pio_mask = 0x1f,
504 .mwdma_mask = 0x07, 533 .mwdma_mask = 0x07,
505 .udma_mask = ATA_UDMA5, 534 .udma_mask = ATA_UDMA5,
506 .port_ops = &ali_c2_port_ops 535 .port_ops = &ali_c4_port_ops
507 }; 536 };
508 /* Revision 0xC5 is UDMA133 with LBA48 DMA */ 537 /* Revision 0xC5 is UDMA133 with LBA48 DMA */
509 static const struct ata_port_info info_c5 = { 538 static const struct ata_port_info info_c5 = {
@@ -516,7 +545,6 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
516 545
517 const struct ata_port_info *ppi[] = { NULL, NULL }; 546 const struct ata_port_info *ppi[] = { NULL, NULL };
518 u8 tmp; 547 u8 tmp;
519 struct pci_dev *isa_bridge;
520 int rc; 548 int rc;
521 549
522 rc = pcim_enable_device(pdev); 550 rc = pcim_enable_device(pdev);
@@ -543,14 +571,12 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
543 571
544 ali_init_chipset(pdev); 572 ali_init_chipset(pdev);
545 573
546 isa_bridge = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); 574 if (ali_isa_bridge && pdev->revision >= 0x20 && pdev->revision < 0xC2) {
547 if (isa_bridge && pdev->revision >= 0x20 && pdev->revision < 0xC2) {
548 /* Are we paired with a UDMA capable chip */ 575 /* Are we paired with a UDMA capable chip */
549 pci_read_config_byte(isa_bridge, 0x5E, &tmp); 576 pci_read_config_byte(ali_isa_bridge, 0x5E, &tmp);
550 if ((tmp & 0x1E) == 0x12) 577 if ((tmp & 0x1E) == 0x12)
551 ppi[0] = &info_20_udma; 578 ppi[0] = &info_20_udma;
552 } 579 }
553 pci_dev_put(isa_bridge);
554 580
555 return ata_pci_sff_init_one(pdev, ppi, &ali_sht, NULL); 581 return ata_pci_sff_init_one(pdev, ppi, &ali_sht, NULL);
556} 582}
@@ -590,13 +616,20 @@ static struct pci_driver ali_pci_driver = {
590 616
591static int __init ali_init(void) 617static int __init ali_init(void)
592{ 618{
593 return pci_register_driver(&ali_pci_driver); 619 int ret;
620 ali_isa_bridge = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL);
621
622 ret = pci_register_driver(&ali_pci_driver);
623 if (ret < 0)
624 pci_dev_put(ali_isa_bridge);
625 return ret;
594} 626}
595 627
596 628
597static void __exit ali_exit(void) 629static void __exit ali_exit(void)
598{ 630{
599 pci_unregister_driver(&ali_pci_driver); 631 pci_unregister_driver(&ali_pci_driver);
632 pci_dev_put(ali_isa_bridge);
600} 633}
601 634
602 635
diff --git a/drivers/ata/pata_amd.c b/drivers/ata/pata_amd.c
index 0ec9c7d9fe9d..63719ab9ea44 100644
--- a/drivers/ata/pata_amd.c
+++ b/drivers/ata/pata_amd.c
@@ -24,7 +24,7 @@
24#include <linux/libata.h> 24#include <linux/libata.h>
25 25
26#define DRV_NAME "pata_amd" 26#define DRV_NAME "pata_amd"
27#define DRV_VERSION "0.3.10" 27#define DRV_VERSION "0.3.11"
28 28
29/** 29/**
30 * timing_setup - shared timing computation and load 30 * timing_setup - shared timing computation and load
@@ -345,7 +345,7 @@ static struct scsi_host_template amd_sht = {
345}; 345};
346 346
347static const struct ata_port_operations amd_base_port_ops = { 347static const struct ata_port_operations amd_base_port_ops = {
348 .inherits = &ata_bmdma_port_ops, 348 .inherits = &ata_bmdma32_port_ops,
349 .prereset = amd_pre_reset, 349 .prereset = amd_pre_reset,
350}; 350};
351 351
diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c
index 0e2cde8f9973..506adde8ebb3 100644
--- a/drivers/ata/pata_atiixp.c
+++ b/drivers/ata/pata_atiixp.c
@@ -32,21 +32,6 @@ enum {
32 ATIIXP_IDE_UDMA_MODE = 0x56 32 ATIIXP_IDE_UDMA_MODE = 0x56
33}; 33};
34 34
35static int atiixp_pre_reset(struct ata_link *link, unsigned long deadline)
36{
37 struct ata_port *ap = link->ap;
38 static const struct pci_bits atiixp_enable_bits[] = {
39 { 0x48, 1, 0x01, 0x00 },
40 { 0x48, 1, 0x08, 0x00 }
41 };
42 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
43
44 if (!pci_test_config_bits(pdev, &atiixp_enable_bits[ap->port_no]))
45 return -ENOENT;
46
47 return ata_sff_prereset(link, deadline);
48}
49
50static int atiixp_cable_detect(struct ata_port *ap) 35static int atiixp_cable_detect(struct ata_port *ap)
51{ 36{
52 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 37 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
@@ -229,10 +214,9 @@ static struct ata_port_operations atiixp_port_ops = {
229 .cable_detect = atiixp_cable_detect, 214 .cable_detect = atiixp_cable_detect,
230 .set_piomode = atiixp_set_piomode, 215 .set_piomode = atiixp_set_piomode,
231 .set_dmamode = atiixp_set_dmamode, 216 .set_dmamode = atiixp_set_dmamode,
232 .prereset = atiixp_pre_reset,
233}; 217};
234 218
235static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) 219static int atiixp_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
236{ 220{
237 static const struct ata_port_info info = { 221 static const struct ata_port_info info = {
238 .flags = ATA_FLAG_SLAVE_POSS, 222 .flags = ATA_FLAG_SLAVE_POSS,
@@ -241,8 +225,18 @@ static int atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id)
241 .udma_mask = 0x3F, 225 .udma_mask = 0x3F,
242 .port_ops = &atiixp_port_ops 226 .port_ops = &atiixp_port_ops
243 }; 227 };
244 const struct ata_port_info *ppi[] = { &info, NULL }; 228 static const struct pci_bits atiixp_enable_bits[] = {
245 return ata_pci_sff_init_one(dev, ppi, &atiixp_sht, NULL); 229 { 0x48, 1, 0x01, 0x00 },
230 { 0x48, 1, 0x08, 0x00 }
231 };
232 const struct ata_port_info *ppi[] = { &info, &info };
233 int i;
234
235 for (i = 0; i < 2; i++)
236 if (!pci_test_config_bits(pdev, &atiixp_enable_bits[i]))
237 ppi[i] = &ata_dummy_port_info;
238
239 return ata_pci_sff_init_one(pdev, ppi, &atiixp_sht, NULL);
246} 240}
247 241
248static const struct pci_device_id atiixp[] = { 242static const struct pci_device_id atiixp[] = {
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c
index e0c4f05d7d57..65c28e5a6cd7 100644
--- a/drivers/ata/pata_hpt366.c
+++ b/drivers/ata/pata_hpt366.c
@@ -30,7 +30,7 @@
30#define DRV_VERSION "0.6.2" 30#define DRV_VERSION "0.6.2"
31 31
32struct hpt_clock { 32struct hpt_clock {
33 u8 xfer_speed; 33 u8 xfer_mode;
34 u32 timing; 34 u32 timing;
35}; 35};
36 36
@@ -189,28 +189,6 @@ static unsigned long hpt366_filter(struct ata_device *adev, unsigned long mask)
189 return ata_bmdma_mode_filter(adev, mask); 189 return ata_bmdma_mode_filter(adev, mask);
190} 190}
191 191
192/**
193 * hpt36x_find_mode - reset the hpt36x bus
194 * @ap: ATA port
195 * @speed: transfer mode
196 *
197 * Return the 32bit register programming information for this channel
198 * that matches the speed provided.
199 */
200
201static u32 hpt36x_find_mode(struct ata_port *ap, int speed)
202{
203 struct hpt_clock *clocks = ap->host->private_data;
204
205 while(clocks->xfer_speed) {
206 if (clocks->xfer_speed == speed)
207 return clocks->timing;
208 clocks++;
209 }
210 BUG();
211 return 0xffffffffU; /* silence compiler warning */
212}
213
214static int hpt36x_cable_detect(struct ata_port *ap) 192static int hpt36x_cable_detect(struct ata_port *ap)
215{ 193{
216 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 194 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
@@ -226,25 +204,16 @@ static int hpt36x_cable_detect(struct ata_port *ap)
226 return ATA_CBL_PATA80; 204 return ATA_CBL_PATA80;
227} 205}
228 206
229/** 207static void hpt366_set_mode(struct ata_port *ap, struct ata_device *adev,
230 * hpt366_set_piomode - PIO setup 208 u8 mode)
231 * @ap: ATA interface
232 * @adev: device on the interface
233 *
234 * Perform PIO mode setup.
235 */
236
237static void hpt366_set_piomode(struct ata_port *ap, struct ata_device *adev)
238{ 209{
210 struct hpt_clock *clocks = ap->host->private_data;
239 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 211 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
240 u32 addr1, addr2; 212 u32 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
241 u32 reg; 213 u32 addr2 = 0x51 + 4 * ap->port_no;
242 u32 mode; 214 u32 mask, reg;
243 u8 fast; 215 u8 fast;
244 216
245 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
246 addr2 = 0x51 + 4 * ap->port_no;
247
248 /* Fast interrupt prediction disable, hold off interrupt disable */ 217 /* Fast interrupt prediction disable, hold off interrupt disable */
249 pci_read_config_byte(pdev, addr2, &fast); 218 pci_read_config_byte(pdev, addr2, &fast);
250 if (fast & 0x80) { 219 if (fast & 0x80) {
@@ -252,12 +221,43 @@ static void hpt366_set_piomode(struct ata_port *ap, struct ata_device *adev)
252 pci_write_config_byte(pdev, addr2, fast); 221 pci_write_config_byte(pdev, addr2, fast);
253 } 222 }
254 223
224 /* determine timing mask and find matching clock entry */
225 if (mode < XFER_MW_DMA_0)
226 mask = 0xc1f8ffff;
227 else if (mode < XFER_UDMA_0)
228 mask = 0x303800ff;
229 else
230 mask = 0x30070000;
231
232 while (clocks->xfer_mode) {
233 if (clocks->xfer_mode == mode)
234 break;
235 clocks++;
236 }
237 if (!clocks->xfer_mode)
238 BUG();
239
240 /*
241 * Combine new mode bits with old config bits and disable
242 * on-chip PIO FIFO/buffer (and PIO MST mode as well) to avoid
243 * problems handling I/O errors later.
244 */
255 pci_read_config_dword(pdev, addr1, &reg); 245 pci_read_config_dword(pdev, addr1, &reg);
256 mode = hpt36x_find_mode(ap, adev->pio_mode); 246 reg = ((reg & ~mask) | (clocks->timing & mask)) & ~0xc0000000;
257 mode &= ~0x8000000; /* No FIFO in PIO */ 247 pci_write_config_dword(pdev, addr1, reg);
258 mode &= ~0x30070000; /* Leave config bits alone */ 248}
259 reg &= 0x30070000; /* Strip timing bits */ 249
260 pci_write_config_dword(pdev, addr1, reg | mode); 250/**
251 * hpt366_set_piomode - PIO setup
252 * @ap: ATA interface
253 * @adev: device on the interface
254 *
255 * Perform PIO mode setup.
256 */
257
258static void hpt366_set_piomode(struct ata_port *ap, struct ata_device *adev)
259{
260 hpt366_set_mode(ap, adev, adev->pio_mode);
261} 261}
262 262
263/** 263/**
@@ -271,28 +271,7 @@ static void hpt366_set_piomode(struct ata_port *ap, struct ata_device *adev)
271 271
272static void hpt366_set_dmamode(struct ata_port *ap, struct ata_device *adev) 272static void hpt366_set_dmamode(struct ata_port *ap, struct ata_device *adev)
273{ 273{
274 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 274 hpt366_set_mode(ap, adev, adev->dma_mode);
275 u32 addr1, addr2;
276 u32 reg;
277 u32 mode;
278 u8 fast;
279
280 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
281 addr2 = 0x51 + 4 * ap->port_no;
282
283 /* Fast interrupt prediction disable, hold off interrupt disable */
284 pci_read_config_byte(pdev, addr2, &fast);
285 if (fast & 0x80) {
286 fast &= ~0x80;
287 pci_write_config_byte(pdev, addr2, fast);
288 }
289
290 pci_read_config_dword(pdev, addr1, &reg);
291 mode = hpt36x_find_mode(ap, adev->dma_mode);
292 mode |= 0x8000000; /* FIFO in MWDMA or UDMA */
293 mode &= ~0xC0000000; /* Leave config bits alone */
294 reg &= 0xC0000000; /* Strip timing bits */
295 pci_write_config_dword(pdev, addr1, reg | mode);
296} 275}
297 276
298static struct scsi_host_template hpt36x_sht = { 277static struct scsi_host_template hpt36x_sht = {
diff --git a/drivers/ata/pata_hpt3x3.c b/drivers/ata/pata_hpt3x3.c
index f11a320337c0..f19cc645881a 100644
--- a/drivers/ata/pata_hpt3x3.c
+++ b/drivers/ata/pata_hpt3x3.c
@@ -23,7 +23,7 @@
23#include <linux/libata.h> 23#include <linux/libata.h>
24 24
25#define DRV_NAME "pata_hpt3x3" 25#define DRV_NAME "pata_hpt3x3"
26#define DRV_VERSION "0.5.3" 26#define DRV_VERSION "0.6.1"
27 27
28/** 28/**
29 * hpt3x3_set_piomode - PIO setup 29 * hpt3x3_set_piomode - PIO setup
@@ -80,14 +80,48 @@ static void hpt3x3_set_dmamode(struct ata_port *ap, struct ata_device *adev)
80 r2 &= ~(0x11 << dn); /* Clear MWDMA and UDMA bits */ 80 r2 &= ~(0x11 << dn); /* Clear MWDMA and UDMA bits */
81 81
82 if (adev->dma_mode >= XFER_UDMA_0) 82 if (adev->dma_mode >= XFER_UDMA_0)
83 r2 |= (0x10 << dn); /* Ultra mode */ 83 r2 |= (0x01 << dn); /* Ultra mode */
84 else 84 else
85 r2 |= (0x01 << dn); /* MWDMA */ 85 r2 |= (0x10 << dn); /* MWDMA */
86 86
87 pci_write_config_dword(pdev, 0x44, r1); 87 pci_write_config_dword(pdev, 0x44, r1);
88 pci_write_config_dword(pdev, 0x48, r2); 88 pci_write_config_dword(pdev, 0x48, r2);
89} 89}
90#endif /* CONFIG_PATA_HPT3X3_DMA */ 90
91/**
92 * hpt3x3_freeze - DMA workaround
93 * @ap: port to freeze
94 *
95 * When freezing an HPT3x3 we must stop any pending DMA before
96 * writing to the control register or the chip will hang
97 */
98
99static void hpt3x3_freeze(struct ata_port *ap)
100{
101 void __iomem *mmio = ap->ioaddr.bmdma_addr;
102
103 iowrite8(ioread8(mmio + ATA_DMA_CMD) & ~ ATA_DMA_START,
104 mmio + ATA_DMA_CMD);
105 ata_sff_dma_pause(ap);
106 ata_sff_freeze(ap);
107}
108
109/**
110 * hpt3x3_bmdma_setup - DMA workaround
111 * @qc: Queued command
112 *
113 * When issuing BMDMA we must clean up the error/active bits in
114 * software on this device
115 */
116
117static void hpt3x3_bmdma_setup(struct ata_queued_cmd *qc)
118{
119 struct ata_port *ap = qc->ap;
120 u8 r = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
121 r |= ATA_DMA_INTR | ATA_DMA_ERR;
122 iowrite8(r, ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
123 return ata_bmdma_setup(qc);
124}
91 125
92/** 126/**
93 * hpt3x3_atapi_dma - ATAPI DMA check 127 * hpt3x3_atapi_dma - ATAPI DMA check
@@ -101,18 +135,23 @@ static int hpt3x3_atapi_dma(struct ata_queued_cmd *qc)
101 return 1; 135 return 1;
102} 136}
103 137
138#endif /* CONFIG_PATA_HPT3X3_DMA */
139
104static struct scsi_host_template hpt3x3_sht = { 140static struct scsi_host_template hpt3x3_sht = {
105 ATA_BMDMA_SHT(DRV_NAME), 141 ATA_BMDMA_SHT(DRV_NAME),
106}; 142};
107 143
108static struct ata_port_operations hpt3x3_port_ops = { 144static struct ata_port_operations hpt3x3_port_ops = {
109 .inherits = &ata_bmdma_port_ops, 145 .inherits = &ata_bmdma_port_ops,
110 .check_atapi_dma= hpt3x3_atapi_dma,
111 .cable_detect = ata_cable_40wire, 146 .cable_detect = ata_cable_40wire,
112 .set_piomode = hpt3x3_set_piomode, 147 .set_piomode = hpt3x3_set_piomode,
113#if defined(CONFIG_PATA_HPT3X3_DMA) 148#if defined(CONFIG_PATA_HPT3X3_DMA)
114 .set_dmamode = hpt3x3_set_dmamode, 149 .set_dmamode = hpt3x3_set_dmamode,
150 .bmdma_setup = hpt3x3_bmdma_setup,
151 .check_atapi_dma= hpt3x3_atapi_dma,
152 .freeze = hpt3x3_freeze,
115#endif 153#endif
154
116}; 155};
117 156
118/** 157/**
diff --git a/drivers/ata/pata_it821x.c b/drivers/ata/pata_it821x.c
index f828a29d7756..f1bb2f9fecbf 100644
--- a/drivers/ata/pata_it821x.c
+++ b/drivers/ata/pata_it821x.c
@@ -80,7 +80,7 @@
80 80
81 81
82#define DRV_NAME "pata_it821x" 82#define DRV_NAME "pata_it821x"
83#define DRV_VERSION "0.4.0" 83#define DRV_VERSION "0.4.2"
84 84
85struct it821x_dev 85struct it821x_dev
86{ 86{
@@ -494,8 +494,6 @@ static int it821x_smart_set_mode(struct ata_link *link, struct ata_device **unus
494 * special. In our case we need to lock the sector count to avoid 494 * special. In our case we need to lock the sector count to avoid
495 * blowing the brains out of the firmware with large LBA48 requests 495 * blowing the brains out of the firmware with large LBA48 requests
496 * 496 *
497 * FIXME: When FUA appears we need to block FUA too. And SMART and
498 * basically we need to filter commands for this chip.
499 */ 497 */
500 498
501static void it821x_dev_config(struct ata_device *adev) 499static void it821x_dev_config(struct ata_device *adev)
@@ -890,6 +888,13 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
890 .flags = ATA_FLAG_SLAVE_POSS, 888 .flags = ATA_FLAG_SLAVE_POSS,
891 .pio_mask = 0x1f, 889 .pio_mask = 0x1f,
892 .mwdma_mask = 0x07, 890 .mwdma_mask = 0x07,
891 .udma_mask = ATA_UDMA6,
892 .port_ops = &it821x_rdc_port_ops
893 };
894 static const struct ata_port_info info_rdc_11 = {
895 .flags = ATA_FLAG_SLAVE_POSS,
896 .pio_mask = 0x1f,
897 .mwdma_mask = 0x07,
893 /* No UDMA */ 898 /* No UDMA */
894 .port_ops = &it821x_rdc_port_ops 899 .port_ops = &it821x_rdc_port_ops
895 }; 900 };
@@ -903,7 +908,11 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
903 return rc; 908 return rc;
904 909
905 if (pdev->vendor == PCI_VENDOR_ID_RDC) { 910 if (pdev->vendor == PCI_VENDOR_ID_RDC) {
906 ppi[0] = &info_rdc; 911 /* Deal with Vortex86SX */
912 if (pdev->revision == 0x11)
913 ppi[0] = &info_rdc_11;
914 else
915 ppi[0] = &info_rdc;
907 } else { 916 } else {
908 /* Force the card into bypass mode if so requested */ 917 /* Force the card into bypass mode if so requested */
909 if (it8212_noraid) { 918 if (it8212_noraid) {
diff --git a/drivers/ata/pata_mpiix.c b/drivers/ata/pata_mpiix.c
index 7c8faa48b5f3..aa576cac4d17 100644
--- a/drivers/ata/pata_mpiix.c
+++ b/drivers/ata/pata_mpiix.c
@@ -35,7 +35,7 @@
35#include <linux/libata.h> 35#include <linux/libata.h>
36 36
37#define DRV_NAME "pata_mpiix" 37#define DRV_NAME "pata_mpiix"
38#define DRV_VERSION "0.7.6" 38#define DRV_VERSION "0.7.7"
39 39
40enum { 40enum {
41 IDETIM = 0x6C, /* IDE control register */ 41 IDETIM = 0x6C, /* IDE control register */
@@ -146,6 +146,7 @@ static struct ata_port_operations mpiix_port_ops = {
146 .cable_detect = ata_cable_40wire, 146 .cable_detect = ata_cable_40wire,
147 .set_piomode = mpiix_set_piomode, 147 .set_piomode = mpiix_set_piomode,
148 .prereset = mpiix_pre_reset, 148 .prereset = mpiix_pre_reset,
149 .sff_data_xfer = ata_sff_data_xfer32,
149}; 150};
150 151
151static int mpiix_init_one(struct pci_dev *dev, const struct pci_device_id *id) 152static int mpiix_init_one(struct pci_dev *dev, const struct pci_device_id *id)
diff --git a/drivers/ata/pata_octeon_cf.c b/drivers/ata/pata_octeon_cf.c
new file mode 100644
index 000000000000..0fe4ef309c62
--- /dev/null
+++ b/drivers/ata/pata_octeon_cf.c
@@ -0,0 +1,965 @@
1/*
2 * Driver for the Octeon bootbus compact flash.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2005 - 2009 Cavium Networks
9 * Copyright (C) 2008 Wind River Systems
10 */
11
12#include <linux/kernel.h>
13#include <linux/module.h>
14#include <linux/libata.h>
15#include <linux/irq.h>
16#include <linux/platform_device.h>
17#include <linux/workqueue.h>
18#include <scsi/scsi_host.h>
19
20#include <asm/octeon/octeon.h>
21
22/*
23 * The Octeon bootbus compact flash interface is connected in at least
24 * 3 different configurations on various evaluation boards:
25 *
26 * -- 8 bits no irq, no DMA
27 * -- 16 bits no irq, no DMA
28 * -- 16 bits True IDE mode with DMA, but no irq.
29 *
30 * In the last case the DMA engine can generate an interrupt when the
31 * transfer is complete. For the first two cases only PIO is supported.
32 *
33 */
34
35#define DRV_NAME "pata_octeon_cf"
36#define DRV_VERSION "2.1"
37
38
39struct octeon_cf_port {
40 struct workqueue_struct *wq;
41 struct delayed_work delayed_finish;
42 struct ata_port *ap;
43 int dma_finished;
44};
45
46static struct scsi_host_template octeon_cf_sht = {
47 ATA_PIO_SHT(DRV_NAME),
48};
49
50/**
51 * Convert nanosecond based time to setting used in the
52 * boot bus timing register, based on timing multiple
53 */
54static unsigned int ns_to_tim_reg(unsigned int tim_mult, unsigned int nsecs)
55{
56 unsigned int val;
57
58 /*
59 * Compute # of eclock periods to get desired duration in
60 * nanoseconds.
61 */
62 val = DIV_ROUND_UP(nsecs * (octeon_get_clock_rate() / 1000000),
63 1000 * tim_mult);
64
65 return val;
66}
67
68static void octeon_cf_set_boot_reg_cfg(int cs)
69{
70 union cvmx_mio_boot_reg_cfgx reg_cfg;
71 reg_cfg.u64 = cvmx_read_csr(CVMX_MIO_BOOT_REG_CFGX(cs));
72 reg_cfg.s.dmack = 0; /* Don't assert DMACK on access */
73 reg_cfg.s.tim_mult = 2; /* Timing mutiplier 2x */
74 reg_cfg.s.rd_dly = 0; /* Sample on falling edge of BOOT_OE */
75 reg_cfg.s.sam = 0; /* Don't combine write and output enable */
76 reg_cfg.s.we_ext = 0; /* No write enable extension */
77 reg_cfg.s.oe_ext = 0; /* No read enable extension */
78 reg_cfg.s.en = 1; /* Enable this region */
79 reg_cfg.s.orbit = 0; /* Don't combine with previous region */
80 reg_cfg.s.ale = 0; /* Don't do address multiplexing */
81 cvmx_write_csr(CVMX_MIO_BOOT_REG_CFGX(cs), reg_cfg.u64);
82}
83
84/**
85 * Called after libata determines the needed PIO mode. This
86 * function programs the Octeon bootbus regions to support the
87 * timing requirements of the PIO mode.
88 *
89 * @ap: ATA port information
90 * @dev: ATA device
91 */
92static void octeon_cf_set_piomode(struct ata_port *ap, struct ata_device *dev)
93{
94 struct octeon_cf_data *ocd = ap->dev->platform_data;
95 union cvmx_mio_boot_reg_timx reg_tim;
96 int cs = ocd->base_region;
97 int T;
98 struct ata_timing timing;
99
100 int use_iordy;
101 int trh;
102 int pause;
103 /* These names are timing parameters from the ATA spec */
104 int t1;
105 int t2;
106 int t2i;
107
108 T = (int)(2000000000000LL / octeon_get_clock_rate());
109
110 if (ata_timing_compute(dev, dev->pio_mode, &timing, T, T))
111 BUG();
112
113 t1 = timing.setup;
114 if (t1)
115 t1--;
116 t2 = timing.active;
117 if (t2)
118 t2--;
119 t2i = timing.act8b;
120 if (t2i)
121 t2i--;
122
123 trh = ns_to_tim_reg(2, 20);
124 if (trh)
125 trh--;
126
127 pause = timing.cycle - timing.active - timing.setup - trh;
128 if (pause)
129 pause--;
130
131 octeon_cf_set_boot_reg_cfg(cs);
132 if (ocd->dma_engine >= 0)
133 /* True IDE mode, program both chip selects. */
134 octeon_cf_set_boot_reg_cfg(cs + 1);
135
136
137 use_iordy = ata_pio_need_iordy(dev);
138
139 reg_tim.u64 = cvmx_read_csr(CVMX_MIO_BOOT_REG_TIMX(cs));
140 /* Disable page mode */
141 reg_tim.s.pagem = 0;
142 /* Enable dynamic timing */
143 reg_tim.s.waitm = use_iordy;
144 /* Pages are disabled */
145 reg_tim.s.pages = 0;
146 /* We don't use multiplexed address mode */
147 reg_tim.s.ale = 0;
148 /* Not used */
149 reg_tim.s.page = 0;
150 /* Time after IORDY to coninue to assert the data */
151 reg_tim.s.wait = 0;
152 /* Time to wait to complete the cycle. */
153 reg_tim.s.pause = pause;
154 /* How long to hold after a write to de-assert CE. */
155 reg_tim.s.wr_hld = trh;
156 /* How long to wait after a read to de-assert CE. */
157 reg_tim.s.rd_hld = trh;
158 /* How long write enable is asserted */
159 reg_tim.s.we = t2;
160 /* How long read enable is asserted */
161 reg_tim.s.oe = t2;
162 /* Time after CE that read/write starts */
163 reg_tim.s.ce = ns_to_tim_reg(2, 5);
164 /* Time before CE that address is valid */
165 reg_tim.s.adr = 0;
166
167 /* Program the bootbus region timing for the data port chip select. */
168 cvmx_write_csr(CVMX_MIO_BOOT_REG_TIMX(cs), reg_tim.u64);
169 if (ocd->dma_engine >= 0)
170 /* True IDE mode, program both chip selects. */
171 cvmx_write_csr(CVMX_MIO_BOOT_REG_TIMX(cs + 1), reg_tim.u64);
172}
173
174static void octeon_cf_set_dmamode(struct ata_port *ap, struct ata_device *dev)
175{
176 struct octeon_cf_data *ocd = dev->link->ap->dev->platform_data;
177 union cvmx_mio_boot_dma_timx dma_tim;
178 unsigned int oe_a;
179 unsigned int oe_n;
180 unsigned int dma_ackh;
181 unsigned int dma_arq;
182 unsigned int pause;
183 unsigned int T0, Tkr, Td;
184 unsigned int tim_mult;
185
186 const struct ata_timing *timing;
187
188 timing = ata_timing_find_mode(dev->dma_mode);
189 T0 = timing->cycle;
190 Td = timing->active;
191 Tkr = timing->recover;
192 dma_ackh = timing->dmack_hold;
193
194 dma_tim.u64 = 0;
195 /* dma_tim.s.tim_mult = 0 --> 4x */
196 tim_mult = 4;
197
198 /* not spec'ed, value in eclocks, not affected by tim_mult */
199 dma_arq = 8;
200 pause = 25 - dma_arq * 1000 /
201 (octeon_get_clock_rate() / 1000000); /* Tz */
202
203 oe_a = Td;
204 /* Tkr from cf spec, lengthened to meet T0 */
205 oe_n = max(T0 - oe_a, Tkr);
206
207 dma_tim.s.dmack_pi = 1;
208
209 dma_tim.s.oe_n = ns_to_tim_reg(tim_mult, oe_n);
210 dma_tim.s.oe_a = ns_to_tim_reg(tim_mult, oe_a);
211
212 /*
213 * This is tI, C.F. spec. says 0, but Sony CF card requires
214 * more, we use 20 nS.
215 */
216 dma_tim.s.dmack_s = ns_to_tim_reg(tim_mult, 20);;
217 dma_tim.s.dmack_h = ns_to_tim_reg(tim_mult, dma_ackh);
218
219 dma_tim.s.dmarq = dma_arq;
220 dma_tim.s.pause = ns_to_tim_reg(tim_mult, pause);
221
222 dma_tim.s.rd_dly = 0; /* Sample right on edge */
223
224 /* writes only */
225 dma_tim.s.we_n = ns_to_tim_reg(tim_mult, oe_n);
226 dma_tim.s.we_a = ns_to_tim_reg(tim_mult, oe_a);
227
228 pr_debug("ns to ticks (mult %d) of %d is: %d\n", tim_mult, 60,
229 ns_to_tim_reg(tim_mult, 60));
230 pr_debug("oe_n: %d, oe_a: %d, dmack_s: %d, dmack_h: "
231 "%d, dmarq: %d, pause: %d\n",
232 dma_tim.s.oe_n, dma_tim.s.oe_a, dma_tim.s.dmack_s,
233 dma_tim.s.dmack_h, dma_tim.s.dmarq, dma_tim.s.pause);
234
235 cvmx_write_csr(CVMX_MIO_BOOT_DMA_TIMX(ocd->dma_engine),
236 dma_tim.u64);
237
238}
239
240/**
241 * Handle an 8 bit I/O request.
242 *
243 * @dev: Device to access
244 * @buffer: Data buffer
245 * @buflen: Length of the buffer.
246 * @rw: True to write.
247 */
248static unsigned int octeon_cf_data_xfer8(struct ata_device *dev,
249 unsigned char *buffer,
250 unsigned int buflen,
251 int rw)
252{
253 struct ata_port *ap = dev->link->ap;
254 void __iomem *data_addr = ap->ioaddr.data_addr;
255 unsigned long words;
256 int count;
257
258 words = buflen;
259 if (rw) {
260 count = 16;
261 while (words--) {
262 iowrite8(*buffer, data_addr);
263 buffer++;
264 /*
265 * Every 16 writes do a read so the bootbus
266 * FIFO doesn't fill up.
267 */
268 if (--count == 0) {
269 ioread8(ap->ioaddr.altstatus_addr);
270 count = 16;
271 }
272 }
273 } else {
274 ioread8_rep(data_addr, buffer, words);
275 }
276 return buflen;
277}
278
279/**
280 * Handle a 16 bit I/O request.
281 *
282 * @dev: Device to access
283 * @buffer: Data buffer
284 * @buflen: Length of the buffer.
285 * @rw: True to write.
286 */
287static unsigned int octeon_cf_data_xfer16(struct ata_device *dev,
288 unsigned char *buffer,
289 unsigned int buflen,
290 int rw)
291{
292 struct ata_port *ap = dev->link->ap;
293 void __iomem *data_addr = ap->ioaddr.data_addr;
294 unsigned long words;
295 int count;
296
297 words = buflen / 2;
298 if (rw) {
299 count = 16;
300 while (words--) {
301 iowrite16(*(uint16_t *)buffer, data_addr);
302 buffer += sizeof(uint16_t);
303 /*
304 * Every 16 writes do a read so the bootbus
305 * FIFO doesn't fill up.
306 */
307 if (--count == 0) {
308 ioread8(ap->ioaddr.altstatus_addr);
309 count = 16;
310 }
311 }
312 } else {
313 while (words--) {
314 *(uint16_t *)buffer = ioread16(data_addr);
315 buffer += sizeof(uint16_t);
316 }
317 }
318 /* Transfer trailing 1 byte, if any. */
319 if (unlikely(buflen & 0x01)) {
320 __le16 align_buf[1] = { 0 };
321
322 if (rw == READ) {
323 align_buf[0] = cpu_to_le16(ioread16(data_addr));
324 memcpy(buffer, align_buf, 1);
325 } else {
326 memcpy(align_buf, buffer, 1);
327 iowrite16(le16_to_cpu(align_buf[0]), data_addr);
328 }
329 words++;
330 }
331 return buflen;
332}
333
334/**
335 * Read the taskfile for 16bit non-True IDE only.
336 */
337static void octeon_cf_tf_read16(struct ata_port *ap, struct ata_taskfile *tf)
338{
339 u16 blob;
340 /* The base of the registers is at ioaddr.data_addr. */
341 void __iomem *base = ap->ioaddr.data_addr;
342
343 blob = __raw_readw(base + 0xc);
344 tf->feature = blob >> 8;
345
346 blob = __raw_readw(base + 2);
347 tf->nsect = blob & 0xff;
348 tf->lbal = blob >> 8;
349
350 blob = __raw_readw(base + 4);
351 tf->lbam = blob & 0xff;
352 tf->lbah = blob >> 8;
353
354 blob = __raw_readw(base + 6);
355 tf->device = blob & 0xff;
356 tf->command = blob >> 8;
357
358 if (tf->flags & ATA_TFLAG_LBA48) {
359 if (likely(ap->ioaddr.ctl_addr)) {
360 iowrite8(tf->ctl | ATA_HOB, ap->ioaddr.ctl_addr);
361
362 blob = __raw_readw(base + 0xc);
363 tf->hob_feature = blob >> 8;
364
365 blob = __raw_readw(base + 2);
366 tf->hob_nsect = blob & 0xff;
367 tf->hob_lbal = blob >> 8;
368
369 blob = __raw_readw(base + 4);
370 tf->hob_lbam = blob & 0xff;
371 tf->hob_lbah = blob >> 8;
372
373 iowrite8(tf->ctl, ap->ioaddr.ctl_addr);
374 ap->last_ctl = tf->ctl;
375 } else {
376 WARN_ON(1);
377 }
378 }
379}
380
381static u8 octeon_cf_check_status16(struct ata_port *ap)
382{
383 u16 blob;
384 void __iomem *base = ap->ioaddr.data_addr;
385
386 blob = __raw_readw(base + 6);
387 return blob >> 8;
388}
389
390static int octeon_cf_softreset16(struct ata_link *link, unsigned int *classes,
391 unsigned long deadline)
392{
393 struct ata_port *ap = link->ap;
394 void __iomem *base = ap->ioaddr.data_addr;
395 int rc;
396 u8 err;
397
398 DPRINTK("about to softreset\n");
399 __raw_writew(ap->ctl, base + 0xe);
400 udelay(20);
401 __raw_writew(ap->ctl | ATA_SRST, base + 0xe);
402 udelay(20);
403 __raw_writew(ap->ctl, base + 0xe);
404
405 rc = ata_sff_wait_after_reset(link, 1, deadline);
406 if (rc) {
407 ata_link_printk(link, KERN_ERR, "SRST failed (errno=%d)\n", rc);
408 return rc;
409 }
410
411 /* determine by signature whether we have ATA or ATAPI devices */
412 classes[0] = ata_sff_dev_classify(&link->device[0], 1, &err);
413 DPRINTK("EXIT, classes[0]=%u [1]=%u\n", classes[0], classes[1]);
414 return 0;
415}
416
417/**
418 * Load the taskfile for 16bit non-True IDE only. The device_addr is
419 * not loaded, we do this as part of octeon_cf_exec_command16.
420 */
421static void octeon_cf_tf_load16(struct ata_port *ap,
422 const struct ata_taskfile *tf)
423{
424 unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR;
425 /* The base of the registers is at ioaddr.data_addr. */
426 void __iomem *base = ap->ioaddr.data_addr;
427
428 if (tf->ctl != ap->last_ctl) {
429 iowrite8(tf->ctl, ap->ioaddr.ctl_addr);
430 ap->last_ctl = tf->ctl;
431 ata_wait_idle(ap);
432 }
433 if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) {
434 __raw_writew(tf->hob_feature << 8, base + 0xc);
435 __raw_writew(tf->hob_nsect | tf->hob_lbal << 8, base + 2);
436 __raw_writew(tf->hob_lbam | tf->hob_lbah << 8, base + 4);
437 VPRINTK("hob: feat 0x%X nsect 0x%X, lba 0x%X 0x%X 0x%X\n",
438 tf->hob_feature,
439 tf->hob_nsect,
440 tf->hob_lbal,
441 tf->hob_lbam,
442 tf->hob_lbah);
443 }
444 if (is_addr) {
445 __raw_writew(tf->feature << 8, base + 0xc);
446 __raw_writew(tf->nsect | tf->lbal << 8, base + 2);
447 __raw_writew(tf->lbam | tf->lbah << 8, base + 4);
448 VPRINTK("feat 0x%X nsect 0x%X, lba 0x%X 0x%X 0x%X\n",
449 tf->feature,
450 tf->nsect,
451 tf->lbal,
452 tf->lbam,
453 tf->lbah);
454 }
455 ata_wait_idle(ap);
456}
457
458
459static void octeon_cf_dev_select(struct ata_port *ap, unsigned int device)
460{
461/* There is only one device, do nothing. */
462 return;
463}
464
465/*
466 * Issue ATA command to host controller. The device_addr is also sent
467 * as it must be written in a combined write with the command.
468 */
469static void octeon_cf_exec_command16(struct ata_port *ap,
470 const struct ata_taskfile *tf)
471{
472 /* The base of the registers is at ioaddr.data_addr. */
473 void __iomem *base = ap->ioaddr.data_addr;
474 u16 blob;
475
476 if (tf->flags & ATA_TFLAG_DEVICE) {
477 VPRINTK("device 0x%X\n", tf->device);
478 blob = tf->device;
479 } else {
480 blob = 0;
481 }
482
483 DPRINTK("ata%u: cmd 0x%X\n", ap->print_id, tf->command);
484 blob |= (tf->command << 8);
485 __raw_writew(blob, base + 6);
486
487
488 ata_wait_idle(ap);
489}
490
491static u8 octeon_cf_irq_on(struct ata_port *ap)
492{
493 return 0;
494}
495
496static void octeon_cf_irq_clear(struct ata_port *ap)
497{
498 return;
499}
500
501static void octeon_cf_dma_setup(struct ata_queued_cmd *qc)
502{
503 struct ata_port *ap = qc->ap;
504 struct octeon_cf_port *cf_port;
505
506 cf_port = (struct octeon_cf_port *)ap->private_data;
507 DPRINTK("ENTER\n");
508 /* issue r/w command */
509 qc->cursg = qc->sg;
510 cf_port->dma_finished = 0;
511 ap->ops->sff_exec_command(ap, &qc->tf);
512 DPRINTK("EXIT\n");
513}
514
515/**
516 * Start a DMA transfer that was already setup
517 *
518 * @qc: Information about the DMA
519 */
520static void octeon_cf_dma_start(struct ata_queued_cmd *qc)
521{
522 struct octeon_cf_data *ocd = qc->ap->dev->platform_data;
523 union cvmx_mio_boot_dma_cfgx mio_boot_dma_cfg;
524 union cvmx_mio_boot_dma_intx mio_boot_dma_int;
525 struct scatterlist *sg;
526
527 VPRINTK("%d scatterlists\n", qc->n_elem);
528
529 /* Get the scatter list entry we need to DMA into */
530 sg = qc->cursg;
531 BUG_ON(!sg);
532
533 /*
534 * Clear the DMA complete status.
535 */
536 mio_boot_dma_int.u64 = 0;
537 mio_boot_dma_int.s.done = 1;
538 cvmx_write_csr(CVMX_MIO_BOOT_DMA_INTX(ocd->dma_engine),
539 mio_boot_dma_int.u64);
540
541 /* Enable the interrupt. */
542 cvmx_write_csr(CVMX_MIO_BOOT_DMA_INT_ENX(ocd->dma_engine),
543 mio_boot_dma_int.u64);
544
545 /* Set the direction of the DMA */
546 mio_boot_dma_cfg.u64 = 0;
547 mio_boot_dma_cfg.s.en = 1;
548 mio_boot_dma_cfg.s.rw = ((qc->tf.flags & ATA_TFLAG_WRITE) != 0);
549
550 /*
551 * Don't stop the DMA if the device deasserts DMARQ. Many
552 * compact flashes deassert DMARQ for a short time between
553 * sectors. Instead of stopping and restarting the DMA, we'll
554 * let the hardware do it. If the DMA is really stopped early
555 * due to an error condition, a later timeout will force us to
556 * stop.
557 */
558 mio_boot_dma_cfg.s.clr = 0;
559
560 /* Size is specified in 16bit words and minus one notation */
561 mio_boot_dma_cfg.s.size = sg_dma_len(sg) / 2 - 1;
562
563 /* We need to swap the high and low bytes of every 16 bits */
564 mio_boot_dma_cfg.s.swap8 = 1;
565
566 mio_boot_dma_cfg.s.adr = sg_dma_address(sg);
567
568 VPRINTK("%s %d bytes address=%p\n",
569 (mio_boot_dma_cfg.s.rw) ? "write" : "read", sg->length,
570 (void *)(unsigned long)mio_boot_dma_cfg.s.adr);
571
572 cvmx_write_csr(CVMX_MIO_BOOT_DMA_CFGX(ocd->dma_engine),
573 mio_boot_dma_cfg.u64);
574}
575
576/**
577 *
578 * LOCKING:
579 * spin_lock_irqsave(host lock)
580 *
581 */
582static unsigned int octeon_cf_dma_finished(struct ata_port *ap,
583 struct ata_queued_cmd *qc)
584{
585 struct ata_eh_info *ehi = &ap->link.eh_info;
586 struct octeon_cf_data *ocd = ap->dev->platform_data;
587 union cvmx_mio_boot_dma_cfgx dma_cfg;
588 union cvmx_mio_boot_dma_intx dma_int;
589 struct octeon_cf_port *cf_port;
590 u8 status;
591
592 VPRINTK("ata%u: protocol %d task_state %d\n",
593 ap->print_id, qc->tf.protocol, ap->hsm_task_state);
594
595
596 if (ap->hsm_task_state != HSM_ST_LAST)
597 return 0;
598
599 cf_port = (struct octeon_cf_port *)ap->private_data;
600
601 dma_cfg.u64 = cvmx_read_csr(CVMX_MIO_BOOT_DMA_CFGX(ocd->dma_engine));
602 if (dma_cfg.s.size != 0xfffff) {
603 /* Error, the transfer was not complete. */
604 qc->err_mask |= AC_ERR_HOST_BUS;
605 ap->hsm_task_state = HSM_ST_ERR;
606 }
607
608 /* Stop and clear the dma engine. */
609 dma_cfg.u64 = 0;
610 dma_cfg.s.size = -1;
611 cvmx_write_csr(CVMX_MIO_BOOT_DMA_CFGX(ocd->dma_engine), dma_cfg.u64);
612
613 /* Disable the interrupt. */
614 dma_int.u64 = 0;
615 cvmx_write_csr(CVMX_MIO_BOOT_DMA_INT_ENX(ocd->dma_engine), dma_int.u64);
616
617 /* Clear the DMA complete status */
618 dma_int.s.done = 1;
619 cvmx_write_csr(CVMX_MIO_BOOT_DMA_INTX(ocd->dma_engine), dma_int.u64);
620
621 status = ap->ops->sff_check_status(ap);
622
623 ata_sff_hsm_move(ap, qc, status, 0);
624
625 if (unlikely(qc->err_mask) && (qc->tf.protocol == ATA_PROT_DMA))
626 ata_ehi_push_desc(ehi, "DMA stat 0x%x", status);
627
628 return 1;
629}
630
631/*
632 * Check if any queued commands have more DMAs, if so start the next
633 * transfer, else do end of transfer handling.
634 */
635static irqreturn_t octeon_cf_interrupt(int irq, void *dev_instance)
636{
637 struct ata_host *host = dev_instance;
638 struct octeon_cf_port *cf_port;
639 int i;
640 unsigned int handled = 0;
641 unsigned long flags;
642
643 spin_lock_irqsave(&host->lock, flags);
644
645 DPRINTK("ENTER\n");
646 for (i = 0; i < host->n_ports; i++) {
647 u8 status;
648 struct ata_port *ap;
649 struct ata_queued_cmd *qc;
650 union cvmx_mio_boot_dma_intx dma_int;
651 union cvmx_mio_boot_dma_cfgx dma_cfg;
652 struct octeon_cf_data *ocd;
653
654 ap = host->ports[i];
655 ocd = ap->dev->platform_data;
656 if (!ap || (ap->flags & ATA_FLAG_DISABLED))
657 continue;
658
659 ocd = ap->dev->platform_data;
660 cf_port = (struct octeon_cf_port *)ap->private_data;
661 dma_int.u64 =
662 cvmx_read_csr(CVMX_MIO_BOOT_DMA_INTX(ocd->dma_engine));
663 dma_cfg.u64 =
664 cvmx_read_csr(CVMX_MIO_BOOT_DMA_CFGX(ocd->dma_engine));
665
666 qc = ata_qc_from_tag(ap, ap->link.active_tag);
667
668 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)) &&
669 (qc->flags & ATA_QCFLAG_ACTIVE)) {
670 if (dma_int.s.done && !dma_cfg.s.en) {
671 if (!sg_is_last(qc->cursg)) {
672 qc->cursg = sg_next(qc->cursg);
673 handled = 1;
674 octeon_cf_dma_start(qc);
675 continue;
676 } else {
677 cf_port->dma_finished = 1;
678 }
679 }
680 if (!cf_port->dma_finished)
681 continue;
682 status = ioread8(ap->ioaddr.altstatus_addr);
683 if (status & (ATA_BUSY | ATA_DRQ)) {
684 /*
685 * We are busy, try to handle it
686 * later. This is the DMA finished
687 * interrupt, and it could take a
688 * little while for the card to be
689 * ready for more commands.
690 */
691 /* Clear DMA irq. */
692 dma_int.u64 = 0;
693 dma_int.s.done = 1;
694 cvmx_write_csr(CVMX_MIO_BOOT_DMA_INTX(ocd->dma_engine),
695 dma_int.u64);
696
697 queue_delayed_work(cf_port->wq,
698 &cf_port->delayed_finish, 1);
699 handled = 1;
700 } else {
701 handled |= octeon_cf_dma_finished(ap, qc);
702 }
703 }
704 }
705 spin_unlock_irqrestore(&host->lock, flags);
706 DPRINTK("EXIT\n");
707 return IRQ_RETVAL(handled);
708}
709
710static void octeon_cf_delayed_finish(struct work_struct *work)
711{
712 struct octeon_cf_port *cf_port = container_of(work,
713 struct octeon_cf_port,
714 delayed_finish.work);
715 struct ata_port *ap = cf_port->ap;
716 struct ata_host *host = ap->host;
717 struct ata_queued_cmd *qc;
718 unsigned long flags;
719 u8 status;
720
721 spin_lock_irqsave(&host->lock, flags);
722
723 /*
724 * If the port is not waiting for completion, it must have
725 * handled it previously. The hsm_task_state is
726 * protected by host->lock.
727 */
728 if (ap->hsm_task_state != HSM_ST_LAST || !cf_port->dma_finished)
729 goto out;
730
731 status = ioread8(ap->ioaddr.altstatus_addr);
732 if (status & (ATA_BUSY | ATA_DRQ)) {
733 /* Still busy, try again. */
734 queue_delayed_work(cf_port->wq,
735 &cf_port->delayed_finish, 1);
736 goto out;
737 }
738 qc = ata_qc_from_tag(ap, ap->link.active_tag);
739 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)) &&
740 (qc->flags & ATA_QCFLAG_ACTIVE))
741 octeon_cf_dma_finished(ap, qc);
742out:
743 spin_unlock_irqrestore(&host->lock, flags);
744}
745
746static void octeon_cf_dev_config(struct ata_device *dev)
747{
748 /*
749 * A maximum of 2^20 - 1 16 bit transfers are possible with
750 * the bootbus DMA. So we need to throttle max_sectors to
751 * (2^12 - 1 == 4095) to assure that this can never happen.
752 */
753 dev->max_sectors = min(dev->max_sectors, 4095U);
754}
755
756/*
757 * Trap if driver tries to do standard bmdma commands. They are not
758 * supported.
759 */
760static void unreachable_qc(struct ata_queued_cmd *qc)
761{
762 BUG();
763}
764
765static u8 unreachable_port(struct ata_port *ap)
766{
767 BUG();
768}
769
770/*
771 * We don't do ATAPI DMA so return 0.
772 */
773static int octeon_cf_check_atapi_dma(struct ata_queued_cmd *qc)
774{
775 return 0;
776}
777
778static unsigned int octeon_cf_qc_issue(struct ata_queued_cmd *qc)
779{
780 struct ata_port *ap = qc->ap;
781
782 switch (qc->tf.protocol) {
783 case ATA_PROT_DMA:
784 WARN_ON(qc->tf.flags & ATA_TFLAG_POLLING);
785
786 ap->ops->sff_tf_load(ap, &qc->tf); /* load tf registers */
787 octeon_cf_dma_setup(qc); /* set up dma */
788 octeon_cf_dma_start(qc); /* initiate dma */
789 ap->hsm_task_state = HSM_ST_LAST;
790 break;
791
792 case ATAPI_PROT_DMA:
793 dev_err(ap->dev, "Error, ATAPI not supported\n");
794 BUG();
795
796 default:
797 return ata_sff_qc_issue(qc);
798 }
799
800 return 0;
801}
802
803static struct ata_port_operations octeon_cf_ops = {
804 .inherits = &ata_sff_port_ops,
805 .check_atapi_dma = octeon_cf_check_atapi_dma,
806 .qc_prep = ata_noop_qc_prep,
807 .qc_issue = octeon_cf_qc_issue,
808 .sff_dev_select = octeon_cf_dev_select,
809 .sff_irq_on = octeon_cf_irq_on,
810 .sff_irq_clear = octeon_cf_irq_clear,
811 .bmdma_setup = unreachable_qc,
812 .bmdma_start = unreachable_qc,
813 .bmdma_stop = unreachable_qc,
814 .bmdma_status = unreachable_port,
815 .cable_detect = ata_cable_40wire,
816 .set_piomode = octeon_cf_set_piomode,
817 .set_dmamode = octeon_cf_set_dmamode,
818 .dev_config = octeon_cf_dev_config,
819};
820
821static int __devinit octeon_cf_probe(struct platform_device *pdev)
822{
823 struct resource *res_cs0, *res_cs1;
824
825 void __iomem *cs0;
826 void __iomem *cs1 = NULL;
827 struct ata_host *host;
828 struct ata_port *ap;
829 struct octeon_cf_data *ocd;
830 int irq = 0;
831 irq_handler_t irq_handler = NULL;
832 void __iomem *base;
833 struct octeon_cf_port *cf_port;
834
835 res_cs0 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
836
837 if (!res_cs0)
838 return -EINVAL;
839
840 ocd = pdev->dev.platform_data;
841
842 cs0 = devm_ioremap_nocache(&pdev->dev, res_cs0->start,
843 res_cs0->end - res_cs0->start + 1);
844
845 if (!cs0)
846 return -ENOMEM;
847
848 /* Determine from availability of DMA if True IDE mode or not */
849 if (ocd->dma_engine >= 0) {
850 res_cs1 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
851 if (!res_cs1)
852 return -EINVAL;
853
854 cs1 = devm_ioremap_nocache(&pdev->dev, res_cs1->start,
855 res_cs0->end - res_cs1->start + 1);
856
857 if (!cs1)
858 return -ENOMEM;
859 }
860
861 cf_port = kzalloc(sizeof(*cf_port), GFP_KERNEL);
862 if (!cf_port)
863 return -ENOMEM;
864
865 /* allocate host */
866 host = ata_host_alloc(&pdev->dev, 1);
867 if (!host)
868 goto free_cf_port;
869
870 ap = host->ports[0];
871 ap->private_data = cf_port;
872 cf_port->ap = ap;
873 ap->ops = &octeon_cf_ops;
874 ap->pio_mask = 0x7f; /* Support PIO 0-6 */
875 ap->flags |= ATA_FLAG_MMIO | ATA_FLAG_NO_LEGACY
876 | ATA_FLAG_NO_ATAPI | ATA_FLAG_PIO_POLLING;
877
878 base = cs0 + ocd->base_region_bias;
879 if (!ocd->is16bit) {
880 ap->ioaddr.cmd_addr = base;
881 ata_sff_std_ports(&ap->ioaddr);
882
883 ap->ioaddr.altstatus_addr = base + 0xe;
884 ap->ioaddr.ctl_addr = base + 0xe;
885 octeon_cf_ops.sff_data_xfer = octeon_cf_data_xfer8;
886 } else if (cs1) {
887 /* Presence of cs1 indicates True IDE mode. */
888 ap->ioaddr.cmd_addr = base + (ATA_REG_CMD << 1) + 1;
889 ap->ioaddr.data_addr = base + (ATA_REG_DATA << 1);
890 ap->ioaddr.error_addr = base + (ATA_REG_ERR << 1) + 1;
891 ap->ioaddr.feature_addr = base + (ATA_REG_FEATURE << 1) + 1;
892 ap->ioaddr.nsect_addr = base + (ATA_REG_NSECT << 1) + 1;
893 ap->ioaddr.lbal_addr = base + (ATA_REG_LBAL << 1) + 1;
894 ap->ioaddr.lbam_addr = base + (ATA_REG_LBAM << 1) + 1;
895 ap->ioaddr.lbah_addr = base + (ATA_REG_LBAH << 1) + 1;
896 ap->ioaddr.device_addr = base + (ATA_REG_DEVICE << 1) + 1;
897 ap->ioaddr.status_addr = base + (ATA_REG_STATUS << 1) + 1;
898 ap->ioaddr.command_addr = base + (ATA_REG_CMD << 1) + 1;
899 ap->ioaddr.altstatus_addr = cs1 + (6 << 1) + 1;
900 ap->ioaddr.ctl_addr = cs1 + (6 << 1) + 1;
901 octeon_cf_ops.sff_data_xfer = octeon_cf_data_xfer16;
902
903 ap->mwdma_mask = 0x1f; /* Support MWDMA 0-4 */
904 irq = platform_get_irq(pdev, 0);
905 irq_handler = octeon_cf_interrupt;
906
907 /* True IDE mode needs delayed work to poll for not-busy. */
908 cf_port->wq = create_singlethread_workqueue(DRV_NAME);
909 if (!cf_port->wq)
910 goto free_cf_port;
911 INIT_DELAYED_WORK(&cf_port->delayed_finish,
912 octeon_cf_delayed_finish);
913
914 } else {
915 /* 16 bit but not True IDE */
916 octeon_cf_ops.sff_data_xfer = octeon_cf_data_xfer16;
917 octeon_cf_ops.softreset = octeon_cf_softreset16;
918 octeon_cf_ops.sff_check_status = octeon_cf_check_status16;
919 octeon_cf_ops.sff_tf_read = octeon_cf_tf_read16;
920 octeon_cf_ops.sff_tf_load = octeon_cf_tf_load16;
921 octeon_cf_ops.sff_exec_command = octeon_cf_exec_command16;
922
923 ap->ioaddr.data_addr = base + ATA_REG_DATA;
924 ap->ioaddr.nsect_addr = base + ATA_REG_NSECT;
925 ap->ioaddr.lbal_addr = base + ATA_REG_LBAL;
926 ap->ioaddr.ctl_addr = base + 0xe;
927 ap->ioaddr.altstatus_addr = base + 0xe;
928 }
929
930 ata_port_desc(ap, "cmd %p ctl %p", base, ap->ioaddr.ctl_addr);
931
932
933 dev_info(&pdev->dev, "version " DRV_VERSION" %d bit%s.\n",
934 (ocd->is16bit) ? 16 : 8,
935 (cs1) ? ", True IDE" : "");
936
937
938 return ata_host_activate(host, irq, irq_handler, 0, &octeon_cf_sht);
939
940free_cf_port:
941 kfree(cf_port);
942 return -ENOMEM;
943}
944
945static struct platform_driver octeon_cf_driver = {
946 .probe = octeon_cf_probe,
947 .driver = {
948 .name = DRV_NAME,
949 .owner = THIS_MODULE,
950 },
951};
952
953static int __init octeon_cf_init(void)
954{
955 return platform_driver_register(&octeon_cf_driver);
956}
957
958
959MODULE_AUTHOR("David Daney <ddaney@caviumnetworks.com>");
960MODULE_DESCRIPTION("low-level driver for Cavium OCTEON Compact Flash PATA");
961MODULE_LICENSE("GPL");
962MODULE_VERSION(DRV_VERSION);
963MODULE_ALIAS("platform:" DRV_NAME);
964
965module_init(octeon_cf_init);
diff --git a/drivers/ata/pata_platform.c b/drivers/ata/pata_platform.c
index 6afa07a37648..d8d743af3225 100644
--- a/drivers/ata/pata_platform.c
+++ b/drivers/ata/pata_platform.c
@@ -186,7 +186,7 @@ EXPORT_SYMBOL_GPL(__pata_platform_probe);
186 * A platform bus ATA device has been unplugged. Perform the needed 186 * A platform bus ATA device has been unplugged. Perform the needed
187 * cleanup. Also called on module unload for any active devices. 187 * cleanup. Also called on module unload for any active devices.
188 */ 188 */
189int __devexit __pata_platform_remove(struct device *dev) 189int __pata_platform_remove(struct device *dev)
190{ 190{
191 struct ata_host *host = dev_get_drvdata(dev); 191 struct ata_host *host = dev_get_drvdata(dev);
192 192
diff --git a/drivers/ata/pata_sil680.c b/drivers/ata/pata_sil680.c
index 83580a59db58..9e764e5747e6 100644
--- a/drivers/ata/pata_sil680.c
+++ b/drivers/ata/pata_sil680.c
@@ -32,7 +32,7 @@
32#include <linux/libata.h> 32#include <linux/libata.h>
33 33
34#define DRV_NAME "pata_sil680" 34#define DRV_NAME "pata_sil680"
35#define DRV_VERSION "0.4.8" 35#define DRV_VERSION "0.4.9"
36 36
37#define SIL680_MMIO_BAR 5 37#define SIL680_MMIO_BAR 5
38 38
@@ -195,7 +195,7 @@ static struct scsi_host_template sil680_sht = {
195}; 195};
196 196
197static struct ata_port_operations sil680_port_ops = { 197static struct ata_port_operations sil680_port_ops = {
198 .inherits = &ata_bmdma_port_ops, 198 .inherits = &ata_bmdma32_port_ops,
199 .cable_detect = sil680_cable_detect, 199 .cable_detect = sil680_cable_detect,
200 .set_piomode = sil680_set_piomode, 200 .set_piomode = sil680_set_piomode,
201 .set_dmamode = sil680_set_dmamode, 201 .set_dmamode = sil680_set_dmamode,
diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c
index 1a56db92ff7a..55bc88c1707b 100644
--- a/drivers/ata/sata_fsl.c
+++ b/drivers/ata/sata_fsl.c
@@ -1288,7 +1288,7 @@ static const struct ata_port_info sata_fsl_port_info[] = {
1288static int sata_fsl_probe(struct of_device *ofdev, 1288static int sata_fsl_probe(struct of_device *ofdev,
1289 const struct of_device_id *match) 1289 const struct of_device_id *match)
1290{ 1290{
1291 int retval = 0; 1291 int retval = -ENXIO;
1292 void __iomem *hcr_base = NULL; 1292 void __iomem *hcr_base = NULL;
1293 void __iomem *ssr_base = NULL; 1293 void __iomem *ssr_base = NULL;
1294 void __iomem *csr_base = NULL; 1294 void __iomem *csr_base = NULL;
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
index ccee930f1e12..2590c2279fa7 100644
--- a/drivers/ata/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -51,13 +51,6 @@ struct sil24_sge {
51 __le32 flags; 51 __le32 flags;
52}; 52};
53 53
54/*
55 * Port multiplier
56 */
57struct sil24_port_multiplier {
58 __le32 diag;
59 __le32 sactive;
60};
61 54
62enum { 55enum {
63 SIL24_HOST_BAR = 0, 56 SIL24_HOST_BAR = 0,
diff --git a/drivers/ata/sata_via.c b/drivers/ata/sata_via.c
index c18935f0bda2..5c62da9cd491 100644
--- a/drivers/ata/sata_via.c
+++ b/drivers/ata/sata_via.c
@@ -92,6 +92,8 @@ static const struct pci_device_id svia_pci_tbl[] = {
92 { PCI_VDEVICE(VIA, 0x5372), vt6420 }, 92 { PCI_VDEVICE(VIA, 0x5372), vt6420 },
93 { PCI_VDEVICE(VIA, 0x7372), vt6420 }, 93 { PCI_VDEVICE(VIA, 0x7372), vt6420 },
94 { PCI_VDEVICE(VIA, 0x5287), vt8251 }, /* 2 sata chnls (Master/Slave) */ 94 { PCI_VDEVICE(VIA, 0x5287), vt8251 }, /* 2 sata chnls (Master/Slave) */
95 { PCI_VDEVICE(VIA, 0x9000), vt8251 },
96 { PCI_VDEVICE(VIA, 0x9040), vt8251 },
95 97
96 { } /* terminate list */ 98 { } /* terminate list */
97}; 99};
diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
index 088885ed51b9..e1c7611e9144 100644
--- a/drivers/atm/iphase.c
+++ b/drivers/atm/iphase.c
@@ -64,7 +64,7 @@
64#include <linux/jiffies.h> 64#include <linux/jiffies.h>
65#include "iphase.h" 65#include "iphase.h"
66#include "suni.h" 66#include "suni.h"
67#define swap(x) (((x & 0xff) << 8) | ((x & 0xff00) >> 8)) 67#define swap_byte_order(x) (((x & 0xff) << 8) | ((x & 0xff00) >> 8))
68 68
69#define PRIV(dev) ((struct suni_priv *) dev->phy_data) 69#define PRIV(dev) ((struct suni_priv *) dev->phy_data)
70 70
@@ -1306,7 +1306,7 @@ static void rx_dle_intr(struct atm_dev *dev)
1306 // get real pkt length pwang_test 1306 // get real pkt length pwang_test
1307 trailer = (struct cpcs_trailer*)((u_char *)skb->data + 1307 trailer = (struct cpcs_trailer*)((u_char *)skb->data +
1308 skb->len - sizeof(*trailer)); 1308 skb->len - sizeof(*trailer));
1309 length = swap(trailer->length); 1309 length = swap_byte_order(trailer->length);
1310 if ((length > iadev->rx_buf_sz) || (length > 1310 if ((length > iadev->rx_buf_sz) || (length >
1311 (skb->len - sizeof(struct cpcs_trailer)))) 1311 (skb->len - sizeof(struct cpcs_trailer))))
1312 { 1312 {
@@ -2995,7 +2995,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
2995 skb->len, PCI_DMA_TODEVICE); 2995 skb->len, PCI_DMA_TODEVICE);
2996 wr_ptr->local_pkt_addr = (buf_desc_ptr->buf_start_hi << 16) | 2996 wr_ptr->local_pkt_addr = (buf_desc_ptr->buf_start_hi << 16) |
2997 buf_desc_ptr->buf_start_lo; 2997 buf_desc_ptr->buf_start_lo;
2998 /* wr_ptr->bytes = swap(total_len); didn't seem to affect ?? */ 2998 /* wr_ptr->bytes = swap_byte_order(total_len); didn't seem to affect?? */
2999 wr_ptr->bytes = skb->len; 2999 wr_ptr->bytes = skb->len;
3000 3000
3001 /* hw bug - DLEs of 0x2d, 0x2e, 0x2f cause DMA lockup */ 3001 /* hw bug - DLEs of 0x2d, 0x2e, 0x2f cause DMA lockup */
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index d8e8c49c0cbd..8f006f96ff53 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -54,7 +54,7 @@ config FIRMWARE_IN_KERNEL
54 such firmware, and do not wish to use an initrd. 54 such firmware, and do not wish to use an initrd.
55 55
56 This single option controls the inclusion of firmware for 56 This single option controls the inclusion of firmware for
57 every driver which uses request_firmare() and ships its 57 every driver which uses request_firmware() and ships its
58 firmware in the kernel source tree, to avoid a proliferation 58 firmware in the kernel source tree, to avoid a proliferation
59 of 'Include firmware for xxx device' options. 59 of 'Include firmware for xxx device' options.
60 60
diff --git a/drivers/base/base.h b/drivers/base/base.h
index b676f8f801f8..0a5f055dffba 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -63,32 +63,6 @@ struct class_private {
63#define to_class(obj) \ 63#define to_class(obj) \
64 container_of(obj, struct class_private, class_subsys.kobj) 64 container_of(obj, struct class_private, class_subsys.kobj)
65 65
66/**
67 * struct device_private - structure to hold the private to the driver core portions of the device structure.
68 *
69 * @klist_children - klist containing all children of this device
70 * @knode_parent - node in sibling list
71 * @knode_driver - node in driver list
72 * @knode_bus - node in bus list
73 * @device - pointer back to the struct class that this structure is
74 * associated with.
75 *
76 * Nothing outside of the driver core should ever touch these fields.
77 */
78struct device_private {
79 struct klist klist_children;
80 struct klist_node knode_parent;
81 struct klist_node knode_driver;
82 struct klist_node knode_bus;
83 struct device *device;
84};
85#define to_device_private_parent(obj) \
86 container_of(obj, struct device_private, knode_parent)
87#define to_device_private_driver(obj) \
88 container_of(obj, struct device_private, knode_driver)
89#define to_device_private_bus(obj) \
90 container_of(obj, struct device_private, knode_bus)
91
92/* initialisation functions */ 66/* initialisation functions */
93extern int devices_init(void); 67extern int devices_init(void);
94extern int buses_init(void); 68extern int buses_init(void);
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 0f0a50444672..83f32b891fa9 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -253,14 +253,7 @@ static ssize_t store_drivers_probe(struct bus_type *bus,
253static struct device *next_device(struct klist_iter *i) 253static struct device *next_device(struct klist_iter *i)
254{ 254{
255 struct klist_node *n = klist_next(i); 255 struct klist_node *n = klist_next(i);
256 struct device *dev = NULL; 256 return n ? container_of(n, struct device, knode_bus) : NULL;
257 struct device_private *dev_prv;
258
259 if (n) {
260 dev_prv = to_device_private_bus(n);
261 dev = dev_prv->device;
262 }
263 return dev;
264} 257}
265 258
266/** 259/**
@@ -293,7 +286,7 @@ int bus_for_each_dev(struct bus_type *bus, struct device *start,
293 return -EINVAL; 286 return -EINVAL;
294 287
295 klist_iter_init_node(&bus->p->klist_devices, &i, 288 klist_iter_init_node(&bus->p->klist_devices, &i,
296 (start ? &start->p->knode_bus : NULL)); 289 (start ? &start->knode_bus : NULL));
297 while ((dev = next_device(&i)) && !error) 290 while ((dev = next_device(&i)) && !error)
298 error = fn(dev, data); 291 error = fn(dev, data);
299 klist_iter_exit(&i); 292 klist_iter_exit(&i);
@@ -327,7 +320,7 @@ struct device *bus_find_device(struct bus_type *bus,
327 return NULL; 320 return NULL;
328 321
329 klist_iter_init_node(&bus->p->klist_devices, &i, 322 klist_iter_init_node(&bus->p->klist_devices, &i,
330 (start ? &start->p->knode_bus : NULL)); 323 (start ? &start->knode_bus : NULL));
331 while ((dev = next_device(&i))) 324 while ((dev = next_device(&i)))
332 if (match(dev, data) && get_device(dev)) 325 if (match(dev, data) && get_device(dev))
333 break; 326 break;
@@ -514,8 +507,7 @@ void bus_attach_device(struct device *dev)
514 ret = device_attach(dev); 507 ret = device_attach(dev);
515 WARN_ON(ret < 0); 508 WARN_ON(ret < 0);
516 if (ret >= 0) 509 if (ret >= 0)
517 klist_add_tail(&dev->p->knode_bus, 510 klist_add_tail(&dev->knode_bus, &bus->p->klist_devices);
518 &bus->p->klist_devices);
519 } 511 }
520} 512}
521 513
@@ -536,8 +528,8 @@ void bus_remove_device(struct device *dev)
536 sysfs_remove_link(&dev->bus->p->devices_kset->kobj, 528 sysfs_remove_link(&dev->bus->p->devices_kset->kobj,
537 dev_name(dev)); 529 dev_name(dev));
538 device_remove_attrs(dev->bus, dev); 530 device_remove_attrs(dev->bus, dev);
539 if (klist_node_attached(&dev->p->knode_bus)) 531 if (klist_node_attached(&dev->knode_bus))
540 klist_del(&dev->p->knode_bus); 532 klist_del(&dev->knode_bus);
541 533
542 pr_debug("bus: '%s': remove device %s\n", 534 pr_debug("bus: '%s': remove device %s\n",
543 dev->bus->name, dev_name(dev)); 535 dev->bus->name, dev_name(dev));
@@ -839,16 +831,14 @@ static void bus_remove_attrs(struct bus_type *bus)
839 831
840static void klist_devices_get(struct klist_node *n) 832static void klist_devices_get(struct klist_node *n)
841{ 833{
842 struct device_private *dev_prv = to_device_private_bus(n); 834 struct device *dev = container_of(n, struct device, knode_bus);
843 struct device *dev = dev_prv->device;
844 835
845 get_device(dev); 836 get_device(dev);
846} 837}
847 838
848static void klist_devices_put(struct klist_node *n) 839static void klist_devices_put(struct klist_node *n)
849{ 840{
850 struct device_private *dev_prv = to_device_private_bus(n); 841 struct device *dev = container_of(n, struct device, knode_bus);
851 struct device *dev = dev_prv->device;
852 842
853 put_device(dev); 843 put_device(dev);
854} 844}
@@ -1003,20 +993,18 @@ static void device_insertion_sort_klist(struct device *a, struct list_head *list
1003{ 993{
1004 struct list_head *pos; 994 struct list_head *pos;
1005 struct klist_node *n; 995 struct klist_node *n;
1006 struct device_private *dev_prv;
1007 struct device *b; 996 struct device *b;
1008 997
1009 list_for_each(pos, list) { 998 list_for_each(pos, list) {
1010 n = container_of(pos, struct klist_node, n_node); 999 n = container_of(pos, struct klist_node, n_node);
1011 dev_prv = to_device_private_bus(n); 1000 b = container_of(n, struct device, knode_bus);
1012 b = dev_prv->device;
1013 if (compare(a, b) <= 0) { 1001 if (compare(a, b) <= 0) {
1014 list_move_tail(&a->p->knode_bus.n_node, 1002 list_move_tail(&a->knode_bus.n_node,
1015 &b->p->knode_bus.n_node); 1003 &b->knode_bus.n_node);
1016 return; 1004 return;
1017 } 1005 }
1018 } 1006 }
1019 list_move_tail(&a->p->knode_bus.n_node, list); 1007 list_move_tail(&a->knode_bus.n_node, list);
1020} 1008}
1021 1009
1022void bus_sort_breadthfirst(struct bus_type *bus, 1010void bus_sort_breadthfirst(struct bus_type *bus,
@@ -1026,7 +1014,6 @@ void bus_sort_breadthfirst(struct bus_type *bus,
1026 LIST_HEAD(sorted_devices); 1014 LIST_HEAD(sorted_devices);
1027 struct list_head *pos, *tmp; 1015 struct list_head *pos, *tmp;
1028 struct klist_node *n; 1016 struct klist_node *n;
1029 struct device_private *dev_prv;
1030 struct device *dev; 1017 struct device *dev;
1031 struct klist *device_klist; 1018 struct klist *device_klist;
1032 1019
@@ -1035,8 +1022,7 @@ void bus_sort_breadthfirst(struct bus_type *bus,
1035 spin_lock(&device_klist->k_lock); 1022 spin_lock(&device_klist->k_lock);
1036 list_for_each_safe(pos, tmp, &device_klist->k_list) { 1023 list_for_each_safe(pos, tmp, &device_klist->k_list) {
1037 n = container_of(pos, struct klist_node, n_node); 1024 n = container_of(pos, struct klist_node, n_node);
1038 dev_prv = to_device_private_bus(n); 1025 dev = container_of(n, struct device, knode_bus);
1039 dev = dev_prv->device;
1040 device_insertion_sort_klist(dev, &sorted_devices, compare); 1026 device_insertion_sort_klist(dev, &sorted_devices, compare);
1041 } 1027 }
1042 list_splice(&sorted_devices, &device_klist->k_list); 1028 list_splice(&sorted_devices, &device_klist->k_list);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 61df508fa62b..8079afca4972 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -109,7 +109,6 @@ static struct sysfs_ops dev_sysfs_ops = {
109static void device_release(struct kobject *kobj) 109static void device_release(struct kobject *kobj)
110{ 110{
111 struct device *dev = to_dev(kobj); 111 struct device *dev = to_dev(kobj);
112 struct device_private *p = dev->p;
113 112
114 if (dev->release) 113 if (dev->release)
115 dev->release(dev); 114 dev->release(dev);
@@ -121,7 +120,6 @@ static void device_release(struct kobject *kobj)
121 WARN(1, KERN_ERR "Device '%s' does not have a release() " 120 WARN(1, KERN_ERR "Device '%s' does not have a release() "
122 "function, it is broken and must be fixed.\n", 121 "function, it is broken and must be fixed.\n",
123 dev_name(dev)); 122 dev_name(dev));
124 kfree(p);
125} 123}
126 124
127static struct kobj_type device_ktype = { 125static struct kobj_type device_ktype = {
@@ -509,16 +507,14 @@ EXPORT_SYMBOL_GPL(device_schedule_callback_owner);
509 507
510static void klist_children_get(struct klist_node *n) 508static void klist_children_get(struct klist_node *n)
511{ 509{
512 struct device_private *p = to_device_private_parent(n); 510 struct device *dev = container_of(n, struct device, knode_parent);
513 struct device *dev = p->device;
514 511
515 get_device(dev); 512 get_device(dev);
516} 513}
517 514
518static void klist_children_put(struct klist_node *n) 515static void klist_children_put(struct klist_node *n)
519{ 516{
520 struct device_private *p = to_device_private_parent(n); 517 struct device *dev = container_of(n, struct device, knode_parent);
521 struct device *dev = p->device;
522 518
523 put_device(dev); 519 put_device(dev);
524} 520}
@@ -540,15 +536,9 @@ static void klist_children_put(struct klist_node *n)
540 */ 536 */
541void device_initialize(struct device *dev) 537void device_initialize(struct device *dev)
542{ 538{
543 dev->p = kzalloc(sizeof(*dev->p), GFP_KERNEL);
544 if (!dev->p) {
545 WARN_ON(1);
546 return;
547 }
548 dev->p->device = dev;
549 dev->kobj.kset = devices_kset; 539 dev->kobj.kset = devices_kset;
550 kobject_init(&dev->kobj, &device_ktype); 540 kobject_init(&dev->kobj, &device_ktype);
551 klist_init(&dev->p->klist_children, klist_children_get, 541 klist_init(&dev->klist_children, klist_children_get,
552 klist_children_put); 542 klist_children_put);
553 INIT_LIST_HEAD(&dev->dma_pools); 543 INIT_LIST_HEAD(&dev->dma_pools);
554 init_MUTEX(&dev->sem); 544 init_MUTEX(&dev->sem);
@@ -932,8 +922,7 @@ int device_add(struct device *dev)
932 kobject_uevent(&dev->kobj, KOBJ_ADD); 922 kobject_uevent(&dev->kobj, KOBJ_ADD);
933 bus_attach_device(dev); 923 bus_attach_device(dev);
934 if (parent) 924 if (parent)
935 klist_add_tail(&dev->p->knode_parent, 925 klist_add_tail(&dev->knode_parent, &parent->klist_children);
936 &parent->p->klist_children);
937 926
938 if (dev->class) { 927 if (dev->class) {
939 mutex_lock(&dev->class->p->class_mutex); 928 mutex_lock(&dev->class->p->class_mutex);
@@ -1047,7 +1036,7 @@ void device_del(struct device *dev)
1047 device_pm_remove(dev); 1036 device_pm_remove(dev);
1048 dpm_sysfs_remove(dev); 1037 dpm_sysfs_remove(dev);
1049 if (parent) 1038 if (parent)
1050 klist_del(&dev->p->knode_parent); 1039 klist_del(&dev->knode_parent);
1051 if (MAJOR(dev->devt)) { 1040 if (MAJOR(dev->devt)) {
1052 device_remove_sys_dev_entry(dev); 1041 device_remove_sys_dev_entry(dev);
1053 device_remove_file(dev, &devt_attr); 1042 device_remove_file(dev, &devt_attr);
@@ -1108,14 +1097,7 @@ void device_unregister(struct device *dev)
1108static struct device *next_device(struct klist_iter *i) 1097static struct device *next_device(struct klist_iter *i)
1109{ 1098{
1110 struct klist_node *n = klist_next(i); 1099 struct klist_node *n = klist_next(i);
1111 struct device *dev = NULL; 1100 return n ? container_of(n, struct device, knode_parent) : NULL;
1112 struct device_private *p;
1113
1114 if (n) {
1115 p = to_device_private_parent(n);
1116 dev = p->device;
1117 }
1118 return dev;
1119} 1101}
1120 1102
1121/** 1103/**
@@ -1137,7 +1119,7 @@ int device_for_each_child(struct device *parent, void *data,
1137 struct device *child; 1119 struct device *child;
1138 int error = 0; 1120 int error = 0;
1139 1121
1140 klist_iter_init(&parent->p->klist_children, &i); 1122 klist_iter_init(&parent->klist_children, &i);
1141 while ((child = next_device(&i)) && !error) 1123 while ((child = next_device(&i)) && !error)
1142 error = fn(child, data); 1124 error = fn(child, data);
1143 klist_iter_exit(&i); 1125 klist_iter_exit(&i);
@@ -1168,7 +1150,7 @@ struct device *device_find_child(struct device *parent, void *data,
1168 if (!parent) 1150 if (!parent)
1169 return NULL; 1151 return NULL;
1170 1152
1171 klist_iter_init(&parent->p->klist_children, &i); 1153 klist_iter_init(&parent->klist_children, &i);
1172 while ((child = next_device(&i))) 1154 while ((child = next_device(&i)))
1173 if (match(child, data) && get_device(child)) 1155 if (match(child, data) && get_device(child))
1174 break; 1156 break;
@@ -1582,10 +1564,9 @@ int device_move(struct device *dev, struct device *new_parent)
1582 old_parent = dev->parent; 1564 old_parent = dev->parent;
1583 dev->parent = new_parent; 1565 dev->parent = new_parent;
1584 if (old_parent) 1566 if (old_parent)
1585 klist_remove(&dev->p->knode_parent); 1567 klist_remove(&dev->knode_parent);
1586 if (new_parent) { 1568 if (new_parent) {
1587 klist_add_tail(&dev->p->knode_parent, 1569 klist_add_tail(&dev->knode_parent, &new_parent->klist_children);
1588 &new_parent->p->klist_children);
1589 set_dev_node(dev, dev_to_node(new_parent)); 1570 set_dev_node(dev, dev_to_node(new_parent));
1590 } 1571 }
1591 1572
@@ -1597,11 +1578,11 @@ int device_move(struct device *dev, struct device *new_parent)
1597 device_move_class_links(dev, new_parent, old_parent); 1578 device_move_class_links(dev, new_parent, old_parent);
1598 if (!kobject_move(&dev->kobj, &old_parent->kobj)) { 1579 if (!kobject_move(&dev->kobj, &old_parent->kobj)) {
1599 if (new_parent) 1580 if (new_parent)
1600 klist_remove(&dev->p->knode_parent); 1581 klist_remove(&dev->knode_parent);
1601 dev->parent = old_parent; 1582 dev->parent = old_parent;
1602 if (old_parent) { 1583 if (old_parent) {
1603 klist_add_tail(&dev->p->knode_parent, 1584 klist_add_tail(&dev->knode_parent,
1604 &old_parent->p->klist_children); 1585 &old_parent->klist_children);
1605 set_dev_node(dev, dev_to_node(old_parent)); 1586 set_dev_node(dev, dev_to_node(old_parent));
1606 } 1587 }
1607 } 1588 }
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 6fdaf76f033f..315bed8d5e7f 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -28,7 +28,7 @@
28 28
29static void driver_bound(struct device *dev) 29static void driver_bound(struct device *dev)
30{ 30{
31 if (klist_node_attached(&dev->p->knode_driver)) { 31 if (klist_node_attached(&dev->knode_driver)) {
32 printk(KERN_WARNING "%s: device %s already bound\n", 32 printk(KERN_WARNING "%s: device %s already bound\n",
33 __func__, kobject_name(&dev->kobj)); 33 __func__, kobject_name(&dev->kobj));
34 return; 34 return;
@@ -41,7 +41,7 @@ static void driver_bound(struct device *dev)
41 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, 41 blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
42 BUS_NOTIFY_BOUND_DRIVER, dev); 42 BUS_NOTIFY_BOUND_DRIVER, dev);
43 43
44 klist_add_tail(&dev->p->knode_driver, &dev->driver->p->klist_devices); 44 klist_add_tail(&dev->knode_driver, &dev->driver->p->klist_devices);
45} 45}
46 46
47static int driver_sysfs_add(struct device *dev) 47static int driver_sysfs_add(struct device *dev)
@@ -310,7 +310,7 @@ static void __device_release_driver(struct device *dev)
310 drv->remove(dev); 310 drv->remove(dev);
311 devres_release_all(dev); 311 devres_release_all(dev);
312 dev->driver = NULL; 312 dev->driver = NULL;
313 klist_remove(&dev->p->knode_driver); 313 klist_remove(&dev->knode_driver);
314 } 314 }
315} 315}
316 316
@@ -340,7 +340,6 @@ EXPORT_SYMBOL_GPL(device_release_driver);
340 */ 340 */
341void driver_detach(struct device_driver *drv) 341void driver_detach(struct device_driver *drv)
342{ 342{
343 struct device_private *dev_prv;
344 struct device *dev; 343 struct device *dev;
345 344
346 for (;;) { 345 for (;;) {
@@ -349,10 +348,8 @@ void driver_detach(struct device_driver *drv)
349 spin_unlock(&drv->p->klist_devices.k_lock); 348 spin_unlock(&drv->p->klist_devices.k_lock);
350 break; 349 break;
351 } 350 }
352 dev_prv = list_entry(drv->p->klist_devices.k_list.prev, 351 dev = list_entry(drv->p->klist_devices.k_list.prev,
353 struct device_private, 352 struct device, knode_driver.n_node);
354 knode_driver.n_node);
355 dev = dev_prv->device;
356 get_device(dev); 353 get_device(dev);
357 spin_unlock(&drv->p->klist_devices.k_lock); 354 spin_unlock(&drv->p->klist_devices.k_lock);
358 355
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index b76cc69f1106..1e2bda780e48 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -19,14 +19,7 @@
19static struct device *next_device(struct klist_iter *i) 19static struct device *next_device(struct klist_iter *i)
20{ 20{
21 struct klist_node *n = klist_next(i); 21 struct klist_node *n = klist_next(i);
22 struct device *dev = NULL; 22 return n ? container_of(n, struct device, knode_driver) : NULL;
23 struct device_private *dev_prv;
24
25 if (n) {
26 dev_prv = to_device_private_driver(n);
27 dev = dev_prv->device;
28 }
29 return dev;
30} 23}
31 24
32/** 25/**
@@ -49,7 +42,7 @@ int driver_for_each_device(struct device_driver *drv, struct device *start,
49 return -EINVAL; 42 return -EINVAL;
50 43
51 klist_iter_init_node(&drv->p->klist_devices, &i, 44 klist_iter_init_node(&drv->p->klist_devices, &i,
52 start ? &start->p->knode_driver : NULL); 45 start ? &start->knode_driver : NULL);
53 while ((dev = next_device(&i)) && !error) 46 while ((dev = next_device(&i)) && !error)
54 error = fn(dev, data); 47 error = fn(dev, data);
55 klist_iter_exit(&i); 48 klist_iter_exit(&i);
@@ -83,7 +76,7 @@ struct device *driver_find_device(struct device_driver *drv,
83 return NULL; 76 return NULL;
84 77
85 klist_iter_init_node(&drv->p->klist_devices, &i, 78 klist_iter_init_node(&drv->p->klist_devices, &i,
86 (start ? &start->p->knode_driver : NULL)); 79 (start ? &start->knode_driver : NULL));
87 while ((dev = next_device(&i))) 80 while ((dev = next_device(&i)))
88 if (match(dev, data) && get_device(dev)) 81 if (match(dev, data) && get_device(dev))
89 break; 82 break;
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index a8bc1cbcfa7c..a778fb52b11f 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -28,6 +28,7 @@
28#include <linux/mm.h> 28#include <linux/mm.h>
29#include <linux/cpu.h> 29#include <linux/cpu.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/hardirq.h>
31#include <linux/topology.h> 32#include <linux/topology.h>
32 33
33#define define_one_ro(_name) \ 34#define define_one_ro(_name) \
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index 4b1d4ac960f1..8df436ff7068 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -156,7 +156,7 @@ static volatile int fdc_busy = -1;
156static volatile int fdc_nested; 156static volatile int fdc_nested;
157static DECLARE_WAIT_QUEUE_HEAD(fdc_wait); 157static DECLARE_WAIT_QUEUE_HEAD(fdc_wait);
158 158
159static DECLARE_WAIT_QUEUE_HEAD(motor_wait); 159static DECLARE_COMPLETION(motor_on_completion);
160 160
161static volatile int selected = -1; /* currently selected drive */ 161static volatile int selected = -1; /* currently selected drive */
162 162
@@ -184,8 +184,7 @@ static unsigned char mfmencode[16]={
184static unsigned char mfmdecode[128]; 184static unsigned char mfmdecode[128];
185 185
186/* floppy internal millisecond timer stuff */ 186/* floppy internal millisecond timer stuff */
187static volatile int ms_busy = -1; 187static DECLARE_COMPLETION(ms_wait_completion);
188static DECLARE_WAIT_QUEUE_HEAD(ms_wait);
189#define MS_TICKS ((amiga_eclock+50)/1000) 188#define MS_TICKS ((amiga_eclock+50)/1000)
190 189
191/* 190/*
@@ -211,8 +210,7 @@ static int fd_device[4] = { 0, 0, 0, 0 };
211 210
212static irqreturn_t ms_isr(int irq, void *dummy) 211static irqreturn_t ms_isr(int irq, void *dummy)
213{ 212{
214 ms_busy = -1; 213 complete(&ms_wait_completion);
215 wake_up(&ms_wait);
216 return IRQ_HANDLED; 214 return IRQ_HANDLED;
217} 215}
218 216
@@ -220,19 +218,17 @@ static irqreturn_t ms_isr(int irq, void *dummy)
220 A more generic routine would do a schedule a la timer.device */ 218 A more generic routine would do a schedule a la timer.device */
221static void ms_delay(int ms) 219static void ms_delay(int ms)
222{ 220{
223 unsigned long flags;
224 int ticks; 221 int ticks;
222 static DEFINE_MUTEX(mutex);
223
225 if (ms > 0) { 224 if (ms > 0) {
226 local_irq_save(flags); 225 mutex_lock(&mutex);
227 while (ms_busy == 0)
228 sleep_on(&ms_wait);
229 ms_busy = 0;
230 local_irq_restore(flags);
231 ticks = MS_TICKS*ms-1; 226 ticks = MS_TICKS*ms-1;
232 ciaa.tblo=ticks%256; 227 ciaa.tblo=ticks%256;
233 ciaa.tbhi=ticks/256; 228 ciaa.tbhi=ticks/256;
234 ciaa.crb=0x19; /*count eclock, force load, one-shoot, start */ 229 ciaa.crb=0x19; /*count eclock, force load, one-shoot, start */
235 sleep_on(&ms_wait); 230 wait_for_completion(&ms_wait_completion);
231 mutex_unlock(&mutex);
236 } 232 }
237} 233}
238 234
@@ -254,8 +250,7 @@ static void get_fdc(int drive)
254 printk("get_fdc: drive %d fdc_busy %d fdc_nested %d\n",drive,fdc_busy,fdc_nested); 250 printk("get_fdc: drive %d fdc_busy %d fdc_nested %d\n",drive,fdc_busy,fdc_nested);
255#endif 251#endif
256 local_irq_save(flags); 252 local_irq_save(flags);
257 while (!try_fdc(drive)) 253 wait_event(fdc_wait, try_fdc(drive));
258 sleep_on(&fdc_wait);
259 fdc_busy = drive; 254 fdc_busy = drive;
260 fdc_nested++; 255 fdc_nested++;
261 local_irq_restore(flags); 256 local_irq_restore(flags);
@@ -330,7 +325,7 @@ static void fd_deselect (int drive)
330static void motor_on_callback(unsigned long nr) 325static void motor_on_callback(unsigned long nr)
331{ 326{
332 if (!(ciaa.pra & DSKRDY) || --on_attempts == 0) { 327 if (!(ciaa.pra & DSKRDY) || --on_attempts == 0) {
333 wake_up (&motor_wait); 328 complete_all(&motor_on_completion);
334 } else { 329 } else {
335 motor_on_timer.expires = jiffies + HZ/10; 330 motor_on_timer.expires = jiffies + HZ/10;
336 add_timer(&motor_on_timer); 331 add_timer(&motor_on_timer);
@@ -347,11 +342,12 @@ static int fd_motor_on(int nr)
347 unit[nr].motor = 1; 342 unit[nr].motor = 1;
348 fd_select(nr); 343 fd_select(nr);
349 344
345 INIT_COMPLETION(motor_on_completion);
350 motor_on_timer.data = nr; 346 motor_on_timer.data = nr;
351 mod_timer(&motor_on_timer, jiffies + HZ/2); 347 mod_timer(&motor_on_timer, jiffies + HZ/2);
352 348
353 on_attempts = 10; 349 on_attempts = 10;
354 sleep_on (&motor_wait); 350 wait_for_completion(&motor_on_completion);
355 fd_deselect(nr); 351 fd_deselect(nr);
356 } 352 }
357 353
@@ -582,8 +578,7 @@ static void raw_read(int drive)
582{ 578{
583 drive&=3; 579 drive&=3;
584 get_fdc(drive); 580 get_fdc(drive);
585 while (block_flag) 581 wait_event(wait_fd_block, !block_flag);
586 sleep_on(&wait_fd_block);
587 fd_select(drive); 582 fd_select(drive);
588 /* setup adkcon bits correctly */ 583 /* setup adkcon bits correctly */
589 custom.adkcon = ADK_MSBSYNC; 584 custom.adkcon = ADK_MSBSYNC;
@@ -598,8 +593,7 @@ static void raw_read(int drive)
598 593
599 block_flag = 1; 594 block_flag = 1;
600 595
601 while (block_flag) 596 wait_event(wait_fd_block, !block_flag);
602 sleep_on (&wait_fd_block);
603 597
604 custom.dsklen = 0; 598 custom.dsklen = 0;
605 fd_deselect(drive); 599 fd_deselect(drive);
@@ -616,8 +610,7 @@ static int raw_write(int drive)
616 rel_fdc(); 610 rel_fdc();
617 return 0; 611 return 0;
618 } 612 }
619 while (block_flag) 613 wait_event(wait_fd_block, !block_flag);
620 sleep_on(&wait_fd_block);
621 fd_select(drive); 614 fd_select(drive);
622 /* clear adkcon bits */ 615 /* clear adkcon bits */
623 custom.adkcon = ADK_PRECOMP1|ADK_PRECOMP0|ADK_WORDSYNC|ADK_MSBSYNC; 616 custom.adkcon = ADK_PRECOMP1|ADK_PRECOMP0|ADK_WORDSYNC|ADK_MSBSYNC;
@@ -1294,8 +1287,7 @@ static int non_int_flush_track (unsigned long nr)
1294 writepending = 0; 1287 writepending = 0;
1295 return 0; 1288 return 0;
1296 } 1289 }
1297 while (block_flag == 2) 1290 wait_event(wait_fd_block, block_flag != 2);
1298 sleep_on (&wait_fd_block);
1299 } 1291 }
1300 else { 1292 else {
1301 local_irq_restore(flags); 1293 local_irq_restore(flags);
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 7bcc1d8bc967..34f80fa6fed1 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -406,6 +406,7 @@ static int nbd_do_it(struct nbd_device *lo)
406 ret = sysfs_create_file(&disk_to_dev(lo->disk)->kobj, &pid_attr.attr); 406 ret = sysfs_create_file(&disk_to_dev(lo->disk)->kobj, &pid_attr.attr);
407 if (ret) { 407 if (ret) {
408 printk(KERN_ERR "nbd: sysfs_create_file failed!"); 408 printk(KERN_ERR "nbd: sysfs_create_file failed!");
409 lo->pid = 0;
409 return ret; 410 return ret;
410 } 411 }
411 412
@@ -413,6 +414,7 @@ static int nbd_do_it(struct nbd_device *lo)
413 nbd_end_request(req); 414 nbd_end_request(req);
414 415
415 sysfs_remove_file(&disk_to_dev(lo->disk)->kobj, &pid_attr.attr); 416 sysfs_remove_file(&disk_to_dev(lo->disk)->kobj, &pid_attr.attr);
417 lo->pid = 0;
416 return 0; 418 return 0;
417} 419}
418 420
@@ -648,6 +650,8 @@ static int nbd_ioctl(struct block_device *bdev, fmode_t mode,
648 set_capacity(lo->disk, lo->bytesize >> 9); 650 set_capacity(lo->disk, lo->bytesize >> 9);
649 return 0; 651 return 0;
650 case NBD_DO_IT: 652 case NBD_DO_IT:
653 if (lo->pid)
654 return -EBUSY;
651 if (!lo->file) 655 if (!lo->file)
652 return -EINVAL; 656 return -EINVAL;
653 thread = kthread_create(nbd_thread, lo, lo->disk->disk_name); 657 thread = kthread_create(nbd_thread, lo, lo->disk->disk_name);
diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c
index 936466f62afd..bccc42bb9212 100644
--- a/drivers/block/ps3disk.c
+++ b/drivers/block/ps3disk.c
@@ -141,7 +141,7 @@ static int ps3disk_submit_request_sg(struct ps3_storage_device *dev,
141 141
142 start_sector = req->sector * priv->blocking_factor; 142 start_sector = req->sector * priv->blocking_factor;
143 sectors = req->nr_sectors * priv->blocking_factor; 143 sectors = req->nr_sectors * priv->blocking_factor;
144 dev_dbg(&dev->sbd.core, "%s:%u: %s %lu sectors starting at %lu\n", 144 dev_dbg(&dev->sbd.core, "%s:%u: %s %llu sectors starting at %llu\n",
145 __func__, __LINE__, op, sectors, start_sector); 145 __func__, __LINE__, op, sectors, start_sector);
146 146
147 if (write) { 147 if (write) {
@@ -178,7 +178,7 @@ static int ps3disk_submit_flush_request(struct ps3_storage_device *dev,
178 LV1_STORAGE_ATA_HDDOUT, 0, 0, 0, 178 LV1_STORAGE_ATA_HDDOUT, 0, 0, 0,
179 0, &dev->tag); 179 0, &dev->tag);
180 if (res) { 180 if (res) {
181 dev_err(&dev->sbd.core, "%s:%u: sync cache failed 0x%lx\n", 181 dev_err(&dev->sbd.core, "%s:%u: sync cache failed 0x%llx\n",
182 __func__, __LINE__, res); 182 __func__, __LINE__, res);
183 end_request(req, 0); 183 end_request(req, 0);
184 return 0; 184 return 0;
@@ -238,11 +238,11 @@ static irqreturn_t ps3disk_interrupt(int irq, void *data)
238 238
239 if (tag != dev->tag) 239 if (tag != dev->tag)
240 dev_err(&dev->sbd.core, 240 dev_err(&dev->sbd.core,
241 "%s:%u: tag mismatch, got %lx, expected %lx\n", 241 "%s:%u: tag mismatch, got %llx, expected %llx\n",
242 __func__, __LINE__, tag, dev->tag); 242 __func__, __LINE__, tag, dev->tag);
243 243
244 if (res) { 244 if (res) {
245 dev_err(&dev->sbd.core, "%s:%u: res=%d status=0x%lx\n", 245 dev_err(&dev->sbd.core, "%s:%u: res=%d status=0x%llx\n",
246 __func__, __LINE__, res, status); 246 __func__, __LINE__, res, status);
247 return IRQ_HANDLED; 247 return IRQ_HANDLED;
248 } 248 }
@@ -269,7 +269,7 @@ static irqreturn_t ps3disk_interrupt(int irq, void *data)
269 op = read ? "read" : "write"; 269 op = read ? "read" : "write";
270 } 270 }
271 if (status) { 271 if (status) {
272 dev_dbg(&dev->sbd.core, "%s:%u: %s failed 0x%lx\n", __func__, 272 dev_dbg(&dev->sbd.core, "%s:%u: %s failed 0x%llx\n", __func__,
273 __LINE__, op, status); 273 __LINE__, op, status);
274 error = -EIO; 274 error = -EIO;
275 } else { 275 } else {
@@ -297,7 +297,7 @@ static int ps3disk_sync_cache(struct ps3_storage_device *dev)
297 297
298 res = ps3stor_send_command(dev, LV1_STORAGE_ATA_HDDOUT, 0, 0, 0, 0); 298 res = ps3stor_send_command(dev, LV1_STORAGE_ATA_HDDOUT, 0, 0, 0, 0);
299 if (res) { 299 if (res) {
300 dev_err(&dev->sbd.core, "%s:%u: sync cache failed 0x%lx\n", 300 dev_err(&dev->sbd.core, "%s:%u: sync cache failed 0x%llx\n",
301 __func__, __LINE__, res); 301 __func__, __LINE__, res);
302 return -EIO; 302 return -EIO;
303 } 303 }
@@ -388,7 +388,7 @@ static int ps3disk_identify(struct ps3_storage_device *dev)
388 sizeof(ata_cmnd), ata_cmnd.buffer, 388 sizeof(ata_cmnd), ata_cmnd.buffer,
389 ata_cmnd.arglen); 389 ata_cmnd.arglen);
390 if (res) { 390 if (res) {
391 dev_err(&dev->sbd.core, "%s:%u: identify disk failed 0x%lx\n", 391 dev_err(&dev->sbd.core, "%s:%u: identify disk failed 0x%llx\n",
392 __func__, __LINE__, res); 392 __func__, __LINE__, res);
393 return -EIO; 393 return -EIO;
394 } 394 }
@@ -426,7 +426,7 @@ static int __devinit ps3disk_probe(struct ps3_system_bus_device *_dev)
426 426
427 if (dev->blk_size < 512) { 427 if (dev->blk_size < 512) {
428 dev_err(&dev->sbd.core, 428 dev_err(&dev->sbd.core,
429 "%s:%u: cannot handle block size %lu\n", __func__, 429 "%s:%u: cannot handle block size %llu\n", __func__,
430 __LINE__, dev->blk_size); 430 __LINE__, dev->blk_size);
431 return -EINVAL; 431 return -EINVAL;
432 } 432 }
@@ -512,7 +512,7 @@ static int __devinit ps3disk_probe(struct ps3_system_bus_device *_dev)
512 dev->regions[dev->region_idx].size*priv->blocking_factor); 512 dev->regions[dev->region_idx].size*priv->blocking_factor);
513 513
514 dev_info(&dev->sbd.core, 514 dev_info(&dev->sbd.core,
515 "%s is a %s (%lu MiB total, %lu MiB for OtherOS)\n", 515 "%s is a %s (%llu MiB total, %lu MiB for OtherOS)\n",
516 gendisk->disk_name, priv->model, priv->raw_capacity >> 11, 516 gendisk->disk_name, priv->model, priv->raw_capacity >> 11,
517 get_capacity(gendisk) >> 11); 517 get_capacity(gendisk) >> 11);
518 518
diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c
index 953c0b83d758..5861e33efe63 100644
--- a/drivers/block/sunvdc.c
+++ b/drivers/block/sunvdc.c
@@ -153,7 +153,7 @@ static int vdc_send_attr(struct vio_driver_state *vio)
153 pkt.vdisk_block_size = port->vdisk_block_size; 153 pkt.vdisk_block_size = port->vdisk_block_size;
154 pkt.max_xfer_size = port->max_xfer_size; 154 pkt.max_xfer_size = port->max_xfer_size;
155 155
156 viodbg(HS, "SEND ATTR xfer_mode[0x%x] blksz[%u] max_xfer[%lu]\n", 156 viodbg(HS, "SEND ATTR xfer_mode[0x%x] blksz[%u] max_xfer[%llu]\n",
157 pkt.xfer_mode, pkt.vdisk_block_size, pkt.max_xfer_size); 157 pkt.xfer_mode, pkt.vdisk_block_size, pkt.max_xfer_size);
158 158
159 return vio_ldc_send(&port->vio, &pkt, sizeof(pkt)); 159 return vio_ldc_send(&port->vio, &pkt, sizeof(pkt));
@@ -164,8 +164,8 @@ static int vdc_handle_attr(struct vio_driver_state *vio, void *arg)
164 struct vdc_port *port = to_vdc_port(vio); 164 struct vdc_port *port = to_vdc_port(vio);
165 struct vio_disk_attr_info *pkt = arg; 165 struct vio_disk_attr_info *pkt = arg;
166 166
167 viodbg(HS, "GOT ATTR stype[0x%x] ops[%lx] disk_size[%lu] disk_type[%x] " 167 viodbg(HS, "GOT ATTR stype[0x%x] ops[%llx] disk_size[%llu] disk_type[%x] "
168 "xfer_mode[0x%x] blksz[%u] max_xfer[%lu]\n", 168 "xfer_mode[0x%x] blksz[%u] max_xfer[%llu]\n",
169 pkt->tag.stype, pkt->operations, 169 pkt->tag.stype, pkt->operations,
170 pkt->vdisk_size, pkt->vdisk_type, 170 pkt->vdisk_size, pkt->vdisk_type,
171 pkt->xfer_mode, pkt->vdisk_block_size, 171 pkt->xfer_mode, pkt->vdisk_block_size,
@@ -753,7 +753,7 @@ static int __devinit vdc_port_probe(struct vio_dev *vdev,
753 753
754 err = -ENODEV; 754 err = -ENODEV;
755 if ((vdev->dev_no << PARTITION_SHIFT) & ~(u64)MINORMASK) { 755 if ((vdev->dev_no << PARTITION_SHIFT) & ~(u64)MINORMASK) {
756 printk(KERN_ERR PFX "Port id [%lu] too large.\n", 756 printk(KERN_ERR PFX "Port id [%llu] too large.\n",
757 vdev->dev_no); 757 vdev->dev_no);
758 goto err_out_release_mdesc; 758 goto err_out_release_mdesc;
759 } 759 }
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index 048d71d244d7..12fb816db7b0 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -1579,7 +1579,7 @@ static void ub_reset_task(struct work_struct *work)
1579 struct ub_dev *sc = container_of(work, struct ub_dev, reset_work); 1579 struct ub_dev *sc = container_of(work, struct ub_dev, reset_work);
1580 unsigned long flags; 1580 unsigned long flags;
1581 struct ub_lun *lun; 1581 struct ub_lun *lun;
1582 int lkr, rc; 1582 int rc;
1583 1583
1584 if (!sc->reset) { 1584 if (!sc->reset) {
1585 printk(KERN_WARNING "%s: Running reset unrequested\n", 1585 printk(KERN_WARNING "%s: Running reset unrequested\n",
@@ -1597,10 +1597,11 @@ static void ub_reset_task(struct work_struct *work)
1597 } else if (sc->dev->actconfig->desc.bNumInterfaces != 1) { 1597 } else if (sc->dev->actconfig->desc.bNumInterfaces != 1) {
1598 ; 1598 ;
1599 } else { 1599 } else {
1600 if ((lkr = usb_lock_device_for_reset(sc->dev, sc->intf)) < 0) { 1600 rc = usb_lock_device_for_reset(sc->dev, sc->intf);
1601 if (rc < 0) {
1601 printk(KERN_NOTICE 1602 printk(KERN_NOTICE
1602 "%s: usb_lock_device_for_reset failed (%d)\n", 1603 "%s: usb_lock_device_for_reset failed (%d)\n",
1603 sc->name, lkr); 1604 sc->name, rc);
1604 } else { 1605 } else {
1605 rc = usb_reset_device(sc->dev); 1606 rc = usb_reset_device(sc->dev);
1606 if (rc < 0) { 1607 if (rc < 0) {
@@ -1608,9 +1609,7 @@ static void ub_reset_task(struct work_struct *work)
1608 "usb_lock_device_for_reset failed (%d)\n", 1609 "usb_lock_device_for_reset failed (%d)\n",
1609 sc->name, rc); 1610 sc->name, rc);
1610 } 1611 }
1611 1612 usb_unlock_device(sc->dev);
1612 if (lkr)
1613 usb_unlock_device(sc->dev);
1614 } 1613 }
1615 } 1614 }
1616 1615
diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
index 29e1dfafb7c6..381d686fc1a3 100644
--- a/drivers/block/xsysace.c
+++ b/drivers/block/xsysace.c
@@ -1206,6 +1206,7 @@ static struct of_device_id ace_of_match[] __devinitdata = {
1206 { .compatible = "xlnx,opb-sysace-1.00.b", }, 1206 { .compatible = "xlnx,opb-sysace-1.00.b", },
1207 { .compatible = "xlnx,opb-sysace-1.00.c", }, 1207 { .compatible = "xlnx,opb-sysace-1.00.c", },
1208 { .compatible = "xlnx,xps-sysace-1.00.a", }, 1208 { .compatible = "xlnx,xps-sysace-1.00.a", },
1209 { .compatible = "xlnx,sysace", },
1209 {}, 1210 {},
1210}; 1211};
1211MODULE_DEVICE_TABLE(of, ace_of_match); 1212MODULE_DEVICE_TABLE(of, ace_of_match);
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 35914b6e1d2a..f5be8081cd81 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -616,6 +616,7 @@ config HVC_ISERIES
616 default y 616 default y
617 select HVC_DRIVER 617 select HVC_DRIVER
618 select HVC_IRQ 618 select HVC_IRQ
619 select VIOPATH
619 help 620 help
620 iSeries machines support a hypervisor virtual console. 621 iSeries machines support a hypervisor virtual console.
621 622
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c
index 4e0cfdeab146..a58869ea8513 100644
--- a/drivers/char/amiserial.c
+++ b/drivers/char/amiserial.c
@@ -1963,6 +1963,7 @@ static int __init rs_init(void)
1963{ 1963{
1964 unsigned long flags; 1964 unsigned long flags;
1965 struct serial_state * state; 1965 struct serial_state * state;
1966 int error;
1966 1967
1967 if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(AMI_SERIAL)) 1968 if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(AMI_SERIAL))
1968 return -ENODEV; 1969 return -ENODEV;
@@ -1975,8 +1976,11 @@ static int __init rs_init(void)
1975 * We request SERDAT and SERPER only, because the serial registers are 1976 * We request SERDAT and SERPER only, because the serial registers are
1976 * too spreaded over the custom register space 1977 * too spreaded over the custom register space
1977 */ 1978 */
1978 if (!request_mem_region(CUSTOM_PHYSADDR+0x30, 4, "amiserial [Paula]")) 1979 if (!request_mem_region(CUSTOM_PHYSADDR+0x30, 4,
1979 return -EBUSY; 1980 "amiserial [Paula]")) {
1981 error = -EBUSY;
1982 goto fail_put_tty_driver;
1983 }
1980 1984
1981 IRQ_ports = NULL; 1985 IRQ_ports = NULL;
1982 1986
@@ -1997,8 +2001,9 @@ static int __init rs_init(void)
1997 serial_driver->flags = TTY_DRIVER_REAL_RAW; 2001 serial_driver->flags = TTY_DRIVER_REAL_RAW;
1998 tty_set_operations(serial_driver, &serial_ops); 2002 tty_set_operations(serial_driver, &serial_ops);
1999 2003
2000 if (tty_register_driver(serial_driver)) 2004 error = tty_register_driver(serial_driver);
2001 panic("Couldn't register serial driver\n"); 2005 if (error)
2006 goto fail_release_mem_region;
2002 2007
2003 state = rs_table; 2008 state = rs_table;
2004 state->magic = SSTATE_MAGIC; 2009 state->magic = SSTATE_MAGIC;
@@ -2024,8 +2029,14 @@ static int __init rs_init(void)
2024 local_irq_save(flags); 2029 local_irq_save(flags);
2025 2030
2026 /* set ISRs, and then disable the rx interrupts */ 2031 /* set ISRs, and then disable the rx interrupts */
2027 request_irq(IRQ_AMIGA_TBE, ser_tx_int, 0, "serial TX", state); 2032 error = request_irq(IRQ_AMIGA_TBE, ser_tx_int, 0, "serial TX", state);
2028 request_irq(IRQ_AMIGA_RBF, ser_rx_int, IRQF_DISABLED, "serial RX", state); 2033 if (error)
2034 goto fail_unregister;
2035
2036 error = request_irq(IRQ_AMIGA_RBF, ser_rx_int, IRQF_DISABLED,
2037 "serial RX", state);
2038 if (error)
2039 goto fail_free_irq;
2029 2040
2030 /* turn off Rx and Tx interrupts */ 2041 /* turn off Rx and Tx interrupts */
2031 custom.intena = IF_RBF | IF_TBE; 2042 custom.intena = IF_RBF | IF_TBE;
@@ -2045,6 +2056,16 @@ static int __init rs_init(void)
2045 ciab.ddra &= ~(SER_DCD | SER_CTS | SER_DSR); /* inputs */ 2056 ciab.ddra &= ~(SER_DCD | SER_CTS | SER_DSR); /* inputs */
2046 2057
2047 return 0; 2058 return 0;
2059
2060fail_free_irq:
2061 free_irq(IRQ_AMIGA_TBE, state);
2062fail_unregister:
2063 tty_unregister_driver(serial_driver);
2064fail_release_mem_region:
2065 release_mem_region(CUSTOM_PHYSADDR+0x30, 4);
2066fail_put_tty_driver:
2067 put_tty_driver(serial_driver);
2068 return error;
2048} 2069}
2049 2070
2050static __exit void rs_exit(void) 2071static __exit void rs_exit(void)
@@ -2064,6 +2085,9 @@ static __exit void rs_exit(void)
2064 kfree(info); 2085 kfree(info);
2065 } 2086 }
2066 2087
2088 free_irq(IRQ_AMIGA_TBE, rs_table);
2089 free_irq(IRQ_AMIGA_RBF, rs_table);
2090
2067 release_mem_region(CUSTOM_PHYSADDR+0x30, 4); 2091 release_mem_region(CUSTOM_PHYSADDR+0x30, 4);
2068} 2092}
2069 2093
diff --git a/drivers/char/bsr.c b/drivers/char/bsr.c
index 977dfb1096a0..f6094ae0ef33 100644
--- a/drivers/char/bsr.c
+++ b/drivers/char/bsr.c
@@ -103,7 +103,7 @@ static ssize_t
103bsr_len_show(struct device *dev, struct device_attribute *attr, char *buf) 103bsr_len_show(struct device *dev, struct device_attribute *attr, char *buf)
104{ 104{
105 struct bsr_dev *bsr_dev = dev_get_drvdata(dev); 105 struct bsr_dev *bsr_dev = dev_get_drvdata(dev);
106 return sprintf(buf, "%lu\n", bsr_dev->bsr_len); 106 return sprintf(buf, "%llu\n", bsr_dev->bsr_len);
107} 107}
108 108
109static struct device_attribute bsr_dev_attrs[] = { 109static struct device_attribute bsr_dev_attrs[] = {
diff --git a/drivers/char/epca.c b/drivers/char/epca.c
index 39ad820b2350..af7c13ca9493 100644
--- a/drivers/char/epca.c
+++ b/drivers/char/epca.c
@@ -769,7 +769,7 @@ static int pc_open(struct tty_struct *tty, struct file *filp)
769 /* Check status of board configured in system. */ 769 /* Check status of board configured in system. */
770 770
771 /* 771 /*
772 * I check to see if the epca_setup routine detected an user error. It 772 * I check to see if the epca_setup routine detected a user error. It
773 * might be better to put this in pc_init, but for the moment it goes 773 * might be better to put this in pc_init, but for the moment it goes
774 * here. 774 * here.
775 */ 775 */
diff --git a/drivers/char/hvc_beat.c b/drivers/char/hvc_beat.c
index 91cdb35a9204..0afc8b82212e 100644
--- a/drivers/char/hvc_beat.c
+++ b/drivers/char/hvc_beat.c
@@ -44,7 +44,7 @@ static int hvc_beat_get_chars(uint32_t vtermno, char *buf, int cnt)
44 static unsigned char q[sizeof(unsigned long) * 2] 44 static unsigned char q[sizeof(unsigned long) * 2]
45 __attribute__((aligned(sizeof(unsigned long)))); 45 __attribute__((aligned(sizeof(unsigned long))));
46 static int qlen = 0; 46 static int qlen = 0;
47 unsigned long got; 47 u64 got;
48 48
49again: 49again:
50 if (qlen) { 50 if (qlen) {
@@ -63,7 +63,7 @@ again:
63 } 63 }
64 } 64 }
65 if (beat_get_term_char(vtermno, &got, 65 if (beat_get_term_char(vtermno, &got,
66 ((unsigned long *)q), ((unsigned long *)q) + 1) == 0) { 66 ((u64 *)q), ((u64 *)q) + 1) == 0) {
67 qlen = got; 67 qlen = got;
68 goto again; 68 goto again;
69 } 69 }
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index 5a8a4c28c867..94e7e3c8c05a 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -318,7 +318,6 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
318 } /* else count == 0 */ 318 } /* else count == 0 */
319 319
320 tty->driver_data = hp; 320 tty->driver_data = hp;
321 tty->low_latency = 1; /* Makes flushes to ldisc synchronous. */
322 321
323 hp->tty = tty; 322 hp->tty = tty;
324 323
@@ -764,13 +763,11 @@ struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int data,
764 return ERR_PTR(err); 763 return ERR_PTR(err);
765 } 764 }
766 765
767 hp = kmalloc(ALIGN(sizeof(*hp), sizeof(long)) + outbuf_size, 766 hp = kzalloc(ALIGN(sizeof(*hp), sizeof(long)) + outbuf_size,
768 GFP_KERNEL); 767 GFP_KERNEL);
769 if (!hp) 768 if (!hp)
770 return ERR_PTR(-ENOMEM); 769 return ERR_PTR(-ENOMEM);
771 770
772 memset(hp, 0x00, sizeof(*hp));
773
774 hp->vtermno = vtermno; 771 hp->vtermno = vtermno;
775 hp->data = data; 772 hp->data = data;
776 hp->ops = ops; 773 hp->ops = ops;
@@ -876,8 +873,11 @@ static int hvc_init(void)
876 goto stop_thread; 873 goto stop_thread;
877 } 874 }
878 875
879 /* FIXME: This mb() seems completely random. Remove it. */ 876 /*
880 mb(); 877 * Make sure tty is fully registered before allowing it to be
878 * found by hvc_console_device.
879 */
880 smp_mb();
881 hvc_driver = drv; 881 hvc_driver = drv;
882 return 0; 882 return 0;
883 883
diff --git a/drivers/char/hvc_irq.c b/drivers/char/hvc_irq.c
index d09e5688d449..2623e177e8d6 100644
--- a/drivers/char/hvc_irq.c
+++ b/drivers/char/hvc_irq.c
@@ -37,7 +37,7 @@ int notifier_add_irq(struct hvc_struct *hp, int irq)
37 37
38void notifier_del_irq(struct hvc_struct *hp, int irq) 38void notifier_del_irq(struct hvc_struct *hp, int irq)
39{ 39{
40 if (!irq) 40 if (!hp->irq_requested)
41 return; 41 return;
42 free_irq(irq, hp); 42 free_irq(irq, hp);
43 hp->irq_requested = 0; 43 hp->irq_requested = 0;
diff --git a/drivers/char/hvc_iucv.c b/drivers/char/hvc_iucv.c
index 5ea7d7713fca..a53496828b76 100644
--- a/drivers/char/hvc_iucv.c
+++ b/drivers/char/hvc_iucv.c
@@ -1,26 +1,30 @@
1/* 1/*
2 * hvc_iucv.c - z/VM IUCV back-end for the Hypervisor Console (HVC) 2 * hvc_iucv.c - z/VM IUCV hypervisor console (HVC) device driver
3 * 3 *
4 * This back-end for HVC provides terminal access via 4 * This HVC device driver provides terminal access using
5 * z/VM IUCV communication paths. 5 * z/VM IUCV communication paths.
6 * 6 *
7 * Copyright IBM Corp. 2008. 7 * Copyright IBM Corp. 2008
8 * 8 *
9 * Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com> 9 * Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
10 */ 10 */
11#define KMSG_COMPONENT "hvc_iucv" 11#define KMSG_COMPONENT "hvc_iucv"
12#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
12 13
13#include <linux/types.h> 14#include <linux/types.h>
14#include <asm/ebcdic.h> 15#include <asm/ebcdic.h>
16#include <linux/delay.h>
17#include <linux/init.h>
15#include <linux/mempool.h> 18#include <linux/mempool.h>
16#include <linux/module.h> 19#include <linux/module.h>
17#include <linux/tty.h> 20#include <linux/tty.h>
21#include <linux/wait.h>
18#include <net/iucv/iucv.h> 22#include <net/iucv/iucv.h>
19 23
20#include "hvc_console.h" 24#include "hvc_console.h"
21 25
22 26
23/* HVC backend for z/VM IUCV */ 27/* General device driver settings */
24#define HVC_IUCV_MAGIC 0xc9e4c3e5 28#define HVC_IUCV_MAGIC 0xc9e4c3e5
25#define MAX_HVC_IUCV_LINES HVC_ALLOC_TTY_ADAPTERS 29#define MAX_HVC_IUCV_LINES HVC_ALLOC_TTY_ADAPTERS
26#define MEMPOOL_MIN_NR (PAGE_SIZE / sizeof(struct iucv_tty_buffer)/4) 30#define MEMPOOL_MIN_NR (PAGE_SIZE / sizeof(struct iucv_tty_buffer)/4)
@@ -33,14 +37,14 @@
33#define MSG_TYPE_WINSIZE 0x08 /* Terminal window size update */ 37#define MSG_TYPE_WINSIZE 0x08 /* Terminal window size update */
34#define MSG_TYPE_DATA 0x10 /* Terminal data */ 38#define MSG_TYPE_DATA 0x10 /* Terminal data */
35 39
36#define MSG_SIZE(s) ((s) + offsetof(struct iucv_tty_msg, data))
37struct iucv_tty_msg { 40struct iucv_tty_msg {
38 u8 version; /* Message version */ 41 u8 version; /* Message version */
39 u8 type; /* Message type */ 42 u8 type; /* Message type */
40#define MSG_MAX_DATALEN (~(u16)0) 43#define MSG_MAX_DATALEN ((u16)(~0))
41 u16 datalen; /* Payload length */ 44 u16 datalen; /* Payload length */
42 u8 data[]; /* Payload buffer */ 45 u8 data[]; /* Payload buffer */
43} __attribute__((packed)); 46} __attribute__((packed));
47#define MSG_SIZE(s) ((s) + offsetof(struct iucv_tty_msg, data))
44 48
45enum iucv_state_t { 49enum iucv_state_t {
46 IUCV_DISCONN = 0, 50 IUCV_DISCONN = 0,
@@ -54,19 +58,26 @@ enum tty_state_t {
54}; 58};
55 59
56struct hvc_iucv_private { 60struct hvc_iucv_private {
57 struct hvc_struct *hvc; /* HVC console struct reference */ 61 struct hvc_struct *hvc; /* HVC struct reference */
58 u8 srv_name[8]; /* IUCV service name (ebcdic) */ 62 u8 srv_name[8]; /* IUCV service name (ebcdic) */
63 unsigned char is_console; /* Linux console usage flag */
59 enum iucv_state_t iucv_state; /* IUCV connection status */ 64 enum iucv_state_t iucv_state; /* IUCV connection status */
60 enum tty_state_t tty_state; /* TTY status */ 65 enum tty_state_t tty_state; /* TTY status */
61 struct iucv_path *path; /* IUCV path pointer */ 66 struct iucv_path *path; /* IUCV path pointer */
62 spinlock_t lock; /* hvc_iucv_private lock */ 67 spinlock_t lock; /* hvc_iucv_private lock */
68#define SNDBUF_SIZE (PAGE_SIZE) /* must be < MSG_MAX_DATALEN */
69 void *sndbuf; /* send buffer */
70 size_t sndbuf_len; /* length of send buffer */
71#define QUEUE_SNDBUF_DELAY (HZ / 25)
72 struct delayed_work sndbuf_work; /* work: send iucv msg(s) */
73 wait_queue_head_t sndbuf_waitq; /* wait for send completion */
63 struct list_head tty_outqueue; /* outgoing IUCV messages */ 74 struct list_head tty_outqueue; /* outgoing IUCV messages */
64 struct list_head tty_inqueue; /* incoming IUCV messages */ 75 struct list_head tty_inqueue; /* incoming IUCV messages */
65}; 76};
66 77
67struct iucv_tty_buffer { 78struct iucv_tty_buffer {
68 struct list_head list; /* list pointer */ 79 struct list_head list; /* list pointer */
69 struct iucv_message msg; /* store an incoming IUCV message */ 80 struct iucv_message msg; /* store an IUCV message */
70 size_t offset; /* data buffer offset */ 81 size_t offset; /* data buffer offset */
71 struct iucv_tty_msg *mbuf; /* buffer to store input/output data */ 82 struct iucv_tty_msg *mbuf; /* buffer to store input/output data */
72}; 83};
@@ -78,11 +89,12 @@ static void hvc_iucv_msg_pending(struct iucv_path *, struct iucv_message *);
78static void hvc_iucv_msg_complete(struct iucv_path *, struct iucv_message *); 89static void hvc_iucv_msg_complete(struct iucv_path *, struct iucv_message *);
79 90
80 91
81/* Kernel module parameters */ 92/* Kernel module parameter: use one terminal device as default */
82static unsigned long hvc_iucv_devices; 93static unsigned long hvc_iucv_devices = 1;
83 94
84/* Array of allocated hvc iucv tty lines... */ 95/* Array of allocated hvc iucv tty lines... */
85static struct hvc_iucv_private *hvc_iucv_table[MAX_HVC_IUCV_LINES]; 96static struct hvc_iucv_private *hvc_iucv_table[MAX_HVC_IUCV_LINES];
97#define IUCV_HVC_CON_IDX (0)
86 98
87/* Kmem cache and mempool for iucv_tty_buffer elements */ 99/* Kmem cache and mempool for iucv_tty_buffer elements */
88static struct kmem_cache *hvc_iucv_buffer_cache; 100static struct kmem_cache *hvc_iucv_buffer_cache;
@@ -112,7 +124,7 @@ struct hvc_iucv_private *hvc_iucv_get_private(uint32_t num)
112} 124}
113 125
114/** 126/**
115 * alloc_tty_buffer() - Returns a new struct iucv_tty_buffer element. 127 * alloc_tty_buffer() - Return a new struct iucv_tty_buffer element.
116 * @size: Size of the internal buffer used to store data. 128 * @size: Size of the internal buffer used to store data.
117 * @flags: Memory allocation flags passed to mempool. 129 * @flags: Memory allocation flags passed to mempool.
118 * 130 *
@@ -120,7 +132,6 @@ struct hvc_iucv_private *hvc_iucv_get_private(uint32_t num)
120 * allocates an internal data buffer with the specified size @size. 132 * allocates an internal data buffer with the specified size @size.
121 * Note: The total message size arises from the internal buffer size and the 133 * Note: The total message size arises from the internal buffer size and the
122 * members of the iucv_tty_msg structure. 134 * members of the iucv_tty_msg structure.
123 *
124 * The function returns NULL if memory allocation has failed. 135 * The function returns NULL if memory allocation has failed.
125 */ 136 */
126static struct iucv_tty_buffer *alloc_tty_buffer(size_t size, gfp_t flags) 137static struct iucv_tty_buffer *alloc_tty_buffer(size_t size, gfp_t flags)
@@ -130,7 +141,7 @@ static struct iucv_tty_buffer *alloc_tty_buffer(size_t size, gfp_t flags)
130 bufp = mempool_alloc(hvc_iucv_mempool, flags); 141 bufp = mempool_alloc(hvc_iucv_mempool, flags);
131 if (!bufp) 142 if (!bufp)
132 return NULL; 143 return NULL;
133 memset(bufp, 0, sizeof(struct iucv_tty_buffer)); 144 memset(bufp, 0, sizeof(*bufp));
134 145
135 if (size > 0) { 146 if (size > 0) {
136 bufp->msg.length = MSG_SIZE(size); 147 bufp->msg.length = MSG_SIZE(size);
@@ -149,9 +160,6 @@ static struct iucv_tty_buffer *alloc_tty_buffer(size_t size, gfp_t flags)
149/** 160/**
150 * destroy_tty_buffer() - destroy struct iucv_tty_buffer element. 161 * destroy_tty_buffer() - destroy struct iucv_tty_buffer element.
151 * @bufp: Pointer to a struct iucv_tty_buffer element, SHALL NOT be NULL. 162 * @bufp: Pointer to a struct iucv_tty_buffer element, SHALL NOT be NULL.
152 *
153 * The destroy_tty_buffer() function frees the internal data buffer and returns
154 * the struct iucv_tty_buffer element back to the mempool for freeing.
155 */ 163 */
156static void destroy_tty_buffer(struct iucv_tty_buffer *bufp) 164static void destroy_tty_buffer(struct iucv_tty_buffer *bufp)
157{ 165{
@@ -161,11 +169,7 @@ static void destroy_tty_buffer(struct iucv_tty_buffer *bufp)
161 169
162/** 170/**
163 * destroy_tty_buffer_list() - call destroy_tty_buffer() for each list element. 171 * destroy_tty_buffer_list() - call destroy_tty_buffer() for each list element.
164 * @list: List head pointer to a list containing struct iucv_tty_buffer 172 * @list: List containing struct iucv_tty_buffer elements.
165 * elements.
166 *
167 * Calls destroy_tty_buffer() for each struct iucv_tty_buffer element in the
168 * list @list.
169 */ 173 */
170static void destroy_tty_buffer_list(struct list_head *list) 174static void destroy_tty_buffer_list(struct list_head *list)
171{ 175{
@@ -178,24 +182,24 @@ static void destroy_tty_buffer_list(struct list_head *list)
178} 182}
179 183
180/** 184/**
181 * hvc_iucv_write() - Receive IUCV message write data to HVC console buffer. 185 * hvc_iucv_write() - Receive IUCV message & write data to HVC buffer.
182 * @priv: Pointer to hvc_iucv_private structure. 186 * @priv: Pointer to struct hvc_iucv_private
183 * @buf: HVC console buffer for writing received terminal data. 187 * @buf: HVC buffer for writing received terminal data.
184 * @count: HVC console buffer size. 188 * @count: HVC buffer size.
185 * @has_more_data: Pointer to an int variable. 189 * @has_more_data: Pointer to an int variable.
186 * 190 *
187 * The function picks up pending messages from the input queue and receives 191 * The function picks up pending messages from the input queue and receives
188 * the message data that is then written to the specified buffer @buf. 192 * the message data that is then written to the specified buffer @buf.
189 * If the buffer size @count is less than the data message size, then the 193 * If the buffer size @count is less than the data message size, the
190 * message is kept on the input queue and @has_more_data is set to 1. 194 * message is kept on the input queue and @has_more_data is set to 1.
191 * If the message data has been entirely written, the message is removed from 195 * If all message data has been written, the message is removed from
192 * the input queue. 196 * the input queue.
193 * 197 *
194 * The function returns the number of bytes written to the terminal, zero if 198 * The function returns the number of bytes written to the terminal, zero if
195 * there are no pending data messages available or if there is no established 199 * there are no pending data messages available or if there is no established
196 * IUCV path. 200 * IUCV path.
197 * If the IUCV path has been severed, then -EPIPE is returned to cause a 201 * If the IUCV path has been severed, then -EPIPE is returned to cause a
198 * hang up (that is issued by the HVC console layer). 202 * hang up (that is issued by the HVC layer).
199 */ 203 */
200static int hvc_iucv_write(struct hvc_iucv_private *priv, 204static int hvc_iucv_write(struct hvc_iucv_private *priv,
201 char *buf, int count, int *has_more_data) 205 char *buf, int count, int *has_more_data)
@@ -204,12 +208,12 @@ static int hvc_iucv_write(struct hvc_iucv_private *priv,
204 int written; 208 int written;
205 int rc; 209 int rc;
206 210
207 /* Immediately return if there is no IUCV connection */ 211 /* immediately return if there is no IUCV connection */
208 if (priv->iucv_state == IUCV_DISCONN) 212 if (priv->iucv_state == IUCV_DISCONN)
209 return 0; 213 return 0;
210 214
211 /* If the IUCV path has been severed, return -EPIPE to inform the 215 /* if the IUCV path has been severed, return -EPIPE to inform the
212 * hvc console layer to hang up the tty device. */ 216 * HVC layer to hang up the tty device. */
213 if (priv->iucv_state == IUCV_SEVERED) 217 if (priv->iucv_state == IUCV_SEVERED)
214 return -EPIPE; 218 return -EPIPE;
215 219
@@ -217,7 +221,7 @@ static int hvc_iucv_write(struct hvc_iucv_private *priv,
217 if (list_empty(&priv->tty_inqueue)) 221 if (list_empty(&priv->tty_inqueue))
218 return 0; 222 return 0;
219 223
220 /* receive a iucv message and flip data to the tty (ldisc) */ 224 /* receive an iucv message and flip data to the tty (ldisc) */
221 rb = list_first_entry(&priv->tty_inqueue, struct iucv_tty_buffer, list); 225 rb = list_first_entry(&priv->tty_inqueue, struct iucv_tty_buffer, list);
222 226
223 written = 0; 227 written = 0;
@@ -260,7 +264,7 @@ static int hvc_iucv_write(struct hvc_iucv_private *priv,
260 case MSG_TYPE_WINSIZE: 264 case MSG_TYPE_WINSIZE:
261 if (rb->mbuf->datalen != sizeof(struct winsize)) 265 if (rb->mbuf->datalen != sizeof(struct winsize))
262 break; 266 break;
263 hvc_resize(priv->hvc, *((struct winsize *)rb->mbuf->data)); 267 hvc_resize(priv->hvc, *((struct winsize *) rb->mbuf->data));
264 break; 268 break;
265 269
266 case MSG_TYPE_ERROR: /* ignored ... */ 270 case MSG_TYPE_ERROR: /* ignored ... */
@@ -284,10 +288,9 @@ out_written:
284 * @buf: Pointer to a buffer to store data 288 * @buf: Pointer to a buffer to store data
285 * @count: Size of buffer available for writing 289 * @count: Size of buffer available for writing
286 * 290 *
287 * The hvc_console thread calls this method to read characters from 291 * The HVC thread calls this method to read characters from the back-end.
288 * the terminal backend. If an IUCV communication path has been established, 292 * If an IUCV communication path has been established, pending IUCV messages
289 * pending IUCV messages are received and data is copied into buffer @buf 293 * are received and data is copied into buffer @buf up to @count bytes.
290 * up to @count bytes.
291 * 294 *
292 * Locking: The routine gets called under an irqsave() spinlock; and 295 * Locking: The routine gets called under an irqsave() spinlock; and
293 * the routine locks the struct hvc_iucv_private->lock to call 296 * the routine locks the struct hvc_iucv_private->lock to call
@@ -318,66 +321,122 @@ static int hvc_iucv_get_chars(uint32_t vtermno, char *buf, int count)
318} 321}
319 322
320/** 323/**
321 * hvc_iucv_send() - Send an IUCV message containing terminal data. 324 * hvc_iucv_queue() - Buffer terminal data for sending.
322 * @priv: Pointer to struct hvc_iucv_private instance. 325 * @priv: Pointer to struct hvc_iucv_private instance.
323 * @buf: Buffer containing data to send. 326 * @buf: Buffer containing data to send.
324 * @size: Size of buffer and amount of data to send. 327 * @count: Size of buffer and amount of data to send.
328 *
329 * The function queues data for sending. To actually send the buffered data,
330 * a work queue function is scheduled (with QUEUE_SNDBUF_DELAY).
331 * The function returns the number of data bytes that has been buffered.
325 * 332 *
326 * If an IUCV communication path is established, the function copies the buffer 333 * If the device is not connected, data is ignored and the function returns
327 * data to a newly allocated struct iucv_tty_buffer element, sends the data and 334 * @count.
328 * puts the element to the outqueue. 335 * If the buffer is full, the function returns 0.
336 * If an existing IUCV communicaton path has been severed, -EPIPE is returned
337 * (that can be passed to HVC layer to cause a tty hangup).
338 */
339static int hvc_iucv_queue(struct hvc_iucv_private *priv, const char *buf,
340 int count)
341{
342 size_t len;
343
344 if (priv->iucv_state == IUCV_DISCONN)
345 return count; /* ignore data */
346
347 if (priv->iucv_state == IUCV_SEVERED)
348 return -EPIPE;
349
350 len = min_t(size_t, count, SNDBUF_SIZE - priv->sndbuf_len);
351 if (!len)
352 return 0;
353
354 memcpy(priv->sndbuf + priv->sndbuf_len, buf, len);
355 priv->sndbuf_len += len;
356
357 if (priv->iucv_state == IUCV_CONNECTED)
358 schedule_delayed_work(&priv->sndbuf_work, QUEUE_SNDBUF_DELAY);
359
360 return len;
361}
362
363/**
364 * hvc_iucv_send() - Send an IUCV message containing terminal data.
365 * @priv: Pointer to struct hvc_iucv_private instance.
329 * 366 *
330 * If there is no IUCV communication path established, the function returns 0. 367 * If an IUCV communication path has been established, the buffered output data
331 * If an existing IUCV communicaton path has been severed, the function returns 368 * is sent via an IUCV message and the number of bytes sent is returned.
332 * -EPIPE (can be passed to HVC layer to cause a tty hangup). 369 * Returns 0 if there is no established IUCV communication path or
370 * -EPIPE if an existing IUCV communicaton path has been severed.
333 */ 371 */
334static int hvc_iucv_send(struct hvc_iucv_private *priv, const char *buf, 372static int hvc_iucv_send(struct hvc_iucv_private *priv)
335 int count)
336{ 373{
337 struct iucv_tty_buffer *sb; 374 struct iucv_tty_buffer *sb;
338 int rc; 375 int rc, len;
339 u16 len;
340 376
341 if (priv->iucv_state == IUCV_SEVERED) 377 if (priv->iucv_state == IUCV_SEVERED)
342 return -EPIPE; 378 return -EPIPE;
343 379
344 if (priv->iucv_state == IUCV_DISCONN) 380 if (priv->iucv_state == IUCV_DISCONN)
345 return 0; 381 return -EIO;
346 382
347 len = min_t(u16, MSG_MAX_DATALEN, count); 383 if (!priv->sndbuf_len)
384 return 0;
348 385
349 /* allocate internal buffer to store msg data and also compute total 386 /* allocate internal buffer to store msg data and also compute total
350 * message length */ 387 * message length */
351 sb = alloc_tty_buffer(len, GFP_ATOMIC); 388 sb = alloc_tty_buffer(priv->sndbuf_len, GFP_ATOMIC);
352 if (!sb) 389 if (!sb)
353 return -ENOMEM; 390 return -ENOMEM;
354 391
355 sb->mbuf->datalen = len; 392 memcpy(sb->mbuf->data, priv->sndbuf, priv->sndbuf_len);
356 memcpy(sb->mbuf->data, buf, len); 393 sb->mbuf->datalen = (u16) priv->sndbuf_len;
394 sb->msg.length = MSG_SIZE(sb->mbuf->datalen);
357 395
358 list_add_tail(&sb->list, &priv->tty_outqueue); 396 list_add_tail(&sb->list, &priv->tty_outqueue);
359 397
360 rc = __iucv_message_send(priv->path, &sb->msg, 0, 0, 398 rc = __iucv_message_send(priv->path, &sb->msg, 0, 0,
361 (void *) sb->mbuf, sb->msg.length); 399 (void *) sb->mbuf, sb->msg.length);
362 if (rc) { 400 if (rc) {
401 /* drop the message here; however we might want to handle
402 * 0x03 (msg limit reached) by trying again... */
363 list_del(&sb->list); 403 list_del(&sb->list);
364 destroy_tty_buffer(sb); 404 destroy_tty_buffer(sb);
365 len = 0;
366 } 405 }
406 len = priv->sndbuf_len;
407 priv->sndbuf_len = 0;
367 408
368 return len; 409 return len;
369} 410}
370 411
371/** 412/**
413 * hvc_iucv_sndbuf_work() - Send buffered data over IUCV
414 * @work: Work structure.
415 *
416 * This work queue function sends buffered output data over IUCV and,
417 * if not all buffered data could be sent, reschedules itself.
418 */
419static void hvc_iucv_sndbuf_work(struct work_struct *work)
420{
421 struct hvc_iucv_private *priv;
422
423 priv = container_of(work, struct hvc_iucv_private, sndbuf_work.work);
424 if (!priv)
425 return;
426
427 spin_lock_bh(&priv->lock);
428 hvc_iucv_send(priv);
429 spin_unlock_bh(&priv->lock);
430}
431
432/**
372 * hvc_iucv_put_chars() - HVC put_chars operation. 433 * hvc_iucv_put_chars() - HVC put_chars operation.
373 * @vtermno: HVC virtual terminal number. 434 * @vtermno: HVC virtual terminal number.
374 * @buf: Pointer to an buffer to read data from 435 * @buf: Pointer to an buffer to read data from
375 * @count: Size of buffer available for reading 436 * @count: Size of buffer available for reading
376 * 437 *
377 * The hvc_console thread calls this method to write characters from 438 * The HVC thread calls this method to write characters to the back-end.
378 * to the terminal backend. 439 * The function calls hvc_iucv_queue() to queue terminal data for sending.
379 * The function calls hvc_iucv_send() under the lock of the
380 * struct hvc_iucv_private instance that corresponds to the tty @vtermno.
381 * 440 *
382 * Locking: The method gets called under an irqsave() spinlock; and 441 * Locking: The method gets called under an irqsave() spinlock; and
383 * locks struct hvc_iucv_private->lock. 442 * locks struct hvc_iucv_private->lock.
@@ -385,7 +444,7 @@ static int hvc_iucv_send(struct hvc_iucv_private *priv, const char *buf,
385static int hvc_iucv_put_chars(uint32_t vtermno, const char *buf, int count) 444static int hvc_iucv_put_chars(uint32_t vtermno, const char *buf, int count)
386{ 445{
387 struct hvc_iucv_private *priv = hvc_iucv_get_private(vtermno); 446 struct hvc_iucv_private *priv = hvc_iucv_get_private(vtermno);
388 int sent; 447 int queued;
389 448
390 if (count <= 0) 449 if (count <= 0)
391 return 0; 450 return 0;
@@ -394,10 +453,10 @@ static int hvc_iucv_put_chars(uint32_t vtermno, const char *buf, int count)
394 return -ENODEV; 453 return -ENODEV;
395 454
396 spin_lock(&priv->lock); 455 spin_lock(&priv->lock);
397 sent = hvc_iucv_send(priv, buf, count); 456 queued = hvc_iucv_queue(priv, buf, count);
398 spin_unlock(&priv->lock); 457 spin_unlock(&priv->lock);
399 458
400 return sent; 459 return queued;
401} 460}
402 461
403/** 462/**
@@ -406,7 +465,7 @@ static int hvc_iucv_put_chars(uint32_t vtermno, const char *buf, int count)
406 * @id: Additional data (originally passed to hvc_alloc): the index of an struct 465 * @id: Additional data (originally passed to hvc_alloc): the index of an struct
407 * hvc_iucv_private instance. 466 * hvc_iucv_private instance.
408 * 467 *
409 * The function sets the tty state to TTY_OPEN for the struct hvc_iucv_private 468 * The function sets the tty state to TTY_OPENED for the struct hvc_iucv_private
410 * instance that is derived from @id. Always returns 0. 469 * instance that is derived from @id. Always returns 0.
411 * 470 *
412 * Locking: struct hvc_iucv_private->lock, spin_lock_bh 471 * Locking: struct hvc_iucv_private->lock, spin_lock_bh
@@ -427,12 +486,8 @@ static int hvc_iucv_notifier_add(struct hvc_struct *hp, int id)
427} 486}
428 487
429/** 488/**
430 * hvc_iucv_cleanup() - Clean up function if the tty portion is finally closed. 489 * hvc_iucv_cleanup() - Clean up and reset a z/VM IUCV HVC instance.
431 * @priv: Pointer to the struct hvc_iucv_private instance. 490 * @priv: Pointer to the struct hvc_iucv_private instance.
432 *
433 * The functions severs the established IUCV communication path (if any), and
434 * destroy struct iucv_tty_buffer elements from the in- and outqueue. Finally,
435 * the functions resets the states to TTY_CLOSED and IUCV_DISCONN.
436 */ 491 */
437static void hvc_iucv_cleanup(struct hvc_iucv_private *priv) 492static void hvc_iucv_cleanup(struct hvc_iucv_private *priv)
438{ 493{
@@ -441,25 +496,62 @@ static void hvc_iucv_cleanup(struct hvc_iucv_private *priv)
441 496
442 priv->tty_state = TTY_CLOSED; 497 priv->tty_state = TTY_CLOSED;
443 priv->iucv_state = IUCV_DISCONN; 498 priv->iucv_state = IUCV_DISCONN;
499
500 priv->sndbuf_len = 0;
444} 501}
445 502
446/** 503/**
447 * hvc_iucv_notifier_hangup() - HVC notifier for tty hangups. 504 * tty_outqueue_empty() - Test if the tty outq is empty
448 * @hp: Pointer to the HVC device (struct hvc_struct) 505 * @priv: Pointer to struct hvc_iucv_private instance.
449 * @id: Additional data (originally passed to hvc_alloc): the index of an struct 506 */
450 * hvc_iucv_private instance. 507static inline int tty_outqueue_empty(struct hvc_iucv_private *priv)
508{
509 int rc;
510
511 spin_lock_bh(&priv->lock);
512 rc = list_empty(&priv->tty_outqueue);
513 spin_unlock_bh(&priv->lock);
514
515 return rc;
516}
517
518/**
519 * flush_sndbuf_sync() - Flush send buffer and wait for completion
520 * @priv: Pointer to struct hvc_iucv_private instance.
451 * 521 *
452 * This routine notifies the HVC backend that a tty hangup (carrier loss, 522 * The routine cancels a pending sndbuf work, calls hvc_iucv_send()
453 * virtual or otherwise) has occured. 523 * to flush any buffered terminal output data and waits for completion.
524 */
525static void flush_sndbuf_sync(struct hvc_iucv_private *priv)
526{
527 int sync_wait;
528
529 cancel_delayed_work_sync(&priv->sndbuf_work);
530
531 spin_lock_bh(&priv->lock);
532 hvc_iucv_send(priv); /* force sending buffered data */
533 sync_wait = !list_empty(&priv->tty_outqueue); /* anything queued ? */
534 spin_unlock_bh(&priv->lock);
535
536 if (sync_wait)
537 wait_event_timeout(priv->sndbuf_waitq,
538 tty_outqueue_empty(priv), HZ);
539}
540
541/**
542 * hvc_iucv_notifier_hangup() - HVC notifier for TTY hangups.
543 * @hp: Pointer to the HVC device (struct hvc_struct)
544 * @id: Additional data (originally passed to hvc_alloc):
545 * the index of an struct hvc_iucv_private instance.
454 * 546 *
455 * The HVC backend for z/VM IUCV ignores virtual hangups (vhangup()), to keep 547 * This routine notifies the HVC back-end that a tty hangup (carrier loss,
456 * an existing IUCV communication path established. 548 * virtual or otherwise) has occured.
549 * The z/VM IUCV HVC device driver ignores virtual hangups (vhangup())
550 * to keep an existing IUCV communication path established.
457 * (Background: vhangup() is called from user space (by getty or login) to 551 * (Background: vhangup() is called from user space (by getty or login) to
458 * disable writing to the tty by other applications). 552 * disable writing to the tty by other applications).
459 * 553 * If the tty has been opened and an established IUCV path has been severed
460 * If the tty has been opened (e.g. getty) and an established IUCV path has been 554 * (we caused the tty hangup), the function calls hvc_iucv_cleanup().
461 * severed (we caused the tty hangup in that case), then the functions invokes
462 * hvc_iucv_cleanup() to clean up.
463 * 555 *
464 * Locking: struct hvc_iucv_private->lock 556 * Locking: struct hvc_iucv_private->lock
465 */ 557 */
@@ -471,12 +563,12 @@ static void hvc_iucv_notifier_hangup(struct hvc_struct *hp, int id)
471 if (!priv) 563 if (!priv)
472 return; 564 return;
473 565
566 flush_sndbuf_sync(priv);
567
474 spin_lock_bh(&priv->lock); 568 spin_lock_bh(&priv->lock);
475 /* NOTE: If the hangup was scheduled by ourself (from the iucv 569 /* NOTE: If the hangup was scheduled by ourself (from the iucv
476 * path_servered callback [IUCV_SEVERED]), then we have to 570 * path_servered callback [IUCV_SEVERED]), we have to clean up
477 * finally clean up the tty backend structure and set state to 571 * our structure and to set state to TTY_CLOSED.
478 * TTY_CLOSED.
479 *
480 * If the tty was hung up otherwise (e.g. vhangup()), then we 572 * If the tty was hung up otherwise (e.g. vhangup()), then we
481 * ignore this hangup and keep an established IUCV path open... 573 * ignore this hangup and keep an established IUCV path open...
482 * (...the reason is that we are not able to connect back to the 574 * (...the reason is that we are not able to connect back to the
@@ -494,10 +586,9 @@ static void hvc_iucv_notifier_hangup(struct hvc_struct *hp, int id)
494 * @id: Additional data (originally passed to hvc_alloc): 586 * @id: Additional data (originally passed to hvc_alloc):
495 * the index of an struct hvc_iucv_private instance. 587 * the index of an struct hvc_iucv_private instance.
496 * 588 *
497 * This routine notifies the HVC backend that the last tty device file 589 * This routine notifies the HVC back-end that the last tty device fd has been
498 * descriptor has been closed. 590 * closed. The function calls hvc_iucv_cleanup() to clean up the struct
499 * The function calls hvc_iucv_cleanup() to clean up the struct hvc_iucv_private 591 * hvc_iucv_private instance.
500 * instance.
501 * 592 *
502 * Locking: struct hvc_iucv_private->lock 593 * Locking: struct hvc_iucv_private->lock
503 */ 594 */
@@ -510,6 +601,8 @@ static void hvc_iucv_notifier_del(struct hvc_struct *hp, int id)
510 if (!priv) 601 if (!priv)
511 return; 602 return;
512 603
604 flush_sndbuf_sync(priv);
605
513 spin_lock_bh(&priv->lock); 606 spin_lock_bh(&priv->lock);
514 path = priv->path; /* save reference to IUCV path */ 607 path = priv->path; /* save reference to IUCV path */
515 priv->path = NULL; 608 priv->path = NULL;
@@ -527,20 +620,18 @@ static void hvc_iucv_notifier_del(struct hvc_struct *hp, int id)
527/** 620/**
528 * hvc_iucv_path_pending() - IUCV handler to process a connection request. 621 * hvc_iucv_path_pending() - IUCV handler to process a connection request.
529 * @path: Pending path (struct iucv_path) 622 * @path: Pending path (struct iucv_path)
530 * @ipvmid: Originator z/VM system identifier 623 * @ipvmid: z/VM system identifier of originator
531 * @ipuser: User specified data for this path 624 * @ipuser: User specified data for this path
532 * (AF_IUCV: port/service name and originator port) 625 * (AF_IUCV: port/service name and originator port)
533 * 626 *
534 * The function uses the @ipuser data to check to determine if the pending 627 * The function uses the @ipuser data to determine if the pending path belongs
535 * path belongs to a terminal managed by this HVC backend. 628 * to a terminal managed by this device driver.
536 * If the check is successful, then an additional check is done to ensure 629 * If the path belongs to this driver, ensure that the terminal is not accessed
537 * that a terminal cannot be accessed multiple times (only one connection 630 * multiple times (only one connection to a terminal is allowed).
538 * to a terminal is allowed). In that particular case, the pending path is 631 * If the terminal is not yet connected, the pending path is accepted and is
539 * severed. If it is the first connection, the pending path is accepted and 632 * associated to the appropriate struct hvc_iucv_private instance.
540 * associated to the struct hvc_iucv_private. The iucv state is updated to
541 * reflect that a communication path has been established.
542 * 633 *
543 * Returns 0 if the path belongs to a terminal managed by the this HVC backend; 634 * Returns 0 if @path belongs to a terminal managed by the this device driver;
544 * otherwise returns -ENODEV in order to dispatch this path to other handlers. 635 * otherwise returns -ENODEV in order to dispatch this path to other handlers.
545 * 636 *
546 * Locking: struct hvc_iucv_private->lock 637 * Locking: struct hvc_iucv_private->lock
@@ -559,7 +650,6 @@ static int hvc_iucv_path_pending(struct iucv_path *path,
559 priv = hvc_iucv_table[i]; 650 priv = hvc_iucv_table[i];
560 break; 651 break;
561 } 652 }
562
563 if (!priv) 653 if (!priv)
564 return -ENODEV; 654 return -ENODEV;
565 655
@@ -588,6 +678,9 @@ static int hvc_iucv_path_pending(struct iucv_path *path,
588 priv->path = path; 678 priv->path = path;
589 priv->iucv_state = IUCV_CONNECTED; 679 priv->iucv_state = IUCV_CONNECTED;
590 680
681 /* flush buffered output data... */
682 schedule_delayed_work(&priv->sndbuf_work, 5);
683
591out_path_handled: 684out_path_handled:
592 spin_unlock(&priv->lock); 685 spin_unlock(&priv->lock);
593 return 0; 686 return 0;
@@ -603,8 +696,7 @@ out_path_handled:
603 * sets the iucv state to IUCV_SEVERED for the associated struct 696 * sets the iucv state to IUCV_SEVERED for the associated struct
604 * hvc_iucv_private instance. Later, the IUCV_SEVERED state triggers a tty 697 * hvc_iucv_private instance. Later, the IUCV_SEVERED state triggers a tty
605 * hangup (hvc_iucv_get_chars() / hvc_iucv_write()). 698 * hangup (hvc_iucv_get_chars() / hvc_iucv_write()).
606 * 699 * If tty portion of the HVC is closed, clean up the outqueue.
607 * If tty portion of the HVC is closed then clean up the outqueue in addition.
608 * 700 *
609 * Locking: struct hvc_iucv_private->lock 701 * Locking: struct hvc_iucv_private->lock
610 */ 702 */
@@ -615,15 +707,25 @@ static void hvc_iucv_path_severed(struct iucv_path *path, u8 ipuser[16])
615 spin_lock(&priv->lock); 707 spin_lock(&priv->lock);
616 priv->iucv_state = IUCV_SEVERED; 708 priv->iucv_state = IUCV_SEVERED;
617 709
618 /* NOTE: If the tty has not yet been opened by a getty program 710 /* If the tty has not yet been opened, clean up the hvc_iucv_private
619 * (e.g. to see console messages), then cleanup the 711 * structure to allow re-connects.
620 * hvc_iucv_private structure to allow re-connects. 712 * This is also done for our console device because console hangups
713 * are handled specially and no notifier is called by HVC.
714 * The tty session is active (TTY_OPEN) and ready for re-connects...
621 * 715 *
622 * If the tty has been opened, the get_chars() callback returns 716 * If it has been opened, let get_chars() return -EPIPE to signal the
623 * -EPIPE to signal the hvc console layer to hang up the tty. */ 717 * HVC layer to hang up the tty.
718 * If so, we need to wake up the HVC thread to call get_chars()...
719 */
624 priv->path = NULL; 720 priv->path = NULL;
625 if (priv->tty_state == TTY_CLOSED) 721 if (priv->tty_state == TTY_CLOSED)
626 hvc_iucv_cleanup(priv); 722 hvc_iucv_cleanup(priv);
723 else
724 if (priv->is_console) {
725 hvc_iucv_cleanup(priv);
726 priv->tty_state = TTY_OPENED;
727 } else
728 hvc_kick();
627 spin_unlock(&priv->lock); 729 spin_unlock(&priv->lock);
628 730
629 /* finally sever path (outside of priv->lock due to lock ordering) */ 731 /* finally sever path (outside of priv->lock due to lock ordering) */
@@ -636,9 +738,9 @@ static void hvc_iucv_path_severed(struct iucv_path *path, u8 ipuser[16])
636 * @path: Pending path (struct iucv_path) 738 * @path: Pending path (struct iucv_path)
637 * @msg: Pointer to the IUCV message 739 * @msg: Pointer to the IUCV message
638 * 740 *
639 * The function stores an incoming message on the input queue for later 741 * The function puts an incoming message on the input queue for later
640 * processing (by hvc_iucv_get_chars() / hvc_iucv_write()). 742 * processing (by hvc_iucv_get_chars() / hvc_iucv_write()).
641 * However, if the tty has not yet been opened, the message is rejected. 743 * If the tty has not yet been opened, the message is rejected.
642 * 744 *
643 * Locking: struct hvc_iucv_private->lock 745 * Locking: struct hvc_iucv_private->lock
644 */ 746 */
@@ -648,6 +750,12 @@ static void hvc_iucv_msg_pending(struct iucv_path *path,
648 struct hvc_iucv_private *priv = path->private; 750 struct hvc_iucv_private *priv = path->private;
649 struct iucv_tty_buffer *rb; 751 struct iucv_tty_buffer *rb;
650 752
753 /* reject messages that exceed max size of iucv_tty_msg->datalen */
754 if (msg->length > MSG_SIZE(MSG_MAX_DATALEN)) {
755 iucv_message_reject(path, msg);
756 return;
757 }
758
651 spin_lock(&priv->lock); 759 spin_lock(&priv->lock);
652 760
653 /* reject messages if tty has not yet been opened */ 761 /* reject messages if tty has not yet been opened */
@@ -656,7 +764,7 @@ static void hvc_iucv_msg_pending(struct iucv_path *path,
656 goto unlock_return; 764 goto unlock_return;
657 } 765 }
658 766
659 /* allocate buffer an empty buffer element */ 767 /* allocate tty buffer to save iucv msg only */
660 rb = alloc_tty_buffer(0, GFP_ATOMIC); 768 rb = alloc_tty_buffer(0, GFP_ATOMIC);
661 if (!rb) { 769 if (!rb) {
662 iucv_message_reject(path, msg); 770 iucv_message_reject(path, msg);
@@ -666,7 +774,7 @@ static void hvc_iucv_msg_pending(struct iucv_path *path,
666 774
667 list_add_tail(&rb->list, &priv->tty_inqueue); 775 list_add_tail(&rb->list, &priv->tty_inqueue);
668 776
669 hvc_kick(); /* wakup hvc console thread */ 777 hvc_kick(); /* wake up hvc thread */
670 778
671unlock_return: 779unlock_return:
672 spin_unlock(&priv->lock); 780 spin_unlock(&priv->lock);
@@ -677,10 +785,10 @@ unlock_return:
677 * @path: Pending path (struct iucv_path) 785 * @path: Pending path (struct iucv_path)
678 * @msg: Pointer to the IUCV message 786 * @msg: Pointer to the IUCV message
679 * 787 *
680 * The function is called upon completion of message delivery and the 788 * The function is called upon completion of message delivery to remove the
681 * message is removed from the outqueue. Additional delivery information 789 * message from the outqueue. Additional delivery information can be found
682 * can be found in msg->audit: rejected messages (0x040000 (IPADRJCT)) and 790 * msg->audit: rejected messages (0x040000 (IPADRJCT)), and
683 * purged messages (0x010000 (IPADPGNR)). 791 * purged messages (0x010000 (IPADPGNR)).
684 * 792 *
685 * Locking: struct hvc_iucv_private->lock 793 * Locking: struct hvc_iucv_private->lock
686 */ 794 */
@@ -697,6 +805,7 @@ static void hvc_iucv_msg_complete(struct iucv_path *path,
697 list_move(&ent->list, &list_remove); 805 list_move(&ent->list, &list_remove);
698 break; 806 break;
699 } 807 }
808 wake_up(&priv->sndbuf_waitq);
700 spin_unlock(&priv->lock); 809 spin_unlock(&priv->lock);
701 destroy_tty_buffer_list(&list_remove); 810 destroy_tty_buffer_list(&list_remove);
702} 811}
@@ -713,13 +822,14 @@ static struct hv_ops hvc_iucv_ops = {
713 822
714/** 823/**
715 * hvc_iucv_alloc() - Allocates a new struct hvc_iucv_private instance 824 * hvc_iucv_alloc() - Allocates a new struct hvc_iucv_private instance
716 * @id: hvc_iucv_table index 825 * @id: hvc_iucv_table index
826 * @is_console: Flag if the instance is used as Linux console
717 * 827 *
718 * This function allocates a new hvc_iucv_private struct and put the 828 * This function allocates a new hvc_iucv_private structure and stores
719 * instance into hvc_iucv_table at index @id. 829 * the instance in hvc_iucv_table at index @id.
720 * Returns 0 on success; otherwise non-zero. 830 * Returns 0 on success; otherwise non-zero.
721 */ 831 */
722static int __init hvc_iucv_alloc(int id) 832static int __init hvc_iucv_alloc(int id, unsigned int is_console)
723{ 833{
724 struct hvc_iucv_private *priv; 834 struct hvc_iucv_private *priv;
725 char name[9]; 835 char name[9];
@@ -732,18 +842,33 @@ static int __init hvc_iucv_alloc(int id)
732 spin_lock_init(&priv->lock); 842 spin_lock_init(&priv->lock);
733 INIT_LIST_HEAD(&priv->tty_outqueue); 843 INIT_LIST_HEAD(&priv->tty_outqueue);
734 INIT_LIST_HEAD(&priv->tty_inqueue); 844 INIT_LIST_HEAD(&priv->tty_inqueue);
845 INIT_DELAYED_WORK(&priv->sndbuf_work, hvc_iucv_sndbuf_work);
846 init_waitqueue_head(&priv->sndbuf_waitq);
847
848 priv->sndbuf = (void *) get_zeroed_page(GFP_KERNEL);
849 if (!priv->sndbuf) {
850 kfree(priv);
851 return -ENOMEM;
852 }
853
854 /* set console flag */
855 priv->is_console = is_console;
735 856
736 /* Finally allocate hvc */ 857 /* finally allocate hvc */
737 priv->hvc = hvc_alloc(HVC_IUCV_MAGIC + id, 858 priv->hvc = hvc_alloc(HVC_IUCV_MAGIC + id, /* PAGE_SIZE */
738 HVC_IUCV_MAGIC + id, &hvc_iucv_ops, PAGE_SIZE); 859 HVC_IUCV_MAGIC + id, &hvc_iucv_ops, 256);
739 if (IS_ERR(priv->hvc)) { 860 if (IS_ERR(priv->hvc)) {
740 rc = PTR_ERR(priv->hvc); 861 rc = PTR_ERR(priv->hvc);
862 free_page((unsigned long) priv->sndbuf);
741 kfree(priv); 863 kfree(priv);
742 return rc; 864 return rc;
743 } 865 }
744 866
867 /* notify HVC thread instead of using polling */
868 priv->hvc->irq_requested = 1;
869
745 /* setup iucv related information */ 870 /* setup iucv related information */
746 snprintf(name, 9, "ihvc%-4d", id); 871 snprintf(name, 9, "lnxhvc%-2d", id);
747 memcpy(priv->srv_name, name, 8); 872 memcpy(priv->srv_name, name, 8);
748 ASCEBC(priv->srv_name, 8); 873 ASCEBC(priv->srv_name, 8);
749 874
@@ -752,15 +877,16 @@ static int __init hvc_iucv_alloc(int id)
752} 877}
753 878
754/** 879/**
755 * hvc_iucv_init() - Initialization of HVC backend for z/VM IUCV 880 * hvc_iucv_init() - z/VM IUCV HVC device driver initialization
756 */ 881 */
757static int __init hvc_iucv_init(void) 882static int __init hvc_iucv_init(void)
758{ 883{
759 int rc, i; 884 int rc;
885 unsigned int i;
760 886
761 if (!MACHINE_IS_VM) { 887 if (!MACHINE_IS_VM) {
762 pr_warning("The z/VM IUCV Hypervisor console cannot be " 888 pr_info("The z/VM IUCV HVC device driver cannot "
763 "used without z/VM.\n"); 889 "be used without z/VM\n");
764 return -ENODEV; 890 return -ENODEV;
765 } 891 }
766 892
@@ -774,26 +900,33 @@ static int __init hvc_iucv_init(void)
774 sizeof(struct iucv_tty_buffer), 900 sizeof(struct iucv_tty_buffer),
775 0, 0, NULL); 901 0, 0, NULL);
776 if (!hvc_iucv_buffer_cache) { 902 if (!hvc_iucv_buffer_cache) {
777 pr_err("Not enough memory for driver initialization " 903 pr_err("Allocating memory failed with reason code=%d\n", 1);
778 "(rs=%d).\n", 1);
779 return -ENOMEM; 904 return -ENOMEM;
780 } 905 }
781 906
782 hvc_iucv_mempool = mempool_create_slab_pool(MEMPOOL_MIN_NR, 907 hvc_iucv_mempool = mempool_create_slab_pool(MEMPOOL_MIN_NR,
783 hvc_iucv_buffer_cache); 908 hvc_iucv_buffer_cache);
784 if (!hvc_iucv_mempool) { 909 if (!hvc_iucv_mempool) {
785 pr_err("Not enough memory for driver initialization " 910 pr_err("Allocating memory failed with reason code=%d\n", 2);
786 "(rs=%d).\n", 2);
787 kmem_cache_destroy(hvc_iucv_buffer_cache); 911 kmem_cache_destroy(hvc_iucv_buffer_cache);
788 return -ENOMEM; 912 return -ENOMEM;
789 } 913 }
790 914
915 /* register the first terminal device as console
916 * (must be done before allocating hvc terminal devices) */
917 rc = hvc_instantiate(HVC_IUCV_MAGIC, IUCV_HVC_CON_IDX, &hvc_iucv_ops);
918 if (rc) {
919 pr_err("Registering HVC terminal device as "
920 "Linux console failed\n");
921 goto out_error_memory;
922 }
923
791 /* allocate hvc_iucv_private structs */ 924 /* allocate hvc_iucv_private structs */
792 for (i = 0; i < hvc_iucv_devices; i++) { 925 for (i = 0; i < hvc_iucv_devices; i++) {
793 rc = hvc_iucv_alloc(i); 926 rc = hvc_iucv_alloc(i, (i == IUCV_HVC_CON_IDX) ? 1 : 0);
794 if (rc) { 927 if (rc) {
795 pr_err("Could not create new z/VM IUCV HVC backend " 928 pr_err("Creating a new HVC terminal device "
796 "rc=%d.\n", rc); 929 "failed with error code=%d\n", rc);
797 goto out_error_hvc; 930 goto out_error_hvc;
798 } 931 }
799 } 932 }
@@ -801,7 +934,8 @@ static int __init hvc_iucv_init(void)
801 /* register IUCV callback handler */ 934 /* register IUCV callback handler */
802 rc = iucv_register(&hvc_iucv_handler, 0); 935 rc = iucv_register(&hvc_iucv_handler, 0);
803 if (rc) { 936 if (rc) {
804 pr_err("Could not register iucv handler (rc=%d).\n", rc); 937 pr_err("Registering IUCV handlers failed with error code=%d\n",
938 rc);
805 goto out_error_iucv; 939 goto out_error_iucv;
806 } 940 }
807 941
@@ -816,22 +950,13 @@ out_error_hvc:
816 hvc_remove(hvc_iucv_table[i]->hvc); 950 hvc_remove(hvc_iucv_table[i]->hvc);
817 kfree(hvc_iucv_table[i]); 951 kfree(hvc_iucv_table[i]);
818 } 952 }
953out_error_memory:
819 mempool_destroy(hvc_iucv_mempool); 954 mempool_destroy(hvc_iucv_mempool);
820 kmem_cache_destroy(hvc_iucv_buffer_cache); 955 kmem_cache_destroy(hvc_iucv_buffer_cache);
821 return rc; 956 return rc;
822} 957}
823 958
824/** 959/**
825 * hvc_iucv_console_init() - Early console initialization
826 */
827static int __init hvc_iucv_console_init(void)
828{
829 if (!MACHINE_IS_VM || !hvc_iucv_devices)
830 return -ENODEV;
831 return hvc_instantiate(HVC_IUCV_MAGIC, 0, &hvc_iucv_ops);
832}
833
834/**
835 * hvc_iucv_config() - Parsing of hvc_iucv= kernel command line parameter 960 * hvc_iucv_config() - Parsing of hvc_iucv= kernel command line parameter
836 * @val: Parameter value (numeric) 961 * @val: Parameter value (numeric)
837 */ 962 */
@@ -841,10 +966,5 @@ static int __init hvc_iucv_config(char *val)
841} 966}
842 967
843 968
844module_init(hvc_iucv_init); 969device_initcall(hvc_iucv_init);
845console_initcall(hvc_iucv_console_init);
846__setup("hvc_iucv=", hvc_iucv_config); 970__setup("hvc_iucv=", hvc_iucv_config);
847
848MODULE_LICENSE("GPL");
849MODULE_DESCRIPTION("HVC back-end for z/VM IUCV.");
850MODULE_AUTHOR("Hendrik Brueckner <brueckner@linux.vnet.ibm.com>");
diff --git a/drivers/char/hw_random/n2-drv.c b/drivers/char/hw_random/n2-drv.c
index 8859aeac2d25..9b3e09cd41f9 100644
--- a/drivers/char/hw_random/n2-drv.c
+++ b/drivers/char/hw_random/n2-drv.c
@@ -482,7 +482,7 @@ static void n2rng_dump_test_buffer(struct n2rng *np)
482 int i; 482 int i;
483 483
484 for (i = 0; i < SELFTEST_BUFFER_WORDS; i++) 484 for (i = 0; i < SELFTEST_BUFFER_WORDS; i++)
485 dev_err(&np->op->dev, "Test buffer slot %d [0x%016lx]\n", 485 dev_err(&np->op->dev, "Test buffer slot %d [0x%016llx]\n",
486 i, np->test_buffer[i]); 486 i, np->test_buffer[i]);
487} 487}
488 488
diff --git a/drivers/char/ps3flash.c b/drivers/char/ps3flash.c
index 79b6f461be75..afbe45676d71 100644
--- a/drivers/char/ps3flash.c
+++ b/drivers/char/ps3flash.c
@@ -44,7 +44,7 @@ static ssize_t ps3flash_read_write_sectors(struct ps3_storage_device *dev,
44 u64 res = ps3stor_read_write_sectors(dev, lpar, start_sector, sectors, 44 u64 res = ps3stor_read_write_sectors(dev, lpar, start_sector, sectors,
45 write); 45 write);
46 if (res) { 46 if (res) {
47 dev_err(&dev->sbd.core, "%s:%u: %s failed 0x%lx\n", __func__, 47 dev_err(&dev->sbd.core, "%s:%u: %s failed 0x%llx\n", __func__,
48 __LINE__, write ? "write" : "read", res); 48 __LINE__, write ? "write" : "read", res);
49 return -EIO; 49 return -EIO;
50 } 50 }
@@ -59,7 +59,7 @@ static ssize_t ps3flash_read_sectors(struct ps3_storage_device *dev,
59 59
60 max_sectors = dev->bounce_size / dev->blk_size; 60 max_sectors = dev->bounce_size / dev->blk_size;
61 if (sectors > max_sectors) { 61 if (sectors > max_sectors) {
62 dev_dbg(&dev->sbd.core, "%s:%u Limiting sectors to %lu\n", 62 dev_dbg(&dev->sbd.core, "%s:%u Limiting sectors to %llu\n",
63 __func__, __LINE__, max_sectors); 63 __func__, __LINE__, max_sectors);
64 sectors = max_sectors; 64 sectors = max_sectors;
65 } 65 }
@@ -144,7 +144,7 @@ static ssize_t ps3flash_read(struct file *file, char __user *buf, size_t count,
144 goto fail; 144 goto fail;
145 } 145 }
146 146
147 n = min(remaining, sectors_read*dev->blk_size-offset); 147 n = min_t(u64, remaining, sectors_read*dev->blk_size-offset);
148 dev_dbg(&dev->sbd.core, 148 dev_dbg(&dev->sbd.core,
149 "%s:%u: copy %lu bytes from 0x%p to user 0x%p\n", 149 "%s:%u: copy %lu bytes from 0x%p to user 0x%p\n",
150 __func__, __LINE__, n, dev->bounce_buf+offset, buf); 150 __func__, __LINE__, n, dev->bounce_buf+offset, buf);
@@ -225,7 +225,7 @@ static ssize_t ps3flash_write(struct file *file, const char __user *buf,
225 if (end_read_sector >= start_read_sector) { 225 if (end_read_sector >= start_read_sector) {
226 /* Merge head and tail */ 226 /* Merge head and tail */
227 dev_dbg(&dev->sbd.core, 227 dev_dbg(&dev->sbd.core,
228 "Merged head and tail: %lu sectors at %lu\n", 228 "Merged head and tail: %llu sectors at %llu\n",
229 chunk_sectors, start_write_sector); 229 chunk_sectors, start_write_sector);
230 res = ps3flash_read_sectors(dev, start_write_sector, 230 res = ps3flash_read_sectors(dev, start_write_sector,
231 chunk_sectors, 0); 231 chunk_sectors, 0);
@@ -235,7 +235,7 @@ static ssize_t ps3flash_write(struct file *file, const char __user *buf,
235 if (head) { 235 if (head) {
236 /* Read head */ 236 /* Read head */
237 dev_dbg(&dev->sbd.core, 237 dev_dbg(&dev->sbd.core,
238 "head: %lu sectors at %lu\n", head, 238 "head: %llu sectors at %llu\n", head,
239 start_write_sector); 239 start_write_sector);
240 res = ps3flash_read_sectors(dev, 240 res = ps3flash_read_sectors(dev,
241 start_write_sector, 241 start_write_sector,
@@ -247,7 +247,7 @@ static ssize_t ps3flash_write(struct file *file, const char __user *buf,
247 start_write_sector+chunk_sectors) { 247 start_write_sector+chunk_sectors) {
248 /* Read tail */ 248 /* Read tail */
249 dev_dbg(&dev->sbd.core, 249 dev_dbg(&dev->sbd.core,
250 "tail: %lu sectors at %lu\n", tail, 250 "tail: %llu sectors at %llu\n", tail,
251 start_read_sector); 251 start_read_sector);
252 sec_off = start_read_sector-start_write_sector; 252 sec_off = start_read_sector-start_write_sector;
253 res = ps3flash_read_sectors(dev, 253 res = ps3flash_read_sectors(dev,
@@ -258,7 +258,7 @@ static ssize_t ps3flash_write(struct file *file, const char __user *buf,
258 } 258 }
259 } 259 }
260 260
261 n = min(remaining, dev->bounce_size-offset); 261 n = min_t(u64, remaining, dev->bounce_size-offset);
262 dev_dbg(&dev->sbd.core, 262 dev_dbg(&dev->sbd.core,
263 "%s:%u: copy %lu bytes from user 0x%p to 0x%p\n", 263 "%s:%u: copy %lu bytes from user 0x%p to 0x%p\n",
264 __func__, __LINE__, n, buf, dev->bounce_buf+offset); 264 __func__, __LINE__, n, buf, dev->bounce_buf+offset);
@@ -299,11 +299,11 @@ static irqreturn_t ps3flash_interrupt(int irq, void *data)
299 299
300 if (tag != dev->tag) 300 if (tag != dev->tag)
301 dev_err(&dev->sbd.core, 301 dev_err(&dev->sbd.core,
302 "%s:%u: tag mismatch, got %lx, expected %lx\n", 302 "%s:%u: tag mismatch, got %llx, expected %llx\n",
303 __func__, __LINE__, tag, dev->tag); 303 __func__, __LINE__, tag, dev->tag);
304 304
305 if (res) { 305 if (res) {
306 dev_err(&dev->sbd.core, "%s:%u: res=%d status=0x%lx\n", 306 dev_err(&dev->sbd.core, "%s:%u: res=%d status=0x%llx\n",
307 __func__, __LINE__, res, status); 307 __func__, __LINE__, res, status);
308 } else { 308 } else {
309 dev->lv1_status = status; 309 dev->lv1_status = status;
diff --git a/drivers/char/pty.c b/drivers/char/pty.c
index 112a6ba9a96f..31038a0052a2 100644
--- a/drivers/char/pty.c
+++ b/drivers/char/pty.c
@@ -32,7 +32,7 @@
32 32
33/* These are global because they are accessed in tty_io.c */ 33/* These are global because they are accessed in tty_io.c */
34#ifdef CONFIG_UNIX98_PTYS 34#ifdef CONFIG_UNIX98_PTYS
35struct tty_driver *ptm_driver; 35static struct tty_driver *ptm_driver;
36static struct tty_driver *pts_driver; 36static struct tty_driver *pts_driver;
37#endif 37#endif
38 38
@@ -230,9 +230,7 @@ static void pty_set_termios(struct tty_struct *tty,
230/** 230/**
231 * pty_do_resize - resize event 231 * pty_do_resize - resize event
232 * @tty: tty being resized 232 * @tty: tty being resized
233 * @real_tty: real tty (not the same as tty if using a pty/tty pair) 233 * @ws: window size being set.
234 * @rows: rows (character)
235 * @cols: cols (character)
236 * 234 *
237 * Update the termios variables and send the neccessary signals to 235 * Update the termios variables and send the neccessary signals to
238 * peform a terminal resize correctly 236 * peform a terminal resize correctly
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c
index 20d6efb6324e..e0d0f8b2696b 100644
--- a/drivers/char/rtc.c
+++ b/drivers/char/rtc.c
@@ -48,9 +48,10 @@
48 * CONFIG_HPET_EMULATE_RTC 48 * CONFIG_HPET_EMULATE_RTC
49 * 1.12a Maciej W. Rozycki: Handle memory-mapped chips properly. 49 * 1.12a Maciej W. Rozycki: Handle memory-mapped chips properly.
50 * 1.12ac Alan Cox: Allow read access to the day of week register 50 * 1.12ac Alan Cox: Allow read access to the day of week register
51 * 1.12b David John: Remove calls to the BKL.
51 */ 52 */
52 53
53#define RTC_VERSION "1.12ac" 54#define RTC_VERSION "1.12b"
54 55
55/* 56/*
56 * Note that *all* calls to CMOS_READ and CMOS_WRITE are done with 57 * Note that *all* calls to CMOS_READ and CMOS_WRITE are done with
@@ -73,7 +74,6 @@
73#include <linux/proc_fs.h> 74#include <linux/proc_fs.h>
74#include <linux/seq_file.h> 75#include <linux/seq_file.h>
75#include <linux/spinlock.h> 76#include <linux/spinlock.h>
76#include <linux/smp_lock.h>
77#include <linux/sysctl.h> 77#include <linux/sysctl.h>
78#include <linux/wait.h> 78#include <linux/wait.h>
79#include <linux/bcd.h> 79#include <linux/bcd.h>
@@ -182,8 +182,8 @@ static int rtc_proc_open(struct inode *inode, struct file *file);
182 182
183/* 183/*
184 * rtc_status is never changed by rtc_interrupt, and ioctl/open/close is 184 * rtc_status is never changed by rtc_interrupt, and ioctl/open/close is
185 * protected by the big kernel lock. However, ioctl can still disable the timer 185 * protected by the spin lock rtc_lock. However, ioctl can still disable the
186 * in rtc_status and then with del_timer after the interrupt has read 186 * timer in rtc_status and then with del_timer after the interrupt has read
187 * rtc_status but before mod_timer is called, which would then reenable the 187 * rtc_status but before mod_timer is called, which would then reenable the
188 * timer (but you would need to have an awful timing before you'd trip on it) 188 * timer (but you would need to have an awful timing before you'd trip on it)
189 */ 189 */
@@ -720,9 +720,7 @@ static int rtc_do_ioctl(unsigned int cmd, unsigned long arg, int kernel)
720static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 720static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
721{ 721{
722 long ret; 722 long ret;
723 lock_kernel();
724 ret = rtc_do_ioctl(cmd, arg, 0); 723 ret = rtc_do_ioctl(cmd, arg, 0);
725 unlock_kernel();
726 return ret; 724 return ret;
727} 725}
728 726
@@ -731,12 +729,8 @@ static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
731 * Also clear the previous interrupt data on an open, and clean 729 * Also clear the previous interrupt data on an open, and clean
732 * up things on a close. 730 * up things on a close.
733 */ 731 */
734
735/* We use rtc_lock to protect against concurrent opens. So the BKL is not
736 * needed here. Or anywhere else in this driver. */
737static int rtc_open(struct inode *inode, struct file *file) 732static int rtc_open(struct inode *inode, struct file *file)
738{ 733{
739 lock_kernel();
740 spin_lock_irq(&rtc_lock); 734 spin_lock_irq(&rtc_lock);
741 735
742 if (rtc_status & RTC_IS_OPEN) 736 if (rtc_status & RTC_IS_OPEN)
@@ -746,12 +740,10 @@ static int rtc_open(struct inode *inode, struct file *file)
746 740
747 rtc_irq_data = 0; 741 rtc_irq_data = 0;
748 spin_unlock_irq(&rtc_lock); 742 spin_unlock_irq(&rtc_lock);
749 unlock_kernel();
750 return 0; 743 return 0;
751 744
752out_busy: 745out_busy:
753 spin_unlock_irq(&rtc_lock); 746 spin_unlock_irq(&rtc_lock);
754 unlock_kernel();
755 return -EBUSY; 747 return -EBUSY;
756} 748}
757 749
@@ -800,7 +792,6 @@ no_irq:
800} 792}
801 793
802#ifdef RTC_IRQ 794#ifdef RTC_IRQ
803/* Called without the kernel lock - fine */
804static unsigned int rtc_poll(struct file *file, poll_table *wait) 795static unsigned int rtc_poll(struct file *file, poll_table *wait)
805{ 796{
806 unsigned long l; 797 unsigned long l;
diff --git a/drivers/char/ser_a2232.c b/drivers/char/ser_a2232.c
index 33872a219df6..33a2b531802e 100644
--- a/drivers/char/ser_a2232.c
+++ b/drivers/char/ser_a2232.c
@@ -718,6 +718,7 @@ static int __init a2232board_init(void)
718 u_char *from; 718 u_char *from;
719 volatile u_char *to; 719 volatile u_char *to;
720 volatile struct a2232memory *mem; 720 volatile struct a2232memory *mem;
721 int error, i;
721 722
722#ifdef CONFIG_SMP 723#ifdef CONFIG_SMP
723 return -ENODEV; /* This driver is not SMP aware. Is there an SMP ZorroII-bus-machine? */ 724 return -ENODEV; /* This driver is not SMP aware. Is there an SMP ZorroII-bus-machine? */
@@ -797,8 +798,15 @@ static int __init a2232board_init(void)
797 */ 798 */
798 if (a2232_init_drivers()) return -ENODEV; // maybe we should use a different -Exxx? 799 if (a2232_init_drivers()) return -ENODEV; // maybe we should use a different -Exxx?
799 800
800 request_irq(IRQ_AMIGA_VERTB, a2232_vbl_inter, 0, "A2232 serial VBL", a2232_driver_ID); 801 error = request_irq(IRQ_AMIGA_VERTB, a2232_vbl_inter, 0,
801 return 0; 802 "A2232 serial VBL", a2232_driver_ID);
803 if (error) {
804 for (i = 0; i < nr_a2232; i++)
805 zorro_release_device(zd_a2232[i]);
806 tty_unregister_driver(a2232_driver);
807 put_tty_driver(a2232_driver);
808 }
809 return error;
802} 810}
803 811
804static void __exit a2232board_exit(void) 812static void __exit a2232board_exit(void)
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index 53544e21f191..f329f459817c 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: synclink_gt.c,v 4.50 2007/07/25 19:29:25 paulkf Exp $
3 *
4 * Device driver for Microgate SyncLink GT serial adapters. 2 * Device driver for Microgate SyncLink GT serial adapters.
5 * 3 *
6 * written by Paul Fulghum for Microgate Corporation 4 * written by Paul Fulghum for Microgate Corporation
@@ -91,7 +89,6 @@
91 * module identification 89 * module identification
92 */ 90 */
93static char *driver_name = "SyncLink GT"; 91static char *driver_name = "SyncLink GT";
94static char *driver_version = "$Revision: 4.50 $";
95static char *tty_driver_name = "synclink_gt"; 92static char *tty_driver_name = "synclink_gt";
96static char *tty_dev_prefix = "ttySLG"; 93static char *tty_dev_prefix = "ttySLG";
97MODULE_LICENSE("GPL"); 94MODULE_LICENSE("GPL");
@@ -1309,7 +1306,7 @@ static int read_proc(char *page, char **start, off_t off, int count,
1309 off_t begin = 0; 1306 off_t begin = 0;
1310 struct slgt_info *info; 1307 struct slgt_info *info;
1311 1308
1312 len += sprintf(page, "synclink_gt driver:%s\n", driver_version); 1309 len += sprintf(page, "synclink_gt driver\n");
1313 1310
1314 info = slgt_device_list; 1311 info = slgt_device_list;
1315 while( info ) { 1312 while( info ) {
@@ -2441,7 +2438,7 @@ static void program_hw(struct slgt_info *info)
2441 info->ri_chkcount = 0; 2438 info->ri_chkcount = 0;
2442 info->dsr_chkcount = 0; 2439 info->dsr_chkcount = 0;
2443 2440
2444 slgt_irq_on(info, IRQ_DCD | IRQ_CTS | IRQ_DSR); 2441 slgt_irq_on(info, IRQ_DCD | IRQ_CTS | IRQ_DSR | IRQ_RI);
2445 get_signals(info); 2442 get_signals(info);
2446 2443
2447 if (info->netcount || 2444 if (info->netcount ||
@@ -3576,7 +3573,7 @@ static void slgt_cleanup(void)
3576 struct slgt_info *info; 3573 struct slgt_info *info;
3577 struct slgt_info *tmp; 3574 struct slgt_info *tmp;
3578 3575
3579 printk("unload %s %s\n", driver_name, driver_version); 3576 printk(KERN_INFO "unload %s\n", driver_name);
3580 3577
3581 if (serial_driver) { 3578 if (serial_driver) {
3582 for (info=slgt_device_list ; info != NULL ; info=info->next_device) 3579 for (info=slgt_device_list ; info != NULL ; info=info->next_device)
@@ -3619,7 +3616,7 @@ static int __init slgt_init(void)
3619{ 3616{
3620 int rc; 3617 int rc;
3621 3618
3622 printk("%s %s\n", driver_name, driver_version); 3619 printk(KERN_INFO "%s\n", driver_name);
3623 3620
3624 serial_driver = alloc_tty_driver(MAX_DEVICES); 3621 serial_driver = alloc_tty_driver(MAX_DEVICES);
3625 if (!serial_driver) { 3622 if (!serial_driver) {
@@ -3650,9 +3647,8 @@ static int __init slgt_init(void)
3650 goto error; 3647 goto error;
3651 } 3648 }
3652 3649
3653 printk("%s %s, tty major#%d\n", 3650 printk(KERN_INFO "%s, tty major#%d\n",
3654 driver_name, driver_version, 3651 driver_name, serial_driver->major);
3655 serial_driver->major);
3656 3652
3657 slgt_device_count = 0; 3653 slgt_device_count = 0;
3658 if ((rc = pci_register_driver(&pci_driver)) < 0) { 3654 if ((rc = pci_register_driver(&pci_driver)) < 0) {
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index d41b9f6f7903..33a9351c896d 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -473,6 +473,12 @@ void __handle_sysrq(int key, struct tty_struct *tty, int check_mask)
473 unsigned long flags; 473 unsigned long flags;
474 474
475 spin_lock_irqsave(&sysrq_key_table_lock, flags); 475 spin_lock_irqsave(&sysrq_key_table_lock, flags);
476 /*
477 * Raise the apparent loglevel to maximum so that the sysrq header
478 * is shown to provide the user with positive feedback. We do not
479 * simply emit this at KERN_EMERG as that would change message
480 * routing in the consumers of /proc/kmsg.
481 */
476 orig_log_level = console_loglevel; 482 orig_log_level = console_loglevel;
477 console_loglevel = 7; 483 console_loglevel = 7;
478 printk(KERN_INFO "SysRq : "); 484 printk(KERN_INFO "SysRq : ");
diff --git a/drivers/char/tpm/tpm_bios.c b/drivers/char/tpm/tpm_bios.c
index 68f052b42ed7..ed306eb1057f 100644
--- a/drivers/char/tpm/tpm_bios.c
+++ b/drivers/char/tpm/tpm_bios.c
@@ -23,8 +23,6 @@
23#include <linux/security.h> 23#include <linux/security.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <acpi/acpi.h> 25#include <acpi/acpi.h>
26#include <acpi/actypes.h>
27#include <acpi/actbl.h>
28#include "tpm.h" 26#include "tpm.h"
29 27
30#define TCG_EVENT_NAME_LEN_MAX 255 28#define TCG_EVENT_NAME_LEN_MAX 255
diff --git a/drivers/char/tpm/tpm_nsc.c b/drivers/char/tpm/tpm_nsc.c
index ab18c1e7b115..70efba2ee053 100644
--- a/drivers/char/tpm/tpm_nsc.c
+++ b/drivers/char/tpm/tpm_nsc.c
@@ -273,12 +273,23 @@ static void tpm_nsc_remove(struct device *dev)
273 } 273 }
274} 274}
275 275
276static struct device_driver nsc_drv = { 276static int tpm_nsc_suspend(struct platform_device *dev, pm_message_t msg)
277 .name = "tpm_nsc", 277{
278 .bus = &platform_bus_type, 278 return tpm_pm_suspend(&dev->dev, msg);
279 .owner = THIS_MODULE, 279}
280 .suspend = tpm_pm_suspend, 280
281 .resume = tpm_pm_resume, 281static int tpm_nsc_resume(struct platform_device *dev)
282{
283 return tpm_pm_resume(&dev->dev);
284}
285
286static struct platform_driver nsc_drv = {
287 .suspend = tpm_nsc_suspend,
288 .resume = tpm_nsc_resume,
289 .driver = {
290 .name = "tpm_nsc",
291 .owner = THIS_MODULE,
292 },
282}; 293};
283 294
284static int __init init_nsc(void) 295static int __init init_nsc(void)
@@ -297,7 +308,7 @@ static int __init init_nsc(void)
297 return -ENODEV; 308 return -ENODEV;
298 } 309 }
299 310
300 err = driver_register(&nsc_drv); 311 err = platform_driver_register(&nsc_drv);
301 if (err) 312 if (err)
302 return err; 313 return err;
303 314
@@ -308,17 +319,15 @@ static int __init init_nsc(void)
308 /* enable the DPM module */ 319 /* enable the DPM module */
309 tpm_write_index(nscAddrBase, NSC_LDC_INDEX, 0x01); 320 tpm_write_index(nscAddrBase, NSC_LDC_INDEX, 0x01);
310 321
311 pdev = kzalloc(sizeof(struct platform_device), GFP_KERNEL); 322 pdev = platform_device_alloc("tpm_nscl0", -1);
312 if (!pdev) { 323 if (!pdev) {
313 rc = -ENOMEM; 324 rc = -ENOMEM;
314 goto err_unreg_drv; 325 goto err_unreg_drv;
315 } 326 }
316 327
317 pdev->name = "tpm_nscl0";
318 pdev->id = -1;
319 pdev->num_resources = 0; 328 pdev->num_resources = 0;
329 pdev->dev.driver = &nsc_drv.driver;
320 pdev->dev.release = tpm_nsc_remove; 330 pdev->dev.release = tpm_nsc_remove;
321 pdev->dev.driver = &nsc_drv;
322 331
323 if ((rc = platform_device_register(pdev)) < 0) 332 if ((rc = platform_device_register(pdev)) < 0)
324 goto err_free_dev; 333 goto err_free_dev;
@@ -377,7 +386,7 @@ err_unreg_dev:
377err_free_dev: 386err_free_dev:
378 kfree(pdev); 387 kfree(pdev);
379err_unreg_drv: 388err_unreg_drv:
380 driver_unregister(&nsc_drv); 389 platform_driver_unregister(&nsc_drv);
381 return rc; 390 return rc;
382} 391}
383 392
@@ -390,7 +399,7 @@ static void __exit cleanup_nsc(void)
390 pdev = NULL; 399 pdev = NULL;
391 } 400 }
392 401
393 driver_unregister(&nsc_drv); 402 platform_driver_unregister(&nsc_drv);
394} 403}
395 404
396module_init(init_nsc); 405module_init(init_nsc);
diff --git a/drivers/char/tty_ioctl.c b/drivers/char/tty_ioctl.c
index a408c8e487ec..6f4c7d0a53bf 100644
--- a/drivers/char/tty_ioctl.c
+++ b/drivers/char/tty_ioctl.c
@@ -1057,7 +1057,7 @@ int tty_perform_flush(struct tty_struct *tty, unsigned long arg)
1057 if (retval) 1057 if (retval)
1058 return retval; 1058 return retval;
1059 1059
1060 ld = tty_ldisc_ref(tty); 1060 ld = tty_ldisc_ref_wait(tty);
1061 switch (arg) { 1061 switch (arg) {
1062 case TCIFLUSH: 1062 case TCIFLUSH:
1063 if (ld && ld->ops->flush_buffer) 1063 if (ld && ld->ops->flush_buffer)
diff --git a/drivers/char/vme_scc.c b/drivers/char/vme_scc.c
index 0e8234bd0e19..994e1a58b987 100644
--- a/drivers/char/vme_scc.c
+++ b/drivers/char/vme_scc.c
@@ -198,6 +198,7 @@ static void scc_init_portstructs(void)
198static int mvme147_scc_init(void) 198static int mvme147_scc_init(void)
199{ 199{
200 struct scc_port *port; 200 struct scc_port *port;
201 int error;
201 202
202 printk(KERN_INFO "SCC: MVME147 Serial Driver\n"); 203 printk(KERN_INFO "SCC: MVME147 Serial Driver\n");
203 /* Init channel A */ 204 /* Init channel A */
@@ -207,14 +208,23 @@ static int mvme147_scc_init(void)
207 port->datap = port->ctrlp + 1; 208 port->datap = port->ctrlp + 1;
208 port->port_a = &scc_ports[0]; 209 port->port_a = &scc_ports[0];
209 port->port_b = &scc_ports[1]; 210 port->port_b = &scc_ports[1];
210 request_irq(MVME147_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED, 211 error = request_irq(MVME147_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED,
211 "SCC-A TX", port); 212 "SCC-A TX", port);
212 request_irq(MVME147_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED, 213 if (error)
214 goto fail;
215 error = request_irq(MVME147_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED,
213 "SCC-A status", port); 216 "SCC-A status", port);
214 request_irq(MVME147_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED, 217 if (error)
218 goto fail_free_a_tx;
219 error = request_irq(MVME147_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED,
215 "SCC-A RX", port); 220 "SCC-A RX", port);
216 request_irq(MVME147_IRQ_SCCA_SPCOND, scc_spcond_int, IRQF_DISABLED, 221 if (error)
217 "SCC-A special cond", port); 222 goto fail_free_a_stat;
223 error = request_irq(MVME147_IRQ_SCCA_SPCOND, scc_spcond_int,
224 IRQF_DISABLED, "SCC-A special cond", port);
225 if (error)
226 goto fail_free_a_rx;
227
218 { 228 {
219 SCC_ACCESS_INIT(port); 229 SCC_ACCESS_INIT(port);
220 230
@@ -234,14 +244,23 @@ static int mvme147_scc_init(void)
234 port->datap = port->ctrlp + 1; 244 port->datap = port->ctrlp + 1;
235 port->port_a = &scc_ports[0]; 245 port->port_a = &scc_ports[0];
236 port->port_b = &scc_ports[1]; 246 port->port_b = &scc_ports[1];
237 request_irq(MVME147_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED, 247 error = request_irq(MVME147_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED,
238 "SCC-B TX", port); 248 "SCC-B TX", port);
239 request_irq(MVME147_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED, 249 if (error)
250 goto fail_free_a_spcond;
251 error = request_irq(MVME147_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED,
240 "SCC-B status", port); 252 "SCC-B status", port);
241 request_irq(MVME147_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED, 253 if (error)
254 goto fail_free_b_tx;
255 error = request_irq(MVME147_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED,
242 "SCC-B RX", port); 256 "SCC-B RX", port);
243 request_irq(MVME147_IRQ_SCCB_SPCOND, scc_spcond_int, IRQF_DISABLED, 257 if (error)
244 "SCC-B special cond", port); 258 goto fail_free_b_stat;
259 error = request_irq(MVME147_IRQ_SCCB_SPCOND, scc_spcond_int,
260 IRQF_DISABLED, "SCC-B special cond", port);
261 if (error)
262 goto fail_free_b_rx;
263
245 { 264 {
246 SCC_ACCESS_INIT(port); 265 SCC_ACCESS_INIT(port);
247 266
@@ -257,6 +276,23 @@ static int mvme147_scc_init(void)
257 scc_init_drivers(); 276 scc_init_drivers();
258 277
259 return 0; 278 return 0;
279
280fail_free_b_rx:
281 free_irq(MVME147_IRQ_SCCB_RX, port);
282fail_free_b_stat:
283 free_irq(MVME147_IRQ_SCCB_STAT, port);
284fail_free_b_tx:
285 free_irq(MVME147_IRQ_SCCB_TX, port);
286fail_free_a_spcond:
287 free_irq(MVME147_IRQ_SCCA_SPCOND, port);
288fail_free_a_rx:
289 free_irq(MVME147_IRQ_SCCA_RX, port);
290fail_free_a_stat:
291 free_irq(MVME147_IRQ_SCCA_STAT, port);
292fail_free_a_tx:
293 free_irq(MVME147_IRQ_SCCA_TX, port);
294fail:
295 return error;
260} 296}
261#endif 297#endif
262 298
@@ -265,6 +301,7 @@ static int mvme147_scc_init(void)
265static int mvme162_scc_init(void) 301static int mvme162_scc_init(void)
266{ 302{
267 struct scc_port *port; 303 struct scc_port *port;
304 int error;
268 305
269 if (!(mvme16x_config & MVME16x_CONFIG_GOT_SCCA)) 306 if (!(mvme16x_config & MVME16x_CONFIG_GOT_SCCA))
270 return (-ENODEV); 307 return (-ENODEV);
@@ -277,14 +314,23 @@ static int mvme162_scc_init(void)
277 port->datap = port->ctrlp + 2; 314 port->datap = port->ctrlp + 2;
278 port->port_a = &scc_ports[0]; 315 port->port_a = &scc_ports[0];
279 port->port_b = &scc_ports[1]; 316 port->port_b = &scc_ports[1];
280 request_irq(MVME162_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED, 317 error = request_irq(MVME162_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED,
281 "SCC-A TX", port); 318 "SCC-A TX", port);
282 request_irq(MVME162_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED, 319 if (error)
320 goto fail;
321 error = request_irq(MVME162_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED,
283 "SCC-A status", port); 322 "SCC-A status", port);
284 request_irq(MVME162_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED, 323 if (error)
324 goto fail_free_a_tx;
325 error = request_irq(MVME162_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED,
285 "SCC-A RX", port); 326 "SCC-A RX", port);
286 request_irq(MVME162_IRQ_SCCA_SPCOND, scc_spcond_int, IRQF_DISABLED, 327 if (error)
287 "SCC-A special cond", port); 328 goto fail_free_a_stat;
329 error = request_irq(MVME162_IRQ_SCCA_SPCOND, scc_spcond_int,
330 IRQF_DISABLED, "SCC-A special cond", port);
331 if (error)
332 goto fail_free_a_rx;
333
288 { 334 {
289 SCC_ACCESS_INIT(port); 335 SCC_ACCESS_INIT(port);
290 336
@@ -304,14 +350,22 @@ static int mvme162_scc_init(void)
304 port->datap = port->ctrlp + 2; 350 port->datap = port->ctrlp + 2;
305 port->port_a = &scc_ports[0]; 351 port->port_a = &scc_ports[0];
306 port->port_b = &scc_ports[1]; 352 port->port_b = &scc_ports[1];
307 request_irq(MVME162_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED, 353 error = request_irq(MVME162_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED,
308 "SCC-B TX", port); 354 "SCC-B TX", port);
309 request_irq(MVME162_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED, 355 if (error)
356 goto fail_free_a_spcond;
357 error = request_irq(MVME162_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED,
310 "SCC-B status", port); 358 "SCC-B status", port);
311 request_irq(MVME162_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED, 359 if (error)
360 goto fail_free_b_tx;
361 error = request_irq(MVME162_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED,
312 "SCC-B RX", port); 362 "SCC-B RX", port);
313 request_irq(MVME162_IRQ_SCCB_SPCOND, scc_spcond_int, IRQF_DISABLED, 363 if (error)
314 "SCC-B special cond", port); 364 goto fail_free_b_stat;
365 error = request_irq(MVME162_IRQ_SCCB_SPCOND, scc_spcond_int,
366 IRQF_DISABLED, "SCC-B special cond", port);
367 if (error)
368 goto fail_free_b_rx;
315 369
316 { 370 {
317 SCC_ACCESS_INIT(port); /* Either channel will do */ 371 SCC_ACCESS_INIT(port); /* Either channel will do */
@@ -328,6 +382,23 @@ static int mvme162_scc_init(void)
328 scc_init_drivers(); 382 scc_init_drivers();
329 383
330 return 0; 384 return 0;
385
386fail_free_b_rx:
387 free_irq(MVME162_IRQ_SCCB_RX, port);
388fail_free_b_stat:
389 free_irq(MVME162_IRQ_SCCB_STAT, port);
390fail_free_b_tx:
391 free_irq(MVME162_IRQ_SCCB_TX, port);
392fail_free_a_spcond:
393 free_irq(MVME162_IRQ_SCCA_SPCOND, port);
394fail_free_a_rx:
395 free_irq(MVME162_IRQ_SCCA_RX, port);
396fail_free_a_stat:
397 free_irq(MVME162_IRQ_SCCA_STAT, port);
398fail_free_a_tx:
399 free_irq(MVME162_IRQ_SCCA_TX, port);
400fail:
401 return error;
331} 402}
332#endif 403#endif
333 404
@@ -336,6 +407,7 @@ static int mvme162_scc_init(void)
336static int bvme6000_scc_init(void) 407static int bvme6000_scc_init(void)
337{ 408{
338 struct scc_port *port; 409 struct scc_port *port;
410 int error;
339 411
340 printk(KERN_INFO "SCC: BVME6000 Serial Driver\n"); 412 printk(KERN_INFO "SCC: BVME6000 Serial Driver\n");
341 /* Init channel A */ 413 /* Init channel A */
@@ -345,14 +417,23 @@ static int bvme6000_scc_init(void)
345 port->datap = port->ctrlp + 4; 417 port->datap = port->ctrlp + 4;
346 port->port_a = &scc_ports[0]; 418 port->port_a = &scc_ports[0];
347 port->port_b = &scc_ports[1]; 419 port->port_b = &scc_ports[1];
348 request_irq(BVME_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED, 420 error = request_irq(BVME_IRQ_SCCA_TX, scc_tx_int, IRQF_DISABLED,
349 "SCC-A TX", port); 421 "SCC-A TX", port);
350 request_irq(BVME_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED, 422 if (error)
423 goto fail;
424 error = request_irq(BVME_IRQ_SCCA_STAT, scc_stat_int, IRQF_DISABLED,
351 "SCC-A status", port); 425 "SCC-A status", port);
352 request_irq(BVME_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED, 426 if (error)
427 goto fail_free_a_tx;
428 error = request_irq(BVME_IRQ_SCCA_RX, scc_rx_int, IRQF_DISABLED,
353 "SCC-A RX", port); 429 "SCC-A RX", port);
354 request_irq(BVME_IRQ_SCCA_SPCOND, scc_spcond_int, IRQF_DISABLED, 430 if (error)
355 "SCC-A special cond", port); 431 goto fail_free_a_stat;
432 error = request_irq(BVME_IRQ_SCCA_SPCOND, scc_spcond_int,
433 IRQF_DISABLED, "SCC-A special cond", port);
434 if (error)
435 goto fail_free_a_rx;
436
356 { 437 {
357 SCC_ACCESS_INIT(port); 438 SCC_ACCESS_INIT(port);
358 439
@@ -372,14 +453,22 @@ static int bvme6000_scc_init(void)
372 port->datap = port->ctrlp + 4; 453 port->datap = port->ctrlp + 4;
373 port->port_a = &scc_ports[0]; 454 port->port_a = &scc_ports[0];
374 port->port_b = &scc_ports[1]; 455 port->port_b = &scc_ports[1];
375 request_irq(BVME_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED, 456 error = request_irq(BVME_IRQ_SCCB_TX, scc_tx_int, IRQF_DISABLED,
376 "SCC-B TX", port); 457 "SCC-B TX", port);
377 request_irq(BVME_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED, 458 if (error)
459 goto fail_free_a_spcond;
460 error = request_irq(BVME_IRQ_SCCB_STAT, scc_stat_int, IRQF_DISABLED,
378 "SCC-B status", port); 461 "SCC-B status", port);
379 request_irq(BVME_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED, 462 if (error)
463 goto fail_free_b_tx;
464 error = request_irq(BVME_IRQ_SCCB_RX, scc_rx_int, IRQF_DISABLED,
380 "SCC-B RX", port); 465 "SCC-B RX", port);
381 request_irq(BVME_IRQ_SCCB_SPCOND, scc_spcond_int, IRQF_DISABLED, 466 if (error)
382 "SCC-B special cond", port); 467 goto fail_free_b_stat;
468 error = request_irq(BVME_IRQ_SCCB_SPCOND, scc_spcond_int,
469 IRQF_DISABLED, "SCC-B special cond", port);
470 if (error)
471 goto fail_free_b_rx;
383 472
384 { 473 {
385 SCC_ACCESS_INIT(port); /* Either channel will do */ 474 SCC_ACCESS_INIT(port); /* Either channel will do */
@@ -393,6 +482,23 @@ static int bvme6000_scc_init(void)
393 scc_init_drivers(); 482 scc_init_drivers();
394 483
395 return 0; 484 return 0;
485
486fail:
487 free_irq(BVME_IRQ_SCCA_STAT, port);
488fail_free_a_tx:
489 free_irq(BVME_IRQ_SCCA_RX, port);
490fail_free_a_stat:
491 free_irq(BVME_IRQ_SCCA_SPCOND, port);
492fail_free_a_rx:
493 free_irq(BVME_IRQ_SCCB_TX, port);
494fail_free_a_spcond:
495 free_irq(BVME_IRQ_SCCB_STAT, port);
496fail_free_b_tx:
497 free_irq(BVME_IRQ_SCCB_RX, port);
498fail_free_b_stat:
499 free_irq(BVME_IRQ_SCCB_SPCOND, port);
500fail_free_b_rx:
501 return error;
396} 502}
397#endif 503#endif
398 504
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 80014213fb53..7900bd63b36d 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -969,8 +969,7 @@ int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int rows)
969 * Takes the console sem and the called methods then take the tty 969 * Takes the console sem and the called methods then take the tty
970 * termios_mutex and the tty ctrl_lock in that order. 970 * termios_mutex and the tty ctrl_lock in that order.
971 */ 971 */
972 972static int vt_resize(struct tty_struct *tty, struct winsize *ws)
973int vt_resize(struct tty_struct *tty, struct winsize *ws)
974{ 973{
975 struct vc_data *vc = tty->driver_data; 974 struct vc_data *vc = tty->driver_data;
976 int ret; 975 int ret;
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index 5f076aef74fa..a8c8d9c19d74 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -83,7 +83,7 @@ config CPU_FREQ_DEFAULT_GOV_USERSPACE
83 select CPU_FREQ_GOV_USERSPACE 83 select CPU_FREQ_GOV_USERSPACE
84 help 84 help
85 Use the CPUFreq governor 'userspace' as default. This allows 85 Use the CPUFreq governor 'userspace' as default. This allows
86 you to set the CPU frequency manually or when an userspace 86 you to set the CPU frequency manually or when a userspace
87 program shall be able to set the CPU dynamically without having 87 program shall be able to set the CPU dynamically without having
88 to enable the userspace governor manually. 88 to enable the userspace governor manually.
89 89
@@ -138,7 +138,7 @@ config CPU_FREQ_GOV_USERSPACE
138 tristate "'userspace' governor for userspace frequency scaling" 138 tristate "'userspace' governor for userspace frequency scaling"
139 help 139 help
140 Enable this cpufreq governor when you either want to set the 140 Enable this cpufreq governor when you either want to set the
141 CPU frequency manually or when an userspace program shall 141 CPU frequency manually or when a userspace program shall
142 be able to set the CPU dynamically, like on LART 142 be able to set the CPU dynamically, like on LART
143 <http://www.lartmaker.nl/>. 143 <http://www.lartmaker.nl/>.
144 144
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 01dde80597f7..b55cb67435bd 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -584,12 +584,12 @@ out:
584 return i; 584 return i;
585} 585}
586 586
587static ssize_t show_cpus(cpumask_t mask, char *buf) 587static ssize_t show_cpus(const struct cpumask *mask, char *buf)
588{ 588{
589 ssize_t i = 0; 589 ssize_t i = 0;
590 unsigned int cpu; 590 unsigned int cpu;
591 591
592 for_each_cpu_mask_nr(cpu, mask) { 592 for_each_cpu(cpu, mask) {
593 if (i) 593 if (i)
594 i += scnprintf(&buf[i], (PAGE_SIZE - i - 2), " "); 594 i += scnprintf(&buf[i], (PAGE_SIZE - i - 2), " ");
595 i += scnprintf(&buf[i], (PAGE_SIZE - i - 2), "%u", cpu); 595 i += scnprintf(&buf[i], (PAGE_SIZE - i - 2), "%u", cpu);
@@ -606,7 +606,7 @@ static ssize_t show_cpus(cpumask_t mask, char *buf)
606 */ 606 */
607static ssize_t show_related_cpus(struct cpufreq_policy *policy, char *buf) 607static ssize_t show_related_cpus(struct cpufreq_policy *policy, char *buf)
608{ 608{
609 if (cpus_empty(policy->related_cpus)) 609 if (cpumask_empty(policy->related_cpus))
610 return show_cpus(policy->cpus, buf); 610 return show_cpus(policy->cpus, buf);
611 return show_cpus(policy->related_cpus, buf); 611 return show_cpus(policy->related_cpus, buf);
612} 612}
@@ -806,9 +806,20 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
806 ret = -ENOMEM; 806 ret = -ENOMEM;
807 goto nomem_out; 807 goto nomem_out;
808 } 808 }
809 if (!alloc_cpumask_var(&policy->cpus, GFP_KERNEL)) {
810 kfree(policy);
811 ret = -ENOMEM;
812 goto nomem_out;
813 }
814 if (!alloc_cpumask_var(&policy->related_cpus, GFP_KERNEL)) {
815 free_cpumask_var(policy->cpus);
816 kfree(policy);
817 ret = -ENOMEM;
818 goto nomem_out;
819 }
809 820
810 policy->cpu = cpu; 821 policy->cpu = cpu;
811 policy->cpus = cpumask_of_cpu(cpu); 822 cpumask_copy(policy->cpus, cpumask_of(cpu));
812 823
813 /* Initially set CPU itself as the policy_cpu */ 824 /* Initially set CPU itself as the policy_cpu */
814 per_cpu(policy_cpu, cpu) = cpu; 825 per_cpu(policy_cpu, cpu) = cpu;
@@ -843,7 +854,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
843 } 854 }
844#endif 855#endif
845 856
846 for_each_cpu_mask_nr(j, policy->cpus) { 857 for_each_cpu(j, policy->cpus) {
847 if (cpu == j) 858 if (cpu == j)
848 continue; 859 continue;
849 860
@@ -861,7 +872,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
861 goto err_out_driver_exit; 872 goto err_out_driver_exit;
862 873
863 spin_lock_irqsave(&cpufreq_driver_lock, flags); 874 spin_lock_irqsave(&cpufreq_driver_lock, flags);
864 managed_policy->cpus = policy->cpus; 875 cpumask_copy(managed_policy->cpus, policy->cpus);
865 per_cpu(cpufreq_cpu_data, cpu) = managed_policy; 876 per_cpu(cpufreq_cpu_data, cpu) = managed_policy;
866 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 877 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
867 878
@@ -916,14 +927,14 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
916 } 927 }
917 928
918 spin_lock_irqsave(&cpufreq_driver_lock, flags); 929 spin_lock_irqsave(&cpufreq_driver_lock, flags);
919 for_each_cpu_mask_nr(j, policy->cpus) { 930 for_each_cpu(j, policy->cpus) {
920 per_cpu(cpufreq_cpu_data, j) = policy; 931 per_cpu(cpufreq_cpu_data, j) = policy;
921 per_cpu(policy_cpu, j) = policy->cpu; 932 per_cpu(policy_cpu, j) = policy->cpu;
922 } 933 }
923 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 934 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
924 935
925 /* symlink affected CPUs */ 936 /* symlink affected CPUs */
926 for_each_cpu_mask_nr(j, policy->cpus) { 937 for_each_cpu(j, policy->cpus) {
927 if (j == cpu) 938 if (j == cpu)
928 continue; 939 continue;
929 if (!cpu_online(j)) 940 if (!cpu_online(j))
@@ -963,7 +974,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
963 974
964err_out_unregister: 975err_out_unregister:
965 spin_lock_irqsave(&cpufreq_driver_lock, flags); 976 spin_lock_irqsave(&cpufreq_driver_lock, flags);
966 for_each_cpu_mask_nr(j, policy->cpus) 977 for_each_cpu(j, policy->cpus)
967 per_cpu(cpufreq_cpu_data, j) = NULL; 978 per_cpu(cpufreq_cpu_data, j) = NULL;
968 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 979 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
969 980
@@ -1024,7 +1035,7 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
1024 */ 1035 */
1025 if (unlikely(cpu != data->cpu)) { 1036 if (unlikely(cpu != data->cpu)) {
1026 dprintk("removing link\n"); 1037 dprintk("removing link\n");
1027 cpu_clear(cpu, data->cpus); 1038 cpumask_clear_cpu(cpu, data->cpus);
1028 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 1039 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
1029 sysfs_remove_link(&sys_dev->kobj, "cpufreq"); 1040 sysfs_remove_link(&sys_dev->kobj, "cpufreq");
1030 cpufreq_cpu_put(data); 1041 cpufreq_cpu_put(data);
@@ -1045,8 +1056,8 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
1045 * per_cpu(cpufreq_cpu_data) while holding the lock, and remove 1056 * per_cpu(cpufreq_cpu_data) while holding the lock, and remove
1046 * the sysfs links afterwards. 1057 * the sysfs links afterwards.
1047 */ 1058 */
1048 if (unlikely(cpus_weight(data->cpus) > 1)) { 1059 if (unlikely(cpumask_weight(data->cpus) > 1)) {
1049 for_each_cpu_mask_nr(j, data->cpus) { 1060 for_each_cpu(j, data->cpus) {
1050 if (j == cpu) 1061 if (j == cpu)
1051 continue; 1062 continue;
1052 per_cpu(cpufreq_cpu_data, j) = NULL; 1063 per_cpu(cpufreq_cpu_data, j) = NULL;
@@ -1055,8 +1066,8 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
1055 1066
1056 spin_unlock_irqrestore(&cpufreq_driver_lock, flags); 1067 spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
1057 1068
1058 if (unlikely(cpus_weight(data->cpus) > 1)) { 1069 if (unlikely(cpumask_weight(data->cpus) > 1)) {
1059 for_each_cpu_mask_nr(j, data->cpus) { 1070 for_each_cpu(j, data->cpus) {
1060 if (j == cpu) 1071 if (j == cpu)
1061 continue; 1072 continue;
1062 dprintk("removing link for cpu %u\n", j); 1073 dprintk("removing link for cpu %u\n", j);
@@ -1090,7 +1101,10 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)
1090 if (cpufreq_driver->exit) 1101 if (cpufreq_driver->exit)
1091 cpufreq_driver->exit(data); 1102 cpufreq_driver->exit(data);
1092 1103
1104 free_cpumask_var(data->related_cpus);
1105 free_cpumask_var(data->cpus);
1093 kfree(data); 1106 kfree(data);
1107 per_cpu(cpufreq_cpu_data, cpu) = NULL;
1094 1108
1095 cpufreq_debug_enable_ratelimit(); 1109 cpufreq_debug_enable_ratelimit();
1096 return 0; 1110 return 0;
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
index e2657837d954..0320962c4ec5 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -498,7 +498,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
498 return rc; 498 return rc;
499 } 499 }
500 500
501 for_each_cpu_mask_nr(j, policy->cpus) { 501 for_each_cpu(j, policy->cpus) {
502 struct cpu_dbs_info_s *j_dbs_info; 502 struct cpu_dbs_info_s *j_dbs_info;
503 j_dbs_info = &per_cpu(cpu_dbs_info, j); 503 j_dbs_info = &per_cpu(cpu_dbs_info, j);
504 j_dbs_info->cur_policy = policy; 504 j_dbs_info->cur_policy = policy;
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index 2ab3c12b88af..6a2b036c9389 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -400,7 +400,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
400 /* Get Absolute Load - in terms of freq */ 400 /* Get Absolute Load - in terms of freq */
401 max_load_freq = 0; 401 max_load_freq = 0;
402 402
403 for_each_cpu_mask_nr(j, policy->cpus) { 403 for_each_cpu(j, policy->cpus) {
404 struct cpu_dbs_info_s *j_dbs_info; 404 struct cpu_dbs_info_s *j_dbs_info;
405 cputime64_t cur_wall_time, cur_idle_time; 405 cputime64_t cur_wall_time, cur_idle_time;
406 unsigned int idle_time, wall_time; 406 unsigned int idle_time, wall_time;
@@ -568,7 +568,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
568 return rc; 568 return rc;
569 } 569 }
570 570
571 for_each_cpu_mask_nr(j, policy->cpus) { 571 for_each_cpu(j, policy->cpus) {
572 struct cpu_dbs_info_s *j_dbs_info; 572 struct cpu_dbs_info_s *j_dbs_info;
573 j_dbs_info = &per_cpu(cpu_dbs_info, j); 573 j_dbs_info = &per_cpu(cpu_dbs_info, j);
574 j_dbs_info->cur_policy = policy; 574 j_dbs_info->cur_policy = policy;
diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index 8d7cf3f31450..f1df59f59a37 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -15,12 +15,14 @@
15#include <linux/tick.h> 15#include <linux/tick.h>
16 16
17#define BREAK_FUZZ 4 /* 4 us */ 17#define BREAK_FUZZ 4 /* 4 us */
18#define PRED_HISTORY_PCT 50
18 19
19struct menu_device { 20struct menu_device {
20 int last_state_idx; 21 int last_state_idx;
21 22
22 unsigned int expected_us; 23 unsigned int expected_us;
23 unsigned int predicted_us; 24 unsigned int predicted_us;
25 unsigned int current_predicted_us;
24 unsigned int last_measured_us; 26 unsigned int last_measured_us;
25 unsigned int elapsed_us; 27 unsigned int elapsed_us;
26}; 28};
@@ -47,6 +49,12 @@ static int menu_select(struct cpuidle_device *dev)
47 data->expected_us = 49 data->expected_us =
48 (u32) ktime_to_ns(tick_nohz_get_sleep_length()) / 1000; 50 (u32) ktime_to_ns(tick_nohz_get_sleep_length()) / 1000;
49 51
52 /* Recalculate predicted_us based on prediction_history_pct */
53 data->predicted_us *= PRED_HISTORY_PCT;
54 data->predicted_us += (100 - PRED_HISTORY_PCT) *
55 data->current_predicted_us;
56 data->predicted_us /= 100;
57
50 /* find the deepest idle state that satisfies our constraints */ 58 /* find the deepest idle state that satisfies our constraints */
51 for (i = CPUIDLE_DRIVER_STATE_START + 1; i < dev->state_count; i++) { 59 for (i = CPUIDLE_DRIVER_STATE_START + 1; i < dev->state_count; i++) {
52 struct cpuidle_state *s = &dev->states[i]; 60 struct cpuidle_state *s = &dev->states[i];
@@ -97,7 +105,7 @@ static void menu_reflect(struct cpuidle_device *dev)
97 measured_us = -1; 105 measured_us = -1;
98 106
99 /* Predict time until next break event */ 107 /* Predict time until next break event */
100 data->predicted_us = max(measured_us, data->last_measured_us); 108 data->current_predicted_us = max(measured_us, data->last_measured_us);
101 109
102 if (last_idle_us + BREAK_FUZZ < 110 if (last_idle_us + BREAK_FUZZ <
103 data->expected_us - target->exit_latency) { 111 data->expected_us - target->exit_latency) {
diff --git a/drivers/dca/dca-core.c b/drivers/dca/dca-core.c
index d883e1b8bb8c..55433849bfa6 100644
--- a/drivers/dca/dca-core.c
+++ b/drivers/dca/dca-core.c
@@ -270,6 +270,6 @@ static void __exit dca_exit(void)
270 dca_sysfs_exit(); 270 dca_sysfs_exit();
271} 271}
272 272
273subsys_initcall(dca_init); 273arch_initcall(dca_init);
274module_exit(dca_exit); 274module_exit(dca_exit);
275 275
diff --git a/drivers/dio/dio-sysfs.c b/drivers/dio/dio-sysfs.c
index f46463038847..ee1a3b59bd4e 100644
--- a/drivers/dio/dio-sysfs.c
+++ b/drivers/dio/dio-sysfs.c
@@ -58,20 +58,25 @@ static ssize_t dio_show_resource(struct device *dev, struct device_attribute *at
58 struct dio_dev *d = to_dio_dev(dev); 58 struct dio_dev *d = to_dio_dev(dev);
59 59
60 return sprintf(buf, "0x%08lx 0x%08lx 0x%08lx\n", 60 return sprintf(buf, "0x%08lx 0x%08lx 0x%08lx\n",
61 dio_resource_start(d), dio_resource_end(d), 61 (unsigned long)dio_resource_start(d),
62 (unsigned long)dio_resource_end(d),
62 dio_resource_flags(d)); 63 dio_resource_flags(d));
63} 64}
64static DEVICE_ATTR(resource, S_IRUGO, dio_show_resource, NULL); 65static DEVICE_ATTR(resource, S_IRUGO, dio_show_resource, NULL);
65 66
66void dio_create_sysfs_dev_files(struct dio_dev *d) 67int dio_create_sysfs_dev_files(struct dio_dev *d)
67{ 68{
68 struct device *dev = &d->dev; 69 struct device *dev = &d->dev;
70 int error;
69 71
70 /* current configuration's attributes */ 72 /* current configuration's attributes */
71 device_create_file(dev, &dev_attr_id); 73 if ((error = device_create_file(dev, &dev_attr_id)) ||
72 device_create_file(dev, &dev_attr_ipl); 74 (error = device_create_file(dev, &dev_attr_ipl)) ||
73 device_create_file(dev, &dev_attr_secid); 75 (error = device_create_file(dev, &dev_attr_secid)) ||
74 device_create_file(dev, &dev_attr_name); 76 (error = device_create_file(dev, &dev_attr_name)) ||
75 device_create_file(dev, &dev_attr_resource); 77 (error = device_create_file(dev, &dev_attr_resource)))
78 return error;
79
80 return 0;
76} 81}
77 82
diff --git a/drivers/dio/dio.c b/drivers/dio/dio.c
index 07f274f853d9..10c3c498358c 100644
--- a/drivers/dio/dio.c
+++ b/drivers/dio/dio.c
@@ -173,6 +173,7 @@ static int __init dio_init(void)
173 mm_segment_t fs; 173 mm_segment_t fs;
174 int i; 174 int i;
175 struct dio_dev *dev; 175 struct dio_dev *dev;
176 int error;
176 177
177 if (!MACH_IS_HP300) 178 if (!MACH_IS_HP300)
178 return 0; 179 return 0;
@@ -182,7 +183,11 @@ static int __init dio_init(void)
182 /* Initialize the DIO bus */ 183 /* Initialize the DIO bus */
183 INIT_LIST_HEAD(&dio_bus.devices); 184 INIT_LIST_HEAD(&dio_bus.devices);
184 strcpy(dio_bus.dev.bus_id, "dio"); 185 strcpy(dio_bus.dev.bus_id, "dio");
185 device_register(&dio_bus.dev); 186 error = device_register(&dio_bus.dev);
187 if (error) {
188 pr_err("DIO: Error registering dio_bus\n");
189 return error;
190 }
186 191
187 /* Request all resources */ 192 /* Request all resources */
188 dio_bus.num_resources = (hp300_model == HP_320 ? 1 : 2); 193 dio_bus.num_resources = (hp300_model == HP_320 ? 1 : 2);
@@ -252,8 +257,15 @@ static int __init dio_init(void)
252 257
253 if (scode >= DIOII_SCBASE) 258 if (scode >= DIOII_SCBASE)
254 iounmap(va); 259 iounmap(va);
255 device_register(&dev->dev); 260 error = device_register(&dev->dev);
256 dio_create_sysfs_dev_files(dev); 261 if (error) {
262 pr_err("DIO: Error registering device %s\n",
263 dev->name);
264 continue;
265 }
266 error = dio_create_sysfs_dev_files(dev);
267 if (error)
268 dev_err(&dev->dev, "Error creating sysfs files\n");
257 } 269 }
258 return 0; 270 return 0;
259} 271}
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 904e57558bb5..e34b06420816 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -33,7 +33,6 @@ config INTEL_IOATDMA
33config INTEL_IOP_ADMA 33config INTEL_IOP_ADMA
34 tristate "Intel IOP ADMA support" 34 tristate "Intel IOP ADMA support"
35 depends on ARCH_IOP32X || ARCH_IOP33X || ARCH_IOP13XX 35 depends on ARCH_IOP32X || ARCH_IOP33X || ARCH_IOP13XX
36 select ASYNC_CORE
37 select DMA_ENGINE 36 select DMA_ENGINE
38 help 37 help
39 Enable support for the Intel(R) IOP Series RAID engines. 38 Enable support for the Intel(R) IOP Series RAID engines.
@@ -59,7 +58,6 @@ config FSL_DMA
59config MV_XOR 58config MV_XOR
60 bool "Marvell XOR engine support" 59 bool "Marvell XOR engine support"
61 depends on PLAT_ORION 60 depends on PLAT_ORION
62 select ASYNC_CORE
63 select DMA_ENGINE 61 select DMA_ENGINE
64 ---help--- 62 ---help---
65 Enable support for the Marvell XOR engine. 63 Enable support for the Marvell XOR engine.
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index 657996517374..403dbe781122 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -31,32 +31,18 @@
31 * 31 *
32 * LOCKING: 32 * LOCKING:
33 * 33 *
34 * The subsystem keeps two global lists, dma_device_list and dma_client_list. 34 * The subsystem keeps a global list of dma_device structs it is protected by a
35 * Both of these are protected by a mutex, dma_list_mutex. 35 * mutex, dma_list_mutex.
36 *
37 * A subsystem can get access to a channel by calling dmaengine_get() followed
38 * by dma_find_channel(), or if it has need for an exclusive channel it can call
39 * dma_request_channel(). Once a channel is allocated a reference is taken
40 * against its corresponding driver to disable removal.
36 * 41 *
37 * Each device has a channels list, which runs unlocked but is never modified 42 * Each device has a channels list, which runs unlocked but is never modified
38 * once the device is registered, it's just setup by the driver. 43 * once the device is registered, it's just setup by the driver.
39 * 44 *
40 * Each client is responsible for keeping track of the channels it uses. See 45 * See Documentation/dmaengine.txt for more details
41 * the definition of dma_event_callback in dmaengine.h.
42 *
43 * Each device has a kref, which is initialized to 1 when the device is
44 * registered. A kref_get is done for each device registered. When the
45 * device is released, the corresponding kref_put is done in the release
46 * method. Every time one of the device's channels is allocated to a client,
47 * a kref_get occurs. When the channel is freed, the corresponding kref_put
48 * happens. The device's release function does a completion, so
49 * unregister_device does a remove event, device_unregister, a kref_put
50 * for the first reference, then waits on the completion for all other
51 * references to finish.
52 *
53 * Each channel has an open-coded implementation of Rusty Russell's "bigref,"
54 * with a kref and a per_cpu local_t. A dma_chan_get is called when a client
55 * signals that it wants to use a channel, and dma_chan_put is called when
56 * a channel is removed or a client using it is unregistered. A client can
57 * take extra references per outstanding transaction, as is the case with
58 * the NET DMA client. The release function does a kref_put on the device.
59 * -ChrisL, DanW
60 */ 46 */
61 47
62#include <linux/init.h> 48#include <linux/init.h>
@@ -70,54 +56,85 @@
70#include <linux/rcupdate.h> 56#include <linux/rcupdate.h>
71#include <linux/mutex.h> 57#include <linux/mutex.h>
72#include <linux/jiffies.h> 58#include <linux/jiffies.h>
59#include <linux/rculist.h>
60#include <linux/idr.h>
73 61
74static DEFINE_MUTEX(dma_list_mutex); 62static DEFINE_MUTEX(dma_list_mutex);
75static LIST_HEAD(dma_device_list); 63static LIST_HEAD(dma_device_list);
76static LIST_HEAD(dma_client_list); 64static long dmaengine_ref_count;
65static struct idr dma_idr;
77 66
78/* --- sysfs implementation --- */ 67/* --- sysfs implementation --- */
79 68
69/**
70 * dev_to_dma_chan - convert a device pointer to the its sysfs container object
71 * @dev - device node
72 *
73 * Must be called under dma_list_mutex
74 */
75static struct dma_chan *dev_to_dma_chan(struct device *dev)
76{
77 struct dma_chan_dev *chan_dev;
78
79 chan_dev = container_of(dev, typeof(*chan_dev), device);
80 return chan_dev->chan;
81}
82
80static ssize_t show_memcpy_count(struct device *dev, struct device_attribute *attr, char *buf) 83static ssize_t show_memcpy_count(struct device *dev, struct device_attribute *attr, char *buf)
81{ 84{
82 struct dma_chan *chan = to_dma_chan(dev); 85 struct dma_chan *chan;
83 unsigned long count = 0; 86 unsigned long count = 0;
84 int i; 87 int i;
88 int err;
85 89
86 for_each_possible_cpu(i) 90 mutex_lock(&dma_list_mutex);
87 count += per_cpu_ptr(chan->local, i)->memcpy_count; 91 chan = dev_to_dma_chan(dev);
92 if (chan) {
93 for_each_possible_cpu(i)
94 count += per_cpu_ptr(chan->local, i)->memcpy_count;
95 err = sprintf(buf, "%lu\n", count);
96 } else
97 err = -ENODEV;
98 mutex_unlock(&dma_list_mutex);
88 99
89 return sprintf(buf, "%lu\n", count); 100 return err;
90} 101}
91 102
92static ssize_t show_bytes_transferred(struct device *dev, struct device_attribute *attr, 103static ssize_t show_bytes_transferred(struct device *dev, struct device_attribute *attr,
93 char *buf) 104 char *buf)
94{ 105{
95 struct dma_chan *chan = to_dma_chan(dev); 106 struct dma_chan *chan;
96 unsigned long count = 0; 107 unsigned long count = 0;
97 int i; 108 int i;
109 int err;
98 110
99 for_each_possible_cpu(i) 111 mutex_lock(&dma_list_mutex);
100 count += per_cpu_ptr(chan->local, i)->bytes_transferred; 112 chan = dev_to_dma_chan(dev);
113 if (chan) {
114 for_each_possible_cpu(i)
115 count += per_cpu_ptr(chan->local, i)->bytes_transferred;
116 err = sprintf(buf, "%lu\n", count);
117 } else
118 err = -ENODEV;
119 mutex_unlock(&dma_list_mutex);
101 120
102 return sprintf(buf, "%lu\n", count); 121 return err;
103} 122}
104 123
105static ssize_t show_in_use(struct device *dev, struct device_attribute *attr, char *buf) 124static ssize_t show_in_use(struct device *dev, struct device_attribute *attr, char *buf)
106{ 125{
107 struct dma_chan *chan = to_dma_chan(dev); 126 struct dma_chan *chan;
108 int in_use = 0; 127 int err;
109
110 if (unlikely(chan->slow_ref) &&
111 atomic_read(&chan->refcount.refcount) > 1)
112 in_use = 1;
113 else {
114 if (local_read(&(per_cpu_ptr(chan->local,
115 get_cpu())->refcount)) > 0)
116 in_use = 1;
117 put_cpu();
118 }
119 128
120 return sprintf(buf, "%d\n", in_use); 129 mutex_lock(&dma_list_mutex);
130 chan = dev_to_dma_chan(dev);
131 if (chan)
132 err = sprintf(buf, "%d\n", chan->client_count);
133 else
134 err = -ENODEV;
135 mutex_unlock(&dma_list_mutex);
136
137 return err;
121} 138}
122 139
123static struct device_attribute dma_attrs[] = { 140static struct device_attribute dma_attrs[] = {
@@ -127,76 +144,110 @@ static struct device_attribute dma_attrs[] = {
127 __ATTR_NULL 144 __ATTR_NULL
128}; 145};
129 146
130static void dma_async_device_cleanup(struct kref *kref); 147static void chan_dev_release(struct device *dev)
131
132static void dma_dev_release(struct device *dev)
133{ 148{
134 struct dma_chan *chan = to_dma_chan(dev); 149 struct dma_chan_dev *chan_dev;
135 kref_put(&chan->device->refcount, dma_async_device_cleanup); 150
151 chan_dev = container_of(dev, typeof(*chan_dev), device);
152 if (atomic_dec_and_test(chan_dev->idr_ref)) {
153 mutex_lock(&dma_list_mutex);
154 idr_remove(&dma_idr, chan_dev->dev_id);
155 mutex_unlock(&dma_list_mutex);
156 kfree(chan_dev->idr_ref);
157 }
158 kfree(chan_dev);
136} 159}
137 160
138static struct class dma_devclass = { 161static struct class dma_devclass = {
139 .name = "dma", 162 .name = "dma",
140 .dev_attrs = dma_attrs, 163 .dev_attrs = dma_attrs,
141 .dev_release = dma_dev_release, 164 .dev_release = chan_dev_release,
142}; 165};
143 166
144/* --- client and device registration --- */ 167/* --- client and device registration --- */
145 168
146#define dma_chan_satisfies_mask(chan, mask) \ 169#define dma_device_satisfies_mask(device, mask) \
147 __dma_chan_satisfies_mask((chan), &(mask)) 170 __dma_device_satisfies_mask((device), &(mask))
148static int 171static int
149__dma_chan_satisfies_mask(struct dma_chan *chan, dma_cap_mask_t *want) 172__dma_device_satisfies_mask(struct dma_device *device, dma_cap_mask_t *want)
150{ 173{
151 dma_cap_mask_t has; 174 dma_cap_mask_t has;
152 175
153 bitmap_and(has.bits, want->bits, chan->device->cap_mask.bits, 176 bitmap_and(has.bits, want->bits, device->cap_mask.bits,
154 DMA_TX_TYPE_END); 177 DMA_TX_TYPE_END);
155 return bitmap_equal(want->bits, has.bits, DMA_TX_TYPE_END); 178 return bitmap_equal(want->bits, has.bits, DMA_TX_TYPE_END);
156} 179}
157 180
181static struct module *dma_chan_to_owner(struct dma_chan *chan)
182{
183 return chan->device->dev->driver->owner;
184}
185
158/** 186/**
159 * dma_client_chan_alloc - try to allocate channels to a client 187 * balance_ref_count - catch up the channel reference count
160 * @client: &dma_client 188 * @chan - channel to balance ->client_count versus dmaengine_ref_count
161 * 189 *
162 * Called with dma_list_mutex held. 190 * balance_ref_count must be called under dma_list_mutex
163 */ 191 */
164static void dma_client_chan_alloc(struct dma_client *client) 192static void balance_ref_count(struct dma_chan *chan)
165{ 193{
166 struct dma_device *device; 194 struct module *owner = dma_chan_to_owner(chan);
167 struct dma_chan *chan;
168 int desc; /* allocated descriptor count */
169 enum dma_state_client ack;
170 195
171 /* Find a channel */ 196 while (chan->client_count < dmaengine_ref_count) {
172 list_for_each_entry(device, &dma_device_list, global_node) { 197 __module_get(owner);
173 /* Does the client require a specific DMA controller? */ 198 chan->client_count++;
174 if (client->slave && client->slave->dma_dev 199 }
175 && client->slave->dma_dev != device->dev) 200}
176 continue;
177 201
178 list_for_each_entry(chan, &device->channels, device_node) { 202/**
179 if (!dma_chan_satisfies_mask(chan, client->cap_mask)) 203 * dma_chan_get - try to grab a dma channel's parent driver module
180 continue; 204 * @chan - channel to grab
205 *
206 * Must be called under dma_list_mutex
207 */
208static int dma_chan_get(struct dma_chan *chan)
209{
210 int err = -ENODEV;
211 struct module *owner = dma_chan_to_owner(chan);
212
213 if (chan->client_count) {
214 __module_get(owner);
215 err = 0;
216 } else if (try_module_get(owner))
217 err = 0;
218
219 if (err == 0)
220 chan->client_count++;
221
222 /* allocate upon first client reference */
223 if (chan->client_count == 1 && err == 0) {
224 int desc_cnt = chan->device->device_alloc_chan_resources(chan);
225
226 if (desc_cnt < 0) {
227 err = desc_cnt;
228 chan->client_count = 0;
229 module_put(owner);
230 } else if (!dma_has_cap(DMA_PRIVATE, chan->device->cap_mask))
231 balance_ref_count(chan);
232 }
181 233
182 desc = chan->device->device_alloc_chan_resources( 234 return err;
183 chan, client); 235}
184 if (desc >= 0) {
185 ack = client->event_callback(client,
186 chan,
187 DMA_RESOURCE_AVAILABLE);
188 236
189 /* we are done once this client rejects 237/**
190 * an available resource 238 * dma_chan_put - drop a reference to a dma channel's parent driver module
191 */ 239 * @chan - channel to release
192 if (ack == DMA_ACK) { 240 *
193 dma_chan_get(chan); 241 * Must be called under dma_list_mutex
194 chan->client_count++; 242 */
195 } else if (ack == DMA_NAK) 243static void dma_chan_put(struct dma_chan *chan)
196 return; 244{
197 } 245 if (!chan->client_count)
198 } 246 return; /* this channel failed alloc_chan_resources */
199 } 247 chan->client_count--;
248 module_put(dma_chan_to_owner(chan));
249 if (chan->client_count == 0)
250 chan->device->device_free_chan_resources(chan);
200} 251}
201 252
202enum dma_status dma_sync_wait(struct dma_chan *chan, dma_cookie_t cookie) 253enum dma_status dma_sync_wait(struct dma_chan *chan, dma_cookie_t cookie)
@@ -218,138 +269,342 @@ enum dma_status dma_sync_wait(struct dma_chan *chan, dma_cookie_t cookie)
218EXPORT_SYMBOL(dma_sync_wait); 269EXPORT_SYMBOL(dma_sync_wait);
219 270
220/** 271/**
221 * dma_chan_cleanup - release a DMA channel's resources 272 * dma_cap_mask_all - enable iteration over all operation types
222 * @kref: kernel reference structure that contains the DMA channel device 273 */
274static dma_cap_mask_t dma_cap_mask_all;
275
276/**
277 * dma_chan_tbl_ent - tracks channel allocations per core/operation
278 * @chan - associated channel for this entry
279 */
280struct dma_chan_tbl_ent {
281 struct dma_chan *chan;
282};
283
284/**
285 * channel_table - percpu lookup table for memory-to-memory offload providers
223 */ 286 */
224void dma_chan_cleanup(struct kref *kref) 287static struct dma_chan_tbl_ent *channel_table[DMA_TX_TYPE_END];
288
289static int __init dma_channel_table_init(void)
225{ 290{
226 struct dma_chan *chan = container_of(kref, struct dma_chan, refcount); 291 enum dma_transaction_type cap;
227 chan->device->device_free_chan_resources(chan); 292 int err = 0;
228 kref_put(&chan->device->refcount, dma_async_device_cleanup); 293
294 bitmap_fill(dma_cap_mask_all.bits, DMA_TX_TYPE_END);
295
296 /* 'interrupt', 'private', and 'slave' are channel capabilities,
297 * but are not associated with an operation so they do not need
298 * an entry in the channel_table
299 */
300 clear_bit(DMA_INTERRUPT, dma_cap_mask_all.bits);
301 clear_bit(DMA_PRIVATE, dma_cap_mask_all.bits);
302 clear_bit(DMA_SLAVE, dma_cap_mask_all.bits);
303
304 for_each_dma_cap_mask(cap, dma_cap_mask_all) {
305 channel_table[cap] = alloc_percpu(struct dma_chan_tbl_ent);
306 if (!channel_table[cap]) {
307 err = -ENOMEM;
308 break;
309 }
310 }
311
312 if (err) {
313 pr_err("dmaengine: initialization failure\n");
314 for_each_dma_cap_mask(cap, dma_cap_mask_all)
315 if (channel_table[cap])
316 free_percpu(channel_table[cap]);
317 }
318
319 return err;
229} 320}
230EXPORT_SYMBOL(dma_chan_cleanup); 321arch_initcall(dma_channel_table_init);
231 322
232static void dma_chan_free_rcu(struct rcu_head *rcu) 323/**
324 * dma_find_channel - find a channel to carry out the operation
325 * @tx_type: transaction type
326 */
327struct dma_chan *dma_find_channel(enum dma_transaction_type tx_type)
233{ 328{
234 struct dma_chan *chan = container_of(rcu, struct dma_chan, rcu); 329 struct dma_chan *chan;
235 int bias = 0x7FFFFFFF; 330 int cpu;
236 int i; 331
237 for_each_possible_cpu(i) 332 WARN_ONCE(dmaengine_ref_count == 0,
238 bias -= local_read(&per_cpu_ptr(chan->local, i)->refcount); 333 "client called %s without a reference", __func__);
239 atomic_sub(bias, &chan->refcount.refcount); 334
240 kref_put(&chan->refcount, dma_chan_cleanup); 335 cpu = get_cpu();
336 chan = per_cpu_ptr(channel_table[tx_type], cpu)->chan;
337 put_cpu();
338
339 return chan;
241} 340}
341EXPORT_SYMBOL(dma_find_channel);
242 342
243static void dma_chan_release(struct dma_chan *chan) 343/**
344 * dma_issue_pending_all - flush all pending operations across all channels
345 */
346void dma_issue_pending_all(void)
244{ 347{
245 atomic_add(0x7FFFFFFF, &chan->refcount.refcount); 348 struct dma_device *device;
246 chan->slow_ref = 1; 349 struct dma_chan *chan;
247 call_rcu(&chan->rcu, dma_chan_free_rcu); 350
351 WARN_ONCE(dmaengine_ref_count == 0,
352 "client called %s without a reference", __func__);
353
354 rcu_read_lock();
355 list_for_each_entry_rcu(device, &dma_device_list, global_node) {
356 if (dma_has_cap(DMA_PRIVATE, device->cap_mask))
357 continue;
358 list_for_each_entry(chan, &device->channels, device_node)
359 if (chan->client_count)
360 device->device_issue_pending(chan);
361 }
362 rcu_read_unlock();
248} 363}
364EXPORT_SYMBOL(dma_issue_pending_all);
249 365
250/** 366/**
251 * dma_chans_notify_available - broadcast available channels to the clients 367 * nth_chan - returns the nth channel of the given capability
368 * @cap: capability to match
369 * @n: nth channel desired
370 *
371 * Defaults to returning the channel with the desired capability and the
372 * lowest reference count when 'n' cannot be satisfied. Must be called
373 * under dma_list_mutex.
252 */ 374 */
253static void dma_clients_notify_available(void) 375static struct dma_chan *nth_chan(enum dma_transaction_type cap, int n)
254{ 376{
255 struct dma_client *client; 377 struct dma_device *device;
378 struct dma_chan *chan;
379 struct dma_chan *ret = NULL;
380 struct dma_chan *min = NULL;
256 381
257 mutex_lock(&dma_list_mutex); 382 list_for_each_entry(device, &dma_device_list, global_node) {
383 if (!dma_has_cap(cap, device->cap_mask) ||
384 dma_has_cap(DMA_PRIVATE, device->cap_mask))
385 continue;
386 list_for_each_entry(chan, &device->channels, device_node) {
387 if (!chan->client_count)
388 continue;
389 if (!min)
390 min = chan;
391 else if (chan->table_count < min->table_count)
392 min = chan;
393
394 if (n-- == 0) {
395 ret = chan;
396 break; /* done */
397 }
398 }
399 if (ret)
400 break; /* done */
401 }
258 402
259 list_for_each_entry(client, &dma_client_list, global_node) 403 if (!ret)
260 dma_client_chan_alloc(client); 404 ret = min;
261 405
262 mutex_unlock(&dma_list_mutex); 406 if (ret)
407 ret->table_count++;
408
409 return ret;
263} 410}
264 411
265/** 412/**
266 * dma_chans_notify_available - tell the clients that a channel is going away 413 * dma_channel_rebalance - redistribute the available channels
267 * @chan: channel on its way out 414 *
415 * Optimize for cpu isolation (each cpu gets a dedicated channel for an
416 * operation type) in the SMP case, and operation isolation (avoid
417 * multi-tasking channels) in the non-SMP case. Must be called under
418 * dma_list_mutex.
268 */ 419 */
269static void dma_clients_notify_removed(struct dma_chan *chan) 420static void dma_channel_rebalance(void)
270{ 421{
271 struct dma_client *client; 422 struct dma_chan *chan;
272 enum dma_state_client ack; 423 struct dma_device *device;
424 int cpu;
425 int cap;
426 int n;
273 427
274 mutex_lock(&dma_list_mutex); 428 /* undo the last distribution */
429 for_each_dma_cap_mask(cap, dma_cap_mask_all)
430 for_each_possible_cpu(cpu)
431 per_cpu_ptr(channel_table[cap], cpu)->chan = NULL;
432
433 list_for_each_entry(device, &dma_device_list, global_node) {
434 if (dma_has_cap(DMA_PRIVATE, device->cap_mask))
435 continue;
436 list_for_each_entry(chan, &device->channels, device_node)
437 chan->table_count = 0;
438 }
275 439
276 list_for_each_entry(client, &dma_client_list, global_node) { 440 /* don't populate the channel_table if no clients are available */
277 ack = client->event_callback(client, chan, 441 if (!dmaengine_ref_count)
278 DMA_RESOURCE_REMOVED); 442 return;
279 443
280 /* client was holding resources for this channel so 444 /* redistribute available channels */
281 * free it 445 n = 0;
282 */ 446 for_each_dma_cap_mask(cap, dma_cap_mask_all)
283 if (ack == DMA_ACK) { 447 for_each_online_cpu(cpu) {
284 dma_chan_put(chan); 448 if (num_possible_cpus() > 1)
285 chan->client_count--; 449 chan = nth_chan(cap, n++);
450 else
451 chan = nth_chan(cap, -1);
452
453 per_cpu_ptr(channel_table[cap], cpu)->chan = chan;
454 }
455}
456
457static struct dma_chan *private_candidate(dma_cap_mask_t *mask, struct dma_device *dev,
458 dma_filter_fn fn, void *fn_param)
459{
460 struct dma_chan *chan;
461
462 if (!__dma_device_satisfies_mask(dev, mask)) {
463 pr_debug("%s: wrong capabilities\n", __func__);
464 return NULL;
465 }
466 /* devices with multiple channels need special handling as we need to
467 * ensure that all channels are either private or public.
468 */
469 if (dev->chancnt > 1 && !dma_has_cap(DMA_PRIVATE, dev->cap_mask))
470 list_for_each_entry(chan, &dev->channels, device_node) {
471 /* some channels are already publicly allocated */
472 if (chan->client_count)
473 return NULL;
286 } 474 }
475
476 list_for_each_entry(chan, &dev->channels, device_node) {
477 if (chan->client_count) {
478 pr_debug("%s: %s busy\n",
479 __func__, dma_chan_name(chan));
480 continue;
481 }
482 if (fn && !fn(chan, fn_param)) {
483 pr_debug("%s: %s filter said false\n",
484 __func__, dma_chan_name(chan));
485 continue;
486 }
487 return chan;
287 } 488 }
288 489
289 mutex_unlock(&dma_list_mutex); 490 return NULL;
290} 491}
291 492
292/** 493/**
293 * dma_async_client_register - register a &dma_client 494 * dma_request_channel - try to allocate an exclusive channel
294 * @client: ptr to a client structure with valid 'event_callback' and 'cap_mask' 495 * @mask: capabilities that the channel must satisfy
496 * @fn: optional callback to disposition available channels
497 * @fn_param: opaque parameter to pass to dma_filter_fn
295 */ 498 */
296void dma_async_client_register(struct dma_client *client) 499struct dma_chan *__dma_request_channel(dma_cap_mask_t *mask, dma_filter_fn fn, void *fn_param)
297{ 500{
298 /* validate client data */ 501 struct dma_device *device, *_d;
299 BUG_ON(dma_has_cap(DMA_SLAVE, client->cap_mask) && 502 struct dma_chan *chan = NULL;
300 !client->slave); 503 int err;
301 504
505 /* Find a channel */
506 mutex_lock(&dma_list_mutex);
507 list_for_each_entry_safe(device, _d, &dma_device_list, global_node) {
508 chan = private_candidate(mask, device, fn, fn_param);
509 if (chan) {
510 /* Found a suitable channel, try to grab, prep, and
511 * return it. We first set DMA_PRIVATE to disable
512 * balance_ref_count as this channel will not be
513 * published in the general-purpose allocator
514 */
515 dma_cap_set(DMA_PRIVATE, device->cap_mask);
516 err = dma_chan_get(chan);
517
518 if (err == -ENODEV) {
519 pr_debug("%s: %s module removed\n", __func__,
520 dma_chan_name(chan));
521 list_del_rcu(&device->global_node);
522 } else if (err)
523 pr_err("dmaengine: failed to get %s: (%d)\n",
524 dma_chan_name(chan), err);
525 else
526 break;
527 chan = NULL;
528 }
529 }
530 mutex_unlock(&dma_list_mutex);
531
532 pr_debug("%s: %s (%s)\n", __func__, chan ? "success" : "fail",
533 chan ? dma_chan_name(chan) : NULL);
534
535 return chan;
536}
537EXPORT_SYMBOL_GPL(__dma_request_channel);
538
539void dma_release_channel(struct dma_chan *chan)
540{
302 mutex_lock(&dma_list_mutex); 541 mutex_lock(&dma_list_mutex);
303 list_add_tail(&client->global_node, &dma_client_list); 542 WARN_ONCE(chan->client_count != 1,
543 "chan reference count %d != 1\n", chan->client_count);
544 dma_chan_put(chan);
304 mutex_unlock(&dma_list_mutex); 545 mutex_unlock(&dma_list_mutex);
305} 546}
306EXPORT_SYMBOL(dma_async_client_register); 547EXPORT_SYMBOL_GPL(dma_release_channel);
307 548
308/** 549/**
309 * dma_async_client_unregister - unregister a client and free the &dma_client 550 * dmaengine_get - register interest in dma_channels
310 * @client: &dma_client to free
311 *
312 * Force frees any allocated DMA channels, frees the &dma_client memory
313 */ 551 */
314void dma_async_client_unregister(struct dma_client *client) 552void dmaengine_get(void)
315{ 553{
316 struct dma_device *device; 554 struct dma_device *device, *_d;
317 struct dma_chan *chan; 555 struct dma_chan *chan;
318 enum dma_state_client ack; 556 int err;
319
320 if (!client)
321 return;
322 557
323 mutex_lock(&dma_list_mutex); 558 mutex_lock(&dma_list_mutex);
324 /* free all channels the client is holding */ 559 dmaengine_ref_count++;
325 list_for_each_entry(device, &dma_device_list, global_node)
326 list_for_each_entry(chan, &device->channels, device_node) {
327 ack = client->event_callback(client, chan,
328 DMA_RESOURCE_REMOVED);
329 560
330 if (ack == DMA_ACK) { 561 /* try to grab channels */
331 dma_chan_put(chan); 562 list_for_each_entry_safe(device, _d, &dma_device_list, global_node) {
332 chan->client_count--; 563 if (dma_has_cap(DMA_PRIVATE, device->cap_mask))
333 } 564 continue;
565 list_for_each_entry(chan, &device->channels, device_node) {
566 err = dma_chan_get(chan);
567 if (err == -ENODEV) {
568 /* module removed before we could use it */
569 list_del_rcu(&device->global_node);
570 break;
571 } else if (err)
572 pr_err("dmaengine: failed to get %s: (%d)\n",
573 dma_chan_name(chan), err);
334 } 574 }
575 }
335 576
336 list_del(&client->global_node); 577 /* if this is the first reference and there were channels
578 * waiting we need to rebalance to get those channels
579 * incorporated into the channel table
580 */
581 if (dmaengine_ref_count == 1)
582 dma_channel_rebalance();
337 mutex_unlock(&dma_list_mutex); 583 mutex_unlock(&dma_list_mutex);
338} 584}
339EXPORT_SYMBOL(dma_async_client_unregister); 585EXPORT_SYMBOL(dmaengine_get);
340 586
341/** 587/**
342 * dma_async_client_chan_request - send all available channels to the 588 * dmaengine_put - let dma drivers be removed when ref_count == 0
343 * client that satisfy the capability mask
344 * @client - requester
345 */ 589 */
346void dma_async_client_chan_request(struct dma_client *client) 590void dmaengine_put(void)
347{ 591{
592 struct dma_device *device;
593 struct dma_chan *chan;
594
348 mutex_lock(&dma_list_mutex); 595 mutex_lock(&dma_list_mutex);
349 dma_client_chan_alloc(client); 596 dmaengine_ref_count--;
597 BUG_ON(dmaengine_ref_count < 0);
598 /* drop channel references */
599 list_for_each_entry(device, &dma_device_list, global_node) {
600 if (dma_has_cap(DMA_PRIVATE, device->cap_mask))
601 continue;
602 list_for_each_entry(chan, &device->channels, device_node)
603 dma_chan_put(chan);
604 }
350 mutex_unlock(&dma_list_mutex); 605 mutex_unlock(&dma_list_mutex);
351} 606}
352EXPORT_SYMBOL(dma_async_client_chan_request); 607EXPORT_SYMBOL(dmaengine_put);
353 608
354/** 609/**
355 * dma_async_device_register - registers DMA devices found 610 * dma_async_device_register - registers DMA devices found
@@ -357,9 +612,9 @@ EXPORT_SYMBOL(dma_async_client_chan_request);
357 */ 612 */
358int dma_async_device_register(struct dma_device *device) 613int dma_async_device_register(struct dma_device *device)
359{ 614{
360 static int id;
361 int chancnt = 0, rc; 615 int chancnt = 0, rc;
362 struct dma_chan* chan; 616 struct dma_chan* chan;
617 atomic_t *idr_ref;
363 618
364 if (!device) 619 if (!device)
365 return -ENODEV; 620 return -ENODEV;
@@ -386,57 +641,83 @@ int dma_async_device_register(struct dma_device *device)
386 BUG_ON(!device->device_issue_pending); 641 BUG_ON(!device->device_issue_pending);
387 BUG_ON(!device->dev); 642 BUG_ON(!device->dev);
388 643
389 init_completion(&device->done); 644 idr_ref = kmalloc(sizeof(*idr_ref), GFP_KERNEL);
390 kref_init(&device->refcount); 645 if (!idr_ref)
391 646 return -ENOMEM;
647 atomic_set(idr_ref, 0);
648 idr_retry:
649 if (!idr_pre_get(&dma_idr, GFP_KERNEL))
650 return -ENOMEM;
392 mutex_lock(&dma_list_mutex); 651 mutex_lock(&dma_list_mutex);
393 device->dev_id = id++; 652 rc = idr_get_new(&dma_idr, NULL, &device->dev_id);
394 mutex_unlock(&dma_list_mutex); 653 mutex_unlock(&dma_list_mutex);
654 if (rc == -EAGAIN)
655 goto idr_retry;
656 else if (rc != 0)
657 return rc;
395 658
396 /* represent channels in sysfs. Probably want devs too */ 659 /* represent channels in sysfs. Probably want devs too */
397 list_for_each_entry(chan, &device->channels, device_node) { 660 list_for_each_entry(chan, &device->channels, device_node) {
398 chan->local = alloc_percpu(typeof(*chan->local)); 661 chan->local = alloc_percpu(typeof(*chan->local));
399 if (chan->local == NULL) 662 if (chan->local == NULL)
400 continue; 663 continue;
664 chan->dev = kzalloc(sizeof(*chan->dev), GFP_KERNEL);
665 if (chan->dev == NULL) {
666 free_percpu(chan->local);
667 continue;
668 }
401 669
402 chan->chan_id = chancnt++; 670 chan->chan_id = chancnt++;
403 chan->dev.class = &dma_devclass; 671 chan->dev->device.class = &dma_devclass;
404 chan->dev.parent = device->dev; 672 chan->dev->device.parent = device->dev;
405 dev_set_name(&chan->dev, "dma%dchan%d", 673 chan->dev->chan = chan;
674 chan->dev->idr_ref = idr_ref;
675 chan->dev->dev_id = device->dev_id;
676 atomic_inc(idr_ref);
677 dev_set_name(&chan->dev->device, "dma%dchan%d",
406 device->dev_id, chan->chan_id); 678 device->dev_id, chan->chan_id);
407 679
408 rc = device_register(&chan->dev); 680 rc = device_register(&chan->dev->device);
409 if (rc) { 681 if (rc) {
410 chancnt--;
411 free_percpu(chan->local); 682 free_percpu(chan->local);
412 chan->local = NULL; 683 chan->local = NULL;
413 goto err_out; 684 goto err_out;
414 } 685 }
415
416 /* One for the channel, one of the class device */
417 kref_get(&device->refcount);
418 kref_get(&device->refcount);
419 kref_init(&chan->refcount);
420 chan->client_count = 0; 686 chan->client_count = 0;
421 chan->slow_ref = 0;
422 INIT_RCU_HEAD(&chan->rcu);
423 } 687 }
688 device->chancnt = chancnt;
424 689
425 mutex_lock(&dma_list_mutex); 690 mutex_lock(&dma_list_mutex);
426 list_add_tail(&device->global_node, &dma_device_list); 691 /* take references on public channels */
692 if (dmaengine_ref_count && !dma_has_cap(DMA_PRIVATE, device->cap_mask))
693 list_for_each_entry(chan, &device->channels, device_node) {
694 /* if clients are already waiting for channels we need
695 * to take references on their behalf
696 */
697 if (dma_chan_get(chan) == -ENODEV) {
698 /* note we can only get here for the first
699 * channel as the remaining channels are
700 * guaranteed to get a reference
701 */
702 rc = -ENODEV;
703 mutex_unlock(&dma_list_mutex);
704 goto err_out;
705 }
706 }
707 list_add_tail_rcu(&device->global_node, &dma_device_list);
708 dma_channel_rebalance();
427 mutex_unlock(&dma_list_mutex); 709 mutex_unlock(&dma_list_mutex);
428 710
429 dma_clients_notify_available();
430
431 return 0; 711 return 0;
432 712
433err_out: 713err_out:
434 list_for_each_entry(chan, &device->channels, device_node) { 714 list_for_each_entry(chan, &device->channels, device_node) {
435 if (chan->local == NULL) 715 if (chan->local == NULL)
436 continue; 716 continue;
437 kref_put(&device->refcount, dma_async_device_cleanup); 717 mutex_lock(&dma_list_mutex);
438 device_unregister(&chan->dev); 718 chan->dev->chan = NULL;
439 chancnt--; 719 mutex_unlock(&dma_list_mutex);
720 device_unregister(&chan->dev->device);
440 free_percpu(chan->local); 721 free_percpu(chan->local);
441 } 722 }
442 return rc; 723 return rc;
@@ -444,37 +725,30 @@ err_out:
444EXPORT_SYMBOL(dma_async_device_register); 725EXPORT_SYMBOL(dma_async_device_register);
445 726
446/** 727/**
447 * dma_async_device_cleanup - function called when all references are released 728 * dma_async_device_unregister - unregister a DMA device
448 * @kref: kernel reference object
449 */
450static void dma_async_device_cleanup(struct kref *kref)
451{
452 struct dma_device *device;
453
454 device = container_of(kref, struct dma_device, refcount);
455 complete(&device->done);
456}
457
458/**
459 * dma_async_device_unregister - unregisters DMA devices
460 * @device: &dma_device 729 * @device: &dma_device
730 *
731 * This routine is called by dma driver exit routines, dmaengine holds module
732 * references to prevent it being called while channels are in use.
461 */ 733 */
462void dma_async_device_unregister(struct dma_device *device) 734void dma_async_device_unregister(struct dma_device *device)
463{ 735{
464 struct dma_chan *chan; 736 struct dma_chan *chan;
465 737
466 mutex_lock(&dma_list_mutex); 738 mutex_lock(&dma_list_mutex);
467 list_del(&device->global_node); 739 list_del_rcu(&device->global_node);
740 dma_channel_rebalance();
468 mutex_unlock(&dma_list_mutex); 741 mutex_unlock(&dma_list_mutex);
469 742
470 list_for_each_entry(chan, &device->channels, device_node) { 743 list_for_each_entry(chan, &device->channels, device_node) {
471 dma_clients_notify_removed(chan); 744 WARN_ONCE(chan->client_count,
472 device_unregister(&chan->dev); 745 "%s called while %d clients hold a reference\n",
473 dma_chan_release(chan); 746 __func__, chan->client_count);
747 mutex_lock(&dma_list_mutex);
748 chan->dev->chan = NULL;
749 mutex_unlock(&dma_list_mutex);
750 device_unregister(&chan->dev->device);
474 } 751 }
475
476 kref_put(&device->refcount, dma_async_device_cleanup);
477 wait_for_completion(&device->done);
478} 752}
479EXPORT_SYMBOL(dma_async_device_unregister); 753EXPORT_SYMBOL(dma_async_device_unregister);
480 754
@@ -626,10 +900,96 @@ void dma_async_tx_descriptor_init(struct dma_async_tx_descriptor *tx,
626} 900}
627EXPORT_SYMBOL(dma_async_tx_descriptor_init); 901EXPORT_SYMBOL(dma_async_tx_descriptor_init);
628 902
903/* dma_wait_for_async_tx - spin wait for a transaction to complete
904 * @tx: in-flight transaction to wait on
905 *
906 * This routine assumes that tx was obtained from a call to async_memcpy,
907 * async_xor, async_memset, etc which ensures that tx is "in-flight" (prepped
908 * and submitted). Walking the parent chain is only meant to cover for DMA
909 * drivers that do not implement the DMA_INTERRUPT capability and may race with
910 * the driver's descriptor cleanup routine.
911 */
912enum dma_status
913dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx)
914{
915 enum dma_status status;
916 struct dma_async_tx_descriptor *iter;
917 struct dma_async_tx_descriptor *parent;
918
919 if (!tx)
920 return DMA_SUCCESS;
921
922 WARN_ONCE(tx->parent, "%s: speculatively walking dependency chain for"
923 " %s\n", __func__, dma_chan_name(tx->chan));
924
925 /* poll through the dependency chain, return when tx is complete */
926 do {
927 iter = tx;
928
929 /* find the root of the unsubmitted dependency chain */
930 do {
931 parent = iter->parent;
932 if (!parent)
933 break;
934 else
935 iter = parent;
936 } while (parent);
937
938 /* there is a small window for ->parent == NULL and
939 * ->cookie == -EBUSY
940 */
941 while (iter->cookie == -EBUSY)
942 cpu_relax();
943
944 status = dma_sync_wait(iter->chan, iter->cookie);
945 } while (status == DMA_IN_PROGRESS || (iter != tx));
946
947 return status;
948}
949EXPORT_SYMBOL_GPL(dma_wait_for_async_tx);
950
951/* dma_run_dependencies - helper routine for dma drivers to process
952 * (start) dependent operations on their target channel
953 * @tx: transaction with dependencies
954 */
955void dma_run_dependencies(struct dma_async_tx_descriptor *tx)
956{
957 struct dma_async_tx_descriptor *dep = tx->next;
958 struct dma_async_tx_descriptor *dep_next;
959 struct dma_chan *chan;
960
961 if (!dep)
962 return;
963
964 chan = dep->chan;
965
966 /* keep submitting up until a channel switch is detected
967 * in that case we will be called again as a result of
968 * processing the interrupt from async_tx_channel_switch
969 */
970 for (; dep; dep = dep_next) {
971 spin_lock_bh(&dep->lock);
972 dep->parent = NULL;
973 dep_next = dep->next;
974 if (dep_next && dep_next->chan == chan)
975 dep->next = NULL; /* ->next will be submitted */
976 else
977 dep_next = NULL; /* submit current dep and terminate */
978 spin_unlock_bh(&dep->lock);
979
980 dep->tx_submit(dep);
981 }
982
983 chan->device->device_issue_pending(chan);
984}
985EXPORT_SYMBOL_GPL(dma_run_dependencies);
986
629static int __init dma_bus_init(void) 987static int __init dma_bus_init(void)
630{ 988{
989 idr_init(&dma_idr);
631 mutex_init(&dma_list_mutex); 990 mutex_init(&dma_list_mutex);
632 return class_register(&dma_devclass); 991 return class_register(&dma_devclass);
633} 992}
634subsys_initcall(dma_bus_init); 993arch_initcall(dma_bus_init);
994
635 995
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index ed9636bfb54a..3603f1ea5b28 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -35,7 +35,7 @@ MODULE_PARM_DESC(threads_per_chan,
35 35
36static unsigned int max_channels; 36static unsigned int max_channels;
37module_param(max_channels, uint, S_IRUGO); 37module_param(max_channels, uint, S_IRUGO);
38MODULE_PARM_DESC(nr_channels, 38MODULE_PARM_DESC(max_channels,
39 "Maximum number of channels to use (default: all)"); 39 "Maximum number of channels to use (default: all)");
40 40
41/* 41/*
@@ -71,7 +71,7 @@ struct dmatest_chan {
71 71
72/* 72/*
73 * These are protected by dma_list_mutex since they're only used by 73 * These are protected by dma_list_mutex since they're only used by
74 * the DMA client event callback 74 * the DMA filter function callback
75 */ 75 */
76static LIST_HEAD(dmatest_channels); 76static LIST_HEAD(dmatest_channels);
77static unsigned int nr_channels; 77static unsigned int nr_channels;
@@ -80,7 +80,7 @@ static bool dmatest_match_channel(struct dma_chan *chan)
80{ 80{
81 if (test_channel[0] == '\0') 81 if (test_channel[0] == '\0')
82 return true; 82 return true;
83 return strcmp(dev_name(&chan->dev), test_channel) == 0; 83 return strcmp(dma_chan_name(chan), test_channel) == 0;
84} 84}
85 85
86static bool dmatest_match_device(struct dma_device *device) 86static bool dmatest_match_device(struct dma_device *device)
@@ -215,7 +215,6 @@ static int dmatest_func(void *data)
215 215
216 smp_rmb(); 216 smp_rmb();
217 chan = thread->chan; 217 chan = thread->chan;
218 dma_chan_get(chan);
219 218
220 while (!kthread_should_stop()) { 219 while (!kthread_should_stop()) {
221 total_tests++; 220 total_tests++;
@@ -293,7 +292,6 @@ static int dmatest_func(void *data)
293 } 292 }
294 293
295 ret = 0; 294 ret = 0;
296 dma_chan_put(chan);
297 kfree(thread->dstbuf); 295 kfree(thread->dstbuf);
298err_dstbuf: 296err_dstbuf:
299 kfree(thread->srcbuf); 297 kfree(thread->srcbuf);
@@ -319,21 +317,16 @@ static void dmatest_cleanup_channel(struct dmatest_chan *dtc)
319 kfree(dtc); 317 kfree(dtc);
320} 318}
321 319
322static enum dma_state_client dmatest_add_channel(struct dma_chan *chan) 320static int dmatest_add_channel(struct dma_chan *chan)
323{ 321{
324 struct dmatest_chan *dtc; 322 struct dmatest_chan *dtc;
325 struct dmatest_thread *thread; 323 struct dmatest_thread *thread;
326 unsigned int i; 324 unsigned int i;
327 325
328 /* Have we already been told about this channel? */
329 list_for_each_entry(dtc, &dmatest_channels, node)
330 if (dtc->chan == chan)
331 return DMA_DUP;
332
333 dtc = kmalloc(sizeof(struct dmatest_chan), GFP_KERNEL); 326 dtc = kmalloc(sizeof(struct dmatest_chan), GFP_KERNEL);
334 if (!dtc) { 327 if (!dtc) {
335 pr_warning("dmatest: No memory for %s\n", dev_name(&chan->dev)); 328 pr_warning("dmatest: No memory for %s\n", dma_chan_name(chan));
336 return DMA_NAK; 329 return -ENOMEM;
337 } 330 }
338 331
339 dtc->chan = chan; 332 dtc->chan = chan;
@@ -343,16 +336,16 @@ static enum dma_state_client dmatest_add_channel(struct dma_chan *chan)
343 thread = kzalloc(sizeof(struct dmatest_thread), GFP_KERNEL); 336 thread = kzalloc(sizeof(struct dmatest_thread), GFP_KERNEL);
344 if (!thread) { 337 if (!thread) {
345 pr_warning("dmatest: No memory for %s-test%u\n", 338 pr_warning("dmatest: No memory for %s-test%u\n",
346 dev_name(&chan->dev), i); 339 dma_chan_name(chan), i);
347 break; 340 break;
348 } 341 }
349 thread->chan = dtc->chan; 342 thread->chan = dtc->chan;
350 smp_wmb(); 343 smp_wmb();
351 thread->task = kthread_run(dmatest_func, thread, "%s-test%u", 344 thread->task = kthread_run(dmatest_func, thread, "%s-test%u",
352 dev_name(&chan->dev), i); 345 dma_chan_name(chan), i);
353 if (IS_ERR(thread->task)) { 346 if (IS_ERR(thread->task)) {
354 pr_warning("dmatest: Failed to run thread %s-test%u\n", 347 pr_warning("dmatest: Failed to run thread %s-test%u\n",
355 dev_name(&chan->dev), i); 348 dma_chan_name(chan), i);
356 kfree(thread); 349 kfree(thread);
357 break; 350 break;
358 } 351 }
@@ -362,86 +355,62 @@ static enum dma_state_client dmatest_add_channel(struct dma_chan *chan)
362 list_add_tail(&thread->node, &dtc->threads); 355 list_add_tail(&thread->node, &dtc->threads);
363 } 356 }
364 357
365 pr_info("dmatest: Started %u threads using %s\n", i, dev_name(&chan->dev)); 358 pr_info("dmatest: Started %u threads using %s\n", i, dma_chan_name(chan));
366 359
367 list_add_tail(&dtc->node, &dmatest_channels); 360 list_add_tail(&dtc->node, &dmatest_channels);
368 nr_channels++; 361 nr_channels++;
369 362
370 return DMA_ACK; 363 return 0;
371}
372
373static enum dma_state_client dmatest_remove_channel(struct dma_chan *chan)
374{
375 struct dmatest_chan *dtc, *_dtc;
376
377 list_for_each_entry_safe(dtc, _dtc, &dmatest_channels, node) {
378 if (dtc->chan == chan) {
379 list_del(&dtc->node);
380 dmatest_cleanup_channel(dtc);
381 pr_debug("dmatest: lost channel %s\n",
382 dev_name(&chan->dev));
383 return DMA_ACK;
384 }
385 }
386
387 return DMA_DUP;
388} 364}
389 365
390/* 366static bool filter(struct dma_chan *chan, void *param)
391 * Start testing threads as new channels are assigned to us, and kill
392 * them when the channels go away.
393 *
394 * When we unregister the client, all channels are removed so this
395 * will also take care of cleaning things up when the module is
396 * unloaded.
397 */
398static enum dma_state_client
399dmatest_event(struct dma_client *client, struct dma_chan *chan,
400 enum dma_state state)
401{ 367{
402 enum dma_state_client ack = DMA_NAK; 368 if (!dmatest_match_channel(chan) || !dmatest_match_device(chan->device))
403 369 return false;
404 switch (state) { 370 else
405 case DMA_RESOURCE_AVAILABLE: 371 return true;
406 if (!dmatest_match_channel(chan)
407 || !dmatest_match_device(chan->device))
408 ack = DMA_DUP;
409 else if (max_channels && nr_channels >= max_channels)
410 ack = DMA_NAK;
411 else
412 ack = dmatest_add_channel(chan);
413 break;
414
415 case DMA_RESOURCE_REMOVED:
416 ack = dmatest_remove_channel(chan);
417 break;
418
419 default:
420 pr_info("dmatest: Unhandled event %u (%s)\n",
421 state, dev_name(&chan->dev));
422 break;
423 }
424
425 return ack;
426} 372}
427 373
428static struct dma_client dmatest_client = {
429 .event_callback = dmatest_event,
430};
431
432static int __init dmatest_init(void) 374static int __init dmatest_init(void)
433{ 375{
434 dma_cap_set(DMA_MEMCPY, dmatest_client.cap_mask); 376 dma_cap_mask_t mask;
435 dma_async_client_register(&dmatest_client); 377 struct dma_chan *chan;
436 dma_async_client_chan_request(&dmatest_client); 378 int err = 0;
379
380 dma_cap_zero(mask);
381 dma_cap_set(DMA_MEMCPY, mask);
382 for (;;) {
383 chan = dma_request_channel(mask, filter, NULL);
384 if (chan) {
385 err = dmatest_add_channel(chan);
386 if (err == 0)
387 continue;
388 else {
389 dma_release_channel(chan);
390 break; /* add_channel failed, punt */
391 }
392 } else
393 break; /* no more channels available */
394 if (max_channels && nr_channels >= max_channels)
395 break; /* we have all we need */
396 }
437 397
438 return 0; 398 return err;
439} 399}
440module_init(dmatest_init); 400/* when compiled-in wait for drivers to load first */
401late_initcall(dmatest_init);
441 402
442static void __exit dmatest_exit(void) 403static void __exit dmatest_exit(void)
443{ 404{
444 dma_async_client_unregister(&dmatest_client); 405 struct dmatest_chan *dtc, *_dtc;
406
407 list_for_each_entry_safe(dtc, _dtc, &dmatest_channels, node) {
408 list_del(&dtc->node);
409 dmatest_cleanup_channel(dtc);
410 pr_debug("dmatest: dropped channel %s\n",
411 dma_chan_name(dtc->chan));
412 dma_release_channel(dtc->chan);
413 }
445} 414}
446module_exit(dmatest_exit); 415module_exit(dmatest_exit);
447 416
diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index 0778d99aea7c..6b702cc46b3d 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -70,6 +70,15 @@
70 * the controller, though. 70 * the controller, though.
71 */ 71 */
72 72
73static struct device *chan2dev(struct dma_chan *chan)
74{
75 return &chan->dev->device;
76}
77static struct device *chan2parent(struct dma_chan *chan)
78{
79 return chan->dev->device.parent;
80}
81
73static struct dw_desc *dwc_first_active(struct dw_dma_chan *dwc) 82static struct dw_desc *dwc_first_active(struct dw_dma_chan *dwc)
74{ 83{
75 return list_entry(dwc->active_list.next, struct dw_desc, desc_node); 84 return list_entry(dwc->active_list.next, struct dw_desc, desc_node);
@@ -93,12 +102,12 @@ static struct dw_desc *dwc_desc_get(struct dw_dma_chan *dwc)
93 ret = desc; 102 ret = desc;
94 break; 103 break;
95 } 104 }
96 dev_dbg(&dwc->chan.dev, "desc %p not ACKed\n", desc); 105 dev_dbg(chan2dev(&dwc->chan), "desc %p not ACKed\n", desc);
97 i++; 106 i++;
98 } 107 }
99 spin_unlock_bh(&dwc->lock); 108 spin_unlock_bh(&dwc->lock);
100 109
101 dev_vdbg(&dwc->chan.dev, "scanned %u descriptors on freelist\n", i); 110 dev_vdbg(chan2dev(&dwc->chan), "scanned %u descriptors on freelist\n", i);
102 111
103 return ret; 112 return ret;
104} 113}
@@ -108,10 +117,10 @@ static void dwc_sync_desc_for_cpu(struct dw_dma_chan *dwc, struct dw_desc *desc)
108 struct dw_desc *child; 117 struct dw_desc *child;
109 118
110 list_for_each_entry(child, &desc->txd.tx_list, desc_node) 119 list_for_each_entry(child, &desc->txd.tx_list, desc_node)
111 dma_sync_single_for_cpu(dwc->chan.dev.parent, 120 dma_sync_single_for_cpu(chan2parent(&dwc->chan),
112 child->txd.phys, sizeof(child->lli), 121 child->txd.phys, sizeof(child->lli),
113 DMA_TO_DEVICE); 122 DMA_TO_DEVICE);
114 dma_sync_single_for_cpu(dwc->chan.dev.parent, 123 dma_sync_single_for_cpu(chan2parent(&dwc->chan),
115 desc->txd.phys, sizeof(desc->lli), 124 desc->txd.phys, sizeof(desc->lli),
116 DMA_TO_DEVICE); 125 DMA_TO_DEVICE);
117} 126}
@@ -129,11 +138,11 @@ static void dwc_desc_put(struct dw_dma_chan *dwc, struct dw_desc *desc)
129 138
130 spin_lock_bh(&dwc->lock); 139 spin_lock_bh(&dwc->lock);
131 list_for_each_entry(child, &desc->txd.tx_list, desc_node) 140 list_for_each_entry(child, &desc->txd.tx_list, desc_node)
132 dev_vdbg(&dwc->chan.dev, 141 dev_vdbg(chan2dev(&dwc->chan),
133 "moving child desc %p to freelist\n", 142 "moving child desc %p to freelist\n",
134 child); 143 child);
135 list_splice_init(&desc->txd.tx_list, &dwc->free_list); 144 list_splice_init(&desc->txd.tx_list, &dwc->free_list);
136 dev_vdbg(&dwc->chan.dev, "moving desc %p to freelist\n", desc); 145 dev_vdbg(chan2dev(&dwc->chan), "moving desc %p to freelist\n", desc);
137 list_add(&desc->desc_node, &dwc->free_list); 146 list_add(&desc->desc_node, &dwc->free_list);
138 spin_unlock_bh(&dwc->lock); 147 spin_unlock_bh(&dwc->lock);
139 } 148 }
@@ -163,9 +172,9 @@ static void dwc_dostart(struct dw_dma_chan *dwc, struct dw_desc *first)
163 172
164 /* ASSERT: channel is idle */ 173 /* ASSERT: channel is idle */
165 if (dma_readl(dw, CH_EN) & dwc->mask) { 174 if (dma_readl(dw, CH_EN) & dwc->mask) {
166 dev_err(&dwc->chan.dev, 175 dev_err(chan2dev(&dwc->chan),
167 "BUG: Attempted to start non-idle channel\n"); 176 "BUG: Attempted to start non-idle channel\n");
168 dev_err(&dwc->chan.dev, 177 dev_err(chan2dev(&dwc->chan),
169 " SAR: 0x%x DAR: 0x%x LLP: 0x%x CTL: 0x%x:%08x\n", 178 " SAR: 0x%x DAR: 0x%x LLP: 0x%x CTL: 0x%x:%08x\n",
170 channel_readl(dwc, SAR), 179 channel_readl(dwc, SAR),
171 channel_readl(dwc, DAR), 180 channel_readl(dwc, DAR),
@@ -193,7 +202,7 @@ dwc_descriptor_complete(struct dw_dma_chan *dwc, struct dw_desc *desc)
193 void *param; 202 void *param;
194 struct dma_async_tx_descriptor *txd = &desc->txd; 203 struct dma_async_tx_descriptor *txd = &desc->txd;
195 204
196 dev_vdbg(&dwc->chan.dev, "descriptor %u complete\n", txd->cookie); 205 dev_vdbg(chan2dev(&dwc->chan), "descriptor %u complete\n", txd->cookie);
197 206
198 dwc->completed = txd->cookie; 207 dwc->completed = txd->cookie;
199 callback = txd->callback; 208 callback = txd->callback;
@@ -208,11 +217,11 @@ dwc_descriptor_complete(struct dw_dma_chan *dwc, struct dw_desc *desc)
208 * mapped before they were submitted... 217 * mapped before they were submitted...
209 */ 218 */
210 if (!(txd->flags & DMA_COMPL_SKIP_DEST_UNMAP)) 219 if (!(txd->flags & DMA_COMPL_SKIP_DEST_UNMAP))
211 dma_unmap_page(dwc->chan.dev.parent, desc->lli.dar, desc->len, 220 dma_unmap_page(chan2parent(&dwc->chan), desc->lli.dar,
212 DMA_FROM_DEVICE); 221 desc->len, DMA_FROM_DEVICE);
213 if (!(txd->flags & DMA_COMPL_SKIP_SRC_UNMAP)) 222 if (!(txd->flags & DMA_COMPL_SKIP_SRC_UNMAP))
214 dma_unmap_page(dwc->chan.dev.parent, desc->lli.sar, desc->len, 223 dma_unmap_page(chan2parent(&dwc->chan), desc->lli.sar,
215 DMA_TO_DEVICE); 224 desc->len, DMA_TO_DEVICE);
216 225
217 /* 226 /*
218 * The API requires that no submissions are done from a 227 * The API requires that no submissions are done from a
@@ -228,7 +237,7 @@ static void dwc_complete_all(struct dw_dma *dw, struct dw_dma_chan *dwc)
228 LIST_HEAD(list); 237 LIST_HEAD(list);
229 238
230 if (dma_readl(dw, CH_EN) & dwc->mask) { 239 if (dma_readl(dw, CH_EN) & dwc->mask) {
231 dev_err(&dwc->chan.dev, 240 dev_err(chan2dev(&dwc->chan),
232 "BUG: XFER bit set, but channel not idle!\n"); 241 "BUG: XFER bit set, but channel not idle!\n");
233 242
234 /* Try to continue after resetting the channel... */ 243 /* Try to continue after resetting the channel... */
@@ -273,7 +282,7 @@ static void dwc_scan_descriptors(struct dw_dma *dw, struct dw_dma_chan *dwc)
273 return; 282 return;
274 } 283 }
275 284
276 dev_vdbg(&dwc->chan.dev, "scan_descriptors: llp=0x%x\n", llp); 285 dev_vdbg(chan2dev(&dwc->chan), "scan_descriptors: llp=0x%x\n", llp);
277 286
278 list_for_each_entry_safe(desc, _desc, &dwc->active_list, desc_node) { 287 list_for_each_entry_safe(desc, _desc, &dwc->active_list, desc_node) {
279 if (desc->lli.llp == llp) 288 if (desc->lli.llp == llp)
@@ -292,7 +301,7 @@ static void dwc_scan_descriptors(struct dw_dma *dw, struct dw_dma_chan *dwc)
292 dwc_descriptor_complete(dwc, desc); 301 dwc_descriptor_complete(dwc, desc);
293 } 302 }
294 303
295 dev_err(&dwc->chan.dev, 304 dev_err(chan2dev(&dwc->chan),
296 "BUG: All descriptors done, but channel not idle!\n"); 305 "BUG: All descriptors done, but channel not idle!\n");
297 306
298 /* Try to continue after resetting the channel... */ 307 /* Try to continue after resetting the channel... */
@@ -308,7 +317,7 @@ static void dwc_scan_descriptors(struct dw_dma *dw, struct dw_dma_chan *dwc)
308 317
309static void dwc_dump_lli(struct dw_dma_chan *dwc, struct dw_lli *lli) 318static void dwc_dump_lli(struct dw_dma_chan *dwc, struct dw_lli *lli)
310{ 319{
311 dev_printk(KERN_CRIT, &dwc->chan.dev, 320 dev_printk(KERN_CRIT, chan2dev(&dwc->chan),
312 " desc: s0x%x d0x%x l0x%x c0x%x:%x\n", 321 " desc: s0x%x d0x%x l0x%x c0x%x:%x\n",
313 lli->sar, lli->dar, lli->llp, 322 lli->sar, lli->dar, lli->llp,
314 lli->ctlhi, lli->ctllo); 323 lli->ctlhi, lli->ctllo);
@@ -342,9 +351,9 @@ static void dwc_handle_error(struct dw_dma *dw, struct dw_dma_chan *dwc)
342 * controller flagged an error instead of scribbling over 351 * controller flagged an error instead of scribbling over
343 * random memory locations. 352 * random memory locations.
344 */ 353 */
345 dev_printk(KERN_CRIT, &dwc->chan.dev, 354 dev_printk(KERN_CRIT, chan2dev(&dwc->chan),
346 "Bad descriptor submitted for DMA!\n"); 355 "Bad descriptor submitted for DMA!\n");
347 dev_printk(KERN_CRIT, &dwc->chan.dev, 356 dev_printk(KERN_CRIT, chan2dev(&dwc->chan),
348 " cookie: %d\n", bad_desc->txd.cookie); 357 " cookie: %d\n", bad_desc->txd.cookie);
349 dwc_dump_lli(dwc, &bad_desc->lli); 358 dwc_dump_lli(dwc, &bad_desc->lli);
350 list_for_each_entry(child, &bad_desc->txd.tx_list, desc_node) 359 list_for_each_entry(child, &bad_desc->txd.tx_list, desc_node)
@@ -442,12 +451,12 @@ static dma_cookie_t dwc_tx_submit(struct dma_async_tx_descriptor *tx)
442 * for DMA. But this is hard to do in a race-free manner. 451 * for DMA. But this is hard to do in a race-free manner.
443 */ 452 */
444 if (list_empty(&dwc->active_list)) { 453 if (list_empty(&dwc->active_list)) {
445 dev_vdbg(&tx->chan->dev, "tx_submit: started %u\n", 454 dev_vdbg(chan2dev(tx->chan), "tx_submit: started %u\n",
446 desc->txd.cookie); 455 desc->txd.cookie);
447 dwc_dostart(dwc, desc); 456 dwc_dostart(dwc, desc);
448 list_add_tail(&desc->desc_node, &dwc->active_list); 457 list_add_tail(&desc->desc_node, &dwc->active_list);
449 } else { 458 } else {
450 dev_vdbg(&tx->chan->dev, "tx_submit: queued %u\n", 459 dev_vdbg(chan2dev(tx->chan), "tx_submit: queued %u\n",
451 desc->txd.cookie); 460 desc->txd.cookie);
452 461
453 list_add_tail(&desc->desc_node, &dwc->queue); 462 list_add_tail(&desc->desc_node, &dwc->queue);
@@ -472,11 +481,11 @@ dwc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
472 unsigned int dst_width; 481 unsigned int dst_width;
473 u32 ctllo; 482 u32 ctllo;
474 483
475 dev_vdbg(&chan->dev, "prep_dma_memcpy d0x%x s0x%x l0x%zx f0x%lx\n", 484 dev_vdbg(chan2dev(chan), "prep_dma_memcpy d0x%x s0x%x l0x%zx f0x%lx\n",
476 dest, src, len, flags); 485 dest, src, len, flags);
477 486
478 if (unlikely(!len)) { 487 if (unlikely(!len)) {
479 dev_dbg(&chan->dev, "prep_dma_memcpy: length is zero!\n"); 488 dev_dbg(chan2dev(chan), "prep_dma_memcpy: length is zero!\n");
480 return NULL; 489 return NULL;
481 } 490 }
482 491
@@ -516,7 +525,7 @@ dwc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
516 first = desc; 525 first = desc;
517 } else { 526 } else {
518 prev->lli.llp = desc->txd.phys; 527 prev->lli.llp = desc->txd.phys;
519 dma_sync_single_for_device(chan->dev.parent, 528 dma_sync_single_for_device(chan2parent(chan),
520 prev->txd.phys, sizeof(prev->lli), 529 prev->txd.phys, sizeof(prev->lli),
521 DMA_TO_DEVICE); 530 DMA_TO_DEVICE);
522 list_add_tail(&desc->desc_node, 531 list_add_tail(&desc->desc_node,
@@ -531,7 +540,7 @@ dwc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
531 prev->lli.ctllo |= DWC_CTLL_INT_EN; 540 prev->lli.ctllo |= DWC_CTLL_INT_EN;
532 541
533 prev->lli.llp = 0; 542 prev->lli.llp = 0;
534 dma_sync_single_for_device(chan->dev.parent, 543 dma_sync_single_for_device(chan2parent(chan),
535 prev->txd.phys, sizeof(prev->lli), 544 prev->txd.phys, sizeof(prev->lli),
536 DMA_TO_DEVICE); 545 DMA_TO_DEVICE);
537 546
@@ -562,15 +571,15 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
562 struct scatterlist *sg; 571 struct scatterlist *sg;
563 size_t total_len = 0; 572 size_t total_len = 0;
564 573
565 dev_vdbg(&chan->dev, "prep_dma_slave\n"); 574 dev_vdbg(chan2dev(chan), "prep_dma_slave\n");
566 575
567 if (unlikely(!dws || !sg_len)) 576 if (unlikely(!dws || !sg_len))
568 return NULL; 577 return NULL;
569 578
570 reg_width = dws->slave.reg_width; 579 reg_width = dws->reg_width;
571 prev = first = NULL; 580 prev = first = NULL;
572 581
573 sg_len = dma_map_sg(chan->dev.parent, sgl, sg_len, direction); 582 sg_len = dma_map_sg(chan2parent(chan), sgl, sg_len, direction);
574 583
575 switch (direction) { 584 switch (direction) {
576 case DMA_TO_DEVICE: 585 case DMA_TO_DEVICE:
@@ -579,7 +588,7 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
579 | DWC_CTLL_DST_FIX 588 | DWC_CTLL_DST_FIX
580 | DWC_CTLL_SRC_INC 589 | DWC_CTLL_SRC_INC
581 | DWC_CTLL_FC_M2P); 590 | DWC_CTLL_FC_M2P);
582 reg = dws->slave.tx_reg; 591 reg = dws->tx_reg;
583 for_each_sg(sgl, sg, sg_len, i) { 592 for_each_sg(sgl, sg, sg_len, i) {
584 struct dw_desc *desc; 593 struct dw_desc *desc;
585 u32 len; 594 u32 len;
@@ -587,7 +596,7 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
587 596
588 desc = dwc_desc_get(dwc); 597 desc = dwc_desc_get(dwc);
589 if (!desc) { 598 if (!desc) {
590 dev_err(&chan->dev, 599 dev_err(chan2dev(chan),
591 "not enough descriptors available\n"); 600 "not enough descriptors available\n");
592 goto err_desc_get; 601 goto err_desc_get;
593 } 602 }
@@ -607,7 +616,7 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
607 first = desc; 616 first = desc;
608 } else { 617 } else {
609 prev->lli.llp = desc->txd.phys; 618 prev->lli.llp = desc->txd.phys;
610 dma_sync_single_for_device(chan->dev.parent, 619 dma_sync_single_for_device(chan2parent(chan),
611 prev->txd.phys, 620 prev->txd.phys,
612 sizeof(prev->lli), 621 sizeof(prev->lli),
613 DMA_TO_DEVICE); 622 DMA_TO_DEVICE);
@@ -625,7 +634,7 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
625 | DWC_CTLL_SRC_FIX 634 | DWC_CTLL_SRC_FIX
626 | DWC_CTLL_FC_P2M); 635 | DWC_CTLL_FC_P2M);
627 636
628 reg = dws->slave.rx_reg; 637 reg = dws->rx_reg;
629 for_each_sg(sgl, sg, sg_len, i) { 638 for_each_sg(sgl, sg, sg_len, i) {
630 struct dw_desc *desc; 639 struct dw_desc *desc;
631 u32 len; 640 u32 len;
@@ -633,7 +642,7 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
633 642
634 desc = dwc_desc_get(dwc); 643 desc = dwc_desc_get(dwc);
635 if (!desc) { 644 if (!desc) {
636 dev_err(&chan->dev, 645 dev_err(chan2dev(chan),
637 "not enough descriptors available\n"); 646 "not enough descriptors available\n");
638 goto err_desc_get; 647 goto err_desc_get;
639 } 648 }
@@ -653,7 +662,7 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
653 first = desc; 662 first = desc;
654 } else { 663 } else {
655 prev->lli.llp = desc->txd.phys; 664 prev->lli.llp = desc->txd.phys;
656 dma_sync_single_for_device(chan->dev.parent, 665 dma_sync_single_for_device(chan2parent(chan),
657 prev->txd.phys, 666 prev->txd.phys,
658 sizeof(prev->lli), 667 sizeof(prev->lli),
659 DMA_TO_DEVICE); 668 DMA_TO_DEVICE);
@@ -673,7 +682,7 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
673 prev->lli.ctllo |= DWC_CTLL_INT_EN; 682 prev->lli.ctllo |= DWC_CTLL_INT_EN;
674 683
675 prev->lli.llp = 0; 684 prev->lli.llp = 0;
676 dma_sync_single_for_device(chan->dev.parent, 685 dma_sync_single_for_device(chan2parent(chan),
677 prev->txd.phys, sizeof(prev->lli), 686 prev->txd.phys, sizeof(prev->lli),
678 DMA_TO_DEVICE); 687 DMA_TO_DEVICE);
679 688
@@ -758,29 +767,21 @@ static void dwc_issue_pending(struct dma_chan *chan)
758 spin_unlock_bh(&dwc->lock); 767 spin_unlock_bh(&dwc->lock);
759} 768}
760 769
761static int dwc_alloc_chan_resources(struct dma_chan *chan, 770static int dwc_alloc_chan_resources(struct dma_chan *chan)
762 struct dma_client *client)
763{ 771{
764 struct dw_dma_chan *dwc = to_dw_dma_chan(chan); 772 struct dw_dma_chan *dwc = to_dw_dma_chan(chan);
765 struct dw_dma *dw = to_dw_dma(chan->device); 773 struct dw_dma *dw = to_dw_dma(chan->device);
766 struct dw_desc *desc; 774 struct dw_desc *desc;
767 struct dma_slave *slave;
768 struct dw_dma_slave *dws; 775 struct dw_dma_slave *dws;
769 int i; 776 int i;
770 u32 cfghi; 777 u32 cfghi;
771 u32 cfglo; 778 u32 cfglo;
772 779
773 dev_vdbg(&chan->dev, "alloc_chan_resources\n"); 780 dev_vdbg(chan2dev(chan), "alloc_chan_resources\n");
774
775 /* Channels doing slave DMA can only handle one client. */
776 if (dwc->dws || client->slave) {
777 if (chan->client_count)
778 return -EBUSY;
779 }
780 781
781 /* ASSERT: channel is idle */ 782 /* ASSERT: channel is idle */
782 if (dma_readl(dw, CH_EN) & dwc->mask) { 783 if (dma_readl(dw, CH_EN) & dwc->mask) {
783 dev_dbg(&chan->dev, "DMA channel not idle?\n"); 784 dev_dbg(chan2dev(chan), "DMA channel not idle?\n");
784 return -EIO; 785 return -EIO;
785 } 786 }
786 787
@@ -789,23 +790,17 @@ static int dwc_alloc_chan_resources(struct dma_chan *chan,
789 cfghi = DWC_CFGH_FIFO_MODE; 790 cfghi = DWC_CFGH_FIFO_MODE;
790 cfglo = 0; 791 cfglo = 0;
791 792
792 slave = client->slave; 793 dws = dwc->dws;
793 if (slave) { 794 if (dws) {
794 /* 795 /*
795 * We need controller-specific data to set up slave 796 * We need controller-specific data to set up slave
796 * transfers. 797 * transfers.
797 */ 798 */
798 BUG_ON(!slave->dma_dev || slave->dma_dev != dw->dma.dev); 799 BUG_ON(!dws->dma_dev || dws->dma_dev != dw->dma.dev);
799
800 dws = container_of(slave, struct dw_dma_slave, slave);
801 800
802 dwc->dws = dws;
803 cfghi = dws->cfg_hi; 801 cfghi = dws->cfg_hi;
804 cfglo = dws->cfg_lo; 802 cfglo = dws->cfg_lo;
805 } else {
806 dwc->dws = NULL;
807 } 803 }
808
809 channel_writel(dwc, CFG_LO, cfglo); 804 channel_writel(dwc, CFG_LO, cfglo);
810 channel_writel(dwc, CFG_HI, cfghi); 805 channel_writel(dwc, CFG_HI, cfghi);
811 806
@@ -822,7 +817,7 @@ static int dwc_alloc_chan_resources(struct dma_chan *chan,
822 817
823 desc = kzalloc(sizeof(struct dw_desc), GFP_KERNEL); 818 desc = kzalloc(sizeof(struct dw_desc), GFP_KERNEL);
824 if (!desc) { 819 if (!desc) {
825 dev_info(&chan->dev, 820 dev_info(chan2dev(chan),
826 "only allocated %d descriptors\n", i); 821 "only allocated %d descriptors\n", i);
827 spin_lock_bh(&dwc->lock); 822 spin_lock_bh(&dwc->lock);
828 break; 823 break;
@@ -832,7 +827,7 @@ static int dwc_alloc_chan_resources(struct dma_chan *chan,
832 desc->txd.tx_submit = dwc_tx_submit; 827 desc->txd.tx_submit = dwc_tx_submit;
833 desc->txd.flags = DMA_CTRL_ACK; 828 desc->txd.flags = DMA_CTRL_ACK;
834 INIT_LIST_HEAD(&desc->txd.tx_list); 829 INIT_LIST_HEAD(&desc->txd.tx_list);
835 desc->txd.phys = dma_map_single(chan->dev.parent, &desc->lli, 830 desc->txd.phys = dma_map_single(chan2parent(chan), &desc->lli,
836 sizeof(desc->lli), DMA_TO_DEVICE); 831 sizeof(desc->lli), DMA_TO_DEVICE);
837 dwc_desc_put(dwc, desc); 832 dwc_desc_put(dwc, desc);
838 833
@@ -847,7 +842,7 @@ static int dwc_alloc_chan_resources(struct dma_chan *chan,
847 842
848 spin_unlock_bh(&dwc->lock); 843 spin_unlock_bh(&dwc->lock);
849 844
850 dev_dbg(&chan->dev, 845 dev_dbg(chan2dev(chan),
851 "alloc_chan_resources allocated %d descriptors\n", i); 846 "alloc_chan_resources allocated %d descriptors\n", i);
852 847
853 return i; 848 return i;
@@ -860,7 +855,7 @@ static void dwc_free_chan_resources(struct dma_chan *chan)
860 struct dw_desc *desc, *_desc; 855 struct dw_desc *desc, *_desc;
861 LIST_HEAD(list); 856 LIST_HEAD(list);
862 857
863 dev_dbg(&chan->dev, "free_chan_resources (descs allocated=%u)\n", 858 dev_dbg(chan2dev(chan), "free_chan_resources (descs allocated=%u)\n",
864 dwc->descs_allocated); 859 dwc->descs_allocated);
865 860
866 /* ASSERT: channel is idle */ 861 /* ASSERT: channel is idle */
@@ -881,13 +876,13 @@ static void dwc_free_chan_resources(struct dma_chan *chan)
881 spin_unlock_bh(&dwc->lock); 876 spin_unlock_bh(&dwc->lock);
882 877
883 list_for_each_entry_safe(desc, _desc, &list, desc_node) { 878 list_for_each_entry_safe(desc, _desc, &list, desc_node) {
884 dev_vdbg(&chan->dev, " freeing descriptor %p\n", desc); 879 dev_vdbg(chan2dev(chan), " freeing descriptor %p\n", desc);
885 dma_unmap_single(chan->dev.parent, desc->txd.phys, 880 dma_unmap_single(chan2parent(chan), desc->txd.phys,
886 sizeof(desc->lli), DMA_TO_DEVICE); 881 sizeof(desc->lli), DMA_TO_DEVICE);
887 kfree(desc); 882 kfree(desc);
888 } 883 }
889 884
890 dev_vdbg(&chan->dev, "free_chan_resources done\n"); 885 dev_vdbg(chan2dev(chan), "free_chan_resources done\n");
891} 886}
892 887
893/*----------------------------------------------------------------------*/ 888/*----------------------------------------------------------------------*/
diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
index 0b95dcce447e..ca70a21afc68 100644
--- a/drivers/dma/fsldma.c
+++ b/drivers/dma/fsldma.c
@@ -366,8 +366,7 @@ static struct fsl_desc_sw *fsl_dma_alloc_descriptor(
366 * 366 *
367 * Return - The number of descriptors allocated. 367 * Return - The number of descriptors allocated.
368 */ 368 */
369static int fsl_dma_alloc_chan_resources(struct dma_chan *chan, 369static int fsl_dma_alloc_chan_resources(struct dma_chan *chan)
370 struct dma_client *client)
371{ 370{
372 struct fsl_dma_chan *fsl_chan = to_fsl_chan(chan); 371 struct fsl_dma_chan *fsl_chan = to_fsl_chan(chan);
373 372
@@ -823,7 +822,7 @@ static int __devinit fsl_dma_chan_probe(struct fsl_dma_device *fdev,
823 */ 822 */
824 WARN_ON(fdev->feature != new_fsl_chan->feature); 823 WARN_ON(fdev->feature != new_fsl_chan->feature);
825 824
826 new_fsl_chan->dev = &new_fsl_chan->common.dev; 825 new_fsl_chan->dev = &new_fsl_chan->common.dev->device;
827 new_fsl_chan->reg_base = ioremap(new_fsl_chan->reg.start, 826 new_fsl_chan->reg_base = ioremap(new_fsl_chan->reg.start,
828 new_fsl_chan->reg.end - new_fsl_chan->reg.start + 1); 827 new_fsl_chan->reg.end - new_fsl_chan->reg.start + 1);
829 828
diff --git a/drivers/dma/ioat.c b/drivers/dma/ioat.c
index 9b16a3af9a0a..4105d6575b64 100644
--- a/drivers/dma/ioat.c
+++ b/drivers/dma/ioat.c
@@ -75,60 +75,10 @@ static int ioat_dca_enabled = 1;
75module_param(ioat_dca_enabled, int, 0644); 75module_param(ioat_dca_enabled, int, 0644);
76MODULE_PARM_DESC(ioat_dca_enabled, "control support of dca service (default: 1)"); 76MODULE_PARM_DESC(ioat_dca_enabled, "control support of dca service (default: 1)");
77 77
78static int ioat_setup_functionality(struct pci_dev *pdev, void __iomem *iobase)
79{
80 struct ioat_device *device = pci_get_drvdata(pdev);
81 u8 version;
82 int err = 0;
83
84 version = readb(iobase + IOAT_VER_OFFSET);
85 switch (version) {
86 case IOAT_VER_1_2:
87 device->dma = ioat_dma_probe(pdev, iobase);
88 if (device->dma && ioat_dca_enabled)
89 device->dca = ioat_dca_init(pdev, iobase);
90 break;
91 case IOAT_VER_2_0:
92 device->dma = ioat_dma_probe(pdev, iobase);
93 if (device->dma && ioat_dca_enabled)
94 device->dca = ioat2_dca_init(pdev, iobase);
95 break;
96 case IOAT_VER_3_0:
97 device->dma = ioat_dma_probe(pdev, iobase);
98 if (device->dma && ioat_dca_enabled)
99 device->dca = ioat3_dca_init(pdev, iobase);
100 break;
101 default:
102 err = -ENODEV;
103 break;
104 }
105 if (!device->dma)
106 err = -ENODEV;
107 return err;
108}
109
110static void ioat_shutdown_functionality(struct pci_dev *pdev)
111{
112 struct ioat_device *device = pci_get_drvdata(pdev);
113
114 dev_err(&pdev->dev, "Removing dma and dca services\n");
115 if (device->dca) {
116 unregister_dca_provider(device->dca);
117 free_dca_provider(device->dca);
118 device->dca = NULL;
119 }
120
121 if (device->dma) {
122 ioat_dma_remove(device->dma);
123 device->dma = NULL;
124 }
125}
126
127static struct pci_driver ioat_pci_driver = { 78static struct pci_driver ioat_pci_driver = {
128 .name = "ioatdma", 79 .name = "ioatdma",
129 .id_table = ioat_pci_tbl, 80 .id_table = ioat_pci_tbl,
130 .probe = ioat_probe, 81 .probe = ioat_probe,
131 .shutdown = ioat_shutdown_functionality,
132 .remove = __devexit_p(ioat_remove), 82 .remove = __devexit_p(ioat_remove),
133}; 83};
134 84
@@ -179,7 +129,29 @@ static int __devinit ioat_probe(struct pci_dev *pdev,
179 129
180 pci_set_master(pdev); 130 pci_set_master(pdev);
181 131
182 err = ioat_setup_functionality(pdev, iobase); 132 switch (readb(iobase + IOAT_VER_OFFSET)) {
133 case IOAT_VER_1_2:
134 device->dma = ioat_dma_probe(pdev, iobase);
135 if (device->dma && ioat_dca_enabled)
136 device->dca = ioat_dca_init(pdev, iobase);
137 break;
138 case IOAT_VER_2_0:
139 device->dma = ioat_dma_probe(pdev, iobase);
140 if (device->dma && ioat_dca_enabled)
141 device->dca = ioat2_dca_init(pdev, iobase);
142 break;
143 case IOAT_VER_3_0:
144 device->dma = ioat_dma_probe(pdev, iobase);
145 if (device->dma && ioat_dca_enabled)
146 device->dca = ioat3_dca_init(pdev, iobase);
147 break;
148 default:
149 err = -ENODEV;
150 break;
151 }
152 if (!device->dma)
153 err = -ENODEV;
154
183 if (err) 155 if (err)
184 goto err_version; 156 goto err_version;
185 157
@@ -198,17 +170,21 @@ err_enable_device:
198 return err; 170 return err;
199} 171}
200 172
201/*
202 * It is unsafe to remove this module: if removed while a requested
203 * dma is outstanding, esp. from tcp, it is possible to hang while
204 * waiting for something that will never finish. However, if you're
205 * feeling lucky, this usually works just fine.
206 */
207static void __devexit ioat_remove(struct pci_dev *pdev) 173static void __devexit ioat_remove(struct pci_dev *pdev)
208{ 174{
209 struct ioat_device *device = pci_get_drvdata(pdev); 175 struct ioat_device *device = pci_get_drvdata(pdev);
210 176
211 ioat_shutdown_functionality(pdev); 177 dev_err(&pdev->dev, "Removing dma and dca services\n");
178 if (device->dca) {
179 unregister_dca_provider(device->dca);
180 free_dca_provider(device->dca);
181 device->dca = NULL;
182 }
183
184 if (device->dma) {
185 ioat_dma_remove(device->dma);
186 device->dma = NULL;
187 }
212 188
213 kfree(device); 189 kfree(device);
214} 190}
diff --git a/drivers/dma/ioat_dma.c b/drivers/dma/ioat_dma.c
index 6607fdd00b1c..b3759c4b6536 100644
--- a/drivers/dma/ioat_dma.c
+++ b/drivers/dma/ioat_dma.c
@@ -734,8 +734,7 @@ static void ioat2_dma_massage_chan_desc(struct ioat_dma_chan *ioat_chan)
734 * ioat_dma_alloc_chan_resources - returns the number of allocated descriptors 734 * ioat_dma_alloc_chan_resources - returns the number of allocated descriptors
735 * @chan: the channel to be filled out 735 * @chan: the channel to be filled out
736 */ 736 */
737static int ioat_dma_alloc_chan_resources(struct dma_chan *chan, 737static int ioat_dma_alloc_chan_resources(struct dma_chan *chan)
738 struct dma_client *client)
739{ 738{
740 struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan); 739 struct ioat_dma_chan *ioat_chan = to_ioat_chan(chan);
741 struct ioat_desc_sw *desc; 740 struct ioat_desc_sw *desc;
@@ -1341,12 +1340,11 @@ static void ioat_dma_start_null_desc(struct ioat_dma_chan *ioat_chan)
1341 */ 1340 */
1342#define IOAT_TEST_SIZE 2000 1341#define IOAT_TEST_SIZE 2000
1343 1342
1344DECLARE_COMPLETION(test_completion);
1345static void ioat_dma_test_callback(void *dma_async_param) 1343static void ioat_dma_test_callback(void *dma_async_param)
1346{ 1344{
1347 printk(KERN_ERR "ioatdma: ioat_dma_test_callback(%p)\n", 1345 struct completion *cmp = dma_async_param;
1348 dma_async_param); 1346
1349 complete(&test_completion); 1347 complete(cmp);
1350} 1348}
1351 1349
1352/** 1350/**
@@ -1363,6 +1361,7 @@ static int ioat_dma_self_test(struct ioatdma_device *device)
1363 dma_addr_t dma_dest, dma_src; 1361 dma_addr_t dma_dest, dma_src;
1364 dma_cookie_t cookie; 1362 dma_cookie_t cookie;
1365 int err = 0; 1363 int err = 0;
1364 struct completion cmp;
1366 1365
1367 src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL); 1366 src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL);
1368 if (!src) 1367 if (!src)
@@ -1381,7 +1380,7 @@ static int ioat_dma_self_test(struct ioatdma_device *device)
1381 dma_chan = container_of(device->common.channels.next, 1380 dma_chan = container_of(device->common.channels.next,
1382 struct dma_chan, 1381 struct dma_chan,
1383 device_node); 1382 device_node);
1384 if (device->common.device_alloc_chan_resources(dma_chan, NULL) < 1) { 1383 if (device->common.device_alloc_chan_resources(dma_chan) < 1) {
1385 dev_err(&device->pdev->dev, 1384 dev_err(&device->pdev->dev,
1386 "selftest cannot allocate chan resource\n"); 1385 "selftest cannot allocate chan resource\n");
1387 err = -ENODEV; 1386 err = -ENODEV;
@@ -1402,8 +1401,9 @@ static int ioat_dma_self_test(struct ioatdma_device *device)
1402 } 1401 }
1403 1402
1404 async_tx_ack(tx); 1403 async_tx_ack(tx);
1404 init_completion(&cmp);
1405 tx->callback = ioat_dma_test_callback; 1405 tx->callback = ioat_dma_test_callback;
1406 tx->callback_param = (void *)0x8086; 1406 tx->callback_param = &cmp;
1407 cookie = tx->tx_submit(tx); 1407 cookie = tx->tx_submit(tx);
1408 if (cookie < 0) { 1408 if (cookie < 0) {
1409 dev_err(&device->pdev->dev, 1409 dev_err(&device->pdev->dev,
@@ -1413,7 +1413,7 @@ static int ioat_dma_self_test(struct ioatdma_device *device)
1413 } 1413 }
1414 device->common.device_issue_pending(dma_chan); 1414 device->common.device_issue_pending(dma_chan);
1415 1415
1416 wait_for_completion_timeout(&test_completion, msecs_to_jiffies(3000)); 1416 wait_for_completion_timeout(&cmp, msecs_to_jiffies(3000));
1417 1417
1418 if (device->common.device_is_tx_complete(dma_chan, cookie, NULL, NULL) 1418 if (device->common.device_is_tx_complete(dma_chan, cookie, NULL, NULL)
1419 != DMA_SUCCESS) { 1419 != DMA_SUCCESS) {
diff --git a/drivers/dma/iop-adma.c b/drivers/dma/iop-adma.c
index 6be317262200..ea5440dd10dc 100644
--- a/drivers/dma/iop-adma.c
+++ b/drivers/dma/iop-adma.c
@@ -24,7 +24,6 @@
24 24
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/async_tx.h>
28#include <linux/delay.h> 27#include <linux/delay.h>
29#include <linux/dma-mapping.h> 28#include <linux/dma-mapping.h>
30#include <linux/spinlock.h> 29#include <linux/spinlock.h>
@@ -116,7 +115,7 @@ iop_adma_run_tx_complete_actions(struct iop_adma_desc_slot *desc,
116 } 115 }
117 116
118 /* run dependent operations */ 117 /* run dependent operations */
119 async_tx_run_dependencies(&desc->async_tx); 118 dma_run_dependencies(&desc->async_tx);
120 119
121 return cookie; 120 return cookie;
122} 121}
@@ -270,8 +269,6 @@ static void __iop_adma_slot_cleanup(struct iop_adma_chan *iop_chan)
270 break; 269 break;
271 } 270 }
272 271
273 BUG_ON(!seen_current);
274
275 if (cookie > 0) { 272 if (cookie > 0) {
276 iop_chan->completed_cookie = cookie; 273 iop_chan->completed_cookie = cookie;
277 pr_debug("\tcompleted cookie %d\n", cookie); 274 pr_debug("\tcompleted cookie %d\n", cookie);
@@ -471,8 +468,7 @@ static void iop_chan_start_null_xor(struct iop_adma_chan *iop_chan);
471 * greater than 2x the number slots needed to satisfy a device->max_xor 468 * greater than 2x the number slots needed to satisfy a device->max_xor
472 * request. 469 * request.
473 * */ 470 * */
474static int iop_adma_alloc_chan_resources(struct dma_chan *chan, 471static int iop_adma_alloc_chan_resources(struct dma_chan *chan)
475 struct dma_client *client)
476{ 472{
477 char *hw_desc; 473 char *hw_desc;
478 int idx; 474 int idx;
@@ -866,7 +862,7 @@ static int __devinit iop_adma_memcpy_self_test(struct iop_adma_device *device)
866 dma_chan = container_of(device->common.channels.next, 862 dma_chan = container_of(device->common.channels.next,
867 struct dma_chan, 863 struct dma_chan,
868 device_node); 864 device_node);
869 if (iop_adma_alloc_chan_resources(dma_chan, NULL) < 1) { 865 if (iop_adma_alloc_chan_resources(dma_chan) < 1) {
870 err = -ENODEV; 866 err = -ENODEV;
871 goto out; 867 goto out;
872 } 868 }
@@ -964,7 +960,7 @@ iop_adma_xor_zero_sum_self_test(struct iop_adma_device *device)
964 dma_chan = container_of(device->common.channels.next, 960 dma_chan = container_of(device->common.channels.next,
965 struct dma_chan, 961 struct dma_chan,
966 device_node); 962 device_node);
967 if (iop_adma_alloc_chan_resources(dma_chan, NULL) < 1) { 963 if (iop_adma_alloc_chan_resources(dma_chan) < 1) {
968 err = -ENODEV; 964 err = -ENODEV;
969 goto out; 965 goto out;
970 } 966 }
@@ -1115,26 +1111,13 @@ static int __devexit iop_adma_remove(struct platform_device *dev)
1115 struct iop_adma_device *device = platform_get_drvdata(dev); 1111 struct iop_adma_device *device = platform_get_drvdata(dev);
1116 struct dma_chan *chan, *_chan; 1112 struct dma_chan *chan, *_chan;
1117 struct iop_adma_chan *iop_chan; 1113 struct iop_adma_chan *iop_chan;
1118 int i;
1119 struct iop_adma_platform_data *plat_data = dev->dev.platform_data; 1114 struct iop_adma_platform_data *plat_data = dev->dev.platform_data;
1120 1115
1121 dma_async_device_unregister(&device->common); 1116 dma_async_device_unregister(&device->common);
1122 1117
1123 for (i = 0; i < 3; i++) {
1124 unsigned int irq;
1125 irq = platform_get_irq(dev, i);
1126 free_irq(irq, device);
1127 }
1128
1129 dma_free_coherent(&dev->dev, plat_data->pool_size, 1118 dma_free_coherent(&dev->dev, plat_data->pool_size,
1130 device->dma_desc_pool_virt, device->dma_desc_pool); 1119 device->dma_desc_pool_virt, device->dma_desc_pool);
1131 1120
1132 do {
1133 struct resource *res;
1134 res = platform_get_resource(dev, IORESOURCE_MEM, 0);
1135 release_mem_region(res->start, res->end - res->start);
1136 } while (0);
1137
1138 list_for_each_entry_safe(chan, _chan, &device->common.channels, 1121 list_for_each_entry_safe(chan, _chan, &device->common.channels,
1139 device_node) { 1122 device_node) {
1140 iop_chan = to_iop_adma_chan(chan); 1123 iop_chan = to_iop_adma_chan(chan);
@@ -1255,7 +1238,6 @@ static int __devinit iop_adma_probe(struct platform_device *pdev)
1255 spin_lock_init(&iop_chan->lock); 1238 spin_lock_init(&iop_chan->lock);
1256 INIT_LIST_HEAD(&iop_chan->chain); 1239 INIT_LIST_HEAD(&iop_chan->chain);
1257 INIT_LIST_HEAD(&iop_chan->all_slots); 1240 INIT_LIST_HEAD(&iop_chan->all_slots);
1258 INIT_RCU_HEAD(&iop_chan->common.rcu);
1259 iop_chan->common.device = dma_dev; 1241 iop_chan->common.device = dma_dev;
1260 list_add_tail(&iop_chan->common.device_node, &dma_dev->channels); 1242 list_add_tail(&iop_chan->common.device_node, &dma_dev->channels);
1261 1243
@@ -1431,16 +1413,12 @@ static int __init iop_adma_init (void)
1431 return platform_driver_register(&iop_adma_driver); 1413 return platform_driver_register(&iop_adma_driver);
1432} 1414}
1433 1415
1434/* it's currently unsafe to unload this module */
1435#if 0
1436static void __exit iop_adma_exit (void) 1416static void __exit iop_adma_exit (void)
1437{ 1417{
1438 platform_driver_unregister(&iop_adma_driver); 1418 platform_driver_unregister(&iop_adma_driver);
1439 return; 1419 return;
1440} 1420}
1441module_exit(iop_adma_exit); 1421module_exit(iop_adma_exit);
1442#endif
1443
1444module_init(iop_adma_init); 1422module_init(iop_adma_init);
1445 1423
1446MODULE_AUTHOR("Intel Corporation"); 1424MODULE_AUTHOR("Intel Corporation");
diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
index bcda17426411..d35cbd1ff0b3 100644
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -18,7 +18,6 @@
18 18
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/async_tx.h>
22#include <linux/delay.h> 21#include <linux/delay.h>
23#include <linux/dma-mapping.h> 22#include <linux/dma-mapping.h>
24#include <linux/spinlock.h> 23#include <linux/spinlock.h>
@@ -340,7 +339,7 @@ mv_xor_run_tx_complete_actions(struct mv_xor_desc_slot *desc,
340 } 339 }
341 340
342 /* run dependent operations */ 341 /* run dependent operations */
343 async_tx_run_dependencies(&desc->async_tx); 342 dma_run_dependencies(&desc->async_tx);
344 343
345 return cookie; 344 return cookie;
346} 345}
@@ -607,8 +606,7 @@ submit_done:
607} 606}
608 607
609/* returns the number of allocated descriptors */ 608/* returns the number of allocated descriptors */
610static int mv_xor_alloc_chan_resources(struct dma_chan *chan, 609static int mv_xor_alloc_chan_resources(struct dma_chan *chan)
611 struct dma_client *client)
612{ 610{
613 char *hw_desc; 611 char *hw_desc;
614 int idx; 612 int idx;
@@ -958,7 +956,7 @@ static int __devinit mv_xor_memcpy_self_test(struct mv_xor_device *device)
958 dma_chan = container_of(device->common.channels.next, 956 dma_chan = container_of(device->common.channels.next,
959 struct dma_chan, 957 struct dma_chan,
960 device_node); 958 device_node);
961 if (mv_xor_alloc_chan_resources(dma_chan, NULL) < 1) { 959 if (mv_xor_alloc_chan_resources(dma_chan) < 1) {
962 err = -ENODEV; 960 err = -ENODEV;
963 goto out; 961 goto out;
964 } 962 }
@@ -1053,7 +1051,7 @@ mv_xor_xor_self_test(struct mv_xor_device *device)
1053 dma_chan = container_of(device->common.channels.next, 1051 dma_chan = container_of(device->common.channels.next,
1054 struct dma_chan, 1052 struct dma_chan,
1055 device_node); 1053 device_node);
1056 if (mv_xor_alloc_chan_resources(dma_chan, NULL) < 1) { 1054 if (mv_xor_alloc_chan_resources(dma_chan) < 1) {
1057 err = -ENODEV; 1055 err = -ENODEV;
1058 goto out; 1056 goto out;
1059 } 1057 }
@@ -1221,7 +1219,6 @@ static int __devinit mv_xor_probe(struct platform_device *pdev)
1221 INIT_LIST_HEAD(&mv_chan->chain); 1219 INIT_LIST_HEAD(&mv_chan->chain);
1222 INIT_LIST_HEAD(&mv_chan->completed_slots); 1220 INIT_LIST_HEAD(&mv_chan->completed_slots);
1223 INIT_LIST_HEAD(&mv_chan->all_slots); 1221 INIT_LIST_HEAD(&mv_chan->all_slots);
1224 INIT_RCU_HEAD(&mv_chan->common.rcu);
1225 mv_chan->common.device = dma_dev; 1222 mv_chan->common.device = dma_dev;
1226 1223
1227 list_add_tail(&mv_chan->common.device_node, &dma_dev->channels); 1224 list_add_tail(&mv_chan->common.device_node, &dma_dev->channels);
diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c
index 418c18f07e9d..6bd91a15d5e6 100644
--- a/drivers/firewire/fw-card.c
+++ b/drivers/firewire/fw-card.c
@@ -75,7 +75,7 @@ generate_config_rom(struct fw_card *card, size_t *config_rom_length)
75 * controller, block reads to the config rom accesses the host 75 * controller, block reads to the config rom accesses the host
76 * memory, but quadlet read access the hardware bus info block 76 * memory, but quadlet read access the hardware bus info block
77 * registers. That's just crack, but it means we should make 77 * registers. That's just crack, but it means we should make
78 * sure the contents of bus info block in host memory mathces 78 * sure the contents of bus info block in host memory matches
79 * the version stored in the OHCI registers. 79 * the version stored in the OHCI registers.
80 */ 80 */
81 81
@@ -189,6 +189,17 @@ static const char gap_count_table[] = {
189 63, 5, 7, 8, 10, 13, 16, 18, 21, 24, 26, 29, 32, 35, 37, 40 189 63, 5, 7, 8, 10, 13, 16, 18, 21, 24, 26, 29, 32, 35, 37, 40
190}; 190};
191 191
192void
193fw_schedule_bm_work(struct fw_card *card, unsigned long delay)
194{
195 int scheduled;
196
197 fw_card_get(card);
198 scheduled = schedule_delayed_work(&card->work, delay);
199 if (!scheduled)
200 fw_card_put(card);
201}
202
192static void 203static void
193fw_card_bm_work(struct work_struct *work) 204fw_card_bm_work(struct work_struct *work)
194{ 205{
@@ -198,6 +209,8 @@ fw_card_bm_work(struct work_struct *work)
198 unsigned long flags; 209 unsigned long flags;
199 int root_id, new_root_id, irm_id, gap_count, generation, grace, rcode; 210 int root_id, new_root_id, irm_id, gap_count, generation, grace, rcode;
200 bool do_reset = false; 211 bool do_reset = false;
212 bool root_device_is_running;
213 bool root_device_is_cmc;
201 __be32 lock_data[2]; 214 __be32 lock_data[2];
202 215
203 spin_lock_irqsave(&card->lock, flags); 216 spin_lock_irqsave(&card->lock, flags);
@@ -206,15 +219,16 @@ fw_card_bm_work(struct work_struct *work)
206 219
207 if (local_node == NULL) { 220 if (local_node == NULL) {
208 spin_unlock_irqrestore(&card->lock, flags); 221 spin_unlock_irqrestore(&card->lock, flags);
209 return; 222 goto out_put_card;
210 } 223 }
211 fw_node_get(local_node); 224 fw_node_get(local_node);
212 fw_node_get(root_node); 225 fw_node_get(root_node);
213 226
214 generation = card->generation; 227 generation = card->generation;
215 root_device = root_node->data; 228 root_device = root_node->data;
216 if (root_device) 229 root_device_is_running = root_device &&
217 fw_device_get(root_device); 230 atomic_read(&root_device->state) == FW_DEVICE_RUNNING;
231 root_device_is_cmc = root_device && root_device->cmc;
218 root_id = root_node->node_id; 232 root_id = root_node->node_id;
219 grace = time_after(jiffies, card->reset_jiffies + DIV_ROUND_UP(HZ, 10)); 233 grace = time_after(jiffies, card->reset_jiffies + DIV_ROUND_UP(HZ, 10));
220 234
@@ -280,7 +294,7 @@ fw_card_bm_work(struct work_struct *work)
280 * this task 100ms from now. 294 * this task 100ms from now.
281 */ 295 */
282 spin_unlock_irqrestore(&card->lock, flags); 296 spin_unlock_irqrestore(&card->lock, flags);
283 schedule_delayed_work(&card->work, DIV_ROUND_UP(HZ, 10)); 297 fw_schedule_bm_work(card, DIV_ROUND_UP(HZ, 10));
284 goto out; 298 goto out;
285 } 299 }
286 300
@@ -297,14 +311,14 @@ fw_card_bm_work(struct work_struct *work)
297 * config rom. In either case, pick another root. 311 * config rom. In either case, pick another root.
298 */ 312 */
299 new_root_id = local_node->node_id; 313 new_root_id = local_node->node_id;
300 } else if (atomic_read(&root_device->state) != FW_DEVICE_RUNNING) { 314 } else if (!root_device_is_running) {
301 /* 315 /*
302 * If we haven't probed this device yet, bail out now 316 * If we haven't probed this device yet, bail out now
303 * and let's try again once that's done. 317 * and let's try again once that's done.
304 */ 318 */
305 spin_unlock_irqrestore(&card->lock, flags); 319 spin_unlock_irqrestore(&card->lock, flags);
306 goto out; 320 goto out;
307 } else if (root_device->cmc) { 321 } else if (root_device_is_cmc) {
308 /* 322 /*
309 * FIXME: I suppose we should set the cmstr bit in the 323 * FIXME: I suppose we should set the cmstr bit in the
310 * STATE_CLEAR register of this node, as described in 324 * STATE_CLEAR register of this node, as described in
@@ -351,10 +365,10 @@ fw_card_bm_work(struct work_struct *work)
351 fw_core_initiate_bus_reset(card, 1); 365 fw_core_initiate_bus_reset(card, 1);
352 } 366 }
353 out: 367 out:
354 if (root_device)
355 fw_device_put(root_device);
356 fw_node_put(root_node); 368 fw_node_put(root_node);
357 fw_node_put(local_node); 369 fw_node_put(local_node);
370 out_put_card:
371 fw_card_put(card);
358} 372}
359 373
360static void 374static void
@@ -510,7 +524,6 @@ fw_core_remove_card(struct fw_card *card)
510 fw_card_put(card); 524 fw_card_put(card);
511 wait_for_completion(&card->done); 525 wait_for_completion(&card->done);
512 526
513 cancel_delayed_work_sync(&card->work);
514 WARN_ON(!list_empty(&card->transaction_list)); 527 WARN_ON(!list_empty(&card->transaction_list));
515 del_timer_sync(&card->flush_timer); 528 del_timer_sync(&card->flush_timer);
516} 529}
diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c
index 6b9be42c7b98..2af5a8d1e012 100644
--- a/drivers/firewire/fw-device.c
+++ b/drivers/firewire/fw-device.c
@@ -159,7 +159,8 @@ static void fw_device_release(struct device *dev)
159 159
160 /* 160 /*
161 * Take the card lock so we don't set this to NULL while a 161 * Take the card lock so we don't set this to NULL while a
162 * FW_NODE_UPDATED callback is being handled. 162 * FW_NODE_UPDATED callback is being handled or while the
163 * bus manager work looks at this node.
163 */ 164 */
164 spin_lock_irqsave(&card->lock, flags); 165 spin_lock_irqsave(&card->lock, flags);
165 device->node->data = NULL; 166 device->node->data = NULL;
@@ -617,7 +618,7 @@ static int shutdown_unit(struct device *device, void *data)
617 */ 618 */
618DECLARE_RWSEM(fw_device_rwsem); 619DECLARE_RWSEM(fw_device_rwsem);
619 620
620static DEFINE_IDR(fw_device_idr); 621DEFINE_IDR(fw_device_idr);
621int fw_cdev_major; 622int fw_cdev_major;
622 623
623struct fw_device *fw_device_get_by_devt(dev_t devt) 624struct fw_device *fw_device_get_by_devt(dev_t devt)
@@ -689,18 +690,19 @@ static void fw_device_init(struct work_struct *work)
689 fw_notify("giving up on config rom for node id %x\n", 690 fw_notify("giving up on config rom for node id %x\n",
690 device->node_id); 691 device->node_id);
691 if (device->node == device->card->root_node) 692 if (device->node == device->card->root_node)
692 schedule_delayed_work(&device->card->work, 0); 693 fw_schedule_bm_work(device->card, 0);
693 fw_device_release(&device->device); 694 fw_device_release(&device->device);
694 } 695 }
695 return; 696 return;
696 } 697 }
697 698
698 err = -ENOMEM; 699 device_initialize(&device->device);
699 700
700 fw_device_get(device); 701 fw_device_get(device);
701 down_write(&fw_device_rwsem); 702 down_write(&fw_device_rwsem);
702 if (idr_pre_get(&fw_device_idr, GFP_KERNEL)) 703 err = idr_pre_get(&fw_device_idr, GFP_KERNEL) ?
703 err = idr_get_new(&fw_device_idr, device, &minor); 704 idr_get_new(&fw_device_idr, device, &minor) :
705 -ENOMEM;
704 up_write(&fw_device_rwsem); 706 up_write(&fw_device_rwsem);
705 707
706 if (err < 0) 708 if (err < 0)
@@ -758,7 +760,7 @@ static void fw_device_init(struct work_struct *work)
758 * pretty harmless. 760 * pretty harmless.
759 */ 761 */
760 if (device->node == device->card->root_node) 762 if (device->node == device->card->root_node)
761 schedule_delayed_work(&device->card->work, 0); 763 fw_schedule_bm_work(device->card, 0);
762 764
763 return; 765 return;
764 766
@@ -892,7 +894,7 @@ static void fw_device_refresh(struct work_struct *work)
892 fw_device_shutdown(work); 894 fw_device_shutdown(work);
893 out: 895 out:
894 if (node_id == card->root_node->node_id) 896 if (node_id == card->root_node->node_id)
895 schedule_delayed_work(&card->work, 0); 897 fw_schedule_bm_work(card, 0);
896} 898}
897 899
898void fw_node_event(struct fw_card *card, struct fw_node *node, int event) 900void fw_node_event(struct fw_card *card, struct fw_node *node, int event)
@@ -911,13 +913,14 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event)
911 913
912 /* 914 /*
913 * Do minimal intialization of the device here, the 915 * Do minimal intialization of the device here, the
914 * rest will happen in fw_device_init(). We need the 916 * rest will happen in fw_device_init().
915 * card and node so we can read the config rom and we 917 *
916 * need to do device_initialize() now so 918 * Attention: A lot of things, even fw_device_get(),
917 * device_for_each_child() in FW_NODE_UPDATED is 919 * cannot be done before fw_device_init() finished!
918 * doesn't freak out. 920 * You can basically just check device->state and
921 * schedule work until then, but only while holding
922 * card->lock.
919 */ 923 */
920 device_initialize(&device->device);
921 atomic_set(&device->state, FW_DEVICE_INITIALIZING); 924 atomic_set(&device->state, FW_DEVICE_INITIALIZING);
922 device->card = fw_card_get(card); 925 device->card = fw_card_get(card);
923 device->node = fw_node_get(node); 926 device->node = fw_node_get(node);
diff --git a/drivers/firewire/fw-device.h b/drivers/firewire/fw-device.h
index 42305bbac72f..df51732608d9 100644
--- a/drivers/firewire/fw-device.h
+++ b/drivers/firewire/fw-device.h
@@ -21,6 +21,7 @@
21 21
22#include <linux/fs.h> 22#include <linux/fs.h>
23#include <linux/cdev.h> 23#include <linux/cdev.h>
24#include <linux/idr.h>
24#include <linux/rwsem.h> 25#include <linux/rwsem.h>
25#include <asm/atomic.h> 26#include <asm/atomic.h>
26 27
@@ -99,6 +100,7 @@ void fw_device_cdev_update(struct fw_device *device);
99void fw_device_cdev_remove(struct fw_device *device); 100void fw_device_cdev_remove(struct fw_device *device);
100 101
101extern struct rw_semaphore fw_device_rwsem; 102extern struct rw_semaphore fw_device_rwsem;
103extern struct idr fw_device_idr;
102extern int fw_cdev_major; 104extern int fw_cdev_major;
103 105
104/* 106/*
diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index e54403ee59e7..e88d5067448c 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -670,17 +670,6 @@ static void sbp2_agent_reset_no_wait(struct sbp2_logical_unit *lu)
670 &d, sizeof(d), complete_agent_reset_write_no_wait, t); 670 &d, sizeof(d), complete_agent_reset_write_no_wait, t);
671} 671}
672 672
673static void sbp2_set_generation(struct sbp2_logical_unit *lu, int generation)
674{
675 struct fw_card *card = fw_device(lu->tgt->unit->device.parent)->card;
676 unsigned long flags;
677
678 /* serialize with comparisons of lu->generation and card->generation */
679 spin_lock_irqsave(&card->lock, flags);
680 lu->generation = generation;
681 spin_unlock_irqrestore(&card->lock, flags);
682}
683
684static inline void sbp2_allow_block(struct sbp2_logical_unit *lu) 673static inline void sbp2_allow_block(struct sbp2_logical_unit *lu)
685{ 674{
686 /* 675 /*
@@ -884,7 +873,7 @@ static void sbp2_login(struct work_struct *work)
884 goto out; 873 goto out;
885 874
886 generation = device->generation; 875 generation = device->generation;
887 smp_rmb(); /* node_id must not be older than generation */ 876 smp_rmb(); /* node IDs must not be older than generation */
888 node_id = device->node_id; 877 node_id = device->node_id;
889 local_node_id = device->card->node_id; 878 local_node_id = device->card->node_id;
890 879
@@ -908,7 +897,8 @@ static void sbp2_login(struct work_struct *work)
908 897
909 tgt->node_id = node_id; 898 tgt->node_id = node_id;
910 tgt->address_high = local_node_id << 16; 899 tgt->address_high = local_node_id << 16;
911 sbp2_set_generation(lu, generation); 900 smp_wmb(); /* node IDs must not be older than generation */
901 lu->generation = generation;
912 902
913 lu->command_block_agent_address = 903 lu->command_block_agent_address =
914 ((u64)(be32_to_cpu(response.command_block_agent.high) & 0xffff) 904 ((u64)(be32_to_cpu(response.command_block_agent.high) & 0xffff)
@@ -1201,7 +1191,7 @@ static void sbp2_reconnect(struct work_struct *work)
1201 goto out; 1191 goto out;
1202 1192
1203 generation = device->generation; 1193 generation = device->generation;
1204 smp_rmb(); /* node_id must not be older than generation */ 1194 smp_rmb(); /* node IDs must not be older than generation */
1205 node_id = device->node_id; 1195 node_id = device->node_id;
1206 local_node_id = device->card->node_id; 1196 local_node_id = device->card->node_id;
1207 1197
@@ -1228,7 +1218,8 @@ static void sbp2_reconnect(struct work_struct *work)
1228 1218
1229 tgt->node_id = node_id; 1219 tgt->node_id = node_id;
1230 tgt->address_high = local_node_id << 16; 1220 tgt->address_high = local_node_id << 16;
1231 sbp2_set_generation(lu, generation); 1221 smp_wmb(); /* node IDs must not be older than generation */
1222 lu->generation = generation;
1232 1223
1233 fw_notify("%s: reconnected to LUN %04x (%d retries)\n", 1224 fw_notify("%s: reconnected to LUN %04x (%d retries)\n",
1234 tgt->bus_id, lu->lun, lu->retries); 1225 tgt->bus_id, lu->lun, lu->retries);
diff --git a/drivers/firewire/fw-topology.c b/drivers/firewire/fw-topology.c
index 5e204713002d..c9be6e6948c4 100644
--- a/drivers/firewire/fw-topology.c
+++ b/drivers/firewire/fw-topology.c
@@ -355,6 +355,9 @@ report_lost_node(struct fw_card *card,
355{ 355{
356 fw_node_event(card, node, FW_NODE_DESTROYED); 356 fw_node_event(card, node, FW_NODE_DESTROYED);
357 fw_node_put(node); 357 fw_node_put(node);
358
359 /* Topology has changed - reset bus manager retry counter */
360 card->bm_retries = 0;
358} 361}
359 362
360static void 363static void
@@ -374,6 +377,9 @@ report_found_node(struct fw_card *card,
374 } 377 }
375 378
376 fw_node_event(card, node, FW_NODE_CREATED); 379 fw_node_event(card, node, FW_NODE_CREATED);
380
381 /* Topology has changed - reset bus manager retry counter */
382 card->bm_retries = 0;
377} 383}
378 384
379void fw_destroy_nodes(struct fw_card *card) 385void fw_destroy_nodes(struct fw_card *card)
@@ -514,14 +520,6 @@ fw_core_handle_bus_reset(struct fw_card *card,
514 520
515 spin_lock_irqsave(&card->lock, flags); 521 spin_lock_irqsave(&card->lock, flags);
516 522
517 /*
518 * If the new topology has a different self_id_count the topology
519 * changed, either nodes were added or removed. In that case we
520 * reset the IRM reset counter.
521 */
522 if (card->self_id_count != self_id_count)
523 card->bm_retries = 0;
524
525 card->node_id = node_id; 523 card->node_id = node_id;
526 /* 524 /*
527 * Update node_id before generation to prevent anybody from using 525 * Update node_id before generation to prevent anybody from using
@@ -530,7 +528,7 @@ fw_core_handle_bus_reset(struct fw_card *card,
530 smp_wmb(); 528 smp_wmb();
531 card->generation = generation; 529 card->generation = generation;
532 card->reset_jiffies = jiffies; 530 card->reset_jiffies = jiffies;
533 schedule_delayed_work(&card->work, 0); 531 fw_schedule_bm_work(card, 0);
534 532
535 local_node = build_tree(card, self_ids, self_id_count); 533 local_node = build_tree(card, self_ids, self_id_count);
536 534
diff --git a/drivers/firewire/fw-transaction.c b/drivers/firewire/fw-transaction.c
index 2884f876397b..699ac041f39a 100644
--- a/drivers/firewire/fw-transaction.c
+++ b/drivers/firewire/fw-transaction.c
@@ -19,6 +19,7 @@
19 */ 19 */
20 20
21#include <linux/completion.h> 21#include <linux/completion.h>
22#include <linux/idr.h>
22#include <linux/kernel.h> 23#include <linux/kernel.h>
23#include <linux/kref.h> 24#include <linux/kref.h>
24#include <linux/module.h> 25#include <linux/module.h>
@@ -971,6 +972,7 @@ static void __exit fw_core_cleanup(void)
971{ 972{
972 unregister_chrdev(fw_cdev_major, "firewire"); 973 unregister_chrdev(fw_cdev_major, "firewire");
973 bus_unregister(&fw_bus_type); 974 bus_unregister(&fw_bus_type);
975 idr_destroy(&fw_device_idr);
974} 976}
975 977
976module_init(fw_core_init); 978module_init(fw_core_init);
diff --git a/drivers/firewire/fw-transaction.h b/drivers/firewire/fw-transaction.h
index 839466f0a795..c9ab12a15f6e 100644
--- a/drivers/firewire/fw-transaction.h
+++ b/drivers/firewire/fw-transaction.h
@@ -237,14 +237,6 @@ struct fw_card {
237 int link_speed; 237 int link_speed;
238 int config_rom_generation; 238 int config_rom_generation;
239 239
240 /*
241 * We need to store up to 4 self ID for a maximum of 63
242 * devices plus 3 words for the topology map header.
243 */
244 int self_id_count;
245 u32 topology_map[252 + 3];
246 u32 broadcast_channel;
247
248 spinlock_t lock; /* Take this lock when handling the lists in 240 spinlock_t lock; /* Take this lock when handling the lists in
249 * this struct. */ 241 * this struct. */
250 struct fw_node *local_node; 242 struct fw_node *local_node;
@@ -262,6 +254,9 @@ struct fw_card {
262 struct delayed_work work; 254 struct delayed_work work;
263 int bm_retries; 255 int bm_retries;
264 int bm_generation; 256 int bm_generation;
257
258 u32 broadcast_channel;
259 u32 topology_map[(CSR_TOPOLOGY_MAP_END - CSR_TOPOLOGY_MAP) / 4];
265}; 260};
266 261
267static inline struct fw_card *fw_card_get(struct fw_card *card) 262static inline struct fw_card *fw_card_get(struct fw_card *card)
@@ -278,6 +273,8 @@ static inline void fw_card_put(struct fw_card *card)
278 kref_put(&card->kref, fw_card_release); 273 kref_put(&card->kref, fw_card_release);
279} 274}
280 275
276extern void fw_schedule_bm_work(struct fw_card *card, unsigned long delay);
277
281/* 278/*
282 * The iso packet format allows for an immediate header/payload part 279 * The iso packet format allows for an immediate header/payload part
283 * stored in 'header' immediately after the packet info plus an 280 * stored in 'header' immediately after the packet info plus an
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c
index 50a071f1c945..777fba48d2d3 100644
--- a/drivers/firmware/dcdbas.c
+++ b/drivers/firmware/dcdbas.c
@@ -238,11 +238,11 @@ static ssize_t host_control_on_shutdown_store(struct device *dev,
238} 238}
239 239
240/** 240/**
241 * smi_request: generate SMI request 241 * dcdbas_smi_request: generate SMI request
242 * 242 *
243 * Called with smi_data_lock. 243 * Called with smi_data_lock.
244 */ 244 */
245static int smi_request(struct smi_cmd *smi_cmd) 245int dcdbas_smi_request(struct smi_cmd *smi_cmd)
246{ 246{
247 cpumask_t old_mask; 247 cpumask_t old_mask;
248 int ret = 0; 248 int ret = 0;
@@ -309,14 +309,14 @@ static ssize_t smi_request_store(struct device *dev,
309 switch (val) { 309 switch (val) {
310 case 2: 310 case 2:
311 /* Raw SMI */ 311 /* Raw SMI */
312 ret = smi_request(smi_cmd); 312 ret = dcdbas_smi_request(smi_cmd);
313 if (!ret) 313 if (!ret)
314 ret = count; 314 ret = count;
315 break; 315 break;
316 case 1: 316 case 1:
317 /* Calling Interface SMI */ 317 /* Calling Interface SMI */
318 smi_cmd->ebx = (u32) virt_to_phys(smi_cmd->command_buffer); 318 smi_cmd->ebx = (u32) virt_to_phys(smi_cmd->command_buffer);
319 ret = smi_request(smi_cmd); 319 ret = dcdbas_smi_request(smi_cmd);
320 if (!ret) 320 if (!ret)
321 ret = count; 321 ret = count;
322 break; 322 break;
@@ -333,6 +333,7 @@ out:
333 mutex_unlock(&smi_data_lock); 333 mutex_unlock(&smi_data_lock);
334 return ret; 334 return ret;
335} 335}
336EXPORT_SYMBOL(dcdbas_smi_request);
336 337
337/** 338/**
338 * host_control_smi: generate host control SMI 339 * host_control_smi: generate host control SMI
diff --git a/drivers/firmware/dcdbas.h b/drivers/firmware/dcdbas.h
index 87bc3417de27..ca3cb0a54ab6 100644
--- a/drivers/firmware/dcdbas.h
+++ b/drivers/firmware/dcdbas.h
@@ -101,5 +101,7 @@ struct apm_cmd {
101 } __attribute__ ((packed)) parameters; 101 } __attribute__ ((packed)) parameters;
102} __attribute__ ((packed)); 102} __attribute__ ((packed));
103 103
104int dcdbas_smi_request(struct smi_cmd *smi_cmd);
105
104#endif /* _DCDBAS_H_ */ 106#endif /* _DCDBAS_H_ */
105 107
diff --git a/drivers/firmware/dell_rbu.c b/drivers/firmware/dell_rbu.c
index 13946ebd77d6..b4704e150b28 100644
--- a/drivers/firmware/dell_rbu.c
+++ b/drivers/firmware/dell_rbu.c
@@ -576,7 +576,7 @@ static ssize_t read_rbu_image_type(struct kobject *kobj,
576{ 576{
577 int size = 0; 577 int size = 0;
578 if (!pos) 578 if (!pos)
579 size = sprintf(buffer, "%s\n", image_type); 579 size = scnprintf(buffer, count, "%s\n", image_type);
580 return size; 580 return size;
581} 581}
582 582
@@ -648,7 +648,7 @@ static ssize_t read_rbu_packet_size(struct kobject *kobj,
648 int size = 0; 648 int size = 0;
649 if (!pos) { 649 if (!pos) {
650 spin_lock(&rbu_data.lock); 650 spin_lock(&rbu_data.lock);
651 size = sprintf(buffer, "%lu\n", rbu_data.packetsize); 651 size = scnprintf(buffer, count, "%lu\n", rbu_data.packetsize);
652 spin_unlock(&rbu_data.lock); 652 spin_unlock(&rbu_data.lock);
653 } 653 }
654 return size; 654 return size;
diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
index 3bf8ee120d42..261b9aa3f248 100644
--- a/drivers/firmware/memmap.c
+++ b/drivers/firmware/memmap.c
@@ -56,9 +56,9 @@ struct memmap_attribute {
56 ssize_t (*show)(struct firmware_map_entry *entry, char *buf); 56 ssize_t (*show)(struct firmware_map_entry *entry, char *buf);
57}; 57};
58 58
59struct memmap_attribute memmap_start_attr = __ATTR_RO(start); 59static struct memmap_attribute memmap_start_attr = __ATTR_RO(start);
60struct memmap_attribute memmap_end_attr = __ATTR_RO(end); 60static struct memmap_attribute memmap_end_attr = __ATTR_RO(end);
61struct memmap_attribute memmap_type_attr = __ATTR_RO(type); 61static struct memmap_attribute memmap_type_attr = __ATTR_RO(type);
62 62
63/* 63/*
64 * These are default attributes that are added for every memmap entry. 64 * These are default attributes that are added for every memmap entry.
diff --git a/drivers/gpio/max7301.c b/drivers/gpio/max7301.c
index 8b24d784db93..3e7f4e06386e 100644
--- a/drivers/gpio/max7301.c
+++ b/drivers/gpio/max7301.c
@@ -217,8 +217,10 @@ static int __devinit max7301_probe(struct spi_device *spi)
217 int i, ret; 217 int i, ret;
218 218
219 pdata = spi->dev.platform_data; 219 pdata = spi->dev.platform_data;
220 if (!pdata || !pdata->base) 220 if (!pdata || !pdata->base) {
221 return -ENODEV; 221 dev_dbg(&spi->dev, "incorrect or missing platform data\n");
222 return -EINVAL;
223 }
222 224
223 /* 225 /*
224 * bits_per_word cannot be configured in platform data 226 * bits_per_word cannot be configured in platform data
diff --git a/drivers/gpio/max732x.c b/drivers/gpio/max732x.c
index 55ae9a41897a..f7868243af89 100644
--- a/drivers/gpio/max732x.c
+++ b/drivers/gpio/max732x.c
@@ -267,8 +267,10 @@ static int __devinit max732x_probe(struct i2c_client *client,
267 int ret, nr_port; 267 int ret, nr_port;
268 268
269 pdata = client->dev.platform_data; 269 pdata = client->dev.platform_data;
270 if (pdata == NULL) 270 if (pdata == NULL) {
271 return -ENODEV; 271 dev_dbg(&client->dev, "no platform data\n");
272 return -EINVAL;
273 }
272 274
273 chip = kzalloc(sizeof(struct max732x_chip), GFP_KERNEL); 275 chip = kzalloc(sizeof(struct max732x_chip), GFP_KERNEL);
274 if (chip == NULL) 276 if (chip == NULL)
diff --git a/drivers/gpio/mcp23s08.c b/drivers/gpio/mcp23s08.c
index 89c1d222e9d1..f6fae0e50e65 100644
--- a/drivers/gpio/mcp23s08.c
+++ b/drivers/gpio/mcp23s08.c
@@ -310,8 +310,10 @@ static int mcp23s08_probe(struct spi_device *spi)
310 unsigned base; 310 unsigned base;
311 311
312 pdata = spi->dev.platform_data; 312 pdata = spi->dev.platform_data;
313 if (!pdata || !gpio_is_valid(pdata->base)) 313 if (!pdata || !gpio_is_valid(pdata->base)) {
314 return -ENODEV; 314 dev_dbg(&spi->dev, "invalid or missing platform data\n");
315 return -EINVAL;
316 }
315 317
316 for (addr = 0; addr < 4; addr++) { 318 for (addr = 0; addr < 4; addr++) {
317 if (!pdata->chip[addr].is_present) 319 if (!pdata->chip[addr].is_present)
diff --git a/drivers/gpio/pca953x.c b/drivers/gpio/pca953x.c
index 37f35388a2ae..8dc0164bd51e 100644
--- a/drivers/gpio/pca953x.c
+++ b/drivers/gpio/pca953x.c
@@ -202,8 +202,10 @@ static int __devinit pca953x_probe(struct i2c_client *client,
202 int ret; 202 int ret;
203 203
204 pdata = client->dev.platform_data; 204 pdata = client->dev.platform_data;
205 if (pdata == NULL) 205 if (pdata == NULL) {
206 return -ENODEV; 206 dev_dbg(&client->dev, "no platform data\n");
207 return -EINVAL;
208 }
207 209
208 chip = kzalloc(sizeof(struct pca953x_chip), GFP_KERNEL); 210 chip = kzalloc(sizeof(struct pca953x_chip), GFP_KERNEL);
209 if (chip == NULL) 211 if (chip == NULL)
diff --git a/drivers/gpio/pcf857x.c b/drivers/gpio/pcf857x.c
index 4bc2070dd4a1..9525724be731 100644
--- a/drivers/gpio/pcf857x.c
+++ b/drivers/gpio/pcf857x.c
@@ -188,8 +188,10 @@ static int pcf857x_probe(struct i2c_client *client,
188 int status; 188 int status;
189 189
190 pdata = client->dev.platform_data; 190 pdata = client->dev.platform_data;
191 if (!pdata) 191 if (!pdata) {
192 return -ENODEV; 192 dev_dbg(&client->dev, "no platform data\n");
193 return -EINVAL;
194 }
193 195
194 /* Allocate, initialize, and register this gpio_chip. */ 196 /* Allocate, initialize, and register this gpio_chip. */
195 gpio = kzalloc(sizeof *gpio, GFP_KERNEL); 197 gpio = kzalloc(sizeof *gpio, GFP_KERNEL);
@@ -248,8 +250,10 @@ static int pcf857x_probe(struct i2c_client *client,
248 else 250 else
249 status = i2c_read_le16(client); 251 status = i2c_read_le16(client);
250 252
251 } else 253 } else {
252 status = -ENODEV; 254 dev_dbg(&client->dev, "unsupported number of gpios\n");
255 status = -EINVAL;
256 }
253 257
254 if (status < 0) 258 if (status < 0)
255 goto fail; 259 goto fail;
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 53c87254be4c..5b2cbb778162 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -210,7 +210,7 @@ static int drm_mode_object_get(struct drm_device *dev,
210 int ret; 210 int ret;
211 211
212 WARN(!mutex_is_locked(&dev->mode_config.mutex), 212 WARN(!mutex_is_locked(&dev->mode_config.mutex),
213 "%s called w/o mode_config lock\n", __FUNCTION__); 213 "%s called w/o mode_config lock\n", __func__);
214again: 214again:
215 if (idr_pre_get(&dev->mode_config.crtc_idr, GFP_KERNEL) == 0) { 215 if (idr_pre_get(&dev->mode_config.crtc_idr, GFP_KERNEL) == 0) {
216 DRM_ERROR("Ran out memory getting a mode number\n"); 216 DRM_ERROR("Ran out memory getting a mode number\n");
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index d8a982b71296..964c5eb1fada 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -36,7 +36,7 @@
36/* 36/*
37 * Detailed mode info for 800x600@60Hz 37 * Detailed mode info for 800x600@60Hz
38 */ 38 */
39static struct drm_display_mode std_mode[] = { 39static struct drm_display_mode std_modes[] = {
40 { DRM_MODE("800x600", DRM_MODE_TYPE_DEFAULT, 40000, 800, 840, 40 { DRM_MODE("800x600", DRM_MODE_TYPE_DEFAULT, 40000, 800, 840,
41 968, 1056, 0, 600, 601, 605, 628, 0, 41 968, 1056, 0, 600, 601, 605, 628, 0,
42 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }, 42 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
@@ -60,15 +60,18 @@ static struct drm_display_mode std_mode[] = {
60 * changes have occurred. 60 * changes have occurred.
61 * 61 *
62 * FIXME: take into account monitor limits 62 * FIXME: take into account monitor limits
63 *
64 * RETURNS:
65 * Number of modes found on @connector.
63 */ 66 */
64void drm_helper_probe_single_connector_modes(struct drm_connector *connector, 67int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
65 uint32_t maxX, uint32_t maxY) 68 uint32_t maxX, uint32_t maxY)
66{ 69{
67 struct drm_device *dev = connector->dev; 70 struct drm_device *dev = connector->dev;
68 struct drm_display_mode *mode, *t; 71 struct drm_display_mode *mode, *t;
69 struct drm_connector_helper_funcs *connector_funcs = 72 struct drm_connector_helper_funcs *connector_funcs =
70 connector->helper_private; 73 connector->helper_private;
71 int ret; 74 int count = 0;
72 75
73 DRM_DEBUG("%s\n", drm_get_connector_name(connector)); 76 DRM_DEBUG("%s\n", drm_get_connector_name(connector));
74 /* set all modes to the unverified state */ 77 /* set all modes to the unverified state */
@@ -81,14 +84,14 @@ void drm_helper_probe_single_connector_modes(struct drm_connector *connector,
81 DRM_DEBUG("%s is disconnected\n", 84 DRM_DEBUG("%s is disconnected\n",
82 drm_get_connector_name(connector)); 85 drm_get_connector_name(connector));
83 /* TODO set EDID to NULL */ 86 /* TODO set EDID to NULL */
84 return; 87 return 0;
85 } 88 }
86 89
87 ret = (*connector_funcs->get_modes)(connector); 90 count = (*connector_funcs->get_modes)(connector);
91 if (!count)
92 return 0;
88 93
89 if (ret) { 94 drm_mode_connector_list_update(connector);
90 drm_mode_connector_list_update(connector);
91 }
92 95
93 if (maxX && maxY) 96 if (maxX && maxY)
94 drm_mode_validate_size(dev, &connector->modes, maxX, 97 drm_mode_validate_size(dev, &connector->modes, maxX,
@@ -102,25 +105,8 @@ void drm_helper_probe_single_connector_modes(struct drm_connector *connector,
102 105
103 drm_mode_prune_invalid(dev, &connector->modes, true); 106 drm_mode_prune_invalid(dev, &connector->modes, true);
104 107
105 if (list_empty(&connector->modes)) { 108 if (list_empty(&connector->modes))
106 struct drm_display_mode *stdmode; 109 return 0;
107
108 DRM_DEBUG("No valid modes on %s\n",
109 drm_get_connector_name(connector));
110
111 /* Should we do this here ???
112 * When no valid EDID modes are available we end up
113 * here and bailed in the past, now we add a standard
114 * 640x480@60Hz mode and carry on.
115 */
116 stdmode = drm_mode_duplicate(dev, &std_mode[0]);
117 drm_mode_probed_add(connector, stdmode);
118 drm_mode_list_concat(&connector->probed_modes,
119 &connector->modes);
120
121 DRM_DEBUG("Adding standard 640x480 @ 60Hz to %s\n",
122 drm_get_connector_name(connector));
123 }
124 110
125 drm_mode_sort(&connector->modes); 111 drm_mode_sort(&connector->modes);
126 112
@@ -131,20 +117,58 @@ void drm_helper_probe_single_connector_modes(struct drm_connector *connector,
131 drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V); 117 drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
132 drm_mode_debug_printmodeline(mode); 118 drm_mode_debug_printmodeline(mode);
133 } 119 }
120
121 return count;
134} 122}
135EXPORT_SYMBOL(drm_helper_probe_single_connector_modes); 123EXPORT_SYMBOL(drm_helper_probe_single_connector_modes);
136 124
137void drm_helper_probe_connector_modes(struct drm_device *dev, uint32_t maxX, 125int drm_helper_probe_connector_modes(struct drm_device *dev, uint32_t maxX,
138 uint32_t maxY) 126 uint32_t maxY)
139{ 127{
140 struct drm_connector *connector; 128 struct drm_connector *connector;
129 int count = 0;
141 130
142 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 131 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
143 drm_helper_probe_single_connector_modes(connector, maxX, maxY); 132 count += drm_helper_probe_single_connector_modes(connector,
133 maxX, maxY);
144 } 134 }
135
136 return count;
145} 137}
146EXPORT_SYMBOL(drm_helper_probe_connector_modes); 138EXPORT_SYMBOL(drm_helper_probe_connector_modes);
147 139
140static void drm_helper_add_std_modes(struct drm_device *dev,
141 struct drm_connector *connector)
142{
143 struct drm_display_mode *mode, *t;
144 int i;
145
146 for (i = 0; i < ARRAY_SIZE(std_modes); i++) {
147 struct drm_display_mode *stdmode;
148
149 /*
150 * When no valid EDID modes are available we end up
151 * here and bailed in the past, now we add some standard
152 * modes and move on.
153 */
154 stdmode = drm_mode_duplicate(dev, &std_modes[i]);
155 drm_mode_probed_add(connector, stdmode);
156 drm_mode_list_concat(&connector->probed_modes,
157 &connector->modes);
158
159 DRM_DEBUG("Adding mode %s to %s\n", stdmode->name,
160 drm_get_connector_name(connector));
161 }
162 drm_mode_sort(&connector->modes);
163
164 DRM_DEBUG("Added std modes on %s\n", drm_get_connector_name(connector));
165 list_for_each_entry_safe(mode, t, &connector->modes, head) {
166 mode->vrefresh = drm_mode_vrefresh(mode);
167
168 drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
169 drm_mode_debug_printmodeline(mode);
170 }
171}
148 172
149/** 173/**
150 * drm_helper_crtc_in_use - check if a given CRTC is in a mode_config 174 * drm_helper_crtc_in_use - check if a given CRTC is in a mode_config
@@ -237,6 +261,8 @@ static void drm_enable_connectors(struct drm_device *dev, bool *enabled)
237 261
238 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 262 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
239 enabled[i] = drm_connector_enabled(connector, true); 263 enabled[i] = drm_connector_enabled(connector, true);
264 DRM_DEBUG("connector %d enabled? %s\n", connector->base.id,
265 enabled[i] ? "yes" : "no");
240 any_enabled |= enabled[i]; 266 any_enabled |= enabled[i];
241 i++; 267 i++;
242 } 268 }
@@ -265,11 +291,17 @@ static bool drm_target_preferred(struct drm_device *dev,
265 continue; 291 continue;
266 } 292 }
267 293
294 DRM_DEBUG("looking for preferred mode on connector %d\n",
295 connector->base.id);
296
268 modes[i] = drm_has_preferred_mode(connector, width, height); 297 modes[i] = drm_has_preferred_mode(connector, width, height);
269 if (!modes[i]) { 298 /* No preferred modes, pick one off the list */
299 if (!modes[i] && !list_empty(&connector->modes)) {
270 list_for_each_entry(modes[i], &connector->modes, head) 300 list_for_each_entry(modes[i], &connector->modes, head)
271 break; 301 break;
272 } 302 }
303 DRM_DEBUG("found mode %s\n", modes[i] ? modes[i]->name :
304 "none");
273 i++; 305 i++;
274 } 306 }
275 return true; 307 return true;
@@ -369,6 +401,8 @@ static void drm_setup_crtcs(struct drm_device *dev)
369 int width, height; 401 int width, height;
370 int i, ret; 402 int i, ret;
371 403
404 DRM_DEBUG("\n");
405
372 width = dev->mode_config.max_width; 406 width = dev->mode_config.max_width;
373 height = dev->mode_config.max_height; 407 height = dev->mode_config.max_height;
374 408
@@ -390,6 +424,8 @@ static void drm_setup_crtcs(struct drm_device *dev)
390 if (!ret) 424 if (!ret)
391 DRM_ERROR("Unable to find initial modes\n"); 425 DRM_ERROR("Unable to find initial modes\n");
392 426
427 DRM_DEBUG("picking CRTCs for %dx%d config\n", width, height);
428
393 drm_pick_crtcs(dev, crtcs, modes, 0, width, height); 429 drm_pick_crtcs(dev, crtcs, modes, 0, width, height);
394 430
395 i = 0; 431 i = 0;
@@ -403,6 +439,8 @@ static void drm_setup_crtcs(struct drm_device *dev)
403 } 439 }
404 440
405 if (mode && crtc) { 441 if (mode && crtc) {
442 DRM_DEBUG("desired mode %s set on crtc %d\n",
443 mode->name, crtc->base.id);
406 crtc->desired_mode = mode; 444 crtc->desired_mode = mode;
407 connector->encoder->crtc = crtc; 445 connector->encoder->crtc = crtc;
408 } else 446 } else
@@ -442,6 +480,7 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
442 int saved_x, saved_y; 480 int saved_x, saved_y;
443 struct drm_encoder *encoder; 481 struct drm_encoder *encoder;
444 bool ret = true; 482 bool ret = true;
483 bool depth_changed, bpp_changed;
445 484
446 adjusted_mode = drm_mode_duplicate(dev, mode); 485 adjusted_mode = drm_mode_duplicate(dev, mode);
447 486
@@ -450,6 +489,15 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
450 if (!crtc->enabled) 489 if (!crtc->enabled)
451 return true; 490 return true;
452 491
492 if (old_fb && crtc->fb) {
493 depth_changed = (old_fb->depth != crtc->fb->depth);
494 bpp_changed = (old_fb->bits_per_pixel !=
495 crtc->fb->bits_per_pixel);
496 } else {
497 depth_changed = true;
498 bpp_changed = true;
499 }
500
453 saved_mode = crtc->mode; 501 saved_mode = crtc->mode;
454 saved_x = crtc->x; 502 saved_x = crtc->x;
455 saved_y = crtc->y; 503 saved_y = crtc->y;
@@ -462,7 +510,8 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
462 crtc->y = y; 510 crtc->y = y;
463 511
464 if (drm_mode_equal(&saved_mode, &crtc->mode)) { 512 if (drm_mode_equal(&saved_mode, &crtc->mode)) {
465 if (saved_x != crtc->x || saved_y != crtc->y) { 513 if (saved_x != crtc->x || saved_y != crtc->y ||
514 depth_changed || bpp_changed) {
466 crtc_funcs->mode_set_base(crtc, crtc->x, crtc->y, 515 crtc_funcs->mode_set_base(crtc, crtc->x, crtc->y,
467 old_fb); 516 old_fb);
468 goto done; 517 goto done;
@@ -568,8 +617,8 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
568 struct drm_encoder **save_encoders, *new_encoder; 617 struct drm_encoder **save_encoders, *new_encoder;
569 struct drm_framebuffer *old_fb; 618 struct drm_framebuffer *old_fb;
570 bool save_enabled; 619 bool save_enabled;
571 bool changed = false; 620 bool mode_changed = false;
572 bool flip_or_move = false; 621 bool fb_changed = false;
573 struct drm_connector *connector; 622 struct drm_connector *connector;
574 int count = 0, ro, fail = 0; 623 int count = 0, ro, fail = 0;
575 struct drm_crtc_helper_funcs *crtc_funcs; 624 struct drm_crtc_helper_funcs *crtc_funcs;
@@ -597,7 +646,10 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
597 /* save previous config */ 646 /* save previous config */
598 save_enabled = set->crtc->enabled; 647 save_enabled = set->crtc->enabled;
599 648
600 /* this is meant to be num_connector not num_crtc */ 649 /*
650 * We do mode_config.num_connectors here since we'll look at the
651 * CRTC and encoder associated with each connector later.
652 */
601 save_crtcs = kzalloc(dev->mode_config.num_connector * 653 save_crtcs = kzalloc(dev->mode_config.num_connector *
602 sizeof(struct drm_crtc *), GFP_KERNEL); 654 sizeof(struct drm_crtc *), GFP_KERNEL);
603 if (!save_crtcs) 655 if (!save_crtcs)
@@ -613,21 +665,25 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
613 /* We should be able to check here if the fb has the same properties 665 /* We should be able to check here if the fb has the same properties
614 * and then just flip_or_move it */ 666 * and then just flip_or_move it */
615 if (set->crtc->fb != set->fb) { 667 if (set->crtc->fb != set->fb) {
616 /* if we have no fb then its a change not a flip */ 668 /* If we have no fb then treat it as a full mode set */
617 if (set->crtc->fb == NULL) 669 if (set->crtc->fb == NULL)
618 changed = true; 670 mode_changed = true;
671 else if ((set->fb->bits_per_pixel !=
672 set->crtc->fb->bits_per_pixel) ||
673 set->fb->depth != set->crtc->fb->depth)
674 fb_changed = true;
619 else 675 else
620 flip_or_move = true; 676 fb_changed = true;
621 } 677 }
622 678
623 if (set->x != set->crtc->x || set->y != set->crtc->y) 679 if (set->x != set->crtc->x || set->y != set->crtc->y)
624 flip_or_move = true; 680 fb_changed = true;
625 681
626 if (set->mode && !drm_mode_equal(set->mode, &set->crtc->mode)) { 682 if (set->mode && !drm_mode_equal(set->mode, &set->crtc->mode)) {
627 DRM_DEBUG("modes are different\n"); 683 DRM_DEBUG("modes are different\n");
628 drm_mode_debug_printmodeline(&set->crtc->mode); 684 drm_mode_debug_printmodeline(&set->crtc->mode);
629 drm_mode_debug_printmodeline(set->mode); 685 drm_mode_debug_printmodeline(set->mode);
630 changed = true; 686 mode_changed = true;
631 } 687 }
632 688
633 /* a) traverse passed in connector list and get encoders for them */ 689 /* a) traverse passed in connector list and get encoders for them */
@@ -650,7 +706,7 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
650 } 706 }
651 707
652 if (new_encoder != connector->encoder) { 708 if (new_encoder != connector->encoder) {
653 changed = true; 709 mode_changed = true;
654 connector->encoder = new_encoder; 710 connector->encoder = new_encoder;
655 } 711 }
656 } 712 }
@@ -677,16 +733,16 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
677 new_crtc = set->crtc; 733 new_crtc = set->crtc;
678 } 734 }
679 if (new_crtc != connector->encoder->crtc) { 735 if (new_crtc != connector->encoder->crtc) {
680 changed = true; 736 mode_changed = true;
681 connector->encoder->crtc = new_crtc; 737 connector->encoder->crtc = new_crtc;
682 } 738 }
683 } 739 }
684 740
685 /* mode_set_base is not a required function */ 741 /* mode_set_base is not a required function */
686 if (flip_or_move && !crtc_funcs->mode_set_base) 742 if (fb_changed && !crtc_funcs->mode_set_base)
687 changed = true; 743 mode_changed = true;
688 744
689 if (changed) { 745 if (mode_changed) {
690 old_fb = set->crtc->fb; 746 old_fb = set->crtc->fb;
691 set->crtc->fb = set->fb; 747 set->crtc->fb = set->fb;
692 set->crtc->enabled = (set->mode != NULL); 748 set->crtc->enabled = (set->mode != NULL);
@@ -705,7 +761,7 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
705 set->crtc->desired_mode = set->mode; 761 set->crtc->desired_mode = set->mode;
706 } 762 }
707 drm_helper_disable_unused_functions(dev); 763 drm_helper_disable_unused_functions(dev);
708 } else if (flip_or_move) { 764 } else if (fb_changed) {
709 old_fb = set->crtc->fb; 765 old_fb = set->crtc->fb;
710 if (set->crtc->fb != set->fb) 766 if (set->crtc->fb != set->fb)
711 set->crtc->fb = set->fb; 767 set->crtc->fb = set->fb;
@@ -764,10 +820,31 @@ bool drm_helper_plugged_event(struct drm_device *dev)
764 */ 820 */
765bool drm_helper_initial_config(struct drm_device *dev, bool can_grow) 821bool drm_helper_initial_config(struct drm_device *dev, bool can_grow)
766{ 822{
767 int ret = false; 823 struct drm_connector *connector;
824 int count = 0;
768 825
769 drm_helper_plugged_event(dev); 826 count = drm_helper_probe_connector_modes(dev,
770 return ret; 827 dev->mode_config.max_width,
828 dev->mode_config.max_height);
829
830 /*
831 * None of the available connectors had any modes, so add some
832 * and try to light them up anyway
833 */
834 if (!count) {
835 DRM_ERROR("connectors have no modes, using standard modes\n");
836 list_for_each_entry(connector,
837 &dev->mode_config.connector_list,
838 head)
839 drm_helper_add_std_modes(dev, connector);
840 }
841
842 drm_setup_crtcs(dev);
843
844 /* alert the driver fb layer */
845 dev->mode_config.funcs->fb_changed(dev);
846
847 return 0;
771} 848}
772EXPORT_SYMBOL(drm_helper_initial_config); 849EXPORT_SYMBOL(drm_helper_initial_config);
773 850
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 724e505873cf..477caa1b1e4b 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -267,7 +267,8 @@ EXPORT_SYMBOL(drm_irq_install);
267 */ 267 */
268int drm_irq_uninstall(struct drm_device * dev) 268int drm_irq_uninstall(struct drm_device * dev)
269{ 269{
270 int irq_enabled; 270 unsigned long irqflags;
271 int irq_enabled, i;
271 272
272 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) 273 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
273 return -EINVAL; 274 return -EINVAL;
@@ -277,6 +278,16 @@ int drm_irq_uninstall(struct drm_device * dev)
277 dev->irq_enabled = 0; 278 dev->irq_enabled = 0;
278 mutex_unlock(&dev->struct_mutex); 279 mutex_unlock(&dev->struct_mutex);
279 280
281 /*
282 * Wake up any waiters so they don't hang.
283 */
284 spin_lock_irqsave(&dev->vbl_lock, irqflags);
285 for (i = 0; i < dev->num_crtcs; i++) {
286 DRM_WAKEUP(&dev->vbl_queue[i]);
287 dev->vblank_enabled[i] = 0;
288 }
289 spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
290
280 if (!irq_enabled) 291 if (!irq_enabled)
281 return -EINVAL; 292 return -EINVAL;
282 293
@@ -652,8 +663,9 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
652 vblwait->request.sequence, crtc); 663 vblwait->request.sequence, crtc);
653 dev->last_vblank_wait[crtc] = vblwait->request.sequence; 664 dev->last_vblank_wait[crtc] = vblwait->request.sequence;
654 DRM_WAIT_ON(ret, dev->vbl_queue[crtc], 3 * DRM_HZ, 665 DRM_WAIT_ON(ret, dev->vbl_queue[crtc], 3 * DRM_HZ,
655 ((drm_vblank_count(dev, crtc) 666 (((drm_vblank_count(dev, crtc) -
656 - vblwait->request.sequence) <= (1 << 23))); 667 vblwait->request.sequence) <= (1 << 23)) ||
668 !dev->irq_enabled));
657 669
658 if (ret != -EINTR) { 670 if (ret != -EINTR) {
659 struct timeval now; 671 struct timeval now;
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 62a4bf7b49df..bbadf1c04142 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -177,6 +177,14 @@ static int i915_initialize(struct drm_device * dev, drm_i915_init_t * init)
177 drm_i915_private_t *dev_priv = dev->dev_private; 177 drm_i915_private_t *dev_priv = dev->dev_private;
178 struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv; 178 struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv;
179 179
180 master_priv->sarea = drm_getsarea(dev);
181 if (master_priv->sarea) {
182 master_priv->sarea_priv = (drm_i915_sarea_t *)
183 ((u8 *)master_priv->sarea->handle + init->sarea_priv_offset);
184 } else {
185 DRM_DEBUG("sarea not found assuming DRI2 userspace\n");
186 }
187
180 if (init->ring_size != 0) { 188 if (init->ring_size != 0) {
181 if (dev_priv->ring.ring_obj != NULL) { 189 if (dev_priv->ring.ring_obj != NULL) {
182 i915_dma_cleanup(dev); 190 i915_dma_cleanup(dev);
@@ -1152,6 +1160,8 @@ int i915_driver_unload(struct drm_device *dev)
1152 if (drm_core_check_feature(dev, DRIVER_MODESET)) { 1160 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
1153 intel_modeset_cleanup(dev); 1161 intel_modeset_cleanup(dev);
1154 1162
1163 i915_gem_free_all_phys_object(dev);
1164
1155 mutex_lock(&dev->struct_mutex); 1165 mutex_lock(&dev->struct_mutex);
1156 i915_gem_cleanup_ringbuffer(dev); 1166 i915_gem_cleanup_ringbuffer(dev);
1157 mutex_unlock(&dev->struct_mutex); 1167 mutex_unlock(&dev->struct_mutex);
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 563de18063fd..e13518252007 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -72,6 +72,18 @@ enum pipe {
72#define WATCH_INACTIVE 0 72#define WATCH_INACTIVE 0
73#define WATCH_PWRITE 0 73#define WATCH_PWRITE 0
74 74
75#define I915_GEM_PHYS_CURSOR_0 1
76#define I915_GEM_PHYS_CURSOR_1 2
77#define I915_GEM_PHYS_OVERLAY_REGS 3
78#define I915_MAX_PHYS_OBJECT (I915_GEM_PHYS_OVERLAY_REGS)
79
80struct drm_i915_gem_phys_object {
81 int id;
82 struct page **page_list;
83 drm_dma_handle_t *handle;
84 struct drm_gem_object *cur_obj;
85};
86
75typedef struct _drm_i915_ring_buffer { 87typedef struct _drm_i915_ring_buffer {
76 int tail_mask; 88 int tail_mask;
77 unsigned long Size; 89 unsigned long Size;
@@ -358,6 +370,9 @@ typedef struct drm_i915_private {
358 uint32_t bit_6_swizzle_x; 370 uint32_t bit_6_swizzle_x;
359 /** Bit 6 swizzling required for Y tiling */ 371 /** Bit 6 swizzling required for Y tiling */
360 uint32_t bit_6_swizzle_y; 372 uint32_t bit_6_swizzle_y;
373
374 /* storage for physical objects */
375 struct drm_i915_gem_phys_object *phys_objs[I915_MAX_PHYS_OBJECT];
361 } mm; 376 } mm;
362} drm_i915_private_t; 377} drm_i915_private_t;
363 378
@@ -436,6 +451,9 @@ struct drm_i915_gem_object {
436 /** User space pin count and filp owning the pin */ 451 /** User space pin count and filp owning the pin */
437 uint32_t user_pin_count; 452 uint32_t user_pin_count;
438 struct drm_file *pin_filp; 453 struct drm_file *pin_filp;
454
455 /** for phy allocated objects */
456 struct drm_i915_gem_phys_object *phys_obj;
439}; 457};
440 458
441/** 459/**
@@ -598,6 +616,11 @@ int i915_gem_do_init(struct drm_device *dev, unsigned long start,
598int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf); 616int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
599int i915_gem_object_set_to_gtt_domain(struct drm_gem_object *obj, 617int i915_gem_object_set_to_gtt_domain(struct drm_gem_object *obj,
600 int write); 618 int write);
619int i915_gem_attach_phys_object(struct drm_device *dev,
620 struct drm_gem_object *obj, int id);
621void i915_gem_detach_phys_object(struct drm_device *dev,
622 struct drm_gem_object *obj);
623void i915_gem_free_all_phys_object(struct drm_device *dev);
601 624
602/* i915_gem_tiling.c */ 625/* i915_gem_tiling.c */
603void i915_gem_detect_bit_6_swizzle(struct drm_device *dev); 626void i915_gem_detect_bit_6_swizzle(struct drm_device *dev);
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 14afc23a0e24..96316fd47233 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -55,6 +55,9 @@ static int i915_gem_object_bind_to_gtt(struct drm_gem_object *obj,
55static void i915_gem_object_get_fence_reg(struct drm_gem_object *obj); 55static void i915_gem_object_get_fence_reg(struct drm_gem_object *obj);
56static void i915_gem_clear_fence_reg(struct drm_gem_object *obj); 56static void i915_gem_clear_fence_reg(struct drm_gem_object *obj);
57static int i915_gem_evict_something(struct drm_device *dev); 57static int i915_gem_evict_something(struct drm_device *dev);
58static int i915_gem_phys_pwrite(struct drm_device *dev, struct drm_gem_object *obj,
59 struct drm_i915_gem_pwrite *args,
60 struct drm_file *file_priv);
58 61
59int i915_gem_do_init(struct drm_device *dev, unsigned long start, 62int i915_gem_do_init(struct drm_device *dev, unsigned long start,
60 unsigned long end) 63 unsigned long end)
@@ -386,8 +389,10 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
386 * pread/pwrite currently are reading and writing from the CPU 389 * pread/pwrite currently are reading and writing from the CPU
387 * perspective, requiring manual detiling by the client. 390 * perspective, requiring manual detiling by the client.
388 */ 391 */
389 if (obj_priv->tiling_mode == I915_TILING_NONE && 392 if (obj_priv->phys_obj)
390 dev->gtt_total != 0) 393 ret = i915_gem_phys_pwrite(dev, obj, args, file_priv);
394 else if (obj_priv->tiling_mode == I915_TILING_NONE &&
395 dev->gtt_total != 0)
391 ret = i915_gem_gtt_pwrite(dev, obj, args, file_priv); 396 ret = i915_gem_gtt_pwrite(dev, obj, args, file_priv);
392 else 397 else
393 ret = i915_gem_shmem_pwrite(dev, obj, args, file_priv); 398 ret = i915_gem_shmem_pwrite(dev, obj, args, file_priv);
@@ -1445,7 +1450,7 @@ static void i915_write_fence_reg(struct drm_i915_fence_reg *reg)
1445 1450
1446 if ((obj_priv->gtt_offset & ~I915_FENCE_START_MASK) || 1451 if ((obj_priv->gtt_offset & ~I915_FENCE_START_MASK) ||
1447 (obj_priv->gtt_offset & (obj->size - 1))) { 1452 (obj_priv->gtt_offset & (obj->size - 1))) {
1448 WARN(1, "%s: object not 1M or size aligned\n", __FUNCTION__); 1453 WARN(1, "%s: object not 1M or size aligned\n", __func__);
1449 return; 1454 return;
1450 } 1455 }
1451 1456
@@ -1478,7 +1483,7 @@ static void i830_write_fence_reg(struct drm_i915_fence_reg *reg)
1478 1483
1479 if ((obj_priv->gtt_offset & ~I915_FENCE_START_MASK) || 1484 if ((obj_priv->gtt_offset & ~I915_FENCE_START_MASK) ||
1480 (obj_priv->gtt_offset & (obj->size - 1))) { 1485 (obj_priv->gtt_offset & (obj->size - 1))) {
1481 WARN(1, "%s: object not 1M or size aligned\n", __FUNCTION__); 1486 WARN(1, "%s: object not 1M or size aligned\n", __func__);
1482 return; 1487 return;
1483 } 1488 }
1484 1489
@@ -2858,6 +2863,9 @@ void i915_gem_free_object(struct drm_gem_object *obj)
2858 while (obj_priv->pin_count > 0) 2863 while (obj_priv->pin_count > 0)
2859 i915_gem_object_unpin(obj); 2864 i915_gem_object_unpin(obj);
2860 2865
2866 if (obj_priv->phys_obj)
2867 i915_gem_detach_phys_object(dev, obj);
2868
2861 i915_gem_object_unbind(obj); 2869 i915_gem_object_unbind(obj);
2862 2870
2863 list = &obj->map_list; 2871 list = &obj->map_list;
@@ -3293,3 +3301,180 @@ i915_gem_load(struct drm_device *dev)
3293 3301
3294 i915_gem_detect_bit_6_swizzle(dev); 3302 i915_gem_detect_bit_6_swizzle(dev);
3295} 3303}
3304
3305/*
3306 * Create a physically contiguous memory object for this object
3307 * e.g. for cursor + overlay regs
3308 */
3309int i915_gem_init_phys_object(struct drm_device *dev,
3310 int id, int size)
3311{
3312 drm_i915_private_t *dev_priv = dev->dev_private;
3313 struct drm_i915_gem_phys_object *phys_obj;
3314 int ret;
3315
3316 if (dev_priv->mm.phys_objs[id - 1] || !size)
3317 return 0;
3318
3319 phys_obj = drm_calloc(1, sizeof(struct drm_i915_gem_phys_object), DRM_MEM_DRIVER);
3320 if (!phys_obj)
3321 return -ENOMEM;
3322
3323 phys_obj->id = id;
3324
3325 phys_obj->handle = drm_pci_alloc(dev, size, 0, 0xffffffff);
3326 if (!phys_obj->handle) {
3327 ret = -ENOMEM;
3328 goto kfree_obj;
3329 }
3330#ifdef CONFIG_X86
3331 set_memory_wc((unsigned long)phys_obj->handle->vaddr, phys_obj->handle->size / PAGE_SIZE);
3332#endif
3333
3334 dev_priv->mm.phys_objs[id - 1] = phys_obj;
3335
3336 return 0;
3337kfree_obj:
3338 drm_free(phys_obj, sizeof(struct drm_i915_gem_phys_object), DRM_MEM_DRIVER);
3339 return ret;
3340}
3341
3342void i915_gem_free_phys_object(struct drm_device *dev, int id)
3343{
3344 drm_i915_private_t *dev_priv = dev->dev_private;
3345 struct drm_i915_gem_phys_object *phys_obj;
3346
3347 if (!dev_priv->mm.phys_objs[id - 1])
3348 return;
3349
3350 phys_obj = dev_priv->mm.phys_objs[id - 1];
3351 if (phys_obj->cur_obj) {
3352 i915_gem_detach_phys_object(dev, phys_obj->cur_obj);
3353 }
3354
3355#ifdef CONFIG_X86
3356 set_memory_wb((unsigned long)phys_obj->handle->vaddr, phys_obj->handle->size / PAGE_SIZE);
3357#endif
3358 drm_pci_free(dev, phys_obj->handle);
3359 kfree(phys_obj);
3360 dev_priv->mm.phys_objs[id - 1] = NULL;
3361}
3362
3363void i915_gem_free_all_phys_object(struct drm_device *dev)
3364{
3365 int i;
3366
3367 for (i = 0; i < I915_MAX_PHYS_OBJECT; i++)
3368 i915_gem_free_phys_object(dev, i);
3369}
3370
3371void i915_gem_detach_phys_object(struct drm_device *dev,
3372 struct drm_gem_object *obj)
3373{
3374 struct drm_i915_gem_object *obj_priv;
3375 int i;
3376 int ret;
3377 int page_count;
3378
3379 obj_priv = obj->driver_private;
3380 if (!obj_priv->phys_obj)
3381 return;
3382
3383 ret = i915_gem_object_get_page_list(obj);
3384 if (ret)
3385 goto out;
3386
3387 page_count = obj->size / PAGE_SIZE;
3388
3389 for (i = 0; i < page_count; i++) {
3390 char *dst = kmap_atomic(obj_priv->page_list[i], KM_USER0);
3391 char *src = obj_priv->phys_obj->handle->vaddr + (i * PAGE_SIZE);
3392
3393 memcpy(dst, src, PAGE_SIZE);
3394 kunmap_atomic(dst, KM_USER0);
3395 }
3396 drm_clflush_pages(obj_priv->page_list, page_count);
3397 drm_agp_chipset_flush(dev);
3398out:
3399 obj_priv->phys_obj->cur_obj = NULL;
3400 obj_priv->phys_obj = NULL;
3401}
3402
3403int
3404i915_gem_attach_phys_object(struct drm_device *dev,
3405 struct drm_gem_object *obj, int id)
3406{
3407 drm_i915_private_t *dev_priv = dev->dev_private;
3408 struct drm_i915_gem_object *obj_priv;
3409 int ret = 0;
3410 int page_count;
3411 int i;
3412
3413 if (id > I915_MAX_PHYS_OBJECT)
3414 return -EINVAL;
3415
3416 obj_priv = obj->driver_private;
3417
3418 if (obj_priv->phys_obj) {
3419 if (obj_priv->phys_obj->id == id)
3420 return 0;
3421 i915_gem_detach_phys_object(dev, obj);
3422 }
3423
3424
3425 /* create a new object */
3426 if (!dev_priv->mm.phys_objs[id - 1]) {
3427 ret = i915_gem_init_phys_object(dev, id,
3428 obj->size);
3429 if (ret) {
3430 DRM_ERROR("failed to init phys object %d size: %d\n", id, obj->size);
3431 goto out;
3432 }
3433 }
3434
3435 /* bind to the object */
3436 obj_priv->phys_obj = dev_priv->mm.phys_objs[id - 1];
3437 obj_priv->phys_obj->cur_obj = obj;
3438
3439 ret = i915_gem_object_get_page_list(obj);
3440 if (ret) {
3441 DRM_ERROR("failed to get page list\n");
3442 goto out;
3443 }
3444
3445 page_count = obj->size / PAGE_SIZE;
3446
3447 for (i = 0; i < page_count; i++) {
3448 char *src = kmap_atomic(obj_priv->page_list[i], KM_USER0);
3449 char *dst = obj_priv->phys_obj->handle->vaddr + (i * PAGE_SIZE);
3450
3451 memcpy(dst, src, PAGE_SIZE);
3452 kunmap_atomic(src, KM_USER0);
3453 }
3454
3455 return 0;
3456out:
3457 return ret;
3458}
3459
3460static int
3461i915_gem_phys_pwrite(struct drm_device *dev, struct drm_gem_object *obj,
3462 struct drm_i915_gem_pwrite *args,
3463 struct drm_file *file_priv)
3464{
3465 struct drm_i915_gem_object *obj_priv = obj->driver_private;
3466 void *obj_addr;
3467 int ret;
3468 char __user *user_data;
3469
3470 user_data = (char __user *) (uintptr_t) args->data_ptr;
3471 obj_addr = obj_priv->phys_obj->handle->vaddr + args->offset;
3472
3473 DRM_ERROR("obj_addr %p, %lld\n", obj_addr, args->size);
3474 ret = copy_from_user(obj_addr, user_data, args->size);
3475 if (ret)
3476 return -EFAULT;
3477
3478 drm_agp_chipset_flush(dev);
3479 return 0;
3480}
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 0cadafbef411..6290219de6c8 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -411,6 +411,12 @@ int i915_enable_vblank(struct drm_device *dev, int pipe)
411{ 411{
412 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; 412 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
413 unsigned long irqflags; 413 unsigned long irqflags;
414 int pipeconf_reg = (pipe == 0) ? PIPEACONF : PIPEBCONF;
415 u32 pipeconf;
416
417 pipeconf = I915_READ(pipeconf_reg);
418 if (!(pipeconf & PIPEACONF_ENABLE))
419 return -EINVAL;
414 420
415 spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags); 421 spin_lock_irqsave(&dev_priv->user_irq_lock, irqflags);
416 if (IS_I965G(dev)) 422 if (IS_I965G(dev))
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 8ccb9c3ab868..31c3732b7a69 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -401,6 +401,8 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
401 I915_WRITE(dspstride, crtc->fb->pitch); 401 I915_WRITE(dspstride, crtc->fb->pitch);
402 402
403 dspcntr = I915_READ(dspcntr_reg); 403 dspcntr = I915_READ(dspcntr_reg);
404 /* Mask out pixel format bits in case we change it */
405 dspcntr &= ~DISPPLANE_PIXFORMAT_MASK;
404 switch (crtc->fb->bits_per_pixel) { 406 switch (crtc->fb->bits_per_pixel) {
405 case 8: 407 case 8:
406 dspcntr |= DISPPLANE_8BPP; 408 dspcntr |= DISPPLANE_8BPP;
@@ -1014,21 +1016,25 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
1014 1016
1015 if (bo->size < width * height * 4) { 1017 if (bo->size < width * height * 4) {
1016 DRM_ERROR("buffer is to small\n"); 1018 DRM_ERROR("buffer is to small\n");
1017 drm_gem_object_unreference(bo); 1019 ret = -ENOMEM;
1018 return -ENOMEM; 1020 goto fail;
1019 } 1021 }
1020 1022
1021 if (dev_priv->cursor_needs_physical) { 1023 /* we only need to pin inside GTT if cursor is non-phy */
1022 addr = dev->agp->base + obj_priv->gtt_offset; 1024 if (!dev_priv->cursor_needs_physical) {
1023 } else { 1025 ret = i915_gem_object_pin(bo, PAGE_SIZE);
1026 if (ret) {
1027 DRM_ERROR("failed to pin cursor bo\n");
1028 goto fail;
1029 }
1024 addr = obj_priv->gtt_offset; 1030 addr = obj_priv->gtt_offset;
1025 } 1031 } else {
1026 1032 ret = i915_gem_attach_phys_object(dev, bo, (pipe == 0) ? I915_GEM_PHYS_CURSOR_0 : I915_GEM_PHYS_CURSOR_1);
1027 ret = i915_gem_object_pin(bo, PAGE_SIZE); 1033 if (ret) {
1028 if (ret) { 1034 DRM_ERROR("failed to attach phys object\n");
1029 DRM_ERROR("failed to pin cursor bo\n"); 1035 goto fail;
1030 drm_gem_object_unreference(bo); 1036 }
1031 return ret; 1037 addr = obj_priv->phys_obj->handle->busaddr;
1032 } 1038 }
1033 1039
1034 temp = 0; 1040 temp = 0;
@@ -1041,14 +1047,25 @@ static int intel_crtc_cursor_set(struct drm_crtc *crtc,
1041 I915_WRITE(base, addr); 1047 I915_WRITE(base, addr);
1042 1048
1043 if (intel_crtc->cursor_bo) { 1049 if (intel_crtc->cursor_bo) {
1044 i915_gem_object_unpin(intel_crtc->cursor_bo); 1050 if (dev_priv->cursor_needs_physical) {
1051 if (intel_crtc->cursor_bo != bo)
1052 i915_gem_detach_phys_object(dev, intel_crtc->cursor_bo);
1053 } else
1054 i915_gem_object_unpin(intel_crtc->cursor_bo);
1055 mutex_lock(&dev->struct_mutex);
1045 drm_gem_object_unreference(intel_crtc->cursor_bo); 1056 drm_gem_object_unreference(intel_crtc->cursor_bo);
1057 mutex_unlock(&dev->struct_mutex);
1046 } 1058 }
1047 1059
1048 intel_crtc->cursor_addr = addr; 1060 intel_crtc->cursor_addr = addr;
1049 intel_crtc->cursor_bo = bo; 1061 intel_crtc->cursor_bo = bo;
1050 1062
1051 return 0; 1063 return 0;
1064fail:
1065 mutex_lock(&dev->struct_mutex);
1066 drm_gem_object_unreference(bo);
1067 mutex_unlock(&dev->struct_mutex);
1068 return ret;
1052} 1069}
1053 1070
1054static int intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) 1071static int intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index ccecfaf6307b..2fafdcc108fe 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -456,6 +456,13 @@ void intel_lvds_init(struct drm_device *dev)
456 dev_priv->panel_fixed_mode = 456 dev_priv->panel_fixed_mode =
457 drm_mode_duplicate(dev, dev_priv->vbt_mode); 457 drm_mode_duplicate(dev, dev_priv->vbt_mode);
458 mutex_unlock(&dev->mode_config.mutex); 458 mutex_unlock(&dev->mode_config.mutex);
459 if (dev_priv->panel_fixed_mode) {
460 dev_priv->panel_fixed_mode->type |=
461 DRM_MODE_TYPE_PREFERRED;
462 drm_mode_probed_add(connector,
463 dev_priv->panel_fixed_mode);
464 goto out;
465 }
459 } 466 }
460 467
461 /* 468 /*
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 03cb494af1c5..f0a0f72238ab 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -102,7 +102,7 @@ static void hid_reset(struct work_struct *work)
102 struct usbhid_device *usbhid = 102 struct usbhid_device *usbhid =
103 container_of(work, struct usbhid_device, reset_work); 103 container_of(work, struct usbhid_device, reset_work);
104 struct hid_device *hid = usbhid->hid; 104 struct hid_device *hid = usbhid->hid;
105 int rc_lock, rc = 0; 105 int rc = 0;
106 106
107 if (test_bit(HID_CLEAR_HALT, &usbhid->iofl)) { 107 if (test_bit(HID_CLEAR_HALT, &usbhid->iofl)) {
108 dev_dbg(&usbhid->intf->dev, "clear halt\n"); 108 dev_dbg(&usbhid->intf->dev, "clear halt\n");
@@ -113,11 +113,10 @@ static void hid_reset(struct work_struct *work)
113 113
114 else if (test_bit(HID_RESET_PENDING, &usbhid->iofl)) { 114 else if (test_bit(HID_RESET_PENDING, &usbhid->iofl)) {
115 dev_dbg(&usbhid->intf->dev, "resetting device\n"); 115 dev_dbg(&usbhid->intf->dev, "resetting device\n");
116 rc = rc_lock = usb_lock_device_for_reset(hid_to_usb_dev(hid), usbhid->intf); 116 rc = usb_lock_device_for_reset(hid_to_usb_dev(hid), usbhid->intf);
117 if (rc_lock >= 0) { 117 if (rc == 0) {
118 rc = usb_reset_device(hid_to_usb_dev(hid)); 118 rc = usb_reset_device(hid_to_usb_dev(hid));
119 if (rc_lock) 119 usb_unlock_device(hid_to_usb_dev(hid));
120 usb_unlock_device(hid_to_usb_dev(hid));
121 } 120 }
122 clear_bit(HID_RESET_PENDING, &usbhid->iofl); 121 clear_bit(HID_RESET_PENDING, &usbhid->iofl);
123 } 122 }
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 6a98f9f572b0..d73eea382ab3 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -874,12 +874,14 @@ int hiddev_connect(struct hid_device *hid, unsigned int force)
874 INIT_LIST_HEAD(&hiddev->list); 874 INIT_LIST_HEAD(&hiddev->list);
875 spin_lock_init(&hiddev->list_lock); 875 spin_lock_init(&hiddev->list_lock);
876 mutex_init(&hiddev->existancelock); 876 mutex_init(&hiddev->existancelock);
877 hid->hiddev = hiddev;
877 hiddev->hid = hid; 878 hiddev->hid = hid;
878 hiddev->exist = 1; 879 hiddev->exist = 1;
879 880
880 retval = usb_register_dev(usbhid->intf, &hiddev_class); 881 retval = usb_register_dev(usbhid->intf, &hiddev_class);
881 if (retval) { 882 if (retval) {
882 err_hid("Not able to get a minor for this device."); 883 err_hid("Not able to get a minor for this device.");
884 hid->hiddev = NULL;
883 kfree(hiddev); 885 kfree(hiddev);
884 return -1; 886 return -1;
885 } else { 887 } else {
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index c709e821f04b..b84bf066879b 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -189,6 +189,16 @@ config SENSORS_ADT7473
189 This driver can also be built as a module. If so, the module 189 This driver can also be built as a module. If so, the module
190 will be called adt7473. 190 will be called adt7473.
191 191
192config SENSORS_ADT7475
193 tristate "Analog Devices ADT7475"
194 depends on I2C && EXPERIMENTAL
195 help
196 If you say yes here you get support for the Analog Devices
197 ADT7475 hardware monitoring chips.
198
199 This driver can also be build as a module. If so, the module
200 will be called adt7475.
201
192config SENSORS_K8TEMP 202config SENSORS_K8TEMP
193 tristate "AMD Athlon64/FX or Opteron temperature sensor" 203 tristate "AMD Athlon64/FX or Opteron temperature sensor"
194 depends on X86 && PCI && EXPERIMENTAL 204 depends on X86 && PCI && EXPERIMENTAL
@@ -284,11 +294,12 @@ config SENSORS_F71805F
284 will be called f71805f. 294 will be called f71805f.
285 295
286config SENSORS_F71882FG 296config SENSORS_F71882FG
287 tristate "Fintek F71882FG and F71883FG" 297 tristate "Fintek F71862FG, F71882FG and F8000"
288 depends on EXPERIMENTAL 298 depends on EXPERIMENTAL
289 help 299 help
290 If you say yes here you get support for hardware monitoring 300 If you say yes here you get support for hardware monitoring
291 features of the Fintek F71882FG and F71883FG Super-I/O chips. 301 features of the Fintek F71882FG/F71883FG, F71862FG/71863FG
302 and F8000 Super-I/O chips.
292 303
293 This driver can also be built as a module. If so, the module 304 This driver can also be built as a module. If so, the module
294 will be called f71882fg. 305 will be called f71882fg.
@@ -304,9 +315,13 @@ config SENSORS_F75375S
304 will be called f75375s. 315 will be called f75375s.
305 316
306config SENSORS_FSCHER 317config SENSORS_FSCHER
307 tristate "FSC Hermes" 318 tristate "FSC Hermes (DEPRECATED)"
308 depends on X86 && I2C 319 depends on X86 && I2C
309 help 320 help
321 This driver is DEPRECATED please use the new merged fschmd
322 ("FSC Poseidon, Scylla, Hermes, Heimdall and Heracles") driver
323 instead.
324
310 If you say yes here you get support for Fujitsu Siemens 325 If you say yes here you get support for Fujitsu Siemens
311 Computers Hermes sensor chips. 326 Computers Hermes sensor chips.
312 327
@@ -314,9 +329,13 @@ config SENSORS_FSCHER
314 will be called fscher. 329 will be called fscher.
315 330
316config SENSORS_FSCPOS 331config SENSORS_FSCPOS
317 tristate "FSC Poseidon" 332 tristate "FSC Poseidon (DEPRECATED)"
318 depends on X86 && I2C 333 depends on X86 && I2C
319 help 334 help
335 This driver is DEPRECATED please use the new merged fschmd
336 ("FSC Poseidon, Scylla, Hermes, Heimdall and Heracles") driver
337 instead.
338
320 If you say yes here you get support for Fujitsu Siemens 339 If you say yes here you get support for Fujitsu Siemens
321 Computers Poseidon sensor chips. 340 Computers Poseidon sensor chips.
322 341
@@ -325,14 +344,15 @@ config SENSORS_FSCPOS
325 344
326config SENSORS_FSCHMD 345config SENSORS_FSCHMD
327 tristate "FSC Poseidon, Scylla, Hermes, Heimdall and Heracles" 346 tristate "FSC Poseidon, Scylla, Hermes, Heimdall and Heracles"
328 depends on X86 && I2C && EXPERIMENTAL 347 depends on X86 && I2C
329 help 348 help
330 If you say yes here you get support for various Fujitsu Siemens 349 If you say yes here you get support for various Fujitsu Siemens
331 Computers sensor chips. 350 Computers sensor chips, including support for the integrated
351 watchdog.
332 352
333 This is a new merged driver for FSC sensor chips which is intended 353 This is a merged driver for FSC sensor chips replacing the fscpos,
334 as a replacment for the fscpos, fscscy and fscher drivers and adds 354 fscscy and fscher drivers and adding support for several other FSC
335 support for several other FCS sensor chips. 355 sensor chips.
336 356
337 This driver can also be built as a module. If so, the module 357 This driver can also be built as a module. If so, the module
338 will be called fschmd. 358 will be called fschmd.
@@ -399,7 +419,8 @@ config SENSORS_IT87
399 select HWMON_VID 419 select HWMON_VID
400 help 420 help
401 If you say yes here you get support for ITE IT8705F, IT8712F, 421 If you say yes here you get support for ITE IT8705F, IT8712F,
402 IT8716F, IT8718F and IT8726F sensor chips, and the SiS960 clone. 422 IT8716F, IT8718F, IT8720F and IT8726F sensor chips, and the
423 SiS960 clone.
403 424
404 This driver can also be built as a module. If so, the module 425 This driver can also be built as a module. If so, the module
405 will be called it87. 426 will be called it87.
@@ -417,11 +438,12 @@ config SENSORS_LM63
417 will be called lm63. 438 will be called lm63.
418 439
419config SENSORS_LM70 440config SENSORS_LM70
420 tristate "National Semiconductor LM70" 441 tristate "National Semiconductor LM70 / Texas Instruments TMP121"
421 depends on SPI_MASTER && EXPERIMENTAL 442 depends on SPI_MASTER && EXPERIMENTAL
422 help 443 help
423 If you say yes here you get support for the National Semiconductor 444 If you say yes here you get support for the National Semiconductor
424 LM70 digital temperature sensor chip. 445 LM70 and Texas Instruments TMP121/TMP123 digital temperature
446 sensor chips.
425 447
426 This driver can also be built as a module. If so, the module 448 This driver can also be built as a module. If so, the module
427 will be called lm70. 449 will be called lm70.
@@ -548,6 +570,17 @@ config SENSORS_LM93
548 This driver can also be built as a module. If so, the module 570 This driver can also be built as a module. If so, the module
549 will be called lm93. 571 will be called lm93.
550 572
573config SENSORS_LTC4245
574 tristate "Linear Technology LTC4245"
575 depends on I2C && EXPERIMENTAL
576 default n
577 help
578 If you say yes here you get support for Linear Technology LTC4245
579 Multiple Supply Hot Swap Controller I2C interface.
580
581 This driver can also be built as a module. If so, the module will
582 be called ltc4245.
583
551config SENSORS_MAX1111 584config SENSORS_MAX1111
552 tristate "Maxim MAX1111 Multichannel, Serial 8-bit ADC chip" 585 tristate "Maxim MAX1111 Multichannel, Serial 8-bit ADC chip"
553 depends on SPI_MASTER 586 depends on SPI_MASTER
@@ -838,6 +871,8 @@ config SENSORS_HDAPS
838config SENSORS_LIS3LV02D 871config SENSORS_LIS3LV02D
839 tristate "STMicroeletronics LIS3LV02Dx three-axis digital accelerometer" 872 tristate "STMicroeletronics LIS3LV02Dx three-axis digital accelerometer"
840 depends on ACPI && INPUT 873 depends on ACPI && INPUT
874 select NEW_LEDS
875 select LEDS_CLASS
841 default n 876 default n
842 help 877 help
843 This driver provides support for the LIS3LV02Dx accelerometer. In 878 This driver provides support for the LIS3LV02Dx accelerometer. In
@@ -849,10 +884,16 @@ config SENSORS_LIS3LV02D
849 /sys/devices/platform/lis3lv02d. 884 /sys/devices/platform/lis3lv02d.
850 885
851 This driver also provides an absolute input class device, allowing 886 This driver also provides an absolute input class device, allowing
852 the laptop to act as a pinball machine-esque joystick. 887 the laptop to act as a pinball machine-esque joystick. On HP laptops,
888 if the led infrastructure is activated, support for a led indicating
889 disk protection will be provided as hp:red:hddprotection.
853 890
854 This driver can also be built as a module. If so, the module 891 This driver can also be built as modules. If so, the core module
855 will be called lis3lv02d. 892 will be called lis3lv02d and a specific module for HP laptops will be
893 called hp_accel.
894
895 Say Y here if you have an applicable laptop and want to experience
896 the awesome power of lis3lv02d.
856 897
857config SENSORS_APPLESMC 898config SENSORS_APPLESMC
858 tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)" 899 tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)"
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 58fc5be5355d..2e80f37f39eb 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -28,6 +28,8 @@ obj-$(CONFIG_SENSORS_ADS7828) += ads7828.o
28obj-$(CONFIG_SENSORS_ADT7462) += adt7462.o 28obj-$(CONFIG_SENSORS_ADT7462) += adt7462.o
29obj-$(CONFIG_SENSORS_ADT7470) += adt7470.o 29obj-$(CONFIG_SENSORS_ADT7470) += adt7470.o
30obj-$(CONFIG_SENSORS_ADT7473) += adt7473.o 30obj-$(CONFIG_SENSORS_ADT7473) += adt7473.o
31obj-$(CONFIG_SENSORS_ADT7475) += adt7475.o
32
31obj-$(CONFIG_SENSORS_APPLESMC) += applesmc.o 33obj-$(CONFIG_SENSORS_APPLESMC) += applesmc.o
32obj-$(CONFIG_SENSORS_AMS) += ams/ 34obj-$(CONFIG_SENSORS_AMS) += ams/
33obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o 35obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o
@@ -49,7 +51,7 @@ obj-$(CONFIG_SENSORS_IBMAEM) += ibmaem.o
49obj-$(CONFIG_SENSORS_IBMPEX) += ibmpex.o 51obj-$(CONFIG_SENSORS_IBMPEX) += ibmpex.o
50obj-$(CONFIG_SENSORS_IT87) += it87.o 52obj-$(CONFIG_SENSORS_IT87) += it87.o
51obj-$(CONFIG_SENSORS_K8TEMP) += k8temp.o 53obj-$(CONFIG_SENSORS_K8TEMP) += k8temp.o
52obj-$(CONFIG_SENSORS_LIS3LV02D) += lis3lv02d.o 54obj-$(CONFIG_SENSORS_LIS3LV02D) += lis3lv02d.o hp_accel.o
53obj-$(CONFIG_SENSORS_LM63) += lm63.o 55obj-$(CONFIG_SENSORS_LM63) += lm63.o
54obj-$(CONFIG_SENSORS_LM70) += lm70.o 56obj-$(CONFIG_SENSORS_LM70) += lm70.o
55obj-$(CONFIG_SENSORS_LM75) += lm75.o 57obj-$(CONFIG_SENSORS_LM75) += lm75.o
@@ -62,6 +64,7 @@ obj-$(CONFIG_SENSORS_LM87) += lm87.o
62obj-$(CONFIG_SENSORS_LM90) += lm90.o 64obj-$(CONFIG_SENSORS_LM90) += lm90.o
63obj-$(CONFIG_SENSORS_LM92) += lm92.o 65obj-$(CONFIG_SENSORS_LM92) += lm92.o
64obj-$(CONFIG_SENSORS_LM93) += lm93.o 66obj-$(CONFIG_SENSORS_LM93) += lm93.o
67obj-$(CONFIG_SENSORS_LTC4245) += ltc4245.o
65obj-$(CONFIG_SENSORS_MAX1111) += max1111.o 68obj-$(CONFIG_SENSORS_MAX1111) += max1111.o
66obj-$(CONFIG_SENSORS_MAX1619) += max1619.o 69obj-$(CONFIG_SENSORS_MAX1619) += max1619.o
67obj-$(CONFIG_SENSORS_MAX6650) += max6650.o 70obj-$(CONFIG_SENSORS_MAX6650) += max6650.o
diff --git a/drivers/hwmon/abituguru3.c b/drivers/hwmon/abituguru3.c
index 70bb854086df..e52b38806d03 100644
--- a/drivers/hwmon/abituguru3.c
+++ b/drivers/hwmon/abituguru3.c
@@ -279,7 +279,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = {
279 { "OTES1 Fan", 36, 2, 60, 1, 0 }, 279 { "OTES1 Fan", 36, 2, 60, 1, 0 },
280 { NULL, 0, 0, 0, 0, 0 } } 280 { NULL, 0, 0, 0, 0, 0 } }
281 }, 281 },
282 { 0x0011, "AT8 32X(ATI RD580-ULI M1575)", { 282 { 0x0011, "AT8 32X", {
283 { "CPU Core", 0, 0, 10, 1, 0 }, 283 { "CPU Core", 0, 0, 10, 1, 0 },
284 { "DDR", 1, 0, 20, 1, 0 }, 284 { "DDR", 1, 0, 20, 1, 0 },
285 { "DDR VTT", 2, 0, 10, 1, 0 }, 285 { "DDR VTT", 2, 0, 10, 1, 0 },
@@ -402,7 +402,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = {
402 { "AUX3 Fan", 36, 2, 60, 1, 0 }, 402 { "AUX3 Fan", 36, 2, 60, 1, 0 },
403 { NULL, 0, 0, 0, 0, 0 } } 403 { NULL, 0, 0, 0, 0, 0 } }
404 }, 404 },
405 { 0x0016, "AW9D-MAX (Intel i975-ICH7)", { 405 { 0x0016, "AW9D-MAX", {
406 { "CPU Core", 0, 0, 10, 1, 0 }, 406 { "CPU Core", 0, 0, 10, 1, 0 },
407 { "DDR2", 1, 0, 20, 1, 0 }, 407 { "DDR2", 1, 0, 20, 1, 0 },
408 { "DDR2 VTT", 2, 0, 10, 1, 0 }, 408 { "DDR2 VTT", 2, 0, 10, 1, 0 },
@@ -482,7 +482,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = {
482 { "AUX3 Fan", 36, 2, 60, 1, 0 }, 482 { "AUX3 Fan", 36, 2, 60, 1, 0 },
483 { NULL, 0, 0, 0, 0, 0 } } 483 { NULL, 0, 0, 0, 0, 0 } }
484 }, 484 },
485 { 0x0019, NULL /* Unknown, need DMI string */, { 485 { 0x0019, "IN9 32X MAX", {
486 { "CPU Core", 7, 0, 10, 1, 0 }, 486 { "CPU Core", 7, 0, 10, 1, 0 },
487 { "DDR2", 13, 0, 20, 1, 0 }, 487 { "DDR2", 13, 0, 20, 1, 0 },
488 { "DDR2 VTT", 14, 0, 10, 1, 0 }, 488 { "DDR2 VTT", 14, 0, 10, 1, 0 },
@@ -509,7 +509,7 @@ static const struct abituguru3_motherboard_info abituguru3_motherboards[] = {
509 { "AUX3 FAN", 36, 2, 60, 1, 0 }, 509 { "AUX3 FAN", 36, 2, 60, 1, 0 },
510 { NULL, 0, 0, 0, 0, 0 } } 510 { NULL, 0, 0, 0, 0, 0 } }
511 }, 511 },
512 { 0x001A, "IP35 Pro(Intel P35-ICH9R)", { 512 { 0x001A, "IP35 Pro", {
513 { "CPU Core", 0, 0, 10, 1, 0 }, 513 { "CPU Core", 0, 0, 10, 1, 0 },
514 { "DDR2", 1, 0, 20, 1, 0 }, 514 { "DDR2", 1, 0, 20, 1, 0 },
515 { "DDR2 VTT", 2, 0, 10, 1, 0 }, 515 { "DDR2 VTT", 2, 0, 10, 1, 0 },
@@ -1128,6 +1128,7 @@ static int __init abituguru3_dmi_detect(void)
1128{ 1128{
1129 const char *board_vendor, *board_name; 1129 const char *board_vendor, *board_name;
1130 int i, err = (force) ? 1 : -ENODEV; 1130 int i, err = (force) ? 1 : -ENODEV;
1131 size_t sublen;
1131 1132
1132 board_vendor = dmi_get_system_info(DMI_BOARD_VENDOR); 1133 board_vendor = dmi_get_system_info(DMI_BOARD_VENDOR);
1133 if (!board_vendor || strcmp(board_vendor, "http://www.abit.com.tw/")) 1134 if (!board_vendor || strcmp(board_vendor, "http://www.abit.com.tw/"))
@@ -1137,9 +1138,20 @@ static int __init abituguru3_dmi_detect(void)
1137 if (!board_name) 1138 if (!board_name)
1138 return err; 1139 return err;
1139 1140
1141 /* At the moment, we don't care about the part of the vendor
1142 * DMI string contained in brackets. Truncate the string at
1143 * the first occurrence of a bracket. Trim any trailing space
1144 * from the substring.
1145 */
1146 sublen = strcspn(board_name, "(");
1147 while (sublen > 0 && board_name[sublen - 1] == ' ')
1148 sublen--;
1149
1140 for (i = 0; abituguru3_motherboards[i].id; i++) { 1150 for (i = 0; abituguru3_motherboards[i].id; i++) {
1141 const char *dmi_name = abituguru3_motherboards[i].dmi_name; 1151 const char *dmi_name = abituguru3_motherboards[i].dmi_name;
1142 if (dmi_name && !strcmp(dmi_name, board_name)) 1152 if (!dmi_name || strlen(dmi_name) != sublen)
1153 continue;
1154 if (!strncasecmp(board_name, dmi_name, sublen))
1143 break; 1155 break;
1144 } 1156 }
1145 1157
@@ -1153,7 +1165,7 @@ static int __init abituguru3_dmi_detect(void)
1153 1165
1154static inline int abituguru3_dmi_detect(void) 1166static inline int abituguru3_dmi_detect(void)
1155{ 1167{
1156 return -ENODEV; 1168 return 1;
1157} 1169}
1158 1170
1159#endif /* CONFIG_DMI */ 1171#endif /* CONFIG_DMI */
diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c
new file mode 100644
index 000000000000..d39877a7da63
--- /dev/null
+++ b/drivers/hwmon/adt7475.c
@@ -0,0 +1,1221 @@
1/*
2 * adt7475 - Thermal sensor driver for the ADT7475 chip and derivatives
3 * Copyright (C) 2007-2008, Advanced Micro Devices, Inc.
4 * Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net>
5 * Copyright (C) 2008 Hans de Goede <hdegoede@redhat.com>
6
7 * Derived from the lm83 driver by Jean Delvare
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/slab.h>
17#include <linux/i2c.h>
18#include <linux/hwmon.h>
19#include <linux/hwmon-sysfs.h>
20#include <linux/err.h>
21
22/* Indexes for the sysfs hooks */
23
24#define INPUT 0
25#define MIN 1
26#define MAX 2
27#define CONTROL 3
28#define OFFSET 3
29#define AUTOMIN 4
30#define THERM 5
31#define HYSTERSIS 6
32
33/* These are unique identifiers for the sysfs functions - unlike the
34 numbers above, these are not also indexes into an array
35*/
36
37#define ALARM 9
38#define FAULT 10
39
40/* 7475 Common Registers */
41
42#define REG_VOLTAGE_BASE 0x21
43#define REG_TEMP_BASE 0x25
44#define REG_TACH_BASE 0x28
45#define REG_PWM_BASE 0x30
46#define REG_PWM_MAX_BASE 0x38
47
48#define REG_DEVID 0x3D
49#define REG_VENDID 0x3E
50
51#define REG_STATUS1 0x41
52#define REG_STATUS2 0x42
53
54#define REG_VOLTAGE_MIN_BASE 0x46
55#define REG_VOLTAGE_MAX_BASE 0x47
56
57#define REG_TEMP_MIN_BASE 0x4E
58#define REG_TEMP_MAX_BASE 0x4F
59
60#define REG_TACH_MIN_BASE 0x54
61
62#define REG_PWM_CONFIG_BASE 0x5C
63
64#define REG_TEMP_TRANGE_BASE 0x5F
65
66#define REG_PWM_MIN_BASE 0x64
67
68#define REG_TEMP_TMIN_BASE 0x67
69#define REG_TEMP_THERM_BASE 0x6A
70
71#define REG_REMOTE1_HYSTERSIS 0x6D
72#define REG_REMOTE2_HYSTERSIS 0x6E
73
74#define REG_TEMP_OFFSET_BASE 0x70
75
76#define REG_EXTEND1 0x76
77#define REG_EXTEND2 0x77
78#define REG_CONFIG5 0x7C
79
80#define CONFIG5_TWOSCOMP 0x01
81#define CONFIG5_TEMPOFFSET 0x02
82
83/* ADT7475 Settings */
84
85#define ADT7475_VOLTAGE_COUNT 2
86#define ADT7475_TEMP_COUNT 3
87#define ADT7475_TACH_COUNT 4
88#define ADT7475_PWM_COUNT 3
89
90/* Macro to read the registers */
91
92#define adt7475_read(reg) i2c_smbus_read_byte_data(client, (reg))
93
94/* Macros to easily index the registers */
95
96#define TACH_REG(idx) (REG_TACH_BASE + ((idx) * 2))
97#define TACH_MIN_REG(idx) (REG_TACH_MIN_BASE + ((idx) * 2))
98
99#define PWM_REG(idx) (REG_PWM_BASE + (idx))
100#define PWM_MAX_REG(idx) (REG_PWM_MAX_BASE + (idx))
101#define PWM_MIN_REG(idx) (REG_PWM_MIN_BASE + (idx))
102#define PWM_CONFIG_REG(idx) (REG_PWM_CONFIG_BASE + (idx))
103
104#define VOLTAGE_REG(idx) (REG_VOLTAGE_BASE + (idx))
105#define VOLTAGE_MIN_REG(idx) (REG_VOLTAGE_MIN_BASE + ((idx) * 2))
106#define VOLTAGE_MAX_REG(idx) (REG_VOLTAGE_MAX_BASE + ((idx) * 2))
107
108#define TEMP_REG(idx) (REG_TEMP_BASE + (idx))
109#define TEMP_MIN_REG(idx) (REG_TEMP_MIN_BASE + ((idx) * 2))
110#define TEMP_MAX_REG(idx) (REG_TEMP_MAX_BASE + ((idx) * 2))
111#define TEMP_TMIN_REG(idx) (REG_TEMP_TMIN_BASE + (idx))
112#define TEMP_THERM_REG(idx) (REG_TEMP_THERM_BASE + (idx))
113#define TEMP_OFFSET_REG(idx) (REG_TEMP_OFFSET_BASE + (idx))
114#define TEMP_TRANGE_REG(idx) (REG_TEMP_TRANGE_BASE + (idx))
115
116static unsigned short normal_i2c[] = { 0x2e, I2C_CLIENT_END };
117
118I2C_CLIENT_INSMOD_1(adt7475);
119
120static const struct i2c_device_id adt7475_id[] = {
121 { "adt7475", adt7475 },
122 { }
123};
124MODULE_DEVICE_TABLE(i2c, adt7475_id);
125
126struct adt7475_data {
127 struct device *hwmon_dev;
128 struct mutex lock;
129
130 unsigned long measure_updated;
131 unsigned long limits_updated;
132 char valid;
133
134 u8 config5;
135 u16 alarms;
136 u16 voltage[3][3];
137 u16 temp[7][3];
138 u16 tach[2][4];
139 u8 pwm[4][3];
140 u8 range[3];
141 u8 pwmctl[3];
142 u8 pwmchan[3];
143};
144
145static struct i2c_driver adt7475_driver;
146static struct adt7475_data *adt7475_update_device(struct device *dev);
147static void adt7475_read_hystersis(struct i2c_client *client);
148static void adt7475_read_pwm(struct i2c_client *client, int index);
149
150/* Given a temp value, convert it to register value */
151
152static inline u16 temp2reg(struct adt7475_data *data, long val)
153{
154 u16 ret;
155
156 if (!(data->config5 & CONFIG5_TWOSCOMP)) {
157 val = SENSORS_LIMIT(val, -64000, 191000);
158 ret = (val + 64500) / 1000;
159 } else {
160 val = SENSORS_LIMIT(val, -128000, 127000);
161 if (val < -500)
162 ret = (256500 + val) / 1000;
163 else
164 ret = (val + 500) / 1000;
165 }
166
167 return ret << 2;
168}
169
170/* Given a register value, convert it to a real temp value */
171
172static inline int reg2temp(struct adt7475_data *data, u16 reg)
173{
174 if (data->config5 & CONFIG5_TWOSCOMP) {
175 if (reg >= 512)
176 return (reg - 1024) * 250;
177 else
178 return reg * 250;
179 } else
180 return (reg - 256) * 250;
181}
182
183static inline int tach2rpm(u16 tach)
184{
185 if (tach == 0 || tach == 0xFFFF)
186 return 0;
187
188 return (90000 * 60) / tach;
189}
190
191static inline u16 rpm2tach(unsigned long rpm)
192{
193 if (rpm == 0)
194 return 0;
195
196 return SENSORS_LIMIT((90000 * 60) / rpm, 1, 0xFFFF);
197}
198
199static inline int reg2vcc(u16 reg)
200{
201 return (4296 * reg) / 1000;
202}
203
204static inline int reg2vccp(u16 reg)
205{
206 return (2929 * reg) / 1000;
207}
208
209static inline u16 vcc2reg(long vcc)
210{
211 vcc = SENSORS_LIMIT(vcc, 0, 4396);
212 return (vcc * 1000) / 4296;
213}
214
215static inline u16 vccp2reg(long vcc)
216{
217 vcc = SENSORS_LIMIT(vcc, 0, 2998);
218 return (vcc * 1000) / 2929;
219}
220
221static u16 adt7475_read_word(struct i2c_client *client, int reg)
222{
223 u16 val;
224
225 val = i2c_smbus_read_byte_data(client, reg);
226 val |= (i2c_smbus_read_byte_data(client, reg + 1) << 8);
227
228 return val;
229}
230
231static void adt7475_write_word(struct i2c_client *client, int reg, u16 val)
232{
233 i2c_smbus_write_byte_data(client, reg + 1, val >> 8);
234 i2c_smbus_write_byte_data(client, reg, val & 0xFF);
235}
236
237/* Find the nearest value in a table - used for pwm frequency and
238 auto temp range */
239static int find_nearest(long val, const int *array, int size)
240{
241 int i;
242
243 if (val < array[0])
244 return 0;
245
246 if (val > array[size - 1])
247 return size - 1;
248
249 for (i = 0; i < size - 1; i++) {
250 int a, b;
251
252 if (val > array[i + 1])
253 continue;
254
255 a = val - array[i];
256 b = array[i + 1] - val;
257
258 return (a <= b) ? i : i + 1;
259 }
260
261 return 0;
262}
263
264static ssize_t show_voltage(struct device *dev, struct device_attribute *attr,
265 char *buf)
266{
267 struct adt7475_data *data = adt7475_update_device(dev);
268 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
269 unsigned short val;
270
271 switch (sattr->nr) {
272 case ALARM:
273 return sprintf(buf, "%d\n",
274 (data->alarms >> (sattr->index + 1)) & 1);
275 default:
276 val = data->voltage[sattr->nr][sattr->index];
277 return sprintf(buf, "%d\n",
278 sattr->index ==
279 0 ? reg2vccp(val) : reg2vcc(val));
280 }
281}
282
283static ssize_t set_voltage(struct device *dev, struct device_attribute *attr,
284 const char *buf, size_t count)
285{
286
287 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
288 struct i2c_client *client = to_i2c_client(dev);
289 struct adt7475_data *data = i2c_get_clientdata(client);
290 unsigned char reg;
291 long val;
292
293 if (strict_strtol(buf, 10, &val))
294 return -EINVAL;
295
296 mutex_lock(&data->lock);
297
298 data->voltage[sattr->nr][sattr->index] =
299 sattr->index ? vcc2reg(val) : vccp2reg(val);
300
301 if (sattr->nr == MIN)
302 reg = VOLTAGE_MIN_REG(sattr->index);
303 else
304 reg = VOLTAGE_MAX_REG(sattr->index);
305
306 i2c_smbus_write_byte_data(client, reg,
307 data->voltage[sattr->nr][sattr->index] >> 2);
308 mutex_unlock(&data->lock);
309
310 return count;
311}
312
313static ssize_t show_temp(struct device *dev, struct device_attribute *attr,
314 char *buf)
315{
316 struct adt7475_data *data = adt7475_update_device(dev);
317 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
318 int out;
319
320 switch (sattr->nr) {
321 case HYSTERSIS:
322 mutex_lock(&data->lock);
323 out = data->temp[sattr->nr][sattr->index];
324 if (sattr->index != 1)
325 out = (out >> 4) & 0xF;
326 else
327 out = (out & 0xF);
328 /* Show the value as an absolute number tied to
329 * THERM */
330 out = reg2temp(data, data->temp[THERM][sattr->index]) -
331 out * 1000;
332 mutex_unlock(&data->lock);
333 break;
334
335 case OFFSET:
336 /* Offset is always 2's complement, regardless of the
337 * setting in CONFIG5 */
338 mutex_lock(&data->lock);
339 out = (s8)data->temp[sattr->nr][sattr->index];
340 if (data->config5 & CONFIG5_TEMPOFFSET)
341 out *= 1000;
342 else
343 out *= 500;
344 mutex_unlock(&data->lock);
345 break;
346
347 case ALARM:
348 out = (data->alarms >> (sattr->index + 4)) & 1;
349 break;
350
351 case FAULT:
352 /* Note - only for remote1 and remote2 */
353 out = data->alarms & (sattr->index ? 0x8000 : 0x4000);
354 out = out ? 0 : 1;
355 break;
356
357 default:
358 /* All other temp values are in the configured format */
359 out = reg2temp(data, data->temp[sattr->nr][sattr->index]);
360 }
361
362 return sprintf(buf, "%d\n", out);
363}
364
365static ssize_t set_temp(struct device *dev, struct device_attribute *attr,
366 const char *buf, size_t count)
367{
368 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
369 struct i2c_client *client = to_i2c_client(dev);
370 struct adt7475_data *data = i2c_get_clientdata(client);
371 unsigned char reg = 0;
372 u8 out;
373 int temp;
374 long val;
375
376 if (strict_strtol(buf, 10, &val))
377 return -EINVAL;
378
379 mutex_lock(&data->lock);
380
381 /* We need the config register in all cases for temp <-> reg conv. */
382 data->config5 = adt7475_read(REG_CONFIG5);
383
384 switch (sattr->nr) {
385 case OFFSET:
386 if (data->config5 & CONFIG5_TEMPOFFSET) {
387 val = SENSORS_LIMIT(val, -63000, 127000);
388 out = data->temp[OFFSET][sattr->index] = val / 1000;
389 } else {
390 val = SENSORS_LIMIT(val, -63000, 64000);
391 out = data->temp[OFFSET][sattr->index] = val / 500;
392 }
393 break;
394
395 case HYSTERSIS:
396 /* The value will be given as an absolute value, turn it
397 into an offset based on THERM */
398
399 /* Read fresh THERM and HYSTERSIS values from the chip */
400 data->temp[THERM][sattr->index] =
401 adt7475_read(TEMP_THERM_REG(sattr->index)) << 2;
402 adt7475_read_hystersis(client);
403
404 temp = reg2temp(data, data->temp[THERM][sattr->index]);
405 val = SENSORS_LIMIT(val, temp - 15000, temp);
406 val = (temp - val) / 1000;
407
408 if (sattr->index != 1) {
409 data->temp[HYSTERSIS][sattr->index] &= 0xF0;
410 data->temp[HYSTERSIS][sattr->index] |= (val & 0xF) << 4;
411 } else {
412 data->temp[HYSTERSIS][sattr->index] &= 0x0F;
413 data->temp[HYSTERSIS][sattr->index] |= (val & 0xF);
414 }
415
416 out = data->temp[HYSTERSIS][sattr->index];
417 break;
418
419 default:
420 data->temp[sattr->nr][sattr->index] = temp2reg(data, val);
421
422 /* We maintain an extra 2 digits of precision for simplicity
423 * - shift those back off before writing the value */
424 out = (u8) (data->temp[sattr->nr][sattr->index] >> 2);
425 }
426
427 switch (sattr->nr) {
428 case MIN:
429 reg = TEMP_MIN_REG(sattr->index);
430 break;
431 case MAX:
432 reg = TEMP_MAX_REG(sattr->index);
433 break;
434 case OFFSET:
435 reg = TEMP_OFFSET_REG(sattr->index);
436 break;
437 case AUTOMIN:
438 reg = TEMP_TMIN_REG(sattr->index);
439 break;
440 case THERM:
441 reg = TEMP_THERM_REG(sattr->index);
442 break;
443 case HYSTERSIS:
444 if (sattr->index != 2)
445 reg = REG_REMOTE1_HYSTERSIS;
446 else
447 reg = REG_REMOTE2_HYSTERSIS;
448
449 break;
450 }
451
452 i2c_smbus_write_byte_data(client, reg, out);
453
454 mutex_unlock(&data->lock);
455 return count;
456}
457
458/* Table of autorange values - the user will write the value in millidegrees,
459 and we'll convert it */
460static const int autorange_table[] = {
461 2000, 2500, 3330, 4000, 5000, 6670, 8000,
462 10000, 13330, 16000, 20000, 26670, 32000, 40000,
463 53330, 80000
464};
465
466static ssize_t show_point2(struct device *dev, struct device_attribute *attr,
467 char *buf)
468{
469 struct adt7475_data *data = adt7475_update_device(dev);
470 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
471 int out, val;
472
473 mutex_lock(&data->lock);
474 out = (data->range[sattr->index] >> 4) & 0x0F;
475 val = reg2temp(data, data->temp[AUTOMIN][sattr->index]);
476 mutex_unlock(&data->lock);
477
478 return sprintf(buf, "%d\n", val + autorange_table[out]);
479}
480
481static ssize_t set_point2(struct device *dev, struct device_attribute *attr,
482 const char *buf, size_t count)
483{
484 struct i2c_client *client = to_i2c_client(dev);
485 struct adt7475_data *data = i2c_get_clientdata(client);
486 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
487 int temp;
488 long val;
489
490 if (strict_strtol(buf, 10, &val))
491 return -EINVAL;
492
493 mutex_lock(&data->lock);
494
495 /* Get a fresh copy of the needed registers */
496 data->config5 = adt7475_read(REG_CONFIG5);
497 data->temp[AUTOMIN][sattr->index] =
498 adt7475_read(TEMP_TMIN_REG(sattr->index)) << 2;
499 data->range[sattr->index] =
500 adt7475_read(TEMP_TRANGE_REG(sattr->index));
501
502 /* The user will write an absolute value, so subtract the start point
503 to figure the range */
504 temp = reg2temp(data, data->temp[AUTOMIN][sattr->index]);
505 val = SENSORS_LIMIT(val, temp + autorange_table[0],
506 temp + autorange_table[ARRAY_SIZE(autorange_table) - 1]);
507 val -= temp;
508
509 /* Find the nearest table entry to what the user wrote */
510 val = find_nearest(val, autorange_table, ARRAY_SIZE(autorange_table));
511
512 data->range[sattr->index] &= ~0xF0;
513 data->range[sattr->index] |= val << 4;
514
515 i2c_smbus_write_byte_data(client, TEMP_TRANGE_REG(sattr->index),
516 data->range[sattr->index]);
517
518 mutex_unlock(&data->lock);
519 return count;
520}
521
522static ssize_t show_tach(struct device *dev, struct device_attribute *attr,
523 char *buf)
524{
525 struct adt7475_data *data = adt7475_update_device(dev);
526 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
527 int out;
528
529 if (sattr->nr == ALARM)
530 out = (data->alarms >> (sattr->index + 10)) & 1;
531 else
532 out = tach2rpm(data->tach[sattr->nr][sattr->index]);
533
534 return sprintf(buf, "%d\n", out);
535}
536
537static ssize_t set_tach(struct device *dev, struct device_attribute *attr,
538 const char *buf, size_t count)
539{
540
541 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
542 struct i2c_client *client = to_i2c_client(dev);
543 struct adt7475_data *data = i2c_get_clientdata(client);
544 unsigned long val;
545
546 if (strict_strtoul(buf, 10, &val))
547 return -EINVAL;
548
549 mutex_lock(&data->lock);
550
551 data->tach[MIN][sattr->index] = rpm2tach(val);
552
553 adt7475_write_word(client, TACH_MIN_REG(sattr->index),
554 data->tach[MIN][sattr->index]);
555
556 mutex_unlock(&data->lock);
557 return count;
558}
559
560static ssize_t show_pwm(struct device *dev, struct device_attribute *attr,
561 char *buf)
562{
563 struct adt7475_data *data = adt7475_update_device(dev);
564 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
565
566 return sprintf(buf, "%d\n", data->pwm[sattr->nr][sattr->index]);
567}
568
569static ssize_t show_pwmchan(struct device *dev, struct device_attribute *attr,
570 char *buf)
571{
572 struct adt7475_data *data = adt7475_update_device(dev);
573 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
574
575 return sprintf(buf, "%d\n", data->pwmchan[sattr->index]);
576}
577
578static ssize_t show_pwmctrl(struct device *dev, struct device_attribute *attr,
579 char *buf)
580{
581 struct adt7475_data *data = adt7475_update_device(dev);
582 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
583
584 return sprintf(buf, "%d\n", data->pwmctl[sattr->index]);
585}
586
587static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
588 const char *buf, size_t count)
589{
590
591 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
592 struct i2c_client *client = to_i2c_client(dev);
593 struct adt7475_data *data = i2c_get_clientdata(client);
594 unsigned char reg = 0;
595 long val;
596
597 if (strict_strtol(buf, 10, &val))
598 return -EINVAL;
599
600 mutex_lock(&data->lock);
601
602 switch (sattr->nr) {
603 case INPUT:
604 /* Get a fresh value for CONTROL */
605 data->pwm[CONTROL][sattr->index] =
606 adt7475_read(PWM_CONFIG_REG(sattr->index));
607
608 /* If we are not in manual mode, then we shouldn't allow
609 * the user to set the pwm speed */
610 if (((data->pwm[CONTROL][sattr->index] >> 5) & 7) != 7) {
611 mutex_unlock(&data->lock);
612 return count;
613 }
614
615 reg = PWM_REG(sattr->index);
616 break;
617
618 case MIN:
619 reg = PWM_MIN_REG(sattr->index);
620 break;
621
622 case MAX:
623 reg = PWM_MAX_REG(sattr->index);
624 break;
625 }
626
627 data->pwm[sattr->nr][sattr->index] = SENSORS_LIMIT(val, 0, 0xFF);
628 i2c_smbus_write_byte_data(client, reg,
629 data->pwm[sattr->nr][sattr->index]);
630
631 mutex_unlock(&data->lock);
632
633 return count;
634}
635
636/* Called by set_pwmctrl and set_pwmchan */
637
638static int hw_set_pwm(struct i2c_client *client, int index,
639 unsigned int pwmctl, unsigned int pwmchan)
640{
641 struct adt7475_data *data = i2c_get_clientdata(client);
642 long val = 0;
643
644 switch (pwmctl) {
645 case 0:
646 val = 0x03; /* Run at full speed */
647 break;
648 case 1:
649 val = 0x07; /* Manual mode */
650 break;
651 case 2:
652 switch (pwmchan) {
653 case 1:
654 /* Remote1 controls PWM */
655 val = 0x00;
656 break;
657 case 2:
658 /* local controls PWM */
659 val = 0x01;
660 break;
661 case 4:
662 /* remote2 controls PWM */
663 val = 0x02;
664 break;
665 case 6:
666 /* local/remote2 control PWM */
667 val = 0x05;
668 break;
669 case 7:
670 /* All three control PWM */
671 val = 0x06;
672 break;
673 default:
674 return -EINVAL;
675 }
676 break;
677 default:
678 return -EINVAL;
679 }
680
681 data->pwmctl[index] = pwmctl;
682 data->pwmchan[index] = pwmchan;
683
684 data->pwm[CONTROL][index] &= ~0xE0;
685 data->pwm[CONTROL][index] |= (val & 7) << 5;
686
687 i2c_smbus_write_byte_data(client, PWM_CONFIG_REG(index),
688 data->pwm[CONTROL][index]);
689
690 return 0;
691}
692
693static ssize_t set_pwmchan(struct device *dev, struct device_attribute *attr,
694 const char *buf, size_t count)
695{
696 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
697 struct i2c_client *client = to_i2c_client(dev);
698 struct adt7475_data *data = i2c_get_clientdata(client);
699 int r;
700 long val;
701
702 if (strict_strtol(buf, 10, &val))
703 return -EINVAL;
704
705 mutex_lock(&data->lock);
706 /* Read Modify Write PWM values */
707 adt7475_read_pwm(client, sattr->index);
708 r = hw_set_pwm(client, sattr->index, data->pwmctl[sattr->index], val);
709 if (r)
710 count = r;
711 mutex_unlock(&data->lock);
712
713 return count;
714}
715
716static ssize_t set_pwmctrl(struct device *dev, struct device_attribute *attr,
717 const char *buf, size_t count)
718{
719 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
720 struct i2c_client *client = to_i2c_client(dev);
721 struct adt7475_data *data = i2c_get_clientdata(client);
722 int r;
723 long val;
724
725 if (strict_strtol(buf, 10, &val))
726 return -EINVAL;
727
728 mutex_lock(&data->lock);
729 /* Read Modify Write PWM values */
730 adt7475_read_pwm(client, sattr->index);
731 r = hw_set_pwm(client, sattr->index, val, data->pwmchan[sattr->index]);
732 if (r)
733 count = r;
734 mutex_unlock(&data->lock);
735
736 return count;
737}
738
739/* List of frequencies for the PWM */
740static const int pwmfreq_table[] = {
741 11, 14, 22, 29, 35, 44, 58, 88
742};
743
744static ssize_t show_pwmfreq(struct device *dev, struct device_attribute *attr,
745 char *buf)
746{
747 struct adt7475_data *data = adt7475_update_device(dev);
748 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
749
750 return sprintf(buf, "%d\n",
751 pwmfreq_table[data->range[sattr->index] & 7]);
752}
753
754static ssize_t set_pwmfreq(struct device *dev, struct device_attribute *attr,
755 const char *buf, size_t count)
756{
757 struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
758 struct i2c_client *client = to_i2c_client(dev);
759 struct adt7475_data *data = i2c_get_clientdata(client);
760 int out;
761 long val;
762
763 if (strict_strtol(buf, 10, &val))
764 return -EINVAL;
765
766 out = find_nearest(val, pwmfreq_table, ARRAY_SIZE(pwmfreq_table));
767
768 mutex_lock(&data->lock);
769
770 data->range[sattr->index] =
771 adt7475_read(TEMP_TRANGE_REG(sattr->index));
772 data->range[sattr->index] &= ~7;
773 data->range[sattr->index] |= out;
774
775 i2c_smbus_write_byte_data(client, TEMP_TRANGE_REG(sattr->index),
776 data->range[sattr->index]);
777
778 mutex_unlock(&data->lock);
779 return count;
780}
781
782static SENSOR_DEVICE_ATTR_2(in1_input, S_IRUGO, show_voltage, NULL, INPUT, 0);
783static SENSOR_DEVICE_ATTR_2(in1_max, S_IRUGO | S_IWUSR, show_voltage,
784 set_voltage, MAX, 0);
785static SENSOR_DEVICE_ATTR_2(in1_min, S_IRUGO | S_IWUSR, show_voltage,
786 set_voltage, MIN, 0);
787static SENSOR_DEVICE_ATTR_2(in1_alarm, S_IRUGO, show_voltage, NULL, ALARM, 0);
788static SENSOR_DEVICE_ATTR_2(in2_input, S_IRUGO, show_voltage, NULL, INPUT, 1);
789static SENSOR_DEVICE_ATTR_2(in2_max, S_IRUGO | S_IWUSR, show_voltage,
790 set_voltage, MAX, 1);
791static SENSOR_DEVICE_ATTR_2(in2_min, S_IRUGO | S_IWUSR, show_voltage,
792 set_voltage, MIN, 1);
793static SENSOR_DEVICE_ATTR_2(in2_alarm, S_IRUGO, show_voltage, NULL, ALARM, 1);
794static SENSOR_DEVICE_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, INPUT, 0);
795static SENSOR_DEVICE_ATTR_2(temp1_alarm, S_IRUGO, show_temp, NULL, ALARM, 0);
796static SENSOR_DEVICE_ATTR_2(temp1_fault, S_IRUGO, show_temp, NULL, FAULT, 0);
797static SENSOR_DEVICE_ATTR_2(temp1_max, S_IRUGO | S_IWUSR, show_temp, set_temp,
798 MAX, 0);
799static SENSOR_DEVICE_ATTR_2(temp1_min, S_IRUGO | S_IWUSR, show_temp, set_temp,
800 MIN, 0);
801static SENSOR_DEVICE_ATTR_2(temp1_offset, S_IRUGO | S_IWUSR, show_temp,
802 set_temp, OFFSET, 0);
803static SENSOR_DEVICE_ATTR_2(temp1_auto_point1_temp, S_IRUGO | S_IWUSR,
804 show_temp, set_temp, AUTOMIN, 0);
805static SENSOR_DEVICE_ATTR_2(temp1_auto_point2_temp, S_IRUGO | S_IWUSR,
806 show_point2, set_point2, 0, 0);
807static SENSOR_DEVICE_ATTR_2(temp1_crit, S_IRUGO | S_IWUSR, show_temp, set_temp,
808 THERM, 0);
809static SENSOR_DEVICE_ATTR_2(temp1_crit_hyst, S_IRUGO | S_IWUSR, show_temp,
810 set_temp, HYSTERSIS, 0);
811static SENSOR_DEVICE_ATTR_2(temp2_input, S_IRUGO, show_temp, NULL, INPUT, 1);
812static SENSOR_DEVICE_ATTR_2(temp2_alarm, S_IRUGO, show_temp, NULL, ALARM, 1);
813static SENSOR_DEVICE_ATTR_2(temp2_max, S_IRUGO | S_IWUSR, show_temp, set_temp,
814 MAX, 1);
815static SENSOR_DEVICE_ATTR_2(temp2_min, S_IRUGO | S_IWUSR, show_temp, set_temp,
816 MIN, 1);
817static SENSOR_DEVICE_ATTR_2(temp2_offset, S_IRUGO | S_IWUSR, show_temp,
818 set_temp, OFFSET, 1);
819static SENSOR_DEVICE_ATTR_2(temp2_auto_point1_temp, S_IRUGO | S_IWUSR,
820 show_temp, set_temp, AUTOMIN, 1);
821static SENSOR_DEVICE_ATTR_2(temp2_auto_point2_temp, S_IRUGO | S_IWUSR,
822 show_point2, set_point2, 0, 1);
823static SENSOR_DEVICE_ATTR_2(temp2_crit, S_IRUGO | S_IWUSR, show_temp, set_temp,
824 THERM, 1);
825static SENSOR_DEVICE_ATTR_2(temp2_crit_hyst, S_IRUGO | S_IWUSR, show_temp,
826 set_temp, HYSTERSIS, 1);
827static SENSOR_DEVICE_ATTR_2(temp3_input, S_IRUGO, show_temp, NULL, INPUT, 2);
828static SENSOR_DEVICE_ATTR_2(temp3_alarm, S_IRUGO, show_temp, NULL, ALARM, 2);
829static SENSOR_DEVICE_ATTR_2(temp3_fault, S_IRUGO, show_temp, NULL, FAULT, 2);
830static SENSOR_DEVICE_ATTR_2(temp3_max, S_IRUGO | S_IWUSR, show_temp, set_temp,
831 MAX, 2);
832static SENSOR_DEVICE_ATTR_2(temp3_min, S_IRUGO | S_IWUSR, show_temp, set_temp,
833 MIN, 2);
834static SENSOR_DEVICE_ATTR_2(temp3_offset, S_IRUGO | S_IWUSR, show_temp,
835 set_temp, OFFSET, 2);
836static SENSOR_DEVICE_ATTR_2(temp3_auto_point1_temp, S_IRUGO | S_IWUSR,
837 show_temp, set_temp, AUTOMIN, 2);
838static SENSOR_DEVICE_ATTR_2(temp3_auto_point2_temp, S_IRUGO | S_IWUSR,
839 show_point2, set_point2, 0, 2);
840static SENSOR_DEVICE_ATTR_2(temp3_crit, S_IRUGO | S_IWUSR, show_temp, set_temp,
841 THERM, 2);
842static SENSOR_DEVICE_ATTR_2(temp3_crit_hyst, S_IRUGO | S_IWUSR, show_temp,
843 set_temp, HYSTERSIS, 2);
844static SENSOR_DEVICE_ATTR_2(fan1_input, S_IRUGO, show_tach, NULL, INPUT, 0);
845static SENSOR_DEVICE_ATTR_2(fan1_min, S_IRUGO | S_IWUSR, show_tach, set_tach,
846 MIN, 0);
847static SENSOR_DEVICE_ATTR_2(fan1_alarm, S_IRUGO, show_tach, NULL, ALARM, 0);
848static SENSOR_DEVICE_ATTR_2(fan2_input, S_IRUGO, show_tach, NULL, INPUT, 1);
849static SENSOR_DEVICE_ATTR_2(fan2_min, S_IRUGO | S_IWUSR, show_tach, set_tach,
850 MIN, 1);
851static SENSOR_DEVICE_ATTR_2(fan2_alarm, S_IRUGO, show_tach, NULL, ALARM, 1);
852static SENSOR_DEVICE_ATTR_2(fan3_input, S_IRUGO, show_tach, NULL, INPUT, 2);
853static SENSOR_DEVICE_ATTR_2(fan3_min, S_IRUGO | S_IWUSR, show_tach, set_tach,
854 MIN, 2);
855static SENSOR_DEVICE_ATTR_2(fan3_alarm, S_IRUGO, show_tach, NULL, ALARM, 2);
856static SENSOR_DEVICE_ATTR_2(fan4_input, S_IRUGO, show_tach, NULL, INPUT, 3);
857static SENSOR_DEVICE_ATTR_2(fan4_min, S_IRUGO | S_IWUSR, show_tach, set_tach,
858 MIN, 3);
859static SENSOR_DEVICE_ATTR_2(fan4_alarm, S_IRUGO, show_tach, NULL, ALARM, 3);
860static SENSOR_DEVICE_ATTR_2(pwm1, S_IRUGO | S_IWUSR, show_pwm, set_pwm, INPUT,
861 0);
862static SENSOR_DEVICE_ATTR_2(pwm1_freq, S_IRUGO | S_IWUSR, show_pwmfreq,
863 set_pwmfreq, INPUT, 0);
864static SENSOR_DEVICE_ATTR_2(pwm1_enable, S_IRUGO | S_IWUSR, show_pwmctrl,
865 set_pwmctrl, INPUT, 0);
866static SENSOR_DEVICE_ATTR_2(pwm1_auto_channel_temp, S_IRUGO | S_IWUSR,
867 show_pwmchan, set_pwmchan, INPUT, 0);
868static SENSOR_DEVICE_ATTR_2(pwm1_auto_point1_pwm, S_IRUGO | S_IWUSR, show_pwm,
869 set_pwm, MIN, 0);
870static SENSOR_DEVICE_ATTR_2(pwm1_auto_point2_pwm, S_IRUGO | S_IWUSR, show_pwm,
871 set_pwm, MAX, 0);
872static SENSOR_DEVICE_ATTR_2(pwm2, S_IRUGO | S_IWUSR, show_pwm, set_pwm, INPUT,
873 1);
874static SENSOR_DEVICE_ATTR_2(pwm2_freq, S_IRUGO | S_IWUSR, show_pwmfreq,
875 set_pwmfreq, INPUT, 1);
876static SENSOR_DEVICE_ATTR_2(pwm2_enable, S_IRUGO | S_IWUSR, show_pwmctrl,
877 set_pwmctrl, INPUT, 1);
878static SENSOR_DEVICE_ATTR_2(pwm2_auto_channel_temp, S_IRUGO | S_IWUSR,
879 show_pwmchan, set_pwmchan, INPUT, 1);
880static SENSOR_DEVICE_ATTR_2(pwm2_auto_point1_pwm, S_IRUGO | S_IWUSR, show_pwm,
881 set_pwm, MIN, 1);
882static SENSOR_DEVICE_ATTR_2(pwm2_auto_point2_pwm, S_IRUGO | S_IWUSR, show_pwm,
883 set_pwm, MAX, 1);
884static SENSOR_DEVICE_ATTR_2(pwm3, S_IRUGO | S_IWUSR, show_pwm, set_pwm, INPUT,
885 2);
886static SENSOR_DEVICE_ATTR_2(pwm3_freq, S_IRUGO | S_IWUSR, show_pwmfreq,
887 set_pwmfreq, INPUT, 2);
888static SENSOR_DEVICE_ATTR_2(pwm3_enable, S_IRUGO | S_IWUSR, show_pwmctrl,
889 set_pwmctrl, INPUT, 2);
890static SENSOR_DEVICE_ATTR_2(pwm3_auto_channel_temp, S_IRUGO | S_IWUSR,
891 show_pwmchan, set_pwmchan, INPUT, 2);
892static SENSOR_DEVICE_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO | S_IWUSR, show_pwm,
893 set_pwm, MIN, 2);
894static SENSOR_DEVICE_ATTR_2(pwm3_auto_point2_pwm, S_IRUGO | S_IWUSR, show_pwm,
895 set_pwm, MAX, 2);
896
897static struct attribute *adt7475_attrs[] = {
898 &sensor_dev_attr_in1_input.dev_attr.attr,
899 &sensor_dev_attr_in1_max.dev_attr.attr,
900 &sensor_dev_attr_in1_min.dev_attr.attr,
901 &sensor_dev_attr_in1_alarm.dev_attr.attr,
902 &sensor_dev_attr_in2_input.dev_attr.attr,
903 &sensor_dev_attr_in2_max.dev_attr.attr,
904 &sensor_dev_attr_in2_min.dev_attr.attr,
905 &sensor_dev_attr_in2_alarm.dev_attr.attr,
906 &sensor_dev_attr_temp1_input.dev_attr.attr,
907 &sensor_dev_attr_temp1_alarm.dev_attr.attr,
908 &sensor_dev_attr_temp1_fault.dev_attr.attr,
909 &sensor_dev_attr_temp1_max.dev_attr.attr,
910 &sensor_dev_attr_temp1_min.dev_attr.attr,
911 &sensor_dev_attr_temp1_offset.dev_attr.attr,
912 &sensor_dev_attr_temp1_auto_point1_temp.dev_attr.attr,
913 &sensor_dev_attr_temp1_auto_point2_temp.dev_attr.attr,
914 &sensor_dev_attr_temp1_crit.dev_attr.attr,
915 &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr,
916 &sensor_dev_attr_temp2_input.dev_attr.attr,
917 &sensor_dev_attr_temp2_alarm.dev_attr.attr,
918 &sensor_dev_attr_temp2_max.dev_attr.attr,
919 &sensor_dev_attr_temp2_min.dev_attr.attr,
920 &sensor_dev_attr_temp2_offset.dev_attr.attr,
921 &sensor_dev_attr_temp2_auto_point1_temp.dev_attr.attr,
922 &sensor_dev_attr_temp2_auto_point2_temp.dev_attr.attr,
923 &sensor_dev_attr_temp2_crit.dev_attr.attr,
924 &sensor_dev_attr_temp2_crit_hyst.dev_attr.attr,
925 &sensor_dev_attr_temp3_input.dev_attr.attr,
926 &sensor_dev_attr_temp3_fault.dev_attr.attr,
927 &sensor_dev_attr_temp3_alarm.dev_attr.attr,
928 &sensor_dev_attr_temp3_max.dev_attr.attr,
929 &sensor_dev_attr_temp3_min.dev_attr.attr,
930 &sensor_dev_attr_temp3_offset.dev_attr.attr,
931 &sensor_dev_attr_temp3_auto_point1_temp.dev_attr.attr,
932 &sensor_dev_attr_temp3_auto_point2_temp.dev_attr.attr,
933 &sensor_dev_attr_temp3_crit.dev_attr.attr,
934 &sensor_dev_attr_temp3_crit_hyst.dev_attr.attr,
935 &sensor_dev_attr_fan1_input.dev_attr.attr,
936 &sensor_dev_attr_fan1_min.dev_attr.attr,
937 &sensor_dev_attr_fan1_alarm.dev_attr.attr,
938 &sensor_dev_attr_fan2_input.dev_attr.attr,
939 &sensor_dev_attr_fan2_min.dev_attr.attr,
940 &sensor_dev_attr_fan2_alarm.dev_attr.attr,
941 &sensor_dev_attr_fan3_input.dev_attr.attr,
942 &sensor_dev_attr_fan3_min.dev_attr.attr,
943 &sensor_dev_attr_fan3_alarm.dev_attr.attr,
944 &sensor_dev_attr_fan4_input.dev_attr.attr,
945 &sensor_dev_attr_fan4_min.dev_attr.attr,
946 &sensor_dev_attr_fan4_alarm.dev_attr.attr,
947 &sensor_dev_attr_pwm1.dev_attr.attr,
948 &sensor_dev_attr_pwm1_freq.dev_attr.attr,
949 &sensor_dev_attr_pwm1_enable.dev_attr.attr,
950 &sensor_dev_attr_pwm1_auto_channel_temp.dev_attr.attr,
951 &sensor_dev_attr_pwm1_auto_point1_pwm.dev_attr.attr,
952 &sensor_dev_attr_pwm1_auto_point2_pwm.dev_attr.attr,
953 &sensor_dev_attr_pwm2.dev_attr.attr,
954 &sensor_dev_attr_pwm2_freq.dev_attr.attr,
955 &sensor_dev_attr_pwm2_enable.dev_attr.attr,
956 &sensor_dev_attr_pwm2_auto_channel_temp.dev_attr.attr,
957 &sensor_dev_attr_pwm2_auto_point1_pwm.dev_attr.attr,
958 &sensor_dev_attr_pwm2_auto_point2_pwm.dev_attr.attr,
959 &sensor_dev_attr_pwm3.dev_attr.attr,
960 &sensor_dev_attr_pwm3_freq.dev_attr.attr,
961 &sensor_dev_attr_pwm3_enable.dev_attr.attr,
962 &sensor_dev_attr_pwm3_auto_channel_temp.dev_attr.attr,
963 &sensor_dev_attr_pwm3_auto_point1_pwm.dev_attr.attr,
964 &sensor_dev_attr_pwm3_auto_point2_pwm.dev_attr.attr,
965 NULL,
966};
967
968struct attribute_group adt7475_attr_group = { .attrs = adt7475_attrs };
969
970static int adt7475_detect(struct i2c_client *client, int kind,
971 struct i2c_board_info *info)
972{
973 struct i2c_adapter *adapter = client->adapter;
974
975 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
976 return -ENODEV;
977
978 if (kind <= 0) {
979 if (adt7475_read(REG_VENDID) != 0x41 ||
980 adt7475_read(REG_DEVID) != 0x75) {
981 dev_err(&adapter->dev,
982 "Couldn't detect a adt7475 part at 0x%02x\n",
983 (unsigned int)client->addr);
984 return -ENODEV;
985 }
986 }
987
988 strlcpy(info->type, adt7475_id[0].name, I2C_NAME_SIZE);
989
990 return 0;
991}
992
993static int adt7475_probe(struct i2c_client *client,
994 const struct i2c_device_id *id)
995{
996 struct adt7475_data *data;
997 int i, ret = 0;
998
999 data = kzalloc(sizeof(*data), GFP_KERNEL);
1000 if (data == NULL)
1001 return -ENOMEM;
1002
1003 mutex_init(&data->lock);
1004 i2c_set_clientdata(client, data);
1005
1006 /* Call adt7475_read_pwm for all pwm's as this will reprogram any
1007 pwm's which are disabled to manual mode with 0% duty cycle */
1008 for (i = 0; i < ADT7475_PWM_COUNT; i++)
1009 adt7475_read_pwm(client, i);
1010
1011 ret = sysfs_create_group(&client->dev.kobj, &adt7475_attr_group);
1012 if (ret)
1013 goto efree;
1014
1015 data->hwmon_dev = hwmon_device_register(&client->dev);
1016 if (IS_ERR(data->hwmon_dev)) {
1017 ret = PTR_ERR(data->hwmon_dev);
1018 goto eremove;
1019 }
1020
1021 return 0;
1022
1023eremove:
1024 sysfs_remove_group(&client->dev.kobj, &adt7475_attr_group);
1025efree:
1026 kfree(data);
1027 return ret;
1028}
1029
1030static int adt7475_remove(struct i2c_client *client)
1031{
1032 struct adt7475_data *data = i2c_get_clientdata(client);
1033
1034 hwmon_device_unregister(data->hwmon_dev);
1035 sysfs_remove_group(&client->dev.kobj, &adt7475_attr_group);
1036 kfree(data);
1037
1038 return 0;
1039}
1040
1041static struct i2c_driver adt7475_driver = {
1042 .class = I2C_CLASS_HWMON,
1043 .driver = {
1044 .name = "adt7475",
1045 },
1046 .probe = adt7475_probe,
1047 .remove = adt7475_remove,
1048 .id_table = adt7475_id,
1049 .detect = adt7475_detect,
1050 .address_data = &addr_data,
1051};
1052
1053static void adt7475_read_hystersis(struct i2c_client *client)
1054{
1055 struct adt7475_data *data = i2c_get_clientdata(client);
1056
1057 data->temp[HYSTERSIS][0] = (u16) adt7475_read(REG_REMOTE1_HYSTERSIS);
1058 data->temp[HYSTERSIS][1] = data->temp[HYSTERSIS][0];
1059 data->temp[HYSTERSIS][2] = (u16) adt7475_read(REG_REMOTE2_HYSTERSIS);
1060}
1061
1062static void adt7475_read_pwm(struct i2c_client *client, int index)
1063{
1064 struct adt7475_data *data = i2c_get_clientdata(client);
1065 unsigned int v;
1066
1067 data->pwm[CONTROL][index] = adt7475_read(PWM_CONFIG_REG(index));
1068
1069 /* Figure out the internal value for pwmctrl and pwmchan
1070 based on the current settings */
1071 v = (data->pwm[CONTROL][index] >> 5) & 7;
1072
1073 if (v == 3)
1074 data->pwmctl[index] = 0;
1075 else if (v == 7)
1076 data->pwmctl[index] = 1;
1077 else if (v == 4) {
1078 /* The fan is disabled - we don't want to
1079 support that, so change to manual mode and
1080 set the duty cycle to 0 instead
1081 */
1082 data->pwm[INPUT][index] = 0;
1083 data->pwm[CONTROL][index] &= ~0xE0;
1084 data->pwm[CONTROL][index] |= (7 << 5);
1085
1086 i2c_smbus_write_byte_data(client, PWM_CONFIG_REG(index),
1087 data->pwm[INPUT][index]);
1088
1089 i2c_smbus_write_byte_data(client, PWM_CONFIG_REG(index),
1090 data->pwm[CONTROL][index]);
1091
1092 data->pwmctl[index] = 1;
1093 } else {
1094 data->pwmctl[index] = 2;
1095
1096 switch (v) {
1097 case 0:
1098 data->pwmchan[index] = 1;
1099 break;
1100 case 1:
1101 data->pwmchan[index] = 2;
1102 break;
1103 case 2:
1104 data->pwmchan[index] = 4;
1105 break;
1106 case 5:
1107 data->pwmchan[index] = 6;
1108 break;
1109 case 6:
1110 data->pwmchan[index] = 7;
1111 break;
1112 }
1113 }
1114}
1115
1116static struct adt7475_data *adt7475_update_device(struct device *dev)
1117{
1118 struct i2c_client *client = to_i2c_client(dev);
1119 struct adt7475_data *data = i2c_get_clientdata(client);
1120 u8 ext;
1121 int i;
1122
1123 mutex_lock(&data->lock);
1124
1125 /* Measurement values update every 2 seconds */
1126 if (time_after(jiffies, data->measure_updated + HZ * 2) ||
1127 !data->valid) {
1128 data->alarms = adt7475_read(REG_STATUS2) << 8;
1129 data->alarms |= adt7475_read(REG_STATUS1);
1130
1131 ext = adt7475_read(REG_EXTEND1);
1132 for (i = 0; i < ADT7475_VOLTAGE_COUNT; i++)
1133 data->voltage[INPUT][i] =
1134 (adt7475_read(VOLTAGE_REG(i)) << 2) |
1135 ((ext >> ((i + 1) * 2)) & 3);
1136
1137 ext = adt7475_read(REG_EXTEND2);
1138 for (i = 0; i < ADT7475_TEMP_COUNT; i++)
1139 data->temp[INPUT][i] =
1140 (adt7475_read(TEMP_REG(i)) << 2) |
1141 ((ext >> ((i + 1) * 2)) & 3);
1142
1143 for (i = 0; i < ADT7475_TACH_COUNT; i++)
1144 data->tach[INPUT][i] =
1145 adt7475_read_word(client, TACH_REG(i));
1146
1147 /* Updated by hw when in auto mode */
1148 for (i = 0; i < ADT7475_PWM_COUNT; i++)
1149 data->pwm[INPUT][i] = adt7475_read(PWM_REG(i));
1150
1151 data->measure_updated = jiffies;
1152 }
1153
1154 /* Limits and settings, should never change update every 60 seconds */
1155 if (time_after(jiffies, data->limits_updated + HZ * 2) ||
1156 !data->valid) {
1157 data->config5 = adt7475_read(REG_CONFIG5);
1158
1159 for (i = 0; i < ADT7475_VOLTAGE_COUNT; i++) {
1160 /* Adjust values so they match the input precision */
1161 data->voltage[MIN][i] =
1162 adt7475_read(VOLTAGE_MIN_REG(i)) << 2;
1163 data->voltage[MAX][i] =
1164 adt7475_read(VOLTAGE_MAX_REG(i)) << 2;
1165 }
1166
1167 for (i = 0; i < ADT7475_TEMP_COUNT; i++) {
1168 /* Adjust values so they match the input precision */
1169 data->temp[MIN][i] =
1170 adt7475_read(TEMP_MIN_REG(i)) << 2;
1171 data->temp[MAX][i] =
1172 adt7475_read(TEMP_MAX_REG(i)) << 2;
1173 data->temp[AUTOMIN][i] =
1174 adt7475_read(TEMP_TMIN_REG(i)) << 2;
1175 data->temp[THERM][i] =
1176 adt7475_read(TEMP_THERM_REG(i)) << 2;
1177 data->temp[OFFSET][i] =
1178 adt7475_read(TEMP_OFFSET_REG(i));
1179 }
1180 adt7475_read_hystersis(client);
1181
1182 for (i = 0; i < ADT7475_TACH_COUNT; i++)
1183 data->tach[MIN][i] =
1184 adt7475_read_word(client, TACH_MIN_REG(i));
1185
1186 for (i = 0; i < ADT7475_PWM_COUNT; i++) {
1187 data->pwm[MAX][i] = adt7475_read(PWM_MAX_REG(i));
1188 data->pwm[MIN][i] = adt7475_read(PWM_MIN_REG(i));
1189 /* Set the channel and control information */
1190 adt7475_read_pwm(client, i);
1191 }
1192
1193 data->range[0] = adt7475_read(TEMP_TRANGE_REG(0));
1194 data->range[1] = adt7475_read(TEMP_TRANGE_REG(1));
1195 data->range[2] = adt7475_read(TEMP_TRANGE_REG(2));
1196
1197 data->limits_updated = jiffies;
1198 data->valid = 1;
1199 }
1200
1201 mutex_unlock(&data->lock);
1202
1203 return data;
1204}
1205
1206static int __init sensors_adt7475_init(void)
1207{
1208 return i2c_add_driver(&adt7475_driver);
1209}
1210
1211static void __exit sensors_adt7475_exit(void)
1212{
1213 i2c_del_driver(&adt7475_driver);
1214}
1215
1216MODULE_AUTHOR("Advanced Micro Devices, Inc");
1217MODULE_DESCRIPTION("adt7475 driver");
1218MODULE_LICENSE("GPL");
1219
1220module_init(sensors_adt7475_init);
1221module_exit(sensors_adt7475_exit);
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index dca47a591baf..e30186236588 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -590,6 +590,11 @@ static ssize_t applesmc_light_show(struct device *dev,
590 } 590 }
591 591
592 ret = applesmc_read_key(LIGHT_SENSOR_LEFT_KEY, buffer, data_length); 592 ret = applesmc_read_key(LIGHT_SENSOR_LEFT_KEY, buffer, data_length);
593 /* newer macbooks report a single 10-bit bigendian value */
594 if (data_length == 10) {
595 left = be16_to_cpu(*(__be16 *)(buffer + 6)) >> 2;
596 goto out;
597 }
593 left = buffer[2]; 598 left = buffer[2];
594 if (ret) 599 if (ret)
595 goto out; 600 goto out;
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c
index 8a45a2e6ba8a..8acf82977e7b 100644
--- a/drivers/hwmon/asb100.c
+++ b/drivers/hwmon/asb100.c
@@ -53,7 +53,10 @@ static const unsigned short normal_i2c[] = { 0x2d, I2C_CLIENT_END };
53 53
54/* Insmod parameters */ 54/* Insmod parameters */
55I2C_CLIENT_INSMOD_1(asb100); 55I2C_CLIENT_INSMOD_1(asb100);
56I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " 56
57static unsigned short force_subclients[4];
58module_param_array(force_subclients, short, NULL, 0);
59MODULE_PARM_DESC(force_subclients, "List of subclient addresses: "
57 "{bus, clientaddr, subclientaddr1, subclientaddr2}"); 60 "{bus, clientaddr, subclientaddr1, subclientaddr2}");
58 61
59/* Voltage IN registers 0-6 */ 62/* Voltage IN registers 0-6 */
diff --git a/drivers/hwmon/dme1737.c b/drivers/hwmon/dme1737.c
index 27a5d397f9a1..3df202a9ad72 100644
--- a/drivers/hwmon/dme1737.c
+++ b/drivers/hwmon/dme1737.c
@@ -34,6 +34,7 @@
34#include <linux/hwmon-vid.h> 34#include <linux/hwmon-vid.h>
35#include <linux/err.h> 35#include <linux/err.h>
36#include <linux/mutex.h> 36#include <linux/mutex.h>
37#include <linux/acpi.h>
37#include <asm/io.h> 38#include <asm/io.h>
38 39
39/* ISA device, if found */ 40/* ISA device, if found */
@@ -2361,6 +2362,10 @@ static int __init dme1737_isa_device_add(unsigned short addr)
2361 }; 2362 };
2362 int err; 2363 int err;
2363 2364
2365 err = acpi_check_resource_conflict(&res);
2366 if (err)
2367 goto exit;
2368
2364 if (!(pdev = platform_device_alloc("dme1737", addr))) { 2369 if (!(pdev = platform_device_alloc("dme1737", addr))) {
2365 printk(KERN_ERR "dme1737: Failed to allocate device.\n"); 2370 printk(KERN_ERR "dme1737: Failed to allocate device.\n");
2366 err = -ENOMEM; 2371 err = -ENOMEM;
diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c
index 7a14a2dbb752..899876579253 100644
--- a/drivers/hwmon/f71805f.c
+++ b/drivers/hwmon/f71805f.c
@@ -39,6 +39,7 @@
39#include <linux/mutex.h> 39#include <linux/mutex.h>
40#include <linux/sysfs.h> 40#include <linux/sysfs.h>
41#include <linux/ioport.h> 41#include <linux/ioport.h>
42#include <linux/acpi.h>
42#include <asm/io.h> 43#include <asm/io.h>
43 44
44static unsigned short force_id; 45static unsigned short force_id;
@@ -1455,6 +1456,10 @@ static int __init f71805f_device_add(unsigned short address,
1455 } 1456 }
1456 1457
1457 res.name = pdev->name; 1458 res.name = pdev->name;
1459 err = acpi_check_resource_conflict(&res);
1460 if (err)
1461 goto exit_device_put;
1462
1458 err = platform_device_add_resources(pdev, &res, 1); 1463 err = platform_device_add_resources(pdev, &res, 1);
1459 if (err) { 1464 if (err) {
1460 printk(KERN_ERR DRVNAME ": Device resource addition failed " 1465 printk(KERN_ERR DRVNAME ": Device resource addition failed "
diff --git a/drivers/hwmon/f71882fg.c b/drivers/hwmon/f71882fg.c
index 67067e9a323e..609cafff86bc 100644
--- a/drivers/hwmon/f71882fg.c
+++ b/drivers/hwmon/f71882fg.c
@@ -1,6 +1,6 @@
1/*************************************************************************** 1/***************************************************************************
2 * Copyright (C) 2006 by Hans Edgington <hans@edgington.nl> * 2 * Copyright (C) 2006 by Hans Edgington <hans@edgington.nl> *
3 * Copyright (C) 2007 by Hans de Goede <j.w.r.degoede@hhs.nl> * 3 * Copyright (C) 2007,2008 by Hans de Goede <hdegoede@redhat.com> *
4 * * 4 * *
5 * This program is free software; you can redistribute it and/or modify * 5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by * 6 * it under the terms of the GNU General Public License as published by *
@@ -27,11 +27,12 @@
27#include <linux/hwmon-sysfs.h> 27#include <linux/hwmon-sysfs.h>
28#include <linux/err.h> 28#include <linux/err.h>
29#include <linux/mutex.h> 29#include <linux/mutex.h>
30#include <asm/io.h> 30#include <linux/io.h>
31#include <linux/acpi.h>
31 32
32#define DRVNAME "f71882fg" 33#define DRVNAME "f71882fg"
33 34
34#define SIO_F71882FG_LD_HWM 0x04 /* Hardware monitor logical device*/ 35#define SIO_F71882FG_LD_HWM 0x04 /* Hardware monitor logical device */
35#define SIO_UNLOCK_KEY 0x87 /* Key to enable Super-I/O */ 36#define SIO_UNLOCK_KEY 0x87 /* Key to enable Super-I/O */
36#define SIO_LOCK_KEY 0xAA /* Key to diasble Super-I/O */ 37#define SIO_LOCK_KEY 0xAA /* Key to diasble Super-I/O */
37 38
@@ -43,7 +44,9 @@
43#define SIO_REG_ADDR 0x60 /* Logical device address (2 bytes) */ 44#define SIO_REG_ADDR 0x60 /* Logical device address (2 bytes) */
44 45
45#define SIO_FINTEK_ID 0x1934 /* Manufacturers ID */ 46#define SIO_FINTEK_ID 0x1934 /* Manufacturers ID */
47#define SIO_F71862_ID 0x0601 /* Chipset ID */
46#define SIO_F71882_ID 0x0541 /* Chipset ID */ 48#define SIO_F71882_ID 0x0541 /* Chipset ID */
49#define SIO_F8000_ID 0x0581 /* Chipset ID */
47 50
48#define REGION_LENGTH 8 51#define REGION_LENGTH 8
49#define ADDR_REG_OFFSET 5 52#define ADDR_REG_OFFSET 5
@@ -51,25 +54,36 @@
51 54
52#define F71882FG_REG_PECI 0x0A 55#define F71882FG_REG_PECI 0x0A
53 56
54#define F71882FG_REG_IN_STATUS 0x12 57#define F71882FG_REG_IN_STATUS 0x12 /* f71882fg only */
55#define F71882FG_REG_IN_BEEP 0x13 58#define F71882FG_REG_IN_BEEP 0x13 /* f71882fg only */
56#define F71882FG_REG_IN(nr) (0x20 + (nr)) 59#define F71882FG_REG_IN(nr) (0x20 + (nr))
57#define F71882FG_REG_IN1_HIGH 0x32 60#define F71882FG_REG_IN1_HIGH 0x32 /* f71882fg only */
58 61
59#define F71882FG_REG_FAN(nr) (0xA0 + (16 * (nr))) 62#define F71882FG_REG_FAN(nr) (0xA0 + (16 * (nr)))
63#define F71882FG_REG_FAN_TARGET(nr) (0xA2 + (16 * (nr)))
64#define F71882FG_REG_FAN_FULL_SPEED(nr) (0xA4 + (16 * (nr)))
60#define F71882FG_REG_FAN_STATUS 0x92 65#define F71882FG_REG_FAN_STATUS 0x92
61#define F71882FG_REG_FAN_BEEP 0x93 66#define F71882FG_REG_FAN_BEEP 0x93
62 67
63#define F71882FG_REG_TEMP(nr) (0x72 + 2 * (nr)) 68#define F71882FG_REG_TEMP(nr) (0x70 + 2 * (nr))
64#define F71882FG_REG_TEMP_OVT(nr) (0x82 + 2 * (nr)) 69#define F71882FG_REG_TEMP_OVT(nr) (0x80 + 2 * (nr))
65#define F71882FG_REG_TEMP_HIGH(nr) (0x83 + 2 * (nr)) 70#define F71882FG_REG_TEMP_HIGH(nr) (0x81 + 2 * (nr))
66#define F71882FG_REG_TEMP_STATUS 0x62 71#define F71882FG_REG_TEMP_STATUS 0x62
67#define F71882FG_REG_TEMP_BEEP 0x63 72#define F71882FG_REG_TEMP_BEEP 0x63
68#define F71882FG_REG_TEMP_HYST1 0x6C 73#define F71882FG_REG_TEMP_HYST(nr) (0x6C + (nr))
69#define F71882FG_REG_TEMP_HYST23 0x6D
70#define F71882FG_REG_TEMP_TYPE 0x6B 74#define F71882FG_REG_TEMP_TYPE 0x6B
71#define F71882FG_REG_TEMP_DIODE_OPEN 0x6F 75#define F71882FG_REG_TEMP_DIODE_OPEN 0x6F
72 76
77#define F71882FG_REG_PWM(nr) (0xA3 + (16 * (nr)))
78#define F71882FG_REG_PWM_TYPE 0x94
79#define F71882FG_REG_PWM_ENABLE 0x96
80
81#define F71882FG_REG_FAN_HYST(nr) (0x98 + (nr))
82
83#define F71882FG_REG_POINT_PWM(pwm, point) (0xAA + (point) + (16 * (pwm)))
84#define F71882FG_REG_POINT_TEMP(pwm, point) (0xA6 + (point) + (16 * (pwm)))
85#define F71882FG_REG_POINT_MAPPING(nr) (0xAF + 16 * (nr))
86
73#define F71882FG_REG_START 0x01 87#define F71882FG_REG_START 0x01
74 88
75#define FAN_MIN_DETECT 366 /* Lowest detectable fanspeed */ 89#define FAN_MIN_DETECT 366 /* Lowest detectable fanspeed */
@@ -78,7 +92,15 @@ static unsigned short force_id;
78module_param(force_id, ushort, 0); 92module_param(force_id, ushort, 0);
79MODULE_PARM_DESC(force_id, "Override the detected device ID"); 93MODULE_PARM_DESC(force_id, "Override the detected device ID");
80 94
81static struct platform_device *f71882fg_pdev = NULL; 95enum chips { f71862fg, f71882fg, f8000 };
96
97static const char *f71882fg_names[] = {
98 "f71862fg",
99 "f71882fg",
100 "f8000",
101};
102
103static struct platform_device *f71882fg_pdev;
82 104
83/* Super-I/O Function prototypes */ 105/* Super-I/O Function prototypes */
84static inline int superio_inb(int base, int reg); 106static inline int superio_inb(int base, int reg);
@@ -87,8 +109,13 @@ static inline void superio_enter(int base);
87static inline void superio_select(int base, int ld); 109static inline void superio_select(int base, int ld);
88static inline void superio_exit(int base); 110static inline void superio_exit(int base);
89 111
112struct f71882fg_sio_data {
113 enum chips type;
114};
115
90struct f71882fg_data { 116struct f71882fg_data {
91 unsigned short addr; 117 unsigned short addr;
118 enum chips type;
92 struct device *hwmon_dev; 119 struct device *hwmon_dev;
93 120
94 struct mutex update_lock; 121 struct mutex update_lock;
@@ -102,19 +129,30 @@ struct f71882fg_data {
102 u8 in_status; 129 u8 in_status;
103 u8 in_beep; 130 u8 in_beep;
104 u16 fan[4]; 131 u16 fan[4];
132 u16 fan_target[4];
133 u16 fan_full_speed[4];
105 u8 fan_status; 134 u8 fan_status;
106 u8 fan_beep; 135 u8 fan_beep;
107 u8 temp[3]; 136 /* Note: all models have only 3 temperature channels, but on some
108 u8 temp_ovt[3]; 137 they are addressed as 0-2 and on others as 1-3, so for coding
109 u8 temp_high[3]; 138 convenience we reserve space for 4 channels */
110 u8 temp_hyst[3]; 139 u8 temp[4];
111 u8 temp_type[3]; 140 u8 temp_ovt[4];
141 u8 temp_high[4];
142 u8 temp_hyst[2]; /* 2 hysts stored per reg */
143 u8 temp_type[4];
112 u8 temp_status; 144 u8 temp_status;
113 u8 temp_beep; 145 u8 temp_beep;
114 u8 temp_diode_open; 146 u8 temp_diode_open;
147 u8 pwm[4];
148 u8 pwm_enable;
149 u8 pwm_auto_point_hyst[2];
150 u8 pwm_auto_point_mapping[4];
151 u8 pwm_auto_point_pwm[4][5];
152 u8 pwm_auto_point_temp[4][4];
115}; 153};
116 154
117/* Sysfs in*/ 155/* Sysfs in */
118static ssize_t show_in(struct device *dev, struct device_attribute *devattr, 156static ssize_t show_in(struct device *dev, struct device_attribute *devattr,
119 char *buf); 157 char *buf);
120static ssize_t show_in_max(struct device *dev, struct device_attribute 158static ssize_t show_in_max(struct device *dev, struct device_attribute
@@ -130,6 +168,10 @@ static ssize_t show_in_alarm(struct device *dev, struct device_attribute
130/* Sysfs Fan */ 168/* Sysfs Fan */
131static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, 169static ssize_t show_fan(struct device *dev, struct device_attribute *devattr,
132 char *buf); 170 char *buf);
171static ssize_t show_fan_full_speed(struct device *dev,
172 struct device_attribute *devattr, char *buf);
173static ssize_t store_fan_full_speed(struct device *dev,
174 struct device_attribute *devattr, const char *buf, size_t count);
133static ssize_t show_fan_beep(struct device *dev, struct device_attribute 175static ssize_t show_fan_beep(struct device *dev, struct device_attribute
134 *devattr, char *buf); 176 *devattr, char *buf);
135static ssize_t store_fan_beep(struct device *dev, struct device_attribute 177static ssize_t store_fan_beep(struct device *dev, struct device_attribute
@@ -163,16 +205,41 @@ static ssize_t show_temp_alarm(struct device *dev, struct device_attribute
163 *devattr, char *buf); 205 *devattr, char *buf);
164static ssize_t show_temp_fault(struct device *dev, struct device_attribute 206static ssize_t show_temp_fault(struct device *dev, struct device_attribute
165 *devattr, char *buf); 207 *devattr, char *buf);
208/* PWM and Auto point control */
209static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr,
210 char *buf);
211static ssize_t store_pwm(struct device *dev, struct device_attribute *devattr,
212 const char *buf, size_t count);
213static ssize_t show_pwm_enable(struct device *dev,
214 struct device_attribute *devattr, char *buf);
215static ssize_t store_pwm_enable(struct device *dev,
216 struct device_attribute *devattr, const char *buf, size_t count);
217static ssize_t show_pwm_interpolate(struct device *dev,
218 struct device_attribute *devattr, char *buf);
219static ssize_t store_pwm_interpolate(struct device *dev,
220 struct device_attribute *devattr, const char *buf, size_t count);
221static ssize_t show_pwm_auto_point_channel(struct device *dev,
222 struct device_attribute *devattr, char *buf);
223static ssize_t store_pwm_auto_point_channel(struct device *dev,
224 struct device_attribute *devattr, const char *buf, size_t count);
225static ssize_t show_pwm_auto_point_temp_hyst(struct device *dev,
226 struct device_attribute *devattr, char *buf);
227static ssize_t store_pwm_auto_point_temp_hyst(struct device *dev,
228 struct device_attribute *devattr, const char *buf, size_t count);
229static ssize_t show_pwm_auto_point_pwm(struct device *dev,
230 struct device_attribute *devattr, char *buf);
231static ssize_t store_pwm_auto_point_pwm(struct device *dev,
232 struct device_attribute *devattr, const char *buf, size_t count);
233static ssize_t show_pwm_auto_point_temp(struct device *dev,
234 struct device_attribute *devattr, char *buf);
235static ssize_t store_pwm_auto_point_temp(struct device *dev,
236 struct device_attribute *devattr, const char *buf, size_t count);
166/* Sysfs misc */ 237/* Sysfs misc */
167static ssize_t show_name(struct device *dev, struct device_attribute *devattr, 238static ssize_t show_name(struct device *dev, struct device_attribute *devattr,
168 char *buf); 239 char *buf);
169 240
170static int __devinit f71882fg_probe(struct platform_device * pdev); 241static int __devinit f71882fg_probe(struct platform_device * pdev);
171static int __devexit f71882fg_remove(struct platform_device *pdev); 242static int f71882fg_remove(struct platform_device *pdev);
172static int __init f71882fg_init(void);
173static int __init f71882fg_find(int sioaddr, unsigned short *address);
174static int __init f71882fg_device_add(unsigned short address);
175static void __exit f71882fg_exit(void);
176 243
177static struct platform_driver f71882fg_driver = { 244static struct platform_driver f71882fg_driver = {
178 .driver = { 245 .driver = {
@@ -183,86 +250,531 @@ static struct platform_driver f71882fg_driver = {
183 .remove = __devexit_p(f71882fg_remove), 250 .remove = __devexit_p(f71882fg_remove),
184}; 251};
185 252
186static struct device_attribute f71882fg_dev_attr[] = 253static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
187{ 254
188 __ATTR( name, S_IRUGO, show_name, NULL ), 255/* Temp and in attr common to both the f71862fg and f71882fg */
256static struct sensor_device_attribute_2 f718x2fg_in_temp_attr[] = {
257 SENSOR_ATTR_2(in0_input, S_IRUGO, show_in, NULL, 0, 0),
258 SENSOR_ATTR_2(in1_input, S_IRUGO, show_in, NULL, 0, 1),
259 SENSOR_ATTR_2(in2_input, S_IRUGO, show_in, NULL, 0, 2),
260 SENSOR_ATTR_2(in3_input, S_IRUGO, show_in, NULL, 0, 3),
261 SENSOR_ATTR_2(in4_input, S_IRUGO, show_in, NULL, 0, 4),
262 SENSOR_ATTR_2(in5_input, S_IRUGO, show_in, NULL, 0, 5),
263 SENSOR_ATTR_2(in6_input, S_IRUGO, show_in, NULL, 0, 6),
264 SENSOR_ATTR_2(in7_input, S_IRUGO, show_in, NULL, 0, 7),
265 SENSOR_ATTR_2(in8_input, S_IRUGO, show_in, NULL, 0, 8),
266 SENSOR_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, 0, 1),
267 SENSOR_ATTR_2(temp1_max, S_IRUGO|S_IWUSR, show_temp_max,
268 store_temp_max, 0, 1),
269 SENSOR_ATTR_2(temp1_max_hyst, S_IRUGO|S_IWUSR, show_temp_max_hyst,
270 store_temp_max_hyst, 0, 1),
271 /* Should really be temp1_max_alarm, but older versions did not handle
272 the max and crit alarms separately and lm_sensors v2 depends on the
273 presence of temp#_alarm files. The same goes for temp2/3 _alarm. */
274 SENSOR_ATTR_2(temp1_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 1),
275 SENSOR_ATTR_2(temp1_max_beep, S_IRUGO|S_IWUSR, show_temp_beep,
276 store_temp_beep, 0, 1),
277 SENSOR_ATTR_2(temp1_crit, S_IRUGO|S_IWUSR, show_temp_crit,
278 store_temp_crit, 0, 1),
279 SENSOR_ATTR_2(temp1_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL,
280 0, 1),
281 SENSOR_ATTR_2(temp1_crit_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 5),
282 SENSOR_ATTR_2(temp1_crit_beep, S_IRUGO|S_IWUSR, show_temp_beep,
283 store_temp_beep, 0, 5),
284 SENSOR_ATTR_2(temp1_type, S_IRUGO, show_temp_type, NULL, 0, 1),
285 SENSOR_ATTR_2(temp1_fault, S_IRUGO, show_temp_fault, NULL, 0, 1),
286 SENSOR_ATTR_2(temp2_input, S_IRUGO, show_temp, NULL, 0, 2),
287 SENSOR_ATTR_2(temp2_max, S_IRUGO|S_IWUSR, show_temp_max,
288 store_temp_max, 0, 2),
289 SENSOR_ATTR_2(temp2_max_hyst, S_IRUGO|S_IWUSR, show_temp_max_hyst,
290 store_temp_max_hyst, 0, 2),
291 /* Should be temp2_max_alarm, see temp1_alarm note */
292 SENSOR_ATTR_2(temp2_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 2),
293 SENSOR_ATTR_2(temp2_max_beep, S_IRUGO|S_IWUSR, show_temp_beep,
294 store_temp_beep, 0, 2),
295 SENSOR_ATTR_2(temp2_crit, S_IRUGO|S_IWUSR, show_temp_crit,
296 store_temp_crit, 0, 2),
297 SENSOR_ATTR_2(temp2_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL,
298 0, 2),
299 SENSOR_ATTR_2(temp2_crit_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 6),
300 SENSOR_ATTR_2(temp2_crit_beep, S_IRUGO|S_IWUSR, show_temp_beep,
301 store_temp_beep, 0, 6),
302 SENSOR_ATTR_2(temp2_type, S_IRUGO, show_temp_type, NULL, 0, 2),
303 SENSOR_ATTR_2(temp2_fault, S_IRUGO, show_temp_fault, NULL, 0, 2),
304 SENSOR_ATTR_2(temp3_input, S_IRUGO, show_temp, NULL, 0, 3),
305 SENSOR_ATTR_2(temp3_max, S_IRUGO|S_IWUSR, show_temp_max,
306 store_temp_max, 0, 3),
307 SENSOR_ATTR_2(temp3_max_hyst, S_IRUGO|S_IWUSR, show_temp_max_hyst,
308 store_temp_max_hyst, 0, 3),
309 /* Should be temp3_max_alarm, see temp1_alarm note */
310 SENSOR_ATTR_2(temp3_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 3),
311 SENSOR_ATTR_2(temp3_max_beep, S_IRUGO|S_IWUSR, show_temp_beep,
312 store_temp_beep, 0, 3),
313 SENSOR_ATTR_2(temp3_crit, S_IRUGO|S_IWUSR, show_temp_crit,
314 store_temp_crit, 0, 3),
315 SENSOR_ATTR_2(temp3_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL,
316 0, 3),
317 SENSOR_ATTR_2(temp3_crit_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 7),
318 SENSOR_ATTR_2(temp3_crit_beep, S_IRUGO|S_IWUSR, show_temp_beep,
319 store_temp_beep, 0, 7),
320 SENSOR_ATTR_2(temp3_type, S_IRUGO, show_temp_type, NULL, 0, 3),
321 SENSOR_ATTR_2(temp3_fault, S_IRUGO, show_temp_fault, NULL, 0, 3),
322};
323
324/* Temp and in attr found only on the f71882fg */
325static struct sensor_device_attribute_2 f71882fg_in_temp_attr[] = {
326 SENSOR_ATTR_2(in1_max, S_IRUGO|S_IWUSR, show_in_max, store_in_max,
327 0, 1),
328 SENSOR_ATTR_2(in1_beep, S_IRUGO|S_IWUSR, show_in_beep, store_in_beep,
329 0, 1),
330 SENSOR_ATTR_2(in1_alarm, S_IRUGO, show_in_alarm, NULL, 0, 1),
331};
332
333/* Temp and in attr for the f8000
334 Note on the f8000 temp_ovt (crit) is used as max, and temp_high (max)
335 is used as hysteresis value to clear alarms
336 */
337static struct sensor_device_attribute_2 f8000_in_temp_attr[] = {
338 SENSOR_ATTR_2(in0_input, S_IRUGO, show_in, NULL, 0, 0),
339 SENSOR_ATTR_2(in1_input, S_IRUGO, show_in, NULL, 0, 1),
340 SENSOR_ATTR_2(in2_input, S_IRUGO, show_in, NULL, 0, 2),
341 SENSOR_ATTR_2(temp1_input, S_IRUGO, show_temp, NULL, 0, 0),
342 SENSOR_ATTR_2(temp1_max, S_IRUGO|S_IWUSR, show_temp_crit,
343 store_temp_crit, 0, 0),
344 SENSOR_ATTR_2(temp1_max_hyst, S_IRUGO|S_IWUSR, show_temp_max,
345 store_temp_max, 0, 0),
346 SENSOR_ATTR_2(temp1_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 4),
347 SENSOR_ATTR_2(temp2_input, S_IRUGO, show_temp, NULL, 0, 1),
348 SENSOR_ATTR_2(temp2_max, S_IRUGO|S_IWUSR, show_temp_crit,
349 store_temp_crit, 0, 1),
350 SENSOR_ATTR_2(temp2_max_hyst, S_IRUGO|S_IWUSR, show_temp_max,
351 store_temp_max, 0, 1),
352 SENSOR_ATTR_2(temp2_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 5),
353 SENSOR_ATTR_2(temp2_type, S_IRUGO, show_temp_type, NULL, 0, 1),
354 SENSOR_ATTR_2(temp3_input, S_IRUGO, show_temp, NULL, 0, 2),
355 SENSOR_ATTR_2(temp3_max, S_IRUGO|S_IWUSR, show_temp_crit,
356 store_temp_crit, 0, 2),
357 SENSOR_ATTR_2(temp3_max_hyst, S_IRUGO|S_IWUSR, show_temp_max,
358 store_temp_max, 0, 2),
359 SENSOR_ATTR_2(temp3_alarm, S_IRUGO, show_temp_alarm, NULL, 0, 6),
360};
361
362/* Fan / PWM attr common to all models */
363static struct sensor_device_attribute_2 fxxxx_fan_attr[] = {
364 SENSOR_ATTR_2(fan1_input, S_IRUGO, show_fan, NULL, 0, 0),
365 SENSOR_ATTR_2(fan1_full_speed, S_IRUGO|S_IWUSR,
366 show_fan_full_speed,
367 store_fan_full_speed, 0, 0),
368 SENSOR_ATTR_2(fan1_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 0),
369 SENSOR_ATTR_2(fan2_input, S_IRUGO, show_fan, NULL, 0, 1),
370 SENSOR_ATTR_2(fan2_full_speed, S_IRUGO|S_IWUSR,
371 show_fan_full_speed,
372 store_fan_full_speed, 0, 1),
373 SENSOR_ATTR_2(fan2_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 1),
374 SENSOR_ATTR_2(fan3_input, S_IRUGO, show_fan, NULL, 0, 2),
375 SENSOR_ATTR_2(fan3_full_speed, S_IRUGO|S_IWUSR,
376 show_fan_full_speed,
377 store_fan_full_speed, 0, 2),
378 SENSOR_ATTR_2(fan3_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 2),
379
380 SENSOR_ATTR_2(pwm1, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 0),
381 SENSOR_ATTR_2(pwm1_enable, S_IRUGO|S_IWUSR, show_pwm_enable,
382 store_pwm_enable, 0, 0),
383 SENSOR_ATTR_2(pwm1_interpolate, S_IRUGO|S_IWUSR,
384 show_pwm_interpolate, store_pwm_interpolate, 0, 0),
385 SENSOR_ATTR_2(pwm1_auto_channels_temp, S_IRUGO|S_IWUSR,
386 show_pwm_auto_point_channel,
387 store_pwm_auto_point_channel, 0, 0),
388
389 SENSOR_ATTR_2(pwm2, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 1),
390 SENSOR_ATTR_2(pwm2_enable, S_IRUGO|S_IWUSR, show_pwm_enable,
391 store_pwm_enable, 0, 1),
392 SENSOR_ATTR_2(pwm2_interpolate, S_IRUGO|S_IWUSR,
393 show_pwm_interpolate, store_pwm_interpolate, 0, 1),
394 SENSOR_ATTR_2(pwm2_auto_channels_temp, S_IRUGO|S_IWUSR,
395 show_pwm_auto_point_channel,
396 store_pwm_auto_point_channel, 0, 1),
397
398 SENSOR_ATTR_2(pwm3_interpolate, S_IRUGO|S_IWUSR,
399 show_pwm_interpolate, store_pwm_interpolate, 0, 2),
400 SENSOR_ATTR_2(pwm3_auto_channels_temp, S_IRUGO|S_IWUSR,
401 show_pwm_auto_point_channel,
402 store_pwm_auto_point_channel, 0, 2),
189}; 403};
190 404
191static struct sensor_device_attribute f71882fg_in_temp_attr[] = 405/* Fan / PWM attr for the f71862fg, less pwms and less zones per pwm than the
192{ 406 f71882fg */
193 SENSOR_ATTR(in0_input, S_IRUGO, show_in, NULL, 0), 407static struct sensor_device_attribute_2 f71862fg_fan_attr[] = {
194 SENSOR_ATTR(in1_input, S_IRUGO, show_in, NULL, 1), 408 SENSOR_ATTR_2(fan1_beep, S_IRUGO|S_IWUSR, show_fan_beep,
195 SENSOR_ATTR(in1_max, S_IRUGO|S_IWUSR, show_in_max, store_in_max, 1), 409 store_fan_beep, 0, 0),
196 SENSOR_ATTR(in1_beep, S_IRUGO|S_IWUSR, show_in_beep, store_in_beep, 1), 410 SENSOR_ATTR_2(fan2_beep, S_IRUGO|S_IWUSR, show_fan_beep,
197 SENSOR_ATTR(in1_alarm, S_IRUGO, show_in_alarm, NULL, 1), 411 store_fan_beep, 0, 1),
198 SENSOR_ATTR(in2_input, S_IRUGO, show_in, NULL, 2), 412 SENSOR_ATTR_2(fan3_beep, S_IRUGO|S_IWUSR, show_fan_beep,
199 SENSOR_ATTR(in3_input, S_IRUGO, show_in, NULL, 3), 413 store_fan_beep, 0, 2),
200 SENSOR_ATTR(in4_input, S_IRUGO, show_in, NULL, 4), 414
201 SENSOR_ATTR(in5_input, S_IRUGO, show_in, NULL, 5), 415 SENSOR_ATTR_2(pwm1_auto_point1_pwm, S_IRUGO|S_IWUSR,
202 SENSOR_ATTR(in6_input, S_IRUGO, show_in, NULL, 6), 416 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
203 SENSOR_ATTR(in7_input, S_IRUGO, show_in, NULL, 7), 417 1, 0),
204 SENSOR_ATTR(in8_input, S_IRUGO, show_in, NULL, 8), 418 SENSOR_ATTR_2(pwm1_auto_point2_pwm, S_IRUGO|S_IWUSR,
205 SENSOR_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0), 419 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
206 SENSOR_ATTR(temp1_max, S_IRUGO|S_IWUSR, show_temp_max, 420 4, 0),
207 store_temp_max, 0), 421 SENSOR_ATTR_2(pwm1_auto_point1_temp, S_IRUGO|S_IWUSR,
208 SENSOR_ATTR(temp1_max_hyst, S_IRUGO|S_IWUSR, show_temp_max_hyst, 422 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
209 store_temp_max_hyst, 0), 423 0, 0),
210 SENSOR_ATTR(temp1_crit, S_IRUGO|S_IWUSR, show_temp_crit, 424 SENSOR_ATTR_2(pwm1_auto_point2_temp, S_IRUGO|S_IWUSR,
211 store_temp_crit, 0), 425 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
212 SENSOR_ATTR(temp1_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, 0), 426 3, 0),
213 SENSOR_ATTR(temp1_type, S_IRUGO, show_temp_type, NULL, 0), 427 SENSOR_ATTR_2(pwm1_auto_point1_temp_hyst, S_IRUGO|S_IWUSR,
214 SENSOR_ATTR(temp1_beep, S_IRUGO|S_IWUSR, show_temp_beep, 428 show_pwm_auto_point_temp_hyst,
215 store_temp_beep, 0), 429 store_pwm_auto_point_temp_hyst,
216 SENSOR_ATTR(temp1_alarm, S_IRUGO, show_temp_alarm, NULL, 0), 430 0, 0),
217 SENSOR_ATTR(temp1_fault, S_IRUGO, show_temp_fault, NULL, 0), 431 SENSOR_ATTR_2(pwm1_auto_point2_temp_hyst, S_IRUGO,
218 SENSOR_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1), 432 show_pwm_auto_point_temp_hyst, NULL, 3, 0),
219 SENSOR_ATTR(temp2_max, S_IRUGO|S_IWUSR, show_temp_max, 433
220 store_temp_max, 1), 434 SENSOR_ATTR_2(pwm2_auto_point1_pwm, S_IRUGO|S_IWUSR,
221 SENSOR_ATTR(temp2_max_hyst, S_IRUGO|S_IWUSR, show_temp_max_hyst, 435 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
222 store_temp_max_hyst, 1), 436 1, 1),
223 SENSOR_ATTR(temp2_crit, S_IRUGO|S_IWUSR, show_temp_crit, 437 SENSOR_ATTR_2(pwm2_auto_point2_pwm, S_IRUGO|S_IWUSR,
224 store_temp_crit, 1), 438 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
225 SENSOR_ATTR(temp2_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, 1), 439 4, 1),
226 SENSOR_ATTR(temp2_type, S_IRUGO, show_temp_type, NULL, 1), 440 SENSOR_ATTR_2(pwm2_auto_point1_temp, S_IRUGO|S_IWUSR,
227 SENSOR_ATTR(temp2_beep, S_IRUGO|S_IWUSR, show_temp_beep, 441 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
228 store_temp_beep, 1), 442 0, 1),
229 SENSOR_ATTR(temp2_alarm, S_IRUGO, show_temp_alarm, NULL, 1), 443 SENSOR_ATTR_2(pwm2_auto_point2_temp, S_IRUGO|S_IWUSR,
230 SENSOR_ATTR(temp2_fault, S_IRUGO, show_temp_fault, NULL, 1), 444 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
231 SENSOR_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2), 445 3, 1),
232 SENSOR_ATTR(temp3_max, S_IRUGO|S_IWUSR, show_temp_max, 446 SENSOR_ATTR_2(pwm2_auto_point1_temp_hyst, S_IRUGO|S_IWUSR,
233 store_temp_max, 2), 447 show_pwm_auto_point_temp_hyst,
234 SENSOR_ATTR(temp3_max_hyst, S_IRUGO|S_IWUSR, show_temp_max_hyst, 448 store_pwm_auto_point_temp_hyst,
235 store_temp_max_hyst, 2), 449 0, 1),
236 SENSOR_ATTR(temp3_crit, S_IRUGO|S_IWUSR, show_temp_crit, 450 SENSOR_ATTR_2(pwm2_auto_point2_temp_hyst, S_IRUGO,
237 store_temp_crit, 2), 451 show_pwm_auto_point_temp_hyst, NULL, 3, 1),
238 SENSOR_ATTR(temp3_crit_hyst, S_IRUGO, show_temp_crit_hyst, NULL, 2), 452
239 SENSOR_ATTR(temp3_type, S_IRUGO, show_temp_type, NULL, 2), 453 SENSOR_ATTR_2(pwm3, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 2),
240 SENSOR_ATTR(temp3_beep, S_IRUGO|S_IWUSR, show_temp_beep, 454 SENSOR_ATTR_2(pwm3_enable, S_IRUGO|S_IWUSR, show_pwm_enable,
241 store_temp_beep, 2), 455 store_pwm_enable, 0, 2),
242 SENSOR_ATTR(temp3_alarm, S_IRUGO, show_temp_alarm, NULL, 2), 456 SENSOR_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO|S_IWUSR,
243 SENSOR_ATTR(temp3_fault, S_IRUGO, show_temp_fault, NULL, 2) 457 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
458 1, 2),
459 SENSOR_ATTR_2(pwm3_auto_point2_pwm, S_IRUGO|S_IWUSR,
460 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
461 4, 2),
462 SENSOR_ATTR_2(pwm3_auto_point1_temp, S_IRUGO|S_IWUSR,
463 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
464 0, 2),
465 SENSOR_ATTR_2(pwm3_auto_point2_temp, S_IRUGO|S_IWUSR,
466 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
467 3, 2),
468 SENSOR_ATTR_2(pwm3_auto_point1_temp_hyst, S_IRUGO|S_IWUSR,
469 show_pwm_auto_point_temp_hyst,
470 store_pwm_auto_point_temp_hyst,
471 0, 2),
472 SENSOR_ATTR_2(pwm3_auto_point2_temp_hyst, S_IRUGO,
473 show_pwm_auto_point_temp_hyst, NULL, 3, 2),
244}; 474};
245 475
246static struct sensor_device_attribute f71882fg_fan_attr[] = 476/* Fan / PWM attr for the f71882fg */
247{ 477static struct sensor_device_attribute_2 f71882fg_fan_attr[] = {
248 SENSOR_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0), 478 SENSOR_ATTR_2(fan1_beep, S_IRUGO|S_IWUSR, show_fan_beep,
249 SENSOR_ATTR(fan1_beep, S_IRUGO|S_IWUSR, show_fan_beep, 479 store_fan_beep, 0, 0),
250 store_fan_beep, 0), 480 SENSOR_ATTR_2(fan2_beep, S_IRUGO|S_IWUSR, show_fan_beep,
251 SENSOR_ATTR(fan1_alarm, S_IRUGO, show_fan_alarm, NULL, 0), 481 store_fan_beep, 0, 1),
252 SENSOR_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1), 482 SENSOR_ATTR_2(fan3_beep, S_IRUGO|S_IWUSR, show_fan_beep,
253 SENSOR_ATTR(fan2_beep, S_IRUGO|S_IWUSR, show_fan_beep, 483 store_fan_beep, 0, 2),
254 store_fan_beep, 1), 484 SENSOR_ATTR_2(fan4_input, S_IRUGO, show_fan, NULL, 0, 3),
255 SENSOR_ATTR(fan2_alarm, S_IRUGO, show_fan_alarm, NULL, 1), 485 SENSOR_ATTR_2(fan4_full_speed, S_IRUGO|S_IWUSR,
256 SENSOR_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2), 486 show_fan_full_speed,
257 SENSOR_ATTR(fan3_beep, S_IRUGO|S_IWUSR, show_fan_beep, 487 store_fan_full_speed, 0, 3),
258 store_fan_beep, 2), 488 SENSOR_ATTR_2(fan4_beep, S_IRUGO|S_IWUSR, show_fan_beep,
259 SENSOR_ATTR(fan3_alarm, S_IRUGO, show_fan_alarm, NULL, 2), 489 store_fan_beep, 0, 3),
260 SENSOR_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 3), 490 SENSOR_ATTR_2(fan4_alarm, S_IRUGO, show_fan_alarm, NULL, 0, 3),
261 SENSOR_ATTR(fan4_beep, S_IRUGO|S_IWUSR, show_fan_beep, 491
262 store_fan_beep, 3), 492 SENSOR_ATTR_2(pwm1_auto_point1_pwm, S_IRUGO|S_IWUSR,
263 SENSOR_ATTR(fan4_alarm, S_IRUGO, show_fan_alarm, NULL, 3) 493 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
494 0, 0),
495 SENSOR_ATTR_2(pwm1_auto_point2_pwm, S_IRUGO|S_IWUSR,
496 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
497 1, 0),
498 SENSOR_ATTR_2(pwm1_auto_point3_pwm, S_IRUGO|S_IWUSR,
499 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
500 2, 0),
501 SENSOR_ATTR_2(pwm1_auto_point4_pwm, S_IRUGO|S_IWUSR,
502 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
503 3, 0),
504 SENSOR_ATTR_2(pwm1_auto_point5_pwm, S_IRUGO|S_IWUSR,
505 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
506 4, 0),
507 SENSOR_ATTR_2(pwm1_auto_point1_temp, S_IRUGO|S_IWUSR,
508 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
509 0, 0),
510 SENSOR_ATTR_2(pwm1_auto_point2_temp, S_IRUGO|S_IWUSR,
511 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
512 1, 0),
513 SENSOR_ATTR_2(pwm1_auto_point3_temp, S_IRUGO|S_IWUSR,
514 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
515 2, 0),
516 SENSOR_ATTR_2(pwm1_auto_point4_temp, S_IRUGO|S_IWUSR,
517 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
518 3, 0),
519 SENSOR_ATTR_2(pwm1_auto_point1_temp_hyst, S_IRUGO|S_IWUSR,
520 show_pwm_auto_point_temp_hyst,
521 store_pwm_auto_point_temp_hyst,
522 0, 0),
523 SENSOR_ATTR_2(pwm1_auto_point2_temp_hyst, S_IRUGO,
524 show_pwm_auto_point_temp_hyst, NULL, 1, 0),
525 SENSOR_ATTR_2(pwm1_auto_point3_temp_hyst, S_IRUGO,
526 show_pwm_auto_point_temp_hyst, NULL, 2, 0),
527 SENSOR_ATTR_2(pwm1_auto_point4_temp_hyst, S_IRUGO,
528 show_pwm_auto_point_temp_hyst, NULL, 3, 0),
529
530 SENSOR_ATTR_2(pwm2_auto_point1_pwm, S_IRUGO|S_IWUSR,
531 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
532 0, 1),
533 SENSOR_ATTR_2(pwm2_auto_point2_pwm, S_IRUGO|S_IWUSR,
534 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
535 1, 1),
536 SENSOR_ATTR_2(pwm2_auto_point3_pwm, S_IRUGO|S_IWUSR,
537 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
538 2, 1),
539 SENSOR_ATTR_2(pwm2_auto_point4_pwm, S_IRUGO|S_IWUSR,
540 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
541 3, 1),
542 SENSOR_ATTR_2(pwm2_auto_point5_pwm, S_IRUGO|S_IWUSR,
543 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
544 4, 1),
545 SENSOR_ATTR_2(pwm2_auto_point1_temp, S_IRUGO|S_IWUSR,
546 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
547 0, 1),
548 SENSOR_ATTR_2(pwm2_auto_point2_temp, S_IRUGO|S_IWUSR,
549 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
550 1, 1),
551 SENSOR_ATTR_2(pwm2_auto_point3_temp, S_IRUGO|S_IWUSR,
552 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
553 2, 1),
554 SENSOR_ATTR_2(pwm2_auto_point4_temp, S_IRUGO|S_IWUSR,
555 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
556 3, 1),
557 SENSOR_ATTR_2(pwm2_auto_point1_temp_hyst, S_IRUGO|S_IWUSR,
558 show_pwm_auto_point_temp_hyst,
559 store_pwm_auto_point_temp_hyst,
560 0, 1),
561 SENSOR_ATTR_2(pwm2_auto_point2_temp_hyst, S_IRUGO,
562 show_pwm_auto_point_temp_hyst, NULL, 1, 1),
563 SENSOR_ATTR_2(pwm2_auto_point3_temp_hyst, S_IRUGO,
564 show_pwm_auto_point_temp_hyst, NULL, 2, 1),
565 SENSOR_ATTR_2(pwm2_auto_point4_temp_hyst, S_IRUGO,
566 show_pwm_auto_point_temp_hyst, NULL, 3, 1),
567
568 SENSOR_ATTR_2(pwm3, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 2),
569 SENSOR_ATTR_2(pwm3_enable, S_IRUGO|S_IWUSR, show_pwm_enable,
570 store_pwm_enable, 0, 2),
571 SENSOR_ATTR_2(pwm3_auto_point1_pwm, S_IRUGO|S_IWUSR,
572 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
573 0, 2),
574 SENSOR_ATTR_2(pwm3_auto_point2_pwm, S_IRUGO|S_IWUSR,
575 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
576 1, 2),
577 SENSOR_ATTR_2(pwm3_auto_point3_pwm, S_IRUGO|S_IWUSR,
578 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
579 2, 2),
580 SENSOR_ATTR_2(pwm3_auto_point4_pwm, S_IRUGO|S_IWUSR,
581 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
582 3, 2),
583 SENSOR_ATTR_2(pwm3_auto_point5_pwm, S_IRUGO|S_IWUSR,
584 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
585 4, 2),
586 SENSOR_ATTR_2(pwm3_auto_point1_temp, S_IRUGO|S_IWUSR,
587 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
588 0, 2),
589 SENSOR_ATTR_2(pwm3_auto_point2_temp, S_IRUGO|S_IWUSR,
590 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
591 1, 2),
592 SENSOR_ATTR_2(pwm3_auto_point3_temp, S_IRUGO|S_IWUSR,
593 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
594 2, 2),
595 SENSOR_ATTR_2(pwm3_auto_point4_temp, S_IRUGO|S_IWUSR,
596 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
597 3, 2),
598 SENSOR_ATTR_2(pwm3_auto_point1_temp_hyst, S_IRUGO|S_IWUSR,
599 show_pwm_auto_point_temp_hyst,
600 store_pwm_auto_point_temp_hyst,
601 0, 2),
602 SENSOR_ATTR_2(pwm3_auto_point2_temp_hyst, S_IRUGO,
603 show_pwm_auto_point_temp_hyst, NULL, 1, 2),
604 SENSOR_ATTR_2(pwm3_auto_point3_temp_hyst, S_IRUGO,
605 show_pwm_auto_point_temp_hyst, NULL, 2, 2),
606 SENSOR_ATTR_2(pwm3_auto_point4_temp_hyst, S_IRUGO,
607 show_pwm_auto_point_temp_hyst, NULL, 3, 2),
608
609 SENSOR_ATTR_2(pwm4, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0, 3),
610 SENSOR_ATTR_2(pwm4_enable, S_IRUGO|S_IWUSR, show_pwm_enable,
611 store_pwm_enable, 0, 3),
612 SENSOR_ATTR_2(pwm4_interpolate, S_IRUGO|S_IWUSR,
613 show_pwm_interpolate, store_pwm_interpolate, 0, 3),
614 SENSOR_ATTR_2(pwm4_auto_channels_temp, S_IRUGO|S_IWUSR,
615 show_pwm_auto_point_channel,
616 store_pwm_auto_point_channel, 0, 3),
617 SENSOR_ATTR_2(pwm4_auto_point1_pwm, S_IRUGO|S_IWUSR,
618 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
619 0, 3),
620 SENSOR_ATTR_2(pwm4_auto_point2_pwm, S_IRUGO|S_IWUSR,
621 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
622 1, 3),
623 SENSOR_ATTR_2(pwm4_auto_point3_pwm, S_IRUGO|S_IWUSR,
624 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
625 2, 3),
626 SENSOR_ATTR_2(pwm4_auto_point4_pwm, S_IRUGO|S_IWUSR,
627 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
628 3, 3),
629 SENSOR_ATTR_2(pwm4_auto_point5_pwm, S_IRUGO|S_IWUSR,
630 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
631 4, 3),
632 SENSOR_ATTR_2(pwm4_auto_point1_temp, S_IRUGO|S_IWUSR,
633 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
634 0, 3),
635 SENSOR_ATTR_2(pwm4_auto_point2_temp, S_IRUGO|S_IWUSR,
636 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
637 1, 3),
638 SENSOR_ATTR_2(pwm4_auto_point3_temp, S_IRUGO|S_IWUSR,
639 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
640 2, 3),
641 SENSOR_ATTR_2(pwm4_auto_point4_temp, S_IRUGO|S_IWUSR,
642 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
643 3, 3),
644 SENSOR_ATTR_2(pwm4_auto_point1_temp_hyst, S_IRUGO|S_IWUSR,
645 show_pwm_auto_point_temp_hyst,
646 store_pwm_auto_point_temp_hyst,
647 0, 3),
648 SENSOR_ATTR_2(pwm4_auto_point2_temp_hyst, S_IRUGO,
649 show_pwm_auto_point_temp_hyst, NULL, 1, 3),
650 SENSOR_ATTR_2(pwm4_auto_point3_temp_hyst, S_IRUGO,
651 show_pwm_auto_point_temp_hyst, NULL, 2, 3),
652 SENSOR_ATTR_2(pwm4_auto_point4_temp_hyst, S_IRUGO,
653 show_pwm_auto_point_temp_hyst, NULL, 3, 3),
264}; 654};
265 655
656/* Fan / PWM attr for the f8000, zones mapped to temp instead of to pwm!
657 Also the register block at offset A0 maps to TEMP1 (so our temp2, as the
658 F8000 starts counting temps at 0), B0 maps the TEMP2 and C0 maps to TEMP0 */
659static struct sensor_device_attribute_2 f8000_fan_attr[] = {
660 SENSOR_ATTR_2(fan4_input, S_IRUGO, show_fan, NULL, 0, 3),
661
662 SENSOR_ATTR_2(pwm3, S_IRUGO, show_pwm, NULL, 0, 2),
663
664 SENSOR_ATTR_2(temp1_auto_point1_pwm, S_IRUGO|S_IWUSR,
665 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
666 0, 2),
667 SENSOR_ATTR_2(temp1_auto_point2_pwm, S_IRUGO|S_IWUSR,
668 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
669 1, 2),
670 SENSOR_ATTR_2(temp1_auto_point3_pwm, S_IRUGO|S_IWUSR,
671 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
672 2, 2),
673 SENSOR_ATTR_2(temp1_auto_point4_pwm, S_IRUGO|S_IWUSR,
674 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
675 3, 2),
676 SENSOR_ATTR_2(temp1_auto_point5_pwm, S_IRUGO|S_IWUSR,
677 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
678 4, 2),
679 SENSOR_ATTR_2(temp1_auto_point1_temp, S_IRUGO|S_IWUSR,
680 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
681 0, 2),
682 SENSOR_ATTR_2(temp1_auto_point2_temp, S_IRUGO|S_IWUSR,
683 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
684 1, 2),
685 SENSOR_ATTR_2(temp1_auto_point3_temp, S_IRUGO|S_IWUSR,
686 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
687 2, 2),
688 SENSOR_ATTR_2(temp1_auto_point4_temp, S_IRUGO|S_IWUSR,
689 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
690 3, 2),
691 SENSOR_ATTR_2(temp1_auto_point1_temp_hyst, S_IRUGO|S_IWUSR,
692 show_pwm_auto_point_temp_hyst,
693 store_pwm_auto_point_temp_hyst,
694 0, 2),
695 SENSOR_ATTR_2(temp1_auto_point2_temp_hyst, S_IRUGO,
696 show_pwm_auto_point_temp_hyst, NULL, 1, 2),
697 SENSOR_ATTR_2(temp1_auto_point3_temp_hyst, S_IRUGO,
698 show_pwm_auto_point_temp_hyst, NULL, 2, 2),
699 SENSOR_ATTR_2(temp1_auto_point4_temp_hyst, S_IRUGO,
700 show_pwm_auto_point_temp_hyst, NULL, 3, 2),
701
702 SENSOR_ATTR_2(temp2_auto_point1_pwm, S_IRUGO|S_IWUSR,
703 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
704 0, 0),
705 SENSOR_ATTR_2(temp2_auto_point2_pwm, S_IRUGO|S_IWUSR,
706 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
707 1, 0),
708 SENSOR_ATTR_2(temp2_auto_point3_pwm, S_IRUGO|S_IWUSR,
709 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
710 2, 0),
711 SENSOR_ATTR_2(temp2_auto_point4_pwm, S_IRUGO|S_IWUSR,
712 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
713 3, 0),
714 SENSOR_ATTR_2(temp2_auto_point5_pwm, S_IRUGO|S_IWUSR,
715 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
716 4, 0),
717 SENSOR_ATTR_2(temp2_auto_point1_temp, S_IRUGO|S_IWUSR,
718 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
719 0, 0),
720 SENSOR_ATTR_2(temp2_auto_point2_temp, S_IRUGO|S_IWUSR,
721 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
722 1, 0),
723 SENSOR_ATTR_2(temp2_auto_point3_temp, S_IRUGO|S_IWUSR,
724 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
725 2, 0),
726 SENSOR_ATTR_2(temp2_auto_point4_temp, S_IRUGO|S_IWUSR,
727 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
728 3, 0),
729 SENSOR_ATTR_2(temp2_auto_point1_temp_hyst, S_IRUGO|S_IWUSR,
730 show_pwm_auto_point_temp_hyst,
731 store_pwm_auto_point_temp_hyst,
732 0, 0),
733 SENSOR_ATTR_2(temp2_auto_point2_temp_hyst, S_IRUGO,
734 show_pwm_auto_point_temp_hyst, NULL, 1, 0),
735 SENSOR_ATTR_2(temp2_auto_point3_temp_hyst, S_IRUGO,
736 show_pwm_auto_point_temp_hyst, NULL, 2, 0),
737 SENSOR_ATTR_2(temp2_auto_point4_temp_hyst, S_IRUGO,
738 show_pwm_auto_point_temp_hyst, NULL, 3, 0),
739
740 SENSOR_ATTR_2(temp3_auto_point1_pwm, S_IRUGO|S_IWUSR,
741 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
742 0, 1),
743 SENSOR_ATTR_2(temp3_auto_point2_pwm, S_IRUGO|S_IWUSR,
744 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
745 1, 1),
746 SENSOR_ATTR_2(temp3_auto_point3_pwm, S_IRUGO|S_IWUSR,
747 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
748 2, 1),
749 SENSOR_ATTR_2(temp3_auto_point4_pwm, S_IRUGO|S_IWUSR,
750 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
751 3, 1),
752 SENSOR_ATTR_2(temp3_auto_point5_pwm, S_IRUGO|S_IWUSR,
753 show_pwm_auto_point_pwm, store_pwm_auto_point_pwm,
754 4, 1),
755 SENSOR_ATTR_2(temp3_auto_point1_temp, S_IRUGO|S_IWUSR,
756 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
757 0, 1),
758 SENSOR_ATTR_2(temp3_auto_point2_temp, S_IRUGO|S_IWUSR,
759 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
760 1, 1),
761 SENSOR_ATTR_2(temp3_auto_point3_temp, S_IRUGO|S_IWUSR,
762 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
763 2, 1),
764 SENSOR_ATTR_2(temp3_auto_point4_temp, S_IRUGO|S_IWUSR,
765 show_pwm_auto_point_temp, store_pwm_auto_point_temp,
766 3, 1),
767 SENSOR_ATTR_2(temp3_auto_point1_temp_hyst, S_IRUGO|S_IWUSR,
768 show_pwm_auto_point_temp_hyst,
769 store_pwm_auto_point_temp_hyst,
770 0, 1),
771 SENSOR_ATTR_2(temp3_auto_point2_temp_hyst, S_IRUGO,
772 show_pwm_auto_point_temp_hyst, NULL, 1, 1),
773 SENSOR_ATTR_2(temp3_auto_point3_temp_hyst, S_IRUGO,
774 show_pwm_auto_point_temp_hyst, NULL, 2, 1),
775 SENSOR_ATTR_2(temp3_auto_point4_temp_hyst, S_IRUGO,
776 show_pwm_auto_point_temp_hyst, NULL, 3, 1),
777};
266 778
267/* Super I/O functions */ 779/* Super I/O functions */
268static inline int superio_inb(int base, int reg) 780static inline int superio_inb(int base, int reg)
@@ -299,11 +811,16 @@ static inline void superio_exit(int base)
299 outb(SIO_LOCK_KEY, base); 811 outb(SIO_LOCK_KEY, base);
300} 812}
301 813
302static inline u16 fan_from_reg(u16 reg) 814static inline int fan_from_reg(u16 reg)
303{ 815{
304 return reg ? (1500000 / reg) : 0; 816 return reg ? (1500000 / reg) : 0;
305} 817}
306 818
819static inline u16 fan_to_reg(int fan)
820{
821 return fan ? (1500000 / fan) : 0;
822}
823
307static u8 f71882fg_read8(struct f71882fg_data *data, u8 reg) 824static u8 f71882fg_read8(struct f71882fg_data *data, u8 reg)
308{ 825{
309 u8 val; 826 u8 val;
@@ -332,52 +849,111 @@ static void f71882fg_write8(struct f71882fg_data *data, u8 reg, u8 val)
332 outb(val, data->addr + DATA_REG_OFFSET); 849 outb(val, data->addr + DATA_REG_OFFSET);
333} 850}
334 851
335static struct f71882fg_data *f71882fg_update_device(struct device * dev) 852static void f71882fg_write16(struct f71882fg_data *data, u8 reg, u16 val)
853{
854 outb(reg++, data->addr + ADDR_REG_OFFSET);
855 outb(val >> 8, data->addr + DATA_REG_OFFSET);
856 outb(reg, data->addr + ADDR_REG_OFFSET);
857 outb(val & 255, data->addr + DATA_REG_OFFSET);
858}
859
860static struct f71882fg_data *f71882fg_update_device(struct device *dev)
336{ 861{
337 struct f71882fg_data *data = dev_get_drvdata(dev); 862 struct f71882fg_data *data = dev_get_drvdata(dev);
338 int nr, reg, reg2; 863 int nr, reg = 0, reg2;
864 int nr_fans = (data->type == f71882fg) ? 4 : 3;
865 int nr_ins = (data->type == f8000) ? 3 : 9;
866 int temp_start = (data->type == f8000) ? 0 : 1;
339 867
340 mutex_lock(&data->update_lock); 868 mutex_lock(&data->update_lock);
341 869
342 /* Update once every 60 seconds */ 870 /* Update once every 60 seconds */
343 if ( time_after(jiffies, data->last_limits + 60 * HZ ) || 871 if ( time_after(jiffies, data->last_limits + 60 * HZ ) ||
344 !data->valid) { 872 !data->valid) {
345 data->in1_max = f71882fg_read8(data, F71882FG_REG_IN1_HIGH); 873 if (data->type == f71882fg) {
346 data->in_beep = f71882fg_read8(data, F71882FG_REG_IN_BEEP); 874 data->in1_max =
875 f71882fg_read8(data, F71882FG_REG_IN1_HIGH);
876 data->in_beep =
877 f71882fg_read8(data, F71882FG_REG_IN_BEEP);
878 }
347 879
348 /* Get High & boundary temps*/ 880 /* Get High & boundary temps*/
349 for (nr = 0; nr < 3; nr++) { 881 for (nr = temp_start; nr < 3 + temp_start; nr++) {
350 data->temp_ovt[nr] = f71882fg_read8(data, 882 data->temp_ovt[nr] = f71882fg_read8(data,
351 F71882FG_REG_TEMP_OVT(nr)); 883 F71882FG_REG_TEMP_OVT(nr));
352 data->temp_high[nr] = f71882fg_read8(data, 884 data->temp_high[nr] = f71882fg_read8(data,
353 F71882FG_REG_TEMP_HIGH(nr)); 885 F71882FG_REG_TEMP_HIGH(nr));
354 } 886 }
355 887
356 /* Have to hardcode hyst*/ 888 if (data->type != f8000) {
357 data->temp_hyst[0] = f71882fg_read8(data, 889 data->fan_beep = f71882fg_read8(data,
358 F71882FG_REG_TEMP_HYST1) >> 4; 890 F71882FG_REG_FAN_BEEP);
359 /* Hyst temps 2 & 3 stored in same register */ 891 data->temp_beep = f71882fg_read8(data,
360 reg = f71882fg_read8(data, F71882FG_REG_TEMP_HYST23); 892 F71882FG_REG_TEMP_BEEP);
361 data->temp_hyst[1] = reg & 0x0F; 893 data->temp_hyst[0] = f71882fg_read8(data,
362 data->temp_hyst[2] = reg >> 4; 894 F71882FG_REG_TEMP_HYST(0));
363 895 data->temp_hyst[1] = f71882fg_read8(data,
364 /* Have to hardcode type, because temp1 is special */ 896 F71882FG_REG_TEMP_HYST(1));
365 reg = f71882fg_read8(data, F71882FG_REG_TEMP_TYPE); 897 /* Have to hardcode type, because temp1 is special */
898 reg = f71882fg_read8(data, F71882FG_REG_TEMP_TYPE);
899 data->temp_type[2] = (reg & 0x04) ? 2 : 4;
900 data->temp_type[3] = (reg & 0x08) ? 2 : 4;
901 }
366 reg2 = f71882fg_read8(data, F71882FG_REG_PECI); 902 reg2 = f71882fg_read8(data, F71882FG_REG_PECI);
367 if ((reg2 & 0x03) == 0x01) 903 if ((reg2 & 0x03) == 0x01)
368 data->temp_type[0] = 6 /* PECI */; 904 data->temp_type[1] = 6 /* PECI */;
369 else if ((reg2 & 0x03) == 0x02) 905 else if ((reg2 & 0x03) == 0x02)
370 data->temp_type[0] = 5 /* AMDSI */; 906 data->temp_type[1] = 5 /* AMDSI */;
907 else if (data->type != f8000)
908 data->temp_type[1] = (reg & 0x02) ? 2 : 4;
371 else 909 else
372 data->temp_type[0] = (reg & 0x02) ? 2 : 4; 910 data->temp_type[1] = 2; /* F8000 only supports BJT */
373 911
374 data->temp_type[1] = (reg & 0x04) ? 2 : 4; 912 data->pwm_enable = f71882fg_read8(data,
375 data->temp_type[2] = (reg & 0x08) ? 2 : 4; 913 F71882FG_REG_PWM_ENABLE);
376 914 data->pwm_auto_point_hyst[0] =
377 data->temp_beep = f71882fg_read8(data, F71882FG_REG_TEMP_BEEP); 915 f71882fg_read8(data, F71882FG_REG_FAN_HYST(0));
378 916 data->pwm_auto_point_hyst[1] =
379 data->fan_beep = f71882fg_read8(data, F71882FG_REG_FAN_BEEP); 917 f71882fg_read8(data, F71882FG_REG_FAN_HYST(1));
380 918
919 for (nr = 0; nr < nr_fans; nr++) {
920 data->pwm_auto_point_mapping[nr] =
921 f71882fg_read8(data,
922 F71882FG_REG_POINT_MAPPING(nr));
923
924 if (data->type != f71862fg) {
925 int point;
926 for (point = 0; point < 5; point++) {
927 data->pwm_auto_point_pwm[nr][point] =
928 f71882fg_read8(data,
929 F71882FG_REG_POINT_PWM
930 (nr, point));
931 }
932 for (point = 0; point < 4; point++) {
933 data->pwm_auto_point_temp[nr][point] =
934 f71882fg_read8(data,
935 F71882FG_REG_POINT_TEMP
936 (nr, point));
937 }
938 } else {
939 data->pwm_auto_point_pwm[nr][1] =
940 f71882fg_read8(data,
941 F71882FG_REG_POINT_PWM
942 (nr, 1));
943 data->pwm_auto_point_pwm[nr][4] =
944 f71882fg_read8(data,
945 F71882FG_REG_POINT_PWM
946 (nr, 4));
947 data->pwm_auto_point_temp[nr][0] =
948 f71882fg_read8(data,
949 F71882FG_REG_POINT_TEMP
950 (nr, 0));
951 data->pwm_auto_point_temp[nr][3] =
952 f71882fg_read8(data,
953 F71882FG_REG_POINT_TEMP
954 (nr, 3));
955 }
956 }
381 data->last_limits = jiffies; 957 data->last_limits = jiffies;
382 } 958 }
383 959
@@ -387,19 +963,32 @@ static struct f71882fg_data *f71882fg_update_device(struct device * dev)
387 F71882FG_REG_TEMP_STATUS); 963 F71882FG_REG_TEMP_STATUS);
388 data->temp_diode_open = f71882fg_read8(data, 964 data->temp_diode_open = f71882fg_read8(data,
389 F71882FG_REG_TEMP_DIODE_OPEN); 965 F71882FG_REG_TEMP_DIODE_OPEN);
390 for (nr = 0; nr < 3; nr++) 966 for (nr = temp_start; nr < 3 + temp_start; nr++)
391 data->temp[nr] = f71882fg_read8(data, 967 data->temp[nr] = f71882fg_read8(data,
392 F71882FG_REG_TEMP(nr)); 968 F71882FG_REG_TEMP(nr));
393 969
394 data->fan_status = f71882fg_read8(data, 970 data->fan_status = f71882fg_read8(data,
395 F71882FG_REG_FAN_STATUS); 971 F71882FG_REG_FAN_STATUS);
396 for (nr = 0; nr < 4; nr++) 972 for (nr = 0; nr < nr_fans; nr++) {
397 data->fan[nr] = f71882fg_read16(data, 973 data->fan[nr] = f71882fg_read16(data,
398 F71882FG_REG_FAN(nr)); 974 F71882FG_REG_FAN(nr));
975 data->fan_target[nr] =
976 f71882fg_read16(data, F71882FG_REG_FAN_TARGET(nr));
977 data->fan_full_speed[nr] =
978 f71882fg_read16(data,
979 F71882FG_REG_FAN_FULL_SPEED(nr));
980 data->pwm[nr] =
981 f71882fg_read8(data, F71882FG_REG_PWM(nr));
982 }
399 983
400 data->in_status = f71882fg_read8(data, 984 /* The f8000 can monitor 1 more fan, but has no pwm for it */
985 if (data->type == f8000)
986 data->fan[3] = f71882fg_read16(data,
987 F71882FG_REG_FAN(3));
988 if (data->type == f71882fg)
989 data->in_status = f71882fg_read8(data,
401 F71882FG_REG_IN_STATUS); 990 F71882FG_REG_IN_STATUS);
402 for (nr = 0; nr < 9; nr++) 991 for (nr = 0; nr < nr_ins; nr++)
403 data->in[nr] = f71882fg_read8(data, 992 data->in[nr] = f71882fg_read8(data,
404 F71882FG_REG_IN(nr)); 993 F71882FG_REG_IN(nr));
405 994
@@ -417,7 +1006,7 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *devattr,
417 char *buf) 1006 char *buf)
418{ 1007{
419 struct f71882fg_data *data = f71882fg_update_device(dev); 1008 struct f71882fg_data *data = f71882fg_update_device(dev);
420 int nr = to_sensor_dev_attr(devattr)->index; 1009 int nr = to_sensor_dev_attr_2(devattr)->index;
421 int speed = fan_from_reg(data->fan[nr]); 1010 int speed = fan_from_reg(data->fan[nr]);
422 1011
423 if (speed == FAN_MIN_DETECT) 1012 if (speed == FAN_MIN_DETECT)
@@ -426,11 +1015,39 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *devattr,
426 return sprintf(buf, "%d\n", speed); 1015 return sprintf(buf, "%d\n", speed);
427} 1016}
428 1017
1018static ssize_t show_fan_full_speed(struct device *dev,
1019 struct device_attribute *devattr, char *buf)
1020{
1021 struct f71882fg_data *data = f71882fg_update_device(dev);
1022 int nr = to_sensor_dev_attr_2(devattr)->index;
1023 int speed = fan_from_reg(data->fan_full_speed[nr]);
1024 return sprintf(buf, "%d\n", speed);
1025}
1026
1027static ssize_t store_fan_full_speed(struct device *dev,
1028 struct device_attribute *devattr,
1029 const char *buf, size_t count)
1030{
1031 struct f71882fg_data *data = dev_get_drvdata(dev);
1032 int nr = to_sensor_dev_attr_2(devattr)->index;
1033 long val = simple_strtol(buf, NULL, 10);
1034
1035 val = SENSORS_LIMIT(val, 23, 1500000);
1036 val = fan_to_reg(val);
1037
1038 mutex_lock(&data->update_lock);
1039 f71882fg_write16(data, F71882FG_REG_FAN_FULL_SPEED(nr), val);
1040 data->fan_full_speed[nr] = val;
1041 mutex_unlock(&data->update_lock);
1042
1043 return count;
1044}
1045
429static ssize_t show_fan_beep(struct device *dev, struct device_attribute 1046static ssize_t show_fan_beep(struct device *dev, struct device_attribute
430 *devattr, char *buf) 1047 *devattr, char *buf)
431{ 1048{
432 struct f71882fg_data *data = f71882fg_update_device(dev); 1049 struct f71882fg_data *data = f71882fg_update_device(dev);
433 int nr = to_sensor_dev_attr(devattr)->index; 1050 int nr = to_sensor_dev_attr_2(devattr)->index;
434 1051
435 if (data->fan_beep & (1 << nr)) 1052 if (data->fan_beep & (1 << nr))
436 return sprintf(buf, "1\n"); 1053 return sprintf(buf, "1\n");
@@ -442,10 +1059,11 @@ static ssize_t store_fan_beep(struct device *dev, struct device_attribute
442 *devattr, const char *buf, size_t count) 1059 *devattr, const char *buf, size_t count)
443{ 1060{
444 struct f71882fg_data *data = dev_get_drvdata(dev); 1061 struct f71882fg_data *data = dev_get_drvdata(dev);
445 int nr = to_sensor_dev_attr(devattr)->index; 1062 int nr = to_sensor_dev_attr_2(devattr)->index;
446 int val = simple_strtoul(buf, NULL, 10); 1063 unsigned long val = simple_strtoul(buf, NULL, 10);
447 1064
448 mutex_lock(&data->update_lock); 1065 mutex_lock(&data->update_lock);
1066 data->fan_beep = f71882fg_read8(data, F71882FG_REG_FAN_BEEP);
449 if (val) 1067 if (val)
450 data->fan_beep |= 1 << nr; 1068 data->fan_beep |= 1 << nr;
451 else 1069 else
@@ -461,7 +1079,7 @@ static ssize_t show_fan_alarm(struct device *dev, struct device_attribute
461 *devattr, char *buf) 1079 *devattr, char *buf)
462{ 1080{
463 struct f71882fg_data *data = f71882fg_update_device(dev); 1081 struct f71882fg_data *data = f71882fg_update_device(dev);
464 int nr = to_sensor_dev_attr(devattr)->index; 1082 int nr = to_sensor_dev_attr_2(devattr)->index;
465 1083
466 if (data->fan_status & (1 << nr)) 1084 if (data->fan_status & (1 << nr))
467 return sprintf(buf, "1\n"); 1085 return sprintf(buf, "1\n");
@@ -473,7 +1091,7 @@ static ssize_t show_in(struct device *dev, struct device_attribute *devattr,
473 char *buf) 1091 char *buf)
474{ 1092{
475 struct f71882fg_data *data = f71882fg_update_device(dev); 1093 struct f71882fg_data *data = f71882fg_update_device(dev);
476 int nr = to_sensor_dev_attr(devattr)->index; 1094 int nr = to_sensor_dev_attr_2(devattr)->index;
477 1095
478 return sprintf(buf, "%d\n", data->in[nr] * 8); 1096 return sprintf(buf, "%d\n", data->in[nr] * 8);
479} 1097}
@@ -490,10 +1108,8 @@ static ssize_t store_in_max(struct device *dev, struct device_attribute
490 *devattr, const char *buf, size_t count) 1108 *devattr, const char *buf, size_t count)
491{ 1109{
492 struct f71882fg_data *data = dev_get_drvdata(dev); 1110 struct f71882fg_data *data = dev_get_drvdata(dev);
493 int val = simple_strtoul(buf, NULL, 10) / 8; 1111 long val = simple_strtol(buf, NULL, 10) / 8;
494 1112 val = SENSORS_LIMIT(val, 0, 255);
495 if (val > 255)
496 val = 255;
497 1113
498 mutex_lock(&data->update_lock); 1114 mutex_lock(&data->update_lock);
499 f71882fg_write8(data, F71882FG_REG_IN1_HIGH, val); 1115 f71882fg_write8(data, F71882FG_REG_IN1_HIGH, val);
@@ -507,7 +1123,7 @@ static ssize_t show_in_beep(struct device *dev, struct device_attribute
507 *devattr, char *buf) 1123 *devattr, char *buf)
508{ 1124{
509 struct f71882fg_data *data = f71882fg_update_device(dev); 1125 struct f71882fg_data *data = f71882fg_update_device(dev);
510 int nr = to_sensor_dev_attr(devattr)->index; 1126 int nr = to_sensor_dev_attr_2(devattr)->index;
511 1127
512 if (data->in_beep & (1 << nr)) 1128 if (data->in_beep & (1 << nr))
513 return sprintf(buf, "1\n"); 1129 return sprintf(buf, "1\n");
@@ -519,10 +1135,11 @@ static ssize_t store_in_beep(struct device *dev, struct device_attribute
519 *devattr, const char *buf, size_t count) 1135 *devattr, const char *buf, size_t count)
520{ 1136{
521 struct f71882fg_data *data = dev_get_drvdata(dev); 1137 struct f71882fg_data *data = dev_get_drvdata(dev);
522 int nr = to_sensor_dev_attr(devattr)->index; 1138 int nr = to_sensor_dev_attr_2(devattr)->index;
523 int val = simple_strtoul(buf, NULL, 10); 1139 unsigned long val = simple_strtoul(buf, NULL, 10);
524 1140
525 mutex_lock(&data->update_lock); 1141 mutex_lock(&data->update_lock);
1142 data->in_beep = f71882fg_read8(data, F71882FG_REG_IN_BEEP);
526 if (val) 1143 if (val)
527 data->in_beep |= 1 << nr; 1144 data->in_beep |= 1 << nr;
528 else 1145 else
@@ -538,7 +1155,7 @@ static ssize_t show_in_alarm(struct device *dev, struct device_attribute
538 *devattr, char *buf) 1155 *devattr, char *buf)
539{ 1156{
540 struct f71882fg_data *data = f71882fg_update_device(dev); 1157 struct f71882fg_data *data = f71882fg_update_device(dev);
541 int nr = to_sensor_dev_attr(devattr)->index; 1158 int nr = to_sensor_dev_attr_2(devattr)->index;
542 1159
543 if (data->in_status & (1 << nr)) 1160 if (data->in_status & (1 << nr))
544 return sprintf(buf, "1\n"); 1161 return sprintf(buf, "1\n");
@@ -550,7 +1167,7 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *devattr,
550 char *buf) 1167 char *buf)
551{ 1168{
552 struct f71882fg_data *data = f71882fg_update_device(dev); 1169 struct f71882fg_data *data = f71882fg_update_device(dev);
553 int nr = to_sensor_dev_attr(devattr)->index; 1170 int nr = to_sensor_dev_attr_2(devattr)->index;
554 1171
555 return sprintf(buf, "%d\n", data->temp[nr] * 1000); 1172 return sprintf(buf, "%d\n", data->temp[nr] * 1000);
556} 1173}
@@ -559,7 +1176,7 @@ static ssize_t show_temp_max(struct device *dev, struct device_attribute
559 *devattr, char *buf) 1176 *devattr, char *buf)
560{ 1177{
561 struct f71882fg_data *data = f71882fg_update_device(dev); 1178 struct f71882fg_data *data = f71882fg_update_device(dev);
562 int nr = to_sensor_dev_attr(devattr)->index; 1179 int nr = to_sensor_dev_attr_2(devattr)->index;
563 1180
564 return sprintf(buf, "%d\n", data->temp_high[nr] * 1000); 1181 return sprintf(buf, "%d\n", data->temp_high[nr] * 1000);
565} 1182}
@@ -568,11 +1185,9 @@ static ssize_t store_temp_max(struct device *dev, struct device_attribute
568 *devattr, const char *buf, size_t count) 1185 *devattr, const char *buf, size_t count)
569{ 1186{
570 struct f71882fg_data *data = dev_get_drvdata(dev); 1187 struct f71882fg_data *data = dev_get_drvdata(dev);
571 int nr = to_sensor_dev_attr(devattr)->index; 1188 int nr = to_sensor_dev_attr_2(devattr)->index;
572 int val = simple_strtoul(buf, NULL, 10) / 1000; 1189 long val = simple_strtol(buf, NULL, 10) / 1000;
573 1190 val = SENSORS_LIMIT(val, 0, 255);
574 if (val > 255)
575 val = 255;
576 1191
577 mutex_lock(&data->update_lock); 1192 mutex_lock(&data->update_lock);
578 f71882fg_write8(data, F71882FG_REG_TEMP_HIGH(nr), val); 1193 f71882fg_write8(data, F71882FG_REG_TEMP_HIGH(nr), val);
@@ -586,48 +1201,46 @@ static ssize_t show_temp_max_hyst(struct device *dev, struct device_attribute
586 *devattr, char *buf) 1201 *devattr, char *buf)
587{ 1202{
588 struct f71882fg_data *data = f71882fg_update_device(dev); 1203 struct f71882fg_data *data = f71882fg_update_device(dev);
589 int nr = to_sensor_dev_attr(devattr)->index; 1204 int nr = to_sensor_dev_attr_2(devattr)->index;
1205 int temp_max_hyst;
1206
1207 mutex_lock(&data->update_lock);
1208 if (nr & 1)
1209 temp_max_hyst = data->temp_hyst[nr / 2] >> 4;
1210 else
1211 temp_max_hyst = data->temp_hyst[nr / 2] & 0x0f;
1212 temp_max_hyst = (data->temp_high[nr] - temp_max_hyst) * 1000;
1213 mutex_unlock(&data->update_lock);
590 1214
591 return sprintf(buf, "%d\n", 1215 return sprintf(buf, "%d\n", temp_max_hyst);
592 (data->temp_high[nr] - data->temp_hyst[nr]) * 1000);
593} 1216}
594 1217
595static ssize_t store_temp_max_hyst(struct device *dev, struct device_attribute 1218static ssize_t store_temp_max_hyst(struct device *dev, struct device_attribute
596 *devattr, const char *buf, size_t count) 1219 *devattr, const char *buf, size_t count)
597{ 1220{
598 struct f71882fg_data *data = dev_get_drvdata(dev); 1221 struct f71882fg_data *data = dev_get_drvdata(dev);
599 int nr = to_sensor_dev_attr(devattr)->index; 1222 int nr = to_sensor_dev_attr_2(devattr)->index;
600 int val = simple_strtoul(buf, NULL, 10) / 1000; 1223 long val = simple_strtol(buf, NULL, 10) / 1000;
601 ssize_t ret = count; 1224 ssize_t ret = count;
1225 u8 reg;
602 1226
603 mutex_lock(&data->update_lock); 1227 mutex_lock(&data->update_lock);
604 1228
605 /* convert abs to relative and check */ 1229 /* convert abs to relative and check */
1230 data->temp_high[nr] = f71882fg_read8(data, F71882FG_REG_TEMP_HIGH(nr));
1231 val = SENSORS_LIMIT(val, data->temp_high[nr] - 15,
1232 data->temp_high[nr]);
606 val = data->temp_high[nr] - val; 1233 val = data->temp_high[nr] - val;
607 if (val < 0 || val > 15) {
608 ret = -EINVAL;
609 goto store_temp_max_hyst_exit;
610 }
611
612 data->temp_hyst[nr] = val;
613 1234
614 /* convert value to register contents */ 1235 /* convert value to register contents */
615 switch (nr) { 1236 reg = f71882fg_read8(data, F71882FG_REG_TEMP_HYST(nr / 2));
616 case 0: 1237 if (nr & 1)
617 val = val << 4; 1238 reg = (reg & 0x0f) | (val << 4);
618 break; 1239 else
619 case 1: 1240 reg = (reg & 0xf0) | val;
620 val = val | (data->temp_hyst[2] << 4); 1241 f71882fg_write8(data, F71882FG_REG_TEMP_HYST(nr / 2), reg);
621 break; 1242 data->temp_hyst[nr / 2] = reg;
622 case 2:
623 val = data->temp_hyst[1] | (val << 4);
624 break;
625 }
626
627 f71882fg_write8(data, nr ? F71882FG_REG_TEMP_HYST23 :
628 F71882FG_REG_TEMP_HYST1, val);
629 1243
630store_temp_max_hyst_exit:
631 mutex_unlock(&data->update_lock); 1244 mutex_unlock(&data->update_lock);
632 return ret; 1245 return ret;
633} 1246}
@@ -636,7 +1249,7 @@ static ssize_t show_temp_crit(struct device *dev, struct device_attribute
636 *devattr, char *buf) 1249 *devattr, char *buf)
637{ 1250{
638 struct f71882fg_data *data = f71882fg_update_device(dev); 1251 struct f71882fg_data *data = f71882fg_update_device(dev);
639 int nr = to_sensor_dev_attr(devattr)->index; 1252 int nr = to_sensor_dev_attr_2(devattr)->index;
640 1253
641 return sprintf(buf, "%d\n", data->temp_ovt[nr] * 1000); 1254 return sprintf(buf, "%d\n", data->temp_ovt[nr] * 1000);
642} 1255}
@@ -645,11 +1258,9 @@ static ssize_t store_temp_crit(struct device *dev, struct device_attribute
645 *devattr, const char *buf, size_t count) 1258 *devattr, const char *buf, size_t count)
646{ 1259{
647 struct f71882fg_data *data = dev_get_drvdata(dev); 1260 struct f71882fg_data *data = dev_get_drvdata(dev);
648 int nr = to_sensor_dev_attr(devattr)->index; 1261 int nr = to_sensor_dev_attr_2(devattr)->index;
649 int val = simple_strtoul(buf, NULL, 10) / 1000; 1262 long val = simple_strtol(buf, NULL, 10) / 1000;
650 1263 val = SENSORS_LIMIT(val, 0, 255);
651 if (val > 255)
652 val = 255;
653 1264
654 mutex_lock(&data->update_lock); 1265 mutex_lock(&data->update_lock);
655 f71882fg_write8(data, F71882FG_REG_TEMP_OVT(nr), val); 1266 f71882fg_write8(data, F71882FG_REG_TEMP_OVT(nr), val);
@@ -663,17 +1274,25 @@ static ssize_t show_temp_crit_hyst(struct device *dev, struct device_attribute
663 *devattr, char *buf) 1274 *devattr, char *buf)
664{ 1275{
665 struct f71882fg_data *data = f71882fg_update_device(dev); 1276 struct f71882fg_data *data = f71882fg_update_device(dev);
666 int nr = to_sensor_dev_attr(devattr)->index; 1277 int nr = to_sensor_dev_attr_2(devattr)->index;
1278 int temp_crit_hyst;
1279
1280 mutex_lock(&data->update_lock);
1281 if (nr & 1)
1282 temp_crit_hyst = data->temp_hyst[nr / 2] >> 4;
1283 else
1284 temp_crit_hyst = data->temp_hyst[nr / 2] & 0x0f;
1285 temp_crit_hyst = (data->temp_ovt[nr] - temp_crit_hyst) * 1000;
1286 mutex_unlock(&data->update_lock);
667 1287
668 return sprintf(buf, "%d\n", 1288 return sprintf(buf, "%d\n", temp_crit_hyst);
669 (data->temp_ovt[nr] - data->temp_hyst[nr]) * 1000);
670} 1289}
671 1290
672static ssize_t show_temp_type(struct device *dev, struct device_attribute 1291static ssize_t show_temp_type(struct device *dev, struct device_attribute
673 *devattr, char *buf) 1292 *devattr, char *buf)
674{ 1293{
675 struct f71882fg_data *data = f71882fg_update_device(dev); 1294 struct f71882fg_data *data = f71882fg_update_device(dev);
676 int nr = to_sensor_dev_attr(devattr)->index; 1295 int nr = to_sensor_dev_attr_2(devattr)->index;
677 1296
678 return sprintf(buf, "%d\n", data->temp_type[nr]); 1297 return sprintf(buf, "%d\n", data->temp_type[nr]);
679} 1298}
@@ -682,9 +1301,9 @@ static ssize_t show_temp_beep(struct device *dev, struct device_attribute
682 *devattr, char *buf) 1301 *devattr, char *buf)
683{ 1302{
684 struct f71882fg_data *data = f71882fg_update_device(dev); 1303 struct f71882fg_data *data = f71882fg_update_device(dev);
685 int nr = to_sensor_dev_attr(devattr)->index; 1304 int nr = to_sensor_dev_attr_2(devattr)->index;
686 1305
687 if (data->temp_beep & (1 << (nr + 1))) 1306 if (data->temp_beep & (1 << nr))
688 return sprintf(buf, "1\n"); 1307 return sprintf(buf, "1\n");
689 else 1308 else
690 return sprintf(buf, "0\n"); 1309 return sprintf(buf, "0\n");
@@ -694,14 +1313,15 @@ static ssize_t store_temp_beep(struct device *dev, struct device_attribute
694 *devattr, const char *buf, size_t count) 1313 *devattr, const char *buf, size_t count)
695{ 1314{
696 struct f71882fg_data *data = dev_get_drvdata(dev); 1315 struct f71882fg_data *data = dev_get_drvdata(dev);
697 int nr = to_sensor_dev_attr(devattr)->index; 1316 int nr = to_sensor_dev_attr_2(devattr)->index;
698 int val = simple_strtoul(buf, NULL, 10); 1317 unsigned long val = simple_strtoul(buf, NULL, 10);
699 1318
700 mutex_lock(&data->update_lock); 1319 mutex_lock(&data->update_lock);
1320 data->temp_beep = f71882fg_read8(data, F71882FG_REG_TEMP_BEEP);
701 if (val) 1321 if (val)
702 data->temp_beep |= 1 << (nr + 1); 1322 data->temp_beep |= 1 << nr;
703 else 1323 else
704 data->temp_beep &= ~(1 << (nr + 1)); 1324 data->temp_beep &= ~(1 << nr);
705 1325
706 f71882fg_write8(data, F71882FG_REG_TEMP_BEEP, data->temp_beep); 1326 f71882fg_write8(data, F71882FG_REG_TEMP_BEEP, data->temp_beep);
707 mutex_unlock(&data->update_lock); 1327 mutex_unlock(&data->update_lock);
@@ -713,9 +1333,9 @@ static ssize_t show_temp_alarm(struct device *dev, struct device_attribute
713 *devattr, char *buf) 1333 *devattr, char *buf)
714{ 1334{
715 struct f71882fg_data *data = f71882fg_update_device(dev); 1335 struct f71882fg_data *data = f71882fg_update_device(dev);
716 int nr = to_sensor_dev_attr(devattr)->index; 1336 int nr = to_sensor_dev_attr_2(devattr)->index;
717 1337
718 if (data->temp_status & (1 << (nr + 1))) 1338 if (data->temp_status & (1 << nr))
719 return sprintf(buf, "1\n"); 1339 return sprintf(buf, "1\n");
720 else 1340 else
721 return sprintf(buf, "0\n"); 1341 return sprintf(buf, "0\n");
@@ -725,113 +1345,528 @@ static ssize_t show_temp_fault(struct device *dev, struct device_attribute
725 *devattr, char *buf) 1345 *devattr, char *buf)
726{ 1346{
727 struct f71882fg_data *data = f71882fg_update_device(dev); 1347 struct f71882fg_data *data = f71882fg_update_device(dev);
728 int nr = to_sensor_dev_attr(devattr)->index; 1348 int nr = to_sensor_dev_attr_2(devattr)->index;
729 1349
730 if (data->temp_diode_open & (1 << (nr + 1))) 1350 if (data->temp_diode_open & (1 << nr))
731 return sprintf(buf, "1\n"); 1351 return sprintf(buf, "1\n");
732 else 1352 else
733 return sprintf(buf, "0\n"); 1353 return sprintf(buf, "0\n");
734} 1354}
735 1355
1356static ssize_t show_pwm(struct device *dev,
1357 struct device_attribute *devattr, char *buf)
1358{
1359 struct f71882fg_data *data = f71882fg_update_device(dev);
1360 int val, nr = to_sensor_dev_attr_2(devattr)->index;
1361 mutex_lock(&data->update_lock);
1362 if (data->pwm_enable & (1 << (2 * nr)))
1363 /* PWM mode */
1364 val = data->pwm[nr];
1365 else {
1366 /* RPM mode */
1367 val = 255 * fan_from_reg(data->fan_target[nr])
1368 / fan_from_reg(data->fan_full_speed[nr]);
1369 }
1370 mutex_unlock(&data->update_lock);
1371 return sprintf(buf, "%d\n", val);
1372}
1373
1374static ssize_t store_pwm(struct device *dev,
1375 struct device_attribute *devattr, const char *buf,
1376 size_t count)
1377{
1378 struct f71882fg_data *data = dev_get_drvdata(dev);
1379 int nr = to_sensor_dev_attr_2(devattr)->index;
1380 long val = simple_strtol(buf, NULL, 10);
1381 val = SENSORS_LIMIT(val, 0, 255);
1382
1383 mutex_lock(&data->update_lock);
1384 data->pwm_enable = f71882fg_read8(data, F71882FG_REG_PWM_ENABLE);
1385 if ((data->type == f8000 && ((data->pwm_enable >> 2 * nr) & 3) != 2) ||
1386 (data->type != f8000 && !((data->pwm_enable >> 2 * nr) & 2))) {
1387 count = -EROFS;
1388 goto leave;
1389 }
1390 if (data->pwm_enable & (1 << (2 * nr))) {
1391 /* PWM mode */
1392 f71882fg_write8(data, F71882FG_REG_PWM(nr), val);
1393 data->pwm[nr] = val;
1394 } else {
1395 /* RPM mode */
1396 int target, full_speed;
1397 full_speed = f71882fg_read16(data,
1398 F71882FG_REG_FAN_FULL_SPEED(nr));
1399 target = fan_to_reg(val * fan_from_reg(full_speed) / 255);
1400 f71882fg_write16(data, F71882FG_REG_FAN_TARGET(nr), target);
1401 data->fan_target[nr] = target;
1402 data->fan_full_speed[nr] = full_speed;
1403 }
1404leave:
1405 mutex_unlock(&data->update_lock);
1406
1407 return count;
1408}
1409
1410static ssize_t show_pwm_enable(struct device *dev,
1411 struct device_attribute *devattr, char *buf)
1412{
1413 int result = 0;
1414 struct f71882fg_data *data = f71882fg_update_device(dev);
1415 int nr = to_sensor_dev_attr_2(devattr)->index;
1416
1417 switch ((data->pwm_enable >> 2 * nr) & 3) {
1418 case 0:
1419 case 1:
1420 result = 2; /* Normal auto mode */
1421 break;
1422 case 2:
1423 result = 1; /* Manual mode */
1424 break;
1425 case 3:
1426 if (data->type == f8000)
1427 result = 3; /* Thermostat mode */
1428 else
1429 result = 1; /* Manual mode */
1430 break;
1431 }
1432
1433 return sprintf(buf, "%d\n", result);
1434}
1435
1436static ssize_t store_pwm_enable(struct device *dev, struct device_attribute
1437 *devattr, const char *buf, size_t count)
1438{
1439 struct f71882fg_data *data = dev_get_drvdata(dev);
1440 int nr = to_sensor_dev_attr_2(devattr)->index;
1441 long val = simple_strtol(buf, NULL, 10);
1442
1443 mutex_lock(&data->update_lock);
1444 data->pwm_enable = f71882fg_read8(data, F71882FG_REG_PWM_ENABLE);
1445 /* Special case for F8000 auto PWM mode / Thermostat mode */
1446 if (data->type == f8000 && ((data->pwm_enable >> 2 * nr) & 1)) {
1447 switch (val) {
1448 case 2:
1449 data->pwm_enable &= ~(2 << (2 * nr));
1450 break; /* Normal auto mode */
1451 case 3:
1452 data->pwm_enable |= 2 << (2 * nr);
1453 break; /* Thermostat mode */
1454 default:
1455 count = -EINVAL;
1456 goto leave;
1457 }
1458 } else {
1459 switch (val) {
1460 case 1:
1461 data->pwm_enable |= 2 << (2 * nr);
1462 break; /* Manual */
1463 case 2:
1464 data->pwm_enable &= ~(2 << (2 * nr));
1465 break; /* Normal auto mode */
1466 default:
1467 count = -EINVAL;
1468 goto leave;
1469 }
1470 }
1471 f71882fg_write8(data, F71882FG_REG_PWM_ENABLE, data->pwm_enable);
1472leave:
1473 mutex_unlock(&data->update_lock);
1474
1475 return count;
1476}
1477
1478static ssize_t show_pwm_auto_point_pwm(struct device *dev,
1479 struct device_attribute *devattr,
1480 char *buf)
1481{
1482 int result;
1483 struct f71882fg_data *data = f71882fg_update_device(dev);
1484 int pwm = to_sensor_dev_attr_2(devattr)->index;
1485 int point = to_sensor_dev_attr_2(devattr)->nr;
1486
1487 mutex_lock(&data->update_lock);
1488 if (data->pwm_enable & (1 << (2 * pwm))) {
1489 /* PWM mode */
1490 result = data->pwm_auto_point_pwm[pwm][point];
1491 } else {
1492 /* RPM mode */
1493 result = 32 * 255 / (32 + data->pwm_auto_point_pwm[pwm][point]);
1494 }
1495 mutex_unlock(&data->update_lock);
1496
1497 return sprintf(buf, "%d\n", result);
1498}
1499
1500static ssize_t store_pwm_auto_point_pwm(struct device *dev,
1501 struct device_attribute *devattr,
1502 const char *buf, size_t count)
1503{
1504 struct f71882fg_data *data = dev_get_drvdata(dev);
1505 int pwm = to_sensor_dev_attr_2(devattr)->index;
1506 int point = to_sensor_dev_attr_2(devattr)->nr;
1507 long val = simple_strtol(buf, NULL, 10);
1508 val = SENSORS_LIMIT(val, 0, 255);
1509
1510 mutex_lock(&data->update_lock);
1511 data->pwm_enable = f71882fg_read8(data, F71882FG_REG_PWM_ENABLE);
1512 if (data->pwm_enable & (1 << (2 * pwm))) {
1513 /* PWM mode */
1514 } else {
1515 /* RPM mode */
1516 if (val < 29) /* Prevent negative numbers */
1517 val = 255;
1518 else
1519 val = (255 - val) * 32 / val;
1520 }
1521 f71882fg_write8(data, F71882FG_REG_POINT_PWM(pwm, point), val);
1522 data->pwm_auto_point_pwm[pwm][point] = val;
1523 mutex_unlock(&data->update_lock);
1524
1525 return count;
1526}
1527
1528static ssize_t show_pwm_auto_point_temp_hyst(struct device *dev,
1529 struct device_attribute *devattr,
1530 char *buf)
1531{
1532 int result = 0;
1533 struct f71882fg_data *data = f71882fg_update_device(dev);
1534 int nr = to_sensor_dev_attr_2(devattr)->index;
1535 int point = to_sensor_dev_attr_2(devattr)->nr;
1536
1537 mutex_lock(&data->update_lock);
1538 if (nr & 1)
1539 result = data->pwm_auto_point_hyst[nr / 2] >> 4;
1540 else
1541 result = data->pwm_auto_point_hyst[nr / 2] & 0x0f;
1542 result = 1000 * (data->pwm_auto_point_temp[nr][point] - result);
1543 mutex_unlock(&data->update_lock);
1544
1545 return sprintf(buf, "%d\n", result);
1546}
1547
1548static ssize_t store_pwm_auto_point_temp_hyst(struct device *dev,
1549 struct device_attribute *devattr,
1550 const char *buf, size_t count)
1551{
1552 struct f71882fg_data *data = dev_get_drvdata(dev);
1553 int nr = to_sensor_dev_attr_2(devattr)->index;
1554 int point = to_sensor_dev_attr_2(devattr)->nr;
1555 long val = simple_strtol(buf, NULL, 10) / 1000;
1556 u8 reg;
1557
1558 mutex_lock(&data->update_lock);
1559 data->pwm_auto_point_temp[nr][point] =
1560 f71882fg_read8(data, F71882FG_REG_POINT_TEMP(nr, point));
1561 val = SENSORS_LIMIT(val, data->pwm_auto_point_temp[nr][point] - 15,
1562 data->pwm_auto_point_temp[nr][point]);
1563 val = data->pwm_auto_point_temp[nr][point] - val;
1564
1565 reg = f71882fg_read8(data, F71882FG_REG_FAN_HYST(nr / 2));
1566 if (nr & 1)
1567 reg = (reg & 0x0f) | (val << 4);
1568 else
1569 reg = (reg & 0xf0) | val;
1570
1571 f71882fg_write8(data, F71882FG_REG_FAN_HYST(nr / 2), reg);
1572 data->pwm_auto_point_hyst[nr / 2] = reg;
1573 mutex_unlock(&data->update_lock);
1574
1575 return count;
1576}
1577
1578static ssize_t show_pwm_interpolate(struct device *dev,
1579 struct device_attribute *devattr, char *buf)
1580{
1581 int result;
1582 struct f71882fg_data *data = f71882fg_update_device(dev);
1583 int nr = to_sensor_dev_attr_2(devattr)->index;
1584
1585 result = (data->pwm_auto_point_mapping[nr] >> 4) & 1;
1586
1587 return sprintf(buf, "%d\n", result);
1588}
1589
1590static ssize_t store_pwm_interpolate(struct device *dev,
1591 struct device_attribute *devattr,
1592 const char *buf, size_t count)
1593{
1594 struct f71882fg_data *data = dev_get_drvdata(dev);
1595 int nr = to_sensor_dev_attr_2(devattr)->index;
1596 unsigned long val = simple_strtoul(buf, NULL, 10);
1597
1598 mutex_lock(&data->update_lock);
1599 data->pwm_auto_point_mapping[nr] =
1600 f71882fg_read8(data, F71882FG_REG_POINT_MAPPING(nr));
1601 if (val)
1602 val = data->pwm_auto_point_mapping[nr] | (1 << 4);
1603 else
1604 val = data->pwm_auto_point_mapping[nr] & (~(1 << 4));
1605 f71882fg_write8(data, F71882FG_REG_POINT_MAPPING(nr), val);
1606 data->pwm_auto_point_mapping[nr] = val;
1607 mutex_unlock(&data->update_lock);
1608
1609 return count;
1610}
1611
1612static ssize_t show_pwm_auto_point_channel(struct device *dev,
1613 struct device_attribute *devattr,
1614 char *buf)
1615{
1616 int result;
1617 struct f71882fg_data *data = f71882fg_update_device(dev);
1618 int nr = to_sensor_dev_attr_2(devattr)->index;
1619 int temp_start = (data->type == f8000) ? 0 : 1;
1620
1621 result = 1 << ((data->pwm_auto_point_mapping[nr] & 3) - temp_start);
1622
1623 return sprintf(buf, "%d\n", result);
1624}
1625
1626static ssize_t store_pwm_auto_point_channel(struct device *dev,
1627 struct device_attribute *devattr,
1628 const char *buf, size_t count)
1629{
1630 struct f71882fg_data *data = dev_get_drvdata(dev);
1631 int nr = to_sensor_dev_attr_2(devattr)->index;
1632 int temp_start = (data->type == f8000) ? 0 : 1;
1633 long val = simple_strtol(buf, NULL, 10);
1634
1635 switch (val) {
1636 case 1:
1637 val = 0;
1638 break;
1639 case 2:
1640 val = 1;
1641 break;
1642 case 4:
1643 val = 2;
1644 break;
1645 default:
1646 return -EINVAL;
1647 }
1648 val += temp_start;
1649 mutex_lock(&data->update_lock);
1650 data->pwm_auto_point_mapping[nr] =
1651 f71882fg_read8(data, F71882FG_REG_POINT_MAPPING(nr));
1652 val = (data->pwm_auto_point_mapping[nr] & 0xfc) | val;
1653 f71882fg_write8(data, F71882FG_REG_POINT_MAPPING(nr), val);
1654 data->pwm_auto_point_mapping[nr] = val;
1655 mutex_unlock(&data->update_lock);
1656
1657 return count;
1658}
1659
1660static ssize_t show_pwm_auto_point_temp(struct device *dev,
1661 struct device_attribute *devattr,
1662 char *buf)
1663{
1664 int result;
1665 struct f71882fg_data *data = f71882fg_update_device(dev);
1666 int pwm = to_sensor_dev_attr_2(devattr)->index;
1667 int point = to_sensor_dev_attr_2(devattr)->nr;
1668
1669 result = data->pwm_auto_point_temp[pwm][point];
1670 return sprintf(buf, "%d\n", 1000 * result);
1671}
1672
1673static ssize_t store_pwm_auto_point_temp(struct device *dev,
1674 struct device_attribute *devattr,
1675 const char *buf, size_t count)
1676{
1677 struct f71882fg_data *data = dev_get_drvdata(dev);
1678 int pwm = to_sensor_dev_attr_2(devattr)->index;
1679 int point = to_sensor_dev_attr_2(devattr)->nr;
1680 long val = simple_strtol(buf, NULL, 10) / 1000;
1681 val = SENSORS_LIMIT(val, 0, 255);
1682
1683 mutex_lock(&data->update_lock);
1684 f71882fg_write8(data, F71882FG_REG_POINT_TEMP(pwm, point), val);
1685 data->pwm_auto_point_temp[pwm][point] = val;
1686 mutex_unlock(&data->update_lock);
1687
1688 return count;
1689}
1690
736static ssize_t show_name(struct device *dev, struct device_attribute *devattr, 1691static ssize_t show_name(struct device *dev, struct device_attribute *devattr,
737 char *buf) 1692 char *buf)
738{ 1693{
739 return sprintf(buf, DRVNAME "\n"); 1694 struct f71882fg_data *data = dev_get_drvdata(dev);
1695 return sprintf(buf, "%s\n", f71882fg_names[data->type]);
740} 1696}
741 1697
1698static int __devinit f71882fg_create_sysfs_files(struct platform_device *pdev,
1699 struct sensor_device_attribute_2 *attr, int count)
1700{
1701 int err, i;
1702
1703 for (i = 0; i < count; i++) {
1704 err = device_create_file(&pdev->dev, &attr[i].dev_attr);
1705 if (err)
1706 return err;
1707 }
1708 return 0;
1709}
742 1710
743static int __devinit f71882fg_probe(struct platform_device * pdev) 1711static int __devinit f71882fg_probe(struct platform_device *pdev)
744{ 1712{
745 struct f71882fg_data *data; 1713 struct f71882fg_data *data;
746 int err, i; 1714 struct f71882fg_sio_data *sio_data = pdev->dev.platform_data;
1715 int err, i, nr_fans = (sio_data->type == f71882fg) ? 4 : 3;
747 u8 start_reg; 1716 u8 start_reg;
748 1717
749 if (!(data = kzalloc(sizeof(struct f71882fg_data), GFP_KERNEL))) 1718 data = kzalloc(sizeof(struct f71882fg_data), GFP_KERNEL);
1719 if (!data)
750 return -ENOMEM; 1720 return -ENOMEM;
751 1721
752 data->addr = platform_get_resource(pdev, IORESOURCE_IO, 0)->start; 1722 data->addr = platform_get_resource(pdev, IORESOURCE_IO, 0)->start;
1723 data->type = sio_data->type;
753 mutex_init(&data->update_lock); 1724 mutex_init(&data->update_lock);
754 platform_set_drvdata(pdev, data); 1725 platform_set_drvdata(pdev, data);
755 1726
756 /* Register sysfs interface files */ 1727 start_reg = f71882fg_read8(data, F71882FG_REG_START);
757 for (i = 0; i < ARRAY_SIZE(f71882fg_dev_attr); i++) { 1728 if (start_reg & 0x04) {
758 err = device_create_file(&pdev->dev, &f71882fg_dev_attr[i]); 1729 dev_warn(&pdev->dev, "Hardware monitor is powered down\n");
759 if (err) 1730 err = -ENODEV;
760 goto exit_unregister_sysfs; 1731 goto exit_free;
1732 }
1733 if (!(start_reg & 0x03)) {
1734 dev_warn(&pdev->dev, "Hardware monitoring not activated\n");
1735 err = -ENODEV;
1736 goto exit_free;
761 } 1737 }
762 1738
763 start_reg = f71882fg_read8(data, F71882FG_REG_START); 1739 data->pwm_enable = f71882fg_read8(data, F71882FG_REG_PWM_ENABLE);
1740 /* If it is a 71862 and the fan / pwm part is enabled sanity check
1741 the pwm settings */
1742 if (data->type == f71862fg && (start_reg & 0x02)) {
1743 if ((data->pwm_enable & 0x15) != 0x15) {
1744 dev_err(&pdev->dev,
1745 "Invalid (reserved) pwm settings: 0x%02x\n",
1746 (unsigned int)data->pwm_enable);
1747 err = -ENODEV;
1748 goto exit_free;
1749 }
1750 }
1751
1752 /* Register sysfs interface files */
1753 err = device_create_file(&pdev->dev, &dev_attr_name);
1754 if (err)
1755 goto exit_unregister_sysfs;
1756
764 if (start_reg & 0x01) { 1757 if (start_reg & 0x01) {
765 for (i = 0; i < ARRAY_SIZE(f71882fg_in_temp_attr); i++) { 1758 switch (data->type) {
766 err = device_create_file(&pdev->dev, 1759 case f71882fg:
767 &f71882fg_in_temp_attr[i].dev_attr); 1760 err = f71882fg_create_sysfs_files(pdev,
1761 f71882fg_in_temp_attr,
1762 ARRAY_SIZE(f71882fg_in_temp_attr));
768 if (err) 1763 if (err)
769 goto exit_unregister_sysfs; 1764 goto exit_unregister_sysfs;
1765 /* fall through! */
1766 case f71862fg:
1767 err = f71882fg_create_sysfs_files(pdev,
1768 f718x2fg_in_temp_attr,
1769 ARRAY_SIZE(f718x2fg_in_temp_attr));
1770 break;
1771 case f8000:
1772 err = f71882fg_create_sysfs_files(pdev,
1773 f8000_in_temp_attr,
1774 ARRAY_SIZE(f8000_in_temp_attr));
1775 break;
770 } 1776 }
1777 if (err)
1778 goto exit_unregister_sysfs;
771 } 1779 }
772 1780
773 if (start_reg & 0x02) { 1781 if (start_reg & 0x02) {
774 for (i = 0; i < ARRAY_SIZE(f71882fg_fan_attr); i++) { 1782 err = f71882fg_create_sysfs_files(pdev, fxxxx_fan_attr,
775 err = device_create_file(&pdev->dev, 1783 ARRAY_SIZE(fxxxx_fan_attr));
776 &f71882fg_fan_attr[i].dev_attr); 1784 if (err)
777 if (err) 1785 goto exit_unregister_sysfs;
778 goto exit_unregister_sysfs; 1786
1787 switch (data->type) {
1788 case f71862fg:
1789 err = f71882fg_create_sysfs_files(pdev,
1790 f71862fg_fan_attr,
1791 ARRAY_SIZE(f71862fg_fan_attr));
1792 break;
1793 case f71882fg:
1794 err = f71882fg_create_sysfs_files(pdev,
1795 f71882fg_fan_attr,
1796 ARRAY_SIZE(f71882fg_fan_attr));
1797 break;
1798 case f8000:
1799 err = f71882fg_create_sysfs_files(pdev,
1800 f8000_fan_attr,
1801 ARRAY_SIZE(f8000_fan_attr));
1802 break;
779 } 1803 }
1804 if (err)
1805 goto exit_unregister_sysfs;
1806
1807 for (i = 0; i < nr_fans; i++)
1808 dev_info(&pdev->dev, "Fan: %d is in %s mode\n", i + 1,
1809 (data->pwm_enable & (1 << 2 * i)) ?
1810 "duty-cycle" : "RPM");
780 } 1811 }
781 1812
782 data->hwmon_dev = hwmon_device_register(&pdev->dev); 1813 data->hwmon_dev = hwmon_device_register(&pdev->dev);
783 if (IS_ERR(data->hwmon_dev)) { 1814 if (IS_ERR(data->hwmon_dev)) {
784 err = PTR_ERR(data->hwmon_dev); 1815 err = PTR_ERR(data->hwmon_dev);
1816 data->hwmon_dev = NULL;
785 goto exit_unregister_sysfs; 1817 goto exit_unregister_sysfs;
786 } 1818 }
787 1819
788 return 0; 1820 return 0;
789 1821
790exit_unregister_sysfs: 1822exit_unregister_sysfs:
791 for (i = 0; i < ARRAY_SIZE(f71882fg_dev_attr); i++) 1823 f71882fg_remove(pdev); /* Will unregister the sysfs files for us */
792 device_remove_file(&pdev->dev, &f71882fg_dev_attr[i]); 1824 return err; /* f71882fg_remove() also frees our data */
793 1825exit_free:
794 for (i = 0; i < ARRAY_SIZE(f71882fg_in_temp_attr); i++)
795 device_remove_file(&pdev->dev,
796 &f71882fg_in_temp_attr[i].dev_attr);
797
798 for (i = 0; i < ARRAY_SIZE(f71882fg_fan_attr); i++)
799 device_remove_file(&pdev->dev, &f71882fg_fan_attr[i].dev_attr);
800
801 kfree(data); 1826 kfree(data);
802
803 return err; 1827 return err;
804} 1828}
805 1829
806static int __devexit f71882fg_remove(struct platform_device *pdev) 1830static int f71882fg_remove(struct platform_device *pdev)
807{ 1831{
808 int i; 1832 int i;
809 struct f71882fg_data *data = platform_get_drvdata(pdev); 1833 struct f71882fg_data *data = platform_get_drvdata(pdev);
810 1834
811 platform_set_drvdata(pdev, NULL); 1835 platform_set_drvdata(pdev, NULL);
812 hwmon_device_unregister(data->hwmon_dev); 1836 if (data->hwmon_dev)
1837 hwmon_device_unregister(data->hwmon_dev);
1838
1839 /* Note we are not looping over all attr arrays we have as the ones
1840 below are supersets of the ones skipped. */
1841 device_remove_file(&pdev->dev, &dev_attr_name);
813 1842
814 for (i = 0; i < ARRAY_SIZE(f71882fg_dev_attr); i++) 1843 for (i = 0; i < ARRAY_SIZE(f718x2fg_in_temp_attr); i++)
815 device_remove_file(&pdev->dev, &f71882fg_dev_attr[i]); 1844 device_remove_file(&pdev->dev,
1845 &f718x2fg_in_temp_attr[i].dev_attr);
816 1846
817 for (i = 0; i < ARRAY_SIZE(f71882fg_in_temp_attr); i++) 1847 for (i = 0; i < ARRAY_SIZE(f71882fg_in_temp_attr); i++)
818 device_remove_file(&pdev->dev, 1848 device_remove_file(&pdev->dev,
819 &f71882fg_in_temp_attr[i].dev_attr); 1849 &f71882fg_in_temp_attr[i].dev_attr);
820 1850
1851 for (i = 0; i < ARRAY_SIZE(fxxxx_fan_attr); i++)
1852 device_remove_file(&pdev->dev, &fxxxx_fan_attr[i].dev_attr);
1853
821 for (i = 0; i < ARRAY_SIZE(f71882fg_fan_attr); i++) 1854 for (i = 0; i < ARRAY_SIZE(f71882fg_fan_attr); i++)
822 device_remove_file(&pdev->dev, &f71882fg_fan_attr[i].dev_attr); 1855 device_remove_file(&pdev->dev, &f71882fg_fan_attr[i].dev_attr);
823 1856
1857 for (i = 0; i < ARRAY_SIZE(f8000_fan_attr); i++)
1858 device_remove_file(&pdev->dev, &f8000_fan_attr[i].dev_attr);
1859
824 kfree(data); 1860 kfree(data);
825 1861
826 return 0; 1862 return 0;
827} 1863}
828 1864
829static int __init f71882fg_find(int sioaddr, unsigned short *address) 1865static int __init f71882fg_find(int sioaddr, unsigned short *address,
1866 struct f71882fg_sio_data *sio_data)
830{ 1867{
831 int err = -ENODEV; 1868 int err = -ENODEV;
832 u16 devid; 1869 u16 devid;
833 u8 start_reg;
834 struct f71882fg_data data;
835 1870
836 superio_enter(sioaddr); 1871 superio_enter(sioaddr);
837 1872
@@ -842,7 +1877,17 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address)
842 } 1877 }
843 1878
844 devid = force_id ? force_id : superio_inw(sioaddr, SIO_REG_DEVID); 1879 devid = force_id ? force_id : superio_inw(sioaddr, SIO_REG_DEVID);
845 if (devid != SIO_F71882_ID) { 1880 switch (devid) {
1881 case SIO_F71862_ID:
1882 sio_data->type = f71862fg;
1883 break;
1884 case SIO_F71882_ID:
1885 sio_data->type = f71882fg;
1886 break;
1887 case SIO_F8000_ID:
1888 sio_data->type = f8000;
1889 break;
1890 default:
846 printk(KERN_INFO DRVNAME ": Unsupported Fintek device\n"); 1891 printk(KERN_INFO DRVNAME ": Unsupported Fintek device\n");
847 goto exit; 1892 goto exit;
848 } 1893 }
@@ -861,24 +1906,17 @@ static int __init f71882fg_find(int sioaddr, unsigned short *address)
861 } 1906 }
862 *address &= ~(REGION_LENGTH - 1); /* Ignore 3 LSB */ 1907 *address &= ~(REGION_LENGTH - 1); /* Ignore 3 LSB */
863 1908
864 data.addr = *address;
865 start_reg = f71882fg_read8(&data, F71882FG_REG_START);
866 if (!(start_reg & 0x03)) {
867 printk(KERN_WARNING DRVNAME
868 ": Hardware monitoring not activated\n");
869 goto exit;
870 }
871
872 err = 0; 1909 err = 0;
873 printk(KERN_INFO DRVNAME ": Found F71882FG chip at %#x, revision %d\n", 1910 printk(KERN_INFO DRVNAME ": Found %s chip at %#x, revision %d\n",
874 (unsigned int)*address, 1911 f71882fg_names[sio_data->type], (unsigned int)*address,
875 (int)superio_inb(sioaddr, SIO_REG_DEVREV)); 1912 (int)superio_inb(sioaddr, SIO_REG_DEVREV));
876exit: 1913exit:
877 superio_exit(sioaddr); 1914 superio_exit(sioaddr);
878 return err; 1915 return err;
879} 1916}
880 1917
881static int __init f71882fg_device_add(unsigned short address) 1918static int __init f71882fg_device_add(unsigned short address,
1919 const struct f71882fg_sio_data *sio_data)
882{ 1920{
883 struct resource res = { 1921 struct resource res = {
884 .start = address, 1922 .start = address,
@@ -892,12 +1930,23 @@ static int __init f71882fg_device_add(unsigned short address)
892 return -ENOMEM; 1930 return -ENOMEM;
893 1931
894 res.name = f71882fg_pdev->name; 1932 res.name = f71882fg_pdev->name;
1933 err = acpi_check_resource_conflict(&res);
1934 if (err)
1935 return err;
1936
895 err = platform_device_add_resources(f71882fg_pdev, &res, 1); 1937 err = platform_device_add_resources(f71882fg_pdev, &res, 1);
896 if (err) { 1938 if (err) {
897 printk(KERN_ERR DRVNAME ": Device resource addition failed\n"); 1939 printk(KERN_ERR DRVNAME ": Device resource addition failed\n");
898 goto exit_device_put; 1940 goto exit_device_put;
899 } 1941 }
900 1942
1943 err = platform_device_add_data(f71882fg_pdev, sio_data,
1944 sizeof(struct f71882fg_sio_data));
1945 if (err) {
1946 printk(KERN_ERR DRVNAME ": Platform data allocation failed\n");
1947 goto exit_device_put;
1948 }
1949
901 err = platform_device_add(f71882fg_pdev); 1950 err = platform_device_add(f71882fg_pdev);
902 if (err) { 1951 if (err) {
903 printk(KERN_ERR DRVNAME ": Device addition failed\n"); 1952 printk(KERN_ERR DRVNAME ": Device addition failed\n");
@@ -916,14 +1965,20 @@ static int __init f71882fg_init(void)
916{ 1965{
917 int err = -ENODEV; 1966 int err = -ENODEV;
918 unsigned short address; 1967 unsigned short address;
1968 struct f71882fg_sio_data sio_data;
1969
1970 memset(&sio_data, 0, sizeof(sio_data));
919 1971
920 if (f71882fg_find(0x2e, &address) && f71882fg_find(0x4e, &address)) 1972 if (f71882fg_find(0x2e, &address, &sio_data) &&
1973 f71882fg_find(0x4e, &address, &sio_data))
921 goto exit; 1974 goto exit;
922 1975
923 if ((err = platform_driver_register(&f71882fg_driver))) 1976 err = platform_driver_register(&f71882fg_driver);
1977 if (err)
924 goto exit; 1978 goto exit;
925 1979
926 if ((err = f71882fg_device_add(address))) 1980 err = f71882fg_device_add(address, &sio_data);
1981 if (err)
927 goto exit_driver; 1982 goto exit_driver;
928 1983
929 return 0; 1984 return 0;
@@ -941,7 +1996,7 @@ static void __exit f71882fg_exit(void)
941} 1996}
942 1997
943MODULE_DESCRIPTION("F71882FG Hardware Monitoring Driver"); 1998MODULE_DESCRIPTION("F71882FG Hardware Monitoring Driver");
944MODULE_AUTHOR("Hans Edgington (hans@edgington.nl)"); 1999MODULE_AUTHOR("Hans Edgington, Hans de Goede (hdegoede@redhat.com)");
945MODULE_LICENSE("GPL"); 2000MODULE_LICENSE("GPL");
946 2001
947module_init(f71882fg_init); 2002module_init(f71882fg_init);
diff --git a/drivers/hwmon/fschmd.c b/drivers/hwmon/fschmd.c
index 967170368933..d07f4ef75092 100644
--- a/drivers/hwmon/fschmd.c
+++ b/drivers/hwmon/fschmd.c
@@ -1,6 +1,6 @@
1/* fschmd.c 1/* fschmd.c
2 * 2 *
3 * Copyright (C) 2007 Hans de Goede <j.w.r.degoede@hhs.nl> 3 * Copyright (C) 2007,2008 Hans de Goede <hdegoede@redhat.com>
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -42,11 +42,20 @@
42#include <linux/mutex.h> 42#include <linux/mutex.h>
43#include <linux/sysfs.h> 43#include <linux/sysfs.h>
44#include <linux/dmi.h> 44#include <linux/dmi.h>
45#include <linux/fs.h>
46#include <linux/watchdog.h>
47#include <linux/miscdevice.h>
48#include <linux/uaccess.h>
49#include <linux/kref.h>
45 50
46/* Addresses to scan */ 51/* Addresses to scan */
47static const unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END }; 52static const unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END };
48 53
49/* Insmod parameters */ 54/* Insmod parameters */
55static int nowayout = WATCHDOG_NOWAYOUT;
56module_param(nowayout, int, 0);
57MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
58 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
50I2C_CLIENT_INSMOD_5(fscpos, fscher, fscscy, fschrc, fschmd); 59I2C_CLIENT_INSMOD_5(fscpos, fscher, fscscy, fschrc, fschmd);
51 60
52/* 61/*
@@ -63,19 +72,26 @@ I2C_CLIENT_INSMOD_5(fscpos, fscher, fscscy, fschrc, fschmd);
63#define FSCHMD_REG_EVENT_STATE 0x04 72#define FSCHMD_REG_EVENT_STATE 0x04
64#define FSCHMD_REG_CONTROL 0x05 73#define FSCHMD_REG_CONTROL 0x05
65 74
66#define FSCHMD_CONTROL_ALERT_LED_MASK 0x01 75#define FSCHMD_CONTROL_ALERT_LED 0x01
67 76
68/* watchdog (support to be implemented) */ 77/* watchdog */
69#define FSCHMD_REG_WDOG_PRESET 0x28 78#define FSCHMD_REG_WDOG_PRESET 0x28
70#define FSCHMD_REG_WDOG_STATE 0x23 79#define FSCHMD_REG_WDOG_STATE 0x23
71#define FSCHMD_REG_WDOG_CONTROL 0x21 80#define FSCHMD_REG_WDOG_CONTROL 0x21
72 81
82#define FSCHMD_WDOG_CONTROL_TRIGGER 0x10
83#define FSCHMD_WDOG_CONTROL_STARTED 0x10 /* the same as trigger */
84#define FSCHMD_WDOG_CONTROL_STOP 0x20
85#define FSCHMD_WDOG_CONTROL_RESOLUTION 0x40
86
87#define FSCHMD_WDOG_STATE_CARDRESET 0x02
88
73/* voltages, weird order is to keep the same order as the old drivers */ 89/* voltages, weird order is to keep the same order as the old drivers */
74static const u8 FSCHMD_REG_VOLT[3] = { 0x45, 0x42, 0x48 }; 90static const u8 FSCHMD_REG_VOLT[3] = { 0x45, 0x42, 0x48 };
75 91
76/* minimum pwm at which the fan is driven (pwm can by increased depending on 92/* minimum pwm at which the fan is driven (pwm can by increased depending on
77 the temp. Notice that for the scy some fans share there minimum speed. 93 the temp. Notice that for the scy some fans share there minimum speed.
78 Also notice that with the scy the sensor order is different then with the 94 Also notice that with the scy the sensor order is different than with the
79 other chips, this order was in the 2.4 driver and kept for consistency. */ 95 other chips, this order was in the 2.4 driver and kept for consistency. */
80static const u8 FSCHMD_REG_FAN_MIN[5][6] = { 96static const u8 FSCHMD_REG_FAN_MIN[5][6] = {
81 { 0x55, 0x65 }, /* pos */ 97 { 0x55, 0x65 }, /* pos */
@@ -115,8 +131,8 @@ static const u8 FSCHMD_REG_FAN_RIPPLE[5][6] = {
115static const int FSCHMD_NO_FAN_SENSORS[5] = { 3, 3, 6, 4, 5 }; 131static const int FSCHMD_NO_FAN_SENSORS[5] = { 3, 3, 6, 4, 5 };
116 132
117/* Fan status register bitmasks */ 133/* Fan status register bitmasks */
118#define FSCHMD_FAN_ALARM_MASK 0x04 /* called fault by FSC! */ 134#define FSCHMD_FAN_ALARM 0x04 /* called fault by FSC! */
119#define FSCHMD_FAN_NOT_PRESENT_MASK 0x08 /* not documented */ 135#define FSCHMD_FAN_NOT_PRESENT 0x08 /* not documented */
120 136
121 137
122/* actual temperature registers */ 138/* actual temperature registers */
@@ -158,14 +174,11 @@ static const u8 FSCHER_REG_TEMP_AUTOP2[] = { 0x75, 0x85, 0x95 }; */
158static const int FSCHMD_NO_TEMP_SENSORS[5] = { 3, 3, 4, 3, 5 }; 174static const int FSCHMD_NO_TEMP_SENSORS[5] = { 3, 3, 4, 3, 5 };
159 175
160/* temp status register bitmasks */ 176/* temp status register bitmasks */
161#define FSCHMD_TEMP_WORKING_MASK 0x01 177#define FSCHMD_TEMP_WORKING 0x01
162#define FSCHMD_TEMP_ALERT_MASK 0x02 178#define FSCHMD_TEMP_ALERT 0x02
163/* there only really is an alarm if the sensor is working and alert == 1 */ 179/* there only really is an alarm if the sensor is working and alert == 1 */
164#define FSCHMD_TEMP_ALARM_MASK \ 180#define FSCHMD_TEMP_ALARM_MASK \
165 (FSCHMD_TEMP_WORKING_MASK | FSCHMD_TEMP_ALERT_MASK) 181 (FSCHMD_TEMP_WORKING | FSCHMD_TEMP_ALERT)
166
167/* our driver name */
168#define FSCHMD_NAME "fschmd"
169 182
170/* 183/*
171 * Functions declarations 184 * Functions declarations
@@ -195,7 +208,7 @@ MODULE_DEVICE_TABLE(i2c, fschmd_id);
195static struct i2c_driver fschmd_driver = { 208static struct i2c_driver fschmd_driver = {
196 .class = I2C_CLASS_HWMON, 209 .class = I2C_CLASS_HWMON,
197 .driver = { 210 .driver = {
198 .name = FSCHMD_NAME, 211 .name = "fschmd",
199 }, 212 },
200 .probe = fschmd_probe, 213 .probe = fschmd_probe,
201 .remove = fschmd_remove, 214 .remove = fschmd_remove,
@@ -209,14 +222,26 @@ static struct i2c_driver fschmd_driver = {
209 */ 222 */
210 223
211struct fschmd_data { 224struct fschmd_data {
225 struct i2c_client *client;
212 struct device *hwmon_dev; 226 struct device *hwmon_dev;
213 struct mutex update_lock; 227 struct mutex update_lock;
228 struct mutex watchdog_lock;
229 struct list_head list; /* member of the watchdog_data_list */
230 struct kref kref;
231 struct miscdevice watchdog_miscdev;
214 int kind; 232 int kind;
233 unsigned long watchdog_is_open;
234 char watchdog_expect_close;
235 char watchdog_name[10]; /* must be unique to avoid sysfs conflict */
215 char valid; /* zero until following fields are valid */ 236 char valid; /* zero until following fields are valid */
216 unsigned long last_updated; /* in jiffies */ 237 unsigned long last_updated; /* in jiffies */
217 238
218 /* register values */ 239 /* register values */
240 u8 revision; /* chip revision */
219 u8 global_control; /* global control register */ 241 u8 global_control; /* global control register */
242 u8 watchdog_control; /* watchdog control register */
243 u8 watchdog_state; /* watchdog status register */
244 u8 watchdog_preset; /* watchdog counter preset on trigger val */
220 u8 volt[3]; /* 12, 5, battery voltage */ 245 u8 volt[3]; /* 12, 5, battery voltage */
221 u8 temp_act[5]; /* temperature */ 246 u8 temp_act[5]; /* temperature */
222 u8 temp_status[5]; /* status of sensor */ 247 u8 temp_status[5]; /* status of sensor */
@@ -228,11 +253,28 @@ struct fschmd_data {
228}; 253};
229 254
230/* Global variables to hold information read from special DMI tables, which are 255/* Global variables to hold information read from special DMI tables, which are
231 available on FSC machines with an fscher or later chip. */ 256 available on FSC machines with an fscher or later chip. There is no need to
257 protect these with a lock as they are only modified from our attach function
258 which always gets called with the i2c-core lock held and never accessed
259 before the attach function is done with them. */
232static int dmi_mult[3] = { 490, 200, 100 }; 260static int dmi_mult[3] = { 490, 200, 100 };
233static int dmi_offset[3] = { 0, 0, 0 }; 261static int dmi_offset[3] = { 0, 0, 0 };
234static int dmi_vref = -1; 262static int dmi_vref = -1;
235 263
264/* Somewhat ugly :( global data pointer list with all fschmd devices, so that
265 we can find our device data as when using misc_register there is no other
266 method to get to ones device data from the open fop. */
267static LIST_HEAD(watchdog_data_list);
268/* Note this lock not only protect list access, but also data.kref access */
269static DEFINE_MUTEX(watchdog_data_mutex);
270
271/* Release our data struct when we're detached from the i2c client *and* all
272 references to our watchdog device are released */
273static void fschmd_release_resources(struct kref *ref)
274{
275 struct fschmd_data *data = container_of(ref, struct fschmd_data, kref);
276 kfree(data);
277}
236 278
237/* 279/*
238 * Sysfs attr show / store functions 280 * Sysfs attr show / store functions
@@ -300,7 +342,7 @@ static ssize_t show_temp_fault(struct device *dev,
300 struct fschmd_data *data = fschmd_update_device(dev); 342 struct fschmd_data *data = fschmd_update_device(dev);
301 343
302 /* bit 0 set means sensor working ok, so no fault! */ 344 /* bit 0 set means sensor working ok, so no fault! */
303 if (data->temp_status[index] & FSCHMD_TEMP_WORKING_MASK) 345 if (data->temp_status[index] & FSCHMD_TEMP_WORKING)
304 return sprintf(buf, "0\n"); 346 return sprintf(buf, "0\n");
305 else 347 else
306 return sprintf(buf, "1\n"); 348 return sprintf(buf, "1\n");
@@ -385,7 +427,7 @@ static ssize_t show_fan_alarm(struct device *dev,
385 int index = to_sensor_dev_attr(devattr)->index; 427 int index = to_sensor_dev_attr(devattr)->index;
386 struct fschmd_data *data = fschmd_update_device(dev); 428 struct fschmd_data *data = fschmd_update_device(dev);
387 429
388 if (data->fan_status[index] & FSCHMD_FAN_ALARM_MASK) 430 if (data->fan_status[index] & FSCHMD_FAN_ALARM)
389 return sprintf(buf, "1\n"); 431 return sprintf(buf, "1\n");
390 else 432 else
391 return sprintf(buf, "0\n"); 433 return sprintf(buf, "0\n");
@@ -397,7 +439,7 @@ static ssize_t show_fan_fault(struct device *dev,
397 int index = to_sensor_dev_attr(devattr)->index; 439 int index = to_sensor_dev_attr(devattr)->index;
398 struct fschmd_data *data = fschmd_update_device(dev); 440 struct fschmd_data *data = fschmd_update_device(dev);
399 441
400 if (data->fan_status[index] & FSCHMD_FAN_NOT_PRESENT_MASK) 442 if (data->fan_status[index] & FSCHMD_FAN_NOT_PRESENT)
401 return sprintf(buf, "1\n"); 443 return sprintf(buf, "1\n");
402 else 444 else
403 return sprintf(buf, "0\n"); 445 return sprintf(buf, "0\n");
@@ -449,7 +491,7 @@ static ssize_t show_alert_led(struct device *dev,
449{ 491{
450 struct fschmd_data *data = fschmd_update_device(dev); 492 struct fschmd_data *data = fschmd_update_device(dev);
451 493
452 if (data->global_control & FSCHMD_CONTROL_ALERT_LED_MASK) 494 if (data->global_control & FSCHMD_CONTROL_ALERT_LED)
453 return sprintf(buf, "1\n"); 495 return sprintf(buf, "1\n");
454 else 496 else
455 return sprintf(buf, "0\n"); 497 return sprintf(buf, "0\n");
@@ -467,9 +509,9 @@ static ssize_t store_alert_led(struct device *dev,
467 reg = i2c_smbus_read_byte_data(to_i2c_client(dev), FSCHMD_REG_CONTROL); 509 reg = i2c_smbus_read_byte_data(to_i2c_client(dev), FSCHMD_REG_CONTROL);
468 510
469 if (v) 511 if (v)
470 reg |= FSCHMD_CONTROL_ALERT_LED_MASK; 512 reg |= FSCHMD_CONTROL_ALERT_LED;
471 else 513 else
472 reg &= ~FSCHMD_CONTROL_ALERT_LED_MASK; 514 reg &= ~FSCHMD_CONTROL_ALERT_LED;
473 515
474 i2c_smbus_write_byte_data(to_i2c_client(dev), FSCHMD_REG_CONTROL, reg); 516 i2c_smbus_write_byte_data(to_i2c_client(dev), FSCHMD_REG_CONTROL, reg);
475 517
@@ -551,7 +593,265 @@ static struct sensor_device_attribute fschmd_fan_attr[] = {
551 593
552 594
553/* 595/*
554 * Real code 596 * Watchdog routines
597 */
598
599static int watchdog_set_timeout(struct fschmd_data *data, int timeout)
600{
601 int ret, resolution;
602 int kind = data->kind + 1; /* 0-x array index -> 1-x module param */
603
604 /* 2 second or 60 second resolution? */
605 if (timeout <= 510 || kind == fscpos || kind == fscscy)
606 resolution = 2;
607 else
608 resolution = 60;
609
610 if (timeout < resolution || timeout > (resolution * 255))
611 return -EINVAL;
612
613 mutex_lock(&data->watchdog_lock);
614 if (!data->client) {
615 ret = -ENODEV;
616 goto leave;
617 }
618
619 if (resolution == 2)
620 data->watchdog_control &= ~FSCHMD_WDOG_CONTROL_RESOLUTION;
621 else
622 data->watchdog_control |= FSCHMD_WDOG_CONTROL_RESOLUTION;
623
624 data->watchdog_preset = DIV_ROUND_UP(timeout, resolution);
625
626 /* Write new timeout value */
627 i2c_smbus_write_byte_data(data->client, FSCHMD_REG_WDOG_PRESET,
628 data->watchdog_preset);
629 /* Write new control register, do not trigger! */
630 i2c_smbus_write_byte_data(data->client, FSCHMD_REG_WDOG_CONTROL,
631 data->watchdog_control & ~FSCHMD_WDOG_CONTROL_TRIGGER);
632
633 ret = data->watchdog_preset * resolution;
634
635leave:
636 mutex_unlock(&data->watchdog_lock);
637 return ret;
638}
639
640static int watchdog_get_timeout(struct fschmd_data *data)
641{
642 int timeout;
643
644 mutex_lock(&data->watchdog_lock);
645 if (data->watchdog_control & FSCHMD_WDOG_CONTROL_RESOLUTION)
646 timeout = data->watchdog_preset * 60;
647 else
648 timeout = data->watchdog_preset * 2;
649 mutex_unlock(&data->watchdog_lock);
650
651 return timeout;
652}
653
654static int watchdog_trigger(struct fschmd_data *data)
655{
656 int ret = 0;
657
658 mutex_lock(&data->watchdog_lock);
659 if (!data->client) {
660 ret = -ENODEV;
661 goto leave;
662 }
663
664 data->watchdog_control |= FSCHMD_WDOG_CONTROL_TRIGGER;
665 i2c_smbus_write_byte_data(data->client, FSCHMD_REG_WDOG_CONTROL,
666 data->watchdog_control);
667leave:
668 mutex_unlock(&data->watchdog_lock);
669 return ret;
670}
671
672static int watchdog_stop(struct fschmd_data *data)
673{
674 int ret = 0;
675
676 mutex_lock(&data->watchdog_lock);
677 if (!data->client) {
678 ret = -ENODEV;
679 goto leave;
680 }
681
682 data->watchdog_control &= ~FSCHMD_WDOG_CONTROL_STARTED;
683 /* Don't store the stop flag in our watchdog control register copy, as
684 its a write only bit (read always returns 0) */
685 i2c_smbus_write_byte_data(data->client, FSCHMD_REG_WDOG_CONTROL,
686 data->watchdog_control | FSCHMD_WDOG_CONTROL_STOP);
687leave:
688 mutex_unlock(&data->watchdog_lock);
689 return ret;
690}
691
692static int watchdog_open(struct inode *inode, struct file *filp)
693{
694 struct fschmd_data *pos, *data = NULL;
695
696 /* We get called from drivers/char/misc.c with misc_mtx hold, and we
697 call misc_register() from fschmd_probe() with watchdog_data_mutex
698 hold, as misc_register() takes the misc_mtx lock, this is a possible
699 deadlock, so we use mutex_trylock here. */
700 if (!mutex_trylock(&watchdog_data_mutex))
701 return -ERESTARTSYS;
702 list_for_each_entry(pos, &watchdog_data_list, list) {
703 if (pos->watchdog_miscdev.minor == iminor(inode)) {
704 data = pos;
705 break;
706 }
707 }
708 /* Note we can never not have found data, so we don't check for this */
709 kref_get(&data->kref);
710 mutex_unlock(&watchdog_data_mutex);
711
712 if (test_and_set_bit(0, &data->watchdog_is_open))
713 return -EBUSY;
714
715 /* Start the watchdog */
716 watchdog_trigger(data);
717 filp->private_data = data;
718
719 return nonseekable_open(inode, filp);
720}
721
722static int watchdog_release(struct inode *inode, struct file *filp)
723{
724 struct fschmd_data *data = filp->private_data;
725
726 if (data->watchdog_expect_close) {
727 watchdog_stop(data);
728 data->watchdog_expect_close = 0;
729 } else {
730 watchdog_trigger(data);
731 dev_crit(&data->client->dev,
732 "unexpected close, not stopping watchdog!\n");
733 }
734
735 clear_bit(0, &data->watchdog_is_open);
736
737 mutex_lock(&watchdog_data_mutex);
738 kref_put(&data->kref, fschmd_release_resources);
739 mutex_unlock(&watchdog_data_mutex);
740
741 return 0;
742}
743
744static ssize_t watchdog_write(struct file *filp, const char __user *buf,
745 size_t count, loff_t *offset)
746{
747 size_t ret;
748 struct fschmd_data *data = filp->private_data;
749
750 if (count) {
751 if (!nowayout) {
752 size_t i;
753
754 /* Clear it in case it was set with a previous write */
755 data->watchdog_expect_close = 0;
756
757 for (i = 0; i != count; i++) {
758 char c;
759 if (get_user(c, buf + i))
760 return -EFAULT;
761 if (c == 'V')
762 data->watchdog_expect_close = 1;
763 }
764 }
765 ret = watchdog_trigger(data);
766 if (ret < 0)
767 return ret;
768 }
769 return count;
770}
771
772static int watchdog_ioctl(struct inode *inode, struct file *filp,
773 unsigned int cmd, unsigned long arg)
774{
775 static struct watchdog_info ident = {
776 .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT |
777 WDIOF_CARDRESET,
778 .identity = "FSC watchdog"
779 };
780 int i, ret = 0;
781 struct fschmd_data *data = filp->private_data;
782
783 switch (cmd) {
784 case WDIOC_GETSUPPORT:
785 ident.firmware_version = data->revision;
786 if (!nowayout)
787 ident.options |= WDIOF_MAGICCLOSE;
788 if (copy_to_user((void __user *)arg, &ident, sizeof(ident)))
789 ret = -EFAULT;
790 break;
791
792 case WDIOC_GETSTATUS:
793 ret = put_user(0, (int __user *)arg);
794 break;
795
796 case WDIOC_GETBOOTSTATUS:
797 if (data->watchdog_state & FSCHMD_WDOG_STATE_CARDRESET)
798 ret = put_user(WDIOF_CARDRESET, (int __user *)arg);
799 else
800 ret = put_user(0, (int __user *)arg);
801 break;
802
803 case WDIOC_KEEPALIVE:
804 ret = watchdog_trigger(data);
805 break;
806
807 case WDIOC_GETTIMEOUT:
808 i = watchdog_get_timeout(data);
809 ret = put_user(i, (int __user *)arg);
810 break;
811
812 case WDIOC_SETTIMEOUT:
813 if (get_user(i, (int __user *)arg)) {
814 ret = -EFAULT;
815 break;
816 }
817 ret = watchdog_set_timeout(data, i);
818 if (ret > 0)
819 ret = put_user(ret, (int __user *)arg);
820 break;
821
822 case WDIOC_SETOPTIONS:
823 if (get_user(i, (int __user *)arg)) {
824 ret = -EFAULT;
825 break;
826 }
827
828 if (i & WDIOS_DISABLECARD)
829 ret = watchdog_stop(data);
830 else if (i & WDIOS_ENABLECARD)
831 ret = watchdog_trigger(data);
832 else
833 ret = -EINVAL;
834
835 break;
836 default:
837 ret = -ENOTTY;
838 }
839
840 return ret;
841}
842
843static struct file_operations watchdog_fops = {
844 .owner = THIS_MODULE,
845 .llseek = no_llseek,
846 .open = watchdog_open,
847 .release = watchdog_release,
848 .write = watchdog_write,
849 .ioctl = watchdog_ioctl,
850};
851
852
853/*
854 * Detect, register, unregister and update device functions
555 */ 855 */
556 856
557/* DMI decode routine to read voltage scaling factors from special DMI tables, 857/* DMI decode routine to read voltage scaling factors from special DMI tables,
@@ -661,9 +961,9 @@ static int fschmd_probe(struct i2c_client *client,
661 const struct i2c_device_id *id) 961 const struct i2c_device_id *id)
662{ 962{
663 struct fschmd_data *data; 963 struct fschmd_data *data;
664 u8 revision;
665 const char * const names[5] = { "Poseidon", "Hermes", "Scylla", 964 const char * const names[5] = { "Poseidon", "Hermes", "Scylla",
666 "Heracles", "Heimdall" }; 965 "Heracles", "Heimdall" };
966 const int watchdog_minors[] = { WATCHDOG_MINOR, 212, 213, 214, 215 };
667 int i, err; 967 int i, err;
668 enum chips kind = id->driver_data; 968 enum chips kind = id->driver_data;
669 969
@@ -673,6 +973,13 @@ static int fschmd_probe(struct i2c_client *client,
673 973
674 i2c_set_clientdata(client, data); 974 i2c_set_clientdata(client, data);
675 mutex_init(&data->update_lock); 975 mutex_init(&data->update_lock);
976 mutex_init(&data->watchdog_lock);
977 INIT_LIST_HEAD(&data->list);
978 kref_init(&data->kref);
979 /* Store client pointer in our data struct for watchdog usage
980 (where the client is found through a data ptr instead of the
981 otherway around) */
982 data->client = client;
676 983
677 if (kind == fscpos) { 984 if (kind == fscpos) {
678 /* The Poseidon has hardwired temp limits, fill these 985 /* The Poseidon has hardwired temp limits, fill these
@@ -683,16 +990,27 @@ static int fschmd_probe(struct i2c_client *client,
683 } 990 }
684 991
685 /* Read the special DMI table for fscher and newer chips */ 992 /* Read the special DMI table for fscher and newer chips */
686 if (kind == fscher || kind >= fschrc) { 993 if ((kind == fscher || kind >= fschrc) && dmi_vref == -1) {
687 dmi_walk(fschmd_dmi_decode); 994 dmi_walk(fschmd_dmi_decode);
688 if (dmi_vref == -1) { 995 if (dmi_vref == -1) {
689 printk(KERN_WARNING FSCHMD_NAME 996 dev_warn(&client->dev,
690 ": Couldn't get voltage scaling factors from " 997 "Couldn't get voltage scaling factors from "
691 "BIOS DMI table, using builtin defaults\n"); 998 "BIOS DMI table, using builtin defaults\n");
692 dmi_vref = 33; 999 dmi_vref = 33;
693 } 1000 }
694 } 1001 }
695 1002
1003 /* Read in some never changing registers */
1004 data->revision = i2c_smbus_read_byte_data(client, FSCHMD_REG_REVISION);
1005 data->global_control = i2c_smbus_read_byte_data(client,
1006 FSCHMD_REG_CONTROL);
1007 data->watchdog_control = i2c_smbus_read_byte_data(client,
1008 FSCHMD_REG_WDOG_CONTROL);
1009 data->watchdog_state = i2c_smbus_read_byte_data(client,
1010 FSCHMD_REG_WDOG_STATE);
1011 data->watchdog_preset = i2c_smbus_read_byte_data(client,
1012 FSCHMD_REG_WDOG_PRESET);
1013
696 /* i2c kind goes from 1-5, we want from 0-4 to address arrays */ 1014 /* i2c kind goes from 1-5, we want from 0-4 to address arrays */
697 data->kind = kind - 1; 1015 data->kind = kind - 1;
698 1016
@@ -735,9 +1053,43 @@ static int fschmd_probe(struct i2c_client *client,
735 goto exit_detach; 1053 goto exit_detach;
736 } 1054 }
737 1055
738 revision = i2c_smbus_read_byte_data(client, FSCHMD_REG_REVISION); 1056 /* We take the data_mutex lock early so that watchdog_open() cannot
739 printk(KERN_INFO FSCHMD_NAME ": Detected FSC %s chip, revision: %d\n", 1057 run when misc_register() has completed, but we've not yet added
740 names[data->kind], (int) revision); 1058 our data to the watchdog_data_list (and set the default timeout) */
1059 mutex_lock(&watchdog_data_mutex);
1060 for (i = 0; i < ARRAY_SIZE(watchdog_minors); i++) {
1061 /* Register our watchdog part */
1062 snprintf(data->watchdog_name, sizeof(data->watchdog_name),
1063 "watchdog%c", (i == 0) ? '\0' : ('0' + i));
1064 data->watchdog_miscdev.name = data->watchdog_name;
1065 data->watchdog_miscdev.fops = &watchdog_fops;
1066 data->watchdog_miscdev.minor = watchdog_minors[i];
1067 err = misc_register(&data->watchdog_miscdev);
1068 if (err == -EBUSY)
1069 continue;
1070 if (err) {
1071 data->watchdog_miscdev.minor = 0;
1072 dev_err(&client->dev,
1073 "Registering watchdog chardev: %d\n", err);
1074 break;
1075 }
1076
1077 list_add(&data->list, &watchdog_data_list);
1078 watchdog_set_timeout(data, 60);
1079 dev_info(&client->dev,
1080 "Registered watchdog chardev major 10, minor: %d\n",
1081 watchdog_minors[i]);
1082 break;
1083 }
1084 if (i == ARRAY_SIZE(watchdog_minors)) {
1085 data->watchdog_miscdev.minor = 0;
1086 dev_warn(&client->dev, "Couldn't register watchdog chardev "
1087 "(due to no free minor)\n");
1088 }
1089 mutex_unlock(&watchdog_data_mutex);
1090
1091 dev_info(&client->dev, "Detected FSC %s chip, revision: %d\n",
1092 names[data->kind], (int) data->revision);
741 1093
742 return 0; 1094 return 0;
743 1095
@@ -751,6 +1103,24 @@ static int fschmd_remove(struct i2c_client *client)
751 struct fschmd_data *data = i2c_get_clientdata(client); 1103 struct fschmd_data *data = i2c_get_clientdata(client);
752 int i; 1104 int i;
753 1105
1106 /* Unregister the watchdog (if registered) */
1107 if (data->watchdog_miscdev.minor) {
1108 misc_deregister(&data->watchdog_miscdev);
1109 if (data->watchdog_is_open) {
1110 dev_warn(&client->dev,
1111 "i2c client detached with watchdog open! "
1112 "Stopping watchdog.\n");
1113 watchdog_stop(data);
1114 }
1115 mutex_lock(&watchdog_data_mutex);
1116 list_del(&data->list);
1117 mutex_unlock(&watchdog_data_mutex);
1118 /* Tell the watchdog code the client is gone */
1119 mutex_lock(&data->watchdog_lock);
1120 data->client = NULL;
1121 mutex_unlock(&data->watchdog_lock);
1122 }
1123
754 /* Check if registered in case we're called from fschmd_detect 1124 /* Check if registered in case we're called from fschmd_detect
755 to cleanup after an error */ 1125 to cleanup after an error */
756 if (data->hwmon_dev) 1126 if (data->hwmon_dev)
@@ -765,7 +1135,10 @@ static int fschmd_remove(struct i2c_client *client)
765 device_remove_file(&client->dev, 1135 device_remove_file(&client->dev,
766 &fschmd_fan_attr[i].dev_attr); 1136 &fschmd_fan_attr[i].dev_attr);
767 1137
768 kfree(data); 1138 mutex_lock(&watchdog_data_mutex);
1139 kref_put(&data->kref, fschmd_release_resources);
1140 mutex_unlock(&watchdog_data_mutex);
1141
769 return 0; 1142 return 0;
770} 1143}
771 1144
@@ -798,7 +1171,7 @@ static struct fschmd_data *fschmd_update_device(struct device *dev)
798 data->temp_act[i] < data->temp_max[i]) 1171 data->temp_act[i] < data->temp_max[i])
799 i2c_smbus_write_byte_data(client, 1172 i2c_smbus_write_byte_data(client,
800 FSCHMD_REG_TEMP_STATE[data->kind][i], 1173 FSCHMD_REG_TEMP_STATE[data->kind][i],
801 FSCHMD_TEMP_ALERT_MASK); 1174 FSCHMD_TEMP_ALERT);
802 } 1175 }
803 1176
804 for (i = 0; i < FSCHMD_NO_FAN_SENSORS[data->kind]; i++) { 1177 for (i = 0; i < FSCHMD_NO_FAN_SENSORS[data->kind]; i++) {
@@ -816,28 +1189,17 @@ static struct fschmd_data *fschmd_update_device(struct device *dev)
816 FSCHMD_REG_FAN_MIN[data->kind][i]); 1189 FSCHMD_REG_FAN_MIN[data->kind][i]);
817 1190
818 /* reset fan status if speed is back to > 0 */ 1191 /* reset fan status if speed is back to > 0 */
819 if ((data->fan_status[i] & FSCHMD_FAN_ALARM_MASK) && 1192 if ((data->fan_status[i] & FSCHMD_FAN_ALARM) &&
820 data->fan_act[i]) 1193 data->fan_act[i])
821 i2c_smbus_write_byte_data(client, 1194 i2c_smbus_write_byte_data(client,
822 FSCHMD_REG_FAN_STATE[data->kind][i], 1195 FSCHMD_REG_FAN_STATE[data->kind][i],
823 FSCHMD_FAN_ALARM_MASK); 1196 FSCHMD_FAN_ALARM);
824 } 1197 }
825 1198
826 for (i = 0; i < 3; i++) 1199 for (i = 0; i < 3; i++)
827 data->volt[i] = i2c_smbus_read_byte_data(client, 1200 data->volt[i] = i2c_smbus_read_byte_data(client,
828 FSCHMD_REG_VOLT[i]); 1201 FSCHMD_REG_VOLT[i]);
829 1202
830 data->global_control = i2c_smbus_read_byte_data(client,
831 FSCHMD_REG_CONTROL);
832
833 /* To be implemented in the future
834 data->watchdog[0] = i2c_smbus_read_byte_data(client,
835 FSCHMD_REG_WDOG_PRESET);
836 data->watchdog[1] = i2c_smbus_read_byte_data(client,
837 FSCHMD_REG_WDOG_STATE);
838 data->watchdog[2] = i2c_smbus_read_byte_data(client,
839 FSCHMD_REG_WDOG_CONTROL); */
840
841 data->last_updated = jiffies; 1203 data->last_updated = jiffies;
842 data->valid = 1; 1204 data->valid = 1;
843 } 1205 }
@@ -857,7 +1219,7 @@ static void __exit fschmd_exit(void)
857 i2c_del_driver(&fschmd_driver); 1219 i2c_del_driver(&fschmd_driver);
858} 1220}
859 1221
860MODULE_AUTHOR("Hans de Goede <j.w.r.degoede@hhs.nl>"); 1222MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
861MODULE_DESCRIPTION("FSC Poseidon, Hermes, Scylla, Heracles and " 1223MODULE_DESCRIPTION("FSC Poseidon, Hermes, Scylla, Heracles and "
862 "Heimdall driver"); 1224 "Heimdall driver");
863MODULE_LICENSE("GPL"); 1225MODULE_LICENSE("GPL");
diff --git a/drivers/hwmon/hp_accel.c b/drivers/hwmon/hp_accel.c
new file mode 100644
index 000000000000..03705240000f
--- /dev/null
+++ b/drivers/hwmon/hp_accel.c
@@ -0,0 +1,334 @@
1/*
2 * hp_accel.c - Interface between LIS3LV02DL driver and HP ACPI BIOS
3 *
4 * Copyright (C) 2007-2008 Yan Burman
5 * Copyright (C) 2008 Eric Piel
6 * Copyright (C) 2008-2009 Pavel Machek
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#include <linux/kernel.h>
24#include <linux/init.h>
25#include <linux/dmi.h>
26#include <linux/module.h>
27#include <linux/types.h>
28#include <linux/platform_device.h>
29#include <linux/interrupt.h>
30#include <linux/input.h>
31#include <linux/kthread.h>
32#include <linux/semaphore.h>
33#include <linux/delay.h>
34#include <linux/wait.h>
35#include <linux/poll.h>
36#include <linux/freezer.h>
37#include <linux/version.h>
38#include <linux/uaccess.h>
39#include <linux/leds.h>
40#include <acpi/acpi_drivers.h>
41#include <asm/atomic.h>
42#include "lis3lv02d.h"
43
44#define DRIVER_NAME "lis3lv02d"
45#define ACPI_MDPS_CLASS "accelerometer"
46
47/* Delayed LEDs infrastructure ------------------------------------ */
48
49/* Special LED class that can defer work */
50struct delayed_led_classdev {
51 struct led_classdev led_classdev;
52 struct work_struct work;
53 enum led_brightness new_brightness;
54
55 unsigned int led; /* For driver */
56 void (*set_brightness)(struct delayed_led_classdev *data, enum led_brightness value);
57};
58
59static inline void delayed_set_status_worker(struct work_struct *work)
60{
61 struct delayed_led_classdev *data =
62 container_of(work, struct delayed_led_classdev, work);
63
64 data->set_brightness(data, data->new_brightness);
65}
66
67static inline void delayed_sysfs_set(struct led_classdev *led_cdev,
68 enum led_brightness brightness)
69{
70 struct delayed_led_classdev *data = container_of(led_cdev,
71 struct delayed_led_classdev, led_classdev);
72 data->new_brightness = brightness;
73 schedule_work(&data->work);
74}
75
76/* HP-specific accelerometer driver ------------------------------------ */
77
78/* For automatic insertion of the module */
79static struct acpi_device_id lis3lv02d_device_ids[] = {
80 {"HPQ0004", 0}, /* HP Mobile Data Protection System PNP */
81 {"", 0},
82};
83MODULE_DEVICE_TABLE(acpi, lis3lv02d_device_ids);
84
85
86/**
87 * lis3lv02d_acpi_init - ACPI _INI method: initialize the device.
88 * @handle: the handle of the device
89 *
90 * Returns AE_OK on success.
91 */
92acpi_status lis3lv02d_acpi_init(acpi_handle handle)
93{
94 return acpi_evaluate_object(handle, METHOD_NAME__INI, NULL, NULL);
95}
96
97/**
98 * lis3lv02d_acpi_read - ACPI ALRD method: read a register
99 * @handle: the handle of the device
100 * @reg: the register to read
101 * @ret: result of the operation
102 *
103 * Returns AE_OK on success.
104 */
105acpi_status lis3lv02d_acpi_read(acpi_handle handle, int reg, u8 *ret)
106{
107 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
108 struct acpi_object_list args = { 1, &arg0 };
109 unsigned long long lret;
110 acpi_status status;
111
112 arg0.integer.value = reg;
113
114 status = acpi_evaluate_integer(handle, "ALRD", &args, &lret);
115 *ret = lret;
116 return status;
117}
118
119/**
120 * lis3lv02d_acpi_write - ACPI ALWR method: write to a register
121 * @handle: the handle of the device
122 * @reg: the register to write to
123 * @val: the value to write
124 *
125 * Returns AE_OK on success.
126 */
127acpi_status lis3lv02d_acpi_write(acpi_handle handle, int reg, u8 val)
128{
129 unsigned long long ret; /* Not used when writting */
130 union acpi_object in_obj[2];
131 struct acpi_object_list args = { 2, in_obj };
132
133 in_obj[0].type = ACPI_TYPE_INTEGER;
134 in_obj[0].integer.value = reg;
135 in_obj[1].type = ACPI_TYPE_INTEGER;
136 in_obj[1].integer.value = val;
137
138 return acpi_evaluate_integer(handle, "ALWR", &args, &ret);
139}
140
141static int lis3lv02d_dmi_matched(const struct dmi_system_id *dmi)
142{
143 adev.ac = *((struct axis_conversion *)dmi->driver_data);
144 printk(KERN_INFO DRIVER_NAME ": hardware type %s found.\n", dmi->ident);
145
146 return 1;
147}
148
149/* Represents, for each axis seen by userspace, the corresponding hw axis (+1).
150 * If the value is negative, the opposite of the hw value is used. */
151static struct axis_conversion lis3lv02d_axis_normal = {1, 2, 3};
152static struct axis_conversion lis3lv02d_axis_y_inverted = {1, -2, 3};
153static struct axis_conversion lis3lv02d_axis_x_inverted = {-1, 2, 3};
154static struct axis_conversion lis3lv02d_axis_z_inverted = {1, 2, -3};
155static struct axis_conversion lis3lv02d_axis_xy_rotated_left = {-2, 1, 3};
156static struct axis_conversion lis3lv02d_axis_xy_swap_inverted = {-2, -1, 3};
157
158#define AXIS_DMI_MATCH(_ident, _name, _axis) { \
159 .ident = _ident, \
160 .callback = lis3lv02d_dmi_matched, \
161 .matches = { \
162 DMI_MATCH(DMI_PRODUCT_NAME, _name) \
163 }, \
164 .driver_data = &lis3lv02d_axis_##_axis \
165}
166static struct dmi_system_id lis3lv02d_dmi_ids[] = {
167 /* product names are truncated to match all kinds of a same model */
168 AXIS_DMI_MATCH("NC64x0", "HP Compaq nc64", x_inverted),
169 AXIS_DMI_MATCH("NC84x0", "HP Compaq nc84", z_inverted),
170 AXIS_DMI_MATCH("NX9420", "HP Compaq nx9420", x_inverted),
171 AXIS_DMI_MATCH("NW9440", "HP Compaq nw9440", x_inverted),
172 AXIS_DMI_MATCH("NC2510", "HP Compaq 2510", y_inverted),
173 AXIS_DMI_MATCH("NC8510", "HP Compaq 8510", xy_swap_inverted),
174 AXIS_DMI_MATCH("HP2133", "HP 2133", xy_rotated_left),
175 { NULL, }
176/* Laptop models without axis info (yet):
177 * "NC651xx" "HP Compaq 651"
178 * "NC671xx" "HP Compaq 671"
179 * "NC6910" "HP Compaq 6910"
180 * HP Compaq 8710x Notebook PC / Mobile Workstation
181 * "NC2400" "HP Compaq nc2400"
182 * "NX74x0" "HP Compaq nx74"
183 * "NX6325" "HP Compaq nx6325"
184 * "NC4400" "HP Compaq nc4400"
185 */
186};
187
188static void hpled_set(struct delayed_led_classdev *led_cdev, enum led_brightness value)
189{
190 acpi_handle handle = adev.device->handle;
191 unsigned long long ret; /* Not used when writing */
192 union acpi_object in_obj[1];
193 struct acpi_object_list args = { 1, in_obj };
194
195 in_obj[0].type = ACPI_TYPE_INTEGER;
196 in_obj[0].integer.value = !!value;
197
198 acpi_evaluate_integer(handle, "ALED", &args, &ret);
199}
200
201static struct delayed_led_classdev hpled_led = {
202 .led_classdev = {
203 .name = "hp::hddprotect",
204 .default_trigger = "none",
205 .brightness_set = delayed_sysfs_set,
206 .flags = LED_CORE_SUSPENDRESUME,
207 },
208 .set_brightness = hpled_set,
209};
210
211static int lis3lv02d_add(struct acpi_device *device)
212{
213 u8 val;
214 int ret;
215
216 if (!device)
217 return -EINVAL;
218
219 adev.device = device;
220 adev.init = lis3lv02d_acpi_init;
221 adev.read = lis3lv02d_acpi_read;
222 adev.write = lis3lv02d_acpi_write;
223 strcpy(acpi_device_name(device), DRIVER_NAME);
224 strcpy(acpi_device_class(device), ACPI_MDPS_CLASS);
225 device->driver_data = &adev;
226
227 lis3lv02d_acpi_read(device->handle, WHO_AM_I, &val);
228 if ((val != LIS3LV02DL_ID) && (val != LIS302DL_ID)) {
229 printk(KERN_ERR DRIVER_NAME
230 ": Accelerometer chip not LIS3LV02D{L,Q}\n");
231 }
232
233 /* If possible use a "standard" axes order */
234 if (dmi_check_system(lis3lv02d_dmi_ids) == 0) {
235 printk(KERN_INFO DRIVER_NAME ": laptop model unknown, "
236 "using default axes configuration\n");
237 adev.ac = lis3lv02d_axis_normal;
238 }
239
240 INIT_WORK(&hpled_led.work, delayed_set_status_worker);
241 ret = led_classdev_register(NULL, &hpled_led.led_classdev);
242 if (ret)
243 return ret;
244
245 ret = lis3lv02d_init_device(&adev);
246 if (ret) {
247 flush_work(&hpled_led.work);
248 led_classdev_unregister(&hpled_led.led_classdev);
249 return ret;
250 }
251
252 return ret;
253}
254
255static int lis3lv02d_remove(struct acpi_device *device, int type)
256{
257 if (!device)
258 return -EINVAL;
259
260 lis3lv02d_joystick_disable();
261 lis3lv02d_poweroff(device->handle);
262
263 flush_work(&hpled_led.work);
264 led_classdev_unregister(&hpled_led.led_classdev);
265
266 return lis3lv02d_remove_fs();
267}
268
269
270#ifdef CONFIG_PM
271static int lis3lv02d_suspend(struct acpi_device *device, pm_message_t state)
272{
273 /* make sure the device is off when we suspend */
274 lis3lv02d_poweroff(device->handle);
275 return 0;
276}
277
278static int lis3lv02d_resume(struct acpi_device *device)
279{
280 /* put back the device in the right state (ACPI might turn it on) */
281 mutex_lock(&adev.lock);
282 if (adev.usage > 0)
283 lis3lv02d_poweron(device->handle);
284 else
285 lis3lv02d_poweroff(device->handle);
286 mutex_unlock(&adev.lock);
287 return 0;
288}
289#else
290#define lis3lv02d_suspend NULL
291#define lis3lv02d_resume NULL
292#endif
293
294/* For the HP MDPS aka 3D Driveguard */
295static struct acpi_driver lis3lv02d_driver = {
296 .name = DRIVER_NAME,
297 .class = ACPI_MDPS_CLASS,
298 .ids = lis3lv02d_device_ids,
299 .ops = {
300 .add = lis3lv02d_add,
301 .remove = lis3lv02d_remove,
302 .suspend = lis3lv02d_suspend,
303 .resume = lis3lv02d_resume,
304 }
305};
306
307static int __init lis3lv02d_init_module(void)
308{
309 int ret;
310
311 if (acpi_disabled)
312 return -ENODEV;
313
314 ret = acpi_bus_register_driver(&lis3lv02d_driver);
315 if (ret < 0)
316 return ret;
317
318 printk(KERN_INFO DRIVER_NAME " driver loaded.\n");
319
320 return 0;
321}
322
323static void __exit lis3lv02d_exit_module(void)
324{
325 acpi_bus_unregister_driver(&lis3lv02d_driver);
326}
327
328MODULE_DESCRIPTION("Glue between LIS3LV02Dx and HP ACPI BIOS and support for disk protection LED.");
329MODULE_AUTHOR("Yan Burman, Eric Piel, Pavel Machek");
330MODULE_LICENSE("GPL");
331
332module_init(lis3lv02d_init_module);
333module_exit(lis3lv02d_exit_module);
334
diff --git a/drivers/hwmon/i5k_amb.c b/drivers/hwmon/i5k_amb.c
index 2ede9388096b..27d7f72a5f11 100644
--- a/drivers/hwmon/i5k_amb.c
+++ b/drivers/hwmon/i5k_amb.c
@@ -490,6 +490,13 @@ static unsigned long chipset_ids[] = {
490 0 490 0
491}; 491};
492 492
493static struct pci_device_id i5k_amb_ids[] __devinitdata = {
494 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5000_ERR) },
495 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5400_ERR) },
496 { 0, }
497};
498MODULE_DEVICE_TABLE(pci, i5k_amb_ids);
499
493static int __devinit i5k_amb_probe(struct platform_device *pdev) 500static int __devinit i5k_amb_probe(struct platform_device *pdev)
494{ 501{
495 struct i5k_amb_data *data; 502 struct i5k_amb_data *data;
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index b74c95735f95..95a99c590da2 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -14,6 +14,7 @@
14 IT8712F Super I/O chip w/LPC interface 14 IT8712F Super I/O chip w/LPC interface
15 IT8716F Super I/O chip w/LPC interface 15 IT8716F Super I/O chip w/LPC interface
16 IT8718F Super I/O chip w/LPC interface 16 IT8718F Super I/O chip w/LPC interface
17 IT8720F Super I/O chip w/LPC interface
17 IT8726F Super I/O chip w/LPC interface 18 IT8726F Super I/O chip w/LPC interface
18 Sis950 A clone of the IT8705F 19 Sis950 A clone of the IT8705F
19 20
@@ -48,11 +49,12 @@
48#include <linux/sysfs.h> 49#include <linux/sysfs.h>
49#include <linux/string.h> 50#include <linux/string.h>
50#include <linux/dmi.h> 51#include <linux/dmi.h>
52#include <linux/acpi.h>
51#include <asm/io.h> 53#include <asm/io.h>
52 54
53#define DRVNAME "it87" 55#define DRVNAME "it87"
54 56
55enum chips { it87, it8712, it8716, it8718 }; 57enum chips { it87, it8712, it8716, it8718, it8720 };
56 58
57static unsigned short force_id; 59static unsigned short force_id;
58module_param(force_id, ushort, 0); 60module_param(force_id, ushort, 0);
@@ -64,7 +66,10 @@ static struct platform_device *pdev;
64#define DEV 0x07 /* Register: Logical device select */ 66#define DEV 0x07 /* Register: Logical device select */
65#define VAL 0x2f /* The value to read/write */ 67#define VAL 0x2f /* The value to read/write */
66#define PME 0x04 /* The device with the fan registers in it */ 68#define PME 0x04 /* The device with the fan registers in it */
67#define GPIO 0x07 /* The device with the IT8718F VID value in it */ 69
70/* The device with the IT8718F/IT8720F VID value in it */
71#define GPIO 0x07
72
68#define DEVID 0x20 /* Register: Device ID */ 73#define DEVID 0x20 /* Register: Device ID */
69#define DEVREV 0x22 /* Register: Device Revision */ 74#define DEVREV 0x22 /* Register: Device Revision */
70 75
@@ -113,6 +118,7 @@ superio_exit(void)
113#define IT8705F_DEVID 0x8705 118#define IT8705F_DEVID 0x8705
114#define IT8716F_DEVID 0x8716 119#define IT8716F_DEVID 0x8716
115#define IT8718F_DEVID 0x8718 120#define IT8718F_DEVID 0x8718
121#define IT8720F_DEVID 0x8720
116#define IT8726F_DEVID 0x8726 122#define IT8726F_DEVID 0x8726
117#define IT87_ACT_REG 0x30 123#define IT87_ACT_REG 0x30
118#define IT87_BASE_REG 0x60 124#define IT87_BASE_REG 0x60
@@ -150,8 +156,8 @@ static int fix_pwm_polarity;
150#define IT87_REG_ALARM2 0x02 156#define IT87_REG_ALARM2 0x02
151#define IT87_REG_ALARM3 0x03 157#define IT87_REG_ALARM3 0x03
152 158
153/* The IT8718F has the VID value in a different register, in Super-I/O 159/* The IT8718F and IT8720F have the VID value in a different register, in
154 configuration space. */ 160 Super-I/O configuration space. */
155#define IT87_REG_VID 0x0a 161#define IT87_REG_VID 0x0a
156/* The IT8705F and IT8712F earlier than revision 0x08 use register 0x0b 162/* The IT8705F and IT8712F earlier than revision 0x08 use register 0x0b
157 for fan divisors. Later IT8712F revisions must use 16-bit tachometer 163 for fan divisors. Later IT8712F revisions must use 16-bit tachometer
@@ -282,7 +288,8 @@ static inline int has_16bit_fans(const struct it87_data *data)
282 return (data->type == it87 && data->revision >= 0x03) 288 return (data->type == it87 && data->revision >= 0x03)
283 || (data->type == it8712 && data->revision >= 0x08) 289 || (data->type == it8712 && data->revision >= 0x08)
284 || data->type == it8716 290 || data->type == it8716
285 || data->type == it8718; 291 || data->type == it8718
292 || data->type == it8720;
286} 293}
287 294
288static int it87_probe(struct platform_device *pdev); 295static int it87_probe(struct platform_device *pdev);
@@ -992,6 +999,9 @@ static int __init it87_find(unsigned short *address,
992 case IT8718F_DEVID: 999 case IT8718F_DEVID:
993 sio_data->type = it8718; 1000 sio_data->type = it8718;
994 break; 1001 break;
1002 case IT8720F_DEVID:
1003 sio_data->type = it8720;
1004 break;
995 case 0xffff: /* No device at all */ 1005 case 0xffff: /* No device at all */
996 goto exit; 1006 goto exit;
997 default: 1007 default:
@@ -1022,7 +1032,8 @@ static int __init it87_find(unsigned short *address,
1022 int reg; 1032 int reg;
1023 1033
1024 superio_select(GPIO); 1034 superio_select(GPIO);
1025 if (chip_type == it8718) 1035 if ((chip_type == it8718) ||
1036 (chip_type == it8720))
1026 sio_data->vid_value = superio_inb(IT87_SIO_VID_REG); 1037 sio_data->vid_value = superio_inb(IT87_SIO_VID_REG);
1027 1038
1028 reg = superio_inb(IT87_SIO_PINX2_REG); 1039 reg = superio_inb(IT87_SIO_PINX2_REG);
@@ -1068,6 +1079,7 @@ static int __devinit it87_probe(struct platform_device *pdev)
1068 "it8712", 1079 "it8712",
1069 "it8716", 1080 "it8716",
1070 "it8718", 1081 "it8718",
1082 "it8720",
1071 }; 1083 };
1072 1084
1073 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 1085 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
@@ -1226,7 +1238,7 @@ static int __devinit it87_probe(struct platform_device *pdev)
1226 } 1238 }
1227 1239
1228 if (data->type == it8712 || data->type == it8716 1240 if (data->type == it8712 || data->type == it8716
1229 || data->type == it8718) { 1241 || data->type == it8718 || data->type == it8720) {
1230 data->vrm = vid_which_vrm(); 1242 data->vrm = vid_which_vrm();
1231 /* VID reading from Super-I/O config space if available */ 1243 /* VID reading from Super-I/O config space if available */
1232 data->vid = sio_data->vid_value; 1244 data->vid = sio_data->vid_value;
@@ -1374,7 +1386,7 @@ static void __devinit it87_init_device(struct platform_device *pdev)
1374 it87_write_value(data, IT87_REG_TEMP_HIGH(i), 127); 1386 it87_write_value(data, IT87_REG_TEMP_HIGH(i), 127);
1375 } 1387 }
1376 1388
1377 /* Check if temperature channnels are reset manually or by some reason */ 1389 /* Check if temperature channels are reset manually or by some reason */
1378 tmp = it87_read_value(data, IT87_REG_TEMP_ENABLE); 1390 tmp = it87_read_value(data, IT87_REG_TEMP_ENABLE);
1379 if ((tmp & 0x3f) == 0) { 1391 if ((tmp & 0x3f) == 0) {
1380 /* Temp1,Temp3=thermistor; Temp2=thermal diode */ 1392 /* Temp1,Temp3=thermistor; Temp2=thermal diode */
@@ -1513,7 +1525,8 @@ static struct it87_data *it87_update_device(struct device *dev)
1513 1525
1514 data->sensor = it87_read_value(data, IT87_REG_TEMP_ENABLE); 1526 data->sensor = it87_read_value(data, IT87_REG_TEMP_ENABLE);
1515 /* The 8705 does not have VID capability. 1527 /* The 8705 does not have VID capability.
1516 The 8718 does not use IT87_REG_VID for the same purpose. */ 1528 The 8718 and the 8720 don't use IT87_REG_VID for the
1529 same purpose. */
1517 if (data->type == it8712 || data->type == it8716) { 1530 if (data->type == it8712 || data->type == it8716) {
1518 data->vid = it87_read_value(data, IT87_REG_VID); 1531 data->vid = it87_read_value(data, IT87_REG_VID);
1519 /* The older IT8712F revisions had only 5 VID pins, 1532 /* The older IT8712F revisions had only 5 VID pins,
@@ -1540,6 +1553,10 @@ static int __init it87_device_add(unsigned short address,
1540 }; 1553 };
1541 int err; 1554 int err;
1542 1555
1556 err = acpi_check_resource_conflict(&res);
1557 if (err)
1558 goto exit;
1559
1543 pdev = platform_device_alloc(DRVNAME, address); 1560 pdev = platform_device_alloc(DRVNAME, address);
1544 if (!pdev) { 1561 if (!pdev) {
1545 err = -ENOMEM; 1562 err = -ENOMEM;
@@ -1608,7 +1625,7 @@ static void __exit sm_it87_exit(void)
1608 1625
1609MODULE_AUTHOR("Chris Gauthron, " 1626MODULE_AUTHOR("Chris Gauthron, "
1610 "Jean Delvare <khali@linux-fr.org>"); 1627 "Jean Delvare <khali@linux-fr.org>");
1611MODULE_DESCRIPTION("IT8705F/8712F/8716F/8718F/8726F, SiS950 driver"); 1628MODULE_DESCRIPTION("IT8705F/8712F/8716F/8718F/8720F/8726F, SiS950 driver");
1612module_param(update_vbat, bool, 0); 1629module_param(update_vbat, bool, 0);
1613MODULE_PARM_DESC(update_vbat, "Update vbat if set else return powerup value"); 1630MODULE_PARM_DESC(update_vbat, "Update vbat if set else return powerup value");
1614module_param(fix_pwm_polarity, bool, 0); 1631module_param(fix_pwm_polarity, bool, 0);
diff --git a/drivers/hwmon/k8temp.c b/drivers/hwmon/k8temp.c
index bd2bde0ef95e..1fe995111841 100644
--- a/drivers/hwmon/k8temp.c
+++ b/drivers/hwmon/k8temp.c
@@ -31,6 +31,7 @@
31#include <linux/hwmon-sysfs.h> 31#include <linux/hwmon-sysfs.h>
32#include <linux/err.h> 32#include <linux/err.h>
33#include <linux/mutex.h> 33#include <linux/mutex.h>
34#include <asm/processor.h>
34 35
35#define TEMP_FROM_REG(val) (((((val) >> 16) & 0xff) - 49) * 1000) 36#define TEMP_FROM_REG(val) (((((val) >> 16) & 0xff) - 49) * 1000)
36#define REG_TEMP 0xe4 37#define REG_TEMP 0xe4
@@ -47,6 +48,8 @@ struct k8temp_data {
47 /* registers values */ 48 /* registers values */
48 u8 sensorsp; /* sensor presence bits - SEL_CORE & SEL_PLACE */ 49 u8 sensorsp; /* sensor presence bits - SEL_CORE & SEL_PLACE */
49 u32 temp[2][2]; /* core, place */ 50 u32 temp[2][2]; /* core, place */
51 u8 swap_core_select; /* meaning of SEL_CORE is inverted */
52 u32 temp_offset;
50}; 53};
51 54
52static struct k8temp_data *k8temp_update_device(struct device *dev) 55static struct k8temp_data *k8temp_update_device(struct device *dev)
@@ -114,10 +117,15 @@ static ssize_t show_temp(struct device *dev,
114 to_sensor_dev_attr_2(devattr); 117 to_sensor_dev_attr_2(devattr);
115 int core = attr->nr; 118 int core = attr->nr;
116 int place = attr->index; 119 int place = attr->index;
120 int temp;
117 struct k8temp_data *data = k8temp_update_device(dev); 121 struct k8temp_data *data = k8temp_update_device(dev);
118 122
119 return sprintf(buf, "%d\n", 123 if (data->swap_core_select)
120 TEMP_FROM_REG(data->temp[core][place])); 124 core = core ? 0 : 1;
125
126 temp = TEMP_FROM_REG(data->temp[core][place]) + data->temp_offset;
127
128 return sprintf(buf, "%d\n", temp);
121} 129}
122 130
123/* core, place */ 131/* core, place */
@@ -141,20 +149,49 @@ static int __devinit k8temp_probe(struct pci_dev *pdev,
141 int err; 149 int err;
142 u8 scfg; 150 u8 scfg;
143 u32 temp; 151 u32 temp;
152 u8 model, stepping;
144 struct k8temp_data *data; 153 struct k8temp_data *data;
145 u32 cpuid = cpuid_eax(1);
146
147 /* this feature should be available since SH-C0 core */
148 if ((cpuid == 0xf40) || (cpuid == 0xf50) || (cpuid == 0xf51)) {
149 err = -ENODEV;
150 goto exit;
151 }
152 154
153 if (!(data = kzalloc(sizeof(struct k8temp_data), GFP_KERNEL))) { 155 if (!(data = kzalloc(sizeof(struct k8temp_data), GFP_KERNEL))) {
154 err = -ENOMEM; 156 err = -ENOMEM;
155 goto exit; 157 goto exit;
156 } 158 }
157 159
160 model = boot_cpu_data.x86_model;
161 stepping = boot_cpu_data.x86_mask;
162
163 switch (boot_cpu_data.x86) {
164 case 0xf:
165 /* feature available since SH-C0, exclude older revisions */
166 if (((model == 4) && (stepping == 0)) ||
167 ((model == 5) && (stepping <= 1))) {
168 err = -ENODEV;
169 goto exit_free;
170 }
171
172 /*
173 * AMD NPT family 0fh, i.e. RevF and RevG:
174 * meaning of SEL_CORE bit is inverted
175 */
176 if (model >= 0x40) {
177 data->swap_core_select = 1;
178 dev_warn(&pdev->dev, "Temperature readouts might be "
179 "wrong - check erratum #141\n");
180 }
181
182 if ((model >= 0x69) &&
183 !(model == 0xc1 || model == 0x6c || model == 0x7c)) {
184 /*
185 * RevG desktop CPUs (i.e. no socket S1G1 parts)
186 * need additional offset, otherwise reported
187 * temperature is below ambient temperature
188 */
189 data->temp_offset = 21000;
190 }
191
192 break;
193 }
194
158 pci_read_config_byte(pdev, REG_TEMP, &scfg); 195 pci_read_config_byte(pdev, REG_TEMP, &scfg);
159 scfg &= ~(SEL_PLACE | SEL_CORE); /* Select sensor 0, core0 */ 196 scfg &= ~(SEL_PLACE | SEL_CORE); /* Select sensor 0, core0 */
160 pci_write_config_byte(pdev, REG_TEMP, scfg); 197 pci_write_config_byte(pdev, REG_TEMP, scfg);
diff --git a/drivers/hwmon/lis3lv02d.c b/drivers/hwmon/lis3lv02d.c
index c002144c76bc..219d2d0d5a62 100644
--- a/drivers/hwmon/lis3lv02d.c
+++ b/drivers/hwmon/lis3lv02d.c
@@ -3,6 +3,7 @@
3 * 3 *
4 * Copyright (C) 2007-2008 Yan Burman 4 * Copyright (C) 2007-2008 Yan Burman
5 * Copyright (C) 2008 Eric Piel 5 * Copyright (C) 2008 Eric Piel
6 * Copyright (C) 2008 Pavel Machek
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
@@ -39,7 +40,6 @@
39#include "lis3lv02d.h" 40#include "lis3lv02d.h"
40 41
41#define DRIVER_NAME "lis3lv02d" 42#define DRIVER_NAME "lis3lv02d"
42#define ACPI_MDPS_CLASS "accelerometer"
43 43
44/* joystick device poll interval in milliseconds */ 44/* joystick device poll interval in milliseconds */
45#define MDPS_POLL_INTERVAL 50 45#define MDPS_POLL_INTERVAL 50
@@ -55,100 +55,17 @@
55/* Maximum value our axis may get for the input device (signed 12 bits) */ 55/* Maximum value our axis may get for the input device (signed 12 bits) */
56#define MDPS_MAX_VAL 2048 56#define MDPS_MAX_VAL 2048
57 57
58struct axis_conversion { 58struct acpi_lis3lv02d adev;
59 s8 x; 59EXPORT_SYMBOL_GPL(adev);
60 s8 y;
61 s8 z;
62};
63
64struct acpi_lis3lv02d {
65 struct acpi_device *device; /* The ACPI device */
66 struct input_dev *idev; /* input device */
67 struct task_struct *kthread; /* kthread for input */
68 struct mutex lock;
69 struct platform_device *pdev; /* platform device */
70 atomic_t count; /* interrupt count after last read */
71 int xcalib; /* calibrated null value for x */
72 int ycalib; /* calibrated null value for y */
73 int zcalib; /* calibrated null value for z */
74 unsigned char is_on; /* whether the device is on or off */
75 unsigned char usage; /* usage counter */
76 struct axis_conversion ac; /* hw -> logical axis */
77};
78 60
79static struct acpi_lis3lv02d adev;
80
81static int lis3lv02d_remove_fs(void);
82static int lis3lv02d_add_fs(struct acpi_device *device); 61static int lis3lv02d_add_fs(struct acpi_device *device);
83 62
84/* For automatic insertion of the module */
85static struct acpi_device_id lis3lv02d_device_ids[] = {
86 {"HPQ0004", 0}, /* HP Mobile Data Protection System PNP */
87 {"", 0},
88};
89MODULE_DEVICE_TABLE(acpi, lis3lv02d_device_ids);
90
91/**
92 * lis3lv02d_acpi_init - ACPI _INI method: initialize the device.
93 * @handle: the handle of the device
94 *
95 * Returns AE_OK on success.
96 */
97static inline acpi_status lis3lv02d_acpi_init(acpi_handle handle)
98{
99 return acpi_evaluate_object(handle, METHOD_NAME__INI, NULL, NULL);
100}
101
102/**
103 * lis3lv02d_acpi_read - ACPI ALRD method: read a register
104 * @handle: the handle of the device
105 * @reg: the register to read
106 * @ret: result of the operation
107 *
108 * Returns AE_OK on success.
109 */
110static acpi_status lis3lv02d_acpi_read(acpi_handle handle, int reg, u8 *ret)
111{
112 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
113 struct acpi_object_list args = { 1, &arg0 };
114 unsigned long long lret;
115 acpi_status status;
116
117 arg0.integer.value = reg;
118
119 status = acpi_evaluate_integer(handle, "ALRD", &args, &lret);
120 *ret = lret;
121 return status;
122}
123
124/**
125 * lis3lv02d_acpi_write - ACPI ALWR method: write to a register
126 * @handle: the handle of the device
127 * @reg: the register to write to
128 * @val: the value to write
129 *
130 * Returns AE_OK on success.
131 */
132static acpi_status lis3lv02d_acpi_write(acpi_handle handle, int reg, u8 val)
133{
134 unsigned long long ret; /* Not used when writting */
135 union acpi_object in_obj[2];
136 struct acpi_object_list args = { 2, in_obj };
137
138 in_obj[0].type = ACPI_TYPE_INTEGER;
139 in_obj[0].integer.value = reg;
140 in_obj[1].type = ACPI_TYPE_INTEGER;
141 in_obj[1].integer.value = val;
142
143 return acpi_evaluate_integer(handle, "ALWR", &args, &ret);
144}
145
146static s16 lis3lv02d_read_16(acpi_handle handle, int reg) 63static s16 lis3lv02d_read_16(acpi_handle handle, int reg)
147{ 64{
148 u8 lo, hi; 65 u8 lo, hi;
149 66
150 lis3lv02d_acpi_read(handle, reg, &lo); 67 adev.read(handle, reg, &lo);
151 lis3lv02d_acpi_read(handle, reg + 1, &hi); 68 adev.read(handle, reg + 1, &hi);
152 /* In "12 bit right justified" mode, bit 6, bit 7, bit 8 = bit 5 */ 69 /* In "12 bit right justified" mode, bit 6, bit 7, bit 8 = bit 5 */
153 return (s16)((hi << 8) | lo); 70 return (s16)((hi << 8) | lo);
154} 71}
@@ -190,54 +107,31 @@ static void lis3lv02d_get_xyz(acpi_handle handle, int *x, int *y, int *z)
190 *z = lis3lv02d_get_axis(adev.ac.z, position); 107 *z = lis3lv02d_get_axis(adev.ac.z, position);
191} 108}
192 109
193static inline void lis3lv02d_poweroff(acpi_handle handle) 110void lis3lv02d_poweroff(acpi_handle handle)
194{ 111{
195 adev.is_on = 0; 112 adev.is_on = 0;
196 /* disable X,Y,Z axis and power down */ 113 /* disable X,Y,Z axis and power down */
197 lis3lv02d_acpi_write(handle, CTRL_REG1, 0x00); 114 adev.write(handle, CTRL_REG1, 0x00);
198} 115}
116EXPORT_SYMBOL_GPL(lis3lv02d_poweroff);
199 117
200static void lis3lv02d_poweron(acpi_handle handle) 118void lis3lv02d_poweron(acpi_handle handle)
201{ 119{
202 u8 val; 120 u8 val;
203 121
204 adev.is_on = 1; 122 adev.is_on = 1;
205 lis3lv02d_acpi_init(handle); 123 adev.init(handle);
206 lis3lv02d_acpi_write(handle, FF_WU_CFG, 0); 124 adev.write(handle, FF_WU_CFG, 0);
207 /* 125 /*
208 * BDU: LSB and MSB values are not updated until both have been read. 126 * BDU: LSB and MSB values are not updated until both have been read.
209 * So the value read will always be correct. 127 * So the value read will always be correct.
210 * IEN: Interrupt for free-fall and DD, not for data-ready. 128 * IEN: Interrupt for free-fall and DD, not for data-ready.
211 */ 129 */
212 lis3lv02d_acpi_read(handle, CTRL_REG2, &val); 130 adev.read(handle, CTRL_REG2, &val);
213 val |= CTRL2_BDU | CTRL2_IEN; 131 val |= CTRL2_BDU | CTRL2_IEN;
214 lis3lv02d_acpi_write(handle, CTRL_REG2, val); 132 adev.write(handle, CTRL_REG2, val);
215}
216
217#ifdef CONFIG_PM
218static int lis3lv02d_suspend(struct acpi_device *device, pm_message_t state)
219{
220 /* make sure the device is off when we suspend */
221 lis3lv02d_poweroff(device->handle);
222 return 0;
223}
224
225static int lis3lv02d_resume(struct acpi_device *device)
226{
227 /* put back the device in the right state (ACPI might turn it on) */
228 mutex_lock(&adev.lock);
229 if (adev.usage > 0)
230 lis3lv02d_poweron(device->handle);
231 else
232 lis3lv02d_poweroff(device->handle);
233 mutex_unlock(&adev.lock);
234 return 0;
235} 133}
236#else 134EXPORT_SYMBOL_GPL(lis3lv02d_poweron);
237#define lis3lv02d_suspend NULL
238#define lis3lv02d_resume NULL
239#endif
240
241 135
242/* 136/*
243 * To be called before starting to use the device. It makes sure that the 137 * To be called before starting to use the device. It makes sure that the
@@ -315,7 +209,7 @@ static inline void lis3lv02d_calibrate_joystick(void)
315 lis3lv02d_get_xyz(adev.device->handle, &adev.xcalib, &adev.ycalib, &adev.zcalib); 209 lis3lv02d_get_xyz(adev.device->handle, &adev.xcalib, &adev.ycalib, &adev.zcalib);
316} 210}
317 211
318static int lis3lv02d_joystick_enable(void) 212int lis3lv02d_joystick_enable(void)
319{ 213{
320 int err; 214 int err;
321 215
@@ -349,8 +243,9 @@ static int lis3lv02d_joystick_enable(void)
349 243
350 return err; 244 return err;
351} 245}
246EXPORT_SYMBOL_GPL(lis3lv02d_joystick_enable);
352 247
353static void lis3lv02d_joystick_disable(void) 248void lis3lv02d_joystick_disable(void)
354{ 249{
355 if (!adev.idev) 250 if (!adev.idev)
356 return; 251 return;
@@ -358,13 +253,13 @@ static void lis3lv02d_joystick_disable(void)
358 input_unregister_device(adev.idev); 253 input_unregister_device(adev.idev);
359 adev.idev = NULL; 254 adev.idev = NULL;
360} 255}
361 256EXPORT_SYMBOL_GPL(lis3lv02d_joystick_disable);
362 257
363/* 258/*
364 * Initialise the accelerometer and the various subsystems. 259 * Initialise the accelerometer and the various subsystems.
365 * Should be rather independant of the bus system. 260 * Should be rather independant of the bus system.
366 */ 261 */
367static int lis3lv02d_init_device(struct acpi_lis3lv02d *dev) 262int lis3lv02d_init_device(struct acpi_lis3lv02d *dev)
368{ 263{
369 mutex_init(&dev->lock); 264 mutex_init(&dev->lock);
370 lis3lv02d_add_fs(dev->device); 265 lis3lv02d_add_fs(dev->device);
@@ -376,93 +271,7 @@ static int lis3lv02d_init_device(struct acpi_lis3lv02d *dev)
376 lis3lv02d_decrease_use(dev); 271 lis3lv02d_decrease_use(dev);
377 return 0; 272 return 0;
378} 273}
379 274EXPORT_SYMBOL_GPL(lis3lv02d_init_device);
380static int lis3lv02d_dmi_matched(const struct dmi_system_id *dmi)
381{
382 adev.ac = *((struct axis_conversion *)dmi->driver_data);
383 printk(KERN_INFO DRIVER_NAME ": hardware type %s found.\n", dmi->ident);
384
385 return 1;
386}
387
388/* Represents, for each axis seen by userspace, the corresponding hw axis (+1).
389 * If the value is negative, the opposite of the hw value is used. */
390static struct axis_conversion lis3lv02d_axis_normal = {1, 2, 3};
391static struct axis_conversion lis3lv02d_axis_y_inverted = {1, -2, 3};
392static struct axis_conversion lis3lv02d_axis_x_inverted = {-1, 2, 3};
393static struct axis_conversion lis3lv02d_axis_z_inverted = {1, 2, -3};
394static struct axis_conversion lis3lv02d_axis_xy_rotated_left = {-2, 1, 3};
395static struct axis_conversion lis3lv02d_axis_xy_swap_inverted = {-2, -1, 3};
396
397#define AXIS_DMI_MATCH(_ident, _name, _axis) { \
398 .ident = _ident, \
399 .callback = lis3lv02d_dmi_matched, \
400 .matches = { \
401 DMI_MATCH(DMI_PRODUCT_NAME, _name) \
402 }, \
403 .driver_data = &lis3lv02d_axis_##_axis \
404}
405static struct dmi_system_id lis3lv02d_dmi_ids[] = {
406 /* product names are truncated to match all kinds of a same model */
407 AXIS_DMI_MATCH("NC64x0", "HP Compaq nc64", x_inverted),
408 AXIS_DMI_MATCH("NC84x0", "HP Compaq nc84", z_inverted),
409 AXIS_DMI_MATCH("NX9420", "HP Compaq nx9420", x_inverted),
410 AXIS_DMI_MATCH("NW9440", "HP Compaq nw9440", x_inverted),
411 AXIS_DMI_MATCH("NC2510", "HP Compaq 2510", y_inverted),
412 AXIS_DMI_MATCH("NC8510", "HP Compaq 8510", xy_swap_inverted),
413 AXIS_DMI_MATCH("HP2133", "HP 2133", xy_rotated_left),
414 { NULL, }
415/* Laptop models without axis info (yet):
416 * "NC651xx" "HP Compaq 651"
417 * "NC671xx" "HP Compaq 671"
418 * "NC6910" "HP Compaq 6910"
419 * HP Compaq 8710x Notebook PC / Mobile Workstation
420 * "NC2400" "HP Compaq nc2400"
421 * "NX74x0" "HP Compaq nx74"
422 * "NX6325" "HP Compaq nx6325"
423 * "NC4400" "HP Compaq nc4400"
424 */
425};
426
427static int lis3lv02d_add(struct acpi_device *device)
428{
429 u8 val;
430
431 if (!device)
432 return -EINVAL;
433
434 adev.device = device;
435 strcpy(acpi_device_name(device), DRIVER_NAME);
436 strcpy(acpi_device_class(device), ACPI_MDPS_CLASS);
437 device->driver_data = &adev;
438
439 lis3lv02d_acpi_read(device->handle, WHO_AM_I, &val);
440 if ((val != LIS3LV02DL_ID) && (val != LIS302DL_ID)) {
441 printk(KERN_ERR DRIVER_NAME
442 ": Accelerometer chip not LIS3LV02D{L,Q}\n");
443 }
444
445 /* If possible use a "standard" axes order */
446 if (dmi_check_system(lis3lv02d_dmi_ids) == 0) {
447 printk(KERN_INFO DRIVER_NAME ": laptop model unknown, "
448 "using default axes configuration\n");
449 adev.ac = lis3lv02d_axis_normal;
450 }
451
452 return lis3lv02d_init_device(&adev);
453}
454
455static int lis3lv02d_remove(struct acpi_device *device, int type)
456{
457 if (!device)
458 return -EINVAL;
459
460 lis3lv02d_joystick_disable();
461 lis3lv02d_poweroff(device->handle);
462
463 return lis3lv02d_remove_fs();
464}
465
466 275
467/* Sysfs stuff */ 276/* Sysfs stuff */
468static ssize_t lis3lv02d_position_show(struct device *dev, 277static ssize_t lis3lv02d_position_show(struct device *dev,
@@ -501,7 +310,7 @@ static ssize_t lis3lv02d_rate_show(struct device *dev,
501 int val; 310 int val;
502 311
503 lis3lv02d_increase_use(&adev); 312 lis3lv02d_increase_use(&adev);
504 lis3lv02d_acpi_read(adev.device->handle, CTRL_REG1, &ctrl); 313 adev.read(adev.device->handle, CTRL_REG1, &ctrl);
505 lis3lv02d_decrease_use(&adev); 314 lis3lv02d_decrease_use(&adev);
506 val = (ctrl & (CTRL1_DF0 | CTRL1_DF1)) >> 4; 315 val = (ctrl & (CTRL1_DF0 | CTRL1_DF1)) >> 4;
507 return sprintf(buf, "%d\n", lis3lv02dl_df_val[val]); 316 return sprintf(buf, "%d\n", lis3lv02dl_df_val[val]);
@@ -523,6 +332,7 @@ static struct attribute_group lis3lv02d_attribute_group = {
523 .attrs = lis3lv02d_attributes 332 .attrs = lis3lv02d_attributes
524}; 333};
525 334
335
526static int lis3lv02d_add_fs(struct acpi_device *device) 336static int lis3lv02d_add_fs(struct acpi_device *device)
527{ 337{
528 adev.pdev = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0); 338 adev.pdev = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0);
@@ -532,50 +342,15 @@ static int lis3lv02d_add_fs(struct acpi_device *device)
532 return sysfs_create_group(&adev.pdev->dev.kobj, &lis3lv02d_attribute_group); 342 return sysfs_create_group(&adev.pdev->dev.kobj, &lis3lv02d_attribute_group);
533} 343}
534 344
535static int lis3lv02d_remove_fs(void) 345int lis3lv02d_remove_fs(void)
536{ 346{
537 sysfs_remove_group(&adev.pdev->dev.kobj, &lis3lv02d_attribute_group); 347 sysfs_remove_group(&adev.pdev->dev.kobj, &lis3lv02d_attribute_group);
538 platform_device_unregister(adev.pdev); 348 platform_device_unregister(adev.pdev);
539 return 0; 349 return 0;
540} 350}
541 351EXPORT_SYMBOL_GPL(lis3lv02d_remove_fs);
542/* For the HP MDPS aka 3D Driveguard */
543static struct acpi_driver lis3lv02d_driver = {
544 .name = DRIVER_NAME,
545 .class = ACPI_MDPS_CLASS,
546 .ids = lis3lv02d_device_ids,
547 .ops = {
548 .add = lis3lv02d_add,
549 .remove = lis3lv02d_remove,
550 .suspend = lis3lv02d_suspend,
551 .resume = lis3lv02d_resume,
552 }
553};
554
555static int __init lis3lv02d_init_module(void)
556{
557 int ret;
558
559 if (acpi_disabled)
560 return -ENODEV;
561
562 ret = acpi_bus_register_driver(&lis3lv02d_driver);
563 if (ret < 0)
564 return ret;
565
566 printk(KERN_INFO DRIVER_NAME " driver loaded.\n");
567
568 return 0;
569}
570
571static void __exit lis3lv02d_exit_module(void)
572{
573 acpi_bus_unregister_driver(&lis3lv02d_driver);
574}
575 352
576MODULE_DESCRIPTION("ST LIS3LV02Dx three-axis digital accelerometer driver"); 353MODULE_DESCRIPTION("ST LIS3LV02Dx three-axis digital accelerometer driver");
577MODULE_AUTHOR("Yan Burman and Eric Piel"); 354MODULE_AUTHOR("Yan Burman and Eric Piel");
578MODULE_LICENSE("GPL"); 355MODULE_LICENSE("GPL");
579 356
580module_init(lis3lv02d_init_module);
581module_exit(lis3lv02d_exit_module);
diff --git a/drivers/hwmon/lis3lv02d.h b/drivers/hwmon/lis3lv02d.h
index 330cfc60e948..223f1c0763bb 100644
--- a/drivers/hwmon/lis3lv02d.h
+++ b/drivers/hwmon/lis3lv02d.h
@@ -23,7 +23,7 @@
23 * The actual chip is STMicroelectronics LIS3LV02DL or LIS3LV02DQ that seems to 23 * The actual chip is STMicroelectronics LIS3LV02DL or LIS3LV02DQ that seems to
24 * be connected via SPI. There exists also several similar chips (such as LIS302DL or 24 * be connected via SPI. There exists also several similar chips (such as LIS302DL or
25 * LIS3L02DQ) but not in the HP laptops and they have slightly different registers. 25 * LIS3L02DQ) but not in the HP laptops and they have slightly different registers.
26 * They can also be connected via I²C. 26 * They can also be connected via I²C.
27 */ 27 */
28 28
29#define LIS3LV02DL_ID 0x3A /* Also the LIS3LV02DQ */ 29#define LIS3LV02DL_ID 0x3A /* Also the LIS3LV02DQ */
@@ -147,3 +147,36 @@ enum lis3lv02d_dd_src {
147 DD_SRC_IA = 0x40, 147 DD_SRC_IA = 0x40,
148}; 148};
149 149
150struct axis_conversion {
151 s8 x;
152 s8 y;
153 s8 z;
154};
155
156struct acpi_lis3lv02d {
157 struct acpi_device *device; /* The ACPI device */
158 acpi_status (*init) (acpi_handle handle);
159 acpi_status (*write) (acpi_handle handle, int reg, u8 val);
160 acpi_status (*read) (acpi_handle handle, int reg, u8 *ret);
161
162 struct input_dev *idev; /* input device */
163 struct task_struct *kthread; /* kthread for input */
164 struct mutex lock;
165 struct platform_device *pdev; /* platform device */
166 atomic_t count; /* interrupt count after last read */
167 int xcalib; /* calibrated null value for x */
168 int ycalib; /* calibrated null value for y */
169 int zcalib; /* calibrated null value for z */
170 unsigned char is_on; /* whether the device is on or off */
171 unsigned char usage; /* usage counter */
172 struct axis_conversion ac; /* hw -> logical axis */
173};
174
175int lis3lv02d_init_device(struct acpi_lis3lv02d *dev);
176int lis3lv02d_joystick_enable(void);
177void lis3lv02d_joystick_disable(void);
178void lis3lv02d_poweroff(acpi_handle handle);
179void lis3lv02d_poweron(acpi_handle handle);
180int lis3lv02d_remove_fs(void);
181
182extern struct acpi_lis3lv02d adev;
diff --git a/drivers/hwmon/lm70.c b/drivers/hwmon/lm70.c
index d435f003292d..ae6204f33214 100644
--- a/drivers/hwmon/lm70.c
+++ b/drivers/hwmon/lm70.c
@@ -37,9 +37,13 @@
37 37
38#define DRVNAME "lm70" 38#define DRVNAME "lm70"
39 39
40#define LM70_CHIP_LM70 0 /* original NS LM70 */
41#define LM70_CHIP_TMP121 1 /* TI TMP121/TMP123 */
42
40struct lm70 { 43struct lm70 {
41 struct device *hwmon_dev; 44 struct device *hwmon_dev;
42 struct mutex lock; 45 struct mutex lock;
46 unsigned int chip;
43}; 47};
44 48
45/* sysfs hook function */ 49/* sysfs hook function */
@@ -47,7 +51,7 @@ static ssize_t lm70_sense_temp(struct device *dev,
47 struct device_attribute *attr, char *buf) 51 struct device_attribute *attr, char *buf)
48{ 52{
49 struct spi_device *spi = to_spi_device(dev); 53 struct spi_device *spi = to_spi_device(dev);
50 int status, val; 54 int status, val = 0;
51 u8 rxbuf[2]; 55 u8 rxbuf[2];
52 s16 raw=0; 56 s16 raw=0;
53 struct lm70 *p_lm70 = dev_get_drvdata(&spi->dev); 57 struct lm70 *p_lm70 = dev_get_drvdata(&spi->dev);
@@ -65,12 +69,12 @@ static ssize_t lm70_sense_temp(struct device *dev,
65 "spi_write_then_read failed with status %d\n", status); 69 "spi_write_then_read failed with status %d\n", status);
66 goto out; 70 goto out;
67 } 71 }
68 dev_dbg(dev, "rxbuf[1] : 0x%x rxbuf[0] : 0x%x\n", rxbuf[1], rxbuf[0]); 72 raw = (rxbuf[0] << 8) + rxbuf[1];
69 73 dev_dbg(dev, "rxbuf[0] : 0x%02x rxbuf[1] : 0x%02x raw=0x%04x\n",
70 raw = (rxbuf[1] << 8) + rxbuf[0]; 74 rxbuf[0], rxbuf[1], raw);
71 dev_dbg(dev, "raw=0x%x\n", raw);
72 75
73 /* 76 /*
77 * LM70:
74 * The "raw" temperature read into rxbuf[] is a 16-bit signed 2's 78 * The "raw" temperature read into rxbuf[] is a 16-bit signed 2's
75 * complement value. Only the MSB 11 bits (1 sign + 10 temperature 79 * complement value. Only the MSB 11 bits (1 sign + 10 temperature
76 * bits) are meaningful; the LSB 5 bits are to be discarded. 80 * bits) are meaningful; the LSB 5 bits are to be discarded.
@@ -80,8 +84,21 @@ static ssize_t lm70_sense_temp(struct device *dev,
80 * by 0.25. Also multiply by 1000 to represent in millidegrees 84 * by 0.25. Also multiply by 1000 to represent in millidegrees
81 * Celsius. 85 * Celsius.
82 * So it's equivalent to multiplying by 0.25 * 1000 = 250. 86 * So it's equivalent to multiplying by 0.25 * 1000 = 250.
87 *
88 * TMP121/TMP123:
89 * 13 bits of 2's complement data, discard LSB 3 bits,
90 * resolution 0.0625 degrees celsius.
83 */ 91 */
84 val = ((int)raw/32) * 250; 92 switch (p_lm70->chip) {
93 case LM70_CHIP_LM70:
94 val = ((int)raw / 32) * 250;
95 break;
96
97 case LM70_CHIP_TMP121:
98 val = ((int)raw / 8) * 625 / 10;
99 break;
100 }
101
85 status = sprintf(buf, "%d\n", val); /* millidegrees Celsius */ 102 status = sprintf(buf, "%d\n", val); /* millidegrees Celsius */
86out: 103out:
87 mutex_unlock(&p_lm70->lock); 104 mutex_unlock(&p_lm70->lock);
@@ -93,27 +110,39 @@ static DEVICE_ATTR(temp1_input, S_IRUGO, lm70_sense_temp, NULL);
93static ssize_t lm70_show_name(struct device *dev, struct device_attribute 110static ssize_t lm70_show_name(struct device *dev, struct device_attribute
94 *devattr, char *buf) 111 *devattr, char *buf)
95{ 112{
96 return sprintf(buf, "lm70\n"); 113 struct lm70 *p_lm70 = dev_get_drvdata(dev);
114 int ret;
115
116 switch (p_lm70->chip) {
117 case LM70_CHIP_LM70:
118 ret = sprintf(buf, "lm70\n");
119 break;
120 case LM70_CHIP_TMP121:
121 ret = sprintf(buf, "tmp121\n");
122 break;
123 default:
124 ret = -EINVAL;
125 }
126 return ret;
97} 127}
98 128
99static DEVICE_ATTR(name, S_IRUGO, lm70_show_name, NULL); 129static DEVICE_ATTR(name, S_IRUGO, lm70_show_name, NULL);
100 130
101/*----------------------------------------------------------------------*/ 131/*----------------------------------------------------------------------*/
102 132
103static int __devinit lm70_probe(struct spi_device *spi) 133static int __devinit common_probe(struct spi_device *spi, int chip)
104{ 134{
105 struct lm70 *p_lm70; 135 struct lm70 *p_lm70;
106 int status; 136 int status;
107 137
108 /* signaling is SPI_MODE_0 on a 3-wire link (shared SI/SO) */ 138 /* NOTE: we assume 8-bit words, and convert to 16 bits manually */
109 if ((spi->mode & (SPI_CPOL|SPI_CPHA)) || !(spi->mode & SPI_3WIRE))
110 return -EINVAL;
111 139
112 p_lm70 = kzalloc(sizeof *p_lm70, GFP_KERNEL); 140 p_lm70 = kzalloc(sizeof *p_lm70, GFP_KERNEL);
113 if (!p_lm70) 141 if (!p_lm70)
114 return -ENOMEM; 142 return -ENOMEM;
115 143
116 mutex_init(&p_lm70->lock); 144 mutex_init(&p_lm70->lock);
145 p_lm70->chip = chip;
117 146
118 /* sysfs hook */ 147 /* sysfs hook */
119 p_lm70->hwmon_dev = hwmon_device_register(&spi->dev); 148 p_lm70->hwmon_dev = hwmon_device_register(&spi->dev);
@@ -141,6 +170,24 @@ out_dev_reg_failed:
141 return status; 170 return status;
142} 171}
143 172
173static int __devinit lm70_probe(struct spi_device *spi)
174{
175 /* signaling is SPI_MODE_0 on a 3-wire link (shared SI/SO) */
176 if ((spi->mode & (SPI_CPOL | SPI_CPHA)) || !(spi->mode & SPI_3WIRE))
177 return -EINVAL;
178
179 return common_probe(spi, LM70_CHIP_LM70);
180}
181
182static int __devinit tmp121_probe(struct spi_device *spi)
183{
184 /* signaling is SPI_MODE_0 with only MISO connected */
185 if (spi->mode & (SPI_CPOL | SPI_CPHA))
186 return -EINVAL;
187
188 return common_probe(spi, LM70_CHIP_TMP121);
189}
190
144static int __devexit lm70_remove(struct spi_device *spi) 191static int __devexit lm70_remove(struct spi_device *spi)
145{ 192{
146 struct lm70 *p_lm70 = dev_get_drvdata(&spi->dev); 193 struct lm70 *p_lm70 = dev_get_drvdata(&spi->dev);
@@ -154,6 +201,15 @@ static int __devexit lm70_remove(struct spi_device *spi)
154 return 0; 201 return 0;
155} 202}
156 203
204static struct spi_driver tmp121_driver = {
205 .driver = {
206 .name = "tmp121",
207 .owner = THIS_MODULE,
208 },
209 .probe = tmp121_probe,
210 .remove = __devexit_p(lm70_remove),
211};
212
157static struct spi_driver lm70_driver = { 213static struct spi_driver lm70_driver = {
158 .driver = { 214 .driver = {
159 .name = "lm70", 215 .name = "lm70",
@@ -165,17 +221,26 @@ static struct spi_driver lm70_driver = {
165 221
166static int __init init_lm70(void) 222static int __init init_lm70(void)
167{ 223{
168 return spi_register_driver(&lm70_driver); 224 int ret = spi_register_driver(&lm70_driver);
225 if (ret)
226 return ret;
227
228 ret = spi_register_driver(&tmp121_driver);
229 if (ret)
230 spi_unregister_driver(&lm70_driver);
231
232 return ret;
169} 233}
170 234
171static void __exit cleanup_lm70(void) 235static void __exit cleanup_lm70(void)
172{ 236{
173 spi_unregister_driver(&lm70_driver); 237 spi_unregister_driver(&lm70_driver);
238 spi_unregister_driver(&tmp121_driver);
174} 239}
175 240
176module_init(init_lm70); 241module_init(init_lm70);
177module_exit(cleanup_lm70); 242module_exit(cleanup_lm70);
178 243
179MODULE_AUTHOR("Kaiwan N Billimoria"); 244MODULE_AUTHOR("Kaiwan N Billimoria");
180MODULE_DESCRIPTION("National Semiconductor LM70 Linux driver"); 245MODULE_DESCRIPTION("NS LM70 / TI TMP121/TMP123 Linux driver");
181MODULE_LICENSE("GPL"); 246MODULE_LICENSE("GPL");
diff --git a/drivers/hwmon/ltc4245.c b/drivers/hwmon/ltc4245.c
new file mode 100644
index 000000000000..034b2c515848
--- /dev/null
+++ b/drivers/hwmon/ltc4245.c
@@ -0,0 +1,567 @@
1/*
2 * Driver for Linear Technology LTC4245 I2C Multiple Supply Hot Swap Controller
3 *
4 * Copyright (C) 2008 Ira W. Snyder <iws@ovro.caltech.edu>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This driver is based on the ds1621 and ina209 drivers.
11 *
12 * Datasheet:
13 * http://www.linear.com/pc/downloadDocument.do?navId=H0,C1,C1003,C1006,C1140,P19392,D13517
14 */
15
16#include <linux/kernel.h>
17#include <linux/module.h>
18#include <linux/init.h>
19#include <linux/err.h>
20#include <linux/slab.h>
21#include <linux/i2c.h>
22#include <linux/hwmon.h>
23#include <linux/hwmon-sysfs.h>
24
25/* Valid addresses are 0x20 - 0x3f
26 *
27 * For now, we do not probe, since some of these addresses
28 * are known to be unfriendly to probing */
29static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
30
31/* Insmod parameters */
32I2C_CLIENT_INSMOD_1(ltc4245);
33
34/* Here are names of the chip's registers (a.k.a. commands) */
35enum ltc4245_cmd {
36 LTC4245_STATUS = 0x00, /* readonly */
37 LTC4245_ALERT = 0x01,
38 LTC4245_CONTROL = 0x02,
39 LTC4245_ON = 0x03,
40 LTC4245_FAULT1 = 0x04,
41 LTC4245_FAULT2 = 0x05,
42 LTC4245_GPIO = 0x06,
43 LTC4245_ADCADR = 0x07,
44
45 LTC4245_12VIN = 0x10,
46 LTC4245_12VSENSE = 0x11,
47 LTC4245_12VOUT = 0x12,
48 LTC4245_5VIN = 0x13,
49 LTC4245_5VSENSE = 0x14,
50 LTC4245_5VOUT = 0x15,
51 LTC4245_3VIN = 0x16,
52 LTC4245_3VSENSE = 0x17,
53 LTC4245_3VOUT = 0x18,
54 LTC4245_VEEIN = 0x19,
55 LTC4245_VEESENSE = 0x1a,
56 LTC4245_VEEOUT = 0x1b,
57 LTC4245_GPIOADC1 = 0x1c,
58 LTC4245_GPIOADC2 = 0x1d,
59 LTC4245_GPIOADC3 = 0x1e,
60};
61
62struct ltc4245_data {
63 struct device *hwmon_dev;
64
65 struct mutex update_lock;
66 bool valid;
67 unsigned long last_updated; /* in jiffies */
68
69 /* Control registers */
70 u8 cregs[0x08];
71
72 /* Voltage registers */
73 u8 vregs[0x0f];
74};
75
76static struct ltc4245_data *ltc4245_update_device(struct device *dev)
77{
78 struct i2c_client *client = to_i2c_client(dev);
79 struct ltc4245_data *data = i2c_get_clientdata(client);
80 s32 val;
81 int i;
82
83 mutex_lock(&data->update_lock);
84
85 if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
86
87 dev_dbg(&client->dev, "Starting ltc4245 update\n");
88
89 /* Read control registers -- 0x00 to 0x07 */
90 for (i = 0; i < ARRAY_SIZE(data->cregs); i++) {
91 val = i2c_smbus_read_byte_data(client, i);
92 if (unlikely(val < 0))
93 data->cregs[i] = 0;
94 else
95 data->cregs[i] = val;
96 }
97
98 /* Read voltage registers -- 0x10 to 0x1f */
99 for (i = 0; i < ARRAY_SIZE(data->vregs); i++) {
100 val = i2c_smbus_read_byte_data(client, i+0x10);
101 if (unlikely(val < 0))
102 data->vregs[i] = 0;
103 else
104 data->vregs[i] = val;
105 }
106
107 data->last_updated = jiffies;
108 data->valid = 1;
109 }
110
111 mutex_unlock(&data->update_lock);
112
113 return data;
114}
115
116/* Return the voltage from the given register in millivolts */
117static int ltc4245_get_voltage(struct device *dev, u8 reg)
118{
119 struct ltc4245_data *data = ltc4245_update_device(dev);
120 const u8 regval = data->vregs[reg - 0x10];
121 u32 voltage = 0;
122
123 switch (reg) {
124 case LTC4245_12VIN:
125 case LTC4245_12VOUT:
126 voltage = regval * 55;
127 break;
128 case LTC4245_5VIN:
129 case LTC4245_5VOUT:
130 voltage = regval * 22;
131 break;
132 case LTC4245_3VIN:
133 case LTC4245_3VOUT:
134 voltage = regval * 15;
135 break;
136 case LTC4245_VEEIN:
137 case LTC4245_VEEOUT:
138 voltage = regval * -55;
139 break;
140 case LTC4245_GPIOADC1:
141 case LTC4245_GPIOADC2:
142 case LTC4245_GPIOADC3:
143 voltage = regval * 10;
144 break;
145 default:
146 /* If we get here, the developer messed up */
147 WARN_ON_ONCE(1);
148 break;
149 }
150
151 return voltage;
152}
153
154/* Return the current in the given sense register in milliAmperes */
155static unsigned int ltc4245_get_current(struct device *dev, u8 reg)
156{
157 struct ltc4245_data *data = ltc4245_update_device(dev);
158 const u8 regval = data->vregs[reg - 0x10];
159 unsigned int voltage;
160 unsigned int curr;
161
162 /* The strange looking conversions that follow are fixed-point
163 * math, since we cannot do floating point in the kernel.
164 *
165 * Step 1: convert sense register to microVolts
166 * Step 2: convert voltage to milliAmperes
167 *
168 * If you play around with the V=IR equation, you come up with
169 * the following: X uV / Y mOhm == Z mA
170 *
171 * With the resistors that are fractions of a milliOhm, we multiply
172 * the voltage and resistance by 10, to shift the decimal point.
173 * Now we can use the normal division operator again.
174 */
175
176 switch (reg) {
177 case LTC4245_12VSENSE:
178 voltage = regval * 250; /* voltage in uV */
179 curr = voltage / 50; /* sense resistor 50 mOhm */
180 break;
181 case LTC4245_5VSENSE:
182 voltage = regval * 125; /* voltage in uV */
183 curr = (voltage * 10) / 35; /* sense resistor 3.5 mOhm */
184 break;
185 case LTC4245_3VSENSE:
186 voltage = regval * 125; /* voltage in uV */
187 curr = (voltage * 10) / 25; /* sense resistor 2.5 mOhm */
188 break;
189 case LTC4245_VEESENSE:
190 voltage = regval * 250; /* voltage in uV */
191 curr = voltage / 100; /* sense resistor 100 mOhm */
192 break;
193 default:
194 /* If we get here, the developer messed up */
195 WARN_ON_ONCE(1);
196 curr = 0;
197 break;
198 }
199
200 return curr;
201}
202
203static ssize_t ltc4245_show_voltage(struct device *dev,
204 struct device_attribute *da,
205 char *buf)
206{
207 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
208 const int voltage = ltc4245_get_voltage(dev, attr->index);
209
210 return snprintf(buf, PAGE_SIZE, "%d\n", voltage);
211}
212
213static ssize_t ltc4245_show_current(struct device *dev,
214 struct device_attribute *da,
215 char *buf)
216{
217 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
218 const unsigned int curr = ltc4245_get_current(dev, attr->index);
219
220 return snprintf(buf, PAGE_SIZE, "%u\n", curr);
221}
222
223static ssize_t ltc4245_show_power(struct device *dev,
224 struct device_attribute *da,
225 char *buf)
226{
227 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
228 const unsigned int curr = ltc4245_get_current(dev, attr->index);
229 const int output_voltage = ltc4245_get_voltage(dev, attr->index+1);
230
231 /* current in mA * voltage in mV == power in uW */
232 const unsigned int power = abs(output_voltage * curr);
233
234 return snprintf(buf, PAGE_SIZE, "%u\n", power);
235}
236
237static ssize_t ltc4245_show_alarm(struct device *dev,
238 struct device_attribute *da,
239 char *buf)
240{
241 struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(da);
242 struct ltc4245_data *data = ltc4245_update_device(dev);
243 const u8 reg = data->cregs[attr->index];
244 const u32 mask = attr->nr;
245
246 return snprintf(buf, PAGE_SIZE, "%u\n", (reg & mask) ? 1 : 0);
247}
248
249/* These macros are used below in constructing device attribute objects
250 * for use with sysfs_create_group() to make a sysfs device file
251 * for each register.
252 */
253
254#define LTC4245_VOLTAGE(name, ltc4245_cmd_idx) \
255 static SENSOR_DEVICE_ATTR(name, S_IRUGO, \
256 ltc4245_show_voltage, NULL, ltc4245_cmd_idx)
257
258#define LTC4245_CURRENT(name, ltc4245_cmd_idx) \
259 static SENSOR_DEVICE_ATTR(name, S_IRUGO, \
260 ltc4245_show_current, NULL, ltc4245_cmd_idx)
261
262#define LTC4245_POWER(name, ltc4245_cmd_idx) \
263 static SENSOR_DEVICE_ATTR(name, S_IRUGO, \
264 ltc4245_show_power, NULL, ltc4245_cmd_idx)
265
266#define LTC4245_ALARM(name, mask, reg) \
267 static SENSOR_DEVICE_ATTR_2(name, S_IRUGO, \
268 ltc4245_show_alarm, NULL, (mask), reg)
269
270/* Construct a sensor_device_attribute structure for each register */
271
272/* Input voltages */
273LTC4245_VOLTAGE(in1_input, LTC4245_12VIN);
274LTC4245_VOLTAGE(in2_input, LTC4245_5VIN);
275LTC4245_VOLTAGE(in3_input, LTC4245_3VIN);
276LTC4245_VOLTAGE(in4_input, LTC4245_VEEIN);
277
278/* Input undervoltage alarms */
279LTC4245_ALARM(in1_min_alarm, (1 << 0), LTC4245_FAULT1);
280LTC4245_ALARM(in2_min_alarm, (1 << 1), LTC4245_FAULT1);
281LTC4245_ALARM(in3_min_alarm, (1 << 2), LTC4245_FAULT1);
282LTC4245_ALARM(in4_min_alarm, (1 << 3), LTC4245_FAULT1);
283
284/* Currents (via sense resistor) */
285LTC4245_CURRENT(curr1_input, LTC4245_12VSENSE);
286LTC4245_CURRENT(curr2_input, LTC4245_5VSENSE);
287LTC4245_CURRENT(curr3_input, LTC4245_3VSENSE);
288LTC4245_CURRENT(curr4_input, LTC4245_VEESENSE);
289
290/* Overcurrent alarms */
291LTC4245_ALARM(curr1_max_alarm, (1 << 4), LTC4245_FAULT1);
292LTC4245_ALARM(curr2_max_alarm, (1 << 5), LTC4245_FAULT1);
293LTC4245_ALARM(curr3_max_alarm, (1 << 6), LTC4245_FAULT1);
294LTC4245_ALARM(curr4_max_alarm, (1 << 7), LTC4245_FAULT1);
295
296/* Output voltages */
297LTC4245_VOLTAGE(in5_input, LTC4245_12VOUT);
298LTC4245_VOLTAGE(in6_input, LTC4245_5VOUT);
299LTC4245_VOLTAGE(in7_input, LTC4245_3VOUT);
300LTC4245_VOLTAGE(in8_input, LTC4245_VEEOUT);
301
302/* Power Bad alarms */
303LTC4245_ALARM(in5_min_alarm, (1 << 0), LTC4245_FAULT2);
304LTC4245_ALARM(in6_min_alarm, (1 << 1), LTC4245_FAULT2);
305LTC4245_ALARM(in7_min_alarm, (1 << 2), LTC4245_FAULT2);
306LTC4245_ALARM(in8_min_alarm, (1 << 3), LTC4245_FAULT2);
307
308/* GPIO voltages */
309LTC4245_VOLTAGE(in9_input, LTC4245_GPIOADC1);
310LTC4245_VOLTAGE(in10_input, LTC4245_GPIOADC2);
311LTC4245_VOLTAGE(in11_input, LTC4245_GPIOADC3);
312
313/* Power Consumption (virtual) */
314LTC4245_POWER(power1_input, LTC4245_12VSENSE);
315LTC4245_POWER(power2_input, LTC4245_5VSENSE);
316LTC4245_POWER(power3_input, LTC4245_3VSENSE);
317LTC4245_POWER(power4_input, LTC4245_VEESENSE);
318
319/* Finally, construct an array of pointers to members of the above objects,
320 * as required for sysfs_create_group()
321 */
322static struct attribute *ltc4245_attributes[] = {
323 &sensor_dev_attr_in1_input.dev_attr.attr,
324 &sensor_dev_attr_in2_input.dev_attr.attr,
325 &sensor_dev_attr_in3_input.dev_attr.attr,
326 &sensor_dev_attr_in4_input.dev_attr.attr,
327
328 &sensor_dev_attr_in1_min_alarm.dev_attr.attr,
329 &sensor_dev_attr_in2_min_alarm.dev_attr.attr,
330 &sensor_dev_attr_in3_min_alarm.dev_attr.attr,
331 &sensor_dev_attr_in4_min_alarm.dev_attr.attr,
332
333 &sensor_dev_attr_curr1_input.dev_attr.attr,
334 &sensor_dev_attr_curr2_input.dev_attr.attr,
335 &sensor_dev_attr_curr3_input.dev_attr.attr,
336 &sensor_dev_attr_curr4_input.dev_attr.attr,
337
338 &sensor_dev_attr_curr1_max_alarm.dev_attr.attr,
339 &sensor_dev_attr_curr2_max_alarm.dev_attr.attr,
340 &sensor_dev_attr_curr3_max_alarm.dev_attr.attr,
341 &sensor_dev_attr_curr4_max_alarm.dev_attr.attr,
342
343 &sensor_dev_attr_in5_input.dev_attr.attr,
344 &sensor_dev_attr_in6_input.dev_attr.attr,
345 &sensor_dev_attr_in7_input.dev_attr.attr,
346 &sensor_dev_attr_in8_input.dev_attr.attr,
347
348 &sensor_dev_attr_in5_min_alarm.dev_attr.attr,
349 &sensor_dev_attr_in6_min_alarm.dev_attr.attr,
350 &sensor_dev_attr_in7_min_alarm.dev_attr.attr,
351 &sensor_dev_attr_in8_min_alarm.dev_attr.attr,
352
353 &sensor_dev_attr_in9_input.dev_attr.attr,
354 &sensor_dev_attr_in10_input.dev_attr.attr,
355 &sensor_dev_attr_in11_input.dev_attr.attr,
356
357 &sensor_dev_attr_power1_input.dev_attr.attr,
358 &sensor_dev_attr_power2_input.dev_attr.attr,
359 &sensor_dev_attr_power3_input.dev_attr.attr,
360 &sensor_dev_attr_power4_input.dev_attr.attr,
361
362 NULL,
363};
364
365static const struct attribute_group ltc4245_group = {
366 .attrs = ltc4245_attributes,
367};
368
369static int ltc4245_probe(struct i2c_client *client,
370 const struct i2c_device_id *id)
371{
372 struct ltc4245_data *data;
373 int ret;
374
375 data = kzalloc(sizeof(*data), GFP_KERNEL);
376 if (!data) {
377 ret = -ENOMEM;
378 goto out_kzalloc;
379 }
380
381 i2c_set_clientdata(client, data);
382 mutex_init(&data->update_lock);
383
384 /* Initialize the LTC4245 chip */
385 /* TODO */
386
387 /* Register sysfs hooks */
388 ret = sysfs_create_group(&client->dev.kobj, &ltc4245_group);
389 if (ret)
390 goto out_sysfs_create_group;
391
392 data->hwmon_dev = hwmon_device_register(&client->dev);
393 if (IS_ERR(data->hwmon_dev)) {
394 ret = PTR_ERR(data->hwmon_dev);
395 goto out_hwmon_device_register;
396 }
397
398 return 0;
399
400out_hwmon_device_register:
401 sysfs_remove_group(&client->dev.kobj, &ltc4245_group);
402out_sysfs_create_group:
403 kfree(data);
404out_kzalloc:
405 return ret;
406}
407
408static int ltc4245_remove(struct i2c_client *client)
409{
410 struct ltc4245_data *data = i2c_get_clientdata(client);
411
412 hwmon_device_unregister(data->hwmon_dev);
413 sysfs_remove_group(&client->dev.kobj, &ltc4245_group);
414
415 kfree(data);
416
417 return 0;
418}
419
420/* Check that some bits in a control register appear at all possible
421 * locations without changing value
422 *
423 * @client: the i2c client to use
424 * @reg: the register to read
425 * @bits: the bits to check (0xff checks all bits,
426 * 0x03 checks only the last two bits)
427 *
428 * return -ERRNO if the register read failed
429 * return -ENODEV if the register value doesn't stay constant at all
430 * possible addresses
431 *
432 * return 0 for success
433 */
434static int ltc4245_check_control_reg(struct i2c_client *client, u8 reg, u8 bits)
435{
436 int i;
437 s32 v, voff1, voff2;
438
439 /* Read register and check for error */
440 v = i2c_smbus_read_byte_data(client, reg);
441 if (v < 0)
442 return v;
443
444 v &= bits;
445
446 for (i = 0x00; i < 0xff; i += 0x20) {
447
448 voff1 = i2c_smbus_read_byte_data(client, reg + i);
449 if (voff1 < 0)
450 return voff1;
451
452 voff2 = i2c_smbus_read_byte_data(client, reg + i + 0x08);
453 if (voff2 < 0)
454 return voff2;
455
456 voff1 &= bits;
457 voff2 &= bits;
458
459 if (v != voff1 || v != voff2)
460 return -ENODEV;
461 }
462
463 return 0;
464}
465
466static int ltc4245_detect(struct i2c_client *client,
467 int kind,
468 struct i2c_board_info *info)
469{
470 struct i2c_adapter *adapter = client->adapter;
471
472 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
473 return -ENODEV;
474
475 if (kind < 0) { /* probed detection - check the chip type */
476 s32 v; /* 8 bits from the chip, or -ERRNO */
477
478 /* Chip registers 0x00-0x07 are control registers
479 * Chip registers 0x10-0x1f are data registers
480 *
481 * Address bits b7-b5 are ignored. This makes the chip "repeat"
482 * in steps of 0x20. Any control registers should appear with
483 * the same values across all duplicated addresses.
484 *
485 * Register 0x02 bit b2 is reserved, expect 0
486 * Register 0x07 bits b7 to b4 are reserved, expect 0
487 *
488 * Registers 0x01, 0x02 are control registers and should not
489 * change on their own.
490 *
491 * Register 0x06 bits b6 and b7 are control bits, and should
492 * not change on their own.
493 *
494 * Register 0x07 bits b3 to b0 are control bits, and should
495 * not change on their own.
496 */
497
498 /* read register 0x02 reserved bit, expect 0 */
499 v = i2c_smbus_read_byte_data(client, LTC4245_CONTROL);
500 if (v < 0 || (v & 0x04) != 0)
501 return -ENODEV;
502
503 /* read register 0x07 reserved bits, expect 0 */
504 v = i2c_smbus_read_byte_data(client, LTC4245_ADCADR);
505 if (v < 0 || (v & 0xf0) != 0)
506 return -ENODEV;
507
508 /* check that the alert register appears at all locations */
509 if (ltc4245_check_control_reg(client, LTC4245_ALERT, 0xff))
510 return -ENODEV;
511
512 /* check that the control register appears at all locations */
513 if (ltc4245_check_control_reg(client, LTC4245_CONTROL, 0xff))
514 return -ENODEV;
515
516 /* check that register 0x06 bits b6 and b7 stay constant */
517 if (ltc4245_check_control_reg(client, LTC4245_GPIO, 0xc0))
518 return -ENODEV;
519
520 /* check that register 0x07 bits b3-b0 stay constant */
521 if (ltc4245_check_control_reg(client, LTC4245_ADCADR, 0x0f))
522 return -ENODEV;
523 }
524
525 strlcpy(info->type, "ltc4245", I2C_NAME_SIZE);
526 dev_info(&adapter->dev, "ltc4245 %s at address 0x%02x\n",
527 kind < 0 ? "probed" : "forced",
528 client->addr);
529
530 return 0;
531}
532
533static const struct i2c_device_id ltc4245_id[] = {
534 { "ltc4245", ltc4245 },
535 { }
536};
537MODULE_DEVICE_TABLE(i2c, ltc4245_id);
538
539/* This is the driver that will be inserted */
540static struct i2c_driver ltc4245_driver = {
541 .class = I2C_CLASS_HWMON,
542 .driver = {
543 .name = "ltc4245",
544 },
545 .probe = ltc4245_probe,
546 .remove = ltc4245_remove,
547 .id_table = ltc4245_id,
548 .detect = ltc4245_detect,
549 .address_data = &addr_data,
550};
551
552static int __init ltc4245_init(void)
553{
554 return i2c_add_driver(&ltc4245_driver);
555}
556
557static void __exit ltc4245_exit(void)
558{
559 i2c_del_driver(&ltc4245_driver);
560}
561
562MODULE_AUTHOR("Ira W. Snyder <iws@ovro.caltech.edu>");
563MODULE_DESCRIPTION("LTC4245 driver");
564MODULE_LICENSE("GPL");
565
566module_init(ltc4245_init);
567module_exit(ltc4245_exit);
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c
index 5fbfa34c110e..fb052fea3744 100644
--- a/drivers/hwmon/pc87360.c
+++ b/drivers/hwmon/pc87360.c
@@ -43,6 +43,7 @@
43#include <linux/hwmon-vid.h> 43#include <linux/hwmon-vid.h>
44#include <linux/err.h> 44#include <linux/err.h>
45#include <linux/mutex.h> 45#include <linux/mutex.h>
46#include <linux/acpi.h>
46#include <asm/io.h> 47#include <asm/io.h>
47 48
48static u8 devid; 49static u8 devid;
@@ -1627,6 +1628,11 @@ static int __init pc87360_device_add(unsigned short address)
1627 continue; 1628 continue;
1628 res.start = extra_isa[i]; 1629 res.start = extra_isa[i];
1629 res.end = extra_isa[i] + PC87360_EXTENT - 1; 1630 res.end = extra_isa[i] + PC87360_EXTENT - 1;
1631
1632 err = acpi_check_resource_conflict(&res);
1633 if (err)
1634 goto exit_device_put;
1635
1630 err = platform_device_add_resources(pdev, &res, 1); 1636 err = platform_device_add_resources(pdev, &res, 1);
1631 if (err) { 1637 if (err) {
1632 printk(KERN_ERR "pc87360: Device resource[%d] " 1638 printk(KERN_ERR "pc87360: Device resource[%d] "
diff --git a/drivers/hwmon/pc87427.c b/drivers/hwmon/pc87427.c
index 7265f22ae5cd..3a8a0f7a7736 100644
--- a/drivers/hwmon/pc87427.c
+++ b/drivers/hwmon/pc87427.c
@@ -32,6 +32,7 @@
32#include <linux/mutex.h> 32#include <linux/mutex.h>
33#include <linux/sysfs.h> 33#include <linux/sysfs.h>
34#include <linux/ioport.h> 34#include <linux/ioport.h>
35#include <linux/acpi.h>
35#include <asm/io.h> 36#include <asm/io.h>
36 37
37static unsigned short force_id; 38static unsigned short force_id;
@@ -524,6 +525,10 @@ static int __init pc87427_device_add(unsigned short address)
524 }; 525 };
525 int err; 526 int err;
526 527
528 err = acpi_check_resource_conflict(&res);
529 if (err)
530 goto exit;
531
527 pdev = platform_device_alloc(DRVNAME, address); 532 pdev = platform_device_alloc(DRVNAME, address);
528 if (!pdev) { 533 if (!pdev) {
529 err = -ENOMEM; 534 err = -ENOMEM;
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c
index a276806f3d53..aa2e8318f167 100644
--- a/drivers/hwmon/sis5595.c
+++ b/drivers/hwmon/sis5595.c
@@ -62,6 +62,7 @@
62#include <linux/jiffies.h> 62#include <linux/jiffies.h>
63#include <linux/mutex.h> 63#include <linux/mutex.h>
64#include <linux/sysfs.h> 64#include <linux/sysfs.h>
65#include <linux/acpi.h>
65#include <asm/io.h> 66#include <asm/io.h>
66 67
67 68
@@ -727,6 +728,10 @@ static int __devinit sis5595_device_add(unsigned short address)
727 }; 728 };
728 int err; 729 int err;
729 730
731 err = acpi_check_resource_conflict(&res);
732 if (err)
733 goto exit;
734
730 pdev = platform_device_alloc("sis5595", address); 735 pdev = platform_device_alloc("sis5595", address);
731 if (!pdev) { 736 if (!pdev) {
732 err = -ENOMEM; 737 err = -ENOMEM;
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c
index eb03544c731c..6f6d52b4fb64 100644
--- a/drivers/hwmon/smsc47b397.c
+++ b/drivers/hwmon/smsc47b397.c
@@ -36,6 +36,7 @@
36#include <linux/err.h> 36#include <linux/err.h>
37#include <linux/init.h> 37#include <linux/init.h>
38#include <linux/mutex.h> 38#include <linux/mutex.h>
39#include <linux/acpi.h>
39#include <asm/io.h> 40#include <asm/io.h>
40 41
41static unsigned short force_id; 42static unsigned short force_id;
@@ -303,6 +304,10 @@ static int __init smsc47b397_device_add(unsigned short address)
303 }; 304 };
304 int err; 305 int err;
305 306
307 err = acpi_check_resource_conflict(&res);
308 if (err)
309 goto exit;
310
306 pdev = platform_device_alloc(DRVNAME, address); 311 pdev = platform_device_alloc(DRVNAME, address);
307 if (!pdev) { 312 if (!pdev) {
308 err = -ENOMEM; 313 err = -ENOMEM;
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index d1b498548736..a92dbb97ee99 100644
--- a/drivers/hwmon/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
@@ -37,6 +37,7 @@
37#include <linux/init.h> 37#include <linux/init.h>
38#include <linux/mutex.h> 38#include <linux/mutex.h>
39#include <linux/sysfs.h> 39#include <linux/sysfs.h>
40#include <linux/acpi.h>
40#include <asm/io.h> 41#include <asm/io.h>
41 42
42static unsigned short force_id; 43static unsigned short force_id;
@@ -705,6 +706,10 @@ static int __init smsc47m1_device_add(unsigned short address,
705 }; 706 };
706 int err; 707 int err;
707 708
709 err = acpi_check_resource_conflict(&res);
710 if (err)
711 goto exit;
712
708 pdev = platform_device_alloc(DRVNAME, address); 713 pdev = platform_device_alloc(DRVNAME, address);
709 if (!pdev) { 714 if (!pdev) {
710 err = -ENOMEM; 715 err = -ENOMEM;
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c
index f1ee5e731968..a022aedcaacb 100644
--- a/drivers/hwmon/via686a.c
+++ b/drivers/hwmon/via686a.c
@@ -41,6 +41,7 @@
41#include <linux/init.h> 41#include <linux/init.h>
42#include <linux/mutex.h> 42#include <linux/mutex.h>
43#include <linux/sysfs.h> 43#include <linux/sysfs.h>
44#include <linux/acpi.h>
44#include <asm/io.h> 45#include <asm/io.h>
45 46
46 47
@@ -783,6 +784,10 @@ static int __devinit via686a_device_add(unsigned short address)
783 }; 784 };
784 int err; 785 int err;
785 786
787 err = acpi_check_resource_conflict(&res);
788 if (err)
789 goto exit;
790
786 pdev = platform_device_alloc("via686a", address); 791 pdev = platform_device_alloc("via686a", address);
787 if (!pdev) { 792 if (!pdev) {
788 err = -ENOMEM; 793 err = -ENOMEM;
diff --git a/drivers/hwmon/vt1211.c b/drivers/hwmon/vt1211.c
index 12b43590fa53..b0ce37852281 100644
--- a/drivers/hwmon/vt1211.c
+++ b/drivers/hwmon/vt1211.c
@@ -32,6 +32,7 @@
32#include <linux/err.h> 32#include <linux/err.h>
33#include <linux/mutex.h> 33#include <linux/mutex.h>
34#include <linux/ioport.h> 34#include <linux/ioport.h>
35#include <linux/acpi.h>
35#include <asm/io.h> 36#include <asm/io.h>
36 37
37static int uch_config = -1; 38static int uch_config = -1;
@@ -1259,6 +1260,10 @@ static int __init vt1211_device_add(unsigned short address)
1259 } 1260 }
1260 1261
1261 res.name = pdev->name; 1262 res.name = pdev->name;
1263 err = acpi_check_resource_conflict(&res);
1264 if (err)
1265 goto EXIT;
1266
1262 err = platform_device_add_resources(pdev, &res, 1); 1267 err = platform_device_add_resources(pdev, &res, 1);
1263 if (err) { 1268 if (err) {
1264 printk(KERN_ERR DRVNAME ": Device resource addition failed " 1269 printk(KERN_ERR DRVNAME ": Device resource addition failed "
diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c
index 5bc57275cae8..9982b45fbb14 100644
--- a/drivers/hwmon/vt8231.c
+++ b/drivers/hwmon/vt8231.c
@@ -35,6 +35,7 @@
35#include <linux/hwmon-vid.h> 35#include <linux/hwmon-vid.h>
36#include <linux/err.h> 36#include <linux/err.h>
37#include <linux/mutex.h> 37#include <linux/mutex.h>
38#include <linux/acpi.h>
38#include <asm/io.h> 39#include <asm/io.h>
39 40
40static int force_addr; 41static int force_addr;
@@ -894,6 +895,10 @@ static int __devinit vt8231_device_add(unsigned short address)
894 }; 895 };
895 int err; 896 int err;
896 897
898 err = acpi_check_resource_conflict(&res);
899 if (err)
900 goto exit;
901
897 pdev = platform_device_alloc("vt8231", address); 902 pdev = platform_device_alloc("vt8231", address);
898 if (!pdev) { 903 if (!pdev) {
899 err = -ENOMEM; 904 err = -ENOMEM;
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index 075164dd65a7..cb808d015361 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -48,6 +48,7 @@
48#include <linux/hwmon-vid.h> 48#include <linux/hwmon-vid.h>
49#include <linux/err.h> 49#include <linux/err.h>
50#include <linux/mutex.h> 50#include <linux/mutex.h>
51#include <linux/acpi.h>
51#include <asm/io.h> 52#include <asm/io.h>
52#include "lm75.h" 53#include "lm75.h"
53 54
@@ -502,7 +503,7 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev)
502 } 503 }
503 504
504 for (i = 0; i < 4; i++) { 505 for (i = 0; i < 4; i++) {
505 /* pwmcfg, tolarance mapped for i=0, i=1 to same reg */ 506 /* pwmcfg, tolerance mapped for i=0, i=1 to same reg */
506 if (i != 1) { 507 if (i != 1) {
507 pwmcfg = w83627ehf_read_value(data, 508 pwmcfg = w83627ehf_read_value(data,
508 W83627EHF_REG_PWM_ENABLE[i]); 509 W83627EHF_REG_PWM_ENABLE[i]);
@@ -1544,6 +1545,11 @@ static int __init sensors_w83627ehf_init(void)
1544 res.start = address + IOREGION_OFFSET; 1545 res.start = address + IOREGION_OFFSET;
1545 res.end = address + IOREGION_OFFSET + IOREGION_LENGTH - 1; 1546 res.end = address + IOREGION_OFFSET + IOREGION_LENGTH - 1;
1546 res.flags = IORESOURCE_IO; 1547 res.flags = IORESOURCE_IO;
1548
1549 err = acpi_check_resource_conflict(&res);
1550 if (err)
1551 goto exit;
1552
1547 err = platform_device_add_resources(pdev, &res, 1); 1553 err = platform_device_add_resources(pdev, &res, 1);
1548 if (err) { 1554 if (err) {
1549 printk(KERN_ERR DRVNAME ": Device resource addition failed " 1555 printk(KERN_ERR DRVNAME ": Device resource addition failed "
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index b30e5796cb26..389150ba30d3 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -50,6 +50,7 @@
50#include <linux/err.h> 50#include <linux/err.h>
51#include <linux/mutex.h> 51#include <linux/mutex.h>
52#include <linux/ioport.h> 52#include <linux/ioport.h>
53#include <linux/acpi.h>
53#include <asm/io.h> 54#include <asm/io.h>
54#include "lm75.h" 55#include "lm75.h"
55 56
@@ -1793,6 +1794,10 @@ static int __init w83627hf_device_add(unsigned short address,
1793 }; 1794 };
1794 int err; 1795 int err;
1795 1796
1797 err = acpi_check_resource_conflict(&res);
1798 if (err)
1799 goto exit;
1800
1796 pdev = platform_device_alloc(DRVNAME, address); 1801 pdev = platform_device_alloc(DRVNAME, address);
1797 if (!pdev) { 1802 if (!pdev) {
1798 err = -ENOMEM; 1803 err = -ENOMEM;
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index fc12bd412e3a..dbfb30c588d8 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -58,7 +58,10 @@ static const unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
58 0x2e, 0x2f, I2C_CLIENT_END }; 58 0x2e, 0x2f, I2C_CLIENT_END };
59/* Insmod parameters */ 59/* Insmod parameters */
60I2C_CLIENT_INSMOD_4(w83781d, w83782d, w83783s, as99127f); 60I2C_CLIENT_INSMOD_4(w83781d, w83782d, w83783s, as99127f);
61I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " 61
62static unsigned short force_subclients[4];
63module_param_array(force_subclients, short, NULL, 0);
64MODULE_PARM_DESC(force_subclients, "List of subclient addresses: "
62 "{bus, clientaddr, subclientaddr1, subclientaddr2}"); 65 "{bus, clientaddr, subclientaddr1, subclientaddr2}");
63 66
64static int reset; 67static int reset;
diff --git a/drivers/hwmon/w83791d.c b/drivers/hwmon/w83791d.c
index 5768def8a4f2..97851c5ba3a3 100644
--- a/drivers/hwmon/w83791d.c
+++ b/drivers/hwmon/w83791d.c
@@ -53,7 +53,10 @@ static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f,
53 53
54/* Insmod parameters */ 54/* Insmod parameters */
55I2C_CLIENT_INSMOD_1(w83791d); 55I2C_CLIENT_INSMOD_1(w83791d);
56I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " 56
57static unsigned short force_subclients[4];
58module_param_array(force_subclients, short, NULL, 0);
59MODULE_PARM_DESC(force_subclients, "List of subclient addresses: "
57 "{bus, clientaddr, subclientaddr1, subclientaddr2}"); 60 "{bus, clientaddr, subclientaddr1, subclientaddr2}");
58 61
59static int reset; 62static int reset;
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c
index cf94c5b0c879..2be16194ddf3 100644
--- a/drivers/hwmon/w83792d.c
+++ b/drivers/hwmon/w83792d.c
@@ -51,7 +51,10 @@ static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f,
51 51
52/* Insmod parameters */ 52/* Insmod parameters */
53I2C_CLIENT_INSMOD_1(w83792d); 53I2C_CLIENT_INSMOD_1(w83792d);
54I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " 54
55static unsigned short force_subclients[4];
56module_param_array(force_subclients, short, NULL, 0);
57MODULE_PARM_DESC(force_subclients, "List of subclient addresses: "
55 "{bus, clientaddr, subclientaddr1, subclientaddr2}"); 58 "{bus, clientaddr, subclientaddr1, subclientaddr2}");
56 59
57static int init; 60static int init;
diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
index 0a739f1c69be..47dd398f7258 100644
--- a/drivers/hwmon/w83793.c
+++ b/drivers/hwmon/w83793.c
@@ -42,7 +42,10 @@ static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f,
42 42
43/* Insmod parameters */ 43/* Insmod parameters */
44I2C_CLIENT_INSMOD_1(w83793); 44I2C_CLIENT_INSMOD_1(w83793);
45I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: " 45
46static unsigned short force_subclients[4];
47module_param_array(force_subclients, short, NULL, 0);
48MODULE_PARM_DESC(force_subclients, "List of subclient addresses: "
46 "{bus, clientaddr, subclientaddr1, subclientaddr2}"); 49 "{bus, clientaddr, subclientaddr1, subclientaddr2}");
47 50
48static int reset; 51static int reset;
diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c
index fc3e5b026423..dd9e796fad69 100644
--- a/drivers/i2c/busses/i2c-ali1563.c
+++ b/drivers/i2c/busses/i2c-ali1563.c
@@ -399,8 +399,8 @@ static int __devinit ali1563_probe(struct pci_dev * dev,
399 if ((error = ali1563_setup(dev))) 399 if ((error = ali1563_setup(dev)))
400 goto exit; 400 goto exit;
401 ali1563_adapter.dev.parent = &dev->dev; 401 ali1563_adapter.dev.parent = &dev->dev;
402 sprintf(ali1563_adapter.name,"SMBus ALi 1563 Adapter @ %04x", 402 snprintf(ali1563_adapter.name, sizeof(ali1563_adapter.name),
403 ali1563_smba); 403 "SMBus ALi 1563 Adapter @ %04x", ali1563_smba);
404 if ((error = i2c_add_adapter(&ali1563_adapter))) 404 if ((error = i2c_add_adapter(&ali1563_adapter)))
405 goto exit_shutdown; 405 goto exit_shutdown;
406 return 0; 406 return 0;
diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
index 8ba2bcf727d3..378fcb5d5783 100644
--- a/drivers/i2c/busses/i2c-amd756-s4882.c
+++ b/drivers/i2c/busses/i2c-amd756-s4882.c
@@ -197,8 +197,8 @@ static int __init amd756_s4882_init(void)
197 for (i = 1; i < 5; i++) { 197 for (i = 1; i < 5; i++) {
198 s4882_algo[i] = *(amd756_smbus.algo); 198 s4882_algo[i] = *(amd756_smbus.algo);
199 s4882_adapter[i] = amd756_smbus; 199 s4882_adapter[i] = amd756_smbus;
200 sprintf(s4882_adapter[i].name, 200 snprintf(s4882_adapter[i].name, sizeof(s4882_adapter[i].name),
201 "SMBus 8111 adapter (CPU%d)", i-1); 201 "SMBus 8111 adapter (CPU%d)", i-1);
202 s4882_adapter[i].algo = s4882_algo+i; 202 s4882_adapter[i].algo = s4882_algo+i;
203 s4882_adapter[i].dev.parent = amd756_smbus.dev.parent; 203 s4882_adapter[i].dev.parent = amd756_smbus.dev.parent;
204 } 204 }
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c
index 424dad6f18d8..36bee5b9c952 100644
--- a/drivers/i2c/busses/i2c-amd756.c
+++ b/drivers/i2c/busses/i2c-amd756.c
@@ -380,8 +380,9 @@ static int __devinit amd756_probe(struct pci_dev *pdev,
380 /* set up the sysfs linkage to our parent device */ 380 /* set up the sysfs linkage to our parent device */
381 amd756_smbus.dev.parent = &pdev->dev; 381 amd756_smbus.dev.parent = &pdev->dev;
382 382
383 sprintf(amd756_smbus.name, "SMBus %s adapter at %04x", 383 snprintf(amd756_smbus.name, sizeof(amd756_smbus.name),
384 chipname[id->driver_data], amd756_ioport); 384 "SMBus %s adapter at %04x", chipname[id->driver_data],
385 amd756_ioport);
385 386
386 error = i2c_add_adapter(&amd756_smbus); 387 error = i2c_add_adapter(&amd756_smbus);
387 if (error) { 388 if (error) {
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 9efb02137254..67d9dc5b351b 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -222,7 +222,7 @@ static int __devinit at91_i2c_probe(struct platform_device *pdev)
222 rc = -ENOMEM; 222 rc = -ENOMEM;
223 goto fail2; 223 goto fail2;
224 } 224 }
225 sprintf(adapter->name, "AT91"); 225 snprintf(adapter->name, sizeof(adapter->name), "AT91");
226 adapter->algo = &at91_algorithm; 226 adapter->algo = &at91_algorithm;
227 adapter->class = I2C_CLASS_HWMON; 227 adapter->class = I2C_CLASS_HWMON;
228 adapter->dev.parent = &pdev->dev; 228 adapter->dev.parent = &pdev->dev;
diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index 3c855ff2992f..3fd2c417c1e0 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -656,7 +656,7 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev)
656 strlcpy(p_adap->name, pdev->name, sizeof(p_adap->name)); 656 strlcpy(p_adap->name, pdev->name, sizeof(p_adap->name));
657 p_adap->algo = &bfin_twi_algorithm; 657 p_adap->algo = &bfin_twi_algorithm;
658 p_adap->algo_data = iface; 658 p_adap->algo_data = iface;
659 p_adap->class = I2C_CLASS_ALL; 659 p_adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
660 p_adap->dev.parent = &pdev->dev; 660 p_adap->dev.parent = &pdev->dev;
661 661
662 rc = peripheral_request_list(pin_req[pdev->id], "i2c-bfin-twi"); 662 rc = peripheral_request_list(pin_req[pdev->id], "i2c-bfin-twi");
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 5123eb69a971..526625eaa84b 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -64,7 +64,7 @@
64#include <linux/init.h> 64#include <linux/init.h>
65#include <linux/i2c.h> 65#include <linux/i2c.h>
66#include <linux/acpi.h> 66#include <linux/acpi.h>
67#include <asm/io.h> 67#include <linux/io.h>
68 68
69/* I801 SMBus address offsets */ 69/* I801 SMBus address offsets */
70#define SMBHSTSTS (0 + i801_smba) 70#define SMBHSTSTS (0 + i801_smba)
@@ -583,6 +583,40 @@ static struct pci_device_id i801_ids[] = {
583 583
584MODULE_DEVICE_TABLE (pci, i801_ids); 584MODULE_DEVICE_TABLE (pci, i801_ids);
585 585
586#if defined CONFIG_INPUT_APANEL || defined CONFIG_INPUT_APANEL_MODULE
587static unsigned char apanel_addr;
588
589/* Scan the system ROM for the signature "FJKEYINF" */
590static __init const void __iomem *bios_signature(const void __iomem *bios)
591{
592 ssize_t offset;
593 const unsigned char signature[] = "FJKEYINF";
594
595 for (offset = 0; offset < 0x10000; offset += 0x10) {
596 if (check_signature(bios + offset, signature,
597 sizeof(signature)-1))
598 return bios + offset;
599 }
600 return NULL;
601}
602
603static void __init input_apanel_init(void)
604{
605 void __iomem *bios;
606 const void __iomem *p;
607
608 bios = ioremap(0xF0000, 0x10000); /* Can't fail */
609 p = bios_signature(bios);
610 if (p) {
611 /* just use the first address */
612 apanel_addr = readb(p + 8 + 3) >> 1;
613 }
614 iounmap(bios);
615}
616#else
617static void __init input_apanel_init(void) {}
618#endif
619
586static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id *id) 620static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
587{ 621{
588 unsigned char temp; 622 unsigned char temp;
@@ -667,6 +701,19 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id
667 dev_err(&dev->dev, "Failed to add SMBus adapter\n"); 701 dev_err(&dev->dev, "Failed to add SMBus adapter\n");
668 goto exit_release; 702 goto exit_release;
669 } 703 }
704
705 /* Register optional slaves */
706#if defined CONFIG_INPUT_APANEL || defined CONFIG_INPUT_APANEL_MODULE
707 if (apanel_addr) {
708 struct i2c_board_info info;
709
710 memset(&info, 0, sizeof(struct i2c_board_info));
711 info.addr = apanel_addr;
712 strlcpy(info.type, "fujitsu_apanel", I2C_NAME_SIZE);
713 i2c_new_device(&i801_adapter, &info);
714 }
715#endif
716
670 return 0; 717 return 0;
671 718
672exit_release: 719exit_release:
@@ -717,6 +764,7 @@ static struct pci_driver i801_driver = {
717 764
718static int __init i2c_i801_init(void) 765static int __init i2c_i801_init(void)
719{ 766{
767 input_apanel_init();
720 return pci_register_driver(&i801_driver); 768 return pci_register_driver(&i801_driver);
721} 769}
722 770
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 587f5b2380d4..6af68146c342 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -1076,10 +1076,10 @@ static int i2c_pxa_probe(struct platform_device *dev)
1076 1076
1077#ifdef CONFIG_I2C_PXA_SLAVE 1077#ifdef CONFIG_I2C_PXA_SLAVE
1078 printk(KERN_INFO "I2C: %s: PXA I2C adapter, slave address %d\n", 1078 printk(KERN_INFO "I2C: %s: PXA I2C adapter, slave address %d\n",
1079 i2c->adap.dev.bus_id, i2c->slave_addr); 1079 dev_name(&i2c->adap.dev), i2c->slave_addr);
1080#else 1080#else
1081 printk(KERN_INFO "I2C: %s: PXA I2C adapter\n", 1081 printk(KERN_INFO "I2C: %s: PXA I2C adapter\n",
1082 i2c->adap.dev.bus_id); 1082 dev_name(&i2c->adap.dev));
1083#endif 1083#endif
1084 return 0; 1084 return 0;
1085 1085
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index f69f91ffb469..5b7f95641ba4 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -906,7 +906,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
906 906
907 platform_set_drvdata(pdev, i2c); 907 platform_set_drvdata(pdev, i2c);
908 908
909 dev_info(&pdev->dev, "%s: S3C I2C adapter\n", i2c->adap.dev.bus_id); 909 dev_info(&pdev->dev, "%s: S3C I2C adapter\n", dev_name(&i2c->adap.dev));
910 return 0; 910 return 0;
911 911
912 err_cpufreq: 912 err_cpufreq:
diff --git a/drivers/i2c/busses/i2c-sh7760.c b/drivers/i2c/busses/i2c-sh7760.c
index 5e0e254976de..baa28b73ae42 100644
--- a/drivers/i2c/busses/i2c-sh7760.c
+++ b/drivers/i2c/busses/i2c-sh7760.c
@@ -475,7 +475,7 @@ static int __devinit sh7760_i2c_probe(struct platform_device *pdev)
475 475
476 id->adap.nr = pdev->id; 476 id->adap.nr = pdev->id;
477 id->adap.algo = &sh7760_i2c_algo; 477 id->adap.algo = &sh7760_i2c_algo;
478 id->adap.class = I2C_CLASS_ALL; 478 id->adap.class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
479 id->adap.retries = 3; 479 id->adap.retries = 3;
480 id->adap.algo_data = id; 480 id->adap.algo_data = id;
481 id->adap.dev.parent = &pdev->dev; 481 id->adap.dev.parent = &pdev->dev;
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index 6c3d60b939bf..1c01083b01b5 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -500,7 +500,7 @@ static int sh_mobile_i2c_hook_irqs(struct platform_device *dev, int hook)
500 while ((res = platform_get_resource(dev, IORESOURCE_IRQ, k))) { 500 while ((res = platform_get_resource(dev, IORESOURCE_IRQ, k))) {
501 for (n = res->start; hook && n <= res->end; n++) { 501 for (n = res->start; hook && n <= res->end; n++) {
502 if (request_irq(n, sh_mobile_i2c_isr, IRQF_DISABLED, 502 if (request_irq(n, sh_mobile_i2c_isr, IRQF_DISABLED,
503 dev->dev.bus_id, dev)) 503 dev_name(&dev->dev), dev))
504 goto rollback; 504 goto rollback;
505 } 505 }
506 k++; 506 k++;
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c
index dfc2d5eb6a68..8ce2daff985c 100644
--- a/drivers/i2c/busses/i2c-sis5595.c
+++ b/drivers/i2c/busses/i2c-sis5595.c
@@ -389,8 +389,8 @@ static int __devinit sis5595_probe(struct pci_dev *dev, const struct pci_device_
389 /* set up the sysfs linkage to our parent device */ 389 /* set up the sysfs linkage to our parent device */
390 sis5595_adapter.dev.parent = &dev->dev; 390 sis5595_adapter.dev.parent = &dev->dev;
391 391
392 sprintf(sis5595_adapter.name, "SMBus SIS5595 adapter at %04x", 392 snprintf(sis5595_adapter.name, sizeof(sis5595_adapter.name),
393 sis5595_base + SMB_INDEX); 393 "SMBus SIS5595 adapter at %04x", sis5595_base + SMB_INDEX);
394 err = i2c_add_adapter(&sis5595_adapter); 394 err = i2c_add_adapter(&sis5595_adapter);
395 if (err) { 395 if (err) {
396 release_region(sis5595_base + SMB_INDEX, 2); 396 release_region(sis5595_base + SMB_INDEX, 2);
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c
index e7c4b790da54..9c9c016ff2b5 100644
--- a/drivers/i2c/busses/i2c-sis630.c
+++ b/drivers/i2c/busses/i2c-sis630.c
@@ -487,8 +487,8 @@ static int __devinit sis630_probe(struct pci_dev *dev, const struct pci_device_i
487 /* set up the sysfs linkage to our parent device */ 487 /* set up the sysfs linkage to our parent device */
488 sis630_adapter.dev.parent = &dev->dev; 488 sis630_adapter.dev.parent = &dev->dev;
489 489
490 sprintf(sis630_adapter.name, "SMBus SIS630 adapter at %04x", 490 snprintf(sis630_adapter.name, sizeof(sis630_adapter.name),
491 acpi_base + SMB_STS); 491 "SMBus SIS630 adapter at %04x", acpi_base + SMB_STS);
492 492
493 return i2c_add_adapter(&sis630_adapter); 493 return i2c_add_adapter(&sis630_adapter);
494} 494}
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
index 864ac561fdbb..b9bef04b7be4 100644
--- a/drivers/i2c/chips/Kconfig
+++ b/drivers/i2c/chips/Kconfig
@@ -114,18 +114,6 @@ config SENSORS_PCF8591
114 These devices are hard to detect and rarely found on mainstream 114 These devices are hard to detect and rarely found on mainstream
115 hardware. If unsure, say N. 115 hardware. If unsure, say N.
116 116
117config ISP1301_OMAP
118 tristate "Philips ISP1301 with OMAP OTG"
119 depends on ARCH_OMAP_OTG
120 help
121 If you say yes here you get support for the Philips ISP1301
122 USB-On-The-Go transceiver working with the OMAP OTG controller.
123 The ISP1301 is used in products including H2 and H3 development
124 boards for Texas Instruments OMAP processors.
125
126 This driver can also be built as a module. If so, the module
127 will be called isp1301_omap.
128
129config SENSORS_MAX6875 117config SENSORS_MAX6875
130 tristate "Maxim MAX6875 Power supply supervisor" 118 tristate "Maxim MAX6875 Power supply supervisor"
131 depends on EXPERIMENTAL 119 depends on EXPERIMENTAL
@@ -151,15 +139,4 @@ config SENSORS_TSL2550
151 This driver can also be built as a module. If so, the module 139 This driver can also be built as a module. If so, the module
152 will be called tsl2550. 140 will be called tsl2550.
153 141
154config MCU_MPC8349EMITX
155 tristate "MPC8349E-mITX MCU driver"
156 depends on I2C && PPC_83xx
157 select GENERIC_GPIO
158 select ARCH_REQUIRE_GPIOLIB
159 help
160 Say Y here to enable soft power-off functionality on the Freescale
161 boards with the MPC8349E-mITX-compatible MCU chips. This driver will
162 also register MCU GPIOs with the generic GPIO API, so you'll able
163 to use MCU pins as GPIOs.
164
165endmenu 142endmenu
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile
index 8b95f41a5001..00fcb5193ac2 100644
--- a/drivers/i2c/chips/Makefile
+++ b/drivers/i2c/chips/Makefile
@@ -18,9 +18,7 @@ obj-$(CONFIG_SENSORS_PCA9539) += pca9539.o
18obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o 18obj-$(CONFIG_SENSORS_PCF8574) += pcf8574.o
19obj-$(CONFIG_PCF8575) += pcf8575.o 19obj-$(CONFIG_PCF8575) += pcf8575.o
20obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o 20obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o
21obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o
22obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o 21obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o
23obj-$(CONFIG_MCU_MPC8349EMITX) += mcu_mpc8349emitx.o
24 22
25ifeq ($(CONFIG_I2C_DEBUG_CHIP),y) 23ifeq ($(CONFIG_I2C_DEBUG_CHIP),y)
26EXTRA_CFLAGS += -DDEBUG 24EXTRA_CFLAGS += -DDEBUG
diff --git a/drivers/i2c/chips/mcu_mpc8349emitx.c b/drivers/i2c/chips/mcu_mpc8349emitx.c
deleted file mode 100644
index 82a9bcb858b6..000000000000
--- a/drivers/i2c/chips/mcu_mpc8349emitx.c
+++ /dev/null
@@ -1,209 +0,0 @@
1/*
2 * Power Management and GPIO expander driver for MPC8349E-mITX-compatible MCU
3 *
4 * Copyright (c) 2008 MontaVista Software, Inc.
5 *
6 * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */
13
14#include <linux/init.h>
15#include <linux/kernel.h>
16#include <linux/module.h>
17#include <linux/device.h>
18#include <linux/mutex.h>
19#include <linux/i2c.h>
20#include <linux/gpio.h>
21#include <linux/of.h>
22#include <linux/of_gpio.h>
23#include <asm/prom.h>
24#include <asm/machdep.h>
25
26/*
27 * I don't have specifications for the MCU firmware, I found this register
28 * and bits positions by the trial&error method.
29 */
30#define MCU_REG_CTRL 0x20
31#define MCU_CTRL_POFF 0x40
32
33#define MCU_NUM_GPIO 2
34
35struct mcu {
36 struct mutex lock;
37 struct device_node *np;
38 struct i2c_client *client;
39 struct of_gpio_chip of_gc;
40 u8 reg_ctrl;
41};
42
43static struct mcu *glob_mcu;
44
45static void mcu_power_off(void)
46{
47 struct mcu *mcu = glob_mcu;
48
49 pr_info("Sending power-off request to the MCU...\n");
50 mutex_lock(&mcu->lock);
51 i2c_smbus_write_byte_data(glob_mcu->client, MCU_REG_CTRL,
52 mcu->reg_ctrl | MCU_CTRL_POFF);
53 mutex_unlock(&mcu->lock);
54}
55
56static void mcu_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
57{
58 struct of_gpio_chip *of_gc = to_of_gpio_chip(gc);
59 struct mcu *mcu = container_of(of_gc, struct mcu, of_gc);
60 u8 bit = 1 << (4 + gpio);
61
62 mutex_lock(&mcu->lock);
63 if (val)
64 mcu->reg_ctrl &= ~bit;
65 else
66 mcu->reg_ctrl |= bit;
67
68 i2c_smbus_write_byte_data(mcu->client, MCU_REG_CTRL, mcu->reg_ctrl);
69 mutex_unlock(&mcu->lock);
70}
71
72static int mcu_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
73{
74 mcu_gpio_set(gc, gpio, val);
75 return 0;
76}
77
78static int mcu_gpiochip_add(struct mcu *mcu)
79{
80 struct device_node *np;
81 struct of_gpio_chip *of_gc = &mcu->of_gc;
82 struct gpio_chip *gc = &of_gc->gc;
83 int ret;
84
85 np = of_find_compatible_node(NULL, NULL, "fsl,mcu-mpc8349emitx");
86 if (!np)
87 return -ENODEV;
88
89 gc->owner = THIS_MODULE;
90 gc->label = np->full_name;
91 gc->can_sleep = 1;
92 gc->ngpio = MCU_NUM_GPIO;
93 gc->base = -1;
94 gc->set = mcu_gpio_set;
95 gc->direction_output = mcu_gpio_dir_out;
96 of_gc->gpio_cells = 2;
97 of_gc->xlate = of_gpio_simple_xlate;
98
99 np->data = of_gc;
100 mcu->np = np;
101
102 /*
103 * We don't want to lose the node, its ->data and ->full_name...
104 * So, if succeeded, we don't put the node here.
105 */
106 ret = gpiochip_add(gc);
107 if (ret)
108 of_node_put(np);
109 return ret;
110}
111
112static int mcu_gpiochip_remove(struct mcu *mcu)
113{
114 int ret;
115
116 ret = gpiochip_remove(&mcu->of_gc.gc);
117 if (ret)
118 return ret;
119 of_node_put(mcu->np);
120
121 return 0;
122}
123
124static int __devinit mcu_probe(struct i2c_client *client,
125 const struct i2c_device_id *id)
126{
127 struct mcu *mcu;
128 int ret;
129
130 mcu = kzalloc(sizeof(*mcu), GFP_KERNEL);
131 if (!mcu)
132 return -ENOMEM;
133
134 mutex_init(&mcu->lock);
135 mcu->client = client;
136 i2c_set_clientdata(client, mcu);
137
138 ret = i2c_smbus_read_byte_data(mcu->client, MCU_REG_CTRL);
139 if (ret < 0)
140 goto err;
141 mcu->reg_ctrl = ret;
142
143 ret = mcu_gpiochip_add(mcu);
144 if (ret)
145 goto err;
146
147 /* XXX: this is potentially racy, but there is no lock for ppc_md */
148 if (!ppc_md.power_off) {
149 glob_mcu = mcu;
150 ppc_md.power_off = mcu_power_off;
151 dev_info(&client->dev, "will provide power-off service\n");
152 }
153
154 return 0;
155err:
156 kfree(mcu);
157 return ret;
158}
159
160static int __devexit mcu_remove(struct i2c_client *client)
161{
162 struct mcu *mcu = i2c_get_clientdata(client);
163 int ret;
164
165 if (glob_mcu == mcu) {
166 ppc_md.power_off = NULL;
167 glob_mcu = NULL;
168 }
169
170 ret = mcu_gpiochip_remove(mcu);
171 if (ret)
172 return ret;
173 i2c_set_clientdata(client, NULL);
174 kfree(mcu);
175 return 0;
176}
177
178static const struct i2c_device_id mcu_ids[] = {
179 { "mcu-mpc8349emitx", },
180 {},
181};
182MODULE_DEVICE_TABLE(i2c, mcu_ids);
183
184static struct i2c_driver mcu_driver = {
185 .driver = {
186 .name = "mcu-mpc8349emitx",
187 .owner = THIS_MODULE,
188 },
189 .probe = mcu_probe,
190 .remove = __devexit_p(mcu_remove),
191 .id_table = mcu_ids,
192};
193
194static int __init mcu_init(void)
195{
196 return i2c_add_driver(&mcu_driver);
197}
198module_init(mcu_init);
199
200static void __exit mcu_exit(void)
201{
202 i2c_del_driver(&mcu_driver);
203}
204module_exit(mcu_exit);
205
206MODULE_DESCRIPTION("Power Management and GPIO expander driver for "
207 "MPC8349E-mITX-compatible MCU");
208MODULE_AUTHOR("Anton Vorontsov <avorontsov@ru.mvista.com>");
209MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index c6a63f46bc15..b1c9abe24c7b 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -459,7 +459,7 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
459 pr_debug("I2C adapter driver [%s] forgot to specify " 459 pr_debug("I2C adapter driver [%s] forgot to specify "
460 "physical device\n", adap->name); 460 "physical device\n", adap->name);
461 } 461 }
462 sprintf(adap->dev.bus_id, "i2c-%d", adap->nr); 462 dev_set_name(&adap->dev, "i2c-%d", adap->nr);
463 adap->dev.release = &i2c_adapter_dev_release; 463 adap->dev.release = &i2c_adapter_dev_release;
464 adap->dev.class = &i2c_adapter_class; 464 adap->dev.class = &i2c_adapter_class;
465 res = device_register(&adap->dev); 465 res = device_register(&adap->dev);
@@ -845,8 +845,8 @@ int i2c_attach_client(struct i2c_client *client)
845 } else 845 } else
846 client->dev.release = i2c_client_dev_release; 846 client->dev.release = i2c_client_dev_release;
847 847
848 snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id), 848 dev_set_name(&client->dev, "%d-%04x", i2c_adapter_id(adapter),
849 "%d-%04x", i2c_adapter_id(adapter), client->addr); 849 client->addr);
850 res = device_register(&client->dev); 850 res = device_register(&client->dev);
851 if (res) 851 if (res)
852 goto out_err; 852 goto out_err;
@@ -856,7 +856,7 @@ int i2c_attach_client(struct i2c_client *client)
856 mutex_unlock(&adapter->clist_lock); 856 mutex_unlock(&adapter->clist_lock);
857 857
858 dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n", 858 dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n",
859 client->name, client->dev.bus_id); 859 client->name, dev_name(&client->dev));
860 860
861 if (adapter->client_register) { 861 if (adapter->client_register) {
862 if (adapter->client_register(client)) { 862 if (adapter->client_register(client)) {
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 3f9503867e6b..b1c6f68d98ce 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -701,11 +701,6 @@ config BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
701 depends on SOC_AU1200 && BLK_DEV_IDE_AU1XXX 701 depends on SOC_AU1200 && BLK_DEV_IDE_AU1XXX
702endchoice 702endchoice
703 703
704config BLK_DEV_IDE_AU1XXX_SEQTS_PER_RQ
705 int "Maximum transfer size (KB) per request (up to 128)"
706 default "128"
707 depends on BLK_DEV_IDE_AU1XXX
708
709config BLK_DEV_IDE_TX4938 704config BLK_DEV_IDE_TX4938
710 tristate "TX4938 internal IDE support" 705 tristate "TX4938 internal IDE support"
711 depends on SOC_TX4938 706 depends on SOC_TX4938
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c
index 2f9e941968d6..d8f295bdad76 100644
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -18,12 +18,6 @@
18#include <linux/dmi.h> 18#include <linux/dmi.h>
19 19
20#include <acpi/acpi_bus.h> 20#include <acpi/acpi_bus.h>
21#include <acpi/acnames.h>
22#include <acpi/acnamesp.h>
23#include <acpi/acparser.h>
24#include <acpi/acexcep.h>
25#include <acpi/acmacros.h>
26#include <acpi/actypes.h>
27 21
28#define REGS_PER_GTF 7 22#define REGS_PER_GTF 7
29struct taskfile_array { 23struct taskfile_array {
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 4088a622873e..806760d24cef 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -633,7 +633,7 @@ static void ide_disk_setup(ide_drive_t *drive)
633 printk(KERN_INFO "%s: max request size: %dKiB\n", drive->name, 633 printk(KERN_INFO "%s: max request size: %dKiB\n", drive->name,
634 q->max_sectors / 2); 634 q->max_sectors / 2);
635 635
636 if (ata_id_is_ssd(id) || ata_id_is_cfa(id)) 636 if (ata_id_is_ssd(id))
637 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q); 637 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q);
638 638
639 /* calculate drive capacity, and select LBA if possible */ 639 /* calculate drive capacity, and select LBA if possible */
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index e728cfe7273f..753b92ebe0ae 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -493,7 +493,7 @@ static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long ti
493 stat = tp_ops->read_status(hwif); 493 stat = tp_ops->read_status(hwif);
494 494
495 if (stat & ATA_BUSY) { 495 if (stat & ATA_BUSY) {
496 local_irq_save(flags); 496 local_save_flags(flags);
497 local_irq_enable_in_hardirq(); 497 local_irq_enable_in_hardirq();
498 timeout += jiffies; 498 timeout += jiffies;
499 while ((stat = tp_ops->read_status(hwif)) & ATA_BUSY) { 499 while ((stat = tp_ops->read_status(hwif)) & ATA_BUSY) {
diff --git a/drivers/ide/ide-pm.c b/drivers/ide/ide-pm.c
index 4b3bf6a06b70..60538d9c84ee 100644
--- a/drivers/ide/ide-pm.c
+++ b/drivers/ide/ide-pm.c
@@ -186,12 +186,10 @@ void ide_complete_pm_request(ide_drive_t *drive, struct request *rq)
186 blk_pm_suspend_request(rq) ? "suspend" : "resume"); 186 blk_pm_suspend_request(rq) ? "suspend" : "resume");
187#endif 187#endif
188 spin_lock_irqsave(q->queue_lock, flags); 188 spin_lock_irqsave(q->queue_lock, flags);
189 if (blk_pm_suspend_request(rq)) { 189 if (blk_pm_suspend_request(rq))
190 blk_stop_queue(q); 190 blk_stop_queue(q);
191 } else { 191 else
192 drive->dev_flags &= ~IDE_DFLAG_BLOCKED; 192 drive->dev_flags &= ~IDE_DFLAG_BLOCKED;
193 blk_start_queue(q);
194 }
195 spin_unlock_irqrestore(q->queue_lock, flags); 193 spin_unlock_irqrestore(q->queue_lock, flags);
196 194
197 drive->hwif->rq = NULL; 195 drive->hwif->rq = NULL;
@@ -219,6 +217,8 @@ void ide_check_pm_state(ide_drive_t *drive, struct request *rq)
219 * point. 217 * point.
220 */ 218 */
221 ide_hwif_t *hwif = drive->hwif; 219 ide_hwif_t *hwif = drive->hwif;
220 struct request_queue *q = drive->queue;
221 unsigned long flags;
222 int rc; 222 int rc;
223#ifdef DEBUG_PM 223#ifdef DEBUG_PM
224 printk("%s: Wakeup request inited, waiting for !BSY...\n", drive->name); 224 printk("%s: Wakeup request inited, waiting for !BSY...\n", drive->name);
@@ -231,5 +231,9 @@ void ide_check_pm_state(ide_drive_t *drive, struct request *rq)
231 rc = ide_wait_not_busy(hwif, 100000); 231 rc = ide_wait_not_busy(hwif, 100000);
232 if (rc) 232 if (rc)
233 printk(KERN_WARNING "%s: drive not ready on wakeup\n", drive->name); 233 printk(KERN_WARNING "%s: drive not ready on wakeup\n", drive->name);
234
235 spin_lock_irqsave(q->queue_lock, flags);
236 blk_start_queue(q);
237 spin_unlock_irqrestore(q->queue_lock, flags);
234 } 238 }
235} 239}
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 0ccbb4459fb9..312127ea443a 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -796,7 +796,7 @@ static int ide_probe_port(ide_hwif_t *hwif)
796 if (irqd) 796 if (irqd)
797 disable_irq(hwif->irq); 797 disable_irq(hwif->irq);
798 798
799 local_irq_save(flags); 799 local_save_flags(flags);
800 local_irq_enable_in_hardirq(); 800 local_irq_enable_in_hardirq();
801 801
802 if (ide_port_wait_ready(hwif) == -EBUSY) 802 if (ide_port_wait_ready(hwif) == -EBUSY)
diff --git a/drivers/ide/it821x.c b/drivers/ide/it821x.c
index 0be27ac1f077..e1c4f5437396 100644
--- a/drivers/ide/it821x.c
+++ b/drivers/ide/it821x.c
@@ -68,6 +68,8 @@
68 68
69#define DRV_NAME "it821x" 69#define DRV_NAME "it821x"
70 70
71#define QUIRK_VORTEX86 1
72
71struct it821x_dev 73struct it821x_dev
72{ 74{
73 unsigned int smart:1, /* Are we in smart raid mode */ 75 unsigned int smart:1, /* Are we in smart raid mode */
@@ -79,6 +81,7 @@ struct it821x_dev
79 u16 pio[2]; /* Cached PIO values */ 81 u16 pio[2]; /* Cached PIO values */
80 u16 mwdma[2]; /* Cached MWDMA values */ 82 u16 mwdma[2]; /* Cached MWDMA values */
81 u16 udma[2]; /* Cached UDMA values (per drive) */ 83 u16 udma[2]; /* Cached UDMA values (per drive) */
84 u16 quirks;
82}; 85};
83 86
84#define ATA_66 0 87#define ATA_66 0
@@ -557,8 +560,7 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
557 * this is necessary. 560 * this is necessary.
558 */ 561 */
559 562
560 pci_read_config_byte(dev, 0x08, &conf); 563 if (dev->revision == 0x10) {
561 if (conf == 0x10) {
562 idev->timing10 = 1; 564 idev->timing10 = 1;
563 hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; 565 hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA;
564 if (idev->smart == 0) 566 if (idev->smart == 0)
@@ -577,6 +579,12 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
577 579
578 hwif->ultra_mask = ATA_UDMA6; 580 hwif->ultra_mask = ATA_UDMA6;
579 hwif->mwdma_mask = ATA_MWDMA2; 581 hwif->mwdma_mask = ATA_MWDMA2;
582
583 /* Vortex86SX quirk: prevent Ultra-DMA mode to fix BadCRC issue */
584 if (idev->quirks & QUIRK_VORTEX86) {
585 if (dev->revision == 0x11)
586 hwif->ultra_mask = 0;
587 }
580} 588}
581 589
582static void it8212_disable_raid(struct pci_dev *dev) 590static void it8212_disable_raid(struct pci_dev *dev)
@@ -649,6 +657,8 @@ static int __devinit it821x_init_one(struct pci_dev *dev, const struct pci_devic
649 return -ENOMEM; 657 return -ENOMEM;
650 } 658 }
651 659
660 itdevs->quirks = id->driver_data;
661
652 rc = ide_pci_init_one(dev, &it821x_chipset, itdevs); 662 rc = ide_pci_init_one(dev, &it821x_chipset, itdevs);
653 if (rc) 663 if (rc)
654 kfree(itdevs); 664 kfree(itdevs);
@@ -668,6 +678,7 @@ static void __devexit it821x_remove(struct pci_dev *dev)
668static const struct pci_device_id it821x_pci_tbl[] = { 678static const struct pci_device_id it821x_pci_tbl[] = {
669 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8211), 0 }, 679 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8211), 0 },
670 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8212), 0 }, 680 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8212), 0 },
681 { PCI_VDEVICE(RDC, PCI_DEVICE_ID_RDC_D1010), QUIRK_VORTEX86 },
671 { 0, }, 682 { 0, },
672}; 683};
673 684
diff --git a/drivers/ide/sl82c105.c b/drivers/ide/sl82c105.c
index 48cc748c5043..6297956507c0 100644
--- a/drivers/ide/sl82c105.c
+++ b/drivers/ide/sl82c105.c
@@ -310,10 +310,6 @@ static const struct ide_port_info sl82c105_chipset __devinitdata = {
310 .dma_ops = &sl82c105_dma_ops, 310 .dma_ops = &sl82c105_dma_ops,
311 .host_flags = IDE_HFLAG_IO_32BIT | 311 .host_flags = IDE_HFLAG_IO_32BIT |
312 IDE_HFLAG_UNMASK_IRQS | 312 IDE_HFLAG_UNMASK_IRQS |
313/* FIXME: check for Compatibility mode in generic IDE PCI code */
314#if defined(CONFIG_LOPEC) || defined(CONFIG_SANDPOINT)
315 IDE_HFLAG_FORCE_LEGACY_IRQS |
316#endif
317 IDE_HFLAG_SERIALIZE_DMA | 313 IDE_HFLAG_SERIALIZE_DMA |
318 IDE_HFLAG_NO_AUTODMA, 314 IDE_HFLAG_NO_AUTODMA,
319 .pio_mask = ATA_PIO5, 315 .pio_mask = ATA_PIO5,
diff --git a/drivers/ide/tx4938ide.c b/drivers/ide/tx4938ide.c
index b4ef218072cd..d9095345f7ca 100644
--- a/drivers/ide/tx4938ide.c
+++ b/drivers/ide/tx4938ide.c
@@ -202,7 +202,6 @@ static const struct ide_tp_ops tx4938ide_tp_ops = {
202 .exec_command = ide_exec_command, 202 .exec_command = ide_exec_command,
203 .read_status = ide_read_status, 203 .read_status = ide_read_status,
204 .read_altstatus = ide_read_altstatus, 204 .read_altstatus = ide_read_altstatus,
205 .read_sff_dma_status = ide_read_sff_dma_status,
206 205
207 .set_irq = ide_set_irq, 206 .set_irq = ide_set_irq,
208 207
diff --git a/drivers/ide/via82cxxx.c b/drivers/ide/via82cxxx.c
index fecc0e03c3fc..703c3eeb20a8 100644
--- a/drivers/ide/via82cxxx.c
+++ b/drivers/ide/via82cxxx.c
@@ -432,8 +432,6 @@ static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_i
432 if (via_clock < 20000 || via_clock > 50000) { 432 if (via_clock < 20000 || via_clock > 50000) {
433 printk(KERN_WARNING DRV_NAME ": User given PCI clock speed " 433 printk(KERN_WARNING DRV_NAME ": User given PCI clock speed "
434 "impossible (%d), using 33 MHz instead.\n", via_clock); 434 "impossible (%d), using 33 MHz instead.\n", via_clock);
435 printk(KERN_WARNING DRV_NAME ": Use ide0=ata66 if you want "
436 "to assume 80-wire cable.\n");
437 via_clock = 33333; 435 via_clock = 33333;
438 } 436 }
439 437
diff --git a/drivers/ieee1394/csr.c b/drivers/ieee1394/csr.c
index c90be4070e40..31400c8ae051 100644
--- a/drivers/ieee1394/csr.c
+++ b/drivers/ieee1394/csr.c
@@ -68,22 +68,22 @@ static struct hpsb_highlevel csr_highlevel = {
68 .host_reset = host_reset, 68 .host_reset = host_reset,
69}; 69};
70 70
71static struct hpsb_address_ops map_ops = { 71const static struct hpsb_address_ops map_ops = {
72 .read = read_maps, 72 .read = read_maps,
73}; 73};
74 74
75static struct hpsb_address_ops fcp_ops = { 75const static struct hpsb_address_ops fcp_ops = {
76 .write = write_fcp, 76 .write = write_fcp,
77}; 77};
78 78
79static struct hpsb_address_ops reg_ops = { 79const static struct hpsb_address_ops reg_ops = {
80 .read = read_regs, 80 .read = read_regs,
81 .write = write_regs, 81 .write = write_regs,
82 .lock = lock_regs, 82 .lock = lock_regs,
83 .lock64 = lock64_regs, 83 .lock64 = lock64_regs,
84}; 84};
85 85
86static struct hpsb_address_ops config_rom_ops = { 86const static struct hpsb_address_ops config_rom_ops = {
87 .read = read_config_rom, 87 .read = read_config_rom,
88}; 88};
89 89
@@ -217,7 +217,7 @@ static void add_host(struct hpsb_host *host)
217 217
218 host->csr.generation = 2; 218 host->csr.generation = 2;
219 219
220 bus_info[1] = __constant_cpu_to_be32(0x31333934); 220 bus_info[1] = IEEE1394_BUSID_MAGIC;
221 bus_info[2] = cpu_to_be32((hpsb_disable_irm ? 0 : 1 << CSR_IRMC_SHIFT) | 221 bus_info[2] = cpu_to_be32((hpsb_disable_irm ? 0 : 1 << CSR_IRMC_SHIFT) |
222 (1 << CSR_CMC_SHIFT) | 222 (1 << CSR_CMC_SHIFT) |
223 (1 << CSR_ISC_SHIFT) | 223 (1 << CSR_ISC_SHIFT) |
@@ -250,7 +250,7 @@ static void remove_host(struct hpsb_host *host)
250{ 250{
251 quadlet_t bus_info[CSR_BUS_INFO_SIZE]; 251 quadlet_t bus_info[CSR_BUS_INFO_SIZE];
252 252
253 bus_info[1] = __constant_cpu_to_be32(0x31333934); 253 bus_info[1] = IEEE1394_BUSID_MAGIC;
254 bus_info[2] = cpu_to_be32((0 << CSR_IRMC_SHIFT) | 254 bus_info[2] = cpu_to_be32((0 << CSR_IRMC_SHIFT) |
255 (0 << CSR_CMC_SHIFT) | 255 (0 << CSR_CMC_SHIFT) |
256 (0 << CSR_ISC_SHIFT) | 256 (0 << CSR_ISC_SHIFT) |
diff --git a/drivers/ieee1394/csr.h b/drivers/ieee1394/csr.h
index f11546550d84..90fb3f2192c3 100644
--- a/drivers/ieee1394/csr.h
+++ b/drivers/ieee1394/csr.h
@@ -50,11 +50,11 @@
50#define CSR_MAX_ROM_SHIFT 8 50#define CSR_MAX_ROM_SHIFT 8
51#define CSR_GENERATION_SHIFT 4 51#define CSR_GENERATION_SHIFT 4
52 52
53#define CSR_SET_BUS_INFO_GENERATION(csr, gen) \ 53static inline void csr_set_bus_info_generation(struct csr1212_csr *csr, u8 gen)
54 ((csr)->bus_info_data[2] = \ 54{
55 cpu_to_be32((be32_to_cpu((csr)->bus_info_data[2]) & \ 55 csr->bus_info_data[2] &= ~cpu_to_be32(0xf << CSR_GENERATION_SHIFT);
56 ~(0xf << CSR_GENERATION_SHIFT)) | \ 56 csr->bus_info_data[2] |= cpu_to_be32((u32)gen << CSR_GENERATION_SHIFT);
57 (gen) << CSR_GENERATION_SHIFT)) 57}
58 58
59struct csr_control { 59struct csr_control {
60 spinlock_t lock; 60 spinlock_t lock;
diff --git a/drivers/ieee1394/csr1212.c b/drivers/ieee1394/csr1212.c
index 5e38a68b8af2..a6dfeb0b3372 100644
--- a/drivers/ieee1394/csr1212.c
+++ b/drivers/ieee1394/csr1212.c
@@ -1077,15 +1077,10 @@ static int csr1212_parse_bus_info_block(struct csr1212_csr *csr)
1077 int i; 1077 int i;
1078 int ret; 1078 int ret;
1079 1079
1080 /* IEEE 1212 says that the entire bus info block should be readable in
1081 * a single transaction regardless of the max_rom value.
1082 * Unfortunately, many IEEE 1394 devices do not abide by that, so the
1083 * bus info block will be read 1 quadlet at a time. The rest of the
1084 * ConfigROM will be read according to the max_rom field. */
1085 for (i = 0; i < csr->bus_info_len; i += sizeof(u32)) { 1080 for (i = 0; i < csr->bus_info_len; i += sizeof(u32)) {
1086 ret = csr->ops->bus_read(csr, CSR1212_CONFIG_ROM_SPACE_BASE + i, 1081 ret = csr->ops->bus_read(csr, CSR1212_CONFIG_ROM_SPACE_BASE + i,
1087 sizeof(u32), &csr->cache_head->data[bytes_to_quads(i)], 1082 &csr->cache_head->data[bytes_to_quads(i)],
1088 csr->private); 1083 csr->private);
1089 if (ret != CSR1212_SUCCESS) 1084 if (ret != CSR1212_SUCCESS)
1090 return ret; 1085 return ret;
1091 1086
@@ -1104,8 +1099,8 @@ static int csr1212_parse_bus_info_block(struct csr1212_csr *csr)
1104 * a time. */ 1099 * a time. */
1105 for (i = csr->bus_info_len; i <= csr->crc_len; i += sizeof(u32)) { 1100 for (i = csr->bus_info_len; i <= csr->crc_len; i += sizeof(u32)) {
1106 ret = csr->ops->bus_read(csr, CSR1212_CONFIG_ROM_SPACE_BASE + i, 1101 ret = csr->ops->bus_read(csr, CSR1212_CONFIG_ROM_SPACE_BASE + i,
1107 sizeof(u32), &csr->cache_head->data[bytes_to_quads(i)], 1102 &csr->cache_head->data[bytes_to_quads(i)],
1108 csr->private); 1103 csr->private);
1109 if (ret != CSR1212_SUCCESS) 1104 if (ret != CSR1212_SUCCESS)
1110 return ret; 1105 return ret;
1111 } 1106 }
@@ -1289,7 +1284,7 @@ csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv)
1289 1284
1290 if (csr->ops->bus_read(csr, 1285 if (csr->ops->bus_read(csr,
1291 CSR1212_REGISTER_SPACE_BASE + kv->offset, 1286 CSR1212_REGISTER_SPACE_BASE + kv->offset,
1292 sizeof(u32), &q, csr->private)) 1287 &q, csr->private))
1293 return -EIO; 1288 return -EIO;
1294 1289
1295 kv->value.leaf.len = be32_to_cpu(q) >> 16; 1290 kv->value.leaf.len = be32_to_cpu(q) >> 16;
@@ -1372,17 +1367,8 @@ csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv)
1372 addr = (CSR1212_CSR_ARCH_REG_SPACE_BASE + cache->offset + 1367 addr = (CSR1212_CSR_ARCH_REG_SPACE_BASE + cache->offset +
1373 cr->offset_end) & ~(csr->max_rom - 1); 1368 cr->offset_end) & ~(csr->max_rom - 1);
1374 1369
1375 if (csr->ops->bus_read(csr, addr, csr->max_rom, cache_ptr, 1370 if (csr->ops->bus_read(csr, addr, cache_ptr, csr->private))
1376 csr->private)) { 1371 return -EIO;
1377 if (csr->max_rom == 4)
1378 /* We've got problems! */
1379 return -EIO;
1380
1381 /* Apperently the max_rom value was a lie, set it to
1382 * do quadlet reads and try again. */
1383 csr->max_rom = 4;
1384 continue;
1385 }
1386 1372
1387 cr->offset_end += csr->max_rom - (cr->offset_end & 1373 cr->offset_end += csr->max_rom - (cr->offset_end &
1388 (csr->max_rom - 1)); 1374 (csr->max_rom - 1));
@@ -1433,7 +1419,6 @@ csr1212_get_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv)
1433 1419
1434int csr1212_parse_csr(struct csr1212_csr *csr) 1420int csr1212_parse_csr(struct csr1212_csr *csr)
1435{ 1421{
1436 static const int mr_map[] = { 4, 64, 1024, 0 };
1437 struct csr1212_dentry *dentry; 1422 struct csr1212_dentry *dentry;
1438 int ret; 1423 int ret;
1439 1424
@@ -1443,15 +1428,13 @@ int csr1212_parse_csr(struct csr1212_csr *csr)
1443 if (ret != CSR1212_SUCCESS) 1428 if (ret != CSR1212_SUCCESS)
1444 return ret; 1429 return ret;
1445 1430
1446 if (!csr->ops->get_max_rom) { 1431 /*
1447 csr->max_rom = mr_map[0]; /* default value */ 1432 * There has been a buggy firmware with bus_info_block.max_rom > 0
1448 } else { 1433 * spotted which actually only supported quadlet read requests to the
1449 int i = csr->ops->get_max_rom(csr->bus_info_data, 1434 * config ROM. Therefore read everything quadlet by quadlet regardless
1450 csr->private); 1435 * of what the bus info block says.
1451 if (i & ~0x3) 1436 */
1452 return -EINVAL; 1437 csr->max_rom = 4;
1453 csr->max_rom = mr_map[i];
1454 }
1455 1438
1456 csr->cache_head->layout_head = csr->root_kv; 1439 csr->cache_head->layout_head = csr->root_kv;
1457 csr->cache_head->layout_tail = csr->root_kv; 1440 csr->cache_head->layout_tail = csr->root_kv;
diff --git a/drivers/ieee1394/csr1212.h b/drivers/ieee1394/csr1212.h
index 043039fc63ec..a892d922dbc9 100644
--- a/drivers/ieee1394/csr1212.h
+++ b/drivers/ieee1394/csr1212.h
@@ -181,7 +181,7 @@ struct csr1212_csr_rom_cache {
181struct csr1212_csr { 181struct csr1212_csr {
182 size_t bus_info_len; /* bus info block length in bytes */ 182 size_t bus_info_len; /* bus info block length in bytes */
183 size_t crc_len; /* crc length in bytes */ 183 size_t crc_len; /* crc length in bytes */
184 u32 *bus_info_data; /* bus info data incl bus name and EUI */ 184 __be32 *bus_info_data; /* bus info data incl bus name and EUI */
185 185
186 void *private; /* private, bus specific data */ 186 void *private; /* private, bus specific data */
187 struct csr1212_bus_ops *ops; 187 struct csr1212_bus_ops *ops;
@@ -200,7 +200,7 @@ struct csr1212_bus_ops {
200 * entries located in the Units Space. Must return 0 on success 200 * entries located in the Units Space. Must return 0 on success
201 * anything else indicates an error. */ 201 * anything else indicates an error. */
202 int (*bus_read) (struct csr1212_csr *csr, u64 addr, 202 int (*bus_read) (struct csr1212_csr *csr, u64 addr,
203 u16 length, void *buffer, void *private); 203 void *buffer, void *private);
204 204
205 /* This function is used by csr1212 to allocate a region in units space 205 /* This function is used by csr1212 to allocate a region in units space
206 * in the event that Config ROM entries don't all fit in the predefined 206 * in the event that Config ROM entries don't all fit in the predefined
@@ -211,11 +211,6 @@ struct csr1212_bus_ops {
211 /* This function is used by csr1212 to release a region in units space 211 /* This function is used by csr1212 to release a region in units space
212 * that is no longer needed. */ 212 * that is no longer needed. */
213 void (*release_addr) (u64 addr, void *private); 213 void (*release_addr) (u64 addr, void *private);
214
215 /* This function is used by csr1212 to determine the max read request
216 * supported by a remote node when reading the ConfigROM space. Must
217 * return 0, 1, or 2 per IEEE 1212. */
218 int (*get_max_rom) (u32 *bus_info, void *private);
219}; 214};
220 215
221 216
diff --git a/drivers/ieee1394/dv1394-private.h b/drivers/ieee1394/dv1394-private.h
index 7d1d2845b420..18b92cbf4a9f 100644
--- a/drivers/ieee1394/dv1394-private.h
+++ b/drivers/ieee1394/dv1394-private.h
@@ -77,11 +77,11 @@ static inline void fill_cip_header(struct CIP_header *cip,
77 See the Texas Instruments OHCI 1394 chipset documentation. 77 See the Texas Instruments OHCI 1394 chipset documentation.
78*/ 78*/
79 79
80struct output_more_immediate { u32 q[8]; }; 80struct output_more_immediate { __le32 q[8]; };
81struct output_more { u32 q[4]; }; 81struct output_more { __le32 q[4]; };
82struct output_last { u32 q[4]; }; 82struct output_last { __le32 q[4]; };
83struct input_more { u32 q[4]; }; 83struct input_more { __le32 q[4]; };
84struct input_last { u32 q[4]; }; 84struct input_last { __le32 q[4]; };
85 85
86/* outputs */ 86/* outputs */
87 87
@@ -92,9 +92,9 @@ static inline void fill_output_more_immediate(struct output_more_immediate *omi,
92 unsigned int payload_size) 92 unsigned int payload_size)
93{ 93{
94 omi->q[0] = cpu_to_le32(0x02000000 | 8); /* OUTPUT_MORE_IMMEDIATE; 8 is the size of the IT header */ 94 omi->q[0] = cpu_to_le32(0x02000000 | 8); /* OUTPUT_MORE_IMMEDIATE; 8 is the size of the IT header */
95 omi->q[1] = 0; 95 omi->q[1] = cpu_to_le32(0);
96 omi->q[2] = 0; 96 omi->q[2] = cpu_to_le32(0);
97 omi->q[3] = 0; 97 omi->q[3] = cpu_to_le32(0);
98 98
99 /* IT packet header */ 99 /* IT packet header */
100 omi->q[4] = cpu_to_le32( (0x0 << 16) /* IEEE1394_SPEED_100 */ 100 omi->q[4] = cpu_to_le32( (0x0 << 16) /* IEEE1394_SPEED_100 */
@@ -106,8 +106,8 @@ static inline void fill_output_more_immediate(struct output_more_immediate *omi,
106 /* reserved field; mimic behavior of my Sony DSR-40 */ 106 /* reserved field; mimic behavior of my Sony DSR-40 */
107 omi->q[5] = cpu_to_le32((payload_size << 16) | (0x7F << 8) | 0xA0); 107 omi->q[5] = cpu_to_le32((payload_size << 16) | (0x7F << 8) | 0xA0);
108 108
109 omi->q[6] = 0; 109 omi->q[6] = cpu_to_le32(0);
110 omi->q[7] = 0; 110 omi->q[7] = cpu_to_le32(0);
111} 111}
112 112
113static inline void fill_output_more(struct output_more *om, 113static inline void fill_output_more(struct output_more *om,
@@ -116,8 +116,8 @@ static inline void fill_output_more(struct output_more *om,
116{ 116{
117 om->q[0] = cpu_to_le32(data_size); 117 om->q[0] = cpu_to_le32(data_size);
118 om->q[1] = cpu_to_le32(data_phys_addr); 118 om->q[1] = cpu_to_le32(data_phys_addr);
119 om->q[2] = 0; 119 om->q[2] = cpu_to_le32(0);
120 om->q[3] = 0; 120 om->q[3] = cpu_to_le32(0);
121} 121}
122 122
123static inline void fill_output_last(struct output_last *ol, 123static inline void fill_output_last(struct output_last *ol,
@@ -140,8 +140,8 @@ static inline void fill_output_last(struct output_last *ol,
140 140
141 ol->q[0] = cpu_to_le32(temp); 141 ol->q[0] = cpu_to_le32(temp);
142 ol->q[1] = cpu_to_le32(data_phys_addr); 142 ol->q[1] = cpu_to_le32(data_phys_addr);
143 ol->q[2] = 0; 143 ol->q[2] = cpu_to_le32(0);
144 ol->q[3] = 0; 144 ol->q[3] = cpu_to_le32(0);
145} 145}
146 146
147/* inputs */ 147/* inputs */
@@ -161,8 +161,8 @@ static inline void fill_input_more(struct input_more *im,
161 161
162 im->q[0] = cpu_to_le32(temp); 162 im->q[0] = cpu_to_le32(temp);
163 im->q[1] = cpu_to_le32(data_phys_addr); 163 im->q[1] = cpu_to_le32(data_phys_addr);
164 im->q[2] = 0; /* branchAddress and Z not use in packet-per-buffer mode */ 164 im->q[2] = cpu_to_le32(0); /* branchAddress and Z not use in packet-per-buffer mode */
165 im->q[3] = 0; /* xferStatus & resCount, resCount must be initialize to data_size */ 165 im->q[3] = cpu_to_le32(0); /* xferStatus & resCount, resCount must be initialize to data_size */
166} 166}
167 167
168static inline void fill_input_last(struct input_last *il, 168static inline void fill_input_last(struct input_last *il,
@@ -331,7 +331,7 @@ struct frame {
331 331
332 /* points to status/timestamp field of first DMA packet */ 332 /* points to status/timestamp field of first DMA packet */
333 /* (we'll check it later to monitor timestamp accuracy) */ 333 /* (we'll check it later to monitor timestamp accuracy) */
334 u32 *frame_begin_timestamp; 334 __le32 *frame_begin_timestamp;
335 335
336 /* the timestamp we assigned to the first packet in the frame */ 336 /* the timestamp we assigned to the first packet in the frame */
337 u32 assigned_timestamp; 337 u32 assigned_timestamp;
@@ -348,15 +348,15 @@ struct frame {
348 that can cause interrupts. We'll check these from the 348 that can cause interrupts. We'll check these from the
349 interrupt handler. 349 interrupt handler.
350 */ 350 */
351 u32 *mid_frame_timestamp; 351 __le32 *mid_frame_timestamp;
352 u32 *frame_end_timestamp; 352 __le32 *frame_end_timestamp;
353 353
354 /* branch address field of final packet. This is effectively 354 /* branch address field of final packet. This is effectively
355 the "tail" in the chain of DMA descriptor blocks. 355 the "tail" in the chain of DMA descriptor blocks.
356 We will fill it with the address of the first DMA descriptor 356 We will fill it with the address of the first DMA descriptor
357 block in the subsequent frame, once it is ready. 357 block in the subsequent frame, once it is ready.
358 */ 358 */
359 u32 *frame_end_branch; 359 __le32 *frame_end_branch;
360 360
361 /* the number of descriptors in the first descriptor block 361 /* the number of descriptors in the first descriptor block
362 of the frame. Needed to start DMA */ 362 of the frame. Needed to start DMA */
@@ -365,10 +365,10 @@ struct frame {
365 365
366 366
367struct packet { 367struct packet {
368 u16 timestamp; 368 __le16 timestamp;
369 u16 invalid; 369 u16 invalid;
370 u16 iso_header; 370 u16 iso_header;
371 u16 data_length; 371 __le16 data_length;
372 u32 cip_h1; 372 u32 cip_h1;
373 u32 cip_h2; 373 u32 cip_h2;
374 unsigned char data[480]; 374 unsigned char data[480];
diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c
index c19f23267157..a329e6bd5d2d 100644
--- a/drivers/ieee1394/dv1394.c
+++ b/drivers/ieee1394/dv1394.c
@@ -265,7 +265,7 @@ static void frame_prepare(struct video_card *video, unsigned int this_frame)
265 /* these flags denote packets that need special attention */ 265 /* these flags denote packets that need special attention */
266 int empty_packet, first_packet, last_packet, mid_packet; 266 int empty_packet, first_packet, last_packet, mid_packet;
267 267
268 u32 *branch_address, *last_branch_address = NULL; 268 __le32 *branch_address, *last_branch_address = NULL;
269 unsigned long data_p; 269 unsigned long data_p;
270 int first_packet_empty = 0; 270 int first_packet_empty = 0;
271 u32 cycleTimer, ct_sec, ct_cyc, ct_off; 271 u32 cycleTimer, ct_sec, ct_cyc, ct_off;
@@ -848,7 +848,7 @@ static void receive_packets(struct video_card *video)
848 dma_addr_t block_dma = 0; 848 dma_addr_t block_dma = 0;
849 struct packet *data = NULL; 849 struct packet *data = NULL;
850 dma_addr_t data_dma = 0; 850 dma_addr_t data_dma = 0;
851 u32 *last_branch_address = NULL; 851 __le32 *last_branch_address = NULL;
852 unsigned long irq_flags; 852 unsigned long irq_flags;
853 int want_interrupt = 0; 853 int want_interrupt = 0;
854 struct frame *f = NULL; 854 struct frame *f = NULL;
@@ -2110,17 +2110,17 @@ static void ir_tasklet_func(unsigned long data)
2110 f = video->frames[next_i / MAX_PACKETS]; 2110 f = video->frames[next_i / MAX_PACKETS];
2111 next = &(f->descriptor_pool[next_i % MAX_PACKETS]); 2111 next = &(f->descriptor_pool[next_i % MAX_PACKETS]);
2112 next_dma = ((unsigned long) block - (unsigned long) f->descriptor_pool) + f->descriptor_pool_dma; 2112 next_dma = ((unsigned long) block - (unsigned long) f->descriptor_pool) + f->descriptor_pool_dma;
2113 next->u.in.il.q[0] |= 3 << 20; /* enable interrupt */ 2113 next->u.in.il.q[0] |= cpu_to_le32(3 << 20); /* enable interrupt */
2114 next->u.in.il.q[2] = 0; /* disable branch */ 2114 next->u.in.il.q[2] = cpu_to_le32(0); /* disable branch */
2115 2115
2116 /* link previous to next */ 2116 /* link previous to next */
2117 prev_i = (next_i == 0) ? (MAX_PACKETS * video->n_frames - 1) : (next_i - 1); 2117 prev_i = (next_i == 0) ? (MAX_PACKETS * video->n_frames - 1) : (next_i - 1);
2118 f = video->frames[prev_i / MAX_PACKETS]; 2118 f = video->frames[prev_i / MAX_PACKETS];
2119 prev = &(f->descriptor_pool[prev_i % MAX_PACKETS]); 2119 prev = &(f->descriptor_pool[prev_i % MAX_PACKETS]);
2120 if (prev_i % (MAX_PACKETS/2)) { 2120 if (prev_i % (MAX_PACKETS/2)) {
2121 prev->u.in.il.q[0] &= ~(3 << 20); /* no interrupt */ 2121 prev->u.in.il.q[0] &= ~cpu_to_le32(3 << 20); /* no interrupt */
2122 } else { 2122 } else {
2123 prev->u.in.il.q[0] |= 3 << 20; /* enable interrupt */ 2123 prev->u.in.il.q[0] |= cpu_to_le32(3 << 20); /* enable interrupt */
2124 } 2124 }
2125 prev->u.in.il.q[2] = cpu_to_le32(next_dma | 1); /* set Z=1 */ 2125 prev->u.in.il.q[2] = cpu_to_le32(next_dma | 1); /* set Z=1 */
2126 wmb(); 2126 wmb();
diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c
index 20128692b339..1a919df809f8 100644
--- a/drivers/ieee1394/eth1394.c
+++ b/drivers/ieee1394/eth1394.c
@@ -92,7 +92,7 @@ struct partial_datagram {
92 struct list_head list; 92 struct list_head list;
93 u16 dgl; 93 u16 dgl;
94 u16 dg_size; 94 u16 dg_size;
95 u16 ether_type; 95 __be16 ether_type;
96 struct sk_buff *skb; 96 struct sk_buff *skb;
97 char *pbuf; 97 char *pbuf;
98 struct list_head frag_info; 98 struct list_head frag_info;
@@ -181,7 +181,7 @@ static void ether1394_remove_host(struct hpsb_host *host);
181static void ether1394_host_reset(struct hpsb_host *host); 181static void ether1394_host_reset(struct hpsb_host *host);
182 182
183/* Function for incoming 1394 packets */ 183/* Function for incoming 1394 packets */
184static struct hpsb_address_ops addr_ops = { 184const static struct hpsb_address_ops addr_ops = {
185 .write = ether1394_write, 185 .write = ether1394_write,
186}; 186};
187 187
@@ -245,12 +245,6 @@ static int ether1394_stop(struct net_device *dev)
245 return 0; 245 return 0;
246} 246}
247 247
248/* Return statistics to the caller */
249static struct net_device_stats *ether1394_stats(struct net_device *dev)
250{
251 return &(((struct eth1394_priv *)netdev_priv(dev))->stats);
252}
253
254/* FIXME: What to do if we timeout? I think a host reset is probably in order, 248/* FIXME: What to do if we timeout? I think a host reset is probably in order,
255 * so that's what we do. Should we increment the stat counters too? */ 249 * so that's what we do. Should we increment the stat counters too? */
256static void ether1394_tx_timeout(struct net_device *dev) 250static void ether1394_tx_timeout(struct net_device *dev)
@@ -516,16 +510,19 @@ static const struct header_ops ether1394_header_ops = {
516 .parse = ether1394_header_parse, 510 .parse = ether1394_header_parse,
517}; 511};
518 512
513static const struct net_device_ops ether1394_netdev_ops = {
514 .ndo_open = ether1394_open,
515 .ndo_stop = ether1394_stop,
516 .ndo_start_xmit = ether1394_tx,
517 .ndo_tx_timeout = ether1394_tx_timeout,
518 .ndo_change_mtu = ether1394_change_mtu,
519};
520
519static void ether1394_init_dev(struct net_device *dev) 521static void ether1394_init_dev(struct net_device *dev)
520{ 522{
521 dev->open = ether1394_open;
522 dev->stop = ether1394_stop;
523 dev->hard_start_xmit = ether1394_tx;
524 dev->get_stats = ether1394_stats;
525 dev->tx_timeout = ether1394_tx_timeout;
526 dev->change_mtu = ether1394_change_mtu;
527 523
528 dev->header_ops = &ether1394_header_ops; 524 dev->header_ops = &ether1394_header_ops;
525 dev->netdev_ops = &ether1394_netdev_ops;
529 526
530 SET_ETHTOOL_OPS(dev, &ethtool_ops); 527 SET_ETHTOOL_OPS(dev, &ethtool_ops);
531 528
@@ -767,7 +764,7 @@ static int ether1394_header_parse(const struct sk_buff *skb,
767static int ether1394_header_cache(const struct neighbour *neigh, 764static int ether1394_header_cache(const struct neighbour *neigh,
768 struct hh_cache *hh) 765 struct hh_cache *hh)
769{ 766{
770 unsigned short type = hh->hh_type; 767 __be16 type = hh->hh_type;
771 struct net_device *dev = neigh->dev; 768 struct net_device *dev = neigh->dev;
772 struct eth1394hdr *eth = 769 struct eth1394hdr *eth =
773 (struct eth1394hdr *)((u8 *)hh->hh_data + 16 - ETH1394_HLEN); 770 (struct eth1394hdr *)((u8 *)hh->hh_data + 16 - ETH1394_HLEN);
@@ -795,7 +792,7 @@ static void ether1394_header_cache_update(struct hh_cache *hh,
795 ******************************************/ 792 ******************************************/
796 793
797/* Copied from net/ethernet/eth.c */ 794/* Copied from net/ethernet/eth.c */
798static u16 ether1394_type_trans(struct sk_buff *skb, struct net_device *dev) 795static __be16 ether1394_type_trans(struct sk_buff *skb, struct net_device *dev)
799{ 796{
800 struct eth1394hdr *eth; 797 struct eth1394hdr *eth;
801 unsigned char *rawp; 798 unsigned char *rawp;
@@ -829,17 +826,17 @@ static u16 ether1394_type_trans(struct sk_buff *skb, struct net_device *dev)
829 826
830/* Parse an encapsulated IP1394 header into an ethernet frame packet. 827/* Parse an encapsulated IP1394 header into an ethernet frame packet.
831 * We also perform ARP translation here, if need be. */ 828 * We also perform ARP translation here, if need be. */
832static u16 ether1394_parse_encap(struct sk_buff *skb, struct net_device *dev, 829static __be16 ether1394_parse_encap(struct sk_buff *skb, struct net_device *dev,
833 nodeid_t srcid, nodeid_t destid, 830 nodeid_t srcid, nodeid_t destid,
834 u16 ether_type) 831 __be16 ether_type)
835{ 832{
836 struct eth1394_priv *priv = netdev_priv(dev); 833 struct eth1394_priv *priv = netdev_priv(dev);
837 u64 dest_hw; 834 __be64 dest_hw;
838 unsigned short ret = 0; 835 __be16 ret = 0;
839 836
840 /* Setup our hw addresses. We use these to build the ethernet header. */ 837 /* Setup our hw addresses. We use these to build the ethernet header. */
841 if (destid == (LOCAL_BUS | ALL_NODES)) 838 if (destid == (LOCAL_BUS | ALL_NODES))
842 dest_hw = ~0ULL; /* broadcast */ 839 dest_hw = ~cpu_to_be64(0); /* broadcast */
843 else 840 else
844 dest_hw = cpu_to_be64((u64)priv->host->csr.guid_hi << 32 | 841 dest_hw = cpu_to_be64((u64)priv->host->csr.guid_hi << 32 |
845 priv->host->csr.guid_lo); 842 priv->host->csr.guid_lo);
@@ -873,7 +870,7 @@ static u16 ether1394_parse_encap(struct sk_buff *skb, struct net_device *dev,
873 node = eth1394_find_node_guid(&priv->ip_node_list, 870 node = eth1394_find_node_guid(&priv->ip_node_list,
874 be64_to_cpu(guid)); 871 be64_to_cpu(guid));
875 if (!node) 872 if (!node)
876 return 0; 873 return cpu_to_be16(0);
877 874
878 node_info = 875 node_info =
879 (struct eth1394_node_info *)node->ud->device.driver_data; 876 (struct eth1394_node_info *)node->ud->device.driver_data;
@@ -1063,7 +1060,7 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
1063 unsigned long flags; 1060 unsigned long flags;
1064 struct eth1394_priv *priv = netdev_priv(dev); 1061 struct eth1394_priv *priv = netdev_priv(dev);
1065 union eth1394_hdr *hdr = (union eth1394_hdr *)buf; 1062 union eth1394_hdr *hdr = (union eth1394_hdr *)buf;
1066 u16 ether_type = 0; /* initialized to clear warning */ 1063 __be16 ether_type = cpu_to_be16(0); /* initialized to clear warning */
1067 int hdr_len; 1064 int hdr_len;
1068 struct unit_directory *ud = priv->ud_list[NODEID_TO_NODE(srcid)]; 1065 struct unit_directory *ud = priv->ud_list[NODEID_TO_NODE(srcid)];
1069 struct eth1394_node_info *node_info; 1066 struct eth1394_node_info *node_info;
@@ -1075,7 +1072,7 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
1075 HPSB_PRINT(KERN_ERR, "ether1394 rx: sender nodeid " 1072 HPSB_PRINT(KERN_ERR, "ether1394 rx: sender nodeid "
1076 "lookup failure: " NODE_BUS_FMT, 1073 "lookup failure: " NODE_BUS_FMT,
1077 NODE_BUS_ARGS(priv->host, srcid)); 1074 NODE_BUS_ARGS(priv->host, srcid));
1078 priv->stats.rx_dropped++; 1075 dev->stats.rx_dropped++;
1079 return -1; 1076 return -1;
1080 } 1077 }
1081 ud = node->ud; 1078 ud = node->ud;
@@ -1098,7 +1095,7 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
1098 skb = dev_alloc_skb(len + dev->hard_header_len + 15); 1095 skb = dev_alloc_skb(len + dev->hard_header_len + 15);
1099 if (unlikely(!skb)) { 1096 if (unlikely(!skb)) {
1100 ETH1394_PRINT_G(KERN_ERR, "Out of memory\n"); 1097 ETH1394_PRINT_G(KERN_ERR, "Out of memory\n");
1101 priv->stats.rx_dropped++; 1098 dev->stats.rx_dropped++;
1102 return -1; 1099 return -1;
1103 } 1100 }
1104 skb_reserve(skb, (dev->hard_header_len + 15) & ~15); 1101 skb_reserve(skb, (dev->hard_header_len + 15) & ~15);
@@ -1217,15 +1214,15 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
1217 spin_lock_irqsave(&priv->lock, flags); 1214 spin_lock_irqsave(&priv->lock, flags);
1218 1215
1219 if (!skb->protocol) { 1216 if (!skb->protocol) {
1220 priv->stats.rx_errors++; 1217 dev->stats.rx_errors++;
1221 priv->stats.rx_dropped++; 1218 dev->stats.rx_dropped++;
1222 dev_kfree_skb_any(skb); 1219 dev_kfree_skb_any(skb);
1223 } else if (netif_rx(skb) == NET_RX_DROP) { 1220 } else if (netif_rx(skb) == NET_RX_DROP) {
1224 priv->stats.rx_errors++; 1221 dev->stats.rx_errors++;
1225 priv->stats.rx_dropped++; 1222 dev->stats.rx_dropped++;
1226 } else { 1223 } else {
1227 priv->stats.rx_packets++; 1224 dev->stats.rx_packets++;
1228 priv->stats.rx_bytes += skb->len; 1225 dev->stats.rx_bytes += skb->len;
1229 } 1226 }
1230 1227
1231 spin_unlock_irqrestore(&priv->lock, flags); 1228 spin_unlock_irqrestore(&priv->lock, flags);
@@ -1234,8 +1231,6 @@ bad_proto:
1234 if (netif_queue_stopped(dev)) 1231 if (netif_queue_stopped(dev))
1235 netif_wake_queue(dev); 1232 netif_wake_queue(dev);
1236 1233
1237 dev->last_rx = jiffies;
1238
1239 return 0; 1234 return 0;
1240} 1235}
1241 1236
@@ -1259,7 +1254,7 @@ static int ether1394_write(struct hpsb_host *host, int srcid, int destid,
1259 1254
1260static void ether1394_iso(struct hpsb_iso *iso) 1255static void ether1394_iso(struct hpsb_iso *iso)
1261{ 1256{
1262 quadlet_t *data; 1257 __be32 *data;
1263 char *buf; 1258 char *buf;
1264 struct eth1394_host_info *hi; 1259 struct eth1394_host_info *hi;
1265 struct net_device *dev; 1260 struct net_device *dev;
@@ -1283,7 +1278,7 @@ static void ether1394_iso(struct hpsb_iso *iso)
1283 for (i = 0; i < nready; i++) { 1278 for (i = 0; i < nready; i++) {
1284 struct hpsb_iso_packet_info *info = 1279 struct hpsb_iso_packet_info *info =
1285 &iso->infos[(iso->first_packet + i) % iso->buf_packets]; 1280 &iso->infos[(iso->first_packet + i) % iso->buf_packets];
1286 data = (quadlet_t *)(iso->data_buf.kvirt + info->offset); 1281 data = (__be32 *)(iso->data_buf.kvirt + info->offset);
1287 1282
1288 /* skip over GASP header */ 1283 /* skip over GASP header */
1289 buf = (char *)data + 8; 1284 buf = (char *)data + 8;
@@ -1509,17 +1504,18 @@ static int ether1394_send_packet(struct packet_task *ptask, unsigned int tx_len)
1509static void ether1394_dg_complete(struct packet_task *ptask, int fail) 1504static void ether1394_dg_complete(struct packet_task *ptask, int fail)
1510{ 1505{
1511 struct sk_buff *skb = ptask->skb; 1506 struct sk_buff *skb = ptask->skb;
1512 struct eth1394_priv *priv = netdev_priv(skb->dev); 1507 struct net_device *dev = skb->dev;
1508 struct eth1394_priv *priv = netdev_priv(dev);
1513 unsigned long flags; 1509 unsigned long flags;
1514 1510
1515 /* Statistics */ 1511 /* Statistics */
1516 spin_lock_irqsave(&priv->lock, flags); 1512 spin_lock_irqsave(&priv->lock, flags);
1517 if (fail) { 1513 if (fail) {
1518 priv->stats.tx_dropped++; 1514 dev->stats.tx_dropped++;
1519 priv->stats.tx_errors++; 1515 dev->stats.tx_errors++;
1520 } else { 1516 } else {
1521 priv->stats.tx_bytes += skb->len; 1517 dev->stats.tx_bytes += skb->len;
1522 priv->stats.tx_packets++; 1518 dev->stats.tx_packets++;
1523 } 1519 }
1524 spin_unlock_irqrestore(&priv->lock, flags); 1520 spin_unlock_irqrestore(&priv->lock, flags);
1525 1521
@@ -1614,7 +1610,7 @@ static int ether1394_tx(struct sk_buff *skb, struct net_device *dev)
1614 if (max_payload < dg_size + hdr_type_len[ETH1394_HDR_LF_UF]) 1610 if (max_payload < dg_size + hdr_type_len[ETH1394_HDR_LF_UF])
1615 priv->bc_dgl++; 1611 priv->bc_dgl++;
1616 } else { 1612 } else {
1617 __be64 guid = get_unaligned((u64 *)hdr_buf.h_dest); 1613 __be64 guid = get_unaligned((__be64 *)hdr_buf.h_dest);
1618 1614
1619 node = eth1394_find_node_guid(&priv->ip_node_list, 1615 node = eth1394_find_node_guid(&priv->ip_node_list,
1620 be64_to_cpu(guid)); 1616 be64_to_cpu(guid));
@@ -1696,8 +1692,8 @@ fail:
1696 dev_kfree_skb(skb); 1692 dev_kfree_skb(skb);
1697 1693
1698 spin_lock_irqsave(&priv->lock, flags); 1694 spin_lock_irqsave(&priv->lock, flags);
1699 priv->stats.tx_dropped++; 1695 dev->stats.tx_dropped++;
1700 priv->stats.tx_errors++; 1696 dev->stats.tx_errors++;
1701 spin_unlock_irqrestore(&priv->lock, flags); 1697 spin_unlock_irqrestore(&priv->lock, flags);
1702 1698
1703 /* 1699 /*
diff --git a/drivers/ieee1394/eth1394.h b/drivers/ieee1394/eth1394.h
index 4f3e2dd46f00..d53bac47b86f 100644
--- a/drivers/ieee1394/eth1394.h
+++ b/drivers/ieee1394/eth1394.h
@@ -54,7 +54,6 @@ enum eth1394_bc_states { ETHER1394_BC_ERROR,
54 54
55/* Private structure for our ethernet driver */ 55/* Private structure for our ethernet driver */
56struct eth1394_priv { 56struct eth1394_priv {
57 struct net_device_stats stats; /* Device stats */
58 struct hpsb_host *host; /* The card for this dev */ 57 struct hpsb_host *host; /* The card for this dev */
59 u16 bc_maxpayload; /* Max broadcast payload */ 58 u16 bc_maxpayload; /* Max broadcast payload */
60 u8 bc_sspd; /* Max broadcast speed */ 59 u8 bc_sspd; /* Max broadcast speed */
@@ -82,7 +81,7 @@ struct eth1394_priv {
82 81
83struct eth1394hdr { 82struct eth1394hdr {
84 unsigned char h_dest[ETH1394_ALEN]; /* destination eth1394 addr */ 83 unsigned char h_dest[ETH1394_ALEN]; /* destination eth1394 addr */
85 unsigned short h_proto; /* packet type ID field */ 84 __be16 h_proto; /* packet type ID field */
86} __attribute__((packed)); 85} __attribute__((packed));
87 86
88static inline struct eth1394hdr *eth1394_hdr(const struct sk_buff *skb) 87static inline struct eth1394hdr *eth1394_hdr(const struct sk_buff *skb)
@@ -99,13 +98,13 @@ typedef enum {ETH1394_GASP, ETH1394_WRREQ} eth1394_tx_type;
99struct eth1394_uf_hdr { 98struct eth1394_uf_hdr {
100 u16 lf:2; 99 u16 lf:2;
101 u16 res:14; 100 u16 res:14;
102 u16 ether_type; /* Ethernet packet type */ 101 __be16 ether_type; /* Ethernet packet type */
103} __attribute__((packed)); 102} __attribute__((packed));
104#elif defined __LITTLE_ENDIAN_BITFIELD 103#elif defined __LITTLE_ENDIAN_BITFIELD
105struct eth1394_uf_hdr { 104struct eth1394_uf_hdr {
106 u16 res:14; 105 u16 res:14;
107 u16 lf:2; 106 u16 lf:2;
108 u16 ether_type; 107 __be16 ether_type;
109} __attribute__((packed)); 108} __attribute__((packed));
110#else 109#else
111#error Unknown bit field type 110#error Unknown bit field type
@@ -117,7 +116,7 @@ struct eth1394_ff_hdr {
117 u16 lf:2; 116 u16 lf:2;
118 u16 res1:2; 117 u16 res1:2;
119 u16 dg_size:12; /* Datagram size */ 118 u16 dg_size:12; /* Datagram size */
120 u16 ether_type; /* Ethernet packet type */ 119 __be16 ether_type; /* Ethernet packet type */
121 u16 dgl; /* Datagram label */ 120 u16 dgl; /* Datagram label */
122 u16 res2; 121 u16 res2;
123} __attribute__((packed)); 122} __attribute__((packed));
@@ -126,7 +125,7 @@ struct eth1394_ff_hdr {
126 u16 dg_size:12; 125 u16 dg_size:12;
127 u16 res1:2; 126 u16 res1:2;
128 u16 lf:2; 127 u16 lf:2;
129 u16 ether_type; 128 __be16 ether_type;
130 u16 dgl; 129 u16 dgl;
131 u16 res2; 130 u16 res2;
132} __attribute__((packed)); 131} __attribute__((packed));
@@ -207,11 +206,11 @@ struct eth1394_arp {
207 u16 opcode; /* ARP Opcode */ 206 u16 opcode; /* ARP Opcode */
208 /* Above is exactly the same format as struct arphdr */ 207 /* Above is exactly the same format as struct arphdr */
209 208
210 u64 s_uniq_id; /* Sender's 64bit EUI */ 209 __be64 s_uniq_id; /* Sender's 64bit EUI */
211 u8 max_rec; /* Sender's max packet size */ 210 u8 max_rec; /* Sender's max packet size */
212 u8 sspd; /* Sender's max speed */ 211 u8 sspd; /* Sender's max speed */
213 u16 fifo_hi; /* hi 16bits of sender's FIFO addr */ 212 __be16 fifo_hi; /* hi 16bits of sender's FIFO addr */
214 u32 fifo_lo; /* lo 32bits of sender's FIFO addr */ 213 __be32 fifo_lo; /* lo 32bits of sender's FIFO addr */
215 u32 sip; /* Sender's IP Address */ 214 u32 sip; /* Sender's IP Address */
216 u32 tip; /* IP Address of requested hw addr */ 215 u32 tip; /* IP Address of requested hw addr */
217}; 216};
diff --git a/drivers/ieee1394/highlevel.c b/drivers/ieee1394/highlevel.c
index 272543a42a43..600e391c8fe7 100644
--- a/drivers/ieee1394/highlevel.c
+++ b/drivers/ieee1394/highlevel.c
@@ -320,7 +320,7 @@ void hpsb_unregister_highlevel(struct hpsb_highlevel *hl)
320 */ 320 */
321u64 hpsb_allocate_and_register_addrspace(struct hpsb_highlevel *hl, 321u64 hpsb_allocate_and_register_addrspace(struct hpsb_highlevel *hl,
322 struct hpsb_host *host, 322 struct hpsb_host *host,
323 struct hpsb_address_ops *ops, 323 const struct hpsb_address_ops *ops,
324 u64 size, u64 alignment, 324 u64 size, u64 alignment,
325 u64 start, u64 end) 325 u64 start, u64 end)
326{ 326{
@@ -407,7 +407,8 @@ u64 hpsb_allocate_and_register_addrspace(struct hpsb_highlevel *hl,
407 * are automatically deallocated together with the hpsb_highlevel @hl. 407 * are automatically deallocated together with the hpsb_highlevel @hl.
408 */ 408 */
409int hpsb_register_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host, 409int hpsb_register_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
410 struct hpsb_address_ops *ops, u64 start, u64 end) 410 const struct hpsb_address_ops *ops,
411 u64 start, u64 end)
411{ 412{
412 struct hpsb_address_serve *as; 413 struct hpsb_address_serve *as;
413 struct list_head *lh; 414 struct list_head *lh;
@@ -420,7 +421,7 @@ int hpsb_register_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
420 return 0; 421 return 0;
421 } 422 }
422 423
423 as = kmalloc(sizeof(*as), GFP_ATOMIC); 424 as = kmalloc(sizeof(*as), GFP_KERNEL);
424 if (!as) 425 if (!as)
425 return 0; 426 return 0;
426 427
@@ -477,7 +478,7 @@ int hpsb_unregister_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
477 return retval; 478 return retval;
478} 479}
479 480
480static struct hpsb_address_ops dummy_ops; 481const static struct hpsb_address_ops dummy_ops;
481 482
482/* dummy address spaces as lower and upper bounds of the host's a.s. list */ 483/* dummy address spaces as lower and upper bounds of the host's a.s. list */
483static void init_hpsb_highlevel(struct hpsb_host *host) 484static void init_hpsb_highlevel(struct hpsb_host *host)
diff --git a/drivers/ieee1394/highlevel.h b/drivers/ieee1394/highlevel.h
index bc5d0854c17e..9dba89fc60ad 100644
--- a/drivers/ieee1394/highlevel.h
+++ b/drivers/ieee1394/highlevel.h
@@ -15,7 +15,7 @@ struct hpsb_host;
15struct hpsb_address_serve { 15struct hpsb_address_serve {
16 struct list_head host_list; /* per host list */ 16 struct list_head host_list; /* per host list */
17 struct list_head hl_list; /* hpsb_highlevel list */ 17 struct list_head hl_list; /* hpsb_highlevel list */
18 struct hpsb_address_ops *op; 18 const struct hpsb_address_ops *op;
19 struct hpsb_host *host; 19 struct hpsb_host *host;
20 u64 start; /* first address handled, quadlet aligned */ 20 u64 start; /* first address handled, quadlet aligned */
21 u64 end; /* first address behind, quadlet aligned */ 21 u64 end; /* first address behind, quadlet aligned */
@@ -119,11 +119,12 @@ void hpsb_unregister_highlevel(struct hpsb_highlevel *hl);
119 119
120u64 hpsb_allocate_and_register_addrspace(struct hpsb_highlevel *hl, 120u64 hpsb_allocate_and_register_addrspace(struct hpsb_highlevel *hl,
121 struct hpsb_host *host, 121 struct hpsb_host *host,
122 struct hpsb_address_ops *ops, 122 const struct hpsb_address_ops *ops,
123 u64 size, u64 alignment, 123 u64 size, u64 alignment,
124 u64 start, u64 end); 124 u64 start, u64 end);
125int hpsb_register_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host, 125int hpsb_register_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
126 struct hpsb_address_ops *ops, u64 start, u64 end); 126 const struct hpsb_address_ops *ops,
127 u64 start, u64 end);
127int hpsb_unregister_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host, 128int hpsb_unregister_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
128 u64 start); 129 u64 start);
129 130
diff --git a/drivers/ieee1394/hosts.c b/drivers/ieee1394/hosts.c
index 237d0c9d69c6..e947d8ffac85 100644
--- a/drivers/ieee1394/hosts.c
+++ b/drivers/ieee1394/hosts.c
@@ -34,18 +34,18 @@ static void delayed_reset_bus(struct work_struct *work)
34{ 34{
35 struct hpsb_host *host = 35 struct hpsb_host *host =
36 container_of(work, struct hpsb_host, delayed_reset.work); 36 container_of(work, struct hpsb_host, delayed_reset.work);
37 int generation = host->csr.generation + 1; 37 u8 generation = host->csr.generation + 1;
38 38
39 /* The generation field rolls over to 2 rather than 0 per IEEE 39 /* The generation field rolls over to 2 rather than 0 per IEEE
40 * 1394a-2000. */ 40 * 1394a-2000. */
41 if (generation > 0xf || generation < 2) 41 if (generation > 0xf || generation < 2)
42 generation = 2; 42 generation = 2;
43 43
44 CSR_SET_BUS_INFO_GENERATION(host->csr.rom, generation); 44 csr_set_bus_info_generation(host->csr.rom, generation);
45 if (csr1212_generate_csr_image(host->csr.rom) != CSR1212_SUCCESS) { 45 if (csr1212_generate_csr_image(host->csr.rom) != CSR1212_SUCCESS) {
46 /* CSR image creation failed. 46 /* CSR image creation failed.
47 * Reset generation field and do not issue a bus reset. */ 47 * Reset generation field and do not issue a bus reset. */
48 CSR_SET_BUS_INFO_GENERATION(host->csr.rom, 48 csr_set_bus_info_generation(host->csr.rom,
49 host->csr.generation); 49 host->csr.generation);
50 return; 50 return;
51 } 51 }
diff --git a/drivers/ieee1394/hosts.h b/drivers/ieee1394/hosts.h
index dd229950acca..49c359022c54 100644
--- a/drivers/ieee1394/hosts.h
+++ b/drivers/ieee1394/hosts.h
@@ -154,7 +154,7 @@ struct hpsb_host_driver {
154 * to set the hardware ConfigROM if the hardware supports handling 154 * to set the hardware ConfigROM if the hardware supports handling
155 * reads to the ConfigROM on its own. */ 155 * reads to the ConfigROM on its own. */
156 void (*set_hw_config_rom)(struct hpsb_host *host, 156 void (*set_hw_config_rom)(struct hpsb_host *host,
157 quadlet_t *config_rom); 157 __be32 *config_rom);
158 158
159 /* This function shall implement packet transmission based on 159 /* This function shall implement packet transmission based on
160 * packet->type. It shall CRC both parts of the packet (unless 160 * packet->type. It shall CRC both parts of the packet (unless
diff --git a/drivers/ieee1394/ieee1394.h b/drivers/ieee1394/ieee1394.h
index 40492074c013..e0ae0d3d747f 100644
--- a/drivers/ieee1394/ieee1394.h
+++ b/drivers/ieee1394/ieee1394.h
@@ -121,6 +121,9 @@ extern const char *hpsb_speedto_str[];
121 121
122#include <asm/byteorder.h> 122#include <asm/byteorder.h>
123 123
124/* '1' '3' '9' '4' in ASCII */
125#define IEEE1394_BUSID_MAGIC cpu_to_be32(0x31333934)
126
124#ifdef __BIG_ENDIAN_BITFIELD 127#ifdef __BIG_ENDIAN_BITFIELD
125 128
126struct selfid { 129struct selfid {
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index 79ef5fd928ae..906c5a98d814 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -67,7 +67,7 @@ static int nodemgr_check_speed(struct nodemgr_csr_info *ci, u64 addr,
67 for (i = IEEE1394_SPEED_100; i <= old_speed; i++) { 67 for (i = IEEE1394_SPEED_100; i <= old_speed; i++) {
68 *speed = i; 68 *speed = i;
69 error = hpsb_read(ci->host, ci->nodeid, ci->generation, addr, 69 error = hpsb_read(ci->host, ci->nodeid, ci->generation, addr,
70 &q, sizeof(quadlet_t)); 70 &q, 4);
71 if (error) 71 if (error)
72 break; 72 break;
73 *buffer = q; 73 *buffer = q;
@@ -85,7 +85,7 @@ static int nodemgr_check_speed(struct nodemgr_csr_info *ci, u64 addr,
85 return error; 85 return error;
86} 86}
87 87
88static int nodemgr_bus_read(struct csr1212_csr *csr, u64 addr, u16 length, 88static int nodemgr_bus_read(struct csr1212_csr *csr, u64 addr,
89 void *buffer, void *__ci) 89 void *buffer, void *__ci)
90{ 90{
91 struct nodemgr_csr_info *ci = (struct nodemgr_csr_info*)__ci; 91 struct nodemgr_csr_info *ci = (struct nodemgr_csr_info*)__ci;
@@ -93,7 +93,7 @@ static int nodemgr_bus_read(struct csr1212_csr *csr, u64 addr, u16 length,
93 93
94 for (i = 1; ; i++) { 94 for (i = 1; ; i++) {
95 error = hpsb_read(ci->host, ci->nodeid, ci->generation, addr, 95 error = hpsb_read(ci->host, ci->nodeid, ci->generation, addr,
96 buffer, length); 96 buffer, 4);
97 if (!error) { 97 if (!error) {
98 ci->speed_unverified = 0; 98 ci->speed_unverified = 0;
99 break; 99 break;
@@ -104,7 +104,7 @@ static int nodemgr_bus_read(struct csr1212_csr *csr, u64 addr, u16 length,
104 104
105 /* The ieee1394_core guessed the node's speed capability from 105 /* The ieee1394_core guessed the node's speed capability from
106 * the self ID. Check whether a lower speed works. */ 106 * the self ID. Check whether a lower speed works. */
107 if (ci->speed_unverified && length == sizeof(quadlet_t)) { 107 if (ci->speed_unverified) {
108 error = nodemgr_check_speed(ci, addr, buffer); 108 error = nodemgr_check_speed(ci, addr, buffer);
109 if (!error) 109 if (!error)
110 break; 110 break;
@@ -115,20 +115,8 @@ static int nodemgr_bus_read(struct csr1212_csr *csr, u64 addr, u16 length,
115 return error; 115 return error;
116} 116}
117 117
118#define OUI_FREECOM_TECHNOLOGIES_GMBH 0x0001db
119
120static int nodemgr_get_max_rom(quadlet_t *bus_info_data, void *__ci)
121{
122 /* Freecom FireWire Hard Drive firmware bug */
123 if (be32_to_cpu(bus_info_data[3]) >> 8 == OUI_FREECOM_TECHNOLOGIES_GMBH)
124 return 0;
125
126 return (be32_to_cpu(bus_info_data[2]) >> 8) & 0x3;
127}
128
129static struct csr1212_bus_ops nodemgr_csr_ops = { 118static struct csr1212_bus_ops nodemgr_csr_ops = {
130 .bus_read = nodemgr_bus_read, 119 .bus_read = nodemgr_bus_read,
131 .get_max_rom = nodemgr_get_max_rom
132}; 120};
133 121
134 122
diff --git a/drivers/ieee1394/nodemgr.h b/drivers/ieee1394/nodemgr.h
index 4f287a3561ba..15ea09733e84 100644
--- a/drivers/ieee1394/nodemgr.h
+++ b/drivers/ieee1394/nodemgr.h
@@ -31,9 +31,6 @@ struct csr1212_keyval;
31struct hpsb_host; 31struct hpsb_host;
32struct ieee1394_device_id; 32struct ieee1394_device_id;
33 33
34/* '1' '3' '9' '4' in ASCII */
35#define IEEE1394_BUSID_MAGIC __constant_cpu_to_be32(0x31333934)
36
37/* This is the start of a Node entry structure. It should be a stable API 34/* This is the start of a Node entry structure. It should be a stable API
38 * for which to gather info from the Node Manager about devices attached 35 * for which to gather info from the Node Manager about devices attached
39 * to the bus. */ 36 * to the bus. */
diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
index e509e13cb7a7..65c1429e4129 100644
--- a/drivers/ieee1394/ohci1394.c
+++ b/drivers/ieee1394/ohci1394.c
@@ -2973,7 +2973,7 @@ alloc_dma_trm_ctx(struct ti_ohci *ohci, struct dma_trm_ctx *d,
2973 return 0; 2973 return 0;
2974} 2974}
2975 2975
2976static void ohci_set_hw_config_rom(struct hpsb_host *host, quadlet_t *config_rom) 2976static void ohci_set_hw_config_rom(struct hpsb_host *host, __be32 *config_rom)
2977{ 2977{
2978 struct ti_ohci *ohci = host->hostdata; 2978 struct ti_ohci *ohci = host->hostdata;
2979 2979
@@ -3199,15 +3199,16 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
3199 /* Now enable LPS, which we need in order to start accessing 3199 /* Now enable LPS, which we need in order to start accessing
3200 * most of the registers. In fact, on some cards (ALI M5251), 3200 * most of the registers. In fact, on some cards (ALI M5251),
3201 * accessing registers in the SClk domain without LPS enabled 3201 * accessing registers in the SClk domain without LPS enabled
3202 * will lock up the machine. Wait 50msec to make sure we have 3202 * will lock up the machine. */
3203 * full link enabled. */
3204 reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_LPS); 3203 reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_LPS);
3205 3204
3206 /* Disable and clear interrupts */ 3205 /* Disable and clear interrupts */
3207 reg_write(ohci, OHCI1394_IntEventClear, 0xffffffff); 3206 reg_write(ohci, OHCI1394_IntEventClear, 0xffffffff);
3208 reg_write(ohci, OHCI1394_IntMaskClear, 0xffffffff); 3207 reg_write(ohci, OHCI1394_IntMaskClear, 0xffffffff);
3209 3208
3210 mdelay(50); 3209 /* Flush MMIO writes and wait to make sure we have full link enabled. */
3210 reg_read(ohci, OHCI1394_Version);
3211 msleep(50);
3211 3212
3212 /* Determine the number of available IR and IT contexts. */ 3213 /* Determine the number of available IR and IT contexts. */
3213 ohci->nb_iso_rcv_ctx = 3214 ohci->nb_iso_rcv_ctx =
@@ -3233,8 +3234,9 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
3233 * we need to get to that "no event", so enough should be initialized 3234 * we need to get to that "no event", so enough should be initialized
3234 * by that point. 3235 * by that point.
3235 */ 3236 */
3236 if (request_irq(dev->irq, ohci_irq_handler, IRQF_SHARED, 3237 err = request_irq(dev->irq, ohci_irq_handler, IRQF_SHARED,
3237 OHCI1394_DRIVER_NAME, ohci)) { 3238 OHCI1394_DRIVER_NAME, ohci);
3239 if (err) {
3238 PRINT_G(KERN_ERR, "Failed to allocate interrupt %d", dev->irq); 3240 PRINT_G(KERN_ERR, "Failed to allocate interrupt %d", dev->irq);
3239 goto err; 3241 goto err;
3240 } 3242 }
@@ -3381,6 +3383,7 @@ static int ohci1394_pci_suspend(struct pci_dev *dev, pm_message_t state)
3381 ohci_devctl(ohci->host, RESET_BUS, LONG_RESET_NO_FORCE_ROOT); 3383 ohci_devctl(ohci->host, RESET_BUS, LONG_RESET_NO_FORCE_ROOT);
3382 ohci_soft_reset(ohci); 3384 ohci_soft_reset(ohci);
3383 3385
3386 free_irq(dev->irq, ohci);
3384 err = pci_save_state(dev); 3387 err = pci_save_state(dev);
3385 if (err) { 3388 if (err) {
3386 PRINT(KERN_ERR, "pci_save_state failed with %d", err); 3389 PRINT(KERN_ERR, "pci_save_state failed with %d", err);
@@ -3420,7 +3423,16 @@ static int ohci1394_pci_resume(struct pci_dev *dev)
3420 reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_LPS); 3423 reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_LPS);
3421 reg_write(ohci, OHCI1394_IntEventClear, 0xffffffff); 3424 reg_write(ohci, OHCI1394_IntEventClear, 0xffffffff);
3422 reg_write(ohci, OHCI1394_IntMaskClear, 0xffffffff); 3425 reg_write(ohci, OHCI1394_IntMaskClear, 0xffffffff);
3423 mdelay(50); 3426 reg_read(ohci, OHCI1394_Version);
3427 msleep(50);
3428
3429 err = request_irq(dev->irq, ohci_irq_handler, IRQF_SHARED,
3430 OHCI1394_DRIVER_NAME, ohci);
3431 if (err) {
3432 PRINT_G(KERN_ERR, "Failed to allocate interrupt %d", dev->irq);
3433 return err;
3434 }
3435
3424 ohci_initialize(ohci); 3436 ohci_initialize(ohci);
3425 3437
3426 hpsb_resume_host(ohci->host); 3438 hpsb_resume_host(ohci->host);
diff --git a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c
index 7aee1ac97c80..dc15cadb06ef 100644
--- a/drivers/ieee1394/pcilynx.c
+++ b/drivers/ieee1394/pcilynx.c
@@ -1463,7 +1463,7 @@ static int __devinit add_card(struct pci_dev *dev,
1463 1463
1464 /* info_length, crc_length and 1394 magic number to check, if it is really a bus info block */ 1464 /* info_length, crc_length and 1394 magic number to check, if it is really a bus info block */
1465 if (((be32_to_cpu(lynx->bus_info_block[0]) & 0xffff0000) == 0x04040000) && 1465 if (((be32_to_cpu(lynx->bus_info_block[0]) & 0xffff0000) == 0x04040000) &&
1466 (lynx->bus_info_block[1] == __constant_cpu_to_be32(0x31333934))) 1466 (lynx->bus_info_block[1] == IEEE1394_BUSID_MAGIC))
1467 { 1467 {
1468 PRINT(KERN_DEBUG, lynx->id, "read a valid bus info block from"); 1468 PRINT(KERN_DEBUG, lynx->id, "read a valid bus info block from");
1469 } else { 1469 } else {
diff --git a/drivers/ieee1394/pcilynx.h b/drivers/ieee1394/pcilynx.h
index ec27321f6724..693a169acea3 100644
--- a/drivers/ieee1394/pcilynx.h
+++ b/drivers/ieee1394/pcilynx.h
@@ -52,7 +52,7 @@ struct ti_lynx {
52 void __iomem *local_rom; 52 void __iomem *local_rom;
53 void __iomem *local_ram; 53 void __iomem *local_ram;
54 void __iomem *aux_port; 54 void __iomem *aux_port;
55 quadlet_t bus_info_block[5]; 55 __be32 bus_info_block[5];
56 56
57 /* 57 /*
58 * use local RAM of LOCALRAM_SIZE bytes for PCLs, which allows for 58 * use local RAM of LOCALRAM_SIZE bytes for PCLs, which allows for
diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
index bf7e761c12b1..bad66c65b0d6 100644
--- a/drivers/ieee1394/raw1394.c
+++ b/drivers/ieee1394/raw1394.c
@@ -90,7 +90,7 @@ static int arm_lock(struct hpsb_host *host, int nodeid, quadlet_t * store,
90static int arm_lock64(struct hpsb_host *host, int nodeid, octlet_t * store, 90static int arm_lock64(struct hpsb_host *host, int nodeid, octlet_t * store,
91 u64 addr, octlet_t data, octlet_t arg, int ext_tcode, 91 u64 addr, octlet_t data, octlet_t arg, int ext_tcode,
92 u16 flags); 92 u16 flags);
93static struct hpsb_address_ops arm_ops = { 93const static struct hpsb_address_ops arm_ops = {
94 .read = arm_read, 94 .read = arm_read,
95 .write = arm_write, 95 .write = arm_write,
96 .lock = arm_lock, 96 .lock = arm_lock,
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index a373c18cf7b8..ab1034ccb7fb 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -265,7 +265,7 @@ static struct hpsb_highlevel sbp2_highlevel = {
265 .host_reset = sbp2_host_reset, 265 .host_reset = sbp2_host_reset,
266}; 266};
267 267
268static struct hpsb_address_ops sbp2_ops = { 268const static struct hpsb_address_ops sbp2_ops = {
269 .write = sbp2_handle_status_write 269 .write = sbp2_handle_status_write
270}; 270};
271 271
@@ -275,7 +275,7 @@ static int sbp2_handle_physdma_write(struct hpsb_host *, int, int, quadlet_t *,
275static int sbp2_handle_physdma_read(struct hpsb_host *, int, quadlet_t *, u64, 275static int sbp2_handle_physdma_read(struct hpsb_host *, int, quadlet_t *, u64,
276 size_t, u16); 276 size_t, u16);
277 277
278static struct hpsb_address_ops sbp2_physdma_ops = { 278const static struct hpsb_address_ops sbp2_physdma_ops = {
279 .read = sbp2_handle_physdma_read, 279 .read = sbp2_handle_physdma_read,
280 .write = sbp2_handle_physdma_write, 280 .write = sbp2_handle_physdma_write,
281}; 281};
diff --git a/drivers/infiniband/hw/ehca/ehca_cq.c b/drivers/infiniband/hw/ehca/ehca_cq.c
index 2f4c28a30271..97e4b231cdc4 100644
--- a/drivers/infiniband/hw/ehca/ehca_cq.c
+++ b/drivers/infiniband/hw/ehca/ehca_cq.c
@@ -196,7 +196,7 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector,
196 196
197 if (h_ret != H_SUCCESS) { 197 if (h_ret != H_SUCCESS) {
198 ehca_err(device, "hipz_h_alloc_resource_cq() failed " 198 ehca_err(device, "hipz_h_alloc_resource_cq() failed "
199 "h_ret=%li device=%p", h_ret, device); 199 "h_ret=%lli device=%p", h_ret, device);
200 cq = ERR_PTR(ehca2ib_return_code(h_ret)); 200 cq = ERR_PTR(ehca2ib_return_code(h_ret));
201 goto create_cq_exit2; 201 goto create_cq_exit2;
202 } 202 }
@@ -232,7 +232,7 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector,
232 232
233 if (h_ret < H_SUCCESS) { 233 if (h_ret < H_SUCCESS) {
234 ehca_err(device, "hipz_h_register_rpage_cq() failed " 234 ehca_err(device, "hipz_h_register_rpage_cq() failed "
235 "ehca_cq=%p cq_num=%x h_ret=%li counter=%i " 235 "ehca_cq=%p cq_num=%x h_ret=%lli counter=%i "
236 "act_pages=%i", my_cq, my_cq->cq_number, 236 "act_pages=%i", my_cq, my_cq->cq_number,
237 h_ret, counter, param.act_pages); 237 h_ret, counter, param.act_pages);
238 cq = ERR_PTR(-EINVAL); 238 cq = ERR_PTR(-EINVAL);
@@ -244,7 +244,7 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector,
244 if ((h_ret != H_SUCCESS) || vpage) { 244 if ((h_ret != H_SUCCESS) || vpage) {
245 ehca_err(device, "Registration of pages not " 245 ehca_err(device, "Registration of pages not "
246 "complete ehca_cq=%p cq_num=%x " 246 "complete ehca_cq=%p cq_num=%x "
247 "h_ret=%li", my_cq, my_cq->cq_number, 247 "h_ret=%lli", my_cq, my_cq->cq_number,
248 h_ret); 248 h_ret);
249 cq = ERR_PTR(-EAGAIN); 249 cq = ERR_PTR(-EAGAIN);
250 goto create_cq_exit4; 250 goto create_cq_exit4;
@@ -252,7 +252,7 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector,
252 } else { 252 } else {
253 if (h_ret != H_PAGE_REGISTERED) { 253 if (h_ret != H_PAGE_REGISTERED) {
254 ehca_err(device, "Registration of page failed " 254 ehca_err(device, "Registration of page failed "
255 "ehca_cq=%p cq_num=%x h_ret=%li " 255 "ehca_cq=%p cq_num=%x h_ret=%lli "
256 "counter=%i act_pages=%i", 256 "counter=%i act_pages=%i",
257 my_cq, my_cq->cq_number, 257 my_cq, my_cq->cq_number,
258 h_ret, counter, param.act_pages); 258 h_ret, counter, param.act_pages);
@@ -266,7 +266,7 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector,
266 266
267 gal = my_cq->galpas.kernel; 267 gal = my_cq->galpas.kernel;
268 cqx_fec = hipz_galpa_load(gal, CQTEMM_OFFSET(cqx_fec)); 268 cqx_fec = hipz_galpa_load(gal, CQTEMM_OFFSET(cqx_fec));
269 ehca_dbg(device, "ehca_cq=%p cq_num=%x CQX_FEC=%lx", 269 ehca_dbg(device, "ehca_cq=%p cq_num=%x CQX_FEC=%llx",
270 my_cq, my_cq->cq_number, cqx_fec); 270 my_cq, my_cq->cq_number, cqx_fec);
271 271
272 my_cq->ib_cq.cqe = my_cq->nr_of_entries = 272 my_cq->ib_cq.cqe = my_cq->nr_of_entries =
@@ -307,7 +307,7 @@ create_cq_exit3:
307 h_ret = hipz_h_destroy_cq(adapter_handle, my_cq, 1); 307 h_ret = hipz_h_destroy_cq(adapter_handle, my_cq, 1);
308 if (h_ret != H_SUCCESS) 308 if (h_ret != H_SUCCESS)
309 ehca_err(device, "hipz_h_destroy_cq() failed ehca_cq=%p " 309 ehca_err(device, "hipz_h_destroy_cq() failed ehca_cq=%p "
310 "cq_num=%x h_ret=%li", my_cq, my_cq->cq_number, h_ret); 310 "cq_num=%x h_ret=%lli", my_cq, my_cq->cq_number, h_ret);
311 311
312create_cq_exit2: 312create_cq_exit2:
313 write_lock_irqsave(&ehca_cq_idr_lock, flags); 313 write_lock_irqsave(&ehca_cq_idr_lock, flags);
@@ -355,7 +355,7 @@ int ehca_destroy_cq(struct ib_cq *cq)
355 h_ret = hipz_h_destroy_cq(adapter_handle, my_cq, 0); 355 h_ret = hipz_h_destroy_cq(adapter_handle, my_cq, 0);
356 if (h_ret == H_R_STATE) { 356 if (h_ret == H_R_STATE) {
357 /* cq in err: read err data and destroy it forcibly */ 357 /* cq in err: read err data and destroy it forcibly */
358 ehca_dbg(device, "ehca_cq=%p cq_num=%x ressource=%lx in err " 358 ehca_dbg(device, "ehca_cq=%p cq_num=%x resource=%llx in err "
359 "state. Try to delete it forcibly.", 359 "state. Try to delete it forcibly.",
360 my_cq, cq_num, my_cq->ipz_cq_handle.handle); 360 my_cq, cq_num, my_cq->ipz_cq_handle.handle);
361 ehca_error_data(shca, my_cq, my_cq->ipz_cq_handle.handle); 361 ehca_error_data(shca, my_cq, my_cq->ipz_cq_handle.handle);
@@ -365,7 +365,7 @@ int ehca_destroy_cq(struct ib_cq *cq)
365 cq_num); 365 cq_num);
366 } 366 }
367 if (h_ret != H_SUCCESS) { 367 if (h_ret != H_SUCCESS) {
368 ehca_err(device, "hipz_h_destroy_cq() failed h_ret=%li " 368 ehca_err(device, "hipz_h_destroy_cq() failed h_ret=%lli "
369 "ehca_cq=%p cq_num=%x", h_ret, my_cq, cq_num); 369 "ehca_cq=%p cq_num=%x", h_ret, my_cq, cq_num);
370 return ehca2ib_return_code(h_ret); 370 return ehca2ib_return_code(h_ret);
371 } 371 }
diff --git a/drivers/infiniband/hw/ehca/ehca_hca.c b/drivers/infiniband/hw/ehca/ehca_hca.c
index 46288220cfbb..9209c5332dfe 100644
--- a/drivers/infiniband/hw/ehca/ehca_hca.c
+++ b/drivers/infiniband/hw/ehca/ehca_hca.c
@@ -393,7 +393,7 @@ int ehca_modify_port(struct ib_device *ibdev,
393 hret = hipz_h_modify_port(shca->ipz_hca_handle, port, 393 hret = hipz_h_modify_port(shca->ipz_hca_handle, port,
394 cap, props->init_type, port_modify_mask); 394 cap, props->init_type, port_modify_mask);
395 if (hret != H_SUCCESS) { 395 if (hret != H_SUCCESS) {
396 ehca_err(&shca->ib_device, "Modify port failed h_ret=%li", 396 ehca_err(&shca->ib_device, "Modify port failed h_ret=%lli",
397 hret); 397 hret);
398 ret = -EINVAL; 398 ret = -EINVAL;
399 } 399 }
diff --git a/drivers/infiniband/hw/ehca/ehca_irq.c b/drivers/infiniband/hw/ehca/ehca_irq.c
index 3128a5090dbd..99bcbd7ffb0a 100644
--- a/drivers/infiniband/hw/ehca/ehca_irq.c
+++ b/drivers/infiniband/hw/ehca/ehca_irq.c
@@ -99,7 +99,7 @@ static void print_error_data(struct ehca_shca *shca, void *data,
99 return; 99 return;
100 100
101 ehca_err(&shca->ib_device, 101 ehca_err(&shca->ib_device,
102 "QP 0x%x (resource=%lx) has errors.", 102 "QP 0x%x (resource=%llx) has errors.",
103 qp->ib_qp.qp_num, resource); 103 qp->ib_qp.qp_num, resource);
104 break; 104 break;
105 } 105 }
@@ -108,21 +108,21 @@ static void print_error_data(struct ehca_shca *shca, void *data,
108 struct ehca_cq *cq = (struct ehca_cq *)data; 108 struct ehca_cq *cq = (struct ehca_cq *)data;
109 109
110 ehca_err(&shca->ib_device, 110 ehca_err(&shca->ib_device,
111 "CQ 0x%x (resource=%lx) has errors.", 111 "CQ 0x%x (resource=%llx) has errors.",
112 cq->cq_number, resource); 112 cq->cq_number, resource);
113 break; 113 break;
114 } 114 }
115 default: 115 default:
116 ehca_err(&shca->ib_device, 116 ehca_err(&shca->ib_device,
117 "Unknown error type: %lx on %s.", 117 "Unknown error type: %llx on %s.",
118 type, shca->ib_device.name); 118 type, shca->ib_device.name);
119 break; 119 break;
120 } 120 }
121 121
122 ehca_err(&shca->ib_device, "Error data is available: %lx.", resource); 122 ehca_err(&shca->ib_device, "Error data is available: %llx.", resource);
123 ehca_err(&shca->ib_device, "EHCA ----- error data begin " 123 ehca_err(&shca->ib_device, "EHCA ----- error data begin "
124 "---------------------------------------------------"); 124 "---------------------------------------------------");
125 ehca_dmp(rblock, length, "resource=%lx", resource); 125 ehca_dmp(rblock, length, "resource=%llx", resource);
126 ehca_err(&shca->ib_device, "EHCA ----- error data end " 126 ehca_err(&shca->ib_device, "EHCA ----- error data end "
127 "----------------------------------------------------"); 127 "----------------------------------------------------");
128 128
@@ -152,7 +152,7 @@ int ehca_error_data(struct ehca_shca *shca, void *data,
152 152
153 if (ret == H_R_STATE) 153 if (ret == H_R_STATE)
154 ehca_err(&shca->ib_device, 154 ehca_err(&shca->ib_device,
155 "No error data is available: %lx.", resource); 155 "No error data is available: %llx.", resource);
156 else if (ret == H_SUCCESS) { 156 else if (ret == H_SUCCESS) {
157 int length; 157 int length;
158 158
@@ -164,7 +164,7 @@ int ehca_error_data(struct ehca_shca *shca, void *data,
164 print_error_data(shca, data, rblock, length); 164 print_error_data(shca, data, rblock, length);
165 } else 165 } else
166 ehca_err(&shca->ib_device, 166 ehca_err(&shca->ib_device,
167 "Error data could not be fetched: %lx", resource); 167 "Error data could not be fetched: %llx", resource);
168 168
169 ehca_free_fw_ctrlblock(rblock); 169 ehca_free_fw_ctrlblock(rblock);
170 170
@@ -514,7 +514,7 @@ static inline void process_eqe(struct ehca_shca *shca, struct ehca_eqe *eqe)
514 struct ehca_cq *cq; 514 struct ehca_cq *cq;
515 515
516 eqe_value = eqe->entry; 516 eqe_value = eqe->entry;
517 ehca_dbg(&shca->ib_device, "eqe_value=%lx", eqe_value); 517 ehca_dbg(&shca->ib_device, "eqe_value=%llx", eqe_value);
518 if (EHCA_BMASK_GET(EQE_COMPLETION_EVENT, eqe_value)) { 518 if (EHCA_BMASK_GET(EQE_COMPLETION_EVENT, eqe_value)) {
519 ehca_dbg(&shca->ib_device, "Got completion event"); 519 ehca_dbg(&shca->ib_device, "Got completion event");
520 token = EHCA_BMASK_GET(EQE_CQ_TOKEN, eqe_value); 520 token = EHCA_BMASK_GET(EQE_CQ_TOKEN, eqe_value);
@@ -603,7 +603,7 @@ void ehca_process_eq(struct ehca_shca *shca, int is_irq)
603 ret = hipz_h_eoi(eq->ist); 603 ret = hipz_h_eoi(eq->ist);
604 if (ret != H_SUCCESS) 604 if (ret != H_SUCCESS)
605 ehca_err(&shca->ib_device, 605 ehca_err(&shca->ib_device,
606 "bad return code EOI -rc = %ld\n", ret); 606 "bad return code EOI -rc = %lld\n", ret);
607 ehca_dbg(&shca->ib_device, "deadman found %x eqe", eqe_cnt); 607 ehca_dbg(&shca->ib_device, "deadman found %x eqe", eqe_cnt);
608 } 608 }
609 if (unlikely(eqe_cnt == EHCA_EQE_CACHE_SIZE)) 609 if (unlikely(eqe_cnt == EHCA_EQE_CACHE_SIZE))
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
index 3b77b674cbf6..368311ce332b 100644
--- a/drivers/infiniband/hw/ehca/ehca_main.c
+++ b/drivers/infiniband/hw/ehca/ehca_main.c
@@ -304,7 +304,7 @@ static int ehca_sense_attributes(struct ehca_shca *shca)
304 304
305 h_ret = hipz_h_query_hca(shca->ipz_hca_handle, rblock); 305 h_ret = hipz_h_query_hca(shca->ipz_hca_handle, rblock);
306 if (h_ret != H_SUCCESS) { 306 if (h_ret != H_SUCCESS) {
307 ehca_gen_err("Cannot query device properties. h_ret=%li", 307 ehca_gen_err("Cannot query device properties. h_ret=%lli",
308 h_ret); 308 h_ret);
309 ret = -EPERM; 309 ret = -EPERM;
310 goto sense_attributes1; 310 goto sense_attributes1;
@@ -391,7 +391,7 @@ static int ehca_sense_attributes(struct ehca_shca *shca)
391 port = (struct hipz_query_port *)rblock; 391 port = (struct hipz_query_port *)rblock;
392 h_ret = hipz_h_query_port(shca->ipz_hca_handle, 1, port); 392 h_ret = hipz_h_query_port(shca->ipz_hca_handle, 1, port);
393 if (h_ret != H_SUCCESS) { 393 if (h_ret != H_SUCCESS) {
394 ehca_gen_err("Cannot query port properties. h_ret=%li", 394 ehca_gen_err("Cannot query port properties. h_ret=%lli",
395 h_ret); 395 h_ret);
396 ret = -EPERM; 396 ret = -EPERM;
397 goto sense_attributes1; 397 goto sense_attributes1;
@@ -682,7 +682,7 @@ static ssize_t ehca_show_adapter_handle(struct device *dev,
682{ 682{
683 struct ehca_shca *shca = dev->driver_data; 683 struct ehca_shca *shca = dev->driver_data;
684 684
685 return sprintf(buf, "%lx\n", shca->ipz_hca_handle.handle); 685 return sprintf(buf, "%llx\n", shca->ipz_hca_handle.handle);
686 686
687} 687}
688static DEVICE_ATTR(adapter_handle, S_IRUGO, ehca_show_adapter_handle, NULL); 688static DEVICE_ATTR(adapter_handle, S_IRUGO, ehca_show_adapter_handle, NULL);
@@ -955,7 +955,7 @@ void ehca_poll_eqs(unsigned long data)
955 struct ehca_eq *eq = &shca->eq; 955 struct ehca_eq *eq = &shca->eq;
956 int max = 3; 956 int max = 3;
957 volatile u64 q_ofs, q_ofs2; 957 volatile u64 q_ofs, q_ofs2;
958 u64 flags; 958 unsigned long flags;
959 spin_lock_irqsave(&eq->spinlock, flags); 959 spin_lock_irqsave(&eq->spinlock, flags);
960 q_ofs = eq->ipz_queue.current_q_offset; 960 q_ofs = eq->ipz_queue.current_q_offset;
961 spin_unlock_irqrestore(&eq->spinlock, flags); 961 spin_unlock_irqrestore(&eq->spinlock, flags);
diff --git a/drivers/infiniband/hw/ehca/ehca_mcast.c b/drivers/infiniband/hw/ehca/ehca_mcast.c
index e3ef0264ccc6..120aedf9f989 100644
--- a/drivers/infiniband/hw/ehca/ehca_mcast.c
+++ b/drivers/infiniband/hw/ehca/ehca_mcast.c
@@ -88,7 +88,7 @@ int ehca_attach_mcast(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
88 if (h_ret != H_SUCCESS) 88 if (h_ret != H_SUCCESS)
89 ehca_err(ibqp->device, 89 ehca_err(ibqp->device,
90 "ehca_qp=%p qp_num=%x hipz_h_attach_mcqp() failed " 90 "ehca_qp=%p qp_num=%x hipz_h_attach_mcqp() failed "
91 "h_ret=%li", my_qp, ibqp->qp_num, h_ret); 91 "h_ret=%lli", my_qp, ibqp->qp_num, h_ret);
92 92
93 return ehca2ib_return_code(h_ret); 93 return ehca2ib_return_code(h_ret);
94} 94}
@@ -125,7 +125,7 @@ int ehca_detach_mcast(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
125 if (h_ret != H_SUCCESS) 125 if (h_ret != H_SUCCESS)
126 ehca_err(ibqp->device, 126 ehca_err(ibqp->device,
127 "ehca_qp=%p qp_num=%x hipz_h_detach_mcqp() failed " 127 "ehca_qp=%p qp_num=%x hipz_h_detach_mcqp() failed "
128 "h_ret=%li", my_qp, ibqp->qp_num, h_ret); 128 "h_ret=%lli", my_qp, ibqp->qp_num, h_ret);
129 129
130 return ehca2ib_return_code(h_ret); 130 return ehca2ib_return_code(h_ret);
131} 131}
diff --git a/drivers/infiniband/hw/ehca/ehca_mrmw.c b/drivers/infiniband/hw/ehca/ehca_mrmw.c
index f974367cad40..72f83f7df614 100644
--- a/drivers/infiniband/hw/ehca/ehca_mrmw.c
+++ b/drivers/infiniband/hw/ehca/ehca_mrmw.c
@@ -204,7 +204,7 @@ struct ib_mr *ehca_reg_phys_mr(struct ib_pd *pd,
204 } 204 }
205 if ((size == 0) || 205 if ((size == 0) ||
206 (((u64)iova_start + size) < (u64)iova_start)) { 206 (((u64)iova_start + size) < (u64)iova_start)) {
207 ehca_err(pd->device, "bad input values: size=%lx iova_start=%p", 207 ehca_err(pd->device, "bad input values: size=%llx iova_start=%p",
208 size, iova_start); 208 size, iova_start);
209 ib_mr = ERR_PTR(-EINVAL); 209 ib_mr = ERR_PTR(-EINVAL);
210 goto reg_phys_mr_exit0; 210 goto reg_phys_mr_exit0;
@@ -309,8 +309,8 @@ struct ib_mr *ehca_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
309 } 309 }
310 310
311 if (length == 0 || virt + length < virt) { 311 if (length == 0 || virt + length < virt) {
312 ehca_err(pd->device, "bad input values: length=%lx " 312 ehca_err(pd->device, "bad input values: length=%llx "
313 "virt_base=%lx", length, virt); 313 "virt_base=%llx", length, virt);
314 ib_mr = ERR_PTR(-EINVAL); 314 ib_mr = ERR_PTR(-EINVAL);
315 goto reg_user_mr_exit0; 315 goto reg_user_mr_exit0;
316 } 316 }
@@ -373,7 +373,7 @@ reg_user_mr_fallback:
373 &e_mr->ib.ib_mr.rkey); 373 &e_mr->ib.ib_mr.rkey);
374 if (ret == -EINVAL && pginfo.hwpage_size > PAGE_SIZE) { 374 if (ret == -EINVAL && pginfo.hwpage_size > PAGE_SIZE) {
375 ehca_warn(pd->device, "failed to register mr " 375 ehca_warn(pd->device, "failed to register mr "
376 "with hwpage_size=%lx", hwpage_size); 376 "with hwpage_size=%llx", hwpage_size);
377 ehca_info(pd->device, "try to register mr with " 377 ehca_info(pd->device, "try to register mr with "
378 "kpage_size=%lx", PAGE_SIZE); 378 "kpage_size=%lx", PAGE_SIZE);
379 /* 379 /*
@@ -509,7 +509,7 @@ int ehca_rereg_phys_mr(struct ib_mr *mr,
509 goto rereg_phys_mr_exit1; 509 goto rereg_phys_mr_exit1;
510 if ((new_size == 0) || 510 if ((new_size == 0) ||
511 (((u64)iova_start + new_size) < (u64)iova_start)) { 511 (((u64)iova_start + new_size) < (u64)iova_start)) {
512 ehca_err(mr->device, "bad input values: new_size=%lx " 512 ehca_err(mr->device, "bad input values: new_size=%llx "
513 "iova_start=%p", new_size, iova_start); 513 "iova_start=%p", new_size, iova_start);
514 ret = -EINVAL; 514 ret = -EINVAL;
515 goto rereg_phys_mr_exit1; 515 goto rereg_phys_mr_exit1;
@@ -580,8 +580,8 @@ int ehca_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr)
580 580
581 h_ret = hipz_h_query_mr(shca->ipz_hca_handle, e_mr, &hipzout); 581 h_ret = hipz_h_query_mr(shca->ipz_hca_handle, e_mr, &hipzout);
582 if (h_ret != H_SUCCESS) { 582 if (h_ret != H_SUCCESS) {
583 ehca_err(mr->device, "hipz_mr_query failed, h_ret=%li mr=%p " 583 ehca_err(mr->device, "hipz_mr_query failed, h_ret=%lli mr=%p "
584 "hca_hndl=%lx mr_hndl=%lx lkey=%x", 584 "hca_hndl=%llx mr_hndl=%llx lkey=%x",
585 h_ret, mr, shca->ipz_hca_handle.handle, 585 h_ret, mr, shca->ipz_hca_handle.handle,
586 e_mr->ipz_mr_handle.handle, mr->lkey); 586 e_mr->ipz_mr_handle.handle, mr->lkey);
587 ret = ehca2ib_return_code(h_ret); 587 ret = ehca2ib_return_code(h_ret);
@@ -630,8 +630,8 @@ int ehca_dereg_mr(struct ib_mr *mr)
630 /* TODO: BUSY: MR still has bound window(s) */ 630 /* TODO: BUSY: MR still has bound window(s) */
631 h_ret = hipz_h_free_resource_mr(shca->ipz_hca_handle, e_mr); 631 h_ret = hipz_h_free_resource_mr(shca->ipz_hca_handle, e_mr);
632 if (h_ret != H_SUCCESS) { 632 if (h_ret != H_SUCCESS) {
633 ehca_err(mr->device, "hipz_free_mr failed, h_ret=%li shca=%p " 633 ehca_err(mr->device, "hipz_free_mr failed, h_ret=%lli shca=%p "
634 "e_mr=%p hca_hndl=%lx mr_hndl=%lx mr->lkey=%x", 634 "e_mr=%p hca_hndl=%llx mr_hndl=%llx mr->lkey=%x",
635 h_ret, shca, e_mr, shca->ipz_hca_handle.handle, 635 h_ret, shca, e_mr, shca->ipz_hca_handle.handle,
636 e_mr->ipz_mr_handle.handle, mr->lkey); 636 e_mr->ipz_mr_handle.handle, mr->lkey);
637 ret = ehca2ib_return_code(h_ret); 637 ret = ehca2ib_return_code(h_ret);
@@ -671,8 +671,8 @@ struct ib_mw *ehca_alloc_mw(struct ib_pd *pd)
671 h_ret = hipz_h_alloc_resource_mw(shca->ipz_hca_handle, e_mw, 671 h_ret = hipz_h_alloc_resource_mw(shca->ipz_hca_handle, e_mw,
672 e_pd->fw_pd, &hipzout); 672 e_pd->fw_pd, &hipzout);
673 if (h_ret != H_SUCCESS) { 673 if (h_ret != H_SUCCESS) {
674 ehca_err(pd->device, "hipz_mw_allocate failed, h_ret=%li " 674 ehca_err(pd->device, "hipz_mw_allocate failed, h_ret=%lli "
675 "shca=%p hca_hndl=%lx mw=%p", 675 "shca=%p hca_hndl=%llx mw=%p",
676 h_ret, shca, shca->ipz_hca_handle.handle, e_mw); 676 h_ret, shca, shca->ipz_hca_handle.handle, e_mw);
677 ib_mw = ERR_PTR(ehca2ib_return_code(h_ret)); 677 ib_mw = ERR_PTR(ehca2ib_return_code(h_ret));
678 goto alloc_mw_exit1; 678 goto alloc_mw_exit1;
@@ -713,8 +713,8 @@ int ehca_dealloc_mw(struct ib_mw *mw)
713 713
714 h_ret = hipz_h_free_resource_mw(shca->ipz_hca_handle, e_mw); 714 h_ret = hipz_h_free_resource_mw(shca->ipz_hca_handle, e_mw);
715 if (h_ret != H_SUCCESS) { 715 if (h_ret != H_SUCCESS) {
716 ehca_err(mw->device, "hipz_free_mw failed, h_ret=%li shca=%p " 716 ehca_err(mw->device, "hipz_free_mw failed, h_ret=%lli shca=%p "
717 "mw=%p rkey=%x hca_hndl=%lx mw_hndl=%lx", 717 "mw=%p rkey=%x hca_hndl=%llx mw_hndl=%llx",
718 h_ret, shca, mw, mw->rkey, shca->ipz_hca_handle.handle, 718 h_ret, shca, mw, mw->rkey, shca->ipz_hca_handle.handle,
719 e_mw->ipz_mw_handle.handle); 719 e_mw->ipz_mw_handle.handle);
720 return ehca2ib_return_code(h_ret); 720 return ehca2ib_return_code(h_ret);
@@ -840,7 +840,7 @@ int ehca_map_phys_fmr(struct ib_fmr *fmr,
840 goto map_phys_fmr_exit0; 840 goto map_phys_fmr_exit0;
841 if (iova % e_fmr->fmr_page_size) { 841 if (iova % e_fmr->fmr_page_size) {
842 /* only whole-numbered pages */ 842 /* only whole-numbered pages */
843 ehca_err(fmr->device, "bad iova, iova=%lx fmr_page_size=%x", 843 ehca_err(fmr->device, "bad iova, iova=%llx fmr_page_size=%x",
844 iova, e_fmr->fmr_page_size); 844 iova, e_fmr->fmr_page_size);
845 ret = -EINVAL; 845 ret = -EINVAL;
846 goto map_phys_fmr_exit0; 846 goto map_phys_fmr_exit0;
@@ -878,7 +878,7 @@ int ehca_map_phys_fmr(struct ib_fmr *fmr,
878map_phys_fmr_exit0: 878map_phys_fmr_exit0:
879 if (ret) 879 if (ret)
880 ehca_err(fmr->device, "ret=%i fmr=%p page_list=%p list_len=%x " 880 ehca_err(fmr->device, "ret=%i fmr=%p page_list=%p list_len=%x "
881 "iova=%lx", ret, fmr, page_list, list_len, iova); 881 "iova=%llx", ret, fmr, page_list, list_len, iova);
882 return ret; 882 return ret;
883} /* end ehca_map_phys_fmr() */ 883} /* end ehca_map_phys_fmr() */
884 884
@@ -964,8 +964,8 @@ int ehca_dealloc_fmr(struct ib_fmr *fmr)
964 964
965 h_ret = hipz_h_free_resource_mr(shca->ipz_hca_handle, e_fmr); 965 h_ret = hipz_h_free_resource_mr(shca->ipz_hca_handle, e_fmr);
966 if (h_ret != H_SUCCESS) { 966 if (h_ret != H_SUCCESS) {
967 ehca_err(fmr->device, "hipz_free_mr failed, h_ret=%li e_fmr=%p " 967 ehca_err(fmr->device, "hipz_free_mr failed, h_ret=%lli e_fmr=%p "
968 "hca_hndl=%lx fmr_hndl=%lx fmr->lkey=%x", 968 "hca_hndl=%llx fmr_hndl=%llx fmr->lkey=%x",
969 h_ret, e_fmr, shca->ipz_hca_handle.handle, 969 h_ret, e_fmr, shca->ipz_hca_handle.handle,
970 e_fmr->ipz_mr_handle.handle, fmr->lkey); 970 e_fmr->ipz_mr_handle.handle, fmr->lkey);
971 ret = ehca2ib_return_code(h_ret); 971 ret = ehca2ib_return_code(h_ret);
@@ -1007,8 +1007,8 @@ int ehca_reg_mr(struct ehca_shca *shca,
1007 (u64)iova_start, size, hipz_acl, 1007 (u64)iova_start, size, hipz_acl,
1008 e_pd->fw_pd, &hipzout); 1008 e_pd->fw_pd, &hipzout);
1009 if (h_ret != H_SUCCESS) { 1009 if (h_ret != H_SUCCESS) {
1010 ehca_err(&shca->ib_device, "hipz_alloc_mr failed, h_ret=%li " 1010 ehca_err(&shca->ib_device, "hipz_alloc_mr failed, h_ret=%lli "
1011 "hca_hndl=%lx", h_ret, shca->ipz_hca_handle.handle); 1011 "hca_hndl=%llx", h_ret, shca->ipz_hca_handle.handle);
1012 ret = ehca2ib_return_code(h_ret); 1012 ret = ehca2ib_return_code(h_ret);
1013 goto ehca_reg_mr_exit0; 1013 goto ehca_reg_mr_exit0;
1014 } 1014 }
@@ -1033,9 +1033,9 @@ int ehca_reg_mr(struct ehca_shca *shca,
1033ehca_reg_mr_exit1: 1033ehca_reg_mr_exit1:
1034 h_ret = hipz_h_free_resource_mr(shca->ipz_hca_handle, e_mr); 1034 h_ret = hipz_h_free_resource_mr(shca->ipz_hca_handle, e_mr);
1035 if (h_ret != H_SUCCESS) { 1035 if (h_ret != H_SUCCESS) {
1036 ehca_err(&shca->ib_device, "h_ret=%li shca=%p e_mr=%p " 1036 ehca_err(&shca->ib_device, "h_ret=%lli shca=%p e_mr=%p "
1037 "iova_start=%p size=%lx acl=%x e_pd=%p lkey=%x " 1037 "iova_start=%p size=%llx acl=%x e_pd=%p lkey=%x "
1038 "pginfo=%p num_kpages=%lx num_hwpages=%lx ret=%i", 1038 "pginfo=%p num_kpages=%llx num_hwpages=%llx ret=%i",
1039 h_ret, shca, e_mr, iova_start, size, acl, e_pd, 1039 h_ret, shca, e_mr, iova_start, size, acl, e_pd,
1040 hipzout.lkey, pginfo, pginfo->num_kpages, 1040 hipzout.lkey, pginfo, pginfo->num_kpages,
1041 pginfo->num_hwpages, ret); 1041 pginfo->num_hwpages, ret);
@@ -1045,8 +1045,8 @@ ehca_reg_mr_exit1:
1045ehca_reg_mr_exit0: 1045ehca_reg_mr_exit0:
1046 if (ret) 1046 if (ret)
1047 ehca_err(&shca->ib_device, "ret=%i shca=%p e_mr=%p " 1047 ehca_err(&shca->ib_device, "ret=%i shca=%p e_mr=%p "
1048 "iova_start=%p size=%lx acl=%x e_pd=%p pginfo=%p " 1048 "iova_start=%p size=%llx acl=%x e_pd=%p pginfo=%p "
1049 "num_kpages=%lx num_hwpages=%lx", 1049 "num_kpages=%llx num_hwpages=%llx",
1050 ret, shca, e_mr, iova_start, size, acl, e_pd, pginfo, 1050 ret, shca, e_mr, iova_start, size, acl, e_pd, pginfo,
1051 pginfo->num_kpages, pginfo->num_hwpages); 1051 pginfo->num_kpages, pginfo->num_hwpages);
1052 return ret; 1052 return ret;
@@ -1116,8 +1116,8 @@ int ehca_reg_mr_rpages(struct ehca_shca *shca,
1116 */ 1116 */
1117 if (h_ret != H_SUCCESS) { 1117 if (h_ret != H_SUCCESS) {
1118 ehca_err(&shca->ib_device, "last " 1118 ehca_err(&shca->ib_device, "last "
1119 "hipz_reg_rpage_mr failed, h_ret=%li " 1119 "hipz_reg_rpage_mr failed, h_ret=%lli "
1120 "e_mr=%p i=%x hca_hndl=%lx mr_hndl=%lx" 1120 "e_mr=%p i=%x hca_hndl=%llx mr_hndl=%llx"
1121 " lkey=%x", h_ret, e_mr, i, 1121 " lkey=%x", h_ret, e_mr, i,
1122 shca->ipz_hca_handle.handle, 1122 shca->ipz_hca_handle.handle,
1123 e_mr->ipz_mr_handle.handle, 1123 e_mr->ipz_mr_handle.handle,
@@ -1128,8 +1128,8 @@ int ehca_reg_mr_rpages(struct ehca_shca *shca,
1128 ret = 0; 1128 ret = 0;
1129 } else if (h_ret != H_PAGE_REGISTERED) { 1129 } else if (h_ret != H_PAGE_REGISTERED) {
1130 ehca_err(&shca->ib_device, "hipz_reg_rpage_mr failed, " 1130 ehca_err(&shca->ib_device, "hipz_reg_rpage_mr failed, "
1131 "h_ret=%li e_mr=%p i=%x lkey=%x hca_hndl=%lx " 1131 "h_ret=%lli e_mr=%p i=%x lkey=%x hca_hndl=%llx "
1132 "mr_hndl=%lx", h_ret, e_mr, i, 1132 "mr_hndl=%llx", h_ret, e_mr, i,
1133 e_mr->ib.ib_mr.lkey, 1133 e_mr->ib.ib_mr.lkey,
1134 shca->ipz_hca_handle.handle, 1134 shca->ipz_hca_handle.handle,
1135 e_mr->ipz_mr_handle.handle); 1135 e_mr->ipz_mr_handle.handle);
@@ -1145,7 +1145,7 @@ ehca_reg_mr_rpages_exit1:
1145ehca_reg_mr_rpages_exit0: 1145ehca_reg_mr_rpages_exit0:
1146 if (ret) 1146 if (ret)
1147 ehca_err(&shca->ib_device, "ret=%i shca=%p e_mr=%p pginfo=%p " 1147 ehca_err(&shca->ib_device, "ret=%i shca=%p e_mr=%p pginfo=%p "
1148 "num_kpages=%lx num_hwpages=%lx", ret, shca, e_mr, 1148 "num_kpages=%llx num_hwpages=%llx", ret, shca, e_mr,
1149 pginfo, pginfo->num_kpages, pginfo->num_hwpages); 1149 pginfo, pginfo->num_kpages, pginfo->num_hwpages);
1150 return ret; 1150 return ret;
1151} /* end ehca_reg_mr_rpages() */ 1151} /* end ehca_reg_mr_rpages() */
@@ -1184,7 +1184,7 @@ inline int ehca_rereg_mr_rereg1(struct ehca_shca *shca,
1184 ret = ehca_set_pagebuf(pginfo, pginfo->num_hwpages, kpage); 1184 ret = ehca_set_pagebuf(pginfo, pginfo->num_hwpages, kpage);
1185 if (ret) { 1185 if (ret) {
1186 ehca_err(&shca->ib_device, "set pagebuf failed, e_mr=%p " 1186 ehca_err(&shca->ib_device, "set pagebuf failed, e_mr=%p "
1187 "pginfo=%p type=%x num_kpages=%lx num_hwpages=%lx " 1187 "pginfo=%p type=%x num_kpages=%llx num_hwpages=%llx "
1188 "kpage=%p", e_mr, pginfo, pginfo->type, 1188 "kpage=%p", e_mr, pginfo, pginfo->type,
1189 pginfo->num_kpages, pginfo->num_hwpages, kpage); 1189 pginfo->num_kpages, pginfo->num_hwpages, kpage);
1190 goto ehca_rereg_mr_rereg1_exit1; 1190 goto ehca_rereg_mr_rereg1_exit1;
@@ -1205,13 +1205,13 @@ inline int ehca_rereg_mr_rereg1(struct ehca_shca *shca,
1205 * (MW bound or MR is shared) 1205 * (MW bound or MR is shared)
1206 */ 1206 */
1207 ehca_warn(&shca->ib_device, "hipz_h_reregister_pmr failed " 1207 ehca_warn(&shca->ib_device, "hipz_h_reregister_pmr failed "
1208 "(Rereg1), h_ret=%li e_mr=%p", h_ret, e_mr); 1208 "(Rereg1), h_ret=%lli e_mr=%p", h_ret, e_mr);
1209 *pginfo = pginfo_save; 1209 *pginfo = pginfo_save;
1210 ret = -EAGAIN; 1210 ret = -EAGAIN;
1211 } else if ((u64 *)hipzout.vaddr != iova_start) { 1211 } else if ((u64 *)hipzout.vaddr != iova_start) {
1212 ehca_err(&shca->ib_device, "PHYP changed iova_start in " 1212 ehca_err(&shca->ib_device, "PHYP changed iova_start in "
1213 "rereg_pmr, iova_start=%p iova_start_out=%lx e_mr=%p " 1213 "rereg_pmr, iova_start=%p iova_start_out=%llx e_mr=%p "
1214 "mr_handle=%lx lkey=%x lkey_out=%x", iova_start, 1214 "mr_handle=%llx lkey=%x lkey_out=%x", iova_start,
1215 hipzout.vaddr, e_mr, e_mr->ipz_mr_handle.handle, 1215 hipzout.vaddr, e_mr, e_mr->ipz_mr_handle.handle,
1216 e_mr->ib.ib_mr.lkey, hipzout.lkey); 1216 e_mr->ib.ib_mr.lkey, hipzout.lkey);
1217 ret = -EFAULT; 1217 ret = -EFAULT;
@@ -1235,7 +1235,7 @@ ehca_rereg_mr_rereg1_exit1:
1235ehca_rereg_mr_rereg1_exit0: 1235ehca_rereg_mr_rereg1_exit0:
1236 if ( ret && (ret != -EAGAIN) ) 1236 if ( ret && (ret != -EAGAIN) )
1237 ehca_err(&shca->ib_device, "ret=%i lkey=%x rkey=%x " 1237 ehca_err(&shca->ib_device, "ret=%i lkey=%x rkey=%x "
1238 "pginfo=%p num_kpages=%lx num_hwpages=%lx", 1238 "pginfo=%p num_kpages=%llx num_hwpages=%llx",
1239 ret, *lkey, *rkey, pginfo, pginfo->num_kpages, 1239 ret, *lkey, *rkey, pginfo, pginfo->num_kpages,
1240 pginfo->num_hwpages); 1240 pginfo->num_hwpages);
1241 return ret; 1241 return ret;
@@ -1263,7 +1263,7 @@ int ehca_rereg_mr(struct ehca_shca *shca,
1263 (e_mr->num_hwpages > MAX_RPAGES) || 1263 (e_mr->num_hwpages > MAX_RPAGES) ||
1264 (pginfo->num_hwpages > e_mr->num_hwpages)) { 1264 (pginfo->num_hwpages > e_mr->num_hwpages)) {
1265 ehca_dbg(&shca->ib_device, "Rereg3 case, " 1265 ehca_dbg(&shca->ib_device, "Rereg3 case, "
1266 "pginfo->num_hwpages=%lx e_mr->num_hwpages=%x", 1266 "pginfo->num_hwpages=%llx e_mr->num_hwpages=%x",
1267 pginfo->num_hwpages, e_mr->num_hwpages); 1267 pginfo->num_hwpages, e_mr->num_hwpages);
1268 rereg_1_hcall = 0; 1268 rereg_1_hcall = 0;
1269 rereg_3_hcall = 1; 1269 rereg_3_hcall = 1;
@@ -1295,7 +1295,7 @@ int ehca_rereg_mr(struct ehca_shca *shca,
1295 h_ret = hipz_h_free_resource_mr(shca->ipz_hca_handle, e_mr); 1295 h_ret = hipz_h_free_resource_mr(shca->ipz_hca_handle, e_mr);
1296 if (h_ret != H_SUCCESS) { 1296 if (h_ret != H_SUCCESS) {
1297 ehca_err(&shca->ib_device, "hipz_free_mr failed, " 1297 ehca_err(&shca->ib_device, "hipz_free_mr failed, "
1298 "h_ret=%li e_mr=%p hca_hndl=%lx mr_hndl=%lx " 1298 "h_ret=%lli e_mr=%p hca_hndl=%llx mr_hndl=%llx "
1299 "mr->lkey=%x", 1299 "mr->lkey=%x",
1300 h_ret, e_mr, shca->ipz_hca_handle.handle, 1300 h_ret, e_mr, shca->ipz_hca_handle.handle,
1301 e_mr->ipz_mr_handle.handle, 1301 e_mr->ipz_mr_handle.handle,
@@ -1328,8 +1328,8 @@ int ehca_rereg_mr(struct ehca_shca *shca,
1328ehca_rereg_mr_exit0: 1328ehca_rereg_mr_exit0:
1329 if (ret) 1329 if (ret)
1330 ehca_err(&shca->ib_device, "ret=%i shca=%p e_mr=%p " 1330 ehca_err(&shca->ib_device, "ret=%i shca=%p e_mr=%p "
1331 "iova_start=%p size=%lx acl=%x e_pd=%p pginfo=%p " 1331 "iova_start=%p size=%llx acl=%x e_pd=%p pginfo=%p "
1332 "num_kpages=%lx lkey=%x rkey=%x rereg_1_hcall=%x " 1332 "num_kpages=%llx lkey=%x rkey=%x rereg_1_hcall=%x "
1333 "rereg_3_hcall=%x", ret, shca, e_mr, iova_start, size, 1333 "rereg_3_hcall=%x", ret, shca, e_mr, iova_start, size,
1334 acl, e_pd, pginfo, pginfo->num_kpages, *lkey, *rkey, 1334 acl, e_pd, pginfo, pginfo->num_kpages, *lkey, *rkey,
1335 rereg_1_hcall, rereg_3_hcall); 1335 rereg_1_hcall, rereg_3_hcall);
@@ -1371,8 +1371,8 @@ int ehca_unmap_one_fmr(struct ehca_shca *shca,
1371 * FMRs are not shared and no MW bound to FMRs 1371 * FMRs are not shared and no MW bound to FMRs
1372 */ 1372 */
1373 ehca_err(&shca->ib_device, "hipz_reregister_pmr failed " 1373 ehca_err(&shca->ib_device, "hipz_reregister_pmr failed "
1374 "(Rereg1), h_ret=%li e_fmr=%p hca_hndl=%lx " 1374 "(Rereg1), h_ret=%lli e_fmr=%p hca_hndl=%llx "
1375 "mr_hndl=%lx lkey=%x lkey_out=%x", 1375 "mr_hndl=%llx lkey=%x lkey_out=%x",
1376 h_ret, e_fmr, shca->ipz_hca_handle.handle, 1376 h_ret, e_fmr, shca->ipz_hca_handle.handle,
1377 e_fmr->ipz_mr_handle.handle, 1377 e_fmr->ipz_mr_handle.handle,
1378 e_fmr->ib.ib_fmr.lkey, hipzout.lkey); 1378 e_fmr->ib.ib_fmr.lkey, hipzout.lkey);
@@ -1383,7 +1383,7 @@ int ehca_unmap_one_fmr(struct ehca_shca *shca,
1383 h_ret = hipz_h_free_resource_mr(shca->ipz_hca_handle, e_fmr); 1383 h_ret = hipz_h_free_resource_mr(shca->ipz_hca_handle, e_fmr);
1384 if (h_ret != H_SUCCESS) { 1384 if (h_ret != H_SUCCESS) {
1385 ehca_err(&shca->ib_device, "hipz_free_mr failed, " 1385 ehca_err(&shca->ib_device, "hipz_free_mr failed, "
1386 "h_ret=%li e_fmr=%p hca_hndl=%lx mr_hndl=%lx " 1386 "h_ret=%lli e_fmr=%p hca_hndl=%llx mr_hndl=%llx "
1387 "lkey=%x", 1387 "lkey=%x",
1388 h_ret, e_fmr, shca->ipz_hca_handle.handle, 1388 h_ret, e_fmr, shca->ipz_hca_handle.handle,
1389 e_fmr->ipz_mr_handle.handle, 1389 e_fmr->ipz_mr_handle.handle,
@@ -1447,9 +1447,9 @@ int ehca_reg_smr(struct ehca_shca *shca,
1447 (u64)iova_start, hipz_acl, e_pd->fw_pd, 1447 (u64)iova_start, hipz_acl, e_pd->fw_pd,
1448 &hipzout); 1448 &hipzout);
1449 if (h_ret != H_SUCCESS) { 1449 if (h_ret != H_SUCCESS) {
1450 ehca_err(&shca->ib_device, "hipz_reg_smr failed, h_ret=%li " 1450 ehca_err(&shca->ib_device, "hipz_reg_smr failed, h_ret=%lli "
1451 "shca=%p e_origmr=%p e_newmr=%p iova_start=%p acl=%x " 1451 "shca=%p e_origmr=%p e_newmr=%p iova_start=%p acl=%x "
1452 "e_pd=%p hca_hndl=%lx mr_hndl=%lx lkey=%x", 1452 "e_pd=%p hca_hndl=%llx mr_hndl=%llx lkey=%x",
1453 h_ret, shca, e_origmr, e_newmr, iova_start, acl, e_pd, 1453 h_ret, shca, e_origmr, e_newmr, iova_start, acl, e_pd,
1454 shca->ipz_hca_handle.handle, 1454 shca->ipz_hca_handle.handle,
1455 e_origmr->ipz_mr_handle.handle, 1455 e_origmr->ipz_mr_handle.handle,
@@ -1527,7 +1527,7 @@ int ehca_reg_internal_maxmr(
1527 &e_mr->ib.ib_mr.rkey); 1527 &e_mr->ib.ib_mr.rkey);
1528 if (ret) { 1528 if (ret) {
1529 ehca_err(&shca->ib_device, "reg of internal max MR failed, " 1529 ehca_err(&shca->ib_device, "reg of internal max MR failed, "
1530 "e_mr=%p iova_start=%p size_maxmr=%lx num_kpages=%x " 1530 "e_mr=%p iova_start=%p size_maxmr=%llx num_kpages=%x "
1531 "num_hwpages=%x", e_mr, iova_start, size_maxmr, 1531 "num_hwpages=%x", e_mr, iova_start, size_maxmr,
1532 num_kpages, num_hwpages); 1532 num_kpages, num_hwpages);
1533 goto ehca_reg_internal_maxmr_exit1; 1533 goto ehca_reg_internal_maxmr_exit1;
@@ -1573,8 +1573,8 @@ int ehca_reg_maxmr(struct ehca_shca *shca,
1573 (u64)iova_start, hipz_acl, e_pd->fw_pd, 1573 (u64)iova_start, hipz_acl, e_pd->fw_pd,
1574 &hipzout); 1574 &hipzout);
1575 if (h_ret != H_SUCCESS) { 1575 if (h_ret != H_SUCCESS) {
1576 ehca_err(&shca->ib_device, "hipz_reg_smr failed, h_ret=%li " 1576 ehca_err(&shca->ib_device, "hipz_reg_smr failed, h_ret=%lli "
1577 "e_origmr=%p hca_hndl=%lx mr_hndl=%lx lkey=%x", 1577 "e_origmr=%p hca_hndl=%llx mr_hndl=%llx lkey=%x",
1578 h_ret, e_origmr, shca->ipz_hca_handle.handle, 1578 h_ret, e_origmr, shca->ipz_hca_handle.handle,
1579 e_origmr->ipz_mr_handle.handle, 1579 e_origmr->ipz_mr_handle.handle,
1580 e_origmr->ib.ib_mr.lkey); 1580 e_origmr->ib.ib_mr.lkey);
@@ -1651,28 +1651,28 @@ int ehca_mr_chk_buf_and_calc_size(struct ib_phys_buf *phys_buf_array,
1651 /* check first buffer */ 1651 /* check first buffer */
1652 if (((u64)iova_start & ~PAGE_MASK) != (pbuf->addr & ~PAGE_MASK)) { 1652 if (((u64)iova_start & ~PAGE_MASK) != (pbuf->addr & ~PAGE_MASK)) {
1653 ehca_gen_err("iova_start/addr mismatch, iova_start=%p " 1653 ehca_gen_err("iova_start/addr mismatch, iova_start=%p "
1654 "pbuf->addr=%lx pbuf->size=%lx", 1654 "pbuf->addr=%llx pbuf->size=%llx",
1655 iova_start, pbuf->addr, pbuf->size); 1655 iova_start, pbuf->addr, pbuf->size);
1656 return -EINVAL; 1656 return -EINVAL;
1657 } 1657 }
1658 if (((pbuf->addr + pbuf->size) % PAGE_SIZE) && 1658 if (((pbuf->addr + pbuf->size) % PAGE_SIZE) &&
1659 (num_phys_buf > 1)) { 1659 (num_phys_buf > 1)) {
1660 ehca_gen_err("addr/size mismatch in 1st buf, pbuf->addr=%lx " 1660 ehca_gen_err("addr/size mismatch in 1st buf, pbuf->addr=%llx "
1661 "pbuf->size=%lx", pbuf->addr, pbuf->size); 1661 "pbuf->size=%llx", pbuf->addr, pbuf->size);
1662 return -EINVAL; 1662 return -EINVAL;
1663 } 1663 }
1664 1664
1665 for (i = 0; i < num_phys_buf; i++) { 1665 for (i = 0; i < num_phys_buf; i++) {
1666 if ((i > 0) && (pbuf->addr % PAGE_SIZE)) { 1666 if ((i > 0) && (pbuf->addr % PAGE_SIZE)) {
1667 ehca_gen_err("bad address, i=%x pbuf->addr=%lx " 1667 ehca_gen_err("bad address, i=%x pbuf->addr=%llx "
1668 "pbuf->size=%lx", 1668 "pbuf->size=%llx",
1669 i, pbuf->addr, pbuf->size); 1669 i, pbuf->addr, pbuf->size);
1670 return -EINVAL; 1670 return -EINVAL;
1671 } 1671 }
1672 if (((i > 0) && /* not 1st */ 1672 if (((i > 0) && /* not 1st */
1673 (i < (num_phys_buf - 1)) && /* not last */ 1673 (i < (num_phys_buf - 1)) && /* not last */
1674 (pbuf->size % PAGE_SIZE)) || (pbuf->size == 0)) { 1674 (pbuf->size % PAGE_SIZE)) || (pbuf->size == 0)) {
1675 ehca_gen_err("bad size, i=%x pbuf->size=%lx", 1675 ehca_gen_err("bad size, i=%x pbuf->size=%llx",
1676 i, pbuf->size); 1676 i, pbuf->size);
1677 return -EINVAL; 1677 return -EINVAL;
1678 } 1678 }
@@ -1705,7 +1705,7 @@ int ehca_fmr_check_page_list(struct ehca_mr *e_fmr,
1705 page = page_list; 1705 page = page_list;
1706 for (i = 0; i < list_len; i++) { 1706 for (i = 0; i < list_len; i++) {
1707 if (*page % e_fmr->fmr_page_size) { 1707 if (*page % e_fmr->fmr_page_size) {
1708 ehca_gen_err("bad page, i=%x *page=%lx page=%p fmr=%p " 1708 ehca_gen_err("bad page, i=%x *page=%llx page=%p fmr=%p "
1709 "fmr_page_size=%x", i, *page, page, e_fmr, 1709 "fmr_page_size=%x", i, *page, page, e_fmr,
1710 e_fmr->fmr_page_size); 1710 e_fmr->fmr_page_size);
1711 return -EINVAL; 1711 return -EINVAL;
@@ -1743,9 +1743,9 @@ static int ehca_set_pagebuf_user1(struct ehca_mr_pginfo *pginfo,
1743 (pginfo->next_hwpage * 1743 (pginfo->next_hwpage *
1744 pginfo->hwpage_size)); 1744 pginfo->hwpage_size));
1745 if ( !(*kpage) ) { 1745 if ( !(*kpage) ) {
1746 ehca_gen_err("pgaddr=%lx " 1746 ehca_gen_err("pgaddr=%llx "
1747 "chunk->page_list[i]=%lx " 1747 "chunk->page_list[i]=%llx "
1748 "i=%x next_hwpage=%lx", 1748 "i=%x next_hwpage=%llx",
1749 pgaddr, (u64)sg_dma_address( 1749 pgaddr, (u64)sg_dma_address(
1750 &chunk->page_list[i]), 1750 &chunk->page_list[i]),
1751 i, pginfo->next_hwpage); 1751 i, pginfo->next_hwpage);
@@ -1795,11 +1795,11 @@ static int ehca_check_kpages_per_ate(struct scatterlist *page_list,
1795 for (t = start_idx; t <= end_idx; t++) { 1795 for (t = start_idx; t <= end_idx; t++) {
1796 u64 pgaddr = page_to_pfn(sg_page(&page_list[t])) << PAGE_SHIFT; 1796 u64 pgaddr = page_to_pfn(sg_page(&page_list[t])) << PAGE_SHIFT;
1797 if (ehca_debug_level >= 3) 1797 if (ehca_debug_level >= 3)
1798 ehca_gen_dbg("chunk_page=%lx value=%016lx", pgaddr, 1798 ehca_gen_dbg("chunk_page=%llx value=%016llx", pgaddr,
1799 *(u64 *)abs_to_virt(phys_to_abs(pgaddr))); 1799 *(u64 *)abs_to_virt(phys_to_abs(pgaddr)));
1800 if (pgaddr - PAGE_SIZE != *prev_pgaddr) { 1800 if (pgaddr - PAGE_SIZE != *prev_pgaddr) {
1801 ehca_gen_err("uncontiguous page found pgaddr=%lx " 1801 ehca_gen_err("uncontiguous page found pgaddr=%llx "
1802 "prev_pgaddr=%lx page_list_i=%x", 1802 "prev_pgaddr=%llx page_list_i=%x",
1803 pgaddr, *prev_pgaddr, t); 1803 pgaddr, *prev_pgaddr, t);
1804 return -EINVAL; 1804 return -EINVAL;
1805 } 1805 }
@@ -1833,7 +1833,7 @@ static int ehca_set_pagebuf_user2(struct ehca_mr_pginfo *pginfo,
1833 << PAGE_SHIFT ); 1833 << PAGE_SHIFT );
1834 *kpage = phys_to_abs(pgaddr); 1834 *kpage = phys_to_abs(pgaddr);
1835 if ( !(*kpage) ) { 1835 if ( !(*kpage) ) {
1836 ehca_gen_err("pgaddr=%lx i=%x", 1836 ehca_gen_err("pgaddr=%llx i=%x",
1837 pgaddr, i); 1837 pgaddr, i);
1838 ret = -EFAULT; 1838 ret = -EFAULT;
1839 return ret; 1839 return ret;
@@ -1846,8 +1846,8 @@ static int ehca_set_pagebuf_user2(struct ehca_mr_pginfo *pginfo,
1846 if (pginfo->hwpage_cnt) { 1846 if (pginfo->hwpage_cnt) {
1847 ehca_gen_err( 1847 ehca_gen_err(
1848 "invalid alignment " 1848 "invalid alignment "
1849 "pgaddr=%lx i=%x " 1849 "pgaddr=%llx i=%x "
1850 "mr_pgsize=%lx", 1850 "mr_pgsize=%llx",
1851 pgaddr, i, 1851 pgaddr, i,
1852 pginfo->hwpage_size); 1852 pginfo->hwpage_size);
1853 ret = -EFAULT; 1853 ret = -EFAULT;
@@ -1866,8 +1866,8 @@ static int ehca_set_pagebuf_user2(struct ehca_mr_pginfo *pginfo,
1866 if (ehca_debug_level >= 3) { 1866 if (ehca_debug_level >= 3) {
1867 u64 val = *(u64 *)abs_to_virt( 1867 u64 val = *(u64 *)abs_to_virt(
1868 phys_to_abs(pgaddr)); 1868 phys_to_abs(pgaddr));
1869 ehca_gen_dbg("kpage=%lx chunk_page=%lx " 1869 ehca_gen_dbg("kpage=%llx chunk_page=%llx "
1870 "value=%016lx", 1870 "value=%016llx",
1871 *kpage, pgaddr, val); 1871 *kpage, pgaddr, val);
1872 } 1872 }
1873 prev_pgaddr = pgaddr; 1873 prev_pgaddr = pgaddr;
@@ -1944,9 +1944,9 @@ static int ehca_set_pagebuf_phys(struct ehca_mr_pginfo *pginfo,
1944 if ((pginfo->kpage_cnt >= pginfo->num_kpages) || 1944 if ((pginfo->kpage_cnt >= pginfo->num_kpages) ||
1945 (pginfo->hwpage_cnt >= pginfo->num_hwpages)) { 1945 (pginfo->hwpage_cnt >= pginfo->num_hwpages)) {
1946 ehca_gen_err("kpage_cnt >= num_kpages, " 1946 ehca_gen_err("kpage_cnt >= num_kpages, "
1947 "kpage_cnt=%lx num_kpages=%lx " 1947 "kpage_cnt=%llx num_kpages=%llx "
1948 "hwpage_cnt=%lx " 1948 "hwpage_cnt=%llx "
1949 "num_hwpages=%lx i=%x", 1949 "num_hwpages=%llx i=%x",
1950 pginfo->kpage_cnt, 1950 pginfo->kpage_cnt,
1951 pginfo->num_kpages, 1951 pginfo->num_kpages,
1952 pginfo->hwpage_cnt, 1952 pginfo->hwpage_cnt,
@@ -1957,8 +1957,8 @@ static int ehca_set_pagebuf_phys(struct ehca_mr_pginfo *pginfo,
1957 (pbuf->addr & ~(pginfo->hwpage_size - 1)) + 1957 (pbuf->addr & ~(pginfo->hwpage_size - 1)) +
1958 (pginfo->next_hwpage * pginfo->hwpage_size)); 1958 (pginfo->next_hwpage * pginfo->hwpage_size));
1959 if ( !(*kpage) && pbuf->addr ) { 1959 if ( !(*kpage) && pbuf->addr ) {
1960 ehca_gen_err("pbuf->addr=%lx pbuf->size=%lx " 1960 ehca_gen_err("pbuf->addr=%llx pbuf->size=%llx "
1961 "next_hwpage=%lx", pbuf->addr, 1961 "next_hwpage=%llx", pbuf->addr,
1962 pbuf->size, pginfo->next_hwpage); 1962 pbuf->size, pginfo->next_hwpage);
1963 return -EFAULT; 1963 return -EFAULT;
1964 } 1964 }
@@ -1996,8 +1996,8 @@ static int ehca_set_pagebuf_fmr(struct ehca_mr_pginfo *pginfo,
1996 *kpage = phys_to_abs((*fmrlist & ~(pginfo->hwpage_size - 1)) + 1996 *kpage = phys_to_abs((*fmrlist & ~(pginfo->hwpage_size - 1)) +
1997 pginfo->next_hwpage * pginfo->hwpage_size); 1997 pginfo->next_hwpage * pginfo->hwpage_size);
1998 if ( !(*kpage) ) { 1998 if ( !(*kpage) ) {
1999 ehca_gen_err("*fmrlist=%lx fmrlist=%p " 1999 ehca_gen_err("*fmrlist=%llx fmrlist=%p "
2000 "next_listelem=%lx next_hwpage=%lx", 2000 "next_listelem=%llx next_hwpage=%llx",
2001 *fmrlist, fmrlist, 2001 *fmrlist, fmrlist,
2002 pginfo->u.fmr.next_listelem, 2002 pginfo->u.fmr.next_listelem,
2003 pginfo->next_hwpage); 2003 pginfo->next_hwpage);
@@ -2025,7 +2025,7 @@ static int ehca_set_pagebuf_fmr(struct ehca_mr_pginfo *pginfo,
2025 ~(pginfo->hwpage_size - 1)); 2025 ~(pginfo->hwpage_size - 1));
2026 if (prev + pginfo->u.fmr.fmr_pgsize != p) { 2026 if (prev + pginfo->u.fmr.fmr_pgsize != p) {
2027 ehca_gen_err("uncontiguous fmr pages " 2027 ehca_gen_err("uncontiguous fmr pages "
2028 "found prev=%lx p=%lx " 2028 "found prev=%llx p=%llx "
2029 "idx=%x", prev, p, i + j); 2029 "idx=%x", prev, p, i + j);
2030 return -EINVAL; 2030 return -EINVAL;
2031 } 2031 }
diff --git a/drivers/infiniband/hw/ehca/ehca_qp.c b/drivers/infiniband/hw/ehca/ehca_qp.c
index f161cf173dbe..00c108159714 100644
--- a/drivers/infiniband/hw/ehca/ehca_qp.c
+++ b/drivers/infiniband/hw/ehca/ehca_qp.c
@@ -331,7 +331,7 @@ static inline int init_qp_queue(struct ehca_shca *shca,
331 if (cnt == (nr_q_pages - 1)) { /* last page! */ 331 if (cnt == (nr_q_pages - 1)) { /* last page! */
332 if (h_ret != expected_hret) { 332 if (h_ret != expected_hret) {
333 ehca_err(ib_dev, "hipz_qp_register_rpage() " 333 ehca_err(ib_dev, "hipz_qp_register_rpage() "
334 "h_ret=%li", h_ret); 334 "h_ret=%lli", h_ret);
335 ret = ehca2ib_return_code(h_ret); 335 ret = ehca2ib_return_code(h_ret);
336 goto init_qp_queue1; 336 goto init_qp_queue1;
337 } 337 }
@@ -345,7 +345,7 @@ static inline int init_qp_queue(struct ehca_shca *shca,
345 } else { 345 } else {
346 if (h_ret != H_PAGE_REGISTERED) { 346 if (h_ret != H_PAGE_REGISTERED) {
347 ehca_err(ib_dev, "hipz_qp_register_rpage() " 347 ehca_err(ib_dev, "hipz_qp_register_rpage() "
348 "h_ret=%li", h_ret); 348 "h_ret=%lli", h_ret);
349 ret = ehca2ib_return_code(h_ret); 349 ret = ehca2ib_return_code(h_ret);
350 goto init_qp_queue1; 350 goto init_qp_queue1;
351 } 351 }
@@ -709,7 +709,7 @@ static struct ehca_qp *internal_create_qp(
709 709
710 h_ret = hipz_h_alloc_resource_qp(shca->ipz_hca_handle, &parms); 710 h_ret = hipz_h_alloc_resource_qp(shca->ipz_hca_handle, &parms);
711 if (h_ret != H_SUCCESS) { 711 if (h_ret != H_SUCCESS) {
712 ehca_err(pd->device, "h_alloc_resource_qp() failed h_ret=%li", 712 ehca_err(pd->device, "h_alloc_resource_qp() failed h_ret=%lli",
713 h_ret); 713 h_ret);
714 ret = ehca2ib_return_code(h_ret); 714 ret = ehca2ib_return_code(h_ret);
715 goto create_qp_exit1; 715 goto create_qp_exit1;
@@ -1010,7 +1010,7 @@ struct ib_srq *ehca_create_srq(struct ib_pd *pd,
1010 mqpcb, my_qp->galpas.kernel); 1010 mqpcb, my_qp->galpas.kernel);
1011 if (hret != H_SUCCESS) { 1011 if (hret != H_SUCCESS) {
1012 ehca_err(pd->device, "Could not modify SRQ to INIT " 1012 ehca_err(pd->device, "Could not modify SRQ to INIT "
1013 "ehca_qp=%p qp_num=%x h_ret=%li", 1013 "ehca_qp=%p qp_num=%x h_ret=%lli",
1014 my_qp, my_qp->real_qp_num, hret); 1014 my_qp, my_qp->real_qp_num, hret);
1015 goto create_srq2; 1015 goto create_srq2;
1016 } 1016 }
@@ -1024,7 +1024,7 @@ struct ib_srq *ehca_create_srq(struct ib_pd *pd,
1024 mqpcb, my_qp->galpas.kernel); 1024 mqpcb, my_qp->galpas.kernel);
1025 if (hret != H_SUCCESS) { 1025 if (hret != H_SUCCESS) {
1026 ehca_err(pd->device, "Could not enable SRQ " 1026 ehca_err(pd->device, "Could not enable SRQ "
1027 "ehca_qp=%p qp_num=%x h_ret=%li", 1027 "ehca_qp=%p qp_num=%x h_ret=%lli",
1028 my_qp, my_qp->real_qp_num, hret); 1028 my_qp, my_qp->real_qp_num, hret);
1029 goto create_srq2; 1029 goto create_srq2;
1030 } 1030 }
@@ -1038,7 +1038,7 @@ struct ib_srq *ehca_create_srq(struct ib_pd *pd,
1038 mqpcb, my_qp->galpas.kernel); 1038 mqpcb, my_qp->galpas.kernel);
1039 if (hret != H_SUCCESS) { 1039 if (hret != H_SUCCESS) {
1040 ehca_err(pd->device, "Could not modify SRQ to RTR " 1040 ehca_err(pd->device, "Could not modify SRQ to RTR "
1041 "ehca_qp=%p qp_num=%x h_ret=%li", 1041 "ehca_qp=%p qp_num=%x h_ret=%lli",
1042 my_qp, my_qp->real_qp_num, hret); 1042 my_qp, my_qp->real_qp_num, hret);
1043 goto create_srq2; 1043 goto create_srq2;
1044 } 1044 }
@@ -1078,7 +1078,7 @@ static int prepare_sqe_rts(struct ehca_qp *my_qp, struct ehca_shca *shca,
1078 &bad_send_wqe_p, NULL, 2); 1078 &bad_send_wqe_p, NULL, 2);
1079 if (h_ret != H_SUCCESS) { 1079 if (h_ret != H_SUCCESS) {
1080 ehca_err(&shca->ib_device, "hipz_h_disable_and_get_wqe() failed" 1080 ehca_err(&shca->ib_device, "hipz_h_disable_and_get_wqe() failed"
1081 " ehca_qp=%p qp_num=%x h_ret=%li", 1081 " ehca_qp=%p qp_num=%x h_ret=%lli",
1082 my_qp, qp_num, h_ret); 1082 my_qp, qp_num, h_ret);
1083 return ehca2ib_return_code(h_ret); 1083 return ehca2ib_return_code(h_ret);
1084 } 1084 }
@@ -1134,7 +1134,7 @@ static int calc_left_cqes(u64 wqe_p, struct ipz_queue *ipz_queue,
1134 1134
1135 if (ipz_queue_abs_to_offset(ipz_queue, wqe_p, &q_ofs)) { 1135 if (ipz_queue_abs_to_offset(ipz_queue, wqe_p, &q_ofs)) {
1136 ehca_gen_err("Invalid offset for calculating left cqes " 1136 ehca_gen_err("Invalid offset for calculating left cqes "
1137 "wqe_p=%#lx wqe_v=%p\n", wqe_p, wqe_v); 1137 "wqe_p=%#llx wqe_v=%p\n", wqe_p, wqe_v);
1138 return -EFAULT; 1138 return -EFAULT;
1139 } 1139 }
1140 1140
@@ -1168,7 +1168,7 @@ static int check_for_left_cqes(struct ehca_qp *my_qp, struct ehca_shca *shca)
1168 &send_wqe_p, &recv_wqe_p, 4); 1168 &send_wqe_p, &recv_wqe_p, 4);
1169 if (h_ret != H_SUCCESS) { 1169 if (h_ret != H_SUCCESS) {
1170 ehca_err(&shca->ib_device, "disable_and_get_wqe() " 1170 ehca_err(&shca->ib_device, "disable_and_get_wqe() "
1171 "failed ehca_qp=%p qp_num=%x h_ret=%li", 1171 "failed ehca_qp=%p qp_num=%x h_ret=%lli",
1172 my_qp, qp_num, h_ret); 1172 my_qp, qp_num, h_ret);
1173 return ehca2ib_return_code(h_ret); 1173 return ehca2ib_return_code(h_ret);
1174 } 1174 }
@@ -1261,7 +1261,7 @@ static int internal_modify_qp(struct ib_qp *ibqp,
1261 mqpcb, my_qp->galpas.kernel); 1261 mqpcb, my_qp->galpas.kernel);
1262 if (h_ret != H_SUCCESS) { 1262 if (h_ret != H_SUCCESS) {
1263 ehca_err(ibqp->device, "hipz_h_query_qp() failed " 1263 ehca_err(ibqp->device, "hipz_h_query_qp() failed "
1264 "ehca_qp=%p qp_num=%x h_ret=%li", 1264 "ehca_qp=%p qp_num=%x h_ret=%lli",
1265 my_qp, ibqp->qp_num, h_ret); 1265 my_qp, ibqp->qp_num, h_ret);
1266 ret = ehca2ib_return_code(h_ret); 1266 ret = ehca2ib_return_code(h_ret);
1267 goto modify_qp_exit1; 1267 goto modify_qp_exit1;
@@ -1690,7 +1690,7 @@ static int internal_modify_qp(struct ib_qp *ibqp,
1690 1690
1691 if (h_ret != H_SUCCESS) { 1691 if (h_ret != H_SUCCESS) {
1692 ret = ehca2ib_return_code(h_ret); 1692 ret = ehca2ib_return_code(h_ret);
1693 ehca_err(ibqp->device, "hipz_h_modify_qp() failed h_ret=%li " 1693 ehca_err(ibqp->device, "hipz_h_modify_qp() failed h_ret=%lli "
1694 "ehca_qp=%p qp_num=%x", h_ret, my_qp, ibqp->qp_num); 1694 "ehca_qp=%p qp_num=%x", h_ret, my_qp, ibqp->qp_num);
1695 goto modify_qp_exit2; 1695 goto modify_qp_exit2;
1696 } 1696 }
@@ -1723,7 +1723,7 @@ static int internal_modify_qp(struct ib_qp *ibqp,
1723 ret = ehca2ib_return_code(h_ret); 1723 ret = ehca2ib_return_code(h_ret);
1724 ehca_err(ibqp->device, "ENABLE in context of " 1724 ehca_err(ibqp->device, "ENABLE in context of "
1725 "RESET_2_INIT failed! Maybe you didn't get " 1725 "RESET_2_INIT failed! Maybe you didn't get "
1726 "a LID h_ret=%li ehca_qp=%p qp_num=%x", 1726 "a LID h_ret=%lli ehca_qp=%p qp_num=%x",
1727 h_ret, my_qp, ibqp->qp_num); 1727 h_ret, my_qp, ibqp->qp_num);
1728 goto modify_qp_exit2; 1728 goto modify_qp_exit2;
1729 } 1729 }
@@ -1909,7 +1909,7 @@ int ehca_query_qp(struct ib_qp *qp,
1909 if (h_ret != H_SUCCESS) { 1909 if (h_ret != H_SUCCESS) {
1910 ret = ehca2ib_return_code(h_ret); 1910 ret = ehca2ib_return_code(h_ret);
1911 ehca_err(qp->device, "hipz_h_query_qp() failed " 1911 ehca_err(qp->device, "hipz_h_query_qp() failed "
1912 "ehca_qp=%p qp_num=%x h_ret=%li", 1912 "ehca_qp=%p qp_num=%x h_ret=%lli",
1913 my_qp, qp->qp_num, h_ret); 1913 my_qp, qp->qp_num, h_ret);
1914 goto query_qp_exit1; 1914 goto query_qp_exit1;
1915 } 1915 }
@@ -2074,7 +2074,7 @@ int ehca_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr,
2074 2074
2075 if (h_ret != H_SUCCESS) { 2075 if (h_ret != H_SUCCESS) {
2076 ret = ehca2ib_return_code(h_ret); 2076 ret = ehca2ib_return_code(h_ret);
2077 ehca_err(ibsrq->device, "hipz_h_modify_qp() failed h_ret=%li " 2077 ehca_err(ibsrq->device, "hipz_h_modify_qp() failed h_ret=%lli "
2078 "ehca_qp=%p qp_num=%x", 2078 "ehca_qp=%p qp_num=%x",
2079 h_ret, my_qp, my_qp->real_qp_num); 2079 h_ret, my_qp, my_qp->real_qp_num);
2080 } 2080 }
@@ -2108,7 +2108,7 @@ int ehca_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr)
2108 if (h_ret != H_SUCCESS) { 2108 if (h_ret != H_SUCCESS) {
2109 ret = ehca2ib_return_code(h_ret); 2109 ret = ehca2ib_return_code(h_ret);
2110 ehca_err(srq->device, "hipz_h_query_qp() failed " 2110 ehca_err(srq->device, "hipz_h_query_qp() failed "
2111 "ehca_qp=%p qp_num=%x h_ret=%li", 2111 "ehca_qp=%p qp_num=%x h_ret=%lli",
2112 my_qp, my_qp->real_qp_num, h_ret); 2112 my_qp, my_qp->real_qp_num, h_ret);
2113 goto query_srq_exit1; 2113 goto query_srq_exit1;
2114 } 2114 }
@@ -2179,7 +2179,7 @@ static int internal_destroy_qp(struct ib_device *dev, struct ehca_qp *my_qp,
2179 2179
2180 h_ret = hipz_h_destroy_qp(shca->ipz_hca_handle, my_qp); 2180 h_ret = hipz_h_destroy_qp(shca->ipz_hca_handle, my_qp);
2181 if (h_ret != H_SUCCESS) { 2181 if (h_ret != H_SUCCESS) {
2182 ehca_err(dev, "hipz_h_destroy_qp() failed h_ret=%li " 2182 ehca_err(dev, "hipz_h_destroy_qp() failed h_ret=%lli "
2183 "ehca_qp=%p qp_num=%x", h_ret, my_qp, qp_num); 2183 "ehca_qp=%p qp_num=%x", h_ret, my_qp, qp_num);
2184 return ehca2ib_return_code(h_ret); 2184 return ehca2ib_return_code(h_ret);
2185 } 2185 }
diff --git a/drivers/infiniband/hw/ehca/ehca_reqs.c b/drivers/infiniband/hw/ehca/ehca_reqs.c
index c7112686782f..5a3d96f84c79 100644
--- a/drivers/infiniband/hw/ehca/ehca_reqs.c
+++ b/drivers/infiniband/hw/ehca/ehca_reqs.c
@@ -822,7 +822,7 @@ static int generate_flush_cqes(struct ehca_qp *my_qp, struct ib_cq *cq,
822 offset = qmap->next_wqe_idx * ipz_queue->qe_size; 822 offset = qmap->next_wqe_idx * ipz_queue->qe_size;
823 wqe = (struct ehca_wqe *)ipz_qeit_calc(ipz_queue, offset); 823 wqe = (struct ehca_wqe *)ipz_qeit_calc(ipz_queue, offset);
824 if (!wqe) { 824 if (!wqe) {
825 ehca_err(cq->device, "Invalid wqe offset=%#lx on " 825 ehca_err(cq->device, "Invalid wqe offset=%#llx on "
826 "qp_num=%#x", offset, my_qp->real_qp_num); 826 "qp_num=%#x", offset, my_qp->real_qp_num);
827 return nr; 827 return nr;
828 } 828 }
diff --git a/drivers/infiniband/hw/ehca/ehca_sqp.c b/drivers/infiniband/hw/ehca/ehca_sqp.c
index 706d97ad5555..44447aaa5501 100644
--- a/drivers/infiniband/hw/ehca/ehca_sqp.c
+++ b/drivers/infiniband/hw/ehca/ehca_sqp.c
@@ -85,7 +85,7 @@ u64 ehca_define_sqp(struct ehca_shca *shca,
85 85
86 if (ret != H_SUCCESS) { 86 if (ret != H_SUCCESS) {
87 ehca_err(&shca->ib_device, 87 ehca_err(&shca->ib_device,
88 "Can't define AQP1 for port %x. h_ret=%li", 88 "Can't define AQP1 for port %x. h_ret=%lli",
89 port, ret); 89 port, ret);
90 return ret; 90 return ret;
91 } 91 }
diff --git a/drivers/infiniband/hw/ehca/ehca_tools.h b/drivers/infiniband/hw/ehca/ehca_tools.h
index 21f7d06f14ad..f09914cccf53 100644
--- a/drivers/infiniband/hw/ehca/ehca_tools.h
+++ b/drivers/infiniband/hw/ehca/ehca_tools.h
@@ -116,7 +116,7 @@ extern int ehca_debug_level;
116 unsigned char *deb = (unsigned char *)(adr); \ 116 unsigned char *deb = (unsigned char *)(adr); \
117 for (x = 0; x < l; x += 16) { \ 117 for (x = 0; x < l; x += 16) { \
118 printk(KERN_INFO "EHCA_DMP:%s " format \ 118 printk(KERN_INFO "EHCA_DMP:%s " format \
119 " adr=%p ofs=%04x %016lx %016lx\n", \ 119 " adr=%p ofs=%04x %016llx %016llx\n", \
120 __func__, ##args, deb, x, \ 120 __func__, ##args, deb, x, \
121 *((u64 *)&deb[0]), *((u64 *)&deb[8])); \ 121 *((u64 *)&deb[0]), *((u64 *)&deb[8])); \
122 deb += 16; \ 122 deb += 16; \
diff --git a/drivers/infiniband/hw/ehca/ehca_uverbs.c b/drivers/infiniband/hw/ehca/ehca_uverbs.c
index e43ed8f8a0c8..3cb688d29131 100644
--- a/drivers/infiniband/hw/ehca/ehca_uverbs.c
+++ b/drivers/infiniband/hw/ehca/ehca_uverbs.c
@@ -114,7 +114,7 @@ static int ehca_mmap_fw(struct vm_area_struct *vma, struct h_galpas *galpas,
114 114
115 physical = galpas->user.fw_handle; 115 physical = galpas->user.fw_handle;
116 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 116 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
117 ehca_gen_dbg("vsize=%lx physical=%lx", vsize, physical); 117 ehca_gen_dbg("vsize=%llx physical=%llx", vsize, physical);
118 /* VM_IO | VM_RESERVED are set by remap_pfn_range() */ 118 /* VM_IO | VM_RESERVED are set by remap_pfn_range() */
119 ret = remap_4k_pfn(vma, vma->vm_start, physical >> EHCA_PAGESHIFT, 119 ret = remap_4k_pfn(vma, vma->vm_start, physical >> EHCA_PAGESHIFT,
120 vma->vm_page_prot); 120 vma->vm_page_prot);
diff --git a/drivers/infiniband/hw/ehca/hcp_if.c b/drivers/infiniband/hw/ehca/hcp_if.c
index 415d3a465de6..d0ab0c0d5e91 100644
--- a/drivers/infiniband/hw/ehca/hcp_if.c
+++ b/drivers/infiniband/hw/ehca/hcp_if.c
@@ -226,7 +226,7 @@ u64 hipz_h_alloc_resource_eq(const struct ipz_adapter_handle adapter_handle,
226 u32 *eq_ist) 226 u32 *eq_ist)
227{ 227{
228 u64 ret; 228 u64 ret;
229 u64 outs[PLPAR_HCALL9_BUFSIZE]; 229 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
230 u64 allocate_controls; 230 u64 allocate_controls;
231 231
232 /* resource type */ 232 /* resource type */
@@ -249,7 +249,7 @@ u64 hipz_h_alloc_resource_eq(const struct ipz_adapter_handle adapter_handle,
249 *eq_ist = (u32)outs[5]; 249 *eq_ist = (u32)outs[5];
250 250
251 if (ret == H_NOT_ENOUGH_RESOURCES) 251 if (ret == H_NOT_ENOUGH_RESOURCES)
252 ehca_gen_err("Not enough resource - ret=%li ", ret); 252 ehca_gen_err("Not enough resource - ret=%lli ", ret);
253 253
254 return ret; 254 return ret;
255} 255}
@@ -270,7 +270,7 @@ u64 hipz_h_alloc_resource_cq(const struct ipz_adapter_handle adapter_handle,
270 struct ehca_alloc_cq_parms *param) 270 struct ehca_alloc_cq_parms *param)
271{ 271{
272 u64 ret; 272 u64 ret;
273 u64 outs[PLPAR_HCALL9_BUFSIZE]; 273 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
274 274
275 ret = ehca_plpar_hcall9(H_ALLOC_RESOURCE, outs, 275 ret = ehca_plpar_hcall9(H_ALLOC_RESOURCE, outs,
276 adapter_handle.handle, /* r4 */ 276 adapter_handle.handle, /* r4 */
@@ -287,7 +287,7 @@ u64 hipz_h_alloc_resource_cq(const struct ipz_adapter_handle adapter_handle,
287 hcp_galpas_ctor(&cq->galpas, outs[5], outs[6]); 287 hcp_galpas_ctor(&cq->galpas, outs[5], outs[6]);
288 288
289 if (ret == H_NOT_ENOUGH_RESOURCES) 289 if (ret == H_NOT_ENOUGH_RESOURCES)
290 ehca_gen_err("Not enough resources. ret=%li", ret); 290 ehca_gen_err("Not enough resources. ret=%lli", ret);
291 291
292 return ret; 292 return ret;
293} 293}
@@ -297,7 +297,7 @@ u64 hipz_h_alloc_resource_qp(const struct ipz_adapter_handle adapter_handle,
297{ 297{
298 u64 ret; 298 u64 ret;
299 u64 allocate_controls, max_r10_reg, r11, r12; 299 u64 allocate_controls, max_r10_reg, r11, r12;
300 u64 outs[PLPAR_HCALL9_BUFSIZE]; 300 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
301 301
302 allocate_controls = 302 allocate_controls =
303 EHCA_BMASK_SET(H_ALL_RES_QP_ENHANCED_OPS, parms->ext_type) 303 EHCA_BMASK_SET(H_ALL_RES_QP_ENHANCED_OPS, parms->ext_type)
@@ -362,7 +362,7 @@ u64 hipz_h_alloc_resource_qp(const struct ipz_adapter_handle adapter_handle,
362 hcp_galpas_ctor(&parms->galpas, outs[6], outs[6]); 362 hcp_galpas_ctor(&parms->galpas, outs[6], outs[6]);
363 363
364 if (ret == H_NOT_ENOUGH_RESOURCES) 364 if (ret == H_NOT_ENOUGH_RESOURCES)
365 ehca_gen_err("Not enough resources. ret=%li", ret); 365 ehca_gen_err("Not enough resources. ret=%lli", ret);
366 366
367 return ret; 367 return ret;
368} 368}
@@ -454,7 +454,7 @@ u64 hipz_h_register_rpage_eq(const struct ipz_adapter_handle adapter_handle,
454 const u64 count) 454 const u64 count)
455{ 455{
456 if (count != 1) { 456 if (count != 1) {
457 ehca_gen_err("Ppage counter=%lx", count); 457 ehca_gen_err("Ppage counter=%llx", count);
458 return H_PARAMETER; 458 return H_PARAMETER;
459 } 459 }
460 return hipz_h_register_rpage(adapter_handle, 460 return hipz_h_register_rpage(adapter_handle,
@@ -489,7 +489,7 @@ u64 hipz_h_register_rpage_cq(const struct ipz_adapter_handle adapter_handle,
489 const struct h_galpa gal) 489 const struct h_galpa gal)
490{ 490{
491 if (count != 1) { 491 if (count != 1) {
492 ehca_gen_err("Page counter=%lx", count); 492 ehca_gen_err("Page counter=%llx", count);
493 return H_PARAMETER; 493 return H_PARAMETER;
494 } 494 }
495 495
@@ -508,7 +508,7 @@ u64 hipz_h_register_rpage_qp(const struct ipz_adapter_handle adapter_handle,
508 const struct h_galpa galpa) 508 const struct h_galpa galpa)
509{ 509{
510 if (count > 1) { 510 if (count > 1) {
511 ehca_gen_err("Page counter=%lx", count); 511 ehca_gen_err("Page counter=%llx", count);
512 return H_PARAMETER; 512 return H_PARAMETER;
513 } 513 }
514 514
@@ -525,7 +525,7 @@ u64 hipz_h_disable_and_get_wqe(const struct ipz_adapter_handle adapter_handle,
525 int dis_and_get_function_code) 525 int dis_and_get_function_code)
526{ 526{
527 u64 ret; 527 u64 ret;
528 u64 outs[PLPAR_HCALL9_BUFSIZE]; 528 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
529 529
530 ret = ehca_plpar_hcall9(H_DISABLE_AND_GETC, outs, 530 ret = ehca_plpar_hcall9(H_DISABLE_AND_GETC, outs,
531 adapter_handle.handle, /* r4 */ 531 adapter_handle.handle, /* r4 */
@@ -548,7 +548,7 @@ u64 hipz_h_modify_qp(const struct ipz_adapter_handle adapter_handle,
548 struct h_galpa gal) 548 struct h_galpa gal)
549{ 549{
550 u64 ret; 550 u64 ret;
551 u64 outs[PLPAR_HCALL9_BUFSIZE]; 551 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
552 ret = ehca_plpar_hcall9(H_MODIFY_QP, outs, 552 ret = ehca_plpar_hcall9(H_MODIFY_QP, outs,
553 adapter_handle.handle, /* r4 */ 553 adapter_handle.handle, /* r4 */
554 qp_handle.handle, /* r5 */ 554 qp_handle.handle, /* r5 */
@@ -557,7 +557,7 @@ u64 hipz_h_modify_qp(const struct ipz_adapter_handle adapter_handle,
557 0, 0, 0, 0, 0); 557 0, 0, 0, 0, 0);
558 558
559 if (ret == H_NOT_ENOUGH_RESOURCES) 559 if (ret == H_NOT_ENOUGH_RESOURCES)
560 ehca_gen_err("Insufficient resources ret=%li", ret); 560 ehca_gen_err("Insufficient resources ret=%lli", ret);
561 561
562 return ret; 562 return ret;
563} 563}
@@ -579,7 +579,7 @@ u64 hipz_h_destroy_qp(const struct ipz_adapter_handle adapter_handle,
579 struct ehca_qp *qp) 579 struct ehca_qp *qp)
580{ 580{
581 u64 ret; 581 u64 ret;
582 u64 outs[PLPAR_HCALL9_BUFSIZE]; 582 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
583 583
584 ret = hcp_galpas_dtor(&qp->galpas); 584 ret = hcp_galpas_dtor(&qp->galpas);
585 if (ret) { 585 if (ret) {
@@ -593,7 +593,7 @@ u64 hipz_h_destroy_qp(const struct ipz_adapter_handle adapter_handle,
593 qp->ipz_qp_handle.handle, /* r6 */ 593 qp->ipz_qp_handle.handle, /* r6 */
594 0, 0, 0, 0, 0, 0); 594 0, 0, 0, 0, 0, 0);
595 if (ret == H_HARDWARE) 595 if (ret == H_HARDWARE)
596 ehca_gen_err("HCA not operational. ret=%li", ret); 596 ehca_gen_err("HCA not operational. ret=%lli", ret);
597 597
598 ret = ehca_plpar_hcall_norets(H_FREE_RESOURCE, 598 ret = ehca_plpar_hcall_norets(H_FREE_RESOURCE,
599 adapter_handle.handle, /* r4 */ 599 adapter_handle.handle, /* r4 */
@@ -601,7 +601,7 @@ u64 hipz_h_destroy_qp(const struct ipz_adapter_handle adapter_handle,
601 0, 0, 0, 0, 0); 601 0, 0, 0, 0, 0);
602 602
603 if (ret == H_RESOURCE) 603 if (ret == H_RESOURCE)
604 ehca_gen_err("Resource still in use. ret=%li", ret); 604 ehca_gen_err("Resource still in use. ret=%lli", ret);
605 605
606 return ret; 606 return ret;
607} 607}
@@ -625,7 +625,7 @@ u64 hipz_h_define_aqp1(const struct ipz_adapter_handle adapter_handle,
625 u32 * bma_qp_nr) 625 u32 * bma_qp_nr)
626{ 626{
627 u64 ret; 627 u64 ret;
628 u64 outs[PLPAR_HCALL9_BUFSIZE]; 628 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
629 629
630 ret = ehca_plpar_hcall9(H_DEFINE_AQP1, outs, 630 ret = ehca_plpar_hcall9(H_DEFINE_AQP1, outs,
631 adapter_handle.handle, /* r4 */ 631 adapter_handle.handle, /* r4 */
@@ -636,7 +636,7 @@ u64 hipz_h_define_aqp1(const struct ipz_adapter_handle adapter_handle,
636 *bma_qp_nr = (u32)outs[1]; 636 *bma_qp_nr = (u32)outs[1];
637 637
638 if (ret == H_ALIAS_EXIST) 638 if (ret == H_ALIAS_EXIST)
639 ehca_gen_err("AQP1 already exists. ret=%li", ret); 639 ehca_gen_err("AQP1 already exists. ret=%lli", ret);
640 640
641 return ret; 641 return ret;
642} 642}
@@ -658,7 +658,7 @@ u64 hipz_h_attach_mcqp(const struct ipz_adapter_handle adapter_handle,
658 0, 0); 658 0, 0);
659 659
660 if (ret == H_NOT_ENOUGH_RESOURCES) 660 if (ret == H_NOT_ENOUGH_RESOURCES)
661 ehca_gen_err("Not enough resources. ret=%li", ret); 661 ehca_gen_err("Not enough resources. ret=%lli", ret);
662 662
663 return ret; 663 return ret;
664} 664}
@@ -697,7 +697,7 @@ u64 hipz_h_destroy_cq(const struct ipz_adapter_handle adapter_handle,
697 0, 0, 0, 0); 697 0, 0, 0, 0);
698 698
699 if (ret == H_RESOURCE) 699 if (ret == H_RESOURCE)
700 ehca_gen_err("H_FREE_RESOURCE failed ret=%li ", ret); 700 ehca_gen_err("H_FREE_RESOURCE failed ret=%lli ", ret);
701 701
702 return ret; 702 return ret;
703} 703}
@@ -719,7 +719,7 @@ u64 hipz_h_destroy_eq(const struct ipz_adapter_handle adapter_handle,
719 0, 0, 0, 0, 0); 719 0, 0, 0, 0, 0);
720 720
721 if (ret == H_RESOURCE) 721 if (ret == H_RESOURCE)
722 ehca_gen_err("Resource in use. ret=%li ", ret); 722 ehca_gen_err("Resource in use. ret=%lli ", ret);
723 723
724 return ret; 724 return ret;
725} 725}
@@ -733,7 +733,7 @@ u64 hipz_h_alloc_resource_mr(const struct ipz_adapter_handle adapter_handle,
733 struct ehca_mr_hipzout_parms *outparms) 733 struct ehca_mr_hipzout_parms *outparms)
734{ 734{
735 u64 ret; 735 u64 ret;
736 u64 outs[PLPAR_HCALL9_BUFSIZE]; 736 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
737 737
738 ret = ehca_plpar_hcall9(H_ALLOC_RESOURCE, outs, 738 ret = ehca_plpar_hcall9(H_ALLOC_RESOURCE, outs,
739 adapter_handle.handle, /* r4 */ 739 adapter_handle.handle, /* r4 */
@@ -774,9 +774,9 @@ u64 hipz_h_register_rpage_mr(const struct ipz_adapter_handle adapter_handle,
774 774
775 if ((count > 1) && (logical_address_of_page & (EHCA_PAGESIZE-1))) { 775 if ((count > 1) && (logical_address_of_page & (EHCA_PAGESIZE-1))) {
776 ehca_gen_err("logical_address_of_page not on a 4k boundary " 776 ehca_gen_err("logical_address_of_page not on a 4k boundary "
777 "adapter_handle=%lx mr=%p mr_handle=%lx " 777 "adapter_handle=%llx mr=%p mr_handle=%llx "
778 "pagesize=%x queue_type=%x " 778 "pagesize=%x queue_type=%x "
779 "logical_address_of_page=%lx count=%lx", 779 "logical_address_of_page=%llx count=%llx",
780 adapter_handle.handle, mr, 780 adapter_handle.handle, mr,
781 mr->ipz_mr_handle.handle, pagesize, queue_type, 781 mr->ipz_mr_handle.handle, pagesize, queue_type,
782 logical_address_of_page, count); 782 logical_address_of_page, count);
@@ -794,7 +794,7 @@ u64 hipz_h_query_mr(const struct ipz_adapter_handle adapter_handle,
794 struct ehca_mr_hipzout_parms *outparms) 794 struct ehca_mr_hipzout_parms *outparms)
795{ 795{
796 u64 ret; 796 u64 ret;
797 u64 outs[PLPAR_HCALL9_BUFSIZE]; 797 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
798 798
799 ret = ehca_plpar_hcall9(H_QUERY_MR, outs, 799 ret = ehca_plpar_hcall9(H_QUERY_MR, outs,
800 adapter_handle.handle, /* r4 */ 800 adapter_handle.handle, /* r4 */
@@ -828,7 +828,7 @@ u64 hipz_h_reregister_pmr(const struct ipz_adapter_handle adapter_handle,
828 struct ehca_mr_hipzout_parms *outparms) 828 struct ehca_mr_hipzout_parms *outparms)
829{ 829{
830 u64 ret; 830 u64 ret;
831 u64 outs[PLPAR_HCALL9_BUFSIZE]; 831 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
832 832
833 ret = ehca_plpar_hcall9(H_REREGISTER_PMR, outs, 833 ret = ehca_plpar_hcall9(H_REREGISTER_PMR, outs,
834 adapter_handle.handle, /* r4 */ 834 adapter_handle.handle, /* r4 */
@@ -855,7 +855,7 @@ u64 hipz_h_register_smr(const struct ipz_adapter_handle adapter_handle,
855 struct ehca_mr_hipzout_parms *outparms) 855 struct ehca_mr_hipzout_parms *outparms)
856{ 856{
857 u64 ret; 857 u64 ret;
858 u64 outs[PLPAR_HCALL9_BUFSIZE]; 858 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
859 859
860 ret = ehca_plpar_hcall9(H_REGISTER_SMR, outs, 860 ret = ehca_plpar_hcall9(H_REGISTER_SMR, outs,
861 adapter_handle.handle, /* r4 */ 861 adapter_handle.handle, /* r4 */
@@ -877,7 +877,7 @@ u64 hipz_h_alloc_resource_mw(const struct ipz_adapter_handle adapter_handle,
877 struct ehca_mw_hipzout_parms *outparms) 877 struct ehca_mw_hipzout_parms *outparms)
878{ 878{
879 u64 ret; 879 u64 ret;
880 u64 outs[PLPAR_HCALL9_BUFSIZE]; 880 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
881 881
882 ret = ehca_plpar_hcall9(H_ALLOC_RESOURCE, outs, 882 ret = ehca_plpar_hcall9(H_ALLOC_RESOURCE, outs,
883 adapter_handle.handle, /* r4 */ 883 adapter_handle.handle, /* r4 */
@@ -895,7 +895,7 @@ u64 hipz_h_query_mw(const struct ipz_adapter_handle adapter_handle,
895 struct ehca_mw_hipzout_parms *outparms) 895 struct ehca_mw_hipzout_parms *outparms)
896{ 896{
897 u64 ret; 897 u64 ret;
898 u64 outs[PLPAR_HCALL9_BUFSIZE]; 898 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
899 899
900 ret = ehca_plpar_hcall9(H_QUERY_MW, outs, 900 ret = ehca_plpar_hcall9(H_QUERY_MW, outs,
901 adapter_handle.handle, /* r4 */ 901 adapter_handle.handle, /* r4 */
diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
index a3c5af1d7ec0..de5263beab4a 100644
--- a/drivers/infiniband/hw/mlx4/cq.c
+++ b/drivers/infiniband/hw/mlx4/cq.c
@@ -367,7 +367,7 @@ int mlx4_ib_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
367 if (err) 367 if (err)
368 goto out; 368 goto out;
369 } else { 369 } else {
370 /* Can't be smaller then the number of outstanding CQEs */ 370 /* Can't be smaller than the number of outstanding CQEs */
371 outst_cqe = mlx4_ib_get_outstanding_cqes(cq); 371 outst_cqe = mlx4_ib_get_outstanding_cqes(cq);
372 if (entries < outst_cqe + 1) { 372 if (entries < outst_cqe + 1) {
373 err = 0; 373 err = 0;
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index dcefe1fceb5c..61588bd273bd 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -543,14 +543,21 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
543{ 543{
544 static int mlx4_ib_version_printed; 544 static int mlx4_ib_version_printed;
545 struct mlx4_ib_dev *ibdev; 545 struct mlx4_ib_dev *ibdev;
546 int num_ports = 0;
546 int i; 547 int i;
547 548
548
549 if (!mlx4_ib_version_printed) { 549 if (!mlx4_ib_version_printed) {
550 printk(KERN_INFO "%s", mlx4_ib_version); 550 printk(KERN_INFO "%s", mlx4_ib_version);
551 ++mlx4_ib_version_printed; 551 ++mlx4_ib_version_printed;
552 } 552 }
553 553
554 mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB)
555 num_ports++;
556
557 /* No point in registering a device with no ports... */
558 if (num_ports == 0)
559 return NULL;
560
554 ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof *ibdev); 561 ibdev = (struct mlx4_ib_dev *) ib_alloc_device(sizeof *ibdev);
555 if (!ibdev) { 562 if (!ibdev) {
556 dev_err(&dev->pdev->dev, "Device struct alloc failed\n"); 563 dev_err(&dev->pdev->dev, "Device struct alloc failed\n");
@@ -574,9 +581,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
574 ibdev->ib_dev.owner = THIS_MODULE; 581 ibdev->ib_dev.owner = THIS_MODULE;
575 ibdev->ib_dev.node_type = RDMA_NODE_IB_CA; 582 ibdev->ib_dev.node_type = RDMA_NODE_IB_CA;
576 ibdev->ib_dev.local_dma_lkey = dev->caps.reserved_lkey; 583 ibdev->ib_dev.local_dma_lkey = dev->caps.reserved_lkey;
577 ibdev->num_ports = 0; 584 ibdev->num_ports = num_ports;
578 mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB)
579 ibdev->num_ports++;
580 ibdev->ib_dev.phys_port_cnt = ibdev->num_ports; 585 ibdev->ib_dev.phys_port_cnt = ibdev->num_ports;
581 ibdev->ib_dev.num_comp_vectors = dev->caps.num_comp_vectors; 586 ibdev->ib_dev.num_comp_vectors = dev->caps.num_comp_vectors;
582 ibdev->ib_dev.dma_device = &dev->pdev->dev; 587 ibdev->ib_dev.dma_device = &dev->pdev->dev;
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index 39167a797f99..a91cb4c3fa5c 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -1462,7 +1462,8 @@ static void __set_data_seg(struct mlx4_wqe_data_seg *dseg, struct ib_sge *sg)
1462} 1462}
1463 1463
1464static int build_lso_seg(struct mlx4_wqe_lso_seg *wqe, struct ib_send_wr *wr, 1464static int build_lso_seg(struct mlx4_wqe_lso_seg *wqe, struct ib_send_wr *wr,
1465 struct mlx4_ib_qp *qp, unsigned *lso_seg_len) 1465 struct mlx4_ib_qp *qp, unsigned *lso_seg_len,
1466 __be32 *lso_hdr_sz)
1466{ 1467{
1467 unsigned halign = ALIGN(sizeof *wqe + wr->wr.ud.hlen, 16); 1468 unsigned halign = ALIGN(sizeof *wqe + wr->wr.ud.hlen, 16);
1468 1469
@@ -1479,12 +1480,8 @@ static int build_lso_seg(struct mlx4_wqe_lso_seg *wqe, struct ib_send_wr *wr,
1479 1480
1480 memcpy(wqe->header, wr->wr.ud.header, wr->wr.ud.hlen); 1481 memcpy(wqe->header, wr->wr.ud.header, wr->wr.ud.hlen);
1481 1482
1482 /* make sure LSO header is written before overwriting stamping */ 1483 *lso_hdr_sz = cpu_to_be32((wr->wr.ud.mss - wr->wr.ud.hlen) << 16 |
1483 wmb(); 1484 wr->wr.ud.hlen);
1484
1485 wqe->mss_hdr_size = cpu_to_be32((wr->wr.ud.mss - wr->wr.ud.hlen) << 16 |
1486 wr->wr.ud.hlen);
1487
1488 *lso_seg_len = halign; 1485 *lso_seg_len = halign;
1489 return 0; 1486 return 0;
1490} 1487}
@@ -1518,6 +1515,9 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
1518 int uninitialized_var(stamp); 1515 int uninitialized_var(stamp);
1519 int uninitialized_var(size); 1516 int uninitialized_var(size);
1520 unsigned uninitialized_var(seglen); 1517 unsigned uninitialized_var(seglen);
1518 __be32 dummy;
1519 __be32 *lso_wqe;
1520 __be32 uninitialized_var(lso_hdr_sz);
1521 int i; 1521 int i;
1522 1522
1523 spin_lock_irqsave(&qp->sq.lock, flags); 1523 spin_lock_irqsave(&qp->sq.lock, flags);
@@ -1525,6 +1525,8 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
1525 ind = qp->sq_next_wqe; 1525 ind = qp->sq_next_wqe;
1526 1526
1527 for (nreq = 0; wr; ++nreq, wr = wr->next) { 1527 for (nreq = 0; wr; ++nreq, wr = wr->next) {
1528 lso_wqe = &dummy;
1529
1528 if (mlx4_wq_overflow(&qp->sq, nreq, qp->ibqp.send_cq)) { 1530 if (mlx4_wq_overflow(&qp->sq, nreq, qp->ibqp.send_cq)) {
1529 err = -ENOMEM; 1531 err = -ENOMEM;
1530 *bad_wr = wr; 1532 *bad_wr = wr;
@@ -1606,11 +1608,12 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
1606 size += sizeof (struct mlx4_wqe_datagram_seg) / 16; 1608 size += sizeof (struct mlx4_wqe_datagram_seg) / 16;
1607 1609
1608 if (wr->opcode == IB_WR_LSO) { 1610 if (wr->opcode == IB_WR_LSO) {
1609 err = build_lso_seg(wqe, wr, qp, &seglen); 1611 err = build_lso_seg(wqe, wr, qp, &seglen, &lso_hdr_sz);
1610 if (unlikely(err)) { 1612 if (unlikely(err)) {
1611 *bad_wr = wr; 1613 *bad_wr = wr;
1612 goto out; 1614 goto out;
1613 } 1615 }
1616 lso_wqe = (__be32 *) wqe;
1614 wqe += seglen; 1617 wqe += seglen;
1615 size += seglen / 16; 1618 size += seglen / 16;
1616 } 1619 }
@@ -1652,6 +1655,14 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
1652 for (i = wr->num_sge - 1; i >= 0; --i, --dseg) 1655 for (i = wr->num_sge - 1; i >= 0; --i, --dseg)
1653 set_data_seg(dseg, wr->sg_list + i); 1656 set_data_seg(dseg, wr->sg_list + i);
1654 1657
1658 /*
1659 * Possibly overwrite stamping in cacheline with LSO
1660 * segment only after making sure all data segments
1661 * are written.
1662 */
1663 wmb();
1664 *lso_wqe = lso_hdr_sz;
1665
1655 ctrl->fence_size = (wr->send_flags & IB_SEND_FENCE ? 1666 ctrl->fence_size = (wr->send_flags & IB_SEND_FENCE ?
1656 MLX4_WQE_CTRL_FENCE : 0) | size; 1667 MLX4_WQE_CTRL_FENCE : 0) | size;
1657 1668
@@ -1686,7 +1697,6 @@ int mlx4_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
1686 stamp_send_wqe(qp, stamp, size * 16); 1697 stamp_send_wqe(qp, stamp, size * 16);
1687 ind = pad_wraparound(qp, ind); 1698 ind = pad_wraparound(qp, ind);
1688 } 1699 }
1689
1690 } 1700 }
1691 1701
1692out: 1702out:
diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
index a812db243477..a01b4488208b 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -778,12 +778,13 @@ static struct nes_cm_node *find_node(struct nes_cm_core *cm_core,
778 unsigned long flags; 778 unsigned long flags;
779 struct list_head *hte; 779 struct list_head *hte;
780 struct nes_cm_node *cm_node; 780 struct nes_cm_node *cm_node;
781 __be32 tmp_addr = cpu_to_be32(loc_addr);
781 782
782 /* get a handle on the hte */ 783 /* get a handle on the hte */
783 hte = &cm_core->connected_nodes; 784 hte = &cm_core->connected_nodes;
784 785
785 nes_debug(NES_DBG_CM, "Searching for an owner node: %pI4:%x from core %p->%p\n", 786 nes_debug(NES_DBG_CM, "Searching for an owner node: %pI4:%x from core %p->%p\n",
786 &loc_addr, loc_port, cm_core, hte); 787 &tmp_addr, loc_port, cm_core, hte);
787 788
788 /* walk list and find cm_node associated with this session ID */ 789 /* walk list and find cm_node associated with this session ID */
789 spin_lock_irqsave(&cm_core->ht_lock, flags); 790 spin_lock_irqsave(&cm_core->ht_lock, flags);
@@ -816,6 +817,7 @@ static struct nes_cm_listener *find_listener(struct nes_cm_core *cm_core,
816{ 817{
817 unsigned long flags; 818 unsigned long flags;
818 struct nes_cm_listener *listen_node; 819 struct nes_cm_listener *listen_node;
820 __be32 tmp_addr = cpu_to_be32(dst_addr);
819 821
820 /* walk list and find cm_node associated with this session ID */ 822 /* walk list and find cm_node associated with this session ID */
821 spin_lock_irqsave(&cm_core->listen_list_lock, flags); 823 spin_lock_irqsave(&cm_core->listen_list_lock, flags);
@@ -833,7 +835,7 @@ static struct nes_cm_listener *find_listener(struct nes_cm_core *cm_core,
833 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags); 835 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
834 836
835 nes_debug(NES_DBG_CM, "Unable to find listener for %pI4:%x\n", 837 nes_debug(NES_DBG_CM, "Unable to find listener for %pI4:%x\n",
836 &dst_addr, dst_port); 838 &tmp_addr, dst_port);
837 839
838 /* no listener */ 840 /* no listener */
839 return NULL; 841 return NULL;
@@ -2059,6 +2061,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
2059 struct tcphdr *tcph; 2061 struct tcphdr *tcph;
2060 struct nes_cm_info nfo; 2062 struct nes_cm_info nfo;
2061 int skb_handled = 1; 2063 int skb_handled = 1;
2064 __be32 tmp_daddr, tmp_saddr;
2062 2065
2063 if (!skb) 2066 if (!skb)
2064 return 0; 2067 return 0;
@@ -2074,8 +2077,11 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
2074 nfo.rem_addr = ntohl(iph->saddr); 2077 nfo.rem_addr = ntohl(iph->saddr);
2075 nfo.rem_port = ntohs(tcph->source); 2078 nfo.rem_port = ntohs(tcph->source);
2076 2079
2080 tmp_daddr = cpu_to_be32(iph->daddr);
2081 tmp_saddr = cpu_to_be32(iph->saddr);
2082
2077 nes_debug(NES_DBG_CM, "Received packet: dest=%pI4:0x%04X src=%pI4:0x%04X\n", 2083 nes_debug(NES_DBG_CM, "Received packet: dest=%pI4:0x%04X src=%pI4:0x%04X\n",
2078 &iph->daddr, tcph->dest, &iph->saddr, tcph->source); 2084 &tmp_daddr, tcph->dest, &tmp_saddr, tcph->source);
2079 2085
2080 do { 2086 do {
2081 cm_node = find_node(cm_core, 2087 cm_node = find_node(cm_core,
@@ -2705,7 +2711,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
2705 sizeof(struct ietf_mpa_frame)); 2711 sizeof(struct ietf_mpa_frame));
2706 2712
2707 2713
2708 /* notify OF layer that accept event was successfull */ 2714 /* notify OF layer that accept event was successful */
2709 cm_id->add_ref(cm_id); 2715 cm_id->add_ref(cm_id);
2710 2716
2711 cm_event.event = IW_CM_EVENT_ESTABLISHED; 2717 cm_event.event = IW_CM_EVENT_ESTABLISHED;
diff --git a/drivers/infiniband/hw/nes/nes_utils.c b/drivers/infiniband/hw/nes/nes_utils.c
index aa9b7348c728..6f3bc1b6bf22 100644
--- a/drivers/infiniband/hw/nes/nes_utils.c
+++ b/drivers/infiniband/hw/nes/nes_utils.c
@@ -655,6 +655,7 @@ int nes_arp_table(struct nes_device *nesdev, u32 ip_addr, u8 *mac_addr, u32 acti
655 struct nes_adapter *nesadapter = nesdev->nesadapter; 655 struct nes_adapter *nesadapter = nesdev->nesadapter;
656 int arp_index; 656 int arp_index;
657 int err = 0; 657 int err = 0;
658 __be32 tmp_addr;
658 659
659 for (arp_index = 0; (u32) arp_index < nesadapter->arp_table_size; arp_index++) { 660 for (arp_index = 0; (u32) arp_index < nesadapter->arp_table_size; arp_index++) {
660 if (nesadapter->arp_table[arp_index].ip_addr == ip_addr) 661 if (nesadapter->arp_table[arp_index].ip_addr == ip_addr)
@@ -682,8 +683,9 @@ int nes_arp_table(struct nes_device *nesdev, u32 ip_addr, u8 *mac_addr, u32 acti
682 683
683 /* DELETE or RESOLVE */ 684 /* DELETE or RESOLVE */
684 if (arp_index == nesadapter->arp_table_size) { 685 if (arp_index == nesadapter->arp_table_size) {
686 tmp_addr = cpu_to_be32(ip_addr);
685 nes_debug(NES_DBG_NETDEV, "MAC for %pI4 not in ARP table - cannot %s\n", 687 nes_debug(NES_DBG_NETDEV, "MAC for %pI4 not in ARP table - cannot %s\n",
686 &ip_addr, action == NES_ARP_RESOLVE ? "resolve" : "delete"); 688 &tmp_addr, action == NES_ARP_RESOLVE ? "resolve" : "delete");
687 return -1; 689 return -1;
688 } 690 }
689 691
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 19e06bc38b39..0bd2a4ff0842 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -106,23 +106,17 @@ int ipoib_open(struct net_device *dev)
106 106
107 ipoib_dbg(priv, "bringing up interface\n"); 107 ipoib_dbg(priv, "bringing up interface\n");
108 108
109 set_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags); 109 if (!test_and_set_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags))
110 napi_enable(&priv->napi);
110 111
111 if (ipoib_pkey_dev_delay_open(dev)) 112 if (ipoib_pkey_dev_delay_open(dev))
112 return 0; 113 return 0;
113 114
114 napi_enable(&priv->napi); 115 if (ipoib_ib_dev_open(dev))
116 goto err_disable;
115 117
116 if (ipoib_ib_dev_open(dev)) { 118 if (ipoib_ib_dev_up(dev))
117 napi_disable(&priv->napi); 119 goto err_stop;
118 return -EINVAL;
119 }
120
121 if (ipoib_ib_dev_up(dev)) {
122 ipoib_ib_dev_stop(dev, 1);
123 napi_disable(&priv->napi);
124 return -EINVAL;
125 }
126 120
127 if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) { 121 if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) {
128 struct ipoib_dev_priv *cpriv; 122 struct ipoib_dev_priv *cpriv;
@@ -144,6 +138,15 @@ int ipoib_open(struct net_device *dev)
144 netif_start_queue(dev); 138 netif_start_queue(dev);
145 139
146 return 0; 140 return 0;
141
142err_stop:
143 ipoib_ib_dev_stop(dev, 1);
144
145err_disable:
146 napi_disable(&priv->napi);
147 clear_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags);
148
149 return -EINVAL;
147} 150}
148 151
149static int ipoib_stop(struct net_device *dev) 152static int ipoib_stop(struct net_device *dev)
@@ -711,26 +714,26 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
711 714
712 neigh = *to_ipoib_neigh(skb->dst->neighbour); 715 neigh = *to_ipoib_neigh(skb->dst->neighbour);
713 716
714 if (neigh->ah) 717 if (unlikely((memcmp(&neigh->dgid.raw,
715 if (unlikely((memcmp(&neigh->dgid.raw, 718 skb->dst->neighbour->ha + 4,
716 skb->dst->neighbour->ha + 4, 719 sizeof(union ib_gid))) ||
717 sizeof(union ib_gid))) || 720 (neigh->dev != dev))) {
718 (neigh->dev != dev))) { 721 spin_lock_irqsave(&priv->lock, flags);
719 spin_lock_irqsave(&priv->lock, flags); 722 /*
720 /* 723 * It's safe to call ipoib_put_ah() inside
721 * It's safe to call ipoib_put_ah() inside 724 * priv->lock here, because we know that
722 * priv->lock here, because we know that 725 * path->ah will always hold one more reference,
723 * path->ah will always hold one more reference, 726 * so ipoib_put_ah() will never do more than
724 * so ipoib_put_ah() will never do more than 727 * decrement the ref count.
725 * decrement the ref count. 728 */
726 */ 729 if (neigh->ah)
727 ipoib_put_ah(neigh->ah); 730 ipoib_put_ah(neigh->ah);
728 list_del(&neigh->list); 731 list_del(&neigh->list);
729 ipoib_neigh_free(dev, neigh); 732 ipoib_neigh_free(dev, neigh);
730 spin_unlock_irqrestore(&priv->lock, flags); 733 spin_unlock_irqrestore(&priv->lock, flags);
731 ipoib_path_lookup(skb, dev); 734 ipoib_path_lookup(skb, dev);
732 return NETDEV_TX_OK; 735 return NETDEV_TX_OK;
733 } 736 }
734 737
735 if (ipoib_cm_get(neigh)) { 738 if (ipoib_cm_get(neigh)) {
736 if (ipoib_cm_up(neigh)) { 739 if (ipoib_cm_up(neigh)) {
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index a2eb3b9789eb..425e31112ed7 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -409,7 +409,7 @@ static int ipoib_mcast_join_complete(int status,
409 } 409 }
410 410
411 if (mcast->logcount++ < 20) { 411 if (mcast->logcount++ < 20) {
412 if (status == -ETIMEDOUT) { 412 if (status == -ETIMEDOUT || status == -EAGAIN) {
413 ipoib_dbg_mcast(priv, "multicast join failed for %pI6, status %d\n", 413 ipoib_dbg_mcast(priv, "multicast join failed for %pI6, status %d\n",
414 mcast->mcmember.mgid.raw, status); 414 mcast->mcmember.mgid.raw, status);
415 } else { 415 } else {
@@ -529,6 +529,9 @@ void ipoib_mcast_join_task(struct work_struct *work)
529 if (!priv->broadcast) { 529 if (!priv->broadcast) {
530 struct ipoib_mcast *broadcast; 530 struct ipoib_mcast *broadcast;
531 531
532 if (!test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags))
533 return;
534
532 broadcast = ipoib_mcast_alloc(dev, 1); 535 broadcast = ipoib_mcast_alloc(dev, 1);
533 if (!broadcast) { 536 if (!broadcast) {
534 ipoib_warn(priv, "failed to allocate broadcast group\n"); 537 ipoib_warn(priv, "failed to allocate broadcast group\n");
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
index 2cf1a4088718..5a76a5510350 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
@@ -61,6 +61,7 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
61 61
62 ppriv = netdev_priv(pdev); 62 ppriv = netdev_priv(pdev);
63 63
64 rtnl_lock();
64 mutex_lock(&ppriv->vlan_mutex); 65 mutex_lock(&ppriv->vlan_mutex);
65 66
66 /* 67 /*
@@ -111,7 +112,7 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
111 goto device_init_failed; 112 goto device_init_failed;
112 } 113 }
113 114
114 result = register_netdev(priv->dev); 115 result = register_netdevice(priv->dev);
115 if (result) { 116 if (result) {
116 ipoib_warn(priv, "failed to initialize; error %i", result); 117 ipoib_warn(priv, "failed to initialize; error %i", result);
117 goto register_failed; 118 goto register_failed;
@@ -134,12 +135,13 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
134 list_add_tail(&priv->list, &ppriv->child_intfs); 135 list_add_tail(&priv->list, &ppriv->child_intfs);
135 136
136 mutex_unlock(&ppriv->vlan_mutex); 137 mutex_unlock(&ppriv->vlan_mutex);
138 rtnl_unlock();
137 139
138 return 0; 140 return 0;
139 141
140sysfs_failed: 142sysfs_failed:
141 ipoib_delete_debug_files(priv->dev); 143 ipoib_delete_debug_files(priv->dev);
142 unregister_netdev(priv->dev); 144 unregister_netdevice(priv->dev);
143 145
144register_failed: 146register_failed:
145 ipoib_dev_cleanup(priv->dev); 147 ipoib_dev_cleanup(priv->dev);
@@ -149,6 +151,7 @@ device_init_failed:
149 151
150err: 152err:
151 mutex_unlock(&ppriv->vlan_mutex); 153 mutex_unlock(&ppriv->vlan_mutex);
154 rtnl_unlock();
152 return result; 155 return result;
153} 156}
154 157
@@ -162,10 +165,11 @@ int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey)
162 165
163 ppriv = netdev_priv(pdev); 166 ppriv = netdev_priv(pdev);
164 167
168 rtnl_lock();
165 mutex_lock(&ppriv->vlan_mutex); 169 mutex_lock(&ppriv->vlan_mutex);
166 list_for_each_entry_safe(priv, tpriv, &ppriv->child_intfs, list) { 170 list_for_each_entry_safe(priv, tpriv, &ppriv->child_intfs, list) {
167 if (priv->pkey == pkey) { 171 if (priv->pkey == pkey) {
168 unregister_netdev(priv->dev); 172 unregister_netdevice(priv->dev);
169 ipoib_dev_cleanup(priv->dev); 173 ipoib_dev_cleanup(priv->dev);
170 list_del(&priv->list); 174 list_del(&priv->list);
171 free_netdev(priv->dev); 175 free_netdev(priv->dev);
@@ -175,6 +179,7 @@ int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey)
175 } 179 }
176 } 180 }
177 mutex_unlock(&ppriv->vlan_mutex); 181 mutex_unlock(&ppriv->vlan_mutex);
182 rtnl_unlock();
178 183
179 return ret; 184 return ret;
180} 185}
diff --git a/drivers/infiniband/ulp/iser/Kconfig b/drivers/infiniband/ulp/iser/Kconfig
index 77dedba829e6..b411c51842da 100644
--- a/drivers/infiniband/ulp/iser/Kconfig
+++ b/drivers/infiniband/ulp/iser/Kconfig
@@ -1,6 +1,6 @@
1config INFINIBAND_ISER 1config INFINIBAND_ISER
2 tristate "iSCSI Extensions for RDMA (iSER)" 2 tristate "iSCSI Extensions for RDMA (iSER)"
3 depends on SCSI && INET 3 depends on SCSI && INET && INFINIBAND_ADDR_TRANS
4 select SCSI_ISCSI_ATTRS 4 select SCSI_ISCSI_ATTRS
5 ---help--- 5 ---help---
6 Support for the iSCSI Extensions for RDMA (iSER) Protocol 6 Support for the iSCSI Extensions for RDMA (iSER) Protocol
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index f6e9f39a527b..c3c8b9bc40ae 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -65,7 +65,7 @@ MODULE_PARM_DESC(extra, "Enable extra LEDs and keys on IBM RapidAcces, EzKey and
65 65
66/* 66/*
67 * Scancode to keycode tables. These are just the default setting, and 67 * Scancode to keycode tables. These are just the default setting, and
68 * are loadable via an userland utility. 68 * are loadable via a userland utility.
69 */ 69 */
70 70
71static const unsigned short atkbd_set2_keycode[512] = { 71static const unsigned short atkbd_set2_keycode[512] = {
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 199055db5082..67e5553f699a 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -220,4 +220,11 @@ config HP_SDC_RTC
220 Say Y here if you want to support the built-in real time clock 220 Say Y here if you want to support the built-in real time clock
221 of the HP SDC controller. 221 of the HP SDC controller.
222 222
223config INPUT_PCF50633_PMU
224 tristate "PCF50633 PMU events"
225 depends on MFD_PCF50633
226 help
227 Say Y to include support for delivering PMU events via input
228 layer on NXP PCF50633.
229
223endif 230endif
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index d7db2aeb8a98..bb62e6efacf3 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -21,3 +21,4 @@ obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o
21obj-$(CONFIG_INPUT_UINPUT) += uinput.o 21obj-$(CONFIG_INPUT_UINPUT) += uinput.o
22obj-$(CONFIG_INPUT_APANEL) += apanel.o 22obj-$(CONFIG_INPUT_APANEL) += apanel.o
23obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o 23obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o
24obj-$(CONFIG_INPUT_PCF50633_PMU) += pcf50633-input.o
diff --git a/drivers/input/misc/apanel.c b/drivers/input/misc/apanel.c
index d82f7f727f7a..71b82434264d 100644
--- a/drivers/input/misc/apanel.c
+++ b/drivers/input/misc/apanel.c
@@ -57,7 +57,7 @@ static enum apanel_chip device_chip[APANEL_DEV_MAX];
57 57
58struct apanel { 58struct apanel {
59 struct input_polled_dev *ipdev; 59 struct input_polled_dev *ipdev;
60 struct i2c_client client; 60 struct i2c_client *client;
61 unsigned short keymap[MAX_PANEL_KEYS]; 61 unsigned short keymap[MAX_PANEL_KEYS];
62 u16 nkeys; 62 u16 nkeys;
63 u16 led_bits; 63 u16 led_bits;
@@ -66,16 +66,7 @@ struct apanel {
66}; 66};
67 67
68 68
69static int apanel_probe(struct i2c_adapter *, int, int); 69static int apanel_probe(struct i2c_client *, const struct i2c_device_id *);
70
71/* for now, we only support one address */
72static unsigned short normal_i2c[] = {0, I2C_CLIENT_END};
73static unsigned short ignore = I2C_CLIENT_END;
74static struct i2c_client_address_data addr_data = {
75 .normal_i2c = normal_i2c,
76 .probe = &ignore,
77 .ignore = &ignore,
78};
79 70
80static void report_key(struct input_dev *input, unsigned keycode) 71static void report_key(struct input_dev *input, unsigned keycode)
81{ 72{
@@ -103,12 +94,12 @@ static void apanel_poll(struct input_polled_dev *ipdev)
103 s32 data; 94 s32 data;
104 int i; 95 int i;
105 96
106 data = i2c_smbus_read_word_data(&ap->client, cmd); 97 data = i2c_smbus_read_word_data(ap->client, cmd);
107 if (data < 0) 98 if (data < 0)
108 return; /* ignore errors (due to ACPI??) */ 99 return; /* ignore errors (due to ACPI??) */
109 100
110 /* write back to clear latch */ 101 /* write back to clear latch */
111 i2c_smbus_write_word_data(&ap->client, cmd, 0); 102 i2c_smbus_write_word_data(ap->client, cmd, 0);
112 103
113 if (!data) 104 if (!data)
114 return; 105 return;
@@ -124,7 +115,7 @@ static void led_update(struct work_struct *work)
124{ 115{
125 struct apanel *ap = container_of(work, struct apanel, led_work); 116 struct apanel *ap = container_of(work, struct apanel, led_work);
126 117
127 i2c_smbus_write_word_data(&ap->client, 0x10, ap->led_bits); 118 i2c_smbus_write_word_data(ap->client, 0x10, ap->led_bits);
128} 119}
129 120
130static void mail_led_set(struct led_classdev *led, 121static void mail_led_set(struct led_classdev *led,
@@ -140,7 +131,7 @@ static void mail_led_set(struct led_classdev *led,
140 schedule_work(&ap->led_work); 131 schedule_work(&ap->led_work);
141} 132}
142 133
143static int apanel_detach_client(struct i2c_client *client) 134static int apanel_remove(struct i2c_client *client)
144{ 135{
145 struct apanel *ap = i2c_get_clientdata(client); 136 struct apanel *ap = i2c_get_clientdata(client);
146 137
@@ -148,43 +139,33 @@ static int apanel_detach_client(struct i2c_client *client)
148 led_classdev_unregister(&ap->mail_led); 139 led_classdev_unregister(&ap->mail_led);
149 140
150 input_unregister_polled_device(ap->ipdev); 141 input_unregister_polled_device(ap->ipdev);
151 i2c_detach_client(&ap->client);
152 input_free_polled_device(ap->ipdev); 142 input_free_polled_device(ap->ipdev);
153 143
154 return 0; 144 return 0;
155} 145}
156 146
157/* Function is invoked for every i2c adapter. */
158static int apanel_attach_adapter(struct i2c_adapter *adap)
159{
160 dev_dbg(&adap->dev, APANEL ": attach adapter id=%d\n", adap->id);
161
162 /* Our device is connected only to i801 on laptop */
163 if (adap->id != I2C_HW_SMBUS_I801)
164 return -ENODEV;
165
166 return i2c_probe(adap, &addr_data, apanel_probe);
167}
168
169static void apanel_shutdown(struct i2c_client *client) 147static void apanel_shutdown(struct i2c_client *client)
170{ 148{
171 apanel_detach_client(client); 149 apanel_remove(client);
172} 150}
173 151
152static struct i2c_device_id apanel_id[] = {
153 { "fujitsu_apanel", 0 },
154 { }
155};
156MODULE_DEVICE_TABLE(i2c, apanel_id);
157
174static struct i2c_driver apanel_driver = { 158static struct i2c_driver apanel_driver = {
175 .driver = { 159 .driver = {
176 .name = APANEL, 160 .name = APANEL,
177 }, 161 },
178 .attach_adapter = &apanel_attach_adapter, 162 .probe = &apanel_probe,
179 .detach_client = &apanel_detach_client, 163 .remove = &apanel_remove,
180 .shutdown = &apanel_shutdown, 164 .shutdown = &apanel_shutdown,
165 .id_table = apanel_id,
181}; 166};
182 167
183static struct apanel apanel = { 168static struct apanel apanel = {
184 .client = {
185 .driver = &apanel_driver,
186 .name = APANEL,
187 },
188 .keymap = { 169 .keymap = {
189 [0] = KEY_MAIL, 170 [0] = KEY_MAIL,
190 [1] = KEY_WWW, 171 [1] = KEY_WWW,
@@ -204,7 +185,8 @@ static struct apanel apanel = {
204}; 185};
205 186
206/* NB: Only one panel on the i2c. */ 187/* NB: Only one panel on the i2c. */
207static int apanel_probe(struct i2c_adapter *bus, int address, int kind) 188static int apanel_probe(struct i2c_client *client,
189 const struct i2c_device_id *id)
208{ 190{
209 struct apanel *ap; 191 struct apanel *ap;
210 struct input_polled_dev *ipdev; 192 struct input_polled_dev *ipdev;
@@ -212,9 +194,6 @@ static int apanel_probe(struct i2c_adapter *bus, int address, int kind)
212 u8 cmd = device_chip[APANEL_DEV_APPBTN] == CHIP_OZ992C ? 0 : 8; 194 u8 cmd = device_chip[APANEL_DEV_APPBTN] == CHIP_OZ992C ? 0 : 8;
213 int i, err = -ENOMEM; 195 int i, err = -ENOMEM;
214 196
215 dev_dbg(&bus->dev, APANEL ": probe adapter %p addr %d kind %d\n",
216 bus, address, kind);
217
218 ap = &apanel; 197 ap = &apanel;
219 198
220 ipdev = input_allocate_polled_device(); 199 ipdev = input_allocate_polled_device();
@@ -222,18 +201,13 @@ static int apanel_probe(struct i2c_adapter *bus, int address, int kind)
222 goto out1; 201 goto out1;
223 202
224 ap->ipdev = ipdev; 203 ap->ipdev = ipdev;
225 ap->client.adapter = bus; 204 ap->client = client;
226 ap->client.addr = address;
227
228 i2c_set_clientdata(&ap->client, ap);
229 205
230 err = i2c_attach_client(&ap->client); 206 i2c_set_clientdata(client, ap);
231 if (err)
232 goto out2;
233 207
234 err = i2c_smbus_write_word_data(&ap->client, cmd, 0); 208 err = i2c_smbus_write_word_data(client, cmd, 0);
235 if (err) { 209 if (err) {
236 dev_warn(&ap->client.dev, APANEL ": smbus write error %d\n", 210 dev_warn(&client->dev, APANEL ": smbus write error %d\n",
237 err); 211 err);
238 goto out3; 212 goto out3;
239 } 213 }
@@ -246,7 +220,7 @@ static int apanel_probe(struct i2c_adapter *bus, int address, int kind)
246 idev->name = APANEL_NAME " buttons"; 220 idev->name = APANEL_NAME " buttons";
247 idev->phys = "apanel/input0"; 221 idev->phys = "apanel/input0";
248 idev->id.bustype = BUS_HOST; 222 idev->id.bustype = BUS_HOST;
249 idev->dev.parent = &ap->client.dev; 223 idev->dev.parent = &client->dev;
250 224
251 set_bit(EV_KEY, idev->evbit); 225 set_bit(EV_KEY, idev->evbit);
252 226
@@ -264,7 +238,7 @@ static int apanel_probe(struct i2c_adapter *bus, int address, int kind)
264 238
265 INIT_WORK(&ap->led_work, led_update); 239 INIT_WORK(&ap->led_work, led_update);
266 if (device_chip[APANEL_DEV_LED] != CHIP_NONE) { 240 if (device_chip[APANEL_DEV_LED] != CHIP_NONE) {
267 err = led_classdev_register(&ap->client.dev, &ap->mail_led); 241 err = led_classdev_register(&client->dev, &ap->mail_led);
268 if (err) 242 if (err)
269 goto out4; 243 goto out4;
270 } 244 }
@@ -273,8 +247,6 @@ static int apanel_probe(struct i2c_adapter *bus, int address, int kind)
273out4: 247out4:
274 input_unregister_polled_device(ipdev); 248 input_unregister_polled_device(ipdev);
275out3: 249out3:
276 i2c_detach_client(&ap->client);
277out2:
278 input_free_polled_device(ipdev); 250 input_free_polled_device(ipdev);
279out1: 251out1:
280 return err; 252 return err;
@@ -301,6 +273,7 @@ static int __init apanel_init(void)
301 void __iomem *bios; 273 void __iomem *bios;
302 const void __iomem *p; 274 const void __iomem *p;
303 u8 devno; 275 u8 devno;
276 unsigned char i2c_addr;
304 int found = 0; 277 int found = 0;
305 278
306 bios = ioremap(0xF0000, 0x10000); /* Can't fail */ 279 bios = ioremap(0xF0000, 0x10000); /* Can't fail */
@@ -313,7 +286,7 @@ static int __init apanel_init(void)
313 286
314 /* just use the first address */ 287 /* just use the first address */
315 p += 8; 288 p += 8;
316 normal_i2c[0] = readb(p+3) >> 1; 289 i2c_addr = readb(p + 3) >> 1;
317 290
318 for ( ; (devno = readb(p)) & 0x7f; p += 4) { 291 for ( ; (devno = readb(p)) & 0x7f; p += 4) {
319 unsigned char method, slave, chip; 292 unsigned char method, slave, chip;
@@ -322,7 +295,7 @@ static int __init apanel_init(void)
322 chip = readb(p + 2); 295 chip = readb(p + 2);
323 slave = readb(p + 3) >> 1; 296 slave = readb(p + 3) >> 1;
324 297
325 if (slave != normal_i2c[0]) { 298 if (slave != i2c_addr) {
326 pr_notice(APANEL ": only one SMBus slave " 299 pr_notice(APANEL ": only one SMBus slave "
327 "address supported, skiping device...\n"); 300 "address supported, skiping device...\n");
328 continue; 301 continue;
diff --git a/drivers/input/misc/pcf50633-input.c b/drivers/input/misc/pcf50633-input.c
new file mode 100644
index 000000000000..039dcb00ebd9
--- /dev/null
+++ b/drivers/input/misc/pcf50633-input.c
@@ -0,0 +1,132 @@
1/* NXP PCF50633 Input Driver
2 *
3 * (C) 2006-2008 by Openmoko, Inc.
4 * Author: Balaji Rao <balajirrao@openmoko.org>
5 * All rights reserved.
6 *
7 * Broken down from monstrous PCF50633 driver mainly by
8 * Harald Welte, Andy Green and Werner Almesberger
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/init.h>
20#include <linux/device.h>
21#include <linux/platform_device.h>
22#include <linux/input.h>
23
24#include <linux/mfd/pcf50633/core.h>
25
26#define PCF50633_OOCSTAT_ONKEY 0x01
27#define PCF50633_REG_OOCSTAT 0x12
28#define PCF50633_REG_OOCMODE 0x10
29
30struct pcf50633_input {
31 struct pcf50633 *pcf;
32 struct input_dev *input_dev;
33};
34
35static void
36pcf50633_input_irq(int irq, void *data)
37{
38 struct pcf50633_input *input;
39 int onkey_released;
40
41 input = data;
42
43 /* We report only one event depending on the key press status */
44 onkey_released = pcf50633_reg_read(input->pcf, PCF50633_REG_OOCSTAT)
45 & PCF50633_OOCSTAT_ONKEY;
46
47 if (irq == PCF50633_IRQ_ONKEYF && !onkey_released)
48 input_report_key(input->input_dev, KEY_POWER, 1);
49 else if (irq == PCF50633_IRQ_ONKEYR && onkey_released)
50 input_report_key(input->input_dev, KEY_POWER, 0);
51
52 input_sync(input->input_dev);
53}
54
55static int __devinit pcf50633_input_probe(struct platform_device *pdev)
56{
57 struct pcf50633_input *input;
58 struct pcf50633_subdev_pdata *pdata = pdev->dev.platform_data;
59 struct input_dev *input_dev;
60 int ret;
61
62
63 input = kzalloc(sizeof(*input), GFP_KERNEL);
64 if (!input)
65 return -ENOMEM;
66
67 input_dev = input_allocate_device();
68 if (!input_dev) {
69 kfree(input);
70 return -ENOMEM;
71 }
72
73 platform_set_drvdata(pdev, input);
74 input->pcf = pdata->pcf;
75 input->input_dev = input_dev;
76
77 input_dev->name = "PCF50633 PMU events";
78 input_dev->id.bustype = BUS_I2C;
79 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_PWR);
80 set_bit(KEY_POWER, input_dev->keybit);
81
82 ret = input_register_device(input_dev);
83 if (ret) {
84 input_free_device(input_dev);
85 kfree(input);
86 return ret;
87 }
88 pcf50633_register_irq(pdata->pcf, PCF50633_IRQ_ONKEYR,
89 pcf50633_input_irq, input);
90 pcf50633_register_irq(pdata->pcf, PCF50633_IRQ_ONKEYF,
91 pcf50633_input_irq, input);
92
93 return 0;
94}
95
96static int __devexit pcf50633_input_remove(struct platform_device *pdev)
97{
98 struct pcf50633_input *input = platform_get_drvdata(pdev);
99
100 pcf50633_free_irq(input->pcf, PCF50633_IRQ_ONKEYR);
101 pcf50633_free_irq(input->pcf, PCF50633_IRQ_ONKEYF);
102
103 input_unregister_device(input->input_dev);
104 kfree(input);
105
106 return 0;
107}
108
109static struct platform_driver pcf50633_input_driver = {
110 .driver = {
111 .name = "pcf50633-input",
112 },
113 .probe = pcf50633_input_probe,
114 .remove = __devexit_p(pcf50633_input_remove),
115};
116
117static int __init pcf50633_input_init(void)
118{
119 return platform_driver_register(&pcf50633_input_driver);
120}
121module_init(pcf50633_input_init);
122
123static void __exit pcf50633_input_exit(void)
124{
125 platform_driver_unregister(&pcf50633_input_driver);
126}
127module_exit(pcf50633_input_exit);
128
129MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>");
130MODULE_DESCRIPTION("PCF50633 input driver");
131MODULE_LICENSE("GPL");
132MODULE_ALIAS("platform:pcf50633-input");
diff --git a/drivers/input/mouse/pxa930_trkball.c b/drivers/input/mouse/pxa930_trkball.c
index a0f45c4fc198..d297accf9a7f 100644
--- a/drivers/input/mouse/pxa930_trkball.c
+++ b/drivers/input/mouse/pxa930_trkball.c
@@ -186,7 +186,7 @@ static int __devinit pxa930_trkball_probe(struct platform_device *pdev)
186 error = request_irq(irq, pxa930_trkball_interrupt, IRQF_DISABLED, 186 error = request_irq(irq, pxa930_trkball_interrupt, IRQF_DISABLED,
187 pdev->name, trkball); 187 pdev->name, trkball);
188 if (error) { 188 if (error) {
189 dev_err(&pdev->dev, "failed to request irq: %d\n", ret); 189 dev_err(&pdev->dev, "failed to request irq: %d\n", error);
190 goto failed_free_io; 190 goto failed_free_io;
191 } 191 }
192 192
@@ -227,7 +227,7 @@ failed_free_io:
227 iounmap(trkball->mmio_base); 227 iounmap(trkball->mmio_base);
228failed: 228failed:
229 kfree(trkball); 229 kfree(trkball);
230 return ret; 230 return error;
231} 231}
232 232
233static int __devexit pxa930_trkball_remove(struct platform_device *pdev) 233static int __devexit pxa930_trkball_remove(struct platform_device *pdev)
diff --git a/drivers/input/touchscreen/da9034-ts.c b/drivers/input/touchscreen/da9034-ts.c
index 4342e77814b5..fa67d782c3c3 100644
--- a/drivers/input/touchscreen/da9034-ts.c
+++ b/drivers/input/touchscreen/da9034-ts.c
@@ -16,6 +16,7 @@
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/input.h> 18#include <linux/input.h>
19#include <linux/workqueue.h>
19#include <linux/mfd/da903x.h> 20#include <linux/mfd/da903x.h>
20 21
21#define DA9034_MANUAL_CTRL 0x50 22#define DA9034_MANUAL_CTRL 0x50
diff --git a/drivers/isdn/hardware/eicon/debuglib.h b/drivers/isdn/hardware/eicon/debuglib.h
index 016410cf2273..8ea587783e14 100644
--- a/drivers/isdn/hardware/eicon/debuglib.h
+++ b/drivers/isdn/hardware/eicon/debuglib.h
@@ -235,7 +235,7 @@ typedef void ( * DbgOld) (unsigned short, char *, va_list) ;
235typedef void ( * DbgEv) (unsigned short, unsigned long, va_list) ; 235typedef void ( * DbgEv) (unsigned short, unsigned long, va_list) ;
236typedef void ( * DbgIrq) (unsigned short, int, char *, va_list) ; 236typedef void ( * DbgIrq) (unsigned short, int, char *, va_list) ;
237typedef struct _DbgHandle_ 237typedef struct _DbgHandle_
238{ char Registered ; /* driver successfull registered */ 238{ char Registered ; /* driver successfully registered */
239#define DBG_HANDLE_REG_NEW 0x01 /* this (new) structure */ 239#define DBG_HANDLE_REG_NEW 0x01 /* this (new) structure */
240#define DBG_HANDLE_REG_OLD 0x7f /* old structure (see below) */ 240#define DBG_HANDLE_REG_OLD 0x7f /* old structure (see below) */
241 char Version; /* version of this structure */ 241 char Version; /* version of this structure */
diff --git a/drivers/isdn/hardware/eicon/os_4bri.c b/drivers/isdn/hardware/eicon/os_4bri.c
index 7b4ec3f60dbf..c964b8d91ada 100644
--- a/drivers/isdn/hardware/eicon/os_4bri.c
+++ b/drivers/isdn/hardware/eicon/os_4bri.c
@@ -997,7 +997,7 @@ diva_4bri_start_adapter(PISDN_ADAPTER IoAdapter,
997 diva_xdi_display_adapter_features(IoAdapter->ANum); 997 diva_xdi_display_adapter_features(IoAdapter->ANum);
998 998
999 for (i = 0; i < IoAdapter->tasks; i++) { 999 for (i = 0; i < IoAdapter->tasks; i++) {
1000 DBG_LOG(("A(%d) %s adapter successfull started", 1000 DBG_LOG(("A(%d) %s adapter successfully started",
1001 IoAdapter->QuadroList->QuadroAdapter[i]->ANum, 1001 IoAdapter->QuadroList->QuadroAdapter[i]->ANum,
1002 (IoAdapter->tasks == 1) ? "BRI 2.0" : "4BRI")) 1002 (IoAdapter->tasks == 1) ? "BRI 2.0" : "4BRI"))
1003 diva_xdi_didd_register_adapter(IoAdapter->QuadroList->QuadroAdapter[i]->ANum); 1003 diva_xdi_didd_register_adapter(IoAdapter->QuadroList->QuadroAdapter[i]->ANum);
diff --git a/drivers/isdn/hardware/eicon/os_bri.c b/drivers/isdn/hardware/eicon/os_bri.c
index f31bba5b16ff..08f01993f46b 100644
--- a/drivers/isdn/hardware/eicon/os_bri.c
+++ b/drivers/isdn/hardware/eicon/os_bri.c
@@ -736,7 +736,7 @@ diva_bri_start_adapter(PISDN_ADAPTER IoAdapter,
736 736
737 IoAdapter->Properties.Features = (word) features; 737 IoAdapter->Properties.Features = (word) features;
738 diva_xdi_display_adapter_features(IoAdapter->ANum); 738 diva_xdi_display_adapter_features(IoAdapter->ANum);
739 DBG_LOG(("A(%d) BRI adapter successfull started", IoAdapter->ANum)) 739 DBG_LOG(("A(%d) BRI adapter successfully started", IoAdapter->ANum))
740 /* 740 /*
741 Register with DIDD 741 Register with DIDD
742 */ 742 */
diff --git a/drivers/isdn/hardware/eicon/os_pri.c b/drivers/isdn/hardware/eicon/os_pri.c
index 903356547b79..5d65405c75f4 100644
--- a/drivers/isdn/hardware/eicon/os_pri.c
+++ b/drivers/isdn/hardware/eicon/os_pri.c
@@ -513,7 +513,7 @@ diva_pri_start_adapter(PISDN_ADAPTER IoAdapter,
513 513
514 diva_xdi_display_adapter_features(IoAdapter->ANum); 514 diva_xdi_display_adapter_features(IoAdapter->ANum);
515 515
516 DBG_LOG(("A(%d) PRI adapter successfull started", IoAdapter->ANum)) 516 DBG_LOG(("A(%d) PRI adapter successfully started", IoAdapter->ANum))
517 /* 517 /*
518 Register with DIDD 518 Register with DIDD
519 */ 519 */
diff --git a/drivers/isdn/hardware/mISDN/Kconfig b/drivers/isdn/hardware/mISDN/Kconfig
index 14793480c453..fd112ae252cf 100644
--- a/drivers/isdn/hardware/mISDN/Kconfig
+++ b/drivers/isdn/hardware/mISDN/Kconfig
@@ -23,3 +23,10 @@ config MISDN_HFCMULTI
23 * HFC-8S (8 S/T interfaces on one chip) 23 * HFC-8S (8 S/T interfaces on one chip)
24 * HFC-E1 (E1 interface for 2Mbit ISDN) 24 * HFC-E1 (E1 interface for 2Mbit ISDN)
25 25
26config MISDN_HFCUSB
27 tristate "Support for HFC-S USB based TAs"
28 depends on USB
29 help
30 Enable support for USB ISDN TAs with Cologne Chip AG's
31 HFC-S USB ISDN Controller
32
diff --git a/drivers/isdn/hardware/mISDN/Makefile b/drivers/isdn/hardware/mISDN/Makefile
index 1e7ca5332ad7..b0403526bbba 100644
--- a/drivers/isdn/hardware/mISDN/Makefile
+++ b/drivers/isdn/hardware/mISDN/Makefile
@@ -5,3 +5,4 @@
5 5
6obj-$(CONFIG_MISDN_HFCPCI) += hfcpci.o 6obj-$(CONFIG_MISDN_HFCPCI) += hfcpci.o
7obj-$(CONFIG_MISDN_HFCMULTI) += hfcmulti.o 7obj-$(CONFIG_MISDN_HFCMULTI) += hfcmulti.o
8obj-$(CONFIG_MISDN_HFCUSB) += hfcsusb.o
diff --git a/drivers/isdn/hardware/mISDN/hfc_multi.h b/drivers/isdn/hardware/mISDN/hfc_multi.h
index 7bbf7300593d..663b77f578be 100644
--- a/drivers/isdn/hardware/mISDN/hfc_multi.h
+++ b/drivers/isdn/hardware/mISDN/hfc_multi.h
@@ -2,10 +2,6 @@
2 * see notice in hfc_multi.c 2 * see notice in hfc_multi.c
3 */ 3 */
4 4
5extern void ztdummy_extern_interrupt(void);
6extern void ztdummy_register_interrupt(void);
7extern int ztdummy_unregister_interrupt(void);
8
9#define DEBUG_HFCMULTI_FIFO 0x00010000 5#define DEBUG_HFCMULTI_FIFO 0x00010000
10#define DEBUG_HFCMULTI_CRC 0x00020000 6#define DEBUG_HFCMULTI_CRC 0x00020000
11#define DEBUG_HFCMULTI_INIT 0x00040000 7#define DEBUG_HFCMULTI_INIT 0x00040000
@@ -13,6 +9,7 @@ extern int ztdummy_unregister_interrupt(void);
13#define DEBUG_HFCMULTI_MODE 0x00100000 9#define DEBUG_HFCMULTI_MODE 0x00100000
14#define DEBUG_HFCMULTI_MSG 0x00200000 10#define DEBUG_HFCMULTI_MSG 0x00200000
15#define DEBUG_HFCMULTI_STATE 0x00400000 11#define DEBUG_HFCMULTI_STATE 0x00400000
12#define DEBUG_HFCMULTI_FILL 0x00800000
16#define DEBUG_HFCMULTI_SYNC 0x01000000 13#define DEBUG_HFCMULTI_SYNC 0x01000000
17#define DEBUG_HFCMULTI_DTMF 0x02000000 14#define DEBUG_HFCMULTI_DTMF 0x02000000
18#define DEBUG_HFCMULTI_LOCK 0x80000000 15#define DEBUG_HFCMULTI_LOCK 0x80000000
@@ -170,6 +167,8 @@ struct hfc_multi {
170 167
171 u_long chip; /* chip configuration */ 168 u_long chip; /* chip configuration */
172 int masterclk; /* port that provides master clock -1=off */ 169 int masterclk; /* port that provides master clock -1=off */
170 unsigned char silence;/* silence byte */
171 unsigned char silence_data[128];/* silence block */
173 int dtmf; /* flag that dtmf is currently in process */ 172 int dtmf; /* flag that dtmf is currently in process */
174 int Flen; /* F-buffer size */ 173 int Flen; /* F-buffer size */
175 int Zlen; /* Z-buffer size (must be int for calculation)*/ 174 int Zlen; /* Z-buffer size (must be int for calculation)*/
@@ -198,6 +197,9 @@ struct hfc_multi {
198 197
199 spinlock_t lock; /* the lock */ 198 spinlock_t lock; /* the lock */
200 199
200 struct mISDNclock *iclock; /* isdn clock support */
201 int iclock_on;
202
201 /* 203 /*
202 * the channel index is counted from 0, regardless where the channel 204 * the channel index is counted from 0, regardless where the channel
203 * is located on the hfc-channel. 205 * is located on the hfc-channel.
diff --git a/drivers/isdn/hardware/mISDN/hfc_pci.h b/drivers/isdn/hardware/mISDN/hfc_pci.h
index 5783d22a18fe..3132ddc99fcd 100644
--- a/drivers/isdn/hardware/mISDN/hfc_pci.h
+++ b/drivers/isdn/hardware/mISDN/hfc_pci.h
@@ -26,7 +26,7 @@
26 * change mask and threshold simultaneously 26 * change mask and threshold simultaneously
27 */ 27 */
28#define HFCPCI_BTRANS_THRESHOLD 128 28#define HFCPCI_BTRANS_THRESHOLD 128
29#define HFCPCI_BTRANS_MAX 256 29#define HFCPCI_FILLEMPTY 64
30#define HFCPCI_BTRANS_THRESMASK 0x00 30#define HFCPCI_BTRANS_THRESMASK 0x00
31 31
32/* defines for PCI config */ 32/* defines for PCI config */
diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c b/drivers/isdn/hardware/mISDN/hfcmulti.c
index c63e2f49da8a..595ba8eb4a07 100644
--- a/drivers/isdn/hardware/mISDN/hfcmulti.c
+++ b/drivers/isdn/hardware/mISDN/hfcmulti.c
@@ -133,6 +133,12 @@
133 * Give the value of the clock control register (A_ST_CLK_DLY) 133 * Give the value of the clock control register (A_ST_CLK_DLY)
134 * of the S/T interfaces in TE mode. 134 * of the S/T interfaces in TE mode.
135 * This register is needed for the TBR3 certification, so don't change it. 135 * This register is needed for the TBR3 certification, so don't change it.
136 *
137 * clock:
138 * NOTE: only one clock value must be given once
139 * Selects interface with clock source for mISDN and applications.
140 * Set to card number starting with 1. Set to -1 to disable.
141 * By default, the first card is used as clock source.
136 */ 142 */
137 143
138/* 144/*
@@ -140,7 +146,7 @@
140 * #define HFC_REGISTER_DEBUG 146 * #define HFC_REGISTER_DEBUG
141 */ 147 */
142 148
143static const char *hfcmulti_revision = "2.02"; 149#define HFC_MULTI_VERSION "2.03"
144 150
145#include <linux/module.h> 151#include <linux/module.h>
146#include <linux/pci.h> 152#include <linux/pci.h>
@@ -165,10 +171,6 @@ static LIST_HEAD(HFClist);
165static spinlock_t HFClock; /* global hfc list lock */ 171static spinlock_t HFClock; /* global hfc list lock */
166 172
167static void ph_state_change(struct dchannel *); 173static void ph_state_change(struct dchannel *);
168static void (*hfc_interrupt)(void);
169static void (*register_interrupt)(void);
170static int (*unregister_interrupt)(void);
171static int interrupt_registered;
172 174
173static struct hfc_multi *syncmaster; 175static struct hfc_multi *syncmaster;
174static int plxsd_master; /* if we have a master card (yet) */ 176static int plxsd_master; /* if we have a master card (yet) */
@@ -184,7 +186,6 @@ static int nt_t1_count[] = { 3840, 1920, 960, 480, 240, 120, 60, 30 };
184#define CLKDEL_TE 0x0f /* CLKDEL in TE mode */ 186#define CLKDEL_TE 0x0f /* CLKDEL in TE mode */
185#define CLKDEL_NT 0x6c /* CLKDEL in NT mode 187#define CLKDEL_NT 0x6c /* CLKDEL in NT mode
186 (0x60 MUST be included!) */ 188 (0x60 MUST be included!) */
187static u_char silence = 0xff; /* silence by LAW */
188 189
189#define DIP_4S 0x1 /* DIP Switches for Beronet 1S/2S/4S cards */ 190#define DIP_4S 0x1 /* DIP Switches for Beronet 1S/2S/4S cards */
190#define DIP_8S 0x2 /* DIP Switches for Beronet 8S+ cards */ 191#define DIP_8S 0x2 /* DIP Switches for Beronet 8S+ cards */
@@ -195,12 +196,13 @@ static u_char silence = 0xff; /* silence by LAW */
195 */ 196 */
196 197
197static uint type[MAX_CARDS]; 198static uint type[MAX_CARDS];
198static uint pcm[MAX_CARDS]; 199static int pcm[MAX_CARDS];
199static uint dslot[MAX_CARDS]; 200static int dslot[MAX_CARDS];
200static uint iomode[MAX_CARDS]; 201static uint iomode[MAX_CARDS];
201static uint port[MAX_PORTS]; 202static uint port[MAX_PORTS];
202static uint debug; 203static uint debug;
203static uint poll; 204static uint poll;
205static int clock;
204static uint timer; 206static uint timer;
205static uint clockdelay_te = CLKDEL_TE; 207static uint clockdelay_te = CLKDEL_TE;
206static uint clockdelay_nt = CLKDEL_NT; 208static uint clockdelay_nt = CLKDEL_NT;
@@ -209,14 +211,16 @@ static int HFC_cnt, Port_cnt, PCM_cnt = 99;
209 211
210MODULE_AUTHOR("Andreas Eversberg"); 212MODULE_AUTHOR("Andreas Eversberg");
211MODULE_LICENSE("GPL"); 213MODULE_LICENSE("GPL");
214MODULE_VERSION(HFC_MULTI_VERSION);
212module_param(debug, uint, S_IRUGO | S_IWUSR); 215module_param(debug, uint, S_IRUGO | S_IWUSR);
213module_param(poll, uint, S_IRUGO | S_IWUSR); 216module_param(poll, uint, S_IRUGO | S_IWUSR);
217module_param(clock, int, S_IRUGO | S_IWUSR);
214module_param(timer, uint, S_IRUGO | S_IWUSR); 218module_param(timer, uint, S_IRUGO | S_IWUSR);
215module_param(clockdelay_te, uint, S_IRUGO | S_IWUSR); 219module_param(clockdelay_te, uint, S_IRUGO | S_IWUSR);
216module_param(clockdelay_nt, uint, S_IRUGO | S_IWUSR); 220module_param(clockdelay_nt, uint, S_IRUGO | S_IWUSR);
217module_param_array(type, uint, NULL, S_IRUGO | S_IWUSR); 221module_param_array(type, uint, NULL, S_IRUGO | S_IWUSR);
218module_param_array(pcm, uint, NULL, S_IRUGO | S_IWUSR); 222module_param_array(pcm, int, NULL, S_IRUGO | S_IWUSR);
219module_param_array(dslot, uint, NULL, S_IRUGO | S_IWUSR); 223module_param_array(dslot, int, NULL, S_IRUGO | S_IWUSR);
220module_param_array(iomode, uint, NULL, S_IRUGO | S_IWUSR); 224module_param_array(iomode, uint, NULL, S_IRUGO | S_IWUSR);
221module_param_array(port, uint, NULL, S_IRUGO | S_IWUSR); 225module_param_array(port, uint, NULL, S_IRUGO | S_IWUSR);
222 226
@@ -1419,19 +1423,6 @@ controller_fail:
1419 HFC_outb(hc, R_TI_WD, poll_timer); 1423 HFC_outb(hc, R_TI_WD, poll_timer);
1420 hc->hw.r_irqmsk_misc |= V_TI_IRQMSK; 1424 hc->hw.r_irqmsk_misc |= V_TI_IRQMSK;
1421 1425
1422 /*
1423 * set up 125us interrupt, only if function pointer is available
1424 * and module parameter timer is set
1425 */
1426 if (timer && hfc_interrupt && register_interrupt) {
1427 /* only one chip should use this interrupt */
1428 timer = 0;
1429 interrupt_registered = 1;
1430 hc->hw.r_irqmsk_misc |= V_PROC_IRQMSK;
1431 /* deactivate other interrupts in ztdummy */
1432 register_interrupt();
1433 }
1434
1435 /* set E1 state machine IRQ */ 1426 /* set E1 state machine IRQ */
1436 if (hc->type == 1) 1427 if (hc->type == 1)
1437 hc->hw.r_irqmsk_misc |= V_STA_IRQMSK; 1428 hc->hw.r_irqmsk_misc |= V_STA_IRQMSK;
@@ -1991,6 +1982,17 @@ next_frame:
1991 return; /* no data */ 1982 return; /* no data */
1992 } 1983 }
1993 1984
1985 /* "fill fifo if empty" feature */
1986 if (bch && test_bit(FLG_FILLEMPTY, &bch->Flags)
1987 && !test_bit(FLG_HDLC, &bch->Flags) && z2 == z1) {
1988 if (debug & DEBUG_HFCMULTI_FILL)
1989 printk(KERN_DEBUG "%s: buffer empty, so we have "
1990 "underrun\n", __func__);
1991 /* fill buffer, to prevent future underrun */
1992 hc->write_fifo(hc, hc->silence_data, poll >> 1);
1993 Zspace -= (poll >> 1);
1994 }
1995
1994 /* if audio data and connected slot */ 1996 /* if audio data and connected slot */
1995 if (bch && (!test_bit(FLG_HDLC, &bch->Flags)) && (!*txpending) 1997 if (bch && (!test_bit(FLG_HDLC, &bch->Flags)) && (!*txpending)
1996 && slot_tx >= 0) { 1998 && slot_tx >= 0) {
@@ -2027,7 +2029,6 @@ next_frame:
2027 __func__, hc->id + 1, ch, Zspace, z1, z2, ii-i, len-i, 2029 __func__, hc->id + 1, ch, Zspace, z1, z2, ii-i, len-i,
2028 temp ? "HDLC":"TRANS"); 2030 temp ? "HDLC":"TRANS");
2029 2031
2030
2031 /* Have to prep the audio data */ 2032 /* Have to prep the audio data */
2032 hc->write_fifo(hc, d, ii - i); 2033 hc->write_fifo(hc, d, ii - i);
2033 *idxp = ii; 2034 *idxp = ii;
@@ -2066,7 +2067,7 @@ next_frame:
2066 * no more data at all. this prevents sending an undefined value. 2067 * no more data at all. this prevents sending an undefined value.
2067 */ 2068 */
2068 if (bch && test_bit(FLG_TRANSPARENT, &bch->Flags)) 2069 if (bch && test_bit(FLG_TRANSPARENT, &bch->Flags))
2069 HFC_outb_nodebug(hc, A_FIFO_DATA0_NOINC, silence); 2070 HFC_outb_nodebug(hc, A_FIFO_DATA0_NOINC, hc->silence);
2070} 2071}
2071 2072
2072 2073
@@ -2583,7 +2584,6 @@ hfcmulti_interrupt(int intno, void *dev_id)
2583 static int iq1 = 0, iq2 = 0, iq3 = 0, iq4 = 0, 2584 static int iq1 = 0, iq2 = 0, iq3 = 0, iq4 = 0,
2584 iq5 = 0, iq6 = 0, iqcnt = 0; 2585 iq5 = 0, iq6 = 0, iqcnt = 0;
2585#endif 2586#endif
2586 static int count;
2587 struct hfc_multi *hc = dev_id; 2587 struct hfc_multi *hc = dev_id;
2588 struct dchannel *dch; 2588 struct dchannel *dch;
2589 u_char r_irq_statech, status, r_irq_misc, r_irq_oview; 2589 u_char r_irq_statech, status, r_irq_misc, r_irq_oview;
@@ -2637,6 +2637,7 @@ hfcmulti_interrupt(int intno, void *dev_id)
2637 iqcnt = 0; 2637 iqcnt = 0;
2638 } 2638 }
2639#endif 2639#endif
2640
2640 if (!r_irq_statech && 2641 if (!r_irq_statech &&
2641 !(status & (V_DTMF_STA | V_LOST_STA | V_EXT_IRQSTA | 2642 !(status & (V_DTMF_STA | V_LOST_STA | V_EXT_IRQSTA |
2642 V_MISC_IRQSTA | V_FR_IRQSTA))) { 2643 V_MISC_IRQSTA | V_FR_IRQSTA))) {
@@ -2657,6 +2658,7 @@ hfcmulti_interrupt(int intno, void *dev_id)
2657 if (status & V_MISC_IRQSTA) { 2658 if (status & V_MISC_IRQSTA) {
2658 /* misc IRQ */ 2659 /* misc IRQ */
2659 r_irq_misc = HFC_inb_nodebug(hc, R_IRQ_MISC); 2660 r_irq_misc = HFC_inb_nodebug(hc, R_IRQ_MISC);
2661 r_irq_misc &= hc->hw.r_irqmsk_misc; /* ignore disabled irqs */
2660 if (r_irq_misc & V_STA_IRQ) { 2662 if (r_irq_misc & V_STA_IRQ) {
2661 if (hc->type == 1) { 2663 if (hc->type == 1) {
2662 /* state machine */ 2664 /* state machine */
@@ -2691,23 +2693,20 @@ hfcmulti_interrupt(int intno, void *dev_id)
2691 plxsd_checksync(hc, 0); 2693 plxsd_checksync(hc, 0);
2692 } 2694 }
2693 } 2695 }
2694 if (r_irq_misc & V_TI_IRQ) 2696 if (r_irq_misc & V_TI_IRQ) {
2697 if (hc->iclock_on)
2698 mISDN_clock_update(hc->iclock, poll, NULL);
2695 handle_timer_irq(hc); 2699 handle_timer_irq(hc);
2700 }
2696 2701
2697 if (r_irq_misc & V_DTMF_IRQ) { 2702 if (r_irq_misc & V_DTMF_IRQ) {
2698 /* -> DTMF IRQ */
2699 hfcmulti_dtmf(hc); 2703 hfcmulti_dtmf(hc);
2700 } 2704 }
2701 /* TODO: REPLACE !!!! 125 us Interrupts are not acceptable */
2702 if (r_irq_misc & V_IRQ_PROC) { 2705 if (r_irq_misc & V_IRQ_PROC) {
2703 /* IRQ every 125us */ 2706 static int irq_proc_cnt;
2704 count++; 2707 if (!irq_proc_cnt++)
2705 /* generate 1kHz signal */ 2708 printk(KERN_WARNING "%s: got V_IRQ_PROC -"
2706 if (count == 8) { 2709 " this should not happen\n", __func__);
2707 if (hfc_interrupt)
2708 hfc_interrupt();
2709 count = 0;
2710 }
2711 } 2710 }
2712 2711
2713 } 2712 }
@@ -2954,7 +2953,7 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx,
2954 HFC_outb(hc, R_INC_RES_FIFO, V_RES_F); 2953 HFC_outb(hc, R_INC_RES_FIFO, V_RES_F);
2955 HFC_wait(hc); 2954 HFC_wait(hc);
2956 /* tx silence */ 2955 /* tx silence */
2957 HFC_outb_nodebug(hc, A_FIFO_DATA0_NOINC, silence); 2956 HFC_outb_nodebug(hc, A_FIFO_DATA0_NOINC, hc->silence);
2958 HFC_outb(hc, R_SLOT, (((ch / 4) * 8) + 2957 HFC_outb(hc, R_SLOT, (((ch / 4) * 8) +
2959 ((ch % 4) * 4)) << 1); 2958 ((ch % 4) * 4)) << 1);
2960 HFC_outb(hc, A_SL_CFG, 0x80 | 0x20 | (ch << 1)); 2959 HFC_outb(hc, A_SL_CFG, 0x80 | 0x20 | (ch << 1));
@@ -2969,7 +2968,7 @@ mode_hfcmulti(struct hfc_multi *hc, int ch, int protocol, int slot_tx,
2969 HFC_outb(hc, R_INC_RES_FIFO, V_RES_F); 2968 HFC_outb(hc, R_INC_RES_FIFO, V_RES_F);
2970 HFC_wait(hc); 2969 HFC_wait(hc);
2971 /* tx silence */ 2970 /* tx silence */
2972 HFC_outb_nodebug(hc, A_FIFO_DATA0_NOINC, silence); 2971 HFC_outb_nodebug(hc, A_FIFO_DATA0_NOINC, hc->silence);
2973 /* enable RX fifo */ 2972 /* enable RX fifo */
2974 HFC_outb(hc, R_FIFO, (ch<<1)|1); 2973 HFC_outb(hc, R_FIFO, (ch<<1)|1);
2975 HFC_wait(hc); 2974 HFC_wait(hc);
@@ -3461,7 +3460,7 @@ channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq)
3461 switch (cq->op) { 3460 switch (cq->op) {
3462 case MISDN_CTRL_GETOP: 3461 case MISDN_CTRL_GETOP:
3463 cq->op = MISDN_CTRL_HFC_OP | MISDN_CTRL_HW_FEATURES_OP 3462 cq->op = MISDN_CTRL_HFC_OP | MISDN_CTRL_HW_FEATURES_OP
3464 | MISDN_CTRL_RX_OFF; 3463 | MISDN_CTRL_RX_OFF | MISDN_CTRL_FILL_EMPTY;
3465 break; 3464 break;
3466 case MISDN_CTRL_RX_OFF: /* turn off / on rx stream */ 3465 case MISDN_CTRL_RX_OFF: /* turn off / on rx stream */
3467 hc->chan[bch->slot].rx_off = !!cq->p1; 3466 hc->chan[bch->slot].rx_off = !!cq->p1;
@@ -3476,6 +3475,12 @@ channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq)
3476 printk(KERN_DEBUG "%s: RX_OFF request (nr=%d off=%d)\n", 3475 printk(KERN_DEBUG "%s: RX_OFF request (nr=%d off=%d)\n",
3477 __func__, bch->nr, hc->chan[bch->slot].rx_off); 3476 __func__, bch->nr, hc->chan[bch->slot].rx_off);
3478 break; 3477 break;
3478 case MISDN_CTRL_FILL_EMPTY: /* fill fifo, if empty */
3479 test_and_set_bit(FLG_FILLEMPTY, &bch->Flags);
3480 if (debug & DEBUG_HFCMULTI_MSG)
3481 printk(KERN_DEBUG "%s: FILL_EMPTY request (nr=%d "
3482 "off=%d)\n", __func__, bch->nr, !!cq->p1);
3483 break;
3479 case MISDN_CTRL_HW_FEATURES: /* fill features structure */ 3484 case MISDN_CTRL_HW_FEATURES: /* fill features structure */
3480 if (debug & DEBUG_HFCMULTI_MSG) 3485 if (debug & DEBUG_HFCMULTI_MSG)
3481 printk(KERN_DEBUG "%s: HW_FEATURE request\n", 3486 printk(KERN_DEBUG "%s: HW_FEATURE request\n",
@@ -3610,7 +3615,7 @@ hfcm_bctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
3610static void 3615static void
3611ph_state_change(struct dchannel *dch) 3616ph_state_change(struct dchannel *dch)
3612{ 3617{
3613 struct hfc_multi *hc = dch->hw; 3618 struct hfc_multi *hc;
3614 int ch, i; 3619 int ch, i;
3615 3620
3616 if (!dch) { 3621 if (!dch) {
@@ -3618,6 +3623,7 @@ ph_state_change(struct dchannel *dch)
3618 __func__); 3623 __func__);
3619 return; 3624 return;
3620 } 3625 }
3626 hc = dch->hw;
3621 ch = dch->slot; 3627 ch = dch->slot;
3622 3628
3623 if (hc->type == 1) { 3629 if (hc->type == 1) {
@@ -3992,6 +3998,7 @@ open_bchannel(struct hfc_multi *hc, struct dchannel *dch,
3992 } 3998 }
3993 if (test_and_set_bit(FLG_OPEN, &bch->Flags)) 3999 if (test_and_set_bit(FLG_OPEN, &bch->Flags))
3994 return -EBUSY; /* b-channel can be only open once */ 4000 return -EBUSY; /* b-channel can be only open once */
4001 test_and_clear_bit(FLG_FILLEMPTY, &bch->Flags);
3995 bch->ch.protocol = rq->protocol; 4002 bch->ch.protocol = rq->protocol;
3996 hc->chan[ch].rx_off = 0; 4003 hc->chan[ch].rx_off = 0;
3997 rq->ch = &bch->ch; 4004 rq->ch = &bch->ch;
@@ -4081,6 +4088,15 @@ hfcm_dctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
4081 return err; 4088 return err;
4082} 4089}
4083 4090
4091static int
4092clockctl(void *priv, int enable)
4093{
4094 struct hfc_multi *hc = priv;
4095
4096 hc->iclock_on = enable;
4097 return 0;
4098}
4099
4084/* 4100/*
4085 * initialize the card 4101 * initialize the card
4086 */ 4102 */
@@ -4495,10 +4511,14 @@ release_card(struct hfc_multi *hc)
4495 printk(KERN_WARNING "%s: release card (%d) entered\n", 4511 printk(KERN_WARNING "%s: release card (%d) entered\n",
4496 __func__, hc->id); 4512 __func__, hc->id);
4497 4513
4514 /* unregister clock source */
4515 if (hc->iclock)
4516 mISDN_unregister_clock(hc->iclock);
4517
4518 /* disable irq */
4498 spin_lock_irqsave(&hc->lock, flags); 4519 spin_lock_irqsave(&hc->lock, flags);
4499 disable_hwirq(hc); 4520 disable_hwirq(hc);
4500 spin_unlock_irqrestore(&hc->lock, flags); 4521 spin_unlock_irqrestore(&hc->lock, flags);
4501
4502 udelay(1000); 4522 udelay(1000);
4503 4523
4504 /* dimm leds */ 4524 /* dimm leds */
@@ -4699,7 +4719,7 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
4699 } else 4719 } else
4700 hc->chan[hc->dslot].jitter = 2; /* default */ 4720 hc->chan[hc->dslot].jitter = 2; /* default */
4701 snprintf(name, MISDN_MAX_IDLEN - 1, "hfc-e1.%d", HFC_cnt + 1); 4721 snprintf(name, MISDN_MAX_IDLEN - 1, "hfc-e1.%d", HFC_cnt + 1);
4702 ret = mISDN_register_device(&dch->dev, name); 4722 ret = mISDN_register_device(&dch->dev, &hc->pci_dev->dev, name);
4703 if (ret) 4723 if (ret)
4704 goto free_chan; 4724 goto free_chan;
4705 hc->created[0] = 1; 4725 hc->created[0] = 1;
@@ -4807,9 +4827,9 @@ init_multi_port(struct hfc_multi *hc, int pt)
4807 test_and_set_bit(HFC_CFG_DIS_ECHANNEL, 4827 test_and_set_bit(HFC_CFG_DIS_ECHANNEL,
4808 &hc->chan[i + 2].cfg); 4828 &hc->chan[i + 2].cfg);
4809 } 4829 }
4810 snprintf(name, MISDN_MAX_IDLEN - 1, "hfc-%ds.%d/%d", 4830 snprintf(name, MISDN_MAX_IDLEN - 1, "hfc-%ds.%d-%d",
4811 hc->type, HFC_cnt + 1, pt + 1); 4831 hc->type, HFC_cnt + 1, pt + 1);
4812 ret = mISDN_register_device(&dch->dev, name); 4832 ret = mISDN_register_device(&dch->dev, &hc->pci_dev->dev, name);
4813 if (ret) 4833 if (ret)
4814 goto free_chan; 4834 goto free_chan;
4815 hc->created[pt] = 1; 4835 hc->created[pt] = 1;
@@ -4828,6 +4848,7 @@ hfcmulti_init(struct pci_dev *pdev, const struct pci_device_id *ent)
4828 struct hfc_multi *hc; 4848 struct hfc_multi *hc;
4829 u_long flags; 4849 u_long flags;
4830 u_char dips = 0, pmj = 0; /* dip settings, port mode Jumpers */ 4850 u_char dips = 0, pmj = 0; /* dip settings, port mode Jumpers */
4851 int i;
4831 4852
4832 if (HFC_cnt >= MAX_CARDS) { 4853 if (HFC_cnt >= MAX_CARDS) {
4833 printk(KERN_ERR "too many cards (max=%d).\n", 4854 printk(KERN_ERR "too many cards (max=%d).\n",
@@ -4861,11 +4882,11 @@ hfcmulti_init(struct pci_dev *pdev, const struct pci_device_id *ent)
4861 hc->id = HFC_cnt; 4882 hc->id = HFC_cnt;
4862 hc->pcm = pcm[HFC_cnt]; 4883 hc->pcm = pcm[HFC_cnt];
4863 hc->io_mode = iomode[HFC_cnt]; 4884 hc->io_mode = iomode[HFC_cnt];
4864 if (dslot[HFC_cnt] < 0) { 4885 if (dslot[HFC_cnt] < 0 && hc->type == 1) {
4865 hc->dslot = 0; 4886 hc->dslot = 0;
4866 printk(KERN_INFO "HFC-E1 card has disabled D-channel, but " 4887 printk(KERN_INFO "HFC-E1 card has disabled D-channel, but "
4867 "31 B-channels\n"); 4888 "31 B-channels\n");
4868 } if (dslot[HFC_cnt] > 0 && dslot[HFC_cnt] < 32) { 4889 } if (dslot[HFC_cnt] > 0 && dslot[HFC_cnt] < 32 && hc->type == 1) {
4869 hc->dslot = dslot[HFC_cnt]; 4890 hc->dslot = dslot[HFC_cnt];
4870 printk(KERN_INFO "HFC-E1 card has alternating D-channel on " 4891 printk(KERN_INFO "HFC-E1 card has alternating D-channel on "
4871 "time slot %d\n", dslot[HFC_cnt]); 4892 "time slot %d\n", dslot[HFC_cnt]);
@@ -4876,9 +4897,17 @@ hfcmulti_init(struct pci_dev *pdev, const struct pci_device_id *ent)
4876 hc->masterclk = -1; 4897 hc->masterclk = -1;
4877 if (type[HFC_cnt] & 0x100) { 4898 if (type[HFC_cnt] & 0x100) {
4878 test_and_set_bit(HFC_CHIP_ULAW, &hc->chip); 4899 test_and_set_bit(HFC_CHIP_ULAW, &hc->chip);
4879 silence = 0xff; /* ulaw silence */ 4900 hc->silence = 0xff; /* ulaw silence */
4880 } else 4901 } else
4881 silence = 0x2a; /* alaw silence */ 4902 hc->silence = 0x2a; /* alaw silence */
4903 if ((poll >> 1) > sizeof(hc->silence_data)) {
4904 printk(KERN_ERR "HFCMULTI error: silence_data too small, "
4905 "please fix\n");
4906 return -EINVAL;
4907 }
4908 for (i = 0; i < (poll >> 1); i++)
4909 hc->silence_data[i] = hc->silence;
4910
4882 if (!(type[HFC_cnt] & 0x200)) 4911 if (!(type[HFC_cnt] & 0x200))
4883 test_and_set_bit(HFC_CHIP_DTMF, &hc->chip); 4912 test_and_set_bit(HFC_CHIP_DTMF, &hc->chip);
4884 4913
@@ -4945,9 +4974,7 @@ hfcmulti_init(struct pci_dev *pdev, const struct pci_device_id *ent)
4945 switch (m->dip_type) { 4974 switch (m->dip_type) {
4946 case DIP_4S: 4975 case DIP_4S:
4947 /* 4976 /*
4948 * get DIP Setting for beroNet 1S/2S/4S cards 4977 * Get DIP setting for beroNet 1S/2S/4S cards
4949 * check if Port Jumper config matches
4950 * module param 'protocol'
4951 * DIP Setting: (collect GPIO 13/14/15 (R_GPIO_IN1) + 4978 * DIP Setting: (collect GPIO 13/14/15 (R_GPIO_IN1) +
4952 * GPI 19/23 (R_GPI_IN2)) 4979 * GPI 19/23 (R_GPI_IN2))
4953 */ 4980 */
@@ -4966,9 +4993,8 @@ hfcmulti_init(struct pci_dev *pdev, const struct pci_device_id *ent)
4966 break; 4993 break;
4967 case DIP_8S: 4994 case DIP_8S:
4968 /* 4995 /*
4969 * get DIP Setting for beroNet 8S0+ cards 4996 * Get DIP Setting for beroNet 8S0+ cards
4970 * 4997 * Enable PCI auxbridge function
4971 * enable PCI auxbridge function
4972 */ 4998 */
4973 HFC_outb(hc, R_BRG_PCM_CFG, 1 | V_PCM_CLK); 4999 HFC_outb(hc, R_BRG_PCM_CFG, 1 | V_PCM_CLK);
4974 /* prepare access to auxport */ 5000 /* prepare access to auxport */
@@ -5003,6 +5029,10 @@ hfcmulti_init(struct pci_dev *pdev, const struct pci_device_id *ent)
5003 list_add_tail(&hc->list, &HFClist); 5029 list_add_tail(&hc->list, &HFClist);
5004 spin_unlock_irqrestore(&HFClock, flags); 5030 spin_unlock_irqrestore(&HFClock, flags);
5005 5031
5032 /* use as clock source */
5033 if (clock == HFC_cnt + 1)
5034 hc->iclock = mISDN_register_clock("HFCMulti", 0, clockctl, hc);
5035
5006 /* initialize hardware */ 5036 /* initialize hardware */
5007 ret_err = init_card(hc); 5037 ret_err = init_card(hc);
5008 if (ret_err) { 5038 if (ret_err) {
@@ -5137,8 +5167,7 @@ static struct pci_device_id hfmultipci_ids[] __devinitdata = {
5137 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD, 5167 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD,
5138 PCI_DEVICE_ID_CCD_HFC8S, 0, 0, H(14)}, /* old Eval */ 5168 PCI_DEVICE_ID_CCD_HFC8S, 0, 0, H(14)}, /* old Eval */
5139 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD, 5169 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD,
5140 PCI_SUBDEVICE_ID_CCD_IOB8STR, 0, 0, H(15)}, 5170 PCI_SUBDEVICE_ID_CCD_IOB8STR, 0, 0, H(15)}, /* IOB8ST Recording */
5141 /* IOB8ST Recording */
5142 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD, 5171 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD,
5143 PCI_SUBDEVICE_ID_CCD_IOB8ST, 0, 0, H(16)}, /* IOB8ST */ 5172 PCI_SUBDEVICE_ID_CCD_IOB8ST, 0, 0, H(16)}, /* IOB8ST */
5144 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD, 5173 { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC8S, PCI_VENDOR_ID_CCD,
@@ -5188,18 +5217,16 @@ hfcmulti_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
5188 struct hm_map *m = (struct hm_map *)ent->driver_data; 5217 struct hm_map *m = (struct hm_map *)ent->driver_data;
5189 int ret; 5218 int ret;
5190 5219
5191 if (m == NULL) { 5220 if (m == NULL && ent->vendor == PCI_VENDOR_ID_CCD && (
5192 if (ent->vendor == PCI_VENDOR_ID_CCD) 5221 ent->device == PCI_DEVICE_ID_CCD_HFC4S ||
5193 if (ent->device == PCI_DEVICE_ID_CCD_HFC4S || 5222 ent->device == PCI_DEVICE_ID_CCD_HFC8S ||
5194 ent->device == PCI_DEVICE_ID_CCD_HFC8S || 5223 ent->device == PCI_DEVICE_ID_CCD_HFCE1)) {
5195 ent->device == PCI_DEVICE_ID_CCD_HFCE1) 5224 printk(KERN_ERR
5196 printk(KERN_ERR 5225 "Unknown HFC multiport controller (vendor:%x device:%x "
5197 "unknown HFC multiport controller " 5226 "subvendor:%x subdevice:%x)\n", ent->vendor, ent->device,
5198 "(vendor:%x device:%x subvendor:%x " 5227 ent->subvendor, ent->subdevice);
5199 "subdevice:%x) Please contact the " 5228 printk(KERN_ERR
5200 "driver maintainer for support.\n", 5229 "Please contact the driver maintainer for support.\n");
5201 ent->vendor, ent->device,
5202 ent->subvendor, ent->subdevice);
5203 return -ENODEV; 5230 return -ENODEV;
5204 } 5231 }
5205 ret = hfcmulti_init(pdev, ent); 5232 ret = hfcmulti_init(pdev, ent);
@@ -5222,22 +5249,9 @@ HFCmulti_cleanup(void)
5222{ 5249{
5223 struct hfc_multi *card, *next; 5250 struct hfc_multi *card, *next;
5224 5251
5225 /* unload interrupt function symbol */ 5252 /* get rid of all devices of this driver */
5226 if (hfc_interrupt)
5227 symbol_put(ztdummy_extern_interrupt);
5228 if (register_interrupt)
5229 symbol_put(ztdummy_register_interrupt);
5230 if (unregister_interrupt) {
5231 if (interrupt_registered) {
5232 interrupt_registered = 0;
5233 unregister_interrupt();
5234 }
5235 symbol_put(ztdummy_unregister_interrupt);
5236 }
5237
5238 list_for_each_entry_safe(card, next, &HFClist, list) 5253 list_for_each_entry_safe(card, next, &HFClist, list)
5239 release_card(card); 5254 release_card(card);
5240 /* get rid of all devices of this driver */
5241 pci_unregister_driver(&hfcmultipci_driver); 5255 pci_unregister_driver(&hfcmultipci_driver);
5242} 5256}
5243 5257
@@ -5246,8 +5260,10 @@ HFCmulti_init(void)
5246{ 5260{
5247 int err; 5261 int err;
5248 5262
5263 printk(KERN_INFO "mISDN: HFC-multi driver %s\n", HFC_MULTI_VERSION);
5264
5249#ifdef IRQ_DEBUG 5265#ifdef IRQ_DEBUG
5250 printk(KERN_ERR "%s: IRQ_DEBUG IS ENABLED!\n", __func__); 5266 printk(KERN_DEBUG "%s: IRQ_DEBUG IS ENABLED!\n", __func__);
5251#endif 5267#endif
5252 5268
5253 spin_lock_init(&HFClock); 5269 spin_lock_init(&HFClock);
@@ -5256,22 +5272,11 @@ HFCmulti_init(void)
5256 if (debug & DEBUG_HFCMULTI_INIT) 5272 if (debug & DEBUG_HFCMULTI_INIT)
5257 printk(KERN_DEBUG "%s: init entered\n", __func__); 5273 printk(KERN_DEBUG "%s: init entered\n", __func__);
5258 5274
5259 hfc_interrupt = symbol_get(ztdummy_extern_interrupt);
5260 register_interrupt = symbol_get(ztdummy_register_interrupt);
5261 unregister_interrupt = symbol_get(ztdummy_unregister_interrupt);
5262 printk(KERN_INFO "mISDN: HFC-multi driver %s\n",
5263 hfcmulti_revision);
5264
5265 switch (poll) { 5275 switch (poll) {
5266 case 0: 5276 case 0:
5267 poll_timer = 6; 5277 poll_timer = 6;
5268 poll = 128; 5278 poll = 128;
5269 break; 5279 break;
5270 /*
5271 * wenn dieses break nochmal verschwindet,
5272 * gibt es heisse ohren :-)
5273 * "without the break you will get hot ears ???"
5274 */
5275 case 8: 5280 case 8:
5276 poll_timer = 2; 5281 poll_timer = 2;
5277 break; 5282 break;
@@ -5298,20 +5303,12 @@ HFCmulti_init(void)
5298 5303
5299 } 5304 }
5300 5305
5306 if (!clock)
5307 clock = 1;
5308
5301 err = pci_register_driver(&hfcmultipci_driver); 5309 err = pci_register_driver(&hfcmultipci_driver);
5302 if (err < 0) { 5310 if (err < 0) {
5303 printk(KERN_ERR "error registering pci driver: %x\n", err); 5311 printk(KERN_ERR "error registering pci driver: %x\n", err);
5304 if (hfc_interrupt)
5305 symbol_put(ztdummy_extern_interrupt);
5306 if (register_interrupt)
5307 symbol_put(ztdummy_register_interrupt);
5308 if (unregister_interrupt) {
5309 if (interrupt_registered) {
5310 interrupt_registered = 0;
5311 unregister_interrupt();
5312 }
5313 symbol_put(ztdummy_unregister_interrupt);
5314 }
5315 return err; 5312 return err;
5316 } 5313 }
5317 return 0; 5314 return 0;
diff --git a/drivers/isdn/hardware/mISDN/hfcpci.c b/drivers/isdn/hardware/mISDN/hfcpci.c
index cd8302af40eb..f0e14dfcf71d 100644
--- a/drivers/isdn/hardware/mISDN/hfcpci.c
+++ b/drivers/isdn/hardware/mISDN/hfcpci.c
@@ -23,6 +23,25 @@
23 * along with this program; if not, write to the Free Software 23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 * 25 *
26 * Module options:
27 *
28 * debug:
29 * NOTE: only one poll value must be given for all cards
30 * See hfc_pci.h for debug flags.
31 *
32 * poll:
33 * NOTE: only one poll value must be given for all cards
34 * Give the number of samples for each fifo process.
35 * By default 128 is used. Decrease to reduce delay, increase to
36 * reduce cpu load. If unsure, don't mess with it!
37 * A value of 128 will use controller's interrupt. Other values will
38 * use kernel timer, because the controller will not allow lower values
39 * than 128.
40 * Also note that the value depends on the kernel timer frequency.
41 * If kernel uses a frequency of 1000 Hz, steps of 8 samples are possible.
42 * If the kernel uses 100 Hz, steps of 80 samples are possible.
43 * If the kernel uses 300 Hz, steps of about 26 samples are possible.
44 *
26 */ 45 */
27 46
28#include <linux/module.h> 47#include <linux/module.h>
@@ -34,16 +53,16 @@
34 53
35static const char *hfcpci_revision = "2.0"; 54static const char *hfcpci_revision = "2.0";
36 55
37#define MAX_CARDS 8
38static int HFC_cnt; 56static int HFC_cnt;
39static uint debug; 57static uint debug;
58static uint poll, tics;
59struct timer_list hfc_tl;
60u32 hfc_jiffies;
40 61
41MODULE_AUTHOR("Karsten Keil"); 62MODULE_AUTHOR("Karsten Keil");
42MODULE_LICENSE("GPL"); 63MODULE_LICENSE("GPL");
43module_param(debug, uint, 0); 64module_param(debug, uint, S_IRUGO | S_IWUSR);
44 65module_param(poll, uint, S_IRUGO | S_IWUSR);
45static LIST_HEAD(HFClist);
46static DEFINE_RWLOCK(HFClock);
47 66
48enum { 67enum {
49 HFC_CCD_2BD0, 68 HFC_CCD_2BD0,
@@ -114,7 +133,6 @@ struct hfcPCI_hw {
114 133
115 134
116struct hfc_pci { 135struct hfc_pci {
117 struct list_head list;
118 u_char subtype; 136 u_char subtype;
119 u_char chanlimit; 137 u_char chanlimit;
120 u_char initdone; 138 u_char initdone;
@@ -520,9 +538,9 @@ receive_dmsg(struct hfc_pci *hc)
520} 538}
521 539
522/* 540/*
523 * check for transparent receive data and read max one threshold size if avail 541 * check for transparent receive data and read max one 'poll' size if avail
524 */ 542 */
525static int 543static void
526hfcpci_empty_fifo_trans(struct bchannel *bch, struct bzfifo *bz, u_char *bdata) 544hfcpci_empty_fifo_trans(struct bchannel *bch, struct bzfifo *bz, u_char *bdata)
527{ 545{
528 __le16 *z1r, *z2r; 546 __le16 *z1r, *z2r;
@@ -534,17 +552,19 @@ hfcpci_empty_fifo_trans(struct bchannel *bch, struct bzfifo *bz, u_char *bdata)
534 552
535 fcnt = le16_to_cpu(*z1r) - le16_to_cpu(*z2r); 553 fcnt = le16_to_cpu(*z1r) - le16_to_cpu(*z2r);
536 if (!fcnt) 554 if (!fcnt)
537 return 0; /* no data avail */ 555 return; /* no data avail */
538 556
539 if (fcnt <= 0) 557 if (fcnt <= 0)
540 fcnt += B_FIFO_SIZE; /* bytes actually buffered */ 558 fcnt += B_FIFO_SIZE; /* bytes actually buffered */
541 if (fcnt > HFCPCI_BTRANS_THRESHOLD)
542 fcnt = HFCPCI_BTRANS_THRESHOLD; /* limit size */
543
544 new_z2 = le16_to_cpu(*z2r) + fcnt; /* new position in fifo */ 559 new_z2 = le16_to_cpu(*z2r) + fcnt; /* new position in fifo */
545 if (new_z2 >= (B_FIFO_SIZE + B_SUB_VAL)) 560 if (new_z2 >= (B_FIFO_SIZE + B_SUB_VAL))
546 new_z2 -= B_FIFO_SIZE; /* buffer wrap */ 561 new_z2 -= B_FIFO_SIZE; /* buffer wrap */
547 562
563 if (fcnt > MAX_DATA_SIZE) { /* flush, if oversized */
564 *z2r = cpu_to_le16(new_z2); /* new position */
565 return;
566 }
567
548 bch->rx_skb = mI_alloc_skb(fcnt, GFP_ATOMIC); 568 bch->rx_skb = mI_alloc_skb(fcnt, GFP_ATOMIC);
549 if (bch->rx_skb) { 569 if (bch->rx_skb) {
550 ptr = skb_put(bch->rx_skb, fcnt); 570 ptr = skb_put(bch->rx_skb, fcnt);
@@ -569,7 +589,6 @@ hfcpci_empty_fifo_trans(struct bchannel *bch, struct bzfifo *bz, u_char *bdata)
569 printk(KERN_WARNING "HFCPCI: receive out of memory\n"); 589 printk(KERN_WARNING "HFCPCI: receive out of memory\n");
570 590
571 *z2r = cpu_to_le16(new_z2); /* new position */ 591 *z2r = cpu_to_le16(new_z2); /* new position */
572 return 1;
573} 592}
574 593
575/* 594/*
@@ -580,12 +599,11 @@ main_rec_hfcpci(struct bchannel *bch)
580{ 599{
581 struct hfc_pci *hc = bch->hw; 600 struct hfc_pci *hc = bch->hw;
582 int rcnt, real_fifo; 601 int rcnt, real_fifo;
583 int receive, count = 5; 602 int receive = 0, count = 5;
584 struct bzfifo *bz; 603 struct bzfifo *bz;
585 u_char *bdata; 604 u_char *bdata;
586 struct zt *zp; 605 struct zt *zp;
587 606
588
589 if ((bch->nr & 2) && (!hc->hw.bswapped)) { 607 if ((bch->nr & 2) && (!hc->hw.bswapped)) {
590 bz = &((union fifo_area *)(hc->hw.fifos))->b_chans.rxbz_b2; 608 bz = &((union fifo_area *)(hc->hw.fifos))->b_chans.rxbz_b2;
591 bdata = ((union fifo_area *)(hc->hw.fifos))->b_chans.rxdat_b2; 609 bdata = ((union fifo_area *)(hc->hw.fifos))->b_chans.rxdat_b2;
@@ -625,9 +643,10 @@ Begin:
625 receive = 1; 643 receive = 1;
626 else 644 else
627 receive = 0; 645 receive = 0;
628 } else if (test_bit(FLG_TRANSPARENT, &bch->Flags)) 646 } else if (test_bit(FLG_TRANSPARENT, &bch->Flags)) {
629 receive = hfcpci_empty_fifo_trans(bch, bz, bdata); 647 hfcpci_empty_fifo_trans(bch, bz, bdata);
630 else 648 return;
649 } else
631 receive = 0; 650 receive = 0;
632 if (count && receive) 651 if (count && receive)
633 goto Begin; 652 goto Begin;
@@ -751,11 +770,41 @@ hfcpci_fill_fifo(struct bchannel *bch)
751 /* fcnt contains available bytes in fifo */ 770 /* fcnt contains available bytes in fifo */
752 fcnt = B_FIFO_SIZE - fcnt; 771 fcnt = B_FIFO_SIZE - fcnt;
753 /* remaining bytes to send (bytes in fifo) */ 772 /* remaining bytes to send (bytes in fifo) */
773
774 /* "fill fifo if empty" feature */
775 if (test_bit(FLG_FILLEMPTY, &bch->Flags) && !fcnt) {
776 /* printk(KERN_DEBUG "%s: buffer empty, so we have "
777 "underrun\n", __func__); */
778 /* fill buffer, to prevent future underrun */
779 count = HFCPCI_FILLEMPTY;
780 new_z1 = le16_to_cpu(*z1t) + count;
781 /* new buffer Position */
782 if (new_z1 >= (B_FIFO_SIZE + B_SUB_VAL))
783 new_z1 -= B_FIFO_SIZE; /* buffer wrap */
784 dst = bdata + (le16_to_cpu(*z1t) - B_SUB_VAL);
785 maxlen = (B_FIFO_SIZE + B_SUB_VAL) - le16_to_cpu(*z1t);
786 /* end of fifo */
787 if (bch->debug & DEBUG_HW_BFIFO)
788 printk(KERN_DEBUG "hfcpci_FFt fillempty "
789 "fcnt(%d) maxl(%d) nz1(%x) dst(%p)\n",
790 fcnt, maxlen, new_z1, dst);
791 fcnt += count;
792 if (maxlen > count)
793 maxlen = count; /* limit size */
794 memset(dst, 0x2a, maxlen); /* first copy */
795 count -= maxlen; /* remaining bytes */
796 if (count) {
797 dst = bdata; /* start of buffer */
798 memset(dst, 0x2a, count);
799 }
800 *z1t = cpu_to_le16(new_z1); /* now send data */
801 }
802
754next_t_frame: 803next_t_frame:
755 count = bch->tx_skb->len - bch->tx_idx; 804 count = bch->tx_skb->len - bch->tx_idx;
756 /* maximum fill shall be HFCPCI_BTRANS_MAX */ 805 /* maximum fill shall be poll*2 */
757 if (count > HFCPCI_BTRANS_MAX - fcnt) 806 if (count > (poll << 1) - fcnt)
758 count = HFCPCI_BTRANS_MAX - fcnt; 807 count = (poll << 1) - fcnt;
759 if (count <= 0) 808 if (count <= 0)
760 return; 809 return;
761 /* data is suitable for fifo */ 810 /* data is suitable for fifo */
@@ -1135,37 +1184,37 @@ hfcpci_int(int intno, void *dev_id)
1135 val &= ~0x80; 1184 val &= ~0x80;
1136 Write_hfc(hc, HFCPCI_CTMT, hc->hw.ctmt | HFCPCI_CLTIMER); 1185 Write_hfc(hc, HFCPCI_CTMT, hc->hw.ctmt | HFCPCI_CLTIMER);
1137 } 1186 }
1138 if (val & 0x08) { 1187 if (val & 0x08) { /* B1 rx */
1139 bch = Sel_BCS(hc, hc->hw.bswapped ? 2 : 1); 1188 bch = Sel_BCS(hc, hc->hw.bswapped ? 2 : 1);
1140 if (bch) 1189 if (bch)
1141 main_rec_hfcpci(bch); 1190 main_rec_hfcpci(bch);
1142 else if (hc->dch.debug) 1191 else if (hc->dch.debug)
1143 printk(KERN_DEBUG "hfcpci spurious 0x08 IRQ\n"); 1192 printk(KERN_DEBUG "hfcpci spurious 0x08 IRQ\n");
1144 } 1193 }
1145 if (val & 0x10) { 1194 if (val & 0x10) { /* B2 rx */
1146 bch = Sel_BCS(hc, 2); 1195 bch = Sel_BCS(hc, 2);
1147 if (bch) 1196 if (bch)
1148 main_rec_hfcpci(bch); 1197 main_rec_hfcpci(bch);
1149 else if (hc->dch.debug) 1198 else if (hc->dch.debug)
1150 printk(KERN_DEBUG "hfcpci spurious 0x10 IRQ\n"); 1199 printk(KERN_DEBUG "hfcpci spurious 0x10 IRQ\n");
1151 } 1200 }
1152 if (val & 0x01) { 1201 if (val & 0x01) { /* B1 tx */
1153 bch = Sel_BCS(hc, hc->hw.bswapped ? 2 : 1); 1202 bch = Sel_BCS(hc, hc->hw.bswapped ? 2 : 1);
1154 if (bch) 1203 if (bch)
1155 tx_birq(bch); 1204 tx_birq(bch);
1156 else if (hc->dch.debug) 1205 else if (hc->dch.debug)
1157 printk(KERN_DEBUG "hfcpci spurious 0x01 IRQ\n"); 1206 printk(KERN_DEBUG "hfcpci spurious 0x01 IRQ\n");
1158 } 1207 }
1159 if (val & 0x02) { 1208 if (val & 0x02) { /* B2 tx */
1160 bch = Sel_BCS(hc, 2); 1209 bch = Sel_BCS(hc, 2);
1161 if (bch) 1210 if (bch)
1162 tx_birq(bch); 1211 tx_birq(bch);
1163 else if (hc->dch.debug) 1212 else if (hc->dch.debug)
1164 printk(KERN_DEBUG "hfcpci spurious 0x02 IRQ\n"); 1213 printk(KERN_DEBUG "hfcpci spurious 0x02 IRQ\n");
1165 } 1214 }
1166 if (val & 0x20) 1215 if (val & 0x20) /* D rx */
1167 receive_dmsg(hc); 1216 receive_dmsg(hc);
1168 if (val & 0x04) { /* dframe transmitted */ 1217 if (val & 0x04) { /* D tx */
1169 if (test_and_clear_bit(FLG_BUSY_TIMER, &hc->dch.Flags)) 1218 if (test_and_clear_bit(FLG_BUSY_TIMER, &hc->dch.Flags))
1170 del_timer(&hc->dch.timer); 1219 del_timer(&hc->dch.timer);
1171 tx_dirq(&hc->dch); 1220 tx_dirq(&hc->dch);
@@ -1283,14 +1332,16 @@ mode_hfcpci(struct bchannel *bch, int bc, int protocol)
1283 } 1332 }
1284 if (fifo2 & 2) { 1333 if (fifo2 & 2) {
1285 hc->hw.fifo_en |= HFCPCI_FIFOEN_B2; 1334 hc->hw.fifo_en |= HFCPCI_FIFOEN_B2;
1286 hc->hw.int_m1 |= (HFCPCI_INTS_B2TRANS + 1335 if (!tics)
1287 HFCPCI_INTS_B2REC); 1336 hc->hw.int_m1 |= (HFCPCI_INTS_B2TRANS +
1337 HFCPCI_INTS_B2REC);
1288 hc->hw.ctmt |= 2; 1338 hc->hw.ctmt |= 2;
1289 hc->hw.conn &= ~0x18; 1339 hc->hw.conn &= ~0x18;
1290 } else { 1340 } else {
1291 hc->hw.fifo_en |= HFCPCI_FIFOEN_B1; 1341 hc->hw.fifo_en |= HFCPCI_FIFOEN_B1;
1292 hc->hw.int_m1 |= (HFCPCI_INTS_B1TRANS + 1342 if (!tics)
1293 HFCPCI_INTS_B1REC); 1343 hc->hw.int_m1 |= (HFCPCI_INTS_B1TRANS +
1344 HFCPCI_INTS_B1REC);
1294 hc->hw.ctmt |= 1; 1345 hc->hw.ctmt |= 1;
1295 hc->hw.conn &= ~0x03; 1346 hc->hw.conn &= ~0x03;
1296 } 1347 }
@@ -1398,7 +1449,8 @@ set_hfcpci_rxtest(struct bchannel *bch, int protocol, int chan)
1398 if (chan & 2) { 1449 if (chan & 2) {
1399 hc->hw.sctrl_r |= SCTRL_B2_ENA; 1450 hc->hw.sctrl_r |= SCTRL_B2_ENA;
1400 hc->hw.fifo_en |= HFCPCI_FIFOEN_B2RX; 1451 hc->hw.fifo_en |= HFCPCI_FIFOEN_B2RX;
1401 hc->hw.int_m1 |= HFCPCI_INTS_B2REC; 1452 if (!tics)
1453 hc->hw.int_m1 |= HFCPCI_INTS_B2REC;
1402 hc->hw.ctmt |= 2; 1454 hc->hw.ctmt |= 2;
1403 hc->hw.conn &= ~0x18; 1455 hc->hw.conn &= ~0x18;
1404#ifdef REVERSE_BITORDER 1456#ifdef REVERSE_BITORDER
@@ -1407,7 +1459,8 @@ set_hfcpci_rxtest(struct bchannel *bch, int protocol, int chan)
1407 } else { 1459 } else {
1408 hc->hw.sctrl_r |= SCTRL_B1_ENA; 1460 hc->hw.sctrl_r |= SCTRL_B1_ENA;
1409 hc->hw.fifo_en |= HFCPCI_FIFOEN_B1RX; 1461 hc->hw.fifo_en |= HFCPCI_FIFOEN_B1RX;
1410 hc->hw.int_m1 |= HFCPCI_INTS_B1REC; 1462 if (!tics)
1463 hc->hw.int_m1 |= HFCPCI_INTS_B1REC;
1411 hc->hw.ctmt |= 1; 1464 hc->hw.ctmt |= 1;
1412 hc->hw.conn &= ~0x03; 1465 hc->hw.conn &= ~0x03;
1413#ifdef REVERSE_BITORDER 1466#ifdef REVERSE_BITORDER
@@ -1481,11 +1534,17 @@ deactivate_bchannel(struct bchannel *bch)
1481static int 1534static int
1482channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq) 1535channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq)
1483{ 1536{
1484 int ret = 0; 1537 int ret = 0;
1485 1538
1486 switch (cq->op) { 1539 switch (cq->op) {
1487 case MISDN_CTRL_GETOP: 1540 case MISDN_CTRL_GETOP:
1488 cq->op = 0; 1541 cq->op = MISDN_CTRL_FILL_EMPTY;
1542 break;
1543 case MISDN_CTRL_FILL_EMPTY: /* fill fifo, if empty */
1544 test_and_set_bit(FLG_FILLEMPTY, &bch->Flags);
1545 if (debug & DEBUG_HW_OPEN)
1546 printk(KERN_DEBUG "%s: FILL_EMPTY request (nr=%d "
1547 "off=%d)\n", __func__, bch->nr, !!cq->p1);
1489 break; 1548 break;
1490 default: 1549 default:
1491 printk(KERN_WARNING "%s: unknown Op %x\n", __func__, cq->op); 1550 printk(KERN_WARNING "%s: unknown Op %x\n", __func__, cq->op);
@@ -1859,6 +1918,10 @@ open_dchannel(struct hfc_pci *hc, struct mISDNchannel *ch,
1859 hc->dch.dev.id, __builtin_return_address(0)); 1918 hc->dch.dev.id, __builtin_return_address(0));
1860 if (rq->protocol == ISDN_P_NONE) 1919 if (rq->protocol == ISDN_P_NONE)
1861 return -EINVAL; 1920 return -EINVAL;
1921 if (rq->adr.channel == 1) {
1922 /* TODO: E-Channel */
1923 return -EINVAL;
1924 }
1862 if (!hc->initdone) { 1925 if (!hc->initdone) {
1863 if (rq->protocol == ISDN_P_TE_S0) { 1926 if (rq->protocol == ISDN_P_TE_S0) {
1864 err = create_l1(&hc->dch, hfc_l1callback); 1927 err = create_l1(&hc->dch, hfc_l1callback);
@@ -1874,6 +1937,11 @@ open_dchannel(struct hfc_pci *hc, struct mISDNchannel *ch,
1874 if (rq->protocol != ch->protocol) { 1937 if (rq->protocol != ch->protocol) {
1875 if (hc->hw.protocol == ISDN_P_TE_S0) 1938 if (hc->hw.protocol == ISDN_P_TE_S0)
1876 l1_event(hc->dch.l1, CLOSE_CHANNEL); 1939 l1_event(hc->dch.l1, CLOSE_CHANNEL);
1940 if (rq->protocol == ISDN_P_TE_S0) {
1941 err = create_l1(&hc->dch, hfc_l1callback);
1942 if (err)
1943 return err;
1944 }
1877 hc->hw.protocol = rq->protocol; 1945 hc->hw.protocol = rq->protocol;
1878 ch->protocol = rq->protocol; 1946 ch->protocol = rq->protocol;
1879 hfcpci_setmode(hc); 1947 hfcpci_setmode(hc);
@@ -1903,6 +1971,7 @@ open_bchannel(struct hfc_pci *hc, struct channel_req *rq)
1903 bch = &hc->bch[rq->adr.channel - 1]; 1971 bch = &hc->bch[rq->adr.channel - 1];
1904 if (test_and_set_bit(FLG_OPEN, &bch->Flags)) 1972 if (test_and_set_bit(FLG_OPEN, &bch->Flags))
1905 return -EBUSY; /* b-channel can be only open once */ 1973 return -EBUSY; /* b-channel can be only open once */
1974 test_and_clear_bit(FLG_FILLEMPTY, &bch->Flags);
1906 bch->ch.protocol = rq->protocol; 1975 bch->ch.protocol = rq->protocol;
1907 rq->ch = &bch->ch; /* TODO: E-channel */ 1976 rq->ch = &bch->ch; /* TODO: E-channel */
1908 if (!try_module_get(THIS_MODULE)) 1977 if (!try_module_get(THIS_MODULE))
@@ -1928,7 +1997,8 @@ hfc_dctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
1928 switch (cmd) { 1997 switch (cmd) {
1929 case OPEN_CHANNEL: 1998 case OPEN_CHANNEL:
1930 rq = arg; 1999 rq = arg;
1931 if (rq->adr.channel == 0) 2000 if ((rq->protocol == ISDN_P_TE_S0) ||
2001 (rq->protocol == ISDN_P_NT_S0))
1932 err = open_dchannel(hc, ch, rq); 2002 err = open_dchannel(hc, ch, rq);
1933 else 2003 else
1934 err = open_bchannel(hc, rq); 2004 err = open_bchannel(hc, rq);
@@ -2027,7 +2097,6 @@ release_card(struct hfc_pci *hc) {
2027 mISDN_freebchannel(&hc->bch[1]); 2097 mISDN_freebchannel(&hc->bch[1]);
2028 mISDN_freebchannel(&hc->bch[0]); 2098 mISDN_freebchannel(&hc->bch[0]);
2029 mISDN_freedchannel(&hc->dch); 2099 mISDN_freedchannel(&hc->dch);
2030 list_del(&hc->list);
2031 pci_set_drvdata(hc->pdev, NULL); 2100 pci_set_drvdata(hc->pdev, NULL);
2032 kfree(hc); 2101 kfree(hc);
2033} 2102}
@@ -2037,12 +2106,8 @@ setup_card(struct hfc_pci *card)
2037{ 2106{
2038 int err = -EINVAL; 2107 int err = -EINVAL;
2039 u_int i; 2108 u_int i;
2040 u_long flags;
2041 char name[MISDN_MAX_IDLEN]; 2109 char name[MISDN_MAX_IDLEN];
2042 2110
2043 if (HFC_cnt >= MAX_CARDS)
2044 return -EINVAL; /* maybe better value */
2045
2046 card->dch.debug = debug; 2111 card->dch.debug = debug;
2047 spin_lock_init(&card->lock); 2112 spin_lock_init(&card->lock);
2048 mISDN_initdchannel(&card->dch, MAX_DFRAME_LEN_L1, ph_state); 2113 mISDN_initdchannel(&card->dch, MAX_DFRAME_LEN_L1, ph_state);
@@ -2068,13 +2133,10 @@ setup_card(struct hfc_pci *card)
2068 if (err) 2133 if (err)
2069 goto error; 2134 goto error;
2070 snprintf(name, MISDN_MAX_IDLEN - 1, "hfc-pci.%d", HFC_cnt + 1); 2135 snprintf(name, MISDN_MAX_IDLEN - 1, "hfc-pci.%d", HFC_cnt + 1);
2071 err = mISDN_register_device(&card->dch.dev, name); 2136 err = mISDN_register_device(&card->dch.dev, &card->pdev->dev, name);
2072 if (err) 2137 if (err)
2073 goto error; 2138 goto error;
2074 HFC_cnt++; 2139 HFC_cnt++;
2075 write_lock_irqsave(&HFClock, flags);
2076 list_add_tail(&card->list, &HFClist);
2077 write_unlock_irqrestore(&HFClock, flags);
2078 printk(KERN_INFO "HFC %d cards installed\n", HFC_cnt); 2140 printk(KERN_INFO "HFC %d cards installed\n", HFC_cnt);
2079 return 0; 2141 return 0;
2080error: 2142error:
@@ -2210,15 +2272,12 @@ static void __devexit
2210hfc_remove_pci(struct pci_dev *pdev) 2272hfc_remove_pci(struct pci_dev *pdev)
2211{ 2273{
2212 struct hfc_pci *card = pci_get_drvdata(pdev); 2274 struct hfc_pci *card = pci_get_drvdata(pdev);
2213 u_long flags;
2214 2275
2215 if (card) { 2276 if (card)
2216 write_lock_irqsave(&HFClock, flags);
2217 release_card(card); 2277 release_card(card);
2218 write_unlock_irqrestore(&HFClock, flags); 2278 else
2219 } else
2220 if (debug) 2279 if (debug)
2221 printk(KERN_WARNING "%s: drvdata allready removed\n", 2280 printk(KERN_WARNING "%s: drvdata already removed\n",
2222 __func__); 2281 __func__);
2223} 2282}
2224 2283
@@ -2230,25 +2289,97 @@ static struct pci_driver hfc_driver = {
2230 .id_table = hfc_ids, 2289 .id_table = hfc_ids,
2231}; 2290};
2232 2291
2292static int
2293_hfcpci_softirq(struct device *dev, void *arg)
2294{
2295 struct hfc_pci *hc = dev_get_drvdata(dev);
2296 struct bchannel *bch;
2297 if (hc == NULL)
2298 return 0;
2299
2300 if (hc->hw.int_m2 & HFCPCI_IRQ_ENABLE) {
2301 spin_lock(&hc->lock);
2302 bch = Sel_BCS(hc, hc->hw.bswapped ? 2 : 1);
2303 if (bch && bch->state == ISDN_P_B_RAW) { /* B1 rx&tx */
2304 main_rec_hfcpci(bch);
2305 tx_birq(bch);
2306 }
2307 bch = Sel_BCS(hc, hc->hw.bswapped ? 1 : 2);
2308 if (bch && bch->state == ISDN_P_B_RAW) { /* B2 rx&tx */
2309 main_rec_hfcpci(bch);
2310 tx_birq(bch);
2311 }
2312 spin_unlock(&hc->lock);
2313 }
2314 return 0;
2315}
2316
2317static void
2318hfcpci_softirq(void *arg)
2319{
2320 (void) driver_for_each_device(&hfc_driver.driver, NULL, arg,
2321 _hfcpci_softirq);
2322
2323 /* if next event would be in the past ... */
2324 if ((s32)(hfc_jiffies + tics - jiffies) <= 0)
2325 hfc_jiffies = jiffies + 1;
2326 else
2327 hfc_jiffies += tics;
2328 hfc_tl.expires = hfc_jiffies;
2329 add_timer(&hfc_tl);
2330}
2331
2233static int __init 2332static int __init
2234HFC_init(void) 2333HFC_init(void)
2235{ 2334{
2236 int err; 2335 int err;
2237 2336
2337 if (!poll)
2338 poll = HFCPCI_BTRANS_THRESHOLD;
2339
2340 if (poll != HFCPCI_BTRANS_THRESHOLD) {
2341 tics = (poll * HZ) / 8000;
2342 if (tics < 1)
2343 tics = 1;
2344 poll = (tics * 8000) / HZ;
2345 if (poll > 256 || poll < 8) {
2346 printk(KERN_ERR "%s: Wrong poll value %d not in range "
2347 "of 8..256.\n", __func__, poll);
2348 err = -EINVAL;
2349 return err;
2350 }
2351 }
2352 if (poll != HFCPCI_BTRANS_THRESHOLD) {
2353 printk(KERN_INFO "%s: Using alternative poll value of %d\n",
2354 __func__, poll);
2355 hfc_tl.function = (void *)hfcpci_softirq;
2356 hfc_tl.data = 0;
2357 init_timer(&hfc_tl);
2358 hfc_tl.expires = jiffies + tics;
2359 hfc_jiffies = hfc_tl.expires;
2360 add_timer(&hfc_tl);
2361 } else
2362 tics = 0; /* indicate the use of controller's timer */
2363
2238 err = pci_register_driver(&hfc_driver); 2364 err = pci_register_driver(&hfc_driver);
2365 if (err) {
2366 if (timer_pending(&hfc_tl))
2367 del_timer(&hfc_tl);
2368 }
2369
2239 return err; 2370 return err;
2240} 2371}
2241 2372
2242static void __exit 2373static void __exit
2243HFC_cleanup(void) 2374HFC_cleanup(void)
2244{ 2375{
2245 struct hfc_pci *card, *next; 2376 if (timer_pending(&hfc_tl))
2377 del_timer(&hfc_tl);
2246 2378
2247 list_for_each_entry_safe(card, next, &HFClist, list) {
2248 release_card(card);
2249 }
2250 pci_unregister_driver(&hfc_driver); 2379 pci_unregister_driver(&hfc_driver);
2251} 2380}
2252 2381
2253module_init(HFC_init); 2382module_init(HFC_init);
2254module_exit(HFC_cleanup); 2383module_exit(HFC_cleanup);
2384
2385MODULE_DEVICE_TABLE(pci, hfc_ids);
diff --git a/drivers/isdn/hardware/mISDN/hfcsusb.c b/drivers/isdn/hardware/mISDN/hfcsusb.c
new file mode 100644
index 000000000000..ba6925fbf38a
--- /dev/null
+++ b/drivers/isdn/hardware/mISDN/hfcsusb.c
@@ -0,0 +1,2196 @@
1/* hfcsusb.c
2 * mISDN driver for Colognechip HFC-S USB chip
3 *
4 * Copyright 2001 by Peter Sprenger (sprenger@moving-bytes.de)
5 * Copyright 2008 by Martin Bachem (info@bachem-it.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, or (at your option)
10 * 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 * module params
23 * debug=<n>, default=0, with n=0xHHHHGGGG
24 * H - l1 driver flags described in hfcsusb.h
25 * G - common mISDN debug flags described at mISDNhw.h
26 *
27 * poll=<n>, default 128
28 * n : burst size of PH_DATA_IND at transparent rx data
29 *
30 */
31
32#include <linux/module.h>
33#include <linux/delay.h>
34#include <linux/usb.h>
35#include <linux/mISDNhw.h>
36#include "hfcsusb.h"
37
38const char *hfcsusb_rev = "Revision: 0.3.3 (socket), 2008-11-05";
39
40static unsigned int debug;
41static int poll = DEFAULT_TRANSP_BURST_SZ;
42
43static LIST_HEAD(HFClist);
44static DEFINE_RWLOCK(HFClock);
45
46
47MODULE_AUTHOR("Martin Bachem");
48MODULE_LICENSE("GPL");
49module_param(debug, uint, S_IRUGO | S_IWUSR);
50module_param(poll, int, 0);
51
52static int hfcsusb_cnt;
53
54/* some function prototypes */
55static void hfcsusb_ph_command(struct hfcsusb *hw, u_char command);
56static void release_hw(struct hfcsusb *hw);
57static void reset_hfcsusb(struct hfcsusb *hw);
58static void setPortMode(struct hfcsusb *hw);
59static void hfcsusb_start_endpoint(struct hfcsusb *hw, int channel);
60static void hfcsusb_stop_endpoint(struct hfcsusb *hw, int channel);
61static int hfcsusb_setup_bch(struct bchannel *bch, int protocol);
62static void deactivate_bchannel(struct bchannel *bch);
63static void hfcsusb_ph_info(struct hfcsusb *hw);
64
65/* start next background transfer for control channel */
66static void
67ctrl_start_transfer(struct hfcsusb *hw)
68{
69 if (debug & DBG_HFC_CALL_TRACE)
70 printk(KERN_DEBUG "%s: %s\n", hw->name, __func__);
71
72 if (hw->ctrl_cnt) {
73 hw->ctrl_urb->pipe = hw->ctrl_out_pipe;
74 hw->ctrl_urb->setup_packet = (u_char *)&hw->ctrl_write;
75 hw->ctrl_urb->transfer_buffer = NULL;
76 hw->ctrl_urb->transfer_buffer_length = 0;
77 hw->ctrl_write.wIndex =
78 cpu_to_le16(hw->ctrl_buff[hw->ctrl_out_idx].hfcs_reg);
79 hw->ctrl_write.wValue =
80 cpu_to_le16(hw->ctrl_buff[hw->ctrl_out_idx].reg_val);
81
82 usb_submit_urb(hw->ctrl_urb, GFP_ATOMIC);
83 }
84}
85
86/*
87 * queue a control transfer request to write HFC-S USB
88 * chip register using CTRL resuest queue
89 */
90static int write_reg(struct hfcsusb *hw, __u8 reg, __u8 val)
91{
92 struct ctrl_buf *buf;
93
94 if (debug & DBG_HFC_CALL_TRACE)
95 printk(KERN_DEBUG "%s: %s reg(0x%02x) val(0x%02x)\n",
96 hw->name, __func__, reg, val);
97
98 spin_lock(&hw->ctrl_lock);
99 if (hw->ctrl_cnt >= HFC_CTRL_BUFSIZE)
100 return 1;
101 buf = &hw->ctrl_buff[hw->ctrl_in_idx];
102 buf->hfcs_reg = reg;
103 buf->reg_val = val;
104 if (++hw->ctrl_in_idx >= HFC_CTRL_BUFSIZE)
105 hw->ctrl_in_idx = 0;
106 if (++hw->ctrl_cnt == 1)
107 ctrl_start_transfer(hw);
108 spin_unlock(&hw->ctrl_lock);
109
110 return 0;
111}
112
113/* control completion routine handling background control cmds */
114static void
115ctrl_complete(struct urb *urb)
116{
117 struct hfcsusb *hw = (struct hfcsusb *) urb->context;
118 struct ctrl_buf *buf;
119
120 if (debug & DBG_HFC_CALL_TRACE)
121 printk(KERN_DEBUG "%s: %s\n", hw->name, __func__);
122
123 urb->dev = hw->dev;
124 if (hw->ctrl_cnt) {
125 buf = &hw->ctrl_buff[hw->ctrl_out_idx];
126 hw->ctrl_cnt--; /* decrement actual count */
127 if (++hw->ctrl_out_idx >= HFC_CTRL_BUFSIZE)
128 hw->ctrl_out_idx = 0; /* pointer wrap */
129
130 ctrl_start_transfer(hw); /* start next transfer */
131 }
132}
133
134/* handle LED bits */
135static void
136set_led_bit(struct hfcsusb *hw, signed short led_bits, int set_on)
137{
138 if (set_on) {
139 if (led_bits < 0)
140 hw->led_state &= ~abs(led_bits);
141 else
142 hw->led_state |= led_bits;
143 } else {
144 if (led_bits < 0)
145 hw->led_state |= abs(led_bits);
146 else
147 hw->led_state &= ~led_bits;
148 }
149}
150
151/* handle LED requests */
152static void
153handle_led(struct hfcsusb *hw, int event)
154{
155 struct hfcsusb_vdata *driver_info = (struct hfcsusb_vdata *)
156 hfcsusb_idtab[hw->vend_idx].driver_info;
157 __u8 tmpled;
158
159 if (driver_info->led_scheme == LED_OFF)
160 return;
161 tmpled = hw->led_state;
162
163 switch (event) {
164 case LED_POWER_ON:
165 set_led_bit(hw, driver_info->led_bits[0], 1);
166 set_led_bit(hw, driver_info->led_bits[1], 0);
167 set_led_bit(hw, driver_info->led_bits[2], 0);
168 set_led_bit(hw, driver_info->led_bits[3], 0);
169 break;
170 case LED_POWER_OFF:
171 set_led_bit(hw, driver_info->led_bits[0], 0);
172 set_led_bit(hw, driver_info->led_bits[1], 0);
173 set_led_bit(hw, driver_info->led_bits[2], 0);
174 set_led_bit(hw, driver_info->led_bits[3], 0);
175 break;
176 case LED_S0_ON:
177 set_led_bit(hw, driver_info->led_bits[1], 1);
178 break;
179 case LED_S0_OFF:
180 set_led_bit(hw, driver_info->led_bits[1], 0);
181 break;
182 case LED_B1_ON:
183 set_led_bit(hw, driver_info->led_bits[2], 1);
184 break;
185 case LED_B1_OFF:
186 set_led_bit(hw, driver_info->led_bits[2], 0);
187 break;
188 case LED_B2_ON:
189 set_led_bit(hw, driver_info->led_bits[3], 1);
190 break;
191 case LED_B2_OFF:
192 set_led_bit(hw, driver_info->led_bits[3], 0);
193 break;
194 }
195
196 if (hw->led_state != tmpled) {
197 if (debug & DBG_HFC_CALL_TRACE)
198 printk(KERN_DEBUG "%s: %s reg(0x%02x) val(x%02x)\n",
199 hw->name, __func__,
200 HFCUSB_P_DATA, hw->led_state);
201
202 write_reg(hw, HFCUSB_P_DATA, hw->led_state);
203 }
204}
205
206/*
207 * Layer2 -> Layer 1 Bchannel data
208 */
209static int
210hfcusb_l2l1B(struct mISDNchannel *ch, struct sk_buff *skb)
211{
212 struct bchannel *bch = container_of(ch, struct bchannel, ch);
213 struct hfcsusb *hw = bch->hw;
214 int ret = -EINVAL;
215 struct mISDNhead *hh = mISDN_HEAD_P(skb);
216 u_long flags;
217
218 if (debug & DBG_HFC_CALL_TRACE)
219 printk(KERN_DEBUG "%s: %s\n", hw->name, __func__);
220
221 switch (hh->prim) {
222 case PH_DATA_REQ:
223 spin_lock_irqsave(&hw->lock, flags);
224 ret = bchannel_senddata(bch, skb);
225 spin_unlock_irqrestore(&hw->lock, flags);
226 if (debug & DBG_HFC_CALL_TRACE)
227 printk(KERN_DEBUG "%s: %s PH_DATA_REQ ret(%i)\n",
228 hw->name, __func__, ret);
229 if (ret > 0) {
230 /*
231 * other l1 drivers don't send early confirms on
232 * transp data, but hfcsusb does because tx_next
233 * skb is needed in tx_iso_complete()
234 */
235 queue_ch_frame(ch, PH_DATA_CNF, hh->id, NULL);
236 ret = 0;
237 }
238 return ret;
239 case PH_ACTIVATE_REQ:
240 if (!test_and_set_bit(FLG_ACTIVE, &bch->Flags)) {
241 hfcsusb_start_endpoint(hw, bch->nr);
242 ret = hfcsusb_setup_bch(bch, ch->protocol);
243 } else
244 ret = 0;
245 if (!ret)
246 _queue_data(ch, PH_ACTIVATE_IND, MISDN_ID_ANY,
247 0, NULL, GFP_KERNEL);
248 break;
249 case PH_DEACTIVATE_REQ:
250 deactivate_bchannel(bch);
251 _queue_data(ch, PH_DEACTIVATE_IND, MISDN_ID_ANY,
252 0, NULL, GFP_KERNEL);
253 ret = 0;
254 break;
255 }
256 if (!ret)
257 dev_kfree_skb(skb);
258 return ret;
259}
260
261/*
262 * send full D/B channel status information
263 * as MPH_INFORMATION_IND
264 */
265static void
266hfcsusb_ph_info(struct hfcsusb *hw)
267{
268 struct ph_info *phi;
269 struct dchannel *dch = &hw->dch;
270 int i;
271
272 phi = kzalloc(sizeof(struct ph_info) +
273 dch->dev.nrbchan * sizeof(struct ph_info_ch), GFP_ATOMIC);
274 phi->dch.ch.protocol = hw->protocol;
275 phi->dch.ch.Flags = dch->Flags;
276 phi->dch.state = dch->state;
277 phi->dch.num_bch = dch->dev.nrbchan;
278 for (i = 0; i < dch->dev.nrbchan; i++) {
279 phi->bch[i].protocol = hw->bch[i].ch.protocol;
280 phi->bch[i].Flags = hw->bch[i].Flags;
281 }
282 _queue_data(&dch->dev.D, MPH_INFORMATION_IND, MISDN_ID_ANY,
283 sizeof(struct ph_info_dch) + dch->dev.nrbchan *
284 sizeof(struct ph_info_ch), phi, GFP_ATOMIC);
285}
286
287/*
288 * Layer2 -> Layer 1 Dchannel data
289 */
290static int
291hfcusb_l2l1D(struct mISDNchannel *ch, struct sk_buff *skb)
292{
293 struct mISDNdevice *dev = container_of(ch, struct mISDNdevice, D);
294 struct dchannel *dch = container_of(dev, struct dchannel, dev);
295 struct mISDNhead *hh = mISDN_HEAD_P(skb);
296 struct hfcsusb *hw = dch->hw;
297 int ret = -EINVAL;
298 u_long flags;
299
300 switch (hh->prim) {
301 case PH_DATA_REQ:
302 if (debug & DBG_HFC_CALL_TRACE)
303 printk(KERN_DEBUG "%s: %s: PH_DATA_REQ\n",
304 hw->name, __func__);
305
306 spin_lock_irqsave(&hw->lock, flags);
307 ret = dchannel_senddata(dch, skb);
308 spin_unlock_irqrestore(&hw->lock, flags);
309 if (ret > 0) {
310 ret = 0;
311 queue_ch_frame(ch, PH_DATA_CNF, hh->id, NULL);
312 }
313 break;
314
315 case PH_ACTIVATE_REQ:
316 if (debug & DBG_HFC_CALL_TRACE)
317 printk(KERN_DEBUG "%s: %s: PH_ACTIVATE_REQ %s\n",
318 hw->name, __func__,
319 (hw->protocol == ISDN_P_NT_S0) ? "NT" : "TE");
320
321 if (hw->protocol == ISDN_P_NT_S0) {
322 ret = 0;
323 if (test_bit(FLG_ACTIVE, &dch->Flags)) {
324 _queue_data(&dch->dev.D,
325 PH_ACTIVATE_IND, MISDN_ID_ANY, 0,
326 NULL, GFP_ATOMIC);
327 } else {
328 hfcsusb_ph_command(hw,
329 HFC_L1_ACTIVATE_NT);
330 test_and_set_bit(FLG_L2_ACTIVATED,
331 &dch->Flags);
332 }
333 } else {
334 hfcsusb_ph_command(hw, HFC_L1_ACTIVATE_TE);
335 ret = l1_event(dch->l1, hh->prim);
336 }
337 break;
338
339 case PH_DEACTIVATE_REQ:
340 if (debug & DBG_HFC_CALL_TRACE)
341 printk(KERN_DEBUG "%s: %s: PH_DEACTIVATE_REQ\n",
342 hw->name, __func__);
343 test_and_clear_bit(FLG_L2_ACTIVATED, &dch->Flags);
344
345 if (hw->protocol == ISDN_P_NT_S0) {
346 hfcsusb_ph_command(hw, HFC_L1_DEACTIVATE_NT);
347 spin_lock_irqsave(&hw->lock, flags);
348 skb_queue_purge(&dch->squeue);
349 if (dch->tx_skb) {
350 dev_kfree_skb(dch->tx_skb);
351 dch->tx_skb = NULL;
352 }
353 dch->tx_idx = 0;
354 if (dch->rx_skb) {
355 dev_kfree_skb(dch->rx_skb);
356 dch->rx_skb = NULL;
357 }
358 test_and_clear_bit(FLG_TX_BUSY, &dch->Flags);
359 spin_unlock_irqrestore(&hw->lock, flags);
360#ifdef FIXME
361 if (test_and_clear_bit(FLG_L1_BUSY, &dch->Flags))
362 dchannel_sched_event(&hc->dch, D_CLEARBUSY);
363#endif
364 ret = 0;
365 } else
366 ret = l1_event(dch->l1, hh->prim);
367 break;
368 case MPH_INFORMATION_REQ:
369 hfcsusb_ph_info(hw);
370 ret = 0;
371 break;
372 }
373
374 return ret;
375}
376
377/*
378 * Layer 1 callback function
379 */
380static int
381hfc_l1callback(struct dchannel *dch, u_int cmd)
382{
383 struct hfcsusb *hw = dch->hw;
384
385 if (debug & DBG_HFC_CALL_TRACE)
386 printk(KERN_DEBUG "%s: %s cmd 0x%x\n",
387 hw->name, __func__, cmd);
388
389 switch (cmd) {
390 case INFO3_P8:
391 case INFO3_P10:
392 case HW_RESET_REQ:
393 case HW_POWERUP_REQ:
394 break;
395
396 case HW_DEACT_REQ:
397 skb_queue_purge(&dch->squeue);
398 if (dch->tx_skb) {
399 dev_kfree_skb(dch->tx_skb);
400 dch->tx_skb = NULL;
401 }
402 dch->tx_idx = 0;
403 if (dch->rx_skb) {
404 dev_kfree_skb(dch->rx_skb);
405 dch->rx_skb = NULL;
406 }
407 test_and_clear_bit(FLG_TX_BUSY, &dch->Flags);
408 break;
409 case PH_ACTIVATE_IND:
410 test_and_set_bit(FLG_ACTIVE, &dch->Flags);
411 _queue_data(&dch->dev.D, cmd, MISDN_ID_ANY, 0, NULL,
412 GFP_ATOMIC);
413 break;
414 case PH_DEACTIVATE_IND:
415 test_and_clear_bit(FLG_ACTIVE, &dch->Flags);
416 _queue_data(&dch->dev.D, cmd, MISDN_ID_ANY, 0, NULL,
417 GFP_ATOMIC);
418 break;
419 default:
420 if (dch->debug & DEBUG_HW)
421 printk(KERN_DEBUG "%s: %s: unknown cmd %x\n",
422 hw->name, __func__, cmd);
423 return -1;
424 }
425 hfcsusb_ph_info(hw);
426 return 0;
427}
428
429static int
430open_dchannel(struct hfcsusb *hw, struct mISDNchannel *ch,
431 struct channel_req *rq)
432{
433 int err = 0;
434
435 if (debug & DEBUG_HW_OPEN)
436 printk(KERN_DEBUG "%s: %s: dev(%d) open addr(%i) from %p\n",
437 hw->name, __func__, hw->dch.dev.id, rq->adr.channel,
438 __builtin_return_address(0));
439 if (rq->protocol == ISDN_P_NONE)
440 return -EINVAL;
441
442 test_and_clear_bit(FLG_ACTIVE, &hw->dch.Flags);
443 test_and_clear_bit(FLG_ACTIVE, &hw->ech.Flags);
444 hfcsusb_start_endpoint(hw, HFC_CHAN_D);
445
446 /* E-Channel logging */
447 if (rq->adr.channel == 1) {
448 if (hw->fifos[HFCUSB_PCM_RX].pipe) {
449 hfcsusb_start_endpoint(hw, HFC_CHAN_E);
450 set_bit(FLG_ACTIVE, &hw->ech.Flags);
451 _queue_data(&hw->ech.dev.D, PH_ACTIVATE_IND,
452 MISDN_ID_ANY, 0, NULL, GFP_ATOMIC);
453 } else
454 return -EINVAL;
455 }
456
457 if (!hw->initdone) {
458 hw->protocol = rq->protocol;
459 if (rq->protocol == ISDN_P_TE_S0) {
460 err = create_l1(&hw->dch, hfc_l1callback);
461 if (err)
462 return err;
463 }
464 setPortMode(hw);
465 ch->protocol = rq->protocol;
466 hw->initdone = 1;
467 } else {
468 if (rq->protocol != ch->protocol)
469 return -EPROTONOSUPPORT;
470 }
471
472 if (((ch->protocol == ISDN_P_NT_S0) && (hw->dch.state == 3)) ||
473 ((ch->protocol == ISDN_P_TE_S0) && (hw->dch.state == 7)))
474 _queue_data(ch, PH_ACTIVATE_IND, MISDN_ID_ANY,
475 0, NULL, GFP_KERNEL);
476 rq->ch = ch;
477 if (!try_module_get(THIS_MODULE))
478 printk(KERN_WARNING "%s: %s: cannot get module\n",
479 hw->name, __func__);
480 return 0;
481}
482
483static int
484open_bchannel(struct hfcsusb *hw, struct channel_req *rq)
485{
486 struct bchannel *bch;
487
488 if (rq->adr.channel > 2)
489 return -EINVAL;
490 if (rq->protocol == ISDN_P_NONE)
491 return -EINVAL;
492
493 if (debug & DBG_HFC_CALL_TRACE)
494 printk(KERN_DEBUG "%s: %s B%i\n",
495 hw->name, __func__, rq->adr.channel);
496
497 bch = &hw->bch[rq->adr.channel - 1];
498 if (test_and_set_bit(FLG_OPEN, &bch->Flags))
499 return -EBUSY; /* b-channel can be only open once */
500 test_and_clear_bit(FLG_FILLEMPTY, &bch->Flags);
501 bch->ch.protocol = rq->protocol;
502 rq->ch = &bch->ch;
503
504 /* start USB endpoint for bchannel */
505 if (rq->adr.channel == 1)
506 hfcsusb_start_endpoint(hw, HFC_CHAN_B1);
507 else
508 hfcsusb_start_endpoint(hw, HFC_CHAN_B2);
509
510 if (!try_module_get(THIS_MODULE))
511 printk(KERN_WARNING "%s: %s:cannot get module\n",
512 hw->name, __func__);
513 return 0;
514}
515
516static int
517channel_ctrl(struct hfcsusb *hw, struct mISDN_ctrl_req *cq)
518{
519 int ret = 0;
520
521 if (debug & DBG_HFC_CALL_TRACE)
522 printk(KERN_DEBUG "%s: %s op(0x%x) channel(0x%x)\n",
523 hw->name, __func__, (cq->op), (cq->channel));
524
525 switch (cq->op) {
526 case MISDN_CTRL_GETOP:
527 cq->op = MISDN_CTRL_LOOP | MISDN_CTRL_CONNECT |
528 MISDN_CTRL_DISCONNECT;
529 break;
530 default:
531 printk(KERN_WARNING "%s: %s: unknown Op %x\n",
532 hw->name, __func__, cq->op);
533 ret = -EINVAL;
534 break;
535 }
536 return ret;
537}
538
539/*
540 * device control function
541 */
542static int
543hfc_dctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
544{
545 struct mISDNdevice *dev = container_of(ch, struct mISDNdevice, D);
546 struct dchannel *dch = container_of(dev, struct dchannel, dev);
547 struct hfcsusb *hw = dch->hw;
548 struct channel_req *rq;
549 int err = 0;
550
551 if (dch->debug & DEBUG_HW)
552 printk(KERN_DEBUG "%s: %s: cmd:%x %p\n",
553 hw->name, __func__, cmd, arg);
554 switch (cmd) {
555 case OPEN_CHANNEL:
556 rq = arg;
557 if ((rq->protocol == ISDN_P_TE_S0) ||
558 (rq->protocol == ISDN_P_NT_S0))
559 err = open_dchannel(hw, ch, rq);
560 else
561 err = open_bchannel(hw, rq);
562 if (!err)
563 hw->open++;
564 break;
565 case CLOSE_CHANNEL:
566 hw->open--;
567 if (debug & DEBUG_HW_OPEN)
568 printk(KERN_DEBUG
569 "%s: %s: dev(%d) close from %p (open %d)\n",
570 hw->name, __func__, hw->dch.dev.id,
571 __builtin_return_address(0), hw->open);
572 if (!hw->open) {
573 hfcsusb_stop_endpoint(hw, HFC_CHAN_D);
574 if (hw->fifos[HFCUSB_PCM_RX].pipe)
575 hfcsusb_stop_endpoint(hw, HFC_CHAN_E);
576 handle_led(hw, LED_POWER_ON);
577 }
578 module_put(THIS_MODULE);
579 break;
580 case CONTROL_CHANNEL:
581 err = channel_ctrl(hw, arg);
582 break;
583 default:
584 if (dch->debug & DEBUG_HW)
585 printk(KERN_DEBUG "%s: %s: unknown command %x\n",
586 hw->name, __func__, cmd);
587 return -EINVAL;
588 }
589 return err;
590}
591
592/*
593 * S0 TE state change event handler
594 */
595static void
596ph_state_te(struct dchannel *dch)
597{
598 struct hfcsusb *hw = dch->hw;
599
600 if (debug & DEBUG_HW) {
601 if (dch->state <= HFC_MAX_TE_LAYER1_STATE)
602 printk(KERN_DEBUG "%s: %s: %s\n", hw->name, __func__,
603 HFC_TE_LAYER1_STATES[dch->state]);
604 else
605 printk(KERN_DEBUG "%s: %s: TE F%d\n",
606 hw->name, __func__, dch->state);
607 }
608
609 switch (dch->state) {
610 case 0:
611 l1_event(dch->l1, HW_RESET_IND);
612 break;
613 case 3:
614 l1_event(dch->l1, HW_DEACT_IND);
615 break;
616 case 5:
617 case 8:
618 l1_event(dch->l1, ANYSIGNAL);
619 break;
620 case 6:
621 l1_event(dch->l1, INFO2);
622 break;
623 case 7:
624 l1_event(dch->l1, INFO4_P8);
625 break;
626 }
627 if (dch->state == 7)
628 handle_led(hw, LED_S0_ON);
629 else
630 handle_led(hw, LED_S0_OFF);
631}
632
633/*
634 * S0 NT state change event handler
635 */
636static void
637ph_state_nt(struct dchannel *dch)
638{
639 struct hfcsusb *hw = dch->hw;
640
641 if (debug & DEBUG_HW) {
642 if (dch->state <= HFC_MAX_NT_LAYER1_STATE)
643 printk(KERN_DEBUG "%s: %s: %s\n",
644 hw->name, __func__,
645 HFC_NT_LAYER1_STATES[dch->state]);
646
647 else
648 printk(KERN_INFO DRIVER_NAME "%s: %s: NT G%d\n",
649 hw->name, __func__, dch->state);
650 }
651
652 switch (dch->state) {
653 case (1):
654 test_and_clear_bit(FLG_ACTIVE, &dch->Flags);
655 test_and_clear_bit(FLG_L2_ACTIVATED, &dch->Flags);
656 hw->nt_timer = 0;
657 hw->timers &= ~NT_ACTIVATION_TIMER;
658 handle_led(hw, LED_S0_OFF);
659 break;
660
661 case (2):
662 if (hw->nt_timer < 0) {
663 hw->nt_timer = 0;
664 hw->timers &= ~NT_ACTIVATION_TIMER;
665 hfcsusb_ph_command(dch->hw, HFC_L1_DEACTIVATE_NT);
666 } else {
667 hw->timers |= NT_ACTIVATION_TIMER;
668 hw->nt_timer = NT_T1_COUNT;
669 /* allow G2 -> G3 transition */
670 write_reg(hw, HFCUSB_STATES, 2 | HFCUSB_NT_G2_G3);
671 }
672 break;
673 case (3):
674 hw->nt_timer = 0;
675 hw->timers &= ~NT_ACTIVATION_TIMER;
676 test_and_set_bit(FLG_ACTIVE, &dch->Flags);
677 _queue_data(&dch->dev.D, PH_ACTIVATE_IND,
678 MISDN_ID_ANY, 0, NULL, GFP_ATOMIC);
679 handle_led(hw, LED_S0_ON);
680 break;
681 case (4):
682 hw->nt_timer = 0;
683 hw->timers &= ~NT_ACTIVATION_TIMER;
684 break;
685 default:
686 break;
687 }
688 hfcsusb_ph_info(hw);
689}
690
691static void
692ph_state(struct dchannel *dch)
693{
694 struct hfcsusb *hw = dch->hw;
695
696 if (hw->protocol == ISDN_P_NT_S0)
697 ph_state_nt(dch);
698 else if (hw->protocol == ISDN_P_TE_S0)
699 ph_state_te(dch);
700}
701
702/*
703 * disable/enable BChannel for desired protocoll
704 */
705static int
706hfcsusb_setup_bch(struct bchannel *bch, int protocol)
707{
708 struct hfcsusb *hw = bch->hw;
709 __u8 conhdlc, sctrl, sctrl_r;
710
711 if (debug & DEBUG_HW)
712 printk(KERN_DEBUG "%s: %s: protocol %x-->%x B%d\n",
713 hw->name, __func__, bch->state, protocol,
714 bch->nr);
715
716 /* setup val for CON_HDLC */
717 conhdlc = 0;
718 if (protocol > ISDN_P_NONE)
719 conhdlc = 8; /* enable FIFO */
720
721 switch (protocol) {
722 case (-1): /* used for init */
723 bch->state = -1;
724 /* fall trough */
725 case (ISDN_P_NONE):
726 if (bch->state == ISDN_P_NONE)
727 return 0; /* already in idle state */
728 bch->state = ISDN_P_NONE;
729 clear_bit(FLG_HDLC, &bch->Flags);
730 clear_bit(FLG_TRANSPARENT, &bch->Flags);
731 break;
732 case (ISDN_P_B_RAW):
733 conhdlc |= 2;
734 bch->state = protocol;
735 set_bit(FLG_TRANSPARENT, &bch->Flags);
736 break;
737 case (ISDN_P_B_HDLC):
738 bch->state = protocol;
739 set_bit(FLG_HDLC, &bch->Flags);
740 break;
741 default:
742 if (debug & DEBUG_HW)
743 printk(KERN_DEBUG "%s: %s: prot not known %x\n",
744 hw->name, __func__, protocol);
745 return -ENOPROTOOPT;
746 }
747
748 if (protocol >= ISDN_P_NONE) {
749 write_reg(hw, HFCUSB_FIFO, (bch->nr == 1) ? 0 : 2);
750 write_reg(hw, HFCUSB_CON_HDLC, conhdlc);
751 write_reg(hw, HFCUSB_INC_RES_F, 2);
752 write_reg(hw, HFCUSB_FIFO, (bch->nr == 1) ? 1 : 3);
753 write_reg(hw, HFCUSB_CON_HDLC, conhdlc);
754 write_reg(hw, HFCUSB_INC_RES_F, 2);
755
756 sctrl = 0x40 + ((hw->protocol == ISDN_P_TE_S0) ? 0x00 : 0x04);
757 sctrl_r = 0x0;
758 if (test_bit(FLG_ACTIVE, &hw->bch[0].Flags)) {
759 sctrl |= 1;
760 sctrl_r |= 1;
761 }
762 if (test_bit(FLG_ACTIVE, &hw->bch[1].Flags)) {
763 sctrl |= 2;
764 sctrl_r |= 2;
765 }
766 write_reg(hw, HFCUSB_SCTRL, sctrl);
767 write_reg(hw, HFCUSB_SCTRL_R, sctrl_r);
768
769 if (protocol > ISDN_P_NONE)
770 handle_led(hw, (bch->nr == 1) ? LED_B1_ON : LED_B2_ON);
771 else
772 handle_led(hw, (bch->nr == 1) ? LED_B1_OFF :
773 LED_B2_OFF);
774 }
775 hfcsusb_ph_info(hw);
776 return 0;
777}
778
779static void
780hfcsusb_ph_command(struct hfcsusb *hw, u_char command)
781{
782 if (debug & DEBUG_HW)
783 printk(KERN_DEBUG "%s: %s: %x\n",
784 hw->name, __func__, command);
785
786 switch (command) {
787 case HFC_L1_ACTIVATE_TE:
788 /* force sending sending INFO1 */
789 write_reg(hw, HFCUSB_STATES, 0x14);
790 /* start l1 activation */
791 write_reg(hw, HFCUSB_STATES, 0x04);
792 break;
793
794 case HFC_L1_FORCE_DEACTIVATE_TE:
795 write_reg(hw, HFCUSB_STATES, 0x10);
796 write_reg(hw, HFCUSB_STATES, 0x03);
797 break;
798
799 case HFC_L1_ACTIVATE_NT:
800 if (hw->dch.state == 3)
801 _queue_data(&hw->dch.dev.D, PH_ACTIVATE_IND,
802 MISDN_ID_ANY, 0, NULL, GFP_ATOMIC);
803 else
804 write_reg(hw, HFCUSB_STATES, HFCUSB_ACTIVATE |
805 HFCUSB_DO_ACTION | HFCUSB_NT_G2_G3);
806 break;
807
808 case HFC_L1_DEACTIVATE_NT:
809 write_reg(hw, HFCUSB_STATES,
810 HFCUSB_DO_ACTION);
811 break;
812 }
813}
814
815/*
816 * Layer 1 B-channel hardware access
817 */
818static int
819channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq)
820{
821 int ret = 0;
822
823 switch (cq->op) {
824 case MISDN_CTRL_GETOP:
825 cq->op = MISDN_CTRL_FILL_EMPTY;
826 break;
827 case MISDN_CTRL_FILL_EMPTY: /* fill fifo, if empty */
828 test_and_set_bit(FLG_FILLEMPTY, &bch->Flags);
829 if (debug & DEBUG_HW_OPEN)
830 printk(KERN_DEBUG "%s: FILL_EMPTY request (nr=%d "
831 "off=%d)\n", __func__, bch->nr, !!cq->p1);
832 break;
833 default:
834 printk(KERN_WARNING "%s: unknown Op %x\n", __func__, cq->op);
835 ret = -EINVAL;
836 break;
837 }
838 return ret;
839}
840
841/* collect data from incoming interrupt or isochron USB data */
842static void
843hfcsusb_rx_frame(struct usb_fifo *fifo, __u8 *data, unsigned int len,
844 int finish)
845{
846 struct hfcsusb *hw = fifo->hw;
847 struct sk_buff *rx_skb = NULL;
848 int maxlen = 0;
849 int fifon = fifo->fifonum;
850 int i;
851 int hdlc = 0;
852
853 if (debug & DBG_HFC_CALL_TRACE)
854 printk(KERN_DEBUG "%s: %s: fifo(%i) len(%i) "
855 "dch(%p) bch(%p) ech(%p)\n",
856 hw->name, __func__, fifon, len,
857 fifo->dch, fifo->bch, fifo->ech);
858
859 if (!len)
860 return;
861
862 if ((!!fifo->dch + !!fifo->bch + !!fifo->ech) != 1) {
863 printk(KERN_DEBUG "%s: %s: undefined channel\n",
864 hw->name, __func__);
865 return;
866 }
867
868 spin_lock(&hw->lock);
869 if (fifo->dch) {
870 rx_skb = fifo->dch->rx_skb;
871 maxlen = fifo->dch->maxlen;
872 hdlc = 1;
873 }
874 if (fifo->bch) {
875 rx_skb = fifo->bch->rx_skb;
876 maxlen = fifo->bch->maxlen;
877 hdlc = test_bit(FLG_HDLC, &fifo->bch->Flags);
878 }
879 if (fifo->ech) {
880 rx_skb = fifo->ech->rx_skb;
881 maxlen = fifo->ech->maxlen;
882 hdlc = 1;
883 }
884
885 if (!rx_skb) {
886 rx_skb = mI_alloc_skb(maxlen, GFP_ATOMIC);
887 if (rx_skb) {
888 if (fifo->dch)
889 fifo->dch->rx_skb = rx_skb;
890 if (fifo->bch)
891 fifo->bch->rx_skb = rx_skb;
892 if (fifo->ech)
893 fifo->ech->rx_skb = rx_skb;
894 skb_trim(rx_skb, 0);
895 } else {
896 printk(KERN_DEBUG "%s: %s: No mem for rx_skb\n",
897 hw->name, __func__);
898 spin_unlock(&hw->lock);
899 return;
900 }
901 }
902
903 if (fifo->dch || fifo->ech) {
904 /* D/E-Channel SKB range check */
905 if ((rx_skb->len + len) >= MAX_DFRAME_LEN_L1) {
906 printk(KERN_DEBUG "%s: %s: sbk mem exceeded "
907 "for fifo(%d) HFCUSB_D_RX\n",
908 hw->name, __func__, fifon);
909 skb_trim(rx_skb, 0);
910 spin_unlock(&hw->lock);
911 return;
912 }
913 } else if (fifo->bch) {
914 /* B-Channel SKB range check */
915 if ((rx_skb->len + len) >= (MAX_BCH_SIZE + 3)) {
916 printk(KERN_DEBUG "%s: %s: sbk mem exceeded "
917 "for fifo(%d) HFCUSB_B_RX\n",
918 hw->name, __func__, fifon);
919 skb_trim(rx_skb, 0);
920 spin_unlock(&hw->lock);
921 return;
922 }
923 }
924
925 memcpy(skb_put(rx_skb, len), data, len);
926
927 if (hdlc) {
928 /* we have a complete hdlc packet */
929 if (finish) {
930 if ((rx_skb->len > 3) &&
931 (!(rx_skb->data[rx_skb->len - 1]))) {
932 if (debug & DBG_HFC_FIFO_VERBOSE) {
933 printk(KERN_DEBUG "%s: %s: fifon(%i)"
934 " new RX len(%i): ",
935 hw->name, __func__, fifon,
936 rx_skb->len);
937 i = 0;
938 while (i < rx_skb->len)
939 printk("%02x ",
940 rx_skb->data[i++]);
941 printk("\n");
942 }
943
944 /* remove CRC & status */
945 skb_trim(rx_skb, rx_skb->len - 3);
946
947 if (fifo->dch)
948 recv_Dchannel(fifo->dch);
949 if (fifo->bch)
950 recv_Bchannel(fifo->bch);
951 if (fifo->ech)
952 recv_Echannel(fifo->ech,
953 &hw->dch);
954 } else {
955 if (debug & DBG_HFC_FIFO_VERBOSE) {
956 printk(KERN_DEBUG
957 "%s: CRC or minlen ERROR fifon(%i) "
958 "RX len(%i): ",
959 hw->name, fifon, rx_skb->len);
960 i = 0;
961 while (i < rx_skb->len)
962 printk("%02x ",
963 rx_skb->data[i++]);
964 printk("\n");
965 }
966 skb_trim(rx_skb, 0);
967 }
968 }
969 } else {
970 /* deliver transparent data to layer2 */
971 if (rx_skb->len >= poll)
972 recv_Bchannel(fifo->bch);
973 }
974 spin_unlock(&hw->lock);
975}
976
977void
978fill_isoc_urb(struct urb *urb, struct usb_device *dev, unsigned int pipe,
979 void *buf, int num_packets, int packet_size, int interval,
980 usb_complete_t complete, void *context)
981{
982 int k;
983
984 usb_fill_bulk_urb(urb, dev, pipe, buf, packet_size * num_packets,
985 complete, context);
986
987 urb->number_of_packets = num_packets;
988 urb->transfer_flags = URB_ISO_ASAP;
989 urb->actual_length = 0;
990 urb->interval = interval;
991
992 for (k = 0; k < num_packets; k++) {
993 urb->iso_frame_desc[k].offset = packet_size * k;
994 urb->iso_frame_desc[k].length = packet_size;
995 urb->iso_frame_desc[k].actual_length = 0;
996 }
997}
998
999/* receive completion routine for all ISO tx fifos */
1000static void
1001rx_iso_complete(struct urb *urb)
1002{
1003 struct iso_urb *context_iso_urb = (struct iso_urb *) urb->context;
1004 struct usb_fifo *fifo = context_iso_urb->owner_fifo;
1005 struct hfcsusb *hw = fifo->hw;
1006 int k, len, errcode, offset, num_isoc_packets, fifon, maxlen,
1007 status, iso_status, i;
1008 __u8 *buf;
1009 static __u8 eof[8];
1010 __u8 s0_state;
1011
1012 fifon = fifo->fifonum;
1013 status = urb->status;
1014
1015 spin_lock(&hw->lock);
1016 if (fifo->stop_gracefull) {
1017 fifo->stop_gracefull = 0;
1018 fifo->active = 0;
1019 spin_unlock(&hw->lock);
1020 return;
1021 }
1022 spin_unlock(&hw->lock);
1023
1024 /*
1025 * ISO transfer only partially completed,
1026 * look at individual frame status for details
1027 */
1028 if (status == -EXDEV) {
1029 if (debug & DEBUG_HW)
1030 printk(KERN_DEBUG "%s: %s: with -EXDEV "
1031 "urb->status %d, fifonum %d\n",
1032 hw->name, __func__, status, fifon);
1033
1034 /* clear status, so go on with ISO transfers */
1035 status = 0;
1036 }
1037
1038 s0_state = 0;
1039 if (fifo->active && !status) {
1040 num_isoc_packets = iso_packets[fifon];
1041 maxlen = fifo->usb_packet_maxlen;
1042
1043 for (k = 0; k < num_isoc_packets; ++k) {
1044 len = urb->iso_frame_desc[k].actual_length;
1045 offset = urb->iso_frame_desc[k].offset;
1046 buf = context_iso_urb->buffer + offset;
1047 iso_status = urb->iso_frame_desc[k].status;
1048
1049 if (iso_status && (debug & DBG_HFC_FIFO_VERBOSE)) {
1050 printk(KERN_DEBUG "%s: %s: "
1051 "ISO packet %i, status: %i\n",
1052 hw->name, __func__, k, iso_status);
1053 }
1054
1055 /* USB data log for every D ISO in */
1056 if ((fifon == HFCUSB_D_RX) &&
1057 (debug & DBG_HFC_USB_VERBOSE)) {
1058 printk(KERN_DEBUG
1059 "%s: %s: %d (%d/%d) len(%d) ",
1060 hw->name, __func__, urb->start_frame,
1061 k, num_isoc_packets-1,
1062 len);
1063 for (i = 0; i < len; i++)
1064 printk("%x ", buf[i]);
1065 printk("\n");
1066 }
1067
1068 if (!iso_status) {
1069 if (fifo->last_urblen != maxlen) {
1070 /*
1071 * save fifo fill-level threshold bits
1072 * to use them later in TX ISO URB
1073 * completions
1074 */
1075 hw->threshold_mask = buf[1];
1076
1077 if (fifon == HFCUSB_D_RX)
1078 s0_state = (buf[0] >> 4);
1079
1080 eof[fifon] = buf[0] & 1;
1081 if (len > 2)
1082 hfcsusb_rx_frame(fifo, buf + 2,
1083 len - 2, (len < maxlen)
1084 ? eof[fifon] : 0);
1085 } else
1086 hfcsusb_rx_frame(fifo, buf, len,
1087 (len < maxlen) ?
1088 eof[fifon] : 0);
1089 fifo->last_urblen = len;
1090 }
1091 }
1092
1093 /* signal S0 layer1 state change */
1094 if ((s0_state) && (hw->initdone) &&
1095 (s0_state != hw->dch.state)) {
1096 hw->dch.state = s0_state;
1097 schedule_event(&hw->dch, FLG_PHCHANGE);
1098 }
1099
1100 fill_isoc_urb(urb, fifo->hw->dev, fifo->pipe,
1101 context_iso_urb->buffer, num_isoc_packets,
1102 fifo->usb_packet_maxlen, fifo->intervall,
1103 (usb_complete_t)rx_iso_complete, urb->context);
1104 errcode = usb_submit_urb(urb, GFP_ATOMIC);
1105 if (errcode < 0) {
1106 if (debug & DEBUG_HW)
1107 printk(KERN_DEBUG "%s: %s: error submitting "
1108 "ISO URB: %d\n",
1109 hw->name, __func__, errcode);
1110 }
1111 } else {
1112 if (status && (debug & DBG_HFC_URB_INFO))
1113 printk(KERN_DEBUG "%s: %s: rx_iso_complete : "
1114 "urb->status %d, fifonum %d\n",
1115 hw->name, __func__, status, fifon);
1116 }
1117}
1118
1119/* receive completion routine for all interrupt rx fifos */
1120static void
1121rx_int_complete(struct urb *urb)
1122{
1123 int len, status, i;
1124 __u8 *buf, maxlen, fifon;
1125 struct usb_fifo *fifo = (struct usb_fifo *) urb->context;
1126 struct hfcsusb *hw = fifo->hw;
1127 static __u8 eof[8];
1128
1129 spin_lock(&hw->lock);
1130 if (fifo->stop_gracefull) {
1131 fifo->stop_gracefull = 0;
1132 fifo->active = 0;
1133 spin_unlock(&hw->lock);
1134 return;
1135 }
1136 spin_unlock(&hw->lock);
1137
1138 fifon = fifo->fifonum;
1139 if ((!fifo->active) || (urb->status)) {
1140 if (debug & DBG_HFC_URB_ERROR)
1141 printk(KERN_DEBUG
1142 "%s: %s: RX-Fifo %i is going down (%i)\n",
1143 hw->name, __func__, fifon, urb->status);
1144
1145 fifo->urb->interval = 0; /* cancel automatic rescheduling */
1146 return;
1147 }
1148 len = urb->actual_length;
1149 buf = fifo->buffer;
1150 maxlen = fifo->usb_packet_maxlen;
1151
1152 /* USB data log for every D INT in */
1153 if ((fifon == HFCUSB_D_RX) && (debug & DBG_HFC_USB_VERBOSE)) {
1154 printk(KERN_DEBUG "%s: %s: D RX INT len(%d) ",
1155 hw->name, __func__, len);
1156 for (i = 0; i < len; i++)
1157 printk("%02x ", buf[i]);
1158 printk("\n");
1159 }
1160
1161 if (fifo->last_urblen != fifo->usb_packet_maxlen) {
1162 /* the threshold mask is in the 2nd status byte */
1163 hw->threshold_mask = buf[1];
1164
1165 /* signal S0 layer1 state change */
1166 if (hw->initdone && ((buf[0] >> 4) != hw->dch.state)) {
1167 hw->dch.state = (buf[0] >> 4);
1168 schedule_event(&hw->dch, FLG_PHCHANGE);
1169 }
1170
1171 eof[fifon] = buf[0] & 1;
1172 /* if we have more than the 2 status bytes -> collect data */
1173 if (len > 2)
1174 hfcsusb_rx_frame(fifo, buf + 2,
1175 urb->actual_length - 2,
1176 (len < maxlen) ? eof[fifon] : 0);
1177 } else {
1178 hfcsusb_rx_frame(fifo, buf, urb->actual_length,
1179 (len < maxlen) ? eof[fifon] : 0);
1180 }
1181 fifo->last_urblen = urb->actual_length;
1182
1183 status = usb_submit_urb(urb, GFP_ATOMIC);
1184 if (status) {
1185 if (debug & DEBUG_HW)
1186 printk(KERN_DEBUG "%s: %s: error resubmitting USB\n",
1187 hw->name, __func__);
1188 }
1189}
1190
1191/* transmit completion routine for all ISO tx fifos */
1192static void
1193tx_iso_complete(struct urb *urb)
1194{
1195 struct iso_urb *context_iso_urb = (struct iso_urb *) urb->context;
1196 struct usb_fifo *fifo = context_iso_urb->owner_fifo;
1197 struct hfcsusb *hw = fifo->hw;
1198 struct sk_buff *tx_skb;
1199 int k, tx_offset, num_isoc_packets, sink, remain, current_len,
1200 errcode, hdlc, i;
1201 int *tx_idx;
1202 int frame_complete, fifon, status;
1203 __u8 threshbit;
1204
1205 spin_lock(&hw->lock);
1206 if (fifo->stop_gracefull) {
1207 fifo->stop_gracefull = 0;
1208 fifo->active = 0;
1209 spin_unlock(&hw->lock);
1210 return;
1211 }
1212
1213 if (fifo->dch) {
1214 tx_skb = fifo->dch->tx_skb;
1215 tx_idx = &fifo->dch->tx_idx;
1216 hdlc = 1;
1217 } else if (fifo->bch) {
1218 tx_skb = fifo->bch->tx_skb;
1219 tx_idx = &fifo->bch->tx_idx;
1220 hdlc = test_bit(FLG_HDLC, &fifo->bch->Flags);
1221 } else {
1222 printk(KERN_DEBUG "%s: %s: neither BCH nor DCH\n",
1223 hw->name, __func__);
1224 spin_unlock(&hw->lock);
1225 return;
1226 }
1227
1228 fifon = fifo->fifonum;
1229 status = urb->status;
1230
1231 tx_offset = 0;
1232
1233 /*
1234 * ISO transfer only partially completed,
1235 * look at individual frame status for details
1236 */
1237 if (status == -EXDEV) {
1238 if (debug & DBG_HFC_URB_ERROR)
1239 printk(KERN_DEBUG "%s: %s: "
1240 "-EXDEV (%i) fifon (%d)\n",
1241 hw->name, __func__, status, fifon);
1242
1243 /* clear status, so go on with ISO transfers */
1244 status = 0;
1245 }
1246
1247 if (fifo->active && !status) {
1248 /* is FifoFull-threshold set for our channel? */
1249 threshbit = (hw->threshold_mask & (1 << fifon));
1250 num_isoc_packets = iso_packets[fifon];
1251
1252 /* predict dataflow to avoid fifo overflow */
1253 if (fifon >= HFCUSB_D_TX)
1254 sink = (threshbit) ? SINK_DMIN : SINK_DMAX;
1255 else
1256 sink = (threshbit) ? SINK_MIN : SINK_MAX;
1257 fill_isoc_urb(urb, fifo->hw->dev, fifo->pipe,
1258 context_iso_urb->buffer, num_isoc_packets,
1259 fifo->usb_packet_maxlen, fifo->intervall,
1260 (usb_complete_t)tx_iso_complete, urb->context);
1261 memset(context_iso_urb->buffer, 0,
1262 sizeof(context_iso_urb->buffer));
1263 frame_complete = 0;
1264
1265 for (k = 0; k < num_isoc_packets; ++k) {
1266 /* analyze tx success of previous ISO packets */
1267 if (debug & DBG_HFC_URB_ERROR) {
1268 errcode = urb->iso_frame_desc[k].status;
1269 if (errcode) {
1270 printk(KERN_DEBUG "%s: %s: "
1271 "ISO packet %i, status: %i\n",
1272 hw->name, __func__, k, errcode);
1273 }
1274 }
1275
1276 /* Generate next ISO Packets */
1277 if (tx_skb)
1278 remain = tx_skb->len - *tx_idx;
1279 else
1280 remain = 0;
1281
1282 if (remain > 0) {
1283 fifo->bit_line -= sink;
1284 current_len = (0 - fifo->bit_line) / 8;
1285 if (current_len > 14)
1286 current_len = 14;
1287 if (current_len < 0)
1288 current_len = 0;
1289 if (remain < current_len)
1290 current_len = remain;
1291
1292 /* how much bit do we put on the line? */
1293 fifo->bit_line += current_len * 8;
1294
1295 context_iso_urb->buffer[tx_offset] = 0;
1296 if (current_len == remain) {
1297 if (hdlc) {
1298 /* signal frame completion */
1299 context_iso_urb->
1300 buffer[tx_offset] = 1;
1301 /* add 2 byte flags and 16bit
1302 * CRC at end of ISDN frame */
1303 fifo->bit_line += 32;
1304 }
1305 frame_complete = 1;
1306 }
1307
1308 /* copy tx data to iso-urb buffer */
1309 memcpy(context_iso_urb->buffer + tx_offset + 1,
1310 (tx_skb->data + *tx_idx), current_len);
1311 *tx_idx += current_len;
1312
1313 urb->iso_frame_desc[k].offset = tx_offset;
1314 urb->iso_frame_desc[k].length = current_len + 1;
1315
1316 /* USB data log for every D ISO out */
1317 if ((fifon == HFCUSB_D_RX) &&
1318 (debug & DBG_HFC_USB_VERBOSE)) {
1319 printk(KERN_DEBUG
1320 "%s: %s (%d/%d) offs(%d) len(%d) ",
1321 hw->name, __func__,
1322 k, num_isoc_packets-1,
1323 urb->iso_frame_desc[k].offset,
1324 urb->iso_frame_desc[k].length);
1325
1326 for (i = urb->iso_frame_desc[k].offset;
1327 i < (urb->iso_frame_desc[k].offset
1328 + urb->iso_frame_desc[k].length);
1329 i++)
1330 printk("%x ",
1331 context_iso_urb->buffer[i]);
1332
1333 printk(" skb->len(%i) tx-idx(%d)\n",
1334 tx_skb->len, *tx_idx);
1335 }
1336
1337 tx_offset += (current_len + 1);
1338 } else {
1339 urb->iso_frame_desc[k].offset = tx_offset++;
1340 urb->iso_frame_desc[k].length = 1;
1341 /* we lower data margin every msec */
1342 fifo->bit_line -= sink;
1343 if (fifo->bit_line < BITLINE_INF)
1344 fifo->bit_line = BITLINE_INF;
1345 }
1346
1347 if (frame_complete) {
1348 frame_complete = 0;
1349
1350 if (debug & DBG_HFC_FIFO_VERBOSE) {
1351 printk(KERN_DEBUG "%s: %s: "
1352 "fifon(%i) new TX len(%i): ",
1353 hw->name, __func__,
1354 fifon, tx_skb->len);
1355 i = 0;
1356 while (i < tx_skb->len)
1357 printk("%02x ",
1358 tx_skb->data[i++]);
1359 printk("\n");
1360 }
1361
1362 dev_kfree_skb(tx_skb);
1363 tx_skb = NULL;
1364 if (fifo->dch && get_next_dframe(fifo->dch))
1365 tx_skb = fifo->dch->tx_skb;
1366 else if (fifo->bch &&
1367 get_next_bframe(fifo->bch)) {
1368 if (test_bit(FLG_TRANSPARENT,
1369 &fifo->bch->Flags))
1370 confirm_Bsend(fifo->bch);
1371 tx_skb = fifo->bch->tx_skb;
1372 }
1373 }
1374 }
1375 errcode = usb_submit_urb(urb, GFP_ATOMIC);
1376 if (errcode < 0) {
1377 if (debug & DEBUG_HW)
1378 printk(KERN_DEBUG
1379 "%s: %s: error submitting ISO URB: %d \n",
1380 hw->name, __func__, errcode);
1381 }
1382
1383 /*
1384 * abuse DChannel tx iso completion to trigger NT mode state
1385 * changes tx_iso_complete is assumed to be called every
1386 * fifo->intervall (ms)
1387 */
1388 if ((fifon == HFCUSB_D_TX) && (hw->protocol == ISDN_P_NT_S0)
1389 && (hw->timers & NT_ACTIVATION_TIMER)) {
1390 if ((--hw->nt_timer) < 0)
1391 schedule_event(&hw->dch, FLG_PHCHANGE);
1392 }
1393
1394 } else {
1395 if (status && (debug & DBG_HFC_URB_ERROR))
1396 printk(KERN_DEBUG "%s: %s: urb->status %s (%i)"
1397 "fifonum=%d\n",
1398 hw->name, __func__,
1399 symbolic(urb_errlist, status), status, fifon);
1400 }
1401 spin_unlock(&hw->lock);
1402}
1403
1404/*
1405 * allocs urbs and start isoc transfer with two pending urbs to avoid
1406 * gaps in the transfer chain
1407 */
1408static int
1409start_isoc_chain(struct usb_fifo *fifo, int num_packets_per_urb,
1410 usb_complete_t complete, int packet_size)
1411{
1412 struct hfcsusb *hw = fifo->hw;
1413 int i, k, errcode;
1414
1415 if (debug)
1416 printk(KERN_DEBUG "%s: %s: fifo %i\n",
1417 hw->name, __func__, fifo->fifonum);
1418
1419 /* allocate Memory for Iso out Urbs */
1420 for (i = 0; i < 2; i++) {
1421 if (!(fifo->iso[i].urb)) {
1422 fifo->iso[i].urb =
1423 usb_alloc_urb(num_packets_per_urb, GFP_KERNEL);
1424 if (!(fifo->iso[i].urb)) {
1425 printk(KERN_DEBUG
1426 "%s: %s: alloc urb for fifo %i failed",
1427 hw->name, __func__, fifo->fifonum);
1428 }
1429 fifo->iso[i].owner_fifo = (struct usb_fifo *) fifo;
1430 fifo->iso[i].indx = i;
1431
1432 /* Init the first iso */
1433 if (ISO_BUFFER_SIZE >=
1434 (fifo->usb_packet_maxlen *
1435 num_packets_per_urb)) {
1436 fill_isoc_urb(fifo->iso[i].urb,
1437 fifo->hw->dev, fifo->pipe,
1438 fifo->iso[i].buffer,
1439 num_packets_per_urb,
1440 fifo->usb_packet_maxlen,
1441 fifo->intervall, complete,
1442 &fifo->iso[i]);
1443 memset(fifo->iso[i].buffer, 0,
1444 sizeof(fifo->iso[i].buffer));
1445
1446 for (k = 0; k < num_packets_per_urb; k++) {
1447 fifo->iso[i].urb->
1448 iso_frame_desc[k].offset =
1449 k * packet_size;
1450 fifo->iso[i].urb->
1451 iso_frame_desc[k].length =
1452 packet_size;
1453 }
1454 } else {
1455 printk(KERN_DEBUG
1456 "%s: %s: ISO Buffer size to small!\n",
1457 hw->name, __func__);
1458 }
1459 }
1460 fifo->bit_line = BITLINE_INF;
1461
1462 errcode = usb_submit_urb(fifo->iso[i].urb, GFP_KERNEL);
1463 fifo->active = (errcode >= 0) ? 1 : 0;
1464 fifo->stop_gracefull = 0;
1465 if (errcode < 0) {
1466 printk(KERN_DEBUG "%s: %s: %s URB nr:%d\n",
1467 hw->name, __func__,
1468 symbolic(urb_errlist, errcode), i);
1469 }
1470 }
1471 return fifo->active;
1472}
1473
1474static void
1475stop_iso_gracefull(struct usb_fifo *fifo)
1476{
1477 struct hfcsusb *hw = fifo->hw;
1478 int i, timeout;
1479 u_long flags;
1480
1481 for (i = 0; i < 2; i++) {
1482 spin_lock_irqsave(&hw->lock, flags);
1483 if (debug)
1484 printk(KERN_DEBUG "%s: %s for fifo %i.%i\n",
1485 hw->name, __func__, fifo->fifonum, i);
1486 fifo->stop_gracefull = 1;
1487 spin_unlock_irqrestore(&hw->lock, flags);
1488 }
1489
1490 for (i = 0; i < 2; i++) {
1491 timeout = 3;
1492 while (fifo->stop_gracefull && timeout--)
1493 schedule_timeout_interruptible((HZ/1000)*16);
1494 if (debug && fifo->stop_gracefull)
1495 printk(KERN_DEBUG "%s: ERROR %s for fifo %i.%i\n",
1496 hw->name, __func__, fifo->fifonum, i);
1497 }
1498}
1499
1500static void
1501stop_int_gracefull(struct usb_fifo *fifo)
1502{
1503 struct hfcsusb *hw = fifo->hw;
1504 int timeout;
1505 u_long flags;
1506
1507 spin_lock_irqsave(&hw->lock, flags);
1508 if (debug)
1509 printk(KERN_DEBUG "%s: %s for fifo %i\n",
1510 hw->name, __func__, fifo->fifonum);
1511 fifo->stop_gracefull = 1;
1512 spin_unlock_irqrestore(&hw->lock, flags);
1513
1514 timeout = 3;
1515 while (fifo->stop_gracefull && timeout--)
1516 schedule_timeout_interruptible((HZ/1000)*3);
1517 if (debug && fifo->stop_gracefull)
1518 printk(KERN_DEBUG "%s: ERROR %s for fifo %i\n",
1519 hw->name, __func__, fifo->fifonum);
1520}
1521
1522/* start the interrupt transfer for the given fifo */
1523static void
1524start_int_fifo(struct usb_fifo *fifo)
1525{
1526 struct hfcsusb *hw = fifo->hw;
1527 int errcode;
1528
1529 if (debug)
1530 printk(KERN_DEBUG "%s: %s: INT IN fifo:%d\n",
1531 hw->name, __func__, fifo->fifonum);
1532
1533 if (!fifo->urb) {
1534 fifo->urb = usb_alloc_urb(0, GFP_KERNEL);
1535 if (!fifo->urb)
1536 return;
1537 }
1538 usb_fill_int_urb(fifo->urb, fifo->hw->dev, fifo->pipe,
1539 fifo->buffer, fifo->usb_packet_maxlen,
1540 (usb_complete_t)rx_int_complete, fifo, fifo->intervall);
1541 fifo->active = 1;
1542 fifo->stop_gracefull = 0;
1543 errcode = usb_submit_urb(fifo->urb, GFP_KERNEL);
1544 if (errcode) {
1545 printk(KERN_DEBUG "%s: %s: submit URB: status:%i\n",
1546 hw->name, __func__, errcode);
1547 fifo->active = 0;
1548 }
1549}
1550
1551static void
1552setPortMode(struct hfcsusb *hw)
1553{
1554 if (debug & DEBUG_HW)
1555 printk(KERN_DEBUG "%s: %s %s\n", hw->name, __func__,
1556 (hw->protocol == ISDN_P_TE_S0) ? "TE" : "NT");
1557
1558 if (hw->protocol == ISDN_P_TE_S0) {
1559 write_reg(hw, HFCUSB_SCTRL, 0x40);
1560 write_reg(hw, HFCUSB_SCTRL_E, 0x00);
1561 write_reg(hw, HFCUSB_CLKDEL, CLKDEL_TE);
1562 write_reg(hw, HFCUSB_STATES, 3 | 0x10);
1563 write_reg(hw, HFCUSB_STATES, 3);
1564 } else {
1565 write_reg(hw, HFCUSB_SCTRL, 0x44);
1566 write_reg(hw, HFCUSB_SCTRL_E, 0x09);
1567 write_reg(hw, HFCUSB_CLKDEL, CLKDEL_NT);
1568 write_reg(hw, HFCUSB_STATES, 1 | 0x10);
1569 write_reg(hw, HFCUSB_STATES, 1);
1570 }
1571}
1572
1573static void
1574reset_hfcsusb(struct hfcsusb *hw)
1575{
1576 struct usb_fifo *fifo;
1577 int i;
1578
1579 if (debug & DEBUG_HW)
1580 printk(KERN_DEBUG "%s: %s\n", hw->name, __func__);
1581
1582 /* do Chip reset */
1583 write_reg(hw, HFCUSB_CIRM, 8);
1584
1585 /* aux = output, reset off */
1586 write_reg(hw, HFCUSB_CIRM, 0x10);
1587
1588 /* set USB_SIZE to match the wMaxPacketSize for INT or BULK transfers */
1589 write_reg(hw, HFCUSB_USB_SIZE, (hw->packet_size / 8) |
1590 ((hw->packet_size / 8) << 4));
1591
1592 /* set USB_SIZE_I to match the the wMaxPacketSize for ISO transfers */
1593 write_reg(hw, HFCUSB_USB_SIZE_I, hw->iso_packet_size);
1594
1595 /* enable PCM/GCI master mode */
1596 write_reg(hw, HFCUSB_MST_MODE1, 0); /* set default values */
1597 write_reg(hw, HFCUSB_MST_MODE0, 1); /* enable master mode */
1598
1599 /* init the fifos */
1600 write_reg(hw, HFCUSB_F_THRES,
1601 (HFCUSB_TX_THRESHOLD / 8) | ((HFCUSB_RX_THRESHOLD / 8) << 4));
1602
1603 fifo = hw->fifos;
1604 for (i = 0; i < HFCUSB_NUM_FIFOS; i++) {
1605 write_reg(hw, HFCUSB_FIFO, i); /* select the desired fifo */
1606 fifo[i].max_size =
1607 (i <= HFCUSB_B2_RX) ? MAX_BCH_SIZE : MAX_DFRAME_LEN;
1608 fifo[i].last_urblen = 0;
1609
1610 /* set 2 bit for D- & E-channel */
1611 write_reg(hw, HFCUSB_HDLC_PAR, ((i <= HFCUSB_B2_RX) ? 0 : 2));
1612
1613 /* enable all fifos */
1614 if (i == HFCUSB_D_TX)
1615 write_reg(hw, HFCUSB_CON_HDLC,
1616 (hw->protocol == ISDN_P_NT_S0) ? 0x08 : 0x09);
1617 else
1618 write_reg(hw, HFCUSB_CON_HDLC, 0x08);
1619 write_reg(hw, HFCUSB_INC_RES_F, 2); /* reset the fifo */
1620 }
1621
1622 write_reg(hw, HFCUSB_SCTRL_R, 0); /* disable both B receivers */
1623 handle_led(hw, LED_POWER_ON);
1624}
1625
1626/* start USB data pipes dependand on device's endpoint configuration */
1627static void
1628hfcsusb_start_endpoint(struct hfcsusb *hw, int channel)
1629{
1630 /* quick check if endpoint already running */
1631 if ((channel == HFC_CHAN_D) && (hw->fifos[HFCUSB_D_RX].active))
1632 return;
1633 if ((channel == HFC_CHAN_B1) && (hw->fifos[HFCUSB_B1_RX].active))
1634 return;
1635 if ((channel == HFC_CHAN_B2) && (hw->fifos[HFCUSB_B2_RX].active))
1636 return;
1637 if ((channel == HFC_CHAN_E) && (hw->fifos[HFCUSB_PCM_RX].active))
1638 return;
1639
1640 /* start rx endpoints using USB INT IN method */
1641 if (hw->cfg_used == CNF_3INT3ISO || hw->cfg_used == CNF_4INT3ISO)
1642 start_int_fifo(hw->fifos + channel*2 + 1);
1643
1644 /* start rx endpoints using USB ISO IN method */
1645 if (hw->cfg_used == CNF_3ISO3ISO || hw->cfg_used == CNF_4ISO3ISO) {
1646 switch (channel) {
1647 case HFC_CHAN_D:
1648 start_isoc_chain(hw->fifos + HFCUSB_D_RX,
1649 ISOC_PACKETS_D,
1650 (usb_complete_t)rx_iso_complete,
1651 16);
1652 break;
1653 case HFC_CHAN_E:
1654 start_isoc_chain(hw->fifos + HFCUSB_PCM_RX,
1655 ISOC_PACKETS_D,
1656 (usb_complete_t)rx_iso_complete,
1657 16);
1658 break;
1659 case HFC_CHAN_B1:
1660 start_isoc_chain(hw->fifos + HFCUSB_B1_RX,
1661 ISOC_PACKETS_B,
1662 (usb_complete_t)rx_iso_complete,
1663 16);
1664 break;
1665 case HFC_CHAN_B2:
1666 start_isoc_chain(hw->fifos + HFCUSB_B2_RX,
1667 ISOC_PACKETS_B,
1668 (usb_complete_t)rx_iso_complete,
1669 16);
1670 break;
1671 }
1672 }
1673
1674 /* start tx endpoints using USB ISO OUT method */
1675 switch (channel) {
1676 case HFC_CHAN_D:
1677 start_isoc_chain(hw->fifos + HFCUSB_D_TX,
1678 ISOC_PACKETS_B,
1679 (usb_complete_t)tx_iso_complete, 1);
1680 break;
1681 case HFC_CHAN_B1:
1682 start_isoc_chain(hw->fifos + HFCUSB_B1_TX,
1683 ISOC_PACKETS_D,
1684 (usb_complete_t)tx_iso_complete, 1);
1685 break;
1686 case HFC_CHAN_B2:
1687 start_isoc_chain(hw->fifos + HFCUSB_B2_TX,
1688 ISOC_PACKETS_B,
1689 (usb_complete_t)tx_iso_complete, 1);
1690 break;
1691 }
1692}
1693
1694/* stop USB data pipes dependand on device's endpoint configuration */
1695static void
1696hfcsusb_stop_endpoint(struct hfcsusb *hw, int channel)
1697{
1698 /* quick check if endpoint currently running */
1699 if ((channel == HFC_CHAN_D) && (!hw->fifos[HFCUSB_D_RX].active))
1700 return;
1701 if ((channel == HFC_CHAN_B1) && (!hw->fifos[HFCUSB_B1_RX].active))
1702 return;
1703 if ((channel == HFC_CHAN_B2) && (!hw->fifos[HFCUSB_B2_RX].active))
1704 return;
1705 if ((channel == HFC_CHAN_E) && (!hw->fifos[HFCUSB_PCM_RX].active))
1706 return;
1707
1708 /* rx endpoints using USB INT IN method */
1709 if (hw->cfg_used == CNF_3INT3ISO || hw->cfg_used == CNF_4INT3ISO)
1710 stop_int_gracefull(hw->fifos + channel*2 + 1);
1711
1712 /* rx endpoints using USB ISO IN method */
1713 if (hw->cfg_used == CNF_3ISO3ISO || hw->cfg_used == CNF_4ISO3ISO)
1714 stop_iso_gracefull(hw->fifos + channel*2 + 1);
1715
1716 /* tx endpoints using USB ISO OUT method */
1717 if (channel != HFC_CHAN_E)
1718 stop_iso_gracefull(hw->fifos + channel*2);
1719}
1720
1721
1722/* Hardware Initialization */
1723int
1724setup_hfcsusb(struct hfcsusb *hw)
1725{
1726 int err;
1727 u_char b;
1728
1729 if (debug & DBG_HFC_CALL_TRACE)
1730 printk(KERN_DEBUG "%s: %s\n", hw->name, __func__);
1731
1732 /* check the chip id */
1733 if (read_reg_atomic(hw, HFCUSB_CHIP_ID, &b) != 1) {
1734 printk(KERN_DEBUG "%s: %s: cannot read chip id\n",
1735 hw->name, __func__);
1736 return 1;
1737 }
1738 if (b != HFCUSB_CHIPID) {
1739 printk(KERN_DEBUG "%s: %s: Invalid chip id 0x%02x\n",
1740 hw->name, __func__, b);
1741 return 1;
1742 }
1743
1744 /* first set the needed config, interface and alternate */
1745 err = usb_set_interface(hw->dev, hw->if_used, hw->alt_used);
1746
1747 hw->led_state = 0;
1748
1749 /* init the background machinery for control requests */
1750 hw->ctrl_read.bRequestType = 0xc0;
1751 hw->ctrl_read.bRequest = 1;
1752 hw->ctrl_read.wLength = cpu_to_le16(1);
1753 hw->ctrl_write.bRequestType = 0x40;
1754 hw->ctrl_write.bRequest = 0;
1755 hw->ctrl_write.wLength = 0;
1756 usb_fill_control_urb(hw->ctrl_urb, hw->dev, hw->ctrl_out_pipe,
1757 (u_char *)&hw->ctrl_write, NULL, 0,
1758 (usb_complete_t)ctrl_complete, hw);
1759
1760 reset_hfcsusb(hw);
1761 return 0;
1762}
1763
1764static void
1765release_hw(struct hfcsusb *hw)
1766{
1767 if (debug & DBG_HFC_CALL_TRACE)
1768 printk(KERN_DEBUG "%s: %s\n", hw->name, __func__);
1769
1770 /*
1771 * stop all endpoints gracefully
1772 * TODO: mISDN_core should generate CLOSE_CHANNEL
1773 * signals after calling mISDN_unregister_device()
1774 */
1775 hfcsusb_stop_endpoint(hw, HFC_CHAN_D);
1776 hfcsusb_stop_endpoint(hw, HFC_CHAN_B1);
1777 hfcsusb_stop_endpoint(hw, HFC_CHAN_B2);
1778 if (hw->fifos[HFCUSB_PCM_RX].pipe)
1779 hfcsusb_stop_endpoint(hw, HFC_CHAN_E);
1780 if (hw->protocol == ISDN_P_TE_S0)
1781 l1_event(hw->dch.l1, CLOSE_CHANNEL);
1782
1783 mISDN_unregister_device(&hw->dch.dev);
1784 mISDN_freebchannel(&hw->bch[1]);
1785 mISDN_freebchannel(&hw->bch[0]);
1786 mISDN_freedchannel(&hw->dch);
1787
1788 if (hw->ctrl_urb) {
1789 usb_kill_urb(hw->ctrl_urb);
1790 usb_free_urb(hw->ctrl_urb);
1791 hw->ctrl_urb = NULL;
1792 }
1793
1794 if (hw->intf)
1795 usb_set_intfdata(hw->intf, NULL);
1796 list_del(&hw->list);
1797 kfree(hw);
1798 hw = NULL;
1799}
1800
1801static void
1802deactivate_bchannel(struct bchannel *bch)
1803{
1804 struct hfcsusb *hw = bch->hw;
1805 u_long flags;
1806
1807 if (bch->debug & DEBUG_HW)
1808 printk(KERN_DEBUG "%s: %s: bch->nr(%i)\n",
1809 hw->name, __func__, bch->nr);
1810
1811 spin_lock_irqsave(&hw->lock, flags);
1812 if (test_and_clear_bit(FLG_TX_NEXT, &bch->Flags)) {
1813 dev_kfree_skb(bch->next_skb);
1814 bch->next_skb = NULL;
1815 }
1816 if (bch->tx_skb) {
1817 dev_kfree_skb(bch->tx_skb);
1818 bch->tx_skb = NULL;
1819 }
1820 bch->tx_idx = 0;
1821 if (bch->rx_skb) {
1822 dev_kfree_skb(bch->rx_skb);
1823 bch->rx_skb = NULL;
1824 }
1825 clear_bit(FLG_ACTIVE, &bch->Flags);
1826 clear_bit(FLG_TX_BUSY, &bch->Flags);
1827 spin_unlock_irqrestore(&hw->lock, flags);
1828 hfcsusb_setup_bch(bch, ISDN_P_NONE);
1829 hfcsusb_stop_endpoint(hw, bch->nr);
1830}
1831
1832/*
1833 * Layer 1 B-channel hardware access
1834 */
1835static int
1836hfc_bctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
1837{
1838 struct bchannel *bch = container_of(ch, struct bchannel, ch);
1839 int ret = -EINVAL;
1840
1841 if (bch->debug & DEBUG_HW)
1842 printk(KERN_DEBUG "%s: cmd:%x %p\n", __func__, cmd, arg);
1843
1844 switch (cmd) {
1845 case HW_TESTRX_RAW:
1846 case HW_TESTRX_HDLC:
1847 case HW_TESTRX_OFF:
1848 ret = -EINVAL;
1849 break;
1850
1851 case CLOSE_CHANNEL:
1852 test_and_clear_bit(FLG_OPEN, &bch->Flags);
1853 if (test_bit(FLG_ACTIVE, &bch->Flags))
1854 deactivate_bchannel(bch);
1855 ch->protocol = ISDN_P_NONE;
1856 ch->peer = NULL;
1857 module_put(THIS_MODULE);
1858 ret = 0;
1859 break;
1860 case CONTROL_CHANNEL:
1861 ret = channel_bctrl(bch, arg);
1862 break;
1863 default:
1864 printk(KERN_WARNING "%s: unknown prim(%x)\n",
1865 __func__, cmd);
1866 }
1867 return ret;
1868}
1869
1870static int
1871setup_instance(struct hfcsusb *hw, struct device *parent)
1872{
1873 u_long flags;
1874 int err, i;
1875
1876 if (debug & DBG_HFC_CALL_TRACE)
1877 printk(KERN_DEBUG "%s: %s\n", hw->name, __func__);
1878
1879 spin_lock_init(&hw->ctrl_lock);
1880 spin_lock_init(&hw->lock);
1881
1882 mISDN_initdchannel(&hw->dch, MAX_DFRAME_LEN_L1, ph_state);
1883 hw->dch.debug = debug & 0xFFFF;
1884 hw->dch.hw = hw;
1885 hw->dch.dev.Dprotocols = (1 << ISDN_P_TE_S0) | (1 << ISDN_P_NT_S0);
1886 hw->dch.dev.D.send = hfcusb_l2l1D;
1887 hw->dch.dev.D.ctrl = hfc_dctrl;
1888
1889 /* enable E-Channel logging */
1890 if (hw->fifos[HFCUSB_PCM_RX].pipe)
1891 mISDN_initdchannel(&hw->ech, MAX_DFRAME_LEN_L1, NULL);
1892
1893 hw->dch.dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) |
1894 (1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK));
1895 hw->dch.dev.nrbchan = 2;
1896 for (i = 0; i < 2; i++) {
1897 hw->bch[i].nr = i + 1;
1898 set_channelmap(i + 1, hw->dch.dev.channelmap);
1899 hw->bch[i].debug = debug;
1900 mISDN_initbchannel(&hw->bch[i], MAX_DATA_MEM);
1901 hw->bch[i].hw = hw;
1902 hw->bch[i].ch.send = hfcusb_l2l1B;
1903 hw->bch[i].ch.ctrl = hfc_bctrl;
1904 hw->bch[i].ch.nr = i + 1;
1905 list_add(&hw->bch[i].ch.list, &hw->dch.dev.bchannels);
1906 }
1907
1908 hw->fifos[HFCUSB_B1_TX].bch = &hw->bch[0];
1909 hw->fifos[HFCUSB_B1_RX].bch = &hw->bch[0];
1910 hw->fifos[HFCUSB_B2_TX].bch = &hw->bch[1];
1911 hw->fifos[HFCUSB_B2_RX].bch = &hw->bch[1];
1912 hw->fifos[HFCUSB_D_TX].dch = &hw->dch;
1913 hw->fifos[HFCUSB_D_RX].dch = &hw->dch;
1914 hw->fifos[HFCUSB_PCM_RX].ech = &hw->ech;
1915 hw->fifos[HFCUSB_PCM_TX].ech = &hw->ech;
1916
1917 err = setup_hfcsusb(hw);
1918 if (err)
1919 goto out;
1920
1921 snprintf(hw->name, MISDN_MAX_IDLEN - 1, "%s.%d", DRIVER_NAME,
1922 hfcsusb_cnt + 1);
1923 printk(KERN_INFO "%s: registered as '%s'\n",
1924 DRIVER_NAME, hw->name);
1925
1926 err = mISDN_register_device(&hw->dch.dev, parent, hw->name);
1927 if (err)
1928 goto out;
1929
1930 hfcsusb_cnt++;
1931 write_lock_irqsave(&HFClock, flags);
1932 list_add_tail(&hw->list, &HFClist);
1933 write_unlock_irqrestore(&HFClock, flags);
1934 return 0;
1935
1936out:
1937 mISDN_freebchannel(&hw->bch[1]);
1938 mISDN_freebchannel(&hw->bch[0]);
1939 mISDN_freedchannel(&hw->dch);
1940 kfree(hw);
1941 return err;
1942}
1943
1944static int
1945hfcsusb_probe(struct usb_interface *intf, const struct usb_device_id *id)
1946{
1947 struct hfcsusb *hw;
1948 struct usb_device *dev = interface_to_usbdev(intf);
1949 struct usb_host_interface *iface = intf->cur_altsetting;
1950 struct usb_host_interface *iface_used = NULL;
1951 struct usb_host_endpoint *ep;
1952 struct hfcsusb_vdata *driver_info;
1953 int ifnum = iface->desc.bInterfaceNumber, i, idx, alt_idx,
1954 probe_alt_setting, vend_idx, cfg_used, *vcf, attr, cfg_found,
1955 ep_addr, cmptbl[16], small_match, iso_packet_size, packet_size,
1956 alt_used = 0;
1957
1958 vend_idx = 0xffff;
1959 for (i = 0; hfcsusb_idtab[i].idVendor; i++) {
1960 if ((le16_to_cpu(dev->descriptor.idVendor)
1961 == hfcsusb_idtab[i].idVendor) &&
1962 (le16_to_cpu(dev->descriptor.idProduct)
1963 == hfcsusb_idtab[i].idProduct)) {
1964 vend_idx = i;
1965 continue;
1966 }
1967 }
1968
1969 printk(KERN_DEBUG
1970 "%s: interface(%d) actalt(%d) minor(%d) vend_idx(%d)\n",
1971 __func__, ifnum, iface->desc.bAlternateSetting,
1972 intf->minor, vend_idx);
1973
1974 if (vend_idx == 0xffff) {
1975 printk(KERN_WARNING
1976 "%s: no valid vendor found in USB descriptor\n",
1977 __func__);
1978 return -EIO;
1979 }
1980 /* if vendor and product ID is OK, start probing alternate settings */
1981 alt_idx = 0;
1982 small_match = -1;
1983
1984 /* default settings */
1985 iso_packet_size = 16;
1986 packet_size = 64;
1987
1988 while (alt_idx < intf->num_altsetting) {
1989 iface = intf->altsetting + alt_idx;
1990 probe_alt_setting = iface->desc.bAlternateSetting;
1991 cfg_used = 0;
1992
1993 while (validconf[cfg_used][0]) {
1994 cfg_found = 1;
1995 vcf = validconf[cfg_used];
1996 ep = iface->endpoint;
1997 memcpy(cmptbl, vcf, 16 * sizeof(int));
1998
1999 /* check for all endpoints in this alternate setting */
2000 for (i = 0; i < iface->desc.bNumEndpoints; i++) {
2001 ep_addr = ep->desc.bEndpointAddress;
2002
2003 /* get endpoint base */
2004 idx = ((ep_addr & 0x7f) - 1) * 2;
2005 if (ep_addr & 0x80)
2006 idx++;
2007 attr = ep->desc.bmAttributes;
2008
2009 if (cmptbl[idx] != EP_NOP) {
2010 if (cmptbl[idx] == EP_NUL)
2011 cfg_found = 0;
2012 if (attr == USB_ENDPOINT_XFER_INT
2013 && cmptbl[idx] == EP_INT)
2014 cmptbl[idx] = EP_NUL;
2015 if (attr == USB_ENDPOINT_XFER_BULK
2016 && cmptbl[idx] == EP_BLK)
2017 cmptbl[idx] = EP_NUL;
2018 if (attr == USB_ENDPOINT_XFER_ISOC
2019 && cmptbl[idx] == EP_ISO)
2020 cmptbl[idx] = EP_NUL;
2021
2022 if (attr == USB_ENDPOINT_XFER_INT &&
2023 ep->desc.bInterval < vcf[17]) {
2024 cfg_found = 0;
2025 }
2026 }
2027 ep++;
2028 }
2029
2030 for (i = 0; i < 16; i++)
2031 if (cmptbl[i] != EP_NOP && cmptbl[i] != EP_NUL)
2032 cfg_found = 0;
2033
2034 if (cfg_found) {
2035 if (small_match < cfg_used) {
2036 small_match = cfg_used;
2037 alt_used = probe_alt_setting;
2038 iface_used = iface;
2039 }
2040 }
2041 cfg_used++;
2042 }
2043 alt_idx++;
2044 } /* (alt_idx < intf->num_altsetting) */
2045
2046 /* not found a valid USB Ta Endpoint config */
2047 if (small_match == -1)
2048 return -EIO;
2049
2050 iface = iface_used;
2051 hw = kzalloc(sizeof(struct hfcsusb), GFP_KERNEL);
2052 if (!hw)
2053 return -ENOMEM; /* got no mem */
2054 snprintf(hw->name, MISDN_MAX_IDLEN - 1, "%s", DRIVER_NAME);
2055
2056 ep = iface->endpoint;
2057 vcf = validconf[small_match];
2058
2059 for (i = 0; i < iface->desc.bNumEndpoints; i++) {
2060 struct usb_fifo *f;
2061
2062 ep_addr = ep->desc.bEndpointAddress;
2063 /* get endpoint base */
2064 idx = ((ep_addr & 0x7f) - 1) * 2;
2065 if (ep_addr & 0x80)
2066 idx++;
2067 f = &hw->fifos[idx & 7];
2068
2069 /* init Endpoints */
2070 if (vcf[idx] == EP_NOP || vcf[idx] == EP_NUL) {
2071 ep++;
2072 continue;
2073 }
2074 switch (ep->desc.bmAttributes) {
2075 case USB_ENDPOINT_XFER_INT:
2076 f->pipe = usb_rcvintpipe(dev,
2077 ep->desc.bEndpointAddress);
2078 f->usb_transfer_mode = USB_INT;
2079 packet_size = le16_to_cpu(ep->desc.wMaxPacketSize);
2080 break;
2081 case USB_ENDPOINT_XFER_BULK:
2082 if (ep_addr & 0x80)
2083 f->pipe = usb_rcvbulkpipe(dev,
2084 ep->desc.bEndpointAddress);
2085 else
2086 f->pipe = usb_sndbulkpipe(dev,
2087 ep->desc.bEndpointAddress);
2088 f->usb_transfer_mode = USB_BULK;
2089 packet_size = le16_to_cpu(ep->desc.wMaxPacketSize);
2090 break;
2091 case USB_ENDPOINT_XFER_ISOC:
2092 if (ep_addr & 0x80)
2093 f->pipe = usb_rcvisocpipe(dev,
2094 ep->desc.bEndpointAddress);
2095 else
2096 f->pipe = usb_sndisocpipe(dev,
2097 ep->desc.bEndpointAddress);
2098 f->usb_transfer_mode = USB_ISOC;
2099 iso_packet_size = le16_to_cpu(ep->desc.wMaxPacketSize);
2100 break;
2101 default:
2102 f->pipe = 0;
2103 }
2104
2105 if (f->pipe) {
2106 f->fifonum = idx & 7;
2107 f->hw = hw;
2108 f->usb_packet_maxlen =
2109 le16_to_cpu(ep->desc.wMaxPacketSize);
2110 f->intervall = ep->desc.bInterval;
2111 }
2112 ep++;
2113 }
2114 hw->dev = dev; /* save device */
2115 hw->if_used = ifnum; /* save used interface */
2116 hw->alt_used = alt_used; /* and alternate config */
2117 hw->ctrl_paksize = dev->descriptor.bMaxPacketSize0; /* control size */
2118 hw->cfg_used = vcf[16]; /* store used config */
2119 hw->vend_idx = vend_idx; /* store found vendor */
2120 hw->packet_size = packet_size;
2121 hw->iso_packet_size = iso_packet_size;
2122
2123 /* create the control pipes needed for register access */
2124 hw->ctrl_in_pipe = usb_rcvctrlpipe(hw->dev, 0);
2125 hw->ctrl_out_pipe = usb_sndctrlpipe(hw->dev, 0);
2126 hw->ctrl_urb = usb_alloc_urb(0, GFP_KERNEL);
2127
2128 driver_info =
2129 (struct hfcsusb_vdata *)hfcsusb_idtab[vend_idx].driver_info;
2130 printk(KERN_DEBUG "%s: %s: detected \"%s\" (%s, if=%d alt=%d)\n",
2131 hw->name, __func__, driver_info->vend_name,
2132 conf_str[small_match], ifnum, alt_used);
2133
2134 if (setup_instance(hw, dev->dev.parent))
2135 return -EIO;
2136
2137 hw->intf = intf;
2138 usb_set_intfdata(hw->intf, hw);
2139 return 0;
2140}
2141
2142/* function called when an active device is removed */
2143static void
2144hfcsusb_disconnect(struct usb_interface *intf)
2145{
2146 struct hfcsusb *hw = usb_get_intfdata(intf);
2147 struct hfcsusb *next;
2148 int cnt = 0;
2149
2150 printk(KERN_INFO "%s: device disconnected\n", hw->name);
2151
2152 handle_led(hw, LED_POWER_OFF);
2153 release_hw(hw);
2154
2155 list_for_each_entry_safe(hw, next, &HFClist, list)
2156 cnt++;
2157 if (!cnt)
2158 hfcsusb_cnt = 0;
2159
2160 usb_set_intfdata(intf, NULL);
2161}
2162
2163static struct usb_driver hfcsusb_drv = {
2164 .name = DRIVER_NAME,
2165 .id_table = hfcsusb_idtab,
2166 .probe = hfcsusb_probe,
2167 .disconnect = hfcsusb_disconnect,
2168};
2169
2170static int __init
2171hfcsusb_init(void)
2172{
2173 printk(KERN_INFO DRIVER_NAME " driver Rev. %s debug(0x%x) poll(%i)\n",
2174 hfcsusb_rev, debug, poll);
2175
2176 if (usb_register(&hfcsusb_drv)) {
2177 printk(KERN_INFO DRIVER_NAME
2178 ": Unable to register hfcsusb module at usb stack\n");
2179 return -ENODEV;
2180 }
2181
2182 return 0;
2183}
2184
2185static void __exit
2186hfcsusb_cleanup(void)
2187{
2188 if (debug & DBG_HFC_CALL_TRACE)
2189 printk(KERN_INFO DRIVER_NAME ": %s\n", __func__);
2190
2191 /* unregister Hardware */
2192 usb_deregister(&hfcsusb_drv); /* release our driver */
2193}
2194
2195module_init(hfcsusb_init);
2196module_exit(hfcsusb_cleanup);
diff --git a/drivers/isdn/hardware/mISDN/hfcsusb.h b/drivers/isdn/hardware/mISDN/hfcsusb.h
new file mode 100644
index 000000000000..098486b8e8d2
--- /dev/null
+++ b/drivers/isdn/hardware/mISDN/hfcsusb.h
@@ -0,0 +1,418 @@
1/*
2 * hfcsusb.h, HFC-S USB mISDN driver
3 */
4
5#ifndef __HFCSUSB_H__
6#define __HFCSUSB_H__
7
8
9#define DRIVER_NAME "HFC-S_USB"
10
11#define DBG_HFC_CALL_TRACE 0x00010000
12#define DBG_HFC_FIFO_VERBOSE 0x00020000
13#define DBG_HFC_USB_VERBOSE 0x00100000
14#define DBG_HFC_URB_INFO 0x00200000
15#define DBG_HFC_URB_ERROR 0x00400000
16
17#define DEFAULT_TRANSP_BURST_SZ 128
18
19#define HFC_CTRL_TIMEOUT 20 /* 5ms timeout writing/reading regs */
20#define CLKDEL_TE 0x0f /* CLKDEL in TE mode */
21#define CLKDEL_NT 0x6c /* CLKDEL in NT mode */
22
23/* hfcsusb Layer1 commands */
24#define HFC_L1_ACTIVATE_TE 1
25#define HFC_L1_ACTIVATE_NT 2
26#define HFC_L1_DEACTIVATE_NT 3
27#define HFC_L1_FORCE_DEACTIVATE_TE 4
28
29/* cmd FLAGS in HFCUSB_STATES register */
30#define HFCUSB_LOAD_STATE 0x10
31#define HFCUSB_ACTIVATE 0x20
32#define HFCUSB_DO_ACTION 0x40
33#define HFCUSB_NT_G2_G3 0x80
34
35/* timers */
36#define NT_ACTIVATION_TIMER 0x01 /* enables NT mode activation Timer */
37#define NT_T1_COUNT 10
38
39#define MAX_BCH_SIZE 2048 /* allowed B-channel packet size */
40
41#define HFCUSB_RX_THRESHOLD 64 /* threshold for fifo report bit rx */
42#define HFCUSB_TX_THRESHOLD 96 /* threshold for fifo report bit tx */
43
44#define HFCUSB_CHIP_ID 0x16 /* Chip ID register index */
45#define HFCUSB_CIRM 0x00 /* cirm register index */
46#define HFCUSB_USB_SIZE 0x07 /* int length register */
47#define HFCUSB_USB_SIZE_I 0x06 /* iso length register */
48#define HFCUSB_F_CROSS 0x0b /* bit order register */
49#define HFCUSB_CLKDEL 0x37 /* bit delay register */
50#define HFCUSB_CON_HDLC 0xfa /* channel connect register */
51#define HFCUSB_HDLC_PAR 0xfb
52#define HFCUSB_SCTRL 0x31 /* S-bus control register (tx) */
53#define HFCUSB_SCTRL_E 0x32 /* same for E and special funcs */
54#define HFCUSB_SCTRL_R 0x33 /* S-bus control register (rx) */
55#define HFCUSB_F_THRES 0x0c /* threshold register */
56#define HFCUSB_FIFO 0x0f /* fifo select register */
57#define HFCUSB_F_USAGE 0x1a /* fifo usage register */
58#define HFCUSB_MST_MODE0 0x14
59#define HFCUSB_MST_MODE1 0x15
60#define HFCUSB_P_DATA 0x1f
61#define HFCUSB_INC_RES_F 0x0e
62#define HFCUSB_B1_SSL 0x20
63#define HFCUSB_B2_SSL 0x21
64#define HFCUSB_B1_RSL 0x24
65#define HFCUSB_B2_RSL 0x25
66#define HFCUSB_STATES 0x30
67
68
69#define HFCUSB_CHIPID 0x40 /* ID value of HFC-S USB */
70
71/* fifo registers */
72#define HFCUSB_NUM_FIFOS 8 /* maximum number of fifos */
73#define HFCUSB_B1_TX 0 /* index for B1 transmit bulk/int */
74#define HFCUSB_B1_RX 1 /* index for B1 receive bulk/int */
75#define HFCUSB_B2_TX 2
76#define HFCUSB_B2_RX 3
77#define HFCUSB_D_TX 4
78#define HFCUSB_D_RX 5
79#define HFCUSB_PCM_TX 6
80#define HFCUSB_PCM_RX 7
81
82
83#define USB_INT 0
84#define USB_BULK 1
85#define USB_ISOC 2
86
87#define ISOC_PACKETS_D 8
88#define ISOC_PACKETS_B 8
89#define ISO_BUFFER_SIZE 128
90
91/* defines how much ISO packets are handled in one URB */
92static int iso_packets[8] =
93 { ISOC_PACKETS_B, ISOC_PACKETS_B, ISOC_PACKETS_B, ISOC_PACKETS_B,
94 ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D, ISOC_PACKETS_D
95};
96
97
98/* Fifo flow Control for TX ISO */
99#define SINK_MAX 68
100#define SINK_MIN 48
101#define SINK_DMIN 12
102#define SINK_DMAX 18
103#define BITLINE_INF (-96*8)
104
105/* HFC-S USB register access by Control-URSs */
106#define write_reg_atomic(a, b, c) \
107 usb_control_msg((a)->dev, (a)->ctrl_out_pipe, 0, 0x40, (c), (b), \
108 0, 0, HFC_CTRL_TIMEOUT)
109#define read_reg_atomic(a, b, c) \
110 usb_control_msg((a)->dev, (a)->ctrl_in_pipe, 1, 0xC0, 0, (b), (c), \
111 1, HFC_CTRL_TIMEOUT)
112#define HFC_CTRL_BUFSIZE 64
113
114struct ctrl_buf {
115 __u8 hfcs_reg; /* register number */
116 __u8 reg_val; /* value to be written (or read) */
117};
118
119/*
120 * URB error codes
121 * Used to represent a list of values and their respective symbolic names
122 */
123struct hfcusb_symbolic_list {
124 const int num;
125 const char *name;
126};
127
128static struct hfcusb_symbolic_list urb_errlist[] = {
129 {-ENOMEM, "No memory for allocation of internal structures"},
130 {-ENOSPC, "The host controller's bandwidth is already consumed"},
131 {-ENOENT, "URB was canceled by unlink_urb"},
132 {-EXDEV, "ISO transfer only partially completed"},
133 {-EAGAIN, "Too match scheduled for the future"},
134 {-ENXIO, "URB already queued"},
135 {-EFBIG, "Too much ISO frames requested"},
136 {-ENOSR, "Buffer error (overrun)"},
137 {-EPIPE, "Specified endpoint is stalled (device not responding)"},
138 {-EOVERFLOW, "Babble (bad cable?)"},
139 {-EPROTO, "Bit-stuff error (bad cable?)"},
140 {-EILSEQ, "CRC/Timeout"},
141 {-ETIMEDOUT, "NAK (device does not respond)"},
142 {-ESHUTDOWN, "Device unplugged"},
143 {-1, NULL}
144};
145
146static inline const char *
147symbolic(struct hfcusb_symbolic_list list[], const int num)
148{
149 int i;
150 for (i = 0; list[i].name != NULL; i++)
151 if (list[i].num == num)
152 return list[i].name;
153 return "<unkown USB Error>";
154}
155
156/* USB descriptor need to contain one of the following EndPoint combination: */
157#define CNF_4INT3ISO 1 /* 4 INT IN, 3 ISO OUT */
158#define CNF_3INT3ISO 2 /* 3 INT IN, 3 ISO OUT */
159#define CNF_4ISO3ISO 3 /* 4 ISO IN, 3 ISO OUT */
160#define CNF_3ISO3ISO 4 /* 3 ISO IN, 3 ISO OUT */
161
162#define EP_NUL 1 /* Endpoint at this position not allowed */
163#define EP_NOP 2 /* all type of endpoints allowed at this position */
164#define EP_ISO 3 /* Isochron endpoint mandatory at this position */
165#define EP_BLK 4 /* Bulk endpoint mandatory at this position */
166#define EP_INT 5 /* Interrupt endpoint mandatory at this position */
167
168#define HFC_CHAN_B1 0
169#define HFC_CHAN_B2 1
170#define HFC_CHAN_D 2
171#define HFC_CHAN_E 3
172
173
174/*
175 * List of all supported enpoints configiration sets, used to find the
176 * best matching endpoint configuration within a devices' USB descriptor.
177 * We need at least 3 RX endpoints, and 3 TX endpoints, either
178 * INT-in and ISO-out, or ISO-in and ISO-out)
179 * with 4 RX endpoints even E-Channel logging is possible
180 */
181static int
182validconf[][19] = {
183 /* INT in, ISO out config */
184 {EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NOP, EP_INT,
185 EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_NUL, EP_NUL,
186 CNF_4INT3ISO, 2, 1},
187 {EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_INT, EP_NUL, EP_NUL,
188 EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_ISO, EP_NUL, EP_NUL, EP_NUL,
189 CNF_3INT3ISO, 2, 0},
190 /* ISO in, ISO out config */
191 {EP_NOP, EP_NOP, EP_NOP, EP_NOP, EP_NOP, EP_NOP, EP_NOP, EP_NOP,
192 EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_NOP, EP_ISO,
193 CNF_4ISO3ISO, 2, 1},
194 {EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL, EP_NUL,
195 EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_ISO, EP_NUL, EP_NUL,
196 CNF_3ISO3ISO, 2, 0},
197 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} /* EOL element */
198};
199
200/* string description of chosen config */
201char *conf_str[] = {
202 "4 Interrupt IN + 3 Isochron OUT",
203 "3 Interrupt IN + 3 Isochron OUT",
204 "4 Isochron IN + 3 Isochron OUT",
205 "3 Isochron IN + 3 Isochron OUT"
206};
207
208
209#define LED_OFF 0 /* no LED support */
210#define LED_SCHEME1 1 /* LED standard scheme */
211#define LED_SCHEME2 2 /* not used yet... */
212
213#define LED_POWER_ON 1
214#define LED_POWER_OFF 2
215#define LED_S0_ON 3
216#define LED_S0_OFF 4
217#define LED_B1_ON 5
218#define LED_B1_OFF 6
219#define LED_B1_DATA 7
220#define LED_B2_ON 8
221#define LED_B2_OFF 9
222#define LED_B2_DATA 10
223
224#define LED_NORMAL 0 /* LEDs are normal */
225#define LED_INVERTED 1 /* LEDs are inverted */
226
227/* time in ms to perform a Flashing LED when B-Channel has traffic */
228#define LED_TIME 250
229
230
231
232struct hfcsusb;
233struct usb_fifo;
234
235/* structure defining input+output fifos (interrupt/bulk mode) */
236struct iso_urb {
237 struct urb *urb;
238 __u8 buffer[ISO_BUFFER_SIZE]; /* buffer rx/tx USB URB data */
239 struct usb_fifo *owner_fifo; /* pointer to owner fifo */
240 __u8 indx; /* Fifos's ISO double buffer 0 or 1 ? */
241#ifdef ISO_FRAME_START_DEBUG
242 int start_frames[ISO_FRAME_START_RING_COUNT];
243 __u8 iso_frm_strt_pos; /* index in start_frame[] */
244#endif
245};
246
247struct usb_fifo {
248 int fifonum; /* fifo index attached to this structure */
249 int active; /* fifo is currently active */
250 struct hfcsusb *hw; /* pointer to main structure */
251 int pipe; /* address of endpoint */
252 __u8 usb_packet_maxlen; /* maximum length for usb transfer */
253 unsigned int max_size; /* maximum size of receive/send packet */
254 __u8 intervall; /* interrupt interval */
255 struct urb *urb; /* transfer structure for usb routines */
256 __u8 buffer[128]; /* buffer USB INT OUT URB data */
257 int bit_line; /* how much bits are in the fifo? */
258
259 __u8 usb_transfer_mode; /* switched between ISO and INT */
260 struct iso_urb iso[2]; /* two urbs to have one always
261 one pending */
262
263 struct dchannel *dch; /* link to hfcsusb_t->dch */
264 struct bchannel *bch; /* link to hfcsusb_t->bch */
265 struct dchannel *ech; /* link to hfcsusb_t->ech, TODO: E-CHANNEL */
266 int last_urblen; /* remember length of last packet */
267 __u8 stop_gracefull; /* stops URB retransmission */
268};
269
270struct hfcsusb {
271 struct list_head list;
272 struct dchannel dch;
273 struct bchannel bch[2];
274 struct dchannel ech; /* TODO : wait for struct echannel ;) */
275
276 struct usb_device *dev; /* our device */
277 struct usb_interface *intf; /* used interface */
278 int if_used; /* used interface number */
279 int alt_used; /* used alternate config */
280 int cfg_used; /* configuration index used */
281 int vend_idx; /* index in hfcsusb_idtab */
282 int packet_size;
283 int iso_packet_size;
284 struct usb_fifo fifos[HFCUSB_NUM_FIFOS];
285
286 /* control pipe background handling */
287 struct ctrl_buf ctrl_buff[HFC_CTRL_BUFSIZE];
288 int ctrl_in_idx, ctrl_out_idx, ctrl_cnt;
289 struct urb *ctrl_urb;
290 struct usb_ctrlrequest ctrl_write;
291 struct usb_ctrlrequest ctrl_read;
292 int ctrl_paksize;
293 int ctrl_in_pipe, ctrl_out_pipe;
294 spinlock_t ctrl_lock; /* lock for ctrl */
295 spinlock_t lock;
296
297 __u8 threshold_mask;
298 __u8 led_state;
299
300 __u8 protocol;
301 int nt_timer;
302 int open;
303 __u8 timers;
304 __u8 initdone;
305 char name[MISDN_MAX_IDLEN];
306};
307
308/* private vendor specific data */
309struct hfcsusb_vdata {
310 __u8 led_scheme; /* led display scheme */
311 signed short led_bits[8]; /* array of 8 possible LED bitmask */
312 char *vend_name; /* device name */
313};
314
315
316#define HFC_MAX_TE_LAYER1_STATE 8
317#define HFC_MAX_NT_LAYER1_STATE 4
318
319const char *HFC_TE_LAYER1_STATES[HFC_MAX_TE_LAYER1_STATE + 1] = {
320 "TE F0 - Reset",
321 "TE F1 - Reset",
322 "TE F2 - Sensing",
323 "TE F3 - Deactivated",
324 "TE F4 - Awaiting signal",
325 "TE F5 - Identifying input",
326 "TE F6 - Synchronized",
327 "TE F7 - Activated",
328 "TE F8 - Lost framing",
329};
330
331const char *HFC_NT_LAYER1_STATES[HFC_MAX_NT_LAYER1_STATE + 1] = {
332 "NT G0 - Reset",
333 "NT G1 - Deactive",
334 "NT G2 - Pending activation",
335 "NT G3 - Active",
336 "NT G4 - Pending deactivation",
337};
338
339/* supported devices */
340static struct usb_device_id hfcsusb_idtab[] = {
341 {
342 USB_DEVICE(0x0959, 0x2bd0),
343 .driver_info = (unsigned long) &((struct hfcsusb_vdata)
344 {LED_OFF, {4, 0, 2, 1},
345 "ISDN USB TA (Cologne Chip HFC-S USB based)"}),
346 },
347 {
348 USB_DEVICE(0x0675, 0x1688),
349 .driver_info = (unsigned long) &((struct hfcsusb_vdata)
350 {LED_SCHEME1, {1, 2, 0, 0},
351 "DrayTek miniVigor 128 USB ISDN TA"}),
352 },
353 {
354 USB_DEVICE(0x07b0, 0x0007),
355 .driver_info = (unsigned long) &((struct hfcsusb_vdata)
356 {LED_SCHEME1, {0x80, -64, -32, -16},
357 "Billion tiny USB ISDN TA 128"}),
358 },
359 {
360 USB_DEVICE(0x0742, 0x2008),
361 .driver_info = (unsigned long) &((struct hfcsusb_vdata)
362 {LED_SCHEME1, {4, 0, 2, 1},
363 "Stollmann USB TA"}),
364 },
365 {
366 USB_DEVICE(0x0742, 0x2009),
367 .driver_info = (unsigned long) &((struct hfcsusb_vdata)
368 {LED_SCHEME1, {4, 0, 2, 1},
369 "Aceex USB ISDN TA"}),
370 },
371 {
372 USB_DEVICE(0x0742, 0x200A),
373 .driver_info = (unsigned long) &((struct hfcsusb_vdata)
374 {LED_SCHEME1, {4, 0, 2, 1},
375 "OEM USB ISDN TA"}),
376 },
377 {
378 USB_DEVICE(0x08e3, 0x0301),
379 .driver_info = (unsigned long) &((struct hfcsusb_vdata)
380 {LED_SCHEME1, {2, 0, 1, 4},
381 "Olitec USB RNIS"}),
382 },
383 {
384 USB_DEVICE(0x07fa, 0x0846),
385 .driver_info = (unsigned long) &((struct hfcsusb_vdata)
386 {LED_SCHEME1, {0x80, -64, -32, -16},
387 "Bewan Modem RNIS USB"}),
388 },
389 {
390 USB_DEVICE(0x07fa, 0x0847),
391 .driver_info = (unsigned long) &((struct hfcsusb_vdata)
392 {LED_SCHEME1, {0x80, -64, -32, -16},
393 "Djinn Numeris USB"}),
394 },
395 {
396 USB_DEVICE(0x07b0, 0x0006),
397 .driver_info = (unsigned long) &((struct hfcsusb_vdata)
398 {LED_SCHEME1, {0x80, -64, -32, -16},
399 "Twister ISDN TA"}),
400 },
401 {
402 USB_DEVICE(0x071d, 0x1005),
403 .driver_info = (unsigned long) &((struct hfcsusb_vdata)
404 {LED_SCHEME1, {0x02, 0, 0x01, 0x04},
405 "Eicon DIVA USB 4.0"}),
406 },
407 {
408 USB_DEVICE(0x0586, 0x0102),
409 .driver_info = (unsigned long) &((struct hfcsusb_vdata)
410 {LED_SCHEME1, {0x88, -64, -32, -16},
411 "ZyXEL OMNI.NET USB II"}),
412 },
413 { }
414};
415
416MODULE_DEVICE_TABLE(usb, hfcsusb_idtab);
417
418#endif /* __HFCSUSB_H__ */
diff --git a/drivers/isdn/hysdn/hysdn_net.c b/drivers/isdn/hysdn/hysdn_net.c
index 7ee5bd9f2bb4..579974cf4c9a 100644
--- a/drivers/isdn/hysdn/hysdn_net.c
+++ b/drivers/isdn/hysdn/hysdn_net.c
@@ -38,16 +38,12 @@ char *hysdn_net_revision = "$Revision: 1.8.6.4 $";
38/* inside the definition. */ 38/* inside the definition. */
39/****************************************************************************/ 39/****************************************************************************/
40struct net_local { 40struct net_local {
41 struct net_device netdev; /* the network device */
42 struct net_device_stats stats;
43 /* additional vars may be added here */
44 char dev_name[9]; /* our own device name */
45
46 /* Tx control lock. This protects the transmit buffer ring 41 /* Tx control lock. This protects the transmit buffer ring
47 * state along with the "tx full" state of the driver. This 42 * state along with the "tx full" state of the driver. This
48 * means all netif_queue flow control actions are protected 43 * means all netif_queue flow control actions are protected
49 * by this lock as well. 44 * by this lock as well.
50 */ 45 */
46 struct net_device *dev;
51 spinlock_t lock; 47 spinlock_t lock;
52 struct sk_buff *skbs[MAX_SKB_BUFFERS]; /* pointers to tx-skbs */ 48 struct sk_buff *skbs[MAX_SKB_BUFFERS]; /* pointers to tx-skbs */
53 int in_idx, out_idx; /* indexes to buffer ring */ 49 int in_idx, out_idx; /* indexes to buffer ring */
@@ -55,15 +51,6 @@ struct net_local {
55}; /* net_local */ 51}; /* net_local */
56 52
57 53
58/*****************************************************/
59/* Get the current statistics for this card. */
60/* This may be called with the card open or closed ! */
61/*****************************************************/
62static struct net_device_stats *
63net_get_stats(struct net_device *dev)
64{
65 return (&((struct net_local *) dev)->stats);
66} /* net_device_stats */
67 54
68/*********************************************************************/ 55/*********************************************************************/
69/* Open/initialize the board. This is called (in the current kernel) */ 56/* Open/initialize the board. This is called (in the current kernel) */
@@ -182,8 +169,8 @@ hysdn_tx_netack(hysdn_card * card)
182 if (!lp->sk_count) 169 if (!lp->sk_count)
183 return; /* error condition */ 170 return; /* error condition */
184 171
185 lp->stats.tx_packets++; 172 lp->dev->stats.tx_packets++;
186 lp->stats.tx_bytes += lp->skbs[lp->out_idx]->len; 173 lp->dev->stats.tx_bytes += lp->skbs[lp->out_idx]->len;
187 174
188 dev_kfree_skb(lp->skbs[lp->out_idx++]); /* free skb */ 175 dev_kfree_skb(lp->skbs[lp->out_idx++]); /* free skb */
189 if (lp->out_idx >= MAX_SKB_BUFFERS) 176 if (lp->out_idx >= MAX_SKB_BUFFERS)
@@ -200,29 +187,30 @@ void
200hysdn_rx_netpkt(hysdn_card * card, unsigned char *buf, unsigned short len) 187hysdn_rx_netpkt(hysdn_card * card, unsigned char *buf, unsigned short len)
201{ 188{
202 struct net_local *lp = card->netif; 189 struct net_local *lp = card->netif;
190 struct net_device *dev = lp->dev;
203 struct sk_buff *skb; 191 struct sk_buff *skb;
204 192
205 if (!lp) 193 if (!lp)
206 return; /* non existing device */ 194 return; /* non existing device */
207 195
208 lp->stats.rx_bytes += len; 196 dev->stats.rx_bytes += len;
209 197
210 skb = dev_alloc_skb(len); 198 skb = dev_alloc_skb(len);
211 if (skb == NULL) { 199 if (skb == NULL) {
212 printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", 200 printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n",
213 lp->netdev.name); 201 dev->name);
214 lp->stats.rx_dropped++; 202 dev->stats.rx_dropped++;
215 return; 203 return;
216 } 204 }
217 /* copy the data */ 205 /* copy the data */
218 memcpy(skb_put(skb, len), buf, len); 206 memcpy(skb_put(skb, len), buf, len);
219 207
220 /* determine the used protocol */ 208 /* determine the used protocol */
221 skb->protocol = eth_type_trans(skb, &lp->netdev); 209 skb->protocol = eth_type_trans(skb, dev);
222 210
223 netif_rx(skb); 211 dev->stats.rx_packets++; /* adjust packet count */
224 lp->stats.rx_packets++; /* adjust packet count */
225 212
213 netif_rx(skb);
226} /* hysdn_rx_netpkt */ 214} /* hysdn_rx_netpkt */
227 215
228/*****************************************************/ 216/*****************************************************/
@@ -242,24 +230,15 @@ hysdn_tx_netget(hysdn_card * card)
242 return (lp->skbs[lp->out_idx]); /* next packet to send */ 230 return (lp->skbs[lp->out_idx]); /* next packet to send */
243} /* hysdn_tx_netget */ 231} /* hysdn_tx_netget */
244 232
233static const struct net_device_ops hysdn_netdev_ops = {
234 .ndo_open = net_open,
235 .ndo_stop = net_close,
236 .ndo_start_xmit = net_send_packet,
237 .ndo_change_mtu = eth_change_mtu,
238 .ndo_set_mac_address = eth_mac_addr,
239 .ndo_validate_addr = eth_validate_addr,
240};
245 241
246/*******************************************/
247/* init function called by register device */
248/*******************************************/
249static int
250net_init(struct net_device *dev)
251{
252 /* setup the function table */
253 dev->open = net_open;
254 dev->stop = net_close;
255 dev->hard_start_xmit = net_send_packet;
256 dev->get_stats = net_get_stats;
257
258 /* Fill in the fields of the device structure with ethernet values. */
259 ether_setup(dev);
260
261 return (0); /* success */
262} /* net_init */
263 242
264/*****************************************************************************/ 243/*****************************************************************************/
265/* hysdn_net_create creates a new net device for the given card. If a device */ 244/* hysdn_net_create creates a new net device for the given card. If a device */
@@ -271,28 +250,34 @@ hysdn_net_create(hysdn_card * card)
271{ 250{
272 struct net_device *dev; 251 struct net_device *dev;
273 int i; 252 int i;
253 struct net_local *lp;
254
274 if(!card) { 255 if(!card) {
275 printk(KERN_WARNING "No card-pt in hysdn_net_create!\n"); 256 printk(KERN_WARNING "No card-pt in hysdn_net_create!\n");
276 return (-ENOMEM); 257 return (-ENOMEM);
277 } 258 }
278 hysdn_net_release(card); /* release an existing net device */ 259 hysdn_net_release(card); /* release an existing net device */
279 if ((dev = kzalloc(sizeof(struct net_local), GFP_KERNEL)) == NULL) { 260
261 dev = alloc_etherdev(sizeof(struct net_local));
262 if (!dev) {
280 printk(KERN_WARNING "HYSDN: unable to allocate mem\n"); 263 printk(KERN_WARNING "HYSDN: unable to allocate mem\n");
281 return (-ENOMEM); 264 return (-ENOMEM);
282 } 265 }
283 266
267 lp = netdev_priv(dev);
268 lp->dev = dev;
269
270 dev->netdev_ops = &hysdn_netdev_ops;
284 spin_lock_init(&((struct net_local *) dev)->lock); 271 spin_lock_init(&((struct net_local *) dev)->lock);
285 272
286 /* initialise necessary or informing fields */ 273 /* initialise necessary or informing fields */
287 dev->base_addr = card->iobase; /* IO address */ 274 dev->base_addr = card->iobase; /* IO address */
288 dev->irq = card->irq; /* irq */ 275 dev->irq = card->irq; /* irq */
289 dev->init = net_init; /* the init function of the device */ 276
290 if(dev->name) { 277 dev->netdev_ops = &hysdn_netdev_ops;
291 strcpy(dev->name, ((struct net_local *) dev)->dev_name);
292 }
293 if ((i = register_netdev(dev))) { 278 if ((i = register_netdev(dev))) {
294 printk(KERN_WARNING "HYSDN: unable to create network device\n"); 279 printk(KERN_WARNING "HYSDN: unable to create network device\n");
295 kfree(dev); 280 free_netdev(dev);
296 return (i); 281 return (i);
297 } 282 }
298 dev->ml_priv = card; /* remember pointer to own data structure */ 283 dev->ml_priv = card; /* remember pointer to own data structure */
@@ -316,7 +301,7 @@ hysdn_net_release(hysdn_card * card)
316 return (0); /* non existing */ 301 return (0); /* non existing */
317 302
318 card->netif = NULL; /* clear out pointer */ 303 card->netif = NULL; /* clear out pointer */
319 dev->stop(dev); /* close the device */ 304 net_close(dev);
320 305
321 flush_tx_buffers((struct net_local *) dev); /* empty buffers */ 306 flush_tx_buffers((struct net_local *) dev); /* empty buffers */
322 307
diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c
index 023ea11d2f9e..cb8943da4f12 100644
--- a/drivers/isdn/i4l/isdn_net.c
+++ b/drivers/isdn/i4l/isdn_net.c
@@ -292,7 +292,9 @@ isdn_net_unbind_channel(isdn_net_local * lp)
292 lp->dialstate = 0; 292 lp->dialstate = 0;
293 dev->rx_netdev[isdn_dc2minor(lp->isdn_device, lp->isdn_channel)] = NULL; 293 dev->rx_netdev[isdn_dc2minor(lp->isdn_device, lp->isdn_channel)] = NULL;
294 dev->st_netdev[isdn_dc2minor(lp->isdn_device, lp->isdn_channel)] = NULL; 294 dev->st_netdev[isdn_dc2minor(lp->isdn_device, lp->isdn_channel)] = NULL;
295 isdn_free_channel(lp->isdn_device, lp->isdn_channel, ISDN_USAGE_NET); 295 if (lp->isdn_device != -1 && lp->isdn_channel != -1)
296 isdn_free_channel(lp->isdn_device, lp->isdn_channel,
297 ISDN_USAGE_NET);
296 lp->flags &= ~ISDN_NET_CONNECTED; 298 lp->flags &= ~ISDN_NET_CONNECTED;
297 lp->isdn_device = -1; 299 lp->isdn_device = -1;
298 lp->isdn_channel = -1; 300 lp->isdn_channel = -1;
@@ -1485,6 +1487,24 @@ isdn_ciscohdlck_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1485 return (rc); 1487 return (rc);
1486} 1488}
1487 1489
1490
1491static int isdn_net_ioctl(struct net_device *dev,
1492 struct ifreq *ifr, int cmd)
1493{
1494 isdn_net_local *lp = (isdn_net_local *) netdev_priv(dev);
1495
1496 switch (lp->p_encap) {
1497#ifdef CONFIG_ISDN_PPP
1498 case ISDN_NET_ENCAP_SYNCPPP:
1499 return isdn_ppp_dev_ioctl(dev, ifr, cmd);
1500#endif
1501 case ISDN_NET_ENCAP_CISCOHDLCK:
1502 return isdn_ciscohdlck_dev_ioctl(dev, ifr, cmd);
1503 default:
1504 return -EINVAL;
1505 }
1506}
1507
1488/* called via cisco_timer.function */ 1508/* called via cisco_timer.function */
1489static void 1509static void
1490isdn_net_ciscohdlck_slarp_send_keepalive(unsigned long data) 1510isdn_net_ciscohdlck_slarp_send_keepalive(unsigned long data)
@@ -1998,23 +2018,6 @@ isdn_net_init(struct net_device *ndev)
1998 ushort max_hlhdr_len = 0; 2018 ushort max_hlhdr_len = 0;
1999 int drvidx; 2019 int drvidx;
2000 2020
2001 ether_setup(ndev);
2002 ndev->header_ops = NULL;
2003
2004 /* Setup the generic properties */
2005 ndev->mtu = 1500;
2006 ndev->flags = IFF_NOARP|IFF_POINTOPOINT;
2007 ndev->type = ARPHRD_ETHER;
2008 ndev->addr_len = ETH_ALEN;
2009 ndev->validate_addr = NULL;
2010
2011 /* for clients with MPPP maybe higher values better */
2012 ndev->tx_queue_len = 30;
2013
2014 /* The ISDN-specific entries in the device structure. */
2015 ndev->open = &isdn_net_open;
2016 ndev->hard_start_xmit = &isdn_net_start_xmit;
2017
2018 /* 2021 /*
2019 * up till binding we ask the protocol layer to reserve as much 2022 * up till binding we ask the protocol layer to reserve as much
2020 * as we might need for HL layer 2023 * as we might need for HL layer
@@ -2026,9 +2029,6 @@ isdn_net_init(struct net_device *ndev)
2026 max_hlhdr_len = dev->drv[drvidx]->interface->hl_hdrlen; 2029 max_hlhdr_len = dev->drv[drvidx]->interface->hl_hdrlen;
2027 2030
2028 ndev->hard_header_len = ETH_HLEN + max_hlhdr_len; 2031 ndev->hard_header_len = ETH_HLEN + max_hlhdr_len;
2029 ndev->stop = &isdn_net_close;
2030 ndev->get_stats = &isdn_net_get_stats;
2031 ndev->do_ioctl = NULL;
2032 return 0; 2032 return 0;
2033} 2033}
2034 2034
@@ -2508,6 +2508,18 @@ isdn_net_force_dial(char *name)
2508 return (isdn_net_force_dial_lp(p->local)); 2508 return (isdn_net_force_dial_lp(p->local));
2509} 2509}
2510 2510
2511/* The ISDN-specific entries in the device structure. */
2512static const struct net_device_ops isdn_netdev_ops = {
2513 .ndo_init = isdn_net_init,
2514 .ndo_open = isdn_net_open,
2515 .ndo_stop = isdn_net_close,
2516 .ndo_do_ioctl = isdn_net_ioctl,
2517
2518 .ndo_start_xmit = isdn_net_start_xmit,
2519 .ndo_get_stats = isdn_net_get_stats,
2520 .ndo_tx_timeout = isdn_net_tx_timeout,
2521};
2522
2511/* 2523/*
2512 * Helper for alloc_netdev() 2524 * Helper for alloc_netdev()
2513 */ 2525 */
@@ -2515,7 +2527,16 @@ static void _isdn_setup(struct net_device *dev)
2515{ 2527{
2516 isdn_net_local *lp = netdev_priv(dev); 2528 isdn_net_local *lp = netdev_priv(dev);
2517 2529
2518 dev->flags = IFF_NOARP | IFF_POINTOPOINT; 2530 ether_setup(dev);
2531
2532 /* Setup the generic properties */
2533 dev->flags = IFF_NOARP|IFF_POINTOPOINT;
2534 dev->header_ops = NULL;
2535 dev->netdev_ops = &isdn_netdev_ops;
2536
2537 /* for clients with MPPP maybe higher values better */
2538 dev->tx_queue_len = 30;
2539
2519 lp->p_encap = ISDN_NET_ENCAP_RAWIP; 2540 lp->p_encap = ISDN_NET_ENCAP_RAWIP;
2520 lp->magic = ISDN_NET_MAGIC; 2541 lp->magic = ISDN_NET_MAGIC;
2521 lp->last = lp; 2542 lp->last = lp;
@@ -2570,7 +2591,7 @@ isdn_net_new(char *name, struct net_device *master)
2570 return NULL; 2591 return NULL;
2571 } 2592 }
2572 netdev->local = netdev_priv(netdev->dev); 2593 netdev->local = netdev_priv(netdev->dev);
2573 netdev->dev->init = isdn_net_init; 2594
2574 if (master) { 2595 if (master) {
2575 /* Device shall be a slave */ 2596 /* Device shall be a slave */
2576 struct net_device *p = MASTER_TO_SLAVE(master); 2597 struct net_device *p = MASTER_TO_SLAVE(master);
@@ -2588,7 +2609,6 @@ isdn_net_new(char *name, struct net_device *master)
2588 /* 2609 /*
2589 * Watchdog timer (currently) for master only. 2610 * Watchdog timer (currently) for master only.
2590 */ 2611 */
2591 netdev->dev->tx_timeout = isdn_net_tx_timeout;
2592 netdev->dev->watchdog_timeo = ISDN_NET_TX_TIMEOUT; 2612 netdev->dev->watchdog_timeo = ISDN_NET_TX_TIMEOUT;
2593 if (register_netdev(netdev->dev) != 0) { 2613 if (register_netdev(netdev->dev) != 0) {
2594 printk(KERN_WARNING "isdn_net: Could not register net-device\n"); 2614 printk(KERN_WARNING "isdn_net: Could not register net-device\n");
@@ -2704,7 +2724,6 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg)
2704#else 2724#else
2705 p->dev->type = ARPHRD_PPP; /* change ARP type */ 2725 p->dev->type = ARPHRD_PPP; /* change ARP type */
2706 p->dev->addr_len = 0; 2726 p->dev->addr_len = 0;
2707 p->dev->do_ioctl = isdn_ppp_dev_ioctl;
2708#endif 2727#endif
2709 break; 2728 break;
2710 case ISDN_NET_ENCAP_X25IFACE: 2729 case ISDN_NET_ENCAP_X25IFACE:
@@ -2718,7 +2737,6 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg)
2718#endif 2737#endif
2719 break; 2738 break;
2720 case ISDN_NET_ENCAP_CISCOHDLCK: 2739 case ISDN_NET_ENCAP_CISCOHDLCK:
2721 p->dev->do_ioctl = isdn_ciscohdlck_dev_ioctl;
2722 break; 2740 break;
2723 default: 2741 default:
2724 if( cfg->p_encap >= 0 && 2742 if( cfg->p_encap >= 0 &&
diff --git a/drivers/isdn/mISDN/Makefile b/drivers/isdn/mISDN/Makefile
index 1cb5e633cf75..0a6bd2a9e730 100644
--- a/drivers/isdn/mISDN/Makefile
+++ b/drivers/isdn/mISDN/Makefile
@@ -8,6 +8,6 @@ obj-$(CONFIG_MISDN_L1OIP) += l1oip.o
8 8
9# multi objects 9# multi objects
10 10
11mISDN_core-objs := core.o fsm.o socket.o hwchannel.o stack.o layer1.o layer2.o tei.o timerdev.o 11mISDN_core-objs := core.o fsm.o socket.o clock.o hwchannel.o stack.o layer1.o layer2.o tei.o timerdev.o
12mISDN_dsp-objs := dsp_core.o dsp_cmx.o dsp_tones.o dsp_dtmf.o dsp_audio.o dsp_blowfish.o dsp_pipeline.o dsp_hwec.o 12mISDN_dsp-objs := dsp_core.o dsp_cmx.o dsp_tones.o dsp_dtmf.o dsp_audio.o dsp_blowfish.o dsp_pipeline.o dsp_hwec.o
13l1oip-objs := l1oip_core.o l1oip_codec.o 13l1oip-objs := l1oip_core.o l1oip_codec.o
diff --git a/drivers/isdn/mISDN/clock.c b/drivers/isdn/mISDN/clock.c
new file mode 100644
index 000000000000..44d9c3d5d33d
--- /dev/null
+++ b/drivers/isdn/mISDN/clock.c
@@ -0,0 +1,216 @@
1/*
2 * Copyright 2008 by Andreas Eversberg <andreas@eversberg.eu>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * Quick API description:
14 *
15 * A clock source registers using mISDN_register_clock:
16 * name = text string to name clock source
17 * priority = value to priorize clock sources (0 = default)
18 * ctl = callback function to enable/disable clock source
19 * priv = private pointer of clock source
20 * return = pointer to clock source structure;
21 *
22 * Note: Callback 'ctl' can be called before mISDN_register_clock returns!
23 * Also it can be called during mISDN_unregister_clock.
24 *
25 * A clock source calls mISDN_clock_update with given samples elapsed, if
26 * enabled. If function call is delayed, tv must be set with the timestamp
27 * of the actual event.
28 *
29 * A clock source unregisters using mISDN_unregister_clock.
30 *
31 * To get current clock, call mISDN_clock_get. The signed short value
32 * counts the number of samples since. Time since last clock event is added.
33 *
34 */
35
36#include <linux/types.h>
37#include <linux/stddef.h>
38#include <linux/spinlock.h>
39#include <linux/mISDNif.h>
40#include "core.h"
41
42static u_int *debug;
43static LIST_HEAD(iclock_list);
44DEFINE_RWLOCK(iclock_lock);
45u16 iclock_count; /* counter of last clock */
46struct timeval iclock_tv; /* time stamp of last clock */
47int iclock_tv_valid; /* already received one timestamp */
48struct mISDNclock *iclock_current;
49
50void
51mISDN_init_clock(u_int *dp)
52{
53 debug = dp;
54 do_gettimeofday(&iclock_tv);
55}
56
57static void
58select_iclock(void)
59{
60 struct mISDNclock *iclock, *bestclock = NULL, *lastclock = NULL;
61 int pri = -128;
62
63 list_for_each_entry(iclock, &iclock_list, list) {
64 if (iclock->pri > pri) {
65 pri = iclock->pri;
66 bestclock = iclock;
67 }
68 if (iclock_current == iclock)
69 lastclock = iclock;
70 }
71 if (lastclock && bestclock != lastclock) {
72 /* last used clock source still exists but changes, disable */
73 if (*debug & DEBUG_CLOCK)
74 printk(KERN_DEBUG "Old clock source '%s' disable.\n",
75 lastclock->name);
76 lastclock->ctl(lastclock->priv, 0);
77 }
78 if (bestclock && bestclock != iclock_current) {
79 /* new clock source selected, enable */
80 if (*debug & DEBUG_CLOCK)
81 printk(KERN_DEBUG "New clock source '%s' enable.\n",
82 bestclock->name);
83 bestclock->ctl(bestclock->priv, 1);
84 }
85 if (bestclock != iclock_current) {
86 /* no clock received yet */
87 iclock_tv_valid = 0;
88 }
89 iclock_current = bestclock;
90}
91
92struct mISDNclock
93*mISDN_register_clock(char *name, int pri, clockctl_func_t *ctl, void *priv)
94{
95 u_long flags;
96 struct mISDNclock *iclock;
97
98 if (*debug & (DEBUG_CORE | DEBUG_CLOCK))
99 printk(KERN_DEBUG "%s: %s %d\n", __func__, name, pri);
100 iclock = kzalloc(sizeof(struct mISDNclock), GFP_ATOMIC);
101 if (!iclock) {
102 printk(KERN_ERR "%s: No memory for clock entry.\n", __func__);
103 return NULL;
104 }
105 strncpy(iclock->name, name, sizeof(iclock->name)-1);
106 iclock->pri = pri;
107 iclock->priv = priv;
108 iclock->ctl = ctl;
109 write_lock_irqsave(&iclock_lock, flags);
110 list_add_tail(&iclock->list, &iclock_list);
111 select_iclock();
112 write_unlock_irqrestore(&iclock_lock, flags);
113 return iclock;
114}
115EXPORT_SYMBOL(mISDN_register_clock);
116
117void
118mISDN_unregister_clock(struct mISDNclock *iclock)
119{
120 u_long flags;
121
122 if (*debug & (DEBUG_CORE | DEBUG_CLOCK))
123 printk(KERN_DEBUG "%s: %s %d\n", __func__, iclock->name,
124 iclock->pri);
125 write_lock_irqsave(&iclock_lock, flags);
126 if (iclock_current == iclock) {
127 if (*debug & DEBUG_CLOCK)
128 printk(KERN_DEBUG
129 "Current clock source '%s' unregisters.\n",
130 iclock->name);
131 iclock->ctl(iclock->priv, 0);
132 }
133 list_del(&iclock->list);
134 select_iclock();
135 write_unlock_irqrestore(&iclock_lock, flags);
136}
137EXPORT_SYMBOL(mISDN_unregister_clock);
138
139void
140mISDN_clock_update(struct mISDNclock *iclock, int samples, struct timeval *tv)
141{
142 u_long flags;
143 struct timeval tv_now;
144 time_t elapsed_sec;
145 int elapsed_8000th;
146
147 write_lock_irqsave(&iclock_lock, flags);
148 if (iclock_current != iclock) {
149 printk(KERN_ERR "%s: '%s' sends us clock updates, but we do "
150 "listen to '%s'. This is a bug!\n", __func__,
151 iclock->name,
152 iclock_current ? iclock_current->name : "nothing");
153 iclock->ctl(iclock->priv, 0);
154 write_unlock_irqrestore(&iclock_lock, flags);
155 return;
156 }
157 if (iclock_tv_valid) {
158 /* increment sample counter by given samples */
159 iclock_count += samples;
160 if (tv) { /* tv must be set, if function call is delayed */
161 iclock_tv.tv_sec = tv->tv_sec;
162 iclock_tv.tv_usec = tv->tv_usec;
163 } else
164 do_gettimeofday(&iclock_tv);
165 } else {
166 /* calc elapsed time by system clock */
167 if (tv) { /* tv must be set, if function call is delayed */
168 tv_now.tv_sec = tv->tv_sec;
169 tv_now.tv_usec = tv->tv_usec;
170 } else
171 do_gettimeofday(&tv_now);
172 elapsed_sec = tv_now.tv_sec - iclock_tv.tv_sec;
173 elapsed_8000th = (tv_now.tv_usec / 125)
174 - (iclock_tv.tv_usec / 125);
175 if (elapsed_8000th < 0) {
176 elapsed_sec -= 1;
177 elapsed_8000th += 8000;
178 }
179 /* add elapsed time to counter and set new timestamp */
180 iclock_count += elapsed_sec * 8000 + elapsed_8000th;
181 iclock_tv.tv_sec = tv_now.tv_sec;
182 iclock_tv.tv_usec = tv_now.tv_usec;
183 iclock_tv_valid = 1;
184 if (*debug & DEBUG_CLOCK)
185 printk("Received first clock from source '%s'.\n",
186 iclock_current ? iclock_current->name : "nothing");
187 }
188 write_unlock_irqrestore(&iclock_lock, flags);
189}
190EXPORT_SYMBOL(mISDN_clock_update);
191
192unsigned short
193mISDN_clock_get(void)
194{
195 u_long flags;
196 struct timeval tv_now;
197 time_t elapsed_sec;
198 int elapsed_8000th;
199 u16 count;
200
201 read_lock_irqsave(&iclock_lock, flags);
202 /* calc elapsed time by system clock */
203 do_gettimeofday(&tv_now);
204 elapsed_sec = tv_now.tv_sec - iclock_tv.tv_sec;
205 elapsed_8000th = (tv_now.tv_usec / 125) - (iclock_tv.tv_usec / 125);
206 if (elapsed_8000th < 0) {
207 elapsed_sec -= 1;
208 elapsed_8000th += 8000;
209 }
210 /* add elapsed time to counter */
211 count = iclock_count + elapsed_sec * 8000 + elapsed_8000th;
212 read_unlock_irqrestore(&iclock_lock, flags);
213 return count;
214}
215EXPORT_SYMBOL(mISDN_clock_get);
216
diff --git a/drivers/isdn/mISDN/core.c b/drivers/isdn/mISDN/core.c
index 751665c448d0..9426c9827e47 100644
--- a/drivers/isdn/mISDN/core.c
+++ b/drivers/isdn/mISDN/core.c
@@ -25,39 +25,183 @@ MODULE_AUTHOR("Karsten Keil");
25MODULE_LICENSE("GPL"); 25MODULE_LICENSE("GPL");
26module_param(debug, uint, S_IRUGO | S_IWUSR); 26module_param(debug, uint, S_IRUGO | S_IWUSR);
27 27
28static LIST_HEAD(devices);
29static DEFINE_RWLOCK(device_lock);
30static u64 device_ids; 28static u64 device_ids;
31#define MAX_DEVICE_ID 63 29#define MAX_DEVICE_ID 63
32 30
33static LIST_HEAD(Bprotocols); 31static LIST_HEAD(Bprotocols);
34static DEFINE_RWLOCK(bp_lock); 32static DEFINE_RWLOCK(bp_lock);
35 33
34static void mISDN_dev_release(struct device *dev)
35{
36 /* nothing to do: the device is part of its parent's data structure */
37}
38
39static ssize_t _show_id(struct device *dev,
40 struct device_attribute *attr, char *buf)
41{
42 struct mISDNdevice *mdev = dev_to_mISDN(dev);
43
44 if (!mdev)
45 return -ENODEV;
46 return sprintf(buf, "%d\n", mdev->id);
47}
48
49static ssize_t _show_nrbchan(struct device *dev,
50 struct device_attribute *attr, char *buf)
51{
52 struct mISDNdevice *mdev = dev_to_mISDN(dev);
53
54 if (!mdev)
55 return -ENODEV;
56 return sprintf(buf, "%d\n", mdev->nrbchan);
57}
58
59static ssize_t _show_d_protocols(struct device *dev,
60 struct device_attribute *attr, char *buf)
61{
62 struct mISDNdevice *mdev = dev_to_mISDN(dev);
63
64 if (!mdev)
65 return -ENODEV;
66 return sprintf(buf, "%d\n", mdev->Dprotocols);
67}
68
69static ssize_t _show_b_protocols(struct device *dev,
70 struct device_attribute *attr, char *buf)
71{
72 struct mISDNdevice *mdev = dev_to_mISDN(dev);
73
74 if (!mdev)
75 return -ENODEV;
76 return sprintf(buf, "%d\n", mdev->Bprotocols | get_all_Bprotocols());
77}
78
79static ssize_t _show_protocol(struct device *dev,
80 struct device_attribute *attr, char *buf)
81{
82 struct mISDNdevice *mdev = dev_to_mISDN(dev);
83
84 if (!mdev)
85 return -ENODEV;
86 return sprintf(buf, "%d\n", mdev->D.protocol);
87}
88
89static ssize_t _show_name(struct device *dev,
90 struct device_attribute *attr, char *buf)
91{
92 strcpy(buf, dev_name(dev));
93 return strlen(buf);
94}
95
96#if 0 /* hangs */
97static ssize_t _set_name(struct device *dev, struct device_attribute *attr,
98 const char *buf, size_t count)
99{
100 int err = 0;
101 char *out = kmalloc(count + 1, GFP_KERNEL);
102
103 if (!out)
104 return -ENOMEM;
105
106 memcpy(out, buf, count);
107 if (count && out[count - 1] == '\n')
108 out[--count] = 0;
109 if (count)
110 err = device_rename(dev, out);
111 kfree(out);
112
113 return (err < 0) ? err : count;
114}
115#endif
116
117static ssize_t _show_channelmap(struct device *dev,
118 struct device_attribute *attr, char *buf)
119{
120 struct mISDNdevice *mdev = dev_to_mISDN(dev);
121 char *bp = buf;
122 int i;
123
124 for (i = 0; i <= mdev->nrbchan; i++)
125 *bp++ = test_channelmap(i, mdev->channelmap) ? '1' : '0';
126
127 return bp - buf;
128}
129
130static struct device_attribute mISDN_dev_attrs[] = {
131 __ATTR(id, S_IRUGO, _show_id, NULL),
132 __ATTR(d_protocols, S_IRUGO, _show_d_protocols, NULL),
133 __ATTR(b_protocols, S_IRUGO, _show_b_protocols, NULL),
134 __ATTR(protocol, S_IRUGO, _show_protocol, NULL),
135 __ATTR(channelmap, S_IRUGO, _show_channelmap, NULL),
136 __ATTR(nrbchan, S_IRUGO, _show_nrbchan, NULL),
137 __ATTR(name, S_IRUGO, _show_name, NULL),
138/* __ATTR(name, S_IRUGO|S_IWUSR, _show_name, _set_name), */
139 {}
140};
141
142#ifdef CONFIG_HOTPLUG
143static int mISDN_uevent(struct device *dev, struct kobj_uevent_env *env)
144{
145 struct mISDNdevice *mdev = dev_to_mISDN(dev);
146
147 if (!mdev)
148 return 0;
149
150 if (add_uevent_var(env, "nchans=%d", mdev->nrbchan))
151 return -ENOMEM;
152
153 return 0;
154}
155#endif
156
157static void mISDN_class_release(struct class *cls)
158{
159 /* do nothing, it's static */
160}
161
162static struct class mISDN_class = {
163 .name = "mISDN",
164 .owner = THIS_MODULE,
165#ifdef CONFIG_HOTPLUG
166 .dev_uevent = mISDN_uevent,
167#endif
168 .dev_attrs = mISDN_dev_attrs,
169 .dev_release = mISDN_dev_release,
170 .class_release = mISDN_class_release,
171};
172
173static int
174_get_mdevice(struct device *dev, void *id)
175{
176 struct mISDNdevice *mdev = dev_to_mISDN(dev);
177
178 if (!mdev)
179 return 0;
180 if (mdev->id != *(u_int *)id)
181 return 0;
182 return 1;
183}
184
36struct mISDNdevice 185struct mISDNdevice
37*get_mdevice(u_int id) 186*get_mdevice(u_int id)
38{ 187{
39 struct mISDNdevice *dev; 188 return dev_to_mISDN(class_find_device(&mISDN_class, NULL, &id,
189 _get_mdevice));
190}
40 191
41 read_lock(&device_lock); 192static int
42 list_for_each_entry(dev, &devices, D.list) 193_get_mdevice_count(struct device *dev, void *cnt)
43 if (dev->id == id) { 194{
44 read_unlock(&device_lock); 195 *(int *)cnt += 1;
45 return dev; 196 return 0;
46 }
47 read_unlock(&device_lock);
48 return NULL;
49} 197}
50 198
51int 199int
52get_mdevice_count(void) 200get_mdevice_count(void)
53{ 201{
54 struct mISDNdevice *dev; 202 int cnt = 0;
55 int cnt = 0;
56 203
57 read_lock(&device_lock); 204 class_for_each_device(&mISDN_class, NULL, &cnt, _get_mdevice_count);
58 list_for_each_entry(dev, &devices, D.list)
59 cnt++;
60 read_unlock(&device_lock);
61 return cnt; 205 return cnt;
62} 206}
63 207
@@ -68,48 +212,66 @@ get_free_devid(void)
68 212
69 for (i = 0; i <= MAX_DEVICE_ID; i++) 213 for (i = 0; i <= MAX_DEVICE_ID; i++)
70 if (!test_and_set_bit(i, (u_long *)&device_ids)) 214 if (!test_and_set_bit(i, (u_long *)&device_ids))
71 return i; 215 break;
72 return -1; 216 if (i > MAX_DEVICE_ID)
217 return -1;
218 return i;
73} 219}
74 220
75int 221int
76mISDN_register_device(struct mISDNdevice *dev, char *name) 222mISDN_register_device(struct mISDNdevice *dev,
223 struct device *parent, char *name)
77{ 224{
78 u_long flags;
79 int err; 225 int err;
80 226
81 dev->id = get_free_devid(); 227 dev->id = get_free_devid();
228 err = -EBUSY;
82 if (dev->id < 0) 229 if (dev->id < 0)
83 return -EBUSY; 230 goto error1;
231
232 device_initialize(&dev->dev);
84 if (name && name[0]) 233 if (name && name[0])
85 strcpy(dev->name, name); 234 dev_set_name(&dev->dev, "%s", name);
86 else 235 else
87 sprintf(dev->name, "mISDN%d", dev->id); 236 dev_set_name(&dev->dev, "mISDN%d", dev->id);
88 if (debug & DEBUG_CORE) 237 if (debug & DEBUG_CORE)
89 printk(KERN_DEBUG "mISDN_register %s %d\n", 238 printk(KERN_DEBUG "mISDN_register %s %d\n",
90 dev->name, dev->id); 239 dev_name(&dev->dev), dev->id);
91 err = create_stack(dev); 240 err = create_stack(dev);
92 if (err) 241 if (err)
93 return err; 242 goto error1;
94 write_lock_irqsave(&device_lock, flags); 243
95 list_add_tail(&dev->D.list, &devices); 244 dev->dev.class = &mISDN_class;
96 write_unlock_irqrestore(&device_lock, flags); 245 dev->dev.platform_data = dev;
246 dev->dev.parent = parent;
247 dev_set_drvdata(&dev->dev, dev);
248
249 err = device_add(&dev->dev);
250 if (err)
251 goto error3;
97 return 0; 252 return 0;
253
254error3:
255 delete_stack(dev);
256 return err;
257error1:
258 return err;
259
98} 260}
99EXPORT_SYMBOL(mISDN_register_device); 261EXPORT_SYMBOL(mISDN_register_device);
100 262
101void 263void
102mISDN_unregister_device(struct mISDNdevice *dev) { 264mISDN_unregister_device(struct mISDNdevice *dev) {
103 u_long flags;
104
105 if (debug & DEBUG_CORE) 265 if (debug & DEBUG_CORE)
106 printk(KERN_DEBUG "mISDN_unregister %s %d\n", 266 printk(KERN_DEBUG "mISDN_unregister %s %d\n",
107 dev->name, dev->id); 267 dev_name(&dev->dev), dev->id);
108 write_lock_irqsave(&device_lock, flags); 268 /* sysfs_remove_link(&dev->dev.kobj, "device"); */
109 list_del(&dev->D.list); 269 device_del(&dev->dev);
110 write_unlock_irqrestore(&device_lock, flags); 270 dev_set_drvdata(&dev->dev, NULL);
271
111 test_and_clear_bit(dev->id, (u_long *)&device_ids); 272 test_and_clear_bit(dev->id, (u_long *)&device_ids);
112 delete_stack(dev); 273 delete_stack(dev);
274 put_device(&dev->dev);
113} 275}
114EXPORT_SYMBOL(mISDN_unregister_device); 276EXPORT_SYMBOL(mISDN_unregister_device);
115 277
@@ -199,43 +361,45 @@ mISDNInit(void)
199 361
200 printk(KERN_INFO "Modular ISDN core version %d.%d.%d\n", 362 printk(KERN_INFO "Modular ISDN core version %d.%d.%d\n",
201 MISDN_MAJOR_VERSION, MISDN_MINOR_VERSION, MISDN_RELEASE); 363 MISDN_MAJOR_VERSION, MISDN_MINOR_VERSION, MISDN_RELEASE);
364 mISDN_init_clock(&debug);
202 mISDN_initstack(&debug); 365 mISDN_initstack(&debug);
366 err = class_register(&mISDN_class);
367 if (err)
368 goto error1;
203 err = mISDN_inittimer(&debug); 369 err = mISDN_inittimer(&debug);
204 if (err) 370 if (err)
205 goto error; 371 goto error2;
206 err = l1_init(&debug); 372 err = l1_init(&debug);
207 if (err) { 373 if (err)
208 mISDN_timer_cleanup(); 374 goto error3;
209 goto error;
210 }
211 err = Isdnl2_Init(&debug); 375 err = Isdnl2_Init(&debug);
212 if (err) { 376 if (err)
213 mISDN_timer_cleanup(); 377 goto error4;
214 l1_cleanup();
215 goto error;
216 }
217 err = misdn_sock_init(&debug); 378 err = misdn_sock_init(&debug);
218 if (err) { 379 if (err)
219 mISDN_timer_cleanup(); 380 goto error5;
220 l1_cleanup(); 381 return 0;
221 Isdnl2_cleanup(); 382
222 } 383error5:
223error: 384 Isdnl2_cleanup();
385error4:
386 l1_cleanup();
387error3:
388 mISDN_timer_cleanup();
389error2:
390 class_unregister(&mISDN_class);
391error1:
224 return err; 392 return err;
225} 393}
226 394
227static void mISDN_cleanup(void) 395static void mISDN_cleanup(void)
228{ 396{
229 misdn_sock_cleanup(); 397 misdn_sock_cleanup();
230 mISDN_timer_cleanup();
231 l1_cleanup();
232 Isdnl2_cleanup(); 398 Isdnl2_cleanup();
399 l1_cleanup();
400 mISDN_timer_cleanup();
401 class_unregister(&mISDN_class);
233 402
234 if (!list_empty(&devices))
235 printk(KERN_ERR "%s devices still registered\n", __func__);
236
237 if (!list_empty(&Bprotocols))
238 printk(KERN_ERR "%s Bprotocols still registered\n", __func__);
239 printk(KERN_DEBUG "mISDNcore unloaded\n"); 403 printk(KERN_DEBUG "mISDNcore unloaded\n");
240} 404}
241 405
diff --git a/drivers/isdn/mISDN/core.h b/drivers/isdn/mISDN/core.h
index 7da7233b4c1a..7ac2f81a812b 100644
--- a/drivers/isdn/mISDN/core.h
+++ b/drivers/isdn/mISDN/core.h
@@ -74,4 +74,6 @@ extern void l1_cleanup(void);
74extern int Isdnl2_Init(u_int *); 74extern int Isdnl2_Init(u_int *);
75extern void Isdnl2_cleanup(void); 75extern void Isdnl2_cleanup(void);
76 76
77extern void mISDN_init_clock(u_int *);
78
77#endif 79#endif
diff --git a/drivers/isdn/mISDN/dsp.h b/drivers/isdn/mISDN/dsp.h
index 6c3fed6b8d4f..98a33c58f091 100644
--- a/drivers/isdn/mISDN/dsp.h
+++ b/drivers/isdn/mISDN/dsp.h
@@ -15,6 +15,7 @@
15#define DEBUG_DSP_TONE 0x0020 15#define DEBUG_DSP_TONE 0x0020
16#define DEBUG_DSP_BLOWFISH 0x0040 16#define DEBUG_DSP_BLOWFISH 0x0040
17#define DEBUG_DSP_DELAY 0x0100 17#define DEBUG_DSP_DELAY 0x0100
18#define DEBUG_DSP_CLOCK 0x0200
18#define DEBUG_DSP_DTMFCOEFF 0x8000 /* heavy output */ 19#define DEBUG_DSP_DTMFCOEFF 0x8000 /* heavy output */
19 20
20/* options may be: 21/* options may be:
@@ -198,6 +199,7 @@ struct dsp {
198 /* hardware stuff */ 199 /* hardware stuff */
199 struct dsp_features features; 200 struct dsp_features features;
200 int features_rx_off; /* set if rx_off is featured */ 201 int features_rx_off; /* set if rx_off is featured */
202 int features_fill_empty; /* set if fill_empty is featured */
201 int pcm_slot_rx; /* current PCM slot (or -1) */ 203 int pcm_slot_rx; /* current PCM slot (or -1) */
202 int pcm_bank_rx; 204 int pcm_bank_rx;
203 int pcm_slot_tx; 205 int pcm_slot_tx;
diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c
index c884511e2d49..58c43e429f73 100644
--- a/drivers/isdn/mISDN/dsp_cmx.c
+++ b/drivers/isdn/mISDN/dsp_cmx.c
@@ -137,6 +137,7 @@
137/* #define CMX_CONF_DEBUG */ 137/* #define CMX_CONF_DEBUG */
138 138
139/*#define CMX_DEBUG * massive read/write pointer output */ 139/*#define CMX_DEBUG * massive read/write pointer output */
140/*#define CMX_DELAY_DEBUG * gives rx-buffer delay overview */
140/*#define CMX_TX_DEBUG * massive read/write on tx-buffer with content */ 141/*#define CMX_TX_DEBUG * massive read/write on tx-buffer with content */
141 142
142static inline int 143static inline int
@@ -744,11 +745,11 @@ conf_software:
744 if (dsp->pcm_slot_rx >= 0 && 745 if (dsp->pcm_slot_rx >= 0 &&
745 dsp->pcm_slot_rx < 746 dsp->pcm_slot_rx <
746 sizeof(freeslots)) 747 sizeof(freeslots))
747 freeslots[dsp->pcm_slot_tx] = 0; 748 freeslots[dsp->pcm_slot_rx] = 0;
748 if (dsp->pcm_slot_tx >= 0 && 749 if (dsp->pcm_slot_tx >= 0 &&
749 dsp->pcm_slot_tx < 750 dsp->pcm_slot_tx <
750 sizeof(freeslots)) 751 sizeof(freeslots))
751 freeslots[dsp->pcm_slot_rx] = 0; 752 freeslots[dsp->pcm_slot_tx] = 0;
752 } 753 }
753 } 754 }
754 i = 0; 755 i = 0;
@@ -836,11 +837,11 @@ conf_software:
836 if (dsp->pcm_slot_rx >= 0 && 837 if (dsp->pcm_slot_rx >= 0 &&
837 dsp->pcm_slot_rx < 838 dsp->pcm_slot_rx <
838 sizeof(freeslots)) 839 sizeof(freeslots))
839 freeslots[dsp->pcm_slot_tx] = 0; 840 freeslots[dsp->pcm_slot_rx] = 0;
840 if (dsp->pcm_slot_tx >= 0 && 841 if (dsp->pcm_slot_tx >= 0 &&
841 dsp->pcm_slot_tx < 842 dsp->pcm_slot_tx <
842 sizeof(freeslots)) 843 sizeof(freeslots))
843 freeslots[dsp->pcm_slot_rx] = 0; 844 freeslots[dsp->pcm_slot_tx] = 0;
844 } 845 }
845 } 846 }
846 i1 = 0; 847 i1 = 0;
@@ -926,10 +927,6 @@ conf_software:
926 927
927 /* for more than two members.. */ 928 /* for more than two members.. */
928 929
929 /* in case of hdlc, we change to software */
930 if (dsp->hdlc)
931 goto conf_software;
932
933 /* if all members already have the same conference */ 930 /* if all members already have the same conference */
934 if (all_conf) 931 if (all_conf)
935 return; 932 return;
@@ -940,6 +937,9 @@ conf_software:
940 if (current_conf >= 0) { 937 if (current_conf >= 0) {
941join_members: 938join_members:
942 list_for_each_entry(member, &conf->mlist, list) { 939 list_for_each_entry(member, &conf->mlist, list) {
940 /* in case of hdlc, change to software */
941 if (member->dsp->hdlc)
942 goto conf_software;
943 /* join to current conference */ 943 /* join to current conference */
944 if (member->dsp->hfc_conf == current_conf) 944 if (member->dsp->hfc_conf == current_conf)
945 continue; 945 continue;
@@ -1135,6 +1135,25 @@ dsp_cmx_conf(struct dsp *dsp, u32 conf_id)
1135 return 0; 1135 return 0;
1136} 1136}
1137 1137
1138#ifdef CMX_DELAY_DEBUG
1139int delaycount;
1140static void
1141showdelay(struct dsp *dsp, int samples, int delay)
1142{
1143 char bar[] = "--------------------------------------------------|";
1144 int sdelay;
1145
1146 delaycount += samples;
1147 if (delaycount < 8000)
1148 return;
1149 delaycount = 0;
1150
1151 sdelay = delay * 50 / (dsp_poll << 2);
1152
1153 printk(KERN_DEBUG "DELAY (%s) %3d >%s\n", dsp->name, delay,
1154 sdelay > 50 ? "..." : bar + 50 - sdelay);
1155}
1156#endif
1138 1157
1139/* 1158/*
1140 * audio data is received from card 1159 * audio data is received from card
@@ -1168,11 +1187,18 @@ dsp_cmx_receive(struct dsp *dsp, struct sk_buff *skb)
1168 dsp->rx_init = 0; 1187 dsp->rx_init = 0;
1169 if (dsp->features.unordered) { 1188 if (dsp->features.unordered) {
1170 dsp->rx_R = (hh->id & CMX_BUFF_MASK); 1189 dsp->rx_R = (hh->id & CMX_BUFF_MASK);
1171 dsp->rx_W = (dsp->rx_R + dsp->cmx_delay) 1190 if (dsp->cmx_delay)
1172 & CMX_BUFF_MASK; 1191 dsp->rx_W = (dsp->rx_R + dsp->cmx_delay)
1192 & CMX_BUFF_MASK;
1193 else
1194 dsp->rx_W = (dsp->rx_R + (dsp_poll >> 1))
1195 & CMX_BUFF_MASK;
1173 } else { 1196 } else {
1174 dsp->rx_R = 0; 1197 dsp->rx_R = 0;
1175 dsp->rx_W = dsp->cmx_delay; 1198 if (dsp->cmx_delay)
1199 dsp->rx_W = dsp->cmx_delay;
1200 else
1201 dsp->rx_W = dsp_poll >> 1;
1176 } 1202 }
1177 } 1203 }
1178 /* if frame contains time code, write directly */ 1204 /* if frame contains time code, write directly */
@@ -1185,19 +1211,25 @@ dsp_cmx_receive(struct dsp *dsp, struct sk_buff *skb)
1185 * we set our new read pointer, and write silence to buffer 1211 * we set our new read pointer, and write silence to buffer
1186 */ 1212 */
1187 if (((dsp->rx_W-dsp->rx_R) & CMX_BUFF_MASK) >= CMX_BUFF_HALF) { 1213 if (((dsp->rx_W-dsp->rx_R) & CMX_BUFF_MASK) >= CMX_BUFF_HALF) {
1188 if (dsp_debug & DEBUG_DSP_CMX) 1214 if (dsp_debug & DEBUG_DSP_CLOCK)
1189 printk(KERN_DEBUG 1215 printk(KERN_DEBUG
1190 "cmx_receive(dsp=%lx): UNDERRUN (or overrun the " 1216 "cmx_receive(dsp=%lx): UNDERRUN (or overrun the "
1191 "maximum delay), adjusting read pointer! " 1217 "maximum delay), adjusting read pointer! "
1192 "(inst %s)\n", (u_long)dsp, dsp->name); 1218 "(inst %s)\n", (u_long)dsp, dsp->name);
1193 /* flush buffer */ 1219 /* flush rx buffer and set delay to dsp_poll / 2 */
1194 if (dsp->features.unordered) { 1220 if (dsp->features.unordered) {
1195 dsp->rx_R = (hh->id & CMX_BUFF_MASK); 1221 dsp->rx_R = (hh->id & CMX_BUFF_MASK);
1196 dsp->rx_W = (dsp->rx_R + dsp->cmx_delay) 1222 if (dsp->cmx_delay)
1197 & CMX_BUFF_MASK; 1223 dsp->rx_W = (dsp->rx_R + dsp->cmx_delay)
1224 & CMX_BUFF_MASK;
1225 dsp->rx_W = (dsp->rx_R + (dsp_poll >> 1))
1226 & CMX_BUFF_MASK;
1198 } else { 1227 } else {
1199 dsp->rx_R = 0; 1228 dsp->rx_R = 0;
1200 dsp->rx_W = dsp->cmx_delay; 1229 if (dsp->cmx_delay)
1230 dsp->rx_W = dsp->cmx_delay;
1231 else
1232 dsp->rx_W = dsp_poll >> 1;
1201 } 1233 }
1202 memset(dsp->rx_buff, dsp_silence, sizeof(dsp->rx_buff)); 1234 memset(dsp->rx_buff, dsp_silence, sizeof(dsp->rx_buff));
1203 } 1235 }
@@ -1205,7 +1237,7 @@ dsp_cmx_receive(struct dsp *dsp, struct sk_buff *skb)
1205 if (dsp->cmx_delay) 1237 if (dsp->cmx_delay)
1206 if (((dsp->rx_W - dsp->rx_R) & CMX_BUFF_MASK) >= 1238 if (((dsp->rx_W - dsp->rx_R) & CMX_BUFF_MASK) >=
1207 (dsp->cmx_delay << 1)) { 1239 (dsp->cmx_delay << 1)) {
1208 if (dsp_debug & DEBUG_DSP_CMX) 1240 if (dsp_debug & DEBUG_DSP_CLOCK)
1209 printk(KERN_DEBUG 1241 printk(KERN_DEBUG
1210 "cmx_receive(dsp=%lx): OVERRUN (because " 1242 "cmx_receive(dsp=%lx): OVERRUN (because "
1211 "twice the delay is reached), adjusting " 1243 "twice the delay is reached), adjusting "
@@ -1243,6 +1275,9 @@ dsp_cmx_receive(struct dsp *dsp, struct sk_buff *skb)
1243 1275
1244 /* increase write-pointer */ 1276 /* increase write-pointer */
1245 dsp->rx_W = ((dsp->rx_W+len) & CMX_BUFF_MASK); 1277 dsp->rx_W = ((dsp->rx_W+len) & CMX_BUFF_MASK);
1278#ifdef CMX_DELAY_DEBUG
1279 showdelay(dsp, len, (dsp->rx_W-dsp->rx_R) & CMX_BUFF_MASK);
1280#endif
1246} 1281}
1247 1282
1248 1283
@@ -1360,8 +1395,12 @@ dsp_cmx_send_member(struct dsp *dsp, int len, s32 *c, int members)
1360 t = (t+1) & CMX_BUFF_MASK; 1395 t = (t+1) & CMX_BUFF_MASK;
1361 r = (r+1) & CMX_BUFF_MASK; 1396 r = (r+1) & CMX_BUFF_MASK;
1362 } 1397 }
1363 if (r != rr) 1398 if (r != rr) {
1399 if (dsp_debug & DEBUG_DSP_CLOCK)
1400 printk(KERN_DEBUG "%s: RX empty\n",
1401 __func__);
1364 memset(d, dsp_silence, (rr-r)&CMX_BUFF_MASK); 1402 memset(d, dsp_silence, (rr-r)&CMX_BUFF_MASK);
1403 }
1365 /* -> if echo is enabled */ 1404 /* -> if echo is enabled */
1366 } else { 1405 } else {
1367 /* 1406 /*
@@ -1540,13 +1579,11 @@ send_packet:
1540 schedule_work(&dsp->workq); 1579 schedule_work(&dsp->workq);
1541} 1580}
1542 1581
1543static u32 samplecount; 1582static u32 jittercount; /* counter for jitter check */
1544struct timer_list dsp_spl_tl; 1583struct timer_list dsp_spl_tl;
1545u32 dsp_spl_jiffies; /* calculate the next time to fire */ 1584u32 dsp_spl_jiffies; /* calculate the next time to fire */
1546#ifdef UNUSED 1585static u16 dsp_count; /* last sample count */
1547static u32 dsp_start_jiffies; /* jiffies at the time, the calculation begins */ 1586static int dsp_count_valid ; /* if we have last sample count */
1548#endif /* UNUSED */
1549static struct timeval dsp_start_tv; /* time at start of calculation */
1550 1587
1551void 1588void
1552dsp_cmx_send(void *arg) 1589dsp_cmx_send(void *arg)
@@ -1560,38 +1597,32 @@ dsp_cmx_send(void *arg)
1560 int r, rr; 1597 int r, rr;
1561 int jittercheck = 0, delay, i; 1598 int jittercheck = 0, delay, i;
1562 u_long flags; 1599 u_long flags;
1563 struct timeval tv; 1600 u16 length, count;
1564 u32 elapsed;
1565 s16 length;
1566 1601
1567 /* lock */ 1602 /* lock */
1568 spin_lock_irqsave(&dsp_lock, flags); 1603 spin_lock_irqsave(&dsp_lock, flags);
1569 1604
1570 if (!dsp_start_tv.tv_sec) { 1605 if (!dsp_count_valid) {
1571 do_gettimeofday(&dsp_start_tv); 1606 dsp_count = mISDN_clock_get();
1572 length = dsp_poll; 1607 length = dsp_poll;
1608 dsp_count_valid = 1;
1573 } else { 1609 } else {
1574 do_gettimeofday(&tv); 1610 count = mISDN_clock_get();
1575 elapsed = ((tv.tv_sec - dsp_start_tv.tv_sec) * 8000) 1611 length = count - dsp_count;
1576 + ((s32)(tv.tv_usec / 125) - (dsp_start_tv.tv_usec / 125)); 1612 dsp_count = count;
1577 dsp_start_tv.tv_sec = tv.tv_sec;
1578 dsp_start_tv.tv_usec = tv.tv_usec;
1579 length = elapsed;
1580 } 1613 }
1581 if (length > MAX_POLL + 100) 1614 if (length > MAX_POLL + 100)
1582 length = MAX_POLL + 100; 1615 length = MAX_POLL + 100;
1583/* printk(KERN_DEBUG "len=%d dsp_count=0x%x.%04x dsp_poll_diff=0x%x.%04x\n", 1616 /* printk(KERN_DEBUG "len=%d dsp_count=0x%x\n", length, dsp_count); */
1584 length, dsp_count >> 16, dsp_count & 0xffff, dsp_poll_diff >> 16,
1585 dsp_poll_diff & 0xffff);
1586 */
1587 1617
1588 /* 1618 /*
1589 * check if jitter needs to be checked 1619 * check if jitter needs to be checked (this is every second)
1590 * (this is about every second = 8192 samples)
1591 */ 1620 */
1592 samplecount += length; 1621 jittercount += length;
1593 if ((samplecount & 8191) < length) 1622 if (jittercount >= 8000) {
1623 jittercount -= 8000;
1594 jittercheck = 1; 1624 jittercheck = 1;
1625 }
1595 1626
1596 /* loop all members that do not require conference mixing */ 1627 /* loop all members that do not require conference mixing */
1597 list_for_each_entry(dsp, &dsp_ilist, list) { 1628 list_for_each_entry(dsp, &dsp_ilist, list) {
@@ -1704,17 +1735,19 @@ dsp_cmx_send(void *arg)
1704 } 1735 }
1705 /* 1736 /*
1706 * remove rx_delay only if we have delay AND we 1737 * remove rx_delay only if we have delay AND we
1707 * have not preset cmx_delay 1738 * have not preset cmx_delay AND
1739 * the delay is greater dsp_poll
1708 */ 1740 */
1709 if (delay && !dsp->cmx_delay) { 1741 if (delay > dsp_poll && !dsp->cmx_delay) {
1710 if (dsp_debug & DEBUG_DSP_CMX) 1742 if (dsp_debug & DEBUG_DSP_CLOCK)
1711 printk(KERN_DEBUG 1743 printk(KERN_DEBUG
1712 "%s lowest rx_delay of %d bytes for" 1744 "%s lowest rx_delay of %d bytes for"
1713 " dsp %s are now removed.\n", 1745 " dsp %s are now removed.\n",
1714 __func__, delay, 1746 __func__, delay,
1715 dsp->name); 1747 dsp->name);
1716 r = dsp->rx_R; 1748 r = dsp->rx_R;
1717 rr = (r + delay) & CMX_BUFF_MASK; 1749 rr = (r + delay - (dsp_poll >> 1))
1750 & CMX_BUFF_MASK;
1718 /* delete rx-data */ 1751 /* delete rx-data */
1719 while (r != rr) { 1752 while (r != rr) {
1720 p[r] = dsp_silence; 1753 p[r] = dsp_silence;
@@ -1736,15 +1769,16 @@ dsp_cmx_send(void *arg)
1736 * remove delay only if we have delay AND we 1769 * remove delay only if we have delay AND we
1737 * have enabled tx_dejitter 1770 * have enabled tx_dejitter
1738 */ 1771 */
1739 if (delay && dsp->tx_dejitter) { 1772 if (delay > dsp_poll && dsp->tx_dejitter) {
1740 if (dsp_debug & DEBUG_DSP_CMX) 1773 if (dsp_debug & DEBUG_DSP_CLOCK)
1741 printk(KERN_DEBUG 1774 printk(KERN_DEBUG
1742 "%s lowest tx_delay of %d bytes for" 1775 "%s lowest tx_delay of %d bytes for"
1743 " dsp %s are now removed.\n", 1776 " dsp %s are now removed.\n",
1744 __func__, delay, 1777 __func__, delay,
1745 dsp->name); 1778 dsp->name);
1746 r = dsp->tx_R; 1779 r = dsp->tx_R;
1747 rr = (r + delay) & CMX_BUFF_MASK; 1780 rr = (r + delay - (dsp_poll >> 1))
1781 & CMX_BUFF_MASK;
1748 /* delete tx-data */ 1782 /* delete tx-data */
1749 while (r != rr) { 1783 while (r != rr) {
1750 q[r] = dsp_silence; 1784 q[r] = dsp_silence;
@@ -1797,14 +1831,16 @@ dsp_cmx_transmit(struct dsp *dsp, struct sk_buff *skb)
1797 ww = dsp->tx_R; 1831 ww = dsp->tx_R;
1798 p = dsp->tx_buff; 1832 p = dsp->tx_buff;
1799 d = skb->data; 1833 d = skb->data;
1800 space = ww-w; 1834 space = (ww - w - 1) & CMX_BUFF_MASK;
1801 if (space <= 0)
1802 space += CMX_BUFF_SIZE;
1803 /* write-pointer should not overrun nor reach read pointer */ 1835 /* write-pointer should not overrun nor reach read pointer */
1804 if (space-1 < skb->len) 1836 if (space < skb->len) {
1805 /* write to the space we have left */ 1837 /* write to the space we have left */
1806 ww = (ww - 1) & CMX_BUFF_MASK; 1838 ww = (ww - 1) & CMX_BUFF_MASK; /* end one byte prior tx_R */
1807 else 1839 if (dsp_debug & DEBUG_DSP_CLOCK)
1840 printk(KERN_DEBUG "%s: TX overflow space=%d skb->len="
1841 "%d, w=0x%04x, ww=0x%04x\n", __func__, space,
1842 skb->len, w, ww);
1843 } else
1808 /* write until all byte are copied */ 1844 /* write until all byte are copied */
1809 ww = (w + skb->len) & CMX_BUFF_MASK; 1845 ww = (w + skb->len) & CMX_BUFF_MASK;
1810 dsp->tx_W = ww; 1846 dsp->tx_W = ww;
@@ -1857,7 +1893,7 @@ dsp_cmx_hdlc(struct dsp *dsp, struct sk_buff *skb)
1857 /* in case of hardware (echo) */ 1893 /* in case of hardware (echo) */
1858 if (dsp->pcm_slot_tx >= 0) 1894 if (dsp->pcm_slot_tx >= 0)
1859 return; 1895 return;
1860 if (dsp->echo) 1896 if (dsp->echo) {
1861 nskb = skb_clone(skb, GFP_ATOMIC); 1897 nskb = skb_clone(skb, GFP_ATOMIC);
1862 if (nskb) { 1898 if (nskb) {
1863 hh = mISDN_HEAD_P(nskb); 1899 hh = mISDN_HEAD_P(nskb);
@@ -1866,6 +1902,7 @@ dsp_cmx_hdlc(struct dsp *dsp, struct sk_buff *skb)
1866 skb_queue_tail(&dsp->sendq, nskb); 1902 skb_queue_tail(&dsp->sendq, nskb);
1867 schedule_work(&dsp->workq); 1903 schedule_work(&dsp->workq);
1868 } 1904 }
1905 }
1869 return; 1906 return;
1870 } 1907 }
1871 /* in case of hardware conference */ 1908 /* in case of hardware conference */
diff --git a/drivers/isdn/mISDN/dsp_core.c b/drivers/isdn/mISDN/dsp_core.c
index 1dc21d803410..3083338716b2 100644
--- a/drivers/isdn/mISDN/dsp_core.c
+++ b/drivers/isdn/mISDN/dsp_core.c
@@ -191,6 +191,8 @@ dsp_rx_off_member(struct dsp *dsp)
191 struct mISDN_ctrl_req cq; 191 struct mISDN_ctrl_req cq;
192 int rx_off = 1; 192 int rx_off = 1;
193 193
194 memset(&cq, 0, sizeof(cq));
195
194 if (!dsp->features_rx_off) 196 if (!dsp->features_rx_off)
195 return; 197 return;
196 198
@@ -249,6 +251,32 @@ dsp_rx_off(struct dsp *dsp)
249 } 251 }
250} 252}
251 253
254/* enable "fill empty" feature */
255static void
256dsp_fill_empty(struct dsp *dsp)
257{
258 struct mISDN_ctrl_req cq;
259
260 memset(&cq, 0, sizeof(cq));
261
262 if (!dsp->ch.peer) {
263 if (dsp_debug & DEBUG_DSP_CORE)
264 printk(KERN_DEBUG "%s: no peer, no fill_empty\n",
265 __func__);
266 return;
267 }
268 cq.op = MISDN_CTRL_FILL_EMPTY;
269 cq.p1 = 1;
270 if (dsp->ch.peer->ctrl(dsp->ch.peer, CONTROL_CHANNEL, &cq)) {
271 printk(KERN_DEBUG "%s: CONTROL_CHANNEL failed\n",
272 __func__);
273 return;
274 }
275 if (dsp_debug & DEBUG_DSP_CORE)
276 printk(KERN_DEBUG "%s: %s set fill_empty = 1\n",
277 __func__, dsp->name);
278}
279
252static int 280static int
253dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb) 281dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb)
254{ 282{
@@ -273,8 +301,9 @@ dsp_control_req(struct dsp *dsp, struct mISDNhead *hh, struct sk_buff *skb)
273 if (dsp_debug & DEBUG_DSP_CORE) 301 if (dsp_debug & DEBUG_DSP_CORE)
274 printk(KERN_DEBUG "%s: start dtmf\n", __func__); 302 printk(KERN_DEBUG "%s: start dtmf\n", __func__);
275 if (len == sizeof(int)) { 303 if (len == sizeof(int)) {
276 printk(KERN_NOTICE "changing DTMF Threshold " 304 if (dsp_debug & DEBUG_DSP_CORE)
277 "to %d\n", *((int *)data)); 305 printk(KERN_NOTICE "changing DTMF Threshold "
306 "to %d\n", *((int *)data));
278 dsp->dtmf.treshold = (*(int *)data) * 10000; 307 dsp->dtmf.treshold = (*(int *)data) * 10000;
279 } 308 }
280 /* init goertzel */ 309 /* init goertzel */
@@ -593,8 +622,6 @@ get_features(struct mISDNchannel *ch)
593 struct dsp *dsp = container_of(ch, struct dsp, ch); 622 struct dsp *dsp = container_of(ch, struct dsp, ch);
594 struct mISDN_ctrl_req cq; 623 struct mISDN_ctrl_req cq;
595 624
596 if (dsp_options & DSP_OPT_NOHARDWARE)
597 return;
598 if (!ch->peer) { 625 if (!ch->peer) {
599 if (dsp_debug & DEBUG_DSP_CORE) 626 if (dsp_debug & DEBUG_DSP_CORE)
600 printk(KERN_DEBUG "%s: no peer, no features\n", 627 printk(KERN_DEBUG "%s: no peer, no features\n",
@@ -610,6 +637,10 @@ get_features(struct mISDNchannel *ch)
610 } 637 }
611 if (cq.op & MISDN_CTRL_RX_OFF) 638 if (cq.op & MISDN_CTRL_RX_OFF)
612 dsp->features_rx_off = 1; 639 dsp->features_rx_off = 1;
640 if (cq.op & MISDN_CTRL_FILL_EMPTY)
641 dsp->features_fill_empty = 1;
642 if (dsp_options & DSP_OPT_NOHARDWARE)
643 return;
613 if ((cq.op & MISDN_CTRL_HW_FEATURES_OP)) { 644 if ((cq.op & MISDN_CTRL_HW_FEATURES_OP)) {
614 cq.op = MISDN_CTRL_HW_FEATURES; 645 cq.op = MISDN_CTRL_HW_FEATURES;
615 *((u_long *)&cq.p1) = (u_long)&dsp->features; 646 *((u_long *)&cq.p1) = (u_long)&dsp->features;
@@ -837,11 +868,14 @@ dsp_function(struct mISDNchannel *ch, struct sk_buff *skb)
837 } 868 }
838 if (dsp->hdlc) { 869 if (dsp->hdlc) {
839 /* hdlc */ 870 /* hdlc */
840 spin_lock_irqsave(&dsp_lock, flags); 871 if (!dsp->b_active) {
841 if (dsp->b_active) { 872 ret = -EIO;
842 skb_queue_tail(&dsp->sendq, skb); 873 break;
843 schedule_work(&dsp->workq);
844 } 874 }
875 hh->prim = PH_DATA_REQ;
876 spin_lock_irqsave(&dsp_lock, flags);
877 skb_queue_tail(&dsp->sendq, skb);
878 schedule_work(&dsp->workq);
845 spin_unlock_irqrestore(&dsp_lock, flags); 879 spin_unlock_irqrestore(&dsp_lock, flags);
846 return 0; 880 return 0;
847 } 881 }
@@ -865,6 +899,9 @@ dsp_function(struct mISDNchannel *ch, struct sk_buff *skb)
865 if (dsp->dtmf.hardware || dsp->dtmf.software) 899 if (dsp->dtmf.hardware || dsp->dtmf.software)
866 dsp_dtmf_goertzel_init(dsp); 900 dsp_dtmf_goertzel_init(dsp);
867 get_features(ch); 901 get_features(ch);
902 /* enable fill_empty feature */
903 if (dsp->features_fill_empty)
904 dsp_fill_empty(dsp);
868 /* send ph_activate */ 905 /* send ph_activate */
869 hh->prim = PH_ACTIVATE_REQ; 906 hh->prim = PH_ACTIVATE_REQ;
870 if (ch->peer) 907 if (ch->peer)
@@ -1105,7 +1142,7 @@ static int dsp_init(void)
1105 } else { 1142 } else {
1106 poll = 8; 1143 poll = 8;
1107 while (poll <= MAX_POLL) { 1144 while (poll <= MAX_POLL) {
1108 tics = poll * HZ / 8000; 1145 tics = (poll * HZ) / 8000;
1109 if (tics * 8000 == poll * HZ) { 1146 if (tics * 8000 == poll * HZ) {
1110 dsp_tics = tics; 1147 dsp_tics = tics;
1111 dsp_poll = poll; 1148 dsp_poll = poll;
diff --git a/drivers/isdn/mISDN/dsp_pipeline.c b/drivers/isdn/mISDN/dsp_pipeline.c
index 83639be7f7ad..18cf87c113e7 100644
--- a/drivers/isdn/mISDN/dsp_pipeline.c
+++ b/drivers/isdn/mISDN/dsp_pipeline.c
@@ -75,6 +75,15 @@ static struct device_attribute element_attributes[] = {
75 __ATTR(args, 0444, attr_show_args, NULL), 75 __ATTR(args, 0444, attr_show_args, NULL),
76}; 76};
77 77
78static void
79mISDN_dsp_dev_release(struct device *dev)
80{
81 struct dsp_element_entry *entry =
82 container_of(dev, struct dsp_element_entry, dev);
83 list_del(&entry->list);
84 kfree(entry);
85}
86
78int mISDN_dsp_element_register(struct mISDN_dsp_element *elem) 87int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
79{ 88{
80 struct dsp_element_entry *entry; 89 struct dsp_element_entry *entry;
@@ -83,13 +92,14 @@ int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
83 if (!elem) 92 if (!elem)
84 return -EINVAL; 93 return -EINVAL;
85 94
86 entry = kzalloc(sizeof(struct dsp_element_entry), GFP_KERNEL); 95 entry = kzalloc(sizeof(struct dsp_element_entry), GFP_ATOMIC);
87 if (!entry) 96 if (!entry)
88 return -ENOMEM; 97 return -ENOMEM;
89 98
90 entry->elem = elem; 99 entry->elem = elem;
91 100
92 entry->dev.class = elements_class; 101 entry->dev.class = elements_class;
102 entry->dev.release = mISDN_dsp_dev_release;
93 dev_set_drvdata(&entry->dev, elem); 103 dev_set_drvdata(&entry->dev, elem);
94 dev_set_name(&entry->dev, elem->name); 104 dev_set_name(&entry->dev, elem->name);
95 ret = device_register(&entry->dev); 105 ret = device_register(&entry->dev);
@@ -98,9 +108,9 @@ int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
98 __func__, elem->name); 108 __func__, elem->name);
99 goto err1; 109 goto err1;
100 } 110 }
111 list_add_tail(&entry->list, &dsp_elements);
101 112
102 for (i = 0; i < (sizeof(element_attributes) 113 for (i = 0; i < ARRAY_SIZE(element_attributes); ++i) {
103 / sizeof(struct device_attribute)); ++i)
104 ret = device_create_file(&entry->dev, 114 ret = device_create_file(&entry->dev,
105 &element_attributes[i]); 115 &element_attributes[i]);
106 if (ret) { 116 if (ret) {
@@ -108,15 +118,17 @@ int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
108 __func__); 118 __func__);
109 goto err2; 119 goto err2;
110 } 120 }
121 }
111 122
112 list_add_tail(&entry->list, &dsp_elements); 123#ifdef PIPELINE_DEBUG
113
114 printk(KERN_DEBUG "%s: %s registered\n", __func__, elem->name); 124 printk(KERN_DEBUG "%s: %s registered\n", __func__, elem->name);
125#endif
115 126
116 return 0; 127 return 0;
117 128
118err2: 129err2:
119 device_unregister(&entry->dev); 130 device_unregister(&entry->dev);
131 return ret;
120err1: 132err1:
121 kfree(entry); 133 kfree(entry);
122 return ret; 134 return ret;
@@ -132,11 +144,11 @@ void mISDN_dsp_element_unregister(struct mISDN_dsp_element *elem)
132 144
133 list_for_each_entry_safe(entry, n, &dsp_elements, list) 145 list_for_each_entry_safe(entry, n, &dsp_elements, list)
134 if (entry->elem == elem) { 146 if (entry->elem == elem) {
135 list_del(&entry->list);
136 device_unregister(&entry->dev); 147 device_unregister(&entry->dev);
137 kfree(entry); 148#ifdef PIPELINE_DEBUG
138 printk(KERN_DEBUG "%s: %s unregistered\n", 149 printk(KERN_DEBUG "%s: %s unregistered\n",
139 __func__, elem->name); 150 __func__, elem->name);
151#endif
140 return; 152 return;
141 } 153 }
142 printk(KERN_ERR "%s: element %s not in list.\n", __func__, elem->name); 154 printk(KERN_ERR "%s: element %s not in list.\n", __func__, elem->name);
@@ -173,7 +185,9 @@ void dsp_pipeline_module_exit(void)
173 kfree(entry); 185 kfree(entry);
174 } 186 }
175 187
188#ifdef PIPELINE_DEBUG
176 printk(KERN_DEBUG "%s: dsp pipeline module exited\n", __func__); 189 printk(KERN_DEBUG "%s: dsp pipeline module exited\n", __func__);
190#endif
177} 191}
178 192
179int dsp_pipeline_init(struct dsp_pipeline *pipeline) 193int dsp_pipeline_init(struct dsp_pipeline *pipeline)
@@ -239,7 +253,7 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
239 if (!len) 253 if (!len)
240 return 0; 254 return 0;
241 255
242 dup = kmalloc(len + 1, GFP_KERNEL); 256 dup = kmalloc(len + 1, GFP_ATOMIC);
243 if (!dup) 257 if (!dup)
244 return 0; 258 return 0;
245 strcpy(dup, cfg); 259 strcpy(dup, cfg);
@@ -256,9 +270,9 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
256 elem = entry->elem; 270 elem = entry->elem;
257 271
258 pipeline_entry = kmalloc(sizeof(struct 272 pipeline_entry = kmalloc(sizeof(struct
259 dsp_pipeline_entry), GFP_KERNEL); 273 dsp_pipeline_entry), GFP_ATOMIC);
260 if (!pipeline_entry) { 274 if (!pipeline_entry) {
261 printk(KERN_DEBUG "%s: failed to add " 275 printk(KERN_ERR "%s: failed to add "
262 "entry to pipeline: %s (out of " 276 "entry to pipeline: %s (out of "
263 "memory)\n", __func__, elem->name); 277 "memory)\n", __func__, elem->name);
264 incomplete = 1; 278 incomplete = 1;
@@ -286,7 +300,7 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
286 args : ""); 300 args : "");
287#endif 301#endif
288 } else { 302 } else {
289 printk(KERN_DEBUG "%s: failed " 303 printk(KERN_ERR "%s: failed "
290 "to add entry to pipeline: " 304 "to add entry to pipeline: "
291 "%s (new() returned NULL)\n", 305 "%s (new() returned NULL)\n",
292 __func__, elem->name); 306 __func__, elem->name);
@@ -301,7 +315,7 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
301 if (found) 315 if (found)
302 found = 0; 316 found = 0;
303 else { 317 else {
304 printk(KERN_DEBUG "%s: element not found, skipping: " 318 printk(KERN_ERR "%s: element not found, skipping: "
305 "%s\n", __func__, name); 319 "%s\n", __func__, name);
306 incomplete = 1; 320 incomplete = 1;
307 } 321 }
diff --git a/drivers/isdn/mISDN/hwchannel.c b/drivers/isdn/mISDN/hwchannel.c
index 2596fba4e614..ab1168a110ae 100644
--- a/drivers/isdn/mISDN/hwchannel.c
+++ b/drivers/isdn/mISDN/hwchannel.c
@@ -50,9 +50,6 @@ bchannel_bh(struct work_struct *ws)
50 50
51 if (test_and_clear_bit(FLG_RECVQUEUE, &bch->Flags)) { 51 if (test_and_clear_bit(FLG_RECVQUEUE, &bch->Flags)) {
52 while ((skb = skb_dequeue(&bch->rqueue))) { 52 while ((skb = skb_dequeue(&bch->rqueue))) {
53 if (bch->rcount >= 64)
54 printk(KERN_WARNING "B-channel %p receive "
55 "queue if full, but empties...\n", bch);
56 bch->rcount--; 53 bch->rcount--;
57 if (likely(bch->ch.peer)) { 54 if (likely(bch->ch.peer)) {
58 err = bch->ch.recv(bch->ch.peer, skb); 55 err = bch->ch.recv(bch->ch.peer, skb);
@@ -169,6 +166,25 @@ recv_Dchannel(struct dchannel *dch)
169EXPORT_SYMBOL(recv_Dchannel); 166EXPORT_SYMBOL(recv_Dchannel);
170 167
171void 168void
169recv_Echannel(struct dchannel *ech, struct dchannel *dch)
170{
171 struct mISDNhead *hh;
172
173 if (ech->rx_skb->len < 2) { /* at least 2 for sapi / tei */
174 dev_kfree_skb(ech->rx_skb);
175 ech->rx_skb = NULL;
176 return;
177 }
178 hh = mISDN_HEAD_P(ech->rx_skb);
179 hh->prim = PH_DATA_E_IND;
180 hh->id = get_sapi_tei(ech->rx_skb->data);
181 skb_queue_tail(&dch->rqueue, ech->rx_skb);
182 ech->rx_skb = NULL;
183 schedule_event(dch, FLG_RECVQUEUE);
184}
185EXPORT_SYMBOL(recv_Echannel);
186
187void
172recv_Bchannel(struct bchannel *bch) 188recv_Bchannel(struct bchannel *bch)
173{ 189{
174 struct mISDNhead *hh; 190 struct mISDNhead *hh;
@@ -177,8 +193,10 @@ recv_Bchannel(struct bchannel *bch)
177 hh->prim = PH_DATA_IND; 193 hh->prim = PH_DATA_IND;
178 hh->id = MISDN_ID_ANY; 194 hh->id = MISDN_ID_ANY;
179 if (bch->rcount >= 64) { 195 if (bch->rcount >= 64) {
180 dev_kfree_skb(bch->rx_skb); 196 printk(KERN_WARNING "B-channel %p receive queue overflow, "
181 bch->rx_skb = NULL; 197 "fushing!\n", bch);
198 skb_queue_purge(&bch->rqueue);
199 bch->rcount = 0;
182 return; 200 return;
183 } 201 }
184 bch->rcount++; 202 bch->rcount++;
@@ -200,8 +218,10 @@ void
200recv_Bchannel_skb(struct bchannel *bch, struct sk_buff *skb) 218recv_Bchannel_skb(struct bchannel *bch, struct sk_buff *skb)
201{ 219{
202 if (bch->rcount >= 64) { 220 if (bch->rcount >= 64) {
203 dev_kfree_skb(skb); 221 printk(KERN_WARNING "B-channel %p receive queue overflow, "
204 return; 222 "fushing!\n", bch);
223 skb_queue_purge(&bch->rqueue);
224 bch->rcount = 0;
205 } 225 }
206 bch->rcount++; 226 bch->rcount++;
207 skb_queue_tail(&bch->rqueue, skb); 227 skb_queue_tail(&bch->rqueue, skb);
@@ -245,8 +265,12 @@ confirm_Bsend(struct bchannel *bch)
245{ 265{
246 struct sk_buff *skb; 266 struct sk_buff *skb;
247 267
248 if (bch->rcount >= 64) 268 if (bch->rcount >= 64) {
249 return; 269 printk(KERN_WARNING "B-channel %p receive queue overflow, "
270 "fushing!\n", bch);
271 skb_queue_purge(&bch->rqueue);
272 bch->rcount = 0;
273 }
250 skb = _alloc_mISDN_skb(PH_DATA_CNF, mISDN_HEAD_ID(bch->tx_skb), 274 skb = _alloc_mISDN_skb(PH_DATA_CNF, mISDN_HEAD_ID(bch->tx_skb),
251 0, NULL, GFP_ATOMIC); 275 0, NULL, GFP_ATOMIC);
252 if (!skb) { 276 if (!skb) {
diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c
index 0884dd6892f8..abe574989572 100644
--- a/drivers/isdn/mISDN/l1oip_core.c
+++ b/drivers/isdn/mISDN/l1oip_core.c
@@ -777,6 +777,8 @@ fail:
777static void 777static void
778l1oip_socket_close(struct l1oip *hc) 778l1oip_socket_close(struct l1oip *hc)
779{ 779{
780 struct dchannel *dch = hc->chan[hc->d_idx].dch;
781
780 /* kill thread */ 782 /* kill thread */
781 if (hc->socket_thread) { 783 if (hc->socket_thread) {
782 if (debug & DEBUG_L1OIP_SOCKET) 784 if (debug & DEBUG_L1OIP_SOCKET)
@@ -785,6 +787,16 @@ l1oip_socket_close(struct l1oip *hc)
785 send_sig(SIGTERM, hc->socket_thread, 0); 787 send_sig(SIGTERM, hc->socket_thread, 0);
786 wait_for_completion(&hc->socket_complete); 788 wait_for_completion(&hc->socket_complete);
787 } 789 }
790
791 /* if active, we send up a PH_DEACTIVATE and deactivate */
792 if (test_bit(FLG_ACTIVE, &dch->Flags)) {
793 if (debug & (DEBUG_L1OIP_MSG|DEBUG_L1OIP_SOCKET))
794 printk(KERN_DEBUG "%s: interface become deactivated "
795 "due to timeout\n", __func__);
796 test_and_clear_bit(FLG_ACTIVE, &dch->Flags);
797 _queue_data(&dch->dev.D, PH_DEACTIVATE_IND, MISDN_ID_ANY, 0,
798 NULL, GFP_ATOMIC);
799 }
788} 800}
789 801
790static int 802static int
@@ -944,7 +956,8 @@ channel_dctrl(struct dchannel *dch, struct mISDN_ctrl_req *cq)
944 956
945 switch (cq->op) { 957 switch (cq->op) {
946 case MISDN_CTRL_GETOP: 958 case MISDN_CTRL_GETOP:
947 cq->op = MISDN_CTRL_SETPEER | MISDN_CTRL_UNSETPEER; 959 cq->op = MISDN_CTRL_SETPEER | MISDN_CTRL_UNSETPEER
960 | MISDN_CTRL_GETPEER;
948 break; 961 break;
949 case MISDN_CTRL_SETPEER: 962 case MISDN_CTRL_SETPEER:
950 hc->remoteip = (u32)cq->p1; 963 hc->remoteip = (u32)cq->p1;
@@ -964,6 +977,13 @@ channel_dctrl(struct dchannel *dch, struct mISDN_ctrl_req *cq)
964 hc->remoteip = 0; 977 hc->remoteip = 0;
965 l1oip_socket_open(hc); 978 l1oip_socket_open(hc);
966 break; 979 break;
980 case MISDN_CTRL_GETPEER:
981 if (debug & DEBUG_L1OIP_SOCKET)
982 printk(KERN_DEBUG "%s: getting ip address.\n",
983 __func__);
984 cq->p1 = hc->remoteip;
985 cq->p2 = hc->remoteport | (hc->localport << 16);
986 break;
967 default: 987 default:
968 printk(KERN_WARNING "%s: unknown Op %x\n", 988 printk(KERN_WARNING "%s: unknown Op %x\n",
969 __func__, cq->op); 989 __func__, cq->op);
@@ -1413,7 +1433,8 @@ init_card(struct l1oip *hc, int pri, int bundle)
1413 hc->chan[i + ch].bch = bch; 1433 hc->chan[i + ch].bch = bch;
1414 set_channelmap(bch->nr, dch->dev.channelmap); 1434 set_channelmap(bch->nr, dch->dev.channelmap);
1415 } 1435 }
1416 ret = mISDN_register_device(&dch->dev, hc->name); 1436 /* TODO: create a parent device for this driver */
1437 ret = mISDN_register_device(&dch->dev, NULL, hc->name);
1417 if (ret) 1438 if (ret)
1418 return ret; 1439 return ret;
1419 hc->registered = 1; 1440 hc->registered = 1;
diff --git a/drivers/isdn/mISDN/layer1.c b/drivers/isdn/mISDN/layer1.c
index b73e952d12cf..e826eeb1ecec 100644
--- a/drivers/isdn/mISDN/layer1.c
+++ b/drivers/isdn/mISDN/layer1.c
@@ -101,7 +101,7 @@ l1m_debug(struct FsmInst *fi, char *fmt, ...)
101 va_list va; 101 va_list va;
102 102
103 va_start(va, fmt); 103 va_start(va, fmt);
104 printk(KERN_DEBUG "%s: ", l1->dch->dev.name); 104 printk(KERN_DEBUG "%s: ", dev_name(&l1->dch->dev.dev));
105 vprintk(fmt, va); 105 vprintk(fmt, va);
106 printk("\n"); 106 printk("\n");
107 va_end(va); 107 va_end(va);
diff --git a/drivers/isdn/mISDN/socket.c b/drivers/isdn/mISDN/socket.c
index 37a2de18cfd0..508945d1b9c1 100644
--- a/drivers/isdn/mISDN/socket.c
+++ b/drivers/isdn/mISDN/socket.c
@@ -381,7 +381,7 @@ data_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
381 memcpy(di.channelmap, dev->channelmap, 381 memcpy(di.channelmap, dev->channelmap,
382 sizeof(di.channelmap)); 382 sizeof(di.channelmap));
383 di.nrbchan = dev->nrbchan; 383 di.nrbchan = dev->nrbchan;
384 strcpy(di.name, dev->name); 384 strcpy(di.name, dev_name(&dev->dev));
385 if (copy_to_user((void __user *)arg, &di, sizeof(di))) 385 if (copy_to_user((void __user *)arg, &di, sizeof(di)))
386 err = -EFAULT; 386 err = -EFAULT;
387 } else 387 } else
@@ -460,6 +460,8 @@ data_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
460{ 460{
461 struct sockaddr_mISDN *maddr = (struct sockaddr_mISDN *) addr; 461 struct sockaddr_mISDN *maddr = (struct sockaddr_mISDN *) addr;
462 struct sock *sk = sock->sk; 462 struct sock *sk = sock->sk;
463 struct hlist_node *node;
464 struct sock *csk;
463 int err = 0; 465 int err = 0;
464 466
465 if (*debug & DEBUG_SOCKET) 467 if (*debug & DEBUG_SOCKET)
@@ -480,6 +482,26 @@ data_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
480 err = -ENODEV; 482 err = -ENODEV;
481 goto done; 483 goto done;
482 } 484 }
485
486 if (sk->sk_protocol < ISDN_P_B_START) {
487 read_lock_bh(&data_sockets.lock);
488 sk_for_each(csk, node, &data_sockets.head) {
489 if (sk == csk)
490 continue;
491 if (_pms(csk)->dev != _pms(sk)->dev)
492 continue;
493 if (csk->sk_protocol >= ISDN_P_B_START)
494 continue;
495 if (IS_ISDN_P_TE(csk->sk_protocol)
496 == IS_ISDN_P_TE(sk->sk_protocol))
497 continue;
498 read_unlock_bh(&data_sockets.lock);
499 err = -EBUSY;
500 goto done;
501 }
502 read_unlock_bh(&data_sockets.lock);
503 }
504
483 _pms(sk)->ch.send = mISDN_send; 505 _pms(sk)->ch.send = mISDN_send;
484 _pms(sk)->ch.ctrl = mISDN_ctrl; 506 _pms(sk)->ch.ctrl = mISDN_ctrl;
485 507
@@ -639,12 +661,27 @@ base_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
639 memcpy(di.channelmap, dev->channelmap, 661 memcpy(di.channelmap, dev->channelmap,
640 sizeof(di.channelmap)); 662 sizeof(di.channelmap));
641 di.nrbchan = dev->nrbchan; 663 di.nrbchan = dev->nrbchan;
642 strcpy(di.name, dev->name); 664 strcpy(di.name, dev_name(&dev->dev));
643 if (copy_to_user((void __user *)arg, &di, sizeof(di))) 665 if (copy_to_user((void __user *)arg, &di, sizeof(di)))
644 err = -EFAULT; 666 err = -EFAULT;
645 } else 667 } else
646 err = -ENODEV; 668 err = -ENODEV;
647 break; 669 break;
670 case IMSETDEVNAME:
671 {
672 struct mISDN_devrename dn;
673 if (copy_from_user(&dn, (void __user *)arg,
674 sizeof(dn))) {
675 err = -EFAULT;
676 break;
677 }
678 dev = get_mdevice(dn.id);
679 if (dev)
680 err = device_rename(&dev->dev, dn.name);
681 else
682 err = -ENODEV;
683 }
684 break;
648 default: 685 default:
649 err = -EINVAL; 686 err = -EINVAL;
650 } 687 }
diff --git a/drivers/isdn/mISDN/stack.c b/drivers/isdn/mISDN/stack.c
index d55b14ae4e99..e2f45019ebf0 100644
--- a/drivers/isdn/mISDN/stack.c
+++ b/drivers/isdn/mISDN/stack.c
@@ -172,7 +172,8 @@ send_msg_to_layer(struct mISDNstack *st, struct sk_buff *skb)
172 else 172 else
173 printk(KERN_WARNING 173 printk(KERN_WARNING
174 "%s: dev(%s) prim(%x) id(%x) no channel\n", 174 "%s: dev(%s) prim(%x) id(%x) no channel\n",
175 __func__, st->dev->name, hh->prim, hh->id); 175 __func__, dev_name(&st->dev->dev), hh->prim,
176 hh->id);
176 } else if (lm == 0x8) { 177 } else if (lm == 0x8) {
177 WARN_ON(lm == 0x8); 178 WARN_ON(lm == 0x8);
178 ch = get_channel4id(st, hh->id); 179 ch = get_channel4id(st, hh->id);
@@ -181,11 +182,12 @@ send_msg_to_layer(struct mISDNstack *st, struct sk_buff *skb)
181 else 182 else
182 printk(KERN_WARNING 183 printk(KERN_WARNING
183 "%s: dev(%s) prim(%x) id(%x) no channel\n", 184 "%s: dev(%s) prim(%x) id(%x) no channel\n",
184 __func__, st->dev->name, hh->prim, hh->id); 185 __func__, dev_name(&st->dev->dev), hh->prim,
186 hh->id);
185 } else { 187 } else {
186 /* broadcast not handled yet */ 188 /* broadcast not handled yet */
187 printk(KERN_WARNING "%s: dev(%s) prim %x not delivered\n", 189 printk(KERN_WARNING "%s: dev(%s) prim %x not delivered\n",
188 __func__, st->dev->name, hh->prim); 190 __func__, dev_name(&st->dev->dev), hh->prim);
189 } 191 }
190 return -ESRCH; 192 return -ESRCH;
191} 193}
@@ -209,7 +211,8 @@ mISDNStackd(void *data)
209 unlock_kernel(); 211 unlock_kernel();
210#endif 212#endif
211 if (*debug & DEBUG_MSG_THREAD) 213 if (*debug & DEBUG_MSG_THREAD)
212 printk(KERN_DEBUG "mISDNStackd %s started\n", st->dev->name); 214 printk(KERN_DEBUG "mISDNStackd %s started\n",
215 dev_name(&st->dev->dev));
213 216
214 if (st->notify != NULL) { 217 if (st->notify != NULL) {
215 complete(st->notify); 218 complete(st->notify);
@@ -245,7 +248,7 @@ mISDNStackd(void *data)
245 printk(KERN_DEBUG 248 printk(KERN_DEBUG
246 "%s: %s prim(%x) id(%x) " 249 "%s: %s prim(%x) id(%x) "
247 "send call(%d)\n", 250 "send call(%d)\n",
248 __func__, st->dev->name, 251 __func__, dev_name(&st->dev->dev),
249 mISDN_HEAD_PRIM(skb), 252 mISDN_HEAD_PRIM(skb),
250 mISDN_HEAD_ID(skb), err); 253 mISDN_HEAD_ID(skb), err);
251 dev_kfree_skb(skb); 254 dev_kfree_skb(skb);
@@ -288,7 +291,7 @@ mISDNStackd(void *data)
288 mISDN_STACK_ACTION_MASK)); 291 mISDN_STACK_ACTION_MASK));
289 if (*debug & DEBUG_MSG_THREAD) 292 if (*debug & DEBUG_MSG_THREAD)
290 printk(KERN_DEBUG "%s: %s wake status %08lx\n", 293 printk(KERN_DEBUG "%s: %s wake status %08lx\n",
291 __func__, st->dev->name, st->status); 294 __func__, dev_name(&st->dev->dev), st->status);
292 test_and_set_bit(mISDN_STACK_ACTIVE, &st->status); 295 test_and_set_bit(mISDN_STACK_ACTIVE, &st->status);
293 296
294 test_and_clear_bit(mISDN_STACK_WAKEUP, &st->status); 297 test_and_clear_bit(mISDN_STACK_WAKEUP, &st->status);
@@ -303,15 +306,16 @@ mISDNStackd(void *data)
303#ifdef MISDN_MSG_STATS 306#ifdef MISDN_MSG_STATS
304 printk(KERN_DEBUG "mISDNStackd daemon for %s proceed %d " 307 printk(KERN_DEBUG "mISDNStackd daemon for %s proceed %d "
305 "msg %d sleep %d stopped\n", 308 "msg %d sleep %d stopped\n",
306 st->dev->name, st->msg_cnt, st->sleep_cnt, st->stopped_cnt); 309 dev_name(&st->dev->dev), st->msg_cnt, st->sleep_cnt,
310 st->stopped_cnt);
307 printk(KERN_DEBUG 311 printk(KERN_DEBUG
308 "mISDNStackd daemon for %s utime(%ld) stime(%ld)\n", 312 "mISDNStackd daemon for %s utime(%ld) stime(%ld)\n",
309 st->dev->name, st->thread->utime, st->thread->stime); 313 dev_name(&st->dev->dev), st->thread->utime, st->thread->stime);
310 printk(KERN_DEBUG 314 printk(KERN_DEBUG
311 "mISDNStackd daemon for %s nvcsw(%ld) nivcsw(%ld)\n", 315 "mISDNStackd daemon for %s nvcsw(%ld) nivcsw(%ld)\n",
312 st->dev->name, st->thread->nvcsw, st->thread->nivcsw); 316 dev_name(&st->dev->dev), st->thread->nvcsw, st->thread->nivcsw);
313 printk(KERN_DEBUG "mISDNStackd daemon for %s killed now\n", 317 printk(KERN_DEBUG "mISDNStackd daemon for %s killed now\n",
314 st->dev->name); 318 dev_name(&st->dev->dev));
315#endif 319#endif
316 test_and_set_bit(mISDN_STACK_KILLED, &st->status); 320 test_and_set_bit(mISDN_STACK_KILLED, &st->status);
317 test_and_clear_bit(mISDN_STACK_RUNNING, &st->status); 321 test_and_clear_bit(mISDN_STACK_RUNNING, &st->status);
@@ -401,15 +405,16 @@ create_stack(struct mISDNdevice *dev)
401 newst->own.send = mISDN_queue_message; 405 newst->own.send = mISDN_queue_message;
402 newst->own.recv = mISDN_queue_message; 406 newst->own.recv = mISDN_queue_message;
403 if (*debug & DEBUG_CORE_FUNC) 407 if (*debug & DEBUG_CORE_FUNC)
404 printk(KERN_DEBUG "%s: st(%s)\n", __func__, newst->dev->name); 408 printk(KERN_DEBUG "%s: st(%s)\n", __func__,
409 dev_name(&newst->dev->dev));
405 newst->notify = &done; 410 newst->notify = &done;
406 newst->thread = kthread_run(mISDNStackd, (void *)newst, "mISDN_%s", 411 newst->thread = kthread_run(mISDNStackd, (void *)newst, "mISDN_%s",
407 newst->dev->name); 412 dev_name(&newst->dev->dev));
408 if (IS_ERR(newst->thread)) { 413 if (IS_ERR(newst->thread)) {
409 err = PTR_ERR(newst->thread); 414 err = PTR_ERR(newst->thread);
410 printk(KERN_ERR 415 printk(KERN_ERR
411 "mISDN:cannot create kernel thread for %s (%d)\n", 416 "mISDN:cannot create kernel thread for %s (%d)\n",
412 newst->dev->name, err); 417 dev_name(&newst->dev->dev), err);
413 delete_teimanager(dev->teimgr); 418 delete_teimanager(dev->teimgr);
414 kfree(newst); 419 kfree(newst);
415 } else 420 } else
@@ -428,29 +433,21 @@ connect_layer1(struct mISDNdevice *dev, struct mISDNchannel *ch,
428 433
429 if (*debug & DEBUG_CORE_FUNC) 434 if (*debug & DEBUG_CORE_FUNC)
430 printk(KERN_DEBUG "%s: %s proto(%x) adr(%d %d %d %d)\n", 435 printk(KERN_DEBUG "%s: %s proto(%x) adr(%d %d %d %d)\n",
431 __func__, dev->name, protocol, adr->dev, adr->channel, 436 __func__, dev_name(&dev->dev), protocol, adr->dev,
432 adr->sapi, adr->tei); 437 adr->channel, adr->sapi, adr->tei);
433 switch (protocol) { 438 switch (protocol) {
434 case ISDN_P_NT_S0: 439 case ISDN_P_NT_S0:
435 case ISDN_P_NT_E1: 440 case ISDN_P_NT_E1:
436 case ISDN_P_TE_S0: 441 case ISDN_P_TE_S0:
437 case ISDN_P_TE_E1: 442 case ISDN_P_TE_E1:
438#ifdef PROTOCOL_CHECK
439 /* this should be enhanced */
440 if (!list_empty(&dev->D.st->layer2)
441 && dev->D.protocol != protocol)
442 return -EBUSY;
443 if (!hlist_empty(&dev->D.st->l1sock.head)
444 && dev->D.protocol != protocol)
445 return -EBUSY;
446#endif
447 ch->recv = mISDN_queue_message; 443 ch->recv = mISDN_queue_message;
448 ch->peer = &dev->D.st->own; 444 ch->peer = &dev->D.st->own;
449 ch->st = dev->D.st; 445 ch->st = dev->D.st;
450 rq.protocol = protocol; 446 rq.protocol = protocol;
451 rq.adr.channel = 0; 447 rq.adr.channel = adr->channel;
452 err = dev->D.ctrl(&dev->D, OPEN_CHANNEL, &rq); 448 err = dev->D.ctrl(&dev->D, OPEN_CHANNEL, &rq);
453 printk(KERN_DEBUG "%s: ret 1 %d\n", __func__, err); 449 printk(KERN_DEBUG "%s: ret %d (dev %d)\n", __func__, err,
450 dev->id);
454 if (err) 451 if (err)
455 return err; 452 return err;
456 write_lock_bh(&dev->D.st->l1sock.lock); 453 write_lock_bh(&dev->D.st->l1sock.lock);
@@ -473,7 +470,7 @@ connect_Bstack(struct mISDNdevice *dev, struct mISDNchannel *ch,
473 470
474 if (*debug & DEBUG_CORE_FUNC) 471 if (*debug & DEBUG_CORE_FUNC)
475 printk(KERN_DEBUG "%s: %s proto(%x) adr(%d %d %d %d)\n", 472 printk(KERN_DEBUG "%s: %s proto(%x) adr(%d %d %d %d)\n",
476 __func__, dev->name, protocol, 473 __func__, dev_name(&dev->dev), protocol,
477 adr->dev, adr->channel, adr->sapi, 474 adr->dev, adr->channel, adr->sapi,
478 adr->tei); 475 adr->tei);
479 ch->st = dev->D.st; 476 ch->st = dev->D.st;
@@ -529,7 +526,7 @@ create_l2entity(struct mISDNdevice *dev, struct mISDNchannel *ch,
529 526
530 if (*debug & DEBUG_CORE_FUNC) 527 if (*debug & DEBUG_CORE_FUNC)
531 printk(KERN_DEBUG "%s: %s proto(%x) adr(%d %d %d %d)\n", 528 printk(KERN_DEBUG "%s: %s proto(%x) adr(%d %d %d %d)\n",
532 __func__, dev->name, protocol, 529 __func__, dev_name(&dev->dev), protocol,
533 adr->dev, adr->channel, adr->sapi, 530 adr->dev, adr->channel, adr->sapi,
534 adr->tei); 531 adr->tei);
535 rq.protocol = ISDN_P_TE_S0; 532 rq.protocol = ISDN_P_TE_S0;
@@ -541,15 +538,6 @@ create_l2entity(struct mISDNdevice *dev, struct mISDNchannel *ch,
541 if (dev->Dprotocols & (1 << ISDN_P_NT_E1)) 538 if (dev->Dprotocols & (1 << ISDN_P_NT_E1))
542 rq.protocol = ISDN_P_NT_E1; 539 rq.protocol = ISDN_P_NT_E1;
543 case ISDN_P_LAPD_TE: 540 case ISDN_P_LAPD_TE:
544#ifdef PROTOCOL_CHECK
545 /* this should be enhanced */
546 if (!list_empty(&dev->D.st->layer2)
547 && dev->D.protocol != protocol)
548 return -EBUSY;
549 if (!hlist_empty(&dev->D.st->l1sock.head)
550 && dev->D.protocol != protocol)
551 return -EBUSY;
552#endif
553 ch->recv = mISDN_queue_message; 541 ch->recv = mISDN_queue_message;
554 ch->peer = &dev->D.st->own; 542 ch->peer = &dev->D.st->own;
555 ch->st = dev->D.st; 543 ch->st = dev->D.st;
@@ -590,7 +578,7 @@ delete_channel(struct mISDNchannel *ch)
590 } 578 }
591 if (*debug & DEBUG_CORE_FUNC) 579 if (*debug & DEBUG_CORE_FUNC)
592 printk(KERN_DEBUG "%s: st(%s) protocol(%x)\n", __func__, 580 printk(KERN_DEBUG "%s: st(%s) protocol(%x)\n", __func__,
593 ch->st->dev->name, ch->protocol); 581 dev_name(&ch->st->dev->dev), ch->protocol);
594 if (ch->protocol >= ISDN_P_B_START) { 582 if (ch->protocol >= ISDN_P_B_START) {
595 if (ch->peer) { 583 if (ch->peer) {
596 ch->peer->ctrl(ch->peer, CLOSE_CHANNEL, NULL); 584 ch->peer->ctrl(ch->peer, CLOSE_CHANNEL, NULL);
@@ -643,7 +631,7 @@ delete_stack(struct mISDNdevice *dev)
643 631
644 if (*debug & DEBUG_CORE_FUNC) 632 if (*debug & DEBUG_CORE_FUNC)
645 printk(KERN_DEBUG "%s: st(%s)\n", __func__, 633 printk(KERN_DEBUG "%s: st(%s)\n", __func__,
646 st->dev->name); 634 dev_name(&st->dev->dev));
647 if (dev->teimgr) 635 if (dev->teimgr)
648 delete_teimanager(dev->teimgr); 636 delete_teimanager(dev->teimgr);
649 if (st->thread) { 637 if (st->thread) {
diff --git a/drivers/isdn/mISDN/tei.c b/drivers/isdn/mISDN/tei.c
index 5c43d19e7c11..b452dead8fd0 100644
--- a/drivers/isdn/mISDN/tei.c
+++ b/drivers/isdn/mISDN/tei.c
@@ -968,9 +968,9 @@ create_teimgr(struct manager *mgr, struct channel_req *crq)
968 968
969 if (*debug & DEBUG_L2_TEI) 969 if (*debug & DEBUG_L2_TEI)
970 printk(KERN_DEBUG "%s: %s proto(%x) adr(%d %d %d %d)\n", 970 printk(KERN_DEBUG "%s: %s proto(%x) adr(%d %d %d %d)\n",
971 __func__, mgr->ch.st->dev->name, crq->protocol, 971 __func__, dev_name(&mgr->ch.st->dev->dev),
972 crq->adr.dev, crq->adr.channel, crq->adr.sapi, 972 crq->protocol, crq->adr.dev, crq->adr.channel,
973 crq->adr.tei); 973 crq->adr.sapi, crq->adr.tei);
974 if (crq->adr.sapi != 0) /* not supported yet */ 974 if (crq->adr.sapi != 0) /* not supported yet */
975 return -EINVAL; 975 return -EINVAL;
976 if (crq->adr.tei > GROUP_TEI) 976 if (crq->adr.tei > GROUP_TEI)
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index e7fb7d2fcbfc..742713611bc5 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -63,6 +63,12 @@ config LEDS_WRAP
63 help 63 help
64 This option enables support for the PCEngines WRAP programmable LEDs. 64 This option enables support for the PCEngines WRAP programmable LEDs.
65 65
66config LEDS_ALIX2
67 tristate "LED Support for ALIX.2 and ALIX.3 series"
68 depends on LEDS_CLASS && X86 && EXPERIMENTAL
69 help
70 This option enables support for the PCEngines ALIX.2 and ALIX.3 LEDs.
71
66config LEDS_H1940 72config LEDS_H1940
67 tristate "LED Support for iPAQ H1940 device" 73 tristate "LED Support for iPAQ H1940 device"
68 depends on LEDS_CLASS && ARCH_H1940 74 depends on LEDS_CLASS && ARCH_H1940
@@ -77,7 +83,7 @@ config LEDS_COBALT_QUBE
77 83
78config LEDS_COBALT_RAQ 84config LEDS_COBALT_RAQ
79 bool "LED Support for the Cobalt Raq series" 85 bool "LED Support for the Cobalt Raq series"
80 depends on LEDS_CLASS && MIPS_COBALT 86 depends on LEDS_CLASS=y && MIPS_COBALT
81 select LEDS_TRIGGERS 87 select LEDS_TRIGGERS
82 help 88 help
83 This option enables support for the Cobalt Raq series LEDs. 89 This option enables support for the Cobalt Raq series LEDs.
@@ -113,13 +119,6 @@ config LEDS_GPIO
113 outputs. To be useful the particular board must have LEDs 119 outputs. To be useful the particular board must have LEDs
114 and they must be connected to the GPIO lines. 120 and they must be connected to the GPIO lines.
115 121
116config LEDS_HP_DISK
117 tristate "LED Support for disk protection LED on HP notebooks"
118 depends on LEDS_CLASS && ACPI
119 help
120 This option enable support for disk protection LED, found on
121 newer HP notebooks.
122
123config LEDS_CLEVO_MAIL 122config LEDS_CLEVO_MAIL
124 tristate "Mail LED on Clevo notebook (EXPERIMENTAL)" 123 tristate "Mail LED on Clevo notebook (EXPERIMENTAL)"
125 depends on LEDS_CLASS && X86 && SERIO_I8042 && DMI && EXPERIMENTAL 124 depends on LEDS_CLASS && X86 && SERIO_I8042 && DMI && EXPERIMENTAL
@@ -158,6 +157,13 @@ config LEDS_PCA955X
158 LED driver chips accessed via the I2C bus. Supported 157 LED driver chips accessed via the I2C bus. Supported
159 devices include PCA9550, PCA9551, PCA9552, and PCA9553. 158 devices include PCA9550, PCA9551, PCA9552, and PCA9553.
160 159
160config LEDS_WM8350
161 tristate "LED Support for WM8350 AudioPlus PMIC"
162 depends on LEDS_CLASS && MFD_WM8350
163 help
164 This option enables support for LEDs driven by the Wolfson
165 Microelectronics WM8350 AudioPlus PMIC.
166
161config LEDS_DA903X 167config LEDS_DA903X
162 tristate "LED Support for DA9030/DA9034 PMIC" 168 tristate "LED Support for DA9030/DA9034 PMIC"
163 depends on LEDS_CLASS && PMIC_DA903X 169 depends on LEDS_CLASS && PMIC_DA903X
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index e1967a29850e..9d76f0f160a4 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o
11obj-$(CONFIG_LEDS_AMS_DELTA) += leds-ams-delta.o 11obj-$(CONFIG_LEDS_AMS_DELTA) += leds-ams-delta.o
12obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o 12obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o
13obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o 13obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o
14obj-$(CONFIG_LEDS_ALIX2) += leds-alix2.o
14obj-$(CONFIG_LEDS_H1940) += leds-h1940.o 15obj-$(CONFIG_LEDS_H1940) += leds-h1940.o
15obj-$(CONFIG_LEDS_COBALT_QUBE) += leds-cobalt-qube.o 16obj-$(CONFIG_LEDS_COBALT_QUBE) += leds-cobalt-qube.o
16obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o 17obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o
@@ -22,7 +23,7 @@ obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o
22obj-$(CONFIG_LEDS_FSG) += leds-fsg.o 23obj-$(CONFIG_LEDS_FSG) += leds-fsg.o
23obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o 24obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o
24obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o 25obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o
25obj-$(CONFIG_LEDS_HP_DISK) += leds-hp-disk.o 26obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o
26 27
27# LED Triggers 28# LED Triggers
28obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o 29obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 6c4a326176d7..52f82e3ea13a 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -91,9 +91,29 @@ void led_classdev_resume(struct led_classdev *led_cdev)
91} 91}
92EXPORT_SYMBOL_GPL(led_classdev_resume); 92EXPORT_SYMBOL_GPL(led_classdev_resume);
93 93
94static int led_suspend(struct device *dev, pm_message_t state)
95{
96 struct led_classdev *led_cdev = dev_get_drvdata(dev);
97
98 if (led_cdev->flags & LED_CORE_SUSPENDRESUME)
99 led_classdev_suspend(led_cdev);
100
101 return 0;
102}
103
104static int led_resume(struct device *dev)
105{
106 struct led_classdev *led_cdev = dev_get_drvdata(dev);
107
108 if (led_cdev->flags & LED_CORE_SUSPENDRESUME)
109 led_classdev_resume(led_cdev);
110
111 return 0;
112}
113
94/** 114/**
95 * led_classdev_register - register a new object of led_classdev class. 115 * led_classdev_register - register a new object of led_classdev class.
96 * @dev: The device to register. 116 * @parent: The device to register.
97 * @led_cdev: the led_classdev structure for this device. 117 * @led_cdev: the led_classdev structure for this device.
98 */ 118 */
99int led_classdev_register(struct device *parent, struct led_classdev *led_cdev) 119int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
@@ -174,6 +194,8 @@ static int __init leds_init(void)
174 leds_class = class_create(THIS_MODULE, "leds"); 194 leds_class = class_create(THIS_MODULE, "leds");
175 if (IS_ERR(leds_class)) 195 if (IS_ERR(leds_class))
176 return PTR_ERR(leds_class); 196 return PTR_ERR(leds_class);
197 leds_class->suspend = led_suspend;
198 leds_class->resume = led_resume;
177 return 0; 199 return 0;
178} 200}
179 201
diff --git a/drivers/leds/leds-alix2.c b/drivers/leds/leds-alix2.c
new file mode 100644
index 000000000000..ddbd7730dfc8
--- /dev/null
+++ b/drivers/leds/leds-alix2.c
@@ -0,0 +1,181 @@
1/*
2 * LEDs driver for PCEngines ALIX.2 and ALIX.3
3 *
4 * Copyright (C) 2008 Constantin Baranov <const@mimas.ru>
5 */
6
7#include <linux/err.h>
8#include <linux/io.h>
9#include <linux/kernel.h>
10#include <linux/leds.h>
11#include <linux/module.h>
12#include <linux/platform_device.h>
13#include <linux/string.h>
14
15static int force = 0;
16module_param(force, bool, 0444);
17MODULE_PARM_DESC(force, "Assume system has ALIX.2 style LEDs");
18
19struct alix_led {
20 struct led_classdev cdev;
21 unsigned short port;
22 unsigned int on_value;
23 unsigned int off_value;
24};
25
26static void alix_led_set(struct led_classdev *led_cdev,
27 enum led_brightness brightness)
28{
29 struct alix_led *led_dev =
30 container_of(led_cdev, struct alix_led, cdev);
31
32 if (brightness)
33 outl(led_dev->on_value, led_dev->port);
34 else
35 outl(led_dev->off_value, led_dev->port);
36}
37
38static struct alix_led alix_leds[] = {
39 {
40 .cdev = {
41 .name = "alix:1",
42 .brightness_set = alix_led_set,
43 },
44 .port = 0x6100,
45 .on_value = 1 << 22,
46 .off_value = 1 << 6,
47 },
48 {
49 .cdev = {
50 .name = "alix:2",
51 .brightness_set = alix_led_set,
52 },
53 .port = 0x6180,
54 .on_value = 1 << 25,
55 .off_value = 1 << 9,
56 },
57 {
58 .cdev = {
59 .name = "alix:3",
60 .brightness_set = alix_led_set,
61 },
62 .port = 0x6180,
63 .on_value = 1 << 27,
64 .off_value = 1 << 11,
65 },
66};
67
68static int __init alix_led_probe(struct platform_device *pdev)
69{
70 int i;
71 int ret;
72
73 for (i = 0; i < ARRAY_SIZE(alix_leds); i++) {
74 alix_leds[i].cdev.flags |= LED_CORE_SUSPENDRESUME;
75 ret = led_classdev_register(&pdev->dev, &alix_leds[i].cdev);
76 if (ret < 0)
77 goto fail;
78 }
79 return 0;
80
81fail:
82 while (--i >= 0)
83 led_classdev_unregister(&alix_leds[i].cdev);
84 return ret;
85}
86
87static int alix_led_remove(struct platform_device *pdev)
88{
89 int i;
90
91 for (i = 0; i < ARRAY_SIZE(alix_leds); i++)
92 led_classdev_unregister(&alix_leds[i].cdev);
93 return 0;
94}
95
96static struct platform_driver alix_led_driver = {
97 .remove = alix_led_remove,
98 .driver = {
99 .name = KBUILD_MODNAME,
100 .owner = THIS_MODULE,
101 },
102};
103
104static int __init alix_present(void)
105{
106 const unsigned long bios_phys = 0x000f0000;
107 const size_t bios_len = 0x00010000;
108 const char alix_sig[] = "PC Engines ALIX.";
109 const size_t alix_sig_len = sizeof(alix_sig) - 1;
110
111 const char *bios_virt;
112 const char *scan_end;
113 const char *p;
114 int ret = 0;
115
116 if (force) {
117 printk(KERN_NOTICE "%s: forced to skip BIOS test, "
118 "assume system has ALIX.2 style LEDs\n",
119 KBUILD_MODNAME);
120 ret = 1;
121 goto out;
122 }
123
124 bios_virt = phys_to_virt(bios_phys);
125 scan_end = bios_virt + bios_len - (alix_sig_len + 2);
126 for (p = bios_virt; p < scan_end; p++) {
127 const char *tail;
128
129 if (memcmp(p, alix_sig, alix_sig_len) != 0) {
130 continue;
131 }
132
133 tail = p + alix_sig_len;
134 if ((tail[0] == '2' || tail[0] == '3') && tail[1] == '\0') {
135 printk(KERN_INFO
136 "%s: system is recognized as \"%s\"\n",
137 KBUILD_MODNAME, p);
138 ret = 1;
139 break;
140 }
141 }
142
143out:
144 return ret;
145}
146
147static struct platform_device *pdev;
148
149static int __init alix_led_init(void)
150{
151 int ret;
152
153 if (!alix_present()) {
154 ret = -ENODEV;
155 goto out;
156 }
157
158 pdev = platform_device_register_simple(KBUILD_MODNAME, -1, NULL, 0);
159 if (!IS_ERR(pdev)) {
160 ret = platform_driver_probe(&alix_led_driver, alix_led_probe);
161 if (ret)
162 platform_device_unregister(pdev);
163 } else
164 ret = PTR_ERR(pdev);
165
166out:
167 return ret;
168}
169
170static void __exit alix_led_exit(void)
171{
172 platform_device_unregister(pdev);
173 platform_driver_unregister(&alix_led_driver);
174}
175
176module_init(alix_led_init);
177module_exit(alix_led_exit);
178
179MODULE_AUTHOR("Constantin Baranov <const@mimas.ru>");
180MODULE_DESCRIPTION("PCEngines ALIX.2 and ALIX.3 LED driver");
181MODULE_LICENSE("GPL");
diff --git a/drivers/leds/leds-ams-delta.c b/drivers/leds/leds-ams-delta.c
index 1bd590bb3a6e..446050759b4d 100644
--- a/drivers/leds/leds-ams-delta.c
+++ b/drivers/leds/leds-ams-delta.c
@@ -79,37 +79,12 @@ static struct ams_delta_led ams_delta_leds[] = {
79 }, 79 },
80}; 80};
81 81
82#ifdef CONFIG_PM
83static int ams_delta_led_suspend(struct platform_device *dev,
84 pm_message_t state)
85{
86 int i;
87
88 for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i++)
89 led_classdev_suspend(&ams_delta_leds[i].cdev);
90
91 return 0;
92}
93
94static int ams_delta_led_resume(struct platform_device *dev)
95{
96 int i;
97
98 for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i++)
99 led_classdev_resume(&ams_delta_leds[i].cdev);
100
101 return 0;
102}
103#else
104#define ams_delta_led_suspend NULL
105#define ams_delta_led_resume NULL
106#endif
107
108static int ams_delta_led_probe(struct platform_device *pdev) 82static int ams_delta_led_probe(struct platform_device *pdev)
109{ 83{
110 int i, ret; 84 int i, ret;
111 85
112 for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i++) { 86 for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i++) {
87 ams_delta_leds[i].cdev.flags |= LED_CORE_SUSPENDRESUME;
113 ret = led_classdev_register(&pdev->dev, 88 ret = led_classdev_register(&pdev->dev,
114 &ams_delta_leds[i].cdev); 89 &ams_delta_leds[i].cdev);
115 if (ret < 0) 90 if (ret < 0)
@@ -127,7 +102,7 @@ static int ams_delta_led_remove(struct platform_device *pdev)
127{ 102{
128 int i; 103 int i;
129 104
130 for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i--) 105 for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i++)
131 led_classdev_unregister(&ams_delta_leds[i].cdev); 106 led_classdev_unregister(&ams_delta_leds[i].cdev);
132 107
133 return 0; 108 return 0;
@@ -136,8 +111,6 @@ static int ams_delta_led_remove(struct platform_device *pdev)
136static struct platform_driver ams_delta_led_driver = { 111static struct platform_driver ams_delta_led_driver = {
137 .probe = ams_delta_led_probe, 112 .probe = ams_delta_led_probe,
138 .remove = ams_delta_led_remove, 113 .remove = ams_delta_led_remove,
139 .suspend = ams_delta_led_suspend,
140 .resume = ams_delta_led_resume,
141 .driver = { 114 .driver = {
142 .name = "ams-delta-led", 115 .name = "ams-delta-led",
143 .owner = THIS_MODULE, 116 .owner = THIS_MODULE,
@@ -151,7 +124,7 @@ static int __init ams_delta_led_init(void)
151 124
152static void __exit ams_delta_led_exit(void) 125static void __exit ams_delta_led_exit(void)
153{ 126{
154 return platform_driver_unregister(&ams_delta_led_driver); 127 platform_driver_unregister(&ams_delta_led_driver);
155} 128}
156 129
157module_init(ams_delta_led_init); 130module_init(ams_delta_led_init);
diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
index eb3415e88f43..1813c84ea5fc 100644
--- a/drivers/leds/leds-clevo-mail.c
+++ b/drivers/leds/leds-clevo-mail.c
@@ -142,6 +142,7 @@ static struct led_classdev clevo_mail_led = {
142 .name = "clevo::mail", 142 .name = "clevo::mail",
143 .brightness_set = clevo_mail_led_set, 143 .brightness_set = clevo_mail_led_set,
144 .blink_set = clevo_mail_led_blink, 144 .blink_set = clevo_mail_led_blink,
145 .flags = LED_CORE_SUSPENDRESUME,
145}; 146};
146 147
147static int __init clevo_mail_led_probe(struct platform_device *pdev) 148static int __init clevo_mail_led_probe(struct platform_device *pdev)
@@ -155,29 +156,9 @@ static int clevo_mail_led_remove(struct platform_device *pdev)
155 return 0; 156 return 0;
156} 157}
157 158
158#ifdef CONFIG_PM
159static int clevo_mail_led_suspend(struct platform_device *dev,
160 pm_message_t state)
161{
162 led_classdev_suspend(&clevo_mail_led);
163 return 0;
164}
165
166static int clevo_mail_led_resume(struct platform_device *dev)
167{
168 led_classdev_resume(&clevo_mail_led);
169 return 0;
170}
171#else
172#define clevo_mail_led_suspend NULL
173#define clevo_mail_led_resume NULL
174#endif
175
176static struct platform_driver clevo_mail_led_driver = { 159static struct platform_driver clevo_mail_led_driver = {
177 .probe = clevo_mail_led_probe, 160 .probe = clevo_mail_led_probe,
178 .remove = clevo_mail_led_remove, 161 .remove = clevo_mail_led_remove,
179 .suspend = clevo_mail_led_suspend,
180 .resume = clevo_mail_led_resume,
181 .driver = { 162 .driver = {
182 .name = KBUILD_MODNAME, 163 .name = KBUILD_MODNAME,
183 .owner = THIS_MODULE, 164 .owner = THIS_MODULE,
diff --git a/drivers/leds/leds-fsg.c b/drivers/leds/leds-fsg.c
index 34935155c1c0..5f7c9c5c09b1 100644
--- a/drivers/leds/leds-fsg.c
+++ b/drivers/leds/leds-fsg.c
@@ -99,64 +99,43 @@ static void fsg_led_ring_set(struct led_classdev *led_cdev,
99} 99}
100 100
101 101
102
103static struct led_classdev fsg_wlan_led = { 102static struct led_classdev fsg_wlan_led = {
104 .name = "fsg:blue:wlan", 103 .name = "fsg:blue:wlan",
105 .brightness_set = fsg_led_wlan_set, 104 .brightness_set = fsg_led_wlan_set,
105 .flags = LED_CORE_SUSPENDRESUME,
106}; 106};
107 107
108static struct led_classdev fsg_wan_led = { 108static struct led_classdev fsg_wan_led = {
109 .name = "fsg:blue:wan", 109 .name = "fsg:blue:wan",
110 .brightness_set = fsg_led_wan_set, 110 .brightness_set = fsg_led_wan_set,
111 .flags = LED_CORE_SUSPENDRESUME,
111}; 112};
112 113
113static struct led_classdev fsg_sata_led = { 114static struct led_classdev fsg_sata_led = {
114 .name = "fsg:blue:sata", 115 .name = "fsg:blue:sata",
115 .brightness_set = fsg_led_sata_set, 116 .brightness_set = fsg_led_sata_set,
117 .flags = LED_CORE_SUSPENDRESUME,
116}; 118};
117 119
118static struct led_classdev fsg_usb_led = { 120static struct led_classdev fsg_usb_led = {
119 .name = "fsg:blue:usb", 121 .name = "fsg:blue:usb",
120 .brightness_set = fsg_led_usb_set, 122 .brightness_set = fsg_led_usb_set,
123 .flags = LED_CORE_SUSPENDRESUME,
121}; 124};
122 125
123static struct led_classdev fsg_sync_led = { 126static struct led_classdev fsg_sync_led = {
124 .name = "fsg:blue:sync", 127 .name = "fsg:blue:sync",
125 .brightness_set = fsg_led_sync_set, 128 .brightness_set = fsg_led_sync_set,
129 .flags = LED_CORE_SUSPENDRESUME,
126}; 130};
127 131
128static struct led_classdev fsg_ring_led = { 132static struct led_classdev fsg_ring_led = {
129 .name = "fsg:blue:ring", 133 .name = "fsg:blue:ring",
130 .brightness_set = fsg_led_ring_set, 134 .brightness_set = fsg_led_ring_set,
135 .flags = LED_CORE_SUSPENDRESUME,
131}; 136};
132 137
133 138
134
135#ifdef CONFIG_PM
136static int fsg_led_suspend(struct platform_device *dev, pm_message_t state)
137{
138 led_classdev_suspend(&fsg_wlan_led);
139 led_classdev_suspend(&fsg_wan_led);
140 led_classdev_suspend(&fsg_sata_led);
141 led_classdev_suspend(&fsg_usb_led);
142 led_classdev_suspend(&fsg_sync_led);
143 led_classdev_suspend(&fsg_ring_led);
144 return 0;
145}
146
147static int fsg_led_resume(struct platform_device *dev)
148{
149 led_classdev_resume(&fsg_wlan_led);
150 led_classdev_resume(&fsg_wan_led);
151 led_classdev_resume(&fsg_sata_led);
152 led_classdev_resume(&fsg_usb_led);
153 led_classdev_resume(&fsg_sync_led);
154 led_classdev_resume(&fsg_ring_led);
155 return 0;
156}
157#endif
158
159
160static int fsg_led_probe(struct platform_device *pdev) 139static int fsg_led_probe(struct platform_device *pdev)
161{ 140{
162 int ret; 141 int ret;
@@ -232,10 +211,6 @@ static int fsg_led_remove(struct platform_device *pdev)
232static struct platform_driver fsg_led_driver = { 211static struct platform_driver fsg_led_driver = {
233 .probe = fsg_led_probe, 212 .probe = fsg_led_probe,
234 .remove = fsg_led_remove, 213 .remove = fsg_led_remove,
235#ifdef CONFIG_PM
236 .suspend = fsg_led_suspend,
237 .resume = fsg_led_resume,
238#endif
239 .driver = { 214 .driver = {
240 .name = "fsg-led", 215 .name = "fsg-led",
241 }, 216 },
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index b13bd2950e95..2e3df08b649b 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -105,6 +105,7 @@ static int gpio_led_probe(struct platform_device *pdev)
105 } 105 }
106 led_dat->cdev.brightness_set = gpio_led_set; 106 led_dat->cdev.brightness_set = gpio_led_set;
107 led_dat->cdev.brightness = LED_OFF; 107 led_dat->cdev.brightness = LED_OFF;
108 led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
108 109
109 gpio_direction_output(led_dat->gpio, led_dat->active_low); 110 gpio_direction_output(led_dat->gpio, led_dat->active_low);
110 111
@@ -154,44 +155,9 @@ static int __devexit gpio_led_remove(struct platform_device *pdev)
154 return 0; 155 return 0;
155} 156}
156 157
157#ifdef CONFIG_PM
158static int gpio_led_suspend(struct platform_device *pdev, pm_message_t state)
159{
160 struct gpio_led_platform_data *pdata = pdev->dev.platform_data;
161 struct gpio_led_data *leds_data;
162 int i;
163
164 leds_data = platform_get_drvdata(pdev);
165
166 for (i = 0; i < pdata->num_leds; i++)
167 led_classdev_suspend(&leds_data[i].cdev);
168
169 return 0;
170}
171
172static int gpio_led_resume(struct platform_device *pdev)
173{
174 struct gpio_led_platform_data *pdata = pdev->dev.platform_data;
175 struct gpio_led_data *leds_data;
176 int i;
177
178 leds_data = platform_get_drvdata(pdev);
179
180 for (i = 0; i < pdata->num_leds; i++)
181 led_classdev_resume(&leds_data[i].cdev);
182
183 return 0;
184}
185#else
186#define gpio_led_suspend NULL
187#define gpio_led_resume NULL
188#endif
189
190static struct platform_driver gpio_led_driver = { 158static struct platform_driver gpio_led_driver = {
191 .probe = gpio_led_probe, 159 .probe = gpio_led_probe,
192 .remove = __devexit_p(gpio_led_remove), 160 .remove = __devexit_p(gpio_led_remove),
193 .suspend = gpio_led_suspend,
194 .resume = gpio_led_resume,
195 .driver = { 161 .driver = {
196 .name = "leds-gpio", 162 .name = "leds-gpio",
197 .owner = THIS_MODULE, 163 .owner = THIS_MODULE,
diff --git a/drivers/leds/leds-hp-disk.c b/drivers/leds/leds-hp-disk.c
deleted file mode 100644
index 44fa757d8254..000000000000
--- a/drivers/leds/leds-hp-disk.c
+++ /dev/null
@@ -1,155 +0,0 @@
1/*
2 * leds-hp-disk.c - driver for HP "hard disk protection" LED
3 *
4 * Copyright (C) 2008 Pavel Machek
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/kernel.h>
22#include <linux/init.h>
23#include <linux/dmi.h>
24#include <linux/module.h>
25#include <linux/types.h>
26#include <linux/platform_device.h>
27#include <linux/interrupt.h>
28#include <linux/input.h>
29#include <linux/kthread.h>
30#include <linux/leds.h>
31#include <acpi/acpi_drivers.h>
32
33#define DRIVER_NAME "leds-hp-disk"
34#define ACPI_MDPS_CLASS "led"
35
36/* For automatic insertion of the module */
37static struct acpi_device_id hpled_device_ids[] = {
38 {"HPQ0004", 0}, /* HP Mobile Data Protection System PNP */
39 {"", 0},
40};
41MODULE_DEVICE_TABLE(acpi, hpled_device_ids);
42
43struct acpi_hpled {
44 struct acpi_device *device; /* The ACPI device */
45};
46
47static struct acpi_hpled adev;
48
49static acpi_status hpled_acpi_write(acpi_handle handle, int reg)
50{
51 unsigned long long ret; /* Not used when writing */
52 union acpi_object in_obj[1];
53 struct acpi_object_list args = { 1, in_obj };
54
55 in_obj[0].type = ACPI_TYPE_INTEGER;
56 in_obj[0].integer.value = reg;
57
58 return acpi_evaluate_integer(handle, "ALED", &args, &ret);
59}
60
61static void hpled_set(struct led_classdev *led_cdev,
62 enum led_brightness value)
63{
64 hpled_acpi_write(adev.device->handle, !!value);
65}
66
67static struct led_classdev hpled_led = {
68 .name = "hp:red:hddprotection",
69 .default_trigger = "heartbeat",
70 .brightness_set = hpled_set,
71};
72
73#ifdef CONFIG_PM
74static int hpled_suspend(struct acpi_device *dev, pm_message_t state)
75{
76 led_classdev_suspend(&hpled_led);
77 return 0;
78}
79
80static int hpled_resume(struct acpi_device *dev)
81{
82 led_classdev_resume(&hpled_led);
83 return 0;
84}
85#else
86#define hpled_suspend NULL
87#define hpled_resume NULL
88#endif
89
90static int hpled_add(struct acpi_device *device)
91{
92 int ret;
93
94 if (!device)
95 return -EINVAL;
96
97 adev.device = device;
98 strcpy(acpi_device_name(device), DRIVER_NAME);
99 strcpy(acpi_device_class(device), ACPI_MDPS_CLASS);
100 device->driver_data = &adev;
101
102 ret = led_classdev_register(NULL, &hpled_led);
103 return ret;
104}
105
106static int hpled_remove(struct acpi_device *device, int type)
107{
108 if (!device)
109 return -EINVAL;
110
111 led_classdev_unregister(&hpled_led);
112 return 0;
113}
114
115
116
117static struct acpi_driver leds_hp_driver = {
118 .name = DRIVER_NAME,
119 .class = ACPI_MDPS_CLASS,
120 .ids = hpled_device_ids,
121 .ops = {
122 .add = hpled_add,
123 .remove = hpled_remove,
124 .suspend = hpled_suspend,
125 .resume = hpled_resume,
126 }
127};
128
129static int __init hpled_init_module(void)
130{
131 int ret;
132
133 if (acpi_disabled)
134 return -ENODEV;
135
136 ret = acpi_bus_register_driver(&leds_hp_driver);
137 if (ret < 0)
138 return ret;
139
140 printk(KERN_INFO DRIVER_NAME " driver loaded.\n");
141
142 return 0;
143}
144
145static void __exit hpled_exit_module(void)
146{
147 acpi_bus_unregister_driver(&leds_hp_driver);
148}
149
150MODULE_DESCRIPTION("Driver for HP disk protection LED");
151MODULE_AUTHOR("Pavel Machek <pavel@suse.cz>");
152MODULE_LICENSE("GPL");
153
154module_init(hpled_init_module);
155module_exit(hpled_exit_module);
diff --git a/drivers/leds/leds-hp6xx.c b/drivers/leds/leds-hp6xx.c
index e8fb1baf8a50..e4ce1fd46338 100644
--- a/drivers/leds/leds-hp6xx.c
+++ b/drivers/leds/leds-hp6xx.c
@@ -45,30 +45,16 @@ static struct led_classdev hp6xx_red_led = {
45 .name = "hp6xx:red", 45 .name = "hp6xx:red",
46 .default_trigger = "hp6xx-charge", 46 .default_trigger = "hp6xx-charge",
47 .brightness_set = hp6xxled_red_set, 47 .brightness_set = hp6xxled_red_set,
48 .flags = LED_CORE_SUSPENDRESUME,
48}; 49};
49 50
50static struct led_classdev hp6xx_green_led = { 51static struct led_classdev hp6xx_green_led = {
51 .name = "hp6xx:green", 52 .name = "hp6xx:green",
52 .default_trigger = "ide-disk", 53 .default_trigger = "ide-disk",
53 .brightness_set = hp6xxled_green_set, 54 .brightness_set = hp6xxled_green_set,
55 .flags = LED_CORE_SUSPENDRESUME,
54}; 56};
55 57
56#ifdef CONFIG_PM
57static int hp6xxled_suspend(struct platform_device *dev, pm_message_t state)
58{
59 led_classdev_suspend(&hp6xx_red_led);
60 led_classdev_suspend(&hp6xx_green_led);
61 return 0;
62}
63
64static int hp6xxled_resume(struct platform_device *dev)
65{
66 led_classdev_resume(&hp6xx_red_led);
67 led_classdev_resume(&hp6xx_green_led);
68 return 0;
69}
70#endif
71
72static int hp6xxled_probe(struct platform_device *pdev) 58static int hp6xxled_probe(struct platform_device *pdev)
73{ 59{
74 int ret; 60 int ret;
@@ -98,10 +84,6 @@ MODULE_ALIAS("platform:hp6xx-led");
98static struct platform_driver hp6xxled_driver = { 84static struct platform_driver hp6xxled_driver = {
99 .probe = hp6xxled_probe, 85 .probe = hp6xxled_probe,
100 .remove = hp6xxled_remove, 86 .remove = hp6xxled_remove,
101#ifdef CONFIG_PM
102 .suspend = hp6xxled_suspend,
103 .resume = hp6xxled_resume,
104#endif
105 .driver = { 87 .driver = {
106 .name = "hp6xx-led", 88 .name = "hp6xx-led",
107 .owner = THIS_MODULE, 89 .owner = THIS_MODULE,
diff --git a/drivers/leds/leds-net48xx.c b/drivers/leds/leds-net48xx.c
index 054360473c94..93987a12da49 100644
--- a/drivers/leds/leds-net48xx.c
+++ b/drivers/leds/leds-net48xx.c
@@ -33,26 +33,9 @@ static void net48xx_error_led_set(struct led_classdev *led_cdev,
33static struct led_classdev net48xx_error_led = { 33static struct led_classdev net48xx_error_led = {
34 .name = "net48xx::error", 34 .name = "net48xx::error",
35 .brightness_set = net48xx_error_led_set, 35 .brightness_set = net48xx_error_led_set,
36 .flags = LED_CORE_SUSPENDRESUME,
36}; 37};
37 38
38#ifdef CONFIG_PM
39static int net48xx_led_suspend(struct platform_device *dev,
40 pm_message_t state)
41{
42 led_classdev_suspend(&net48xx_error_led);
43 return 0;
44}
45
46static int net48xx_led_resume(struct platform_device *dev)
47{
48 led_classdev_resume(&net48xx_error_led);
49 return 0;
50}
51#else
52#define net48xx_led_suspend NULL
53#define net48xx_led_resume NULL
54#endif
55
56static int net48xx_led_probe(struct platform_device *pdev) 39static int net48xx_led_probe(struct platform_device *pdev)
57{ 40{
58 return led_classdev_register(&pdev->dev, &net48xx_error_led); 41 return led_classdev_register(&pdev->dev, &net48xx_error_led);
@@ -67,8 +50,6 @@ static int net48xx_led_remove(struct platform_device *pdev)
67static struct platform_driver net48xx_led_driver = { 50static struct platform_driver net48xx_led_driver = {
68 .probe = net48xx_led_probe, 51 .probe = net48xx_led_probe,
69 .remove = net48xx_led_remove, 52 .remove = net48xx_led_remove,
70 .suspend = net48xx_led_suspend,
71 .resume = net48xx_led_resume,
72 .driver = { 53 .driver = {
73 .name = DRVNAME, 54 .name = DRVNAME,
74 .owner = THIS_MODULE, 55 .owner = THIS_MODULE,
diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c
index 4064d4f6b33b..76ec7498e2d5 100644
--- a/drivers/leds/leds-pca9532.c
+++ b/drivers/leds/leds-pca9532.c
@@ -16,6 +16,7 @@
16#include <linux/leds.h> 16#include <linux/leds.h>
17#include <linux/input.h> 17#include <linux/input.h>
18#include <linux/mutex.h> 18#include <linux/mutex.h>
19#include <linux/workqueue.h>
19#include <linux/leds-pca9532.h> 20#include <linux/leds-pca9532.h>
20 21
21static const unsigned short normal_i2c[] = { /*0x60,*/ I2C_CLIENT_END}; 22static const unsigned short normal_i2c[] = { /*0x60,*/ I2C_CLIENT_END};
@@ -34,6 +35,7 @@ struct pca9532_data {
34 struct pca9532_led leds[16]; 35 struct pca9532_led leds[16];
35 struct mutex update_lock; 36 struct mutex update_lock;
36 struct input_dev *idev; 37 struct input_dev *idev;
38 struct work_struct work;
37 u8 pwm[2]; 39 u8 pwm[2];
38 u8 psc[2]; 40 u8 psc[2];
39}; 41};
@@ -63,7 +65,7 @@ static struct i2c_driver pca9532_driver = {
63 * as a compromise we average one pwm to the values requested by all 65 * as a compromise we average one pwm to the values requested by all
64 * leds that are not ON/OFF. 66 * leds that are not ON/OFF.
65 * */ 67 * */
66static int pca9532_setpwm(struct i2c_client *client, int pwm, int blink, 68static int pca9532_calcpwm(struct i2c_client *client, int pwm, int blink,
67 enum led_brightness value) 69 enum led_brightness value)
68{ 70{
69 int a = 0, b = 0, i = 0; 71 int a = 0, b = 0, i = 0;
@@ -84,11 +86,17 @@ static int pca9532_setpwm(struct i2c_client *client, int pwm, int blink,
84 b = b/a; 86 b = b/a;
85 if (b > 0xFF) 87 if (b > 0xFF)
86 return -EINVAL; 88 return -EINVAL;
87 mutex_lock(&data->update_lock);
88 data->pwm[pwm] = b; 89 data->pwm[pwm] = b;
90 data->psc[pwm] = blink;
91 return 0;
92}
93
94static int pca9532_setpwm(struct i2c_client *client, int pwm)
95{
96 struct pca9532_data *data = i2c_get_clientdata(client);
97 mutex_lock(&data->update_lock);
89 i2c_smbus_write_byte_data(client, PCA9532_REG_PWM(pwm), 98 i2c_smbus_write_byte_data(client, PCA9532_REG_PWM(pwm),
90 data->pwm[pwm]); 99 data->pwm[pwm]);
91 data->psc[pwm] = blink;
92 i2c_smbus_write_byte_data(client, PCA9532_REG_PSC(pwm), 100 i2c_smbus_write_byte_data(client, PCA9532_REG_PSC(pwm),
93 data->psc[pwm]); 101 data->psc[pwm]);
94 mutex_unlock(&data->update_lock); 102 mutex_unlock(&data->update_lock);
@@ -124,11 +132,11 @@ static void pca9532_set_brightness(struct led_classdev *led_cdev,
124 led->state = PCA9532_ON; 132 led->state = PCA9532_ON;
125 else { 133 else {
126 led->state = PCA9532_PWM0; /* Thecus: hardcode one pwm */ 134 led->state = PCA9532_PWM0; /* Thecus: hardcode one pwm */
127 err = pca9532_setpwm(led->client, 0, 0, value); 135 err = pca9532_calcpwm(led->client, 0, 0, value);
128 if (err) 136 if (err)
129 return; /* XXX: led api doesn't allow error code? */ 137 return; /* XXX: led api doesn't allow error code? */
130 } 138 }
131 pca9532_setled(led); 139 schedule_work(&led->work);
132} 140}
133 141
134static int pca9532_set_blink(struct led_classdev *led_cdev, 142static int pca9532_set_blink(struct led_classdev *led_cdev,
@@ -137,6 +145,7 @@ static int pca9532_set_blink(struct led_classdev *led_cdev,
137 struct pca9532_led *led = ldev_to_led(led_cdev); 145 struct pca9532_led *led = ldev_to_led(led_cdev);
138 struct i2c_client *client = led->client; 146 struct i2c_client *client = led->client;
139 int psc; 147 int psc;
148 int err = 0;
140 149
141 if (*delay_on == 0 && *delay_off == 0) { 150 if (*delay_on == 0 && *delay_off == 0) {
142 /* led subsystem ask us for a blink rate */ 151 /* led subsystem ask us for a blink rate */
@@ -148,11 +157,15 @@ static int pca9532_set_blink(struct led_classdev *led_cdev,
148 157
149 /* Thecus specific: only use PSC/PWM 0 */ 158 /* Thecus specific: only use PSC/PWM 0 */
150 psc = (*delay_on * 152-1)/1000; 159 psc = (*delay_on * 152-1)/1000;
151 return pca9532_setpwm(client, 0, psc, led_cdev->brightness); 160 err = pca9532_calcpwm(client, 0, psc, led_cdev->brightness);
161 if (err)
162 return err;
163 schedule_work(&led->work);
164 return 0;
152} 165}
153 166
154int pca9532_event(struct input_dev *dev, unsigned int type, unsigned int code, 167static int pca9532_event(struct input_dev *dev, unsigned int type,
155 int value) 168 unsigned int code, int value)
156{ 169{
157 struct pca9532_data *data = input_get_drvdata(dev); 170 struct pca9532_data *data = input_get_drvdata(dev);
158 171
@@ -165,13 +178,28 @@ int pca9532_event(struct input_dev *dev, unsigned int type, unsigned int code,
165 else 178 else
166 data->pwm[1] = 0; 179 data->pwm[1] = 0;
167 180
168 dev_info(&dev->dev, "setting beep to %d \n", data->pwm[1]); 181 schedule_work(&data->work);
182
183 return 0;
184}
185
186static void pca9532_input_work(struct work_struct *work)
187{
188 struct pca9532_data *data;
189 data = container_of(work, struct pca9532_data, work);
169 mutex_lock(&data->update_lock); 190 mutex_lock(&data->update_lock);
170 i2c_smbus_write_byte_data(data->client, PCA9532_REG_PWM(1), 191 i2c_smbus_write_byte_data(data->client, PCA9532_REG_PWM(1),
171 data->pwm[1]); 192 data->pwm[1]);
172 mutex_unlock(&data->update_lock); 193 mutex_unlock(&data->update_lock);
194}
173 195
174 return 0; 196static void pca9532_led_work(struct work_struct *work)
197{
198 struct pca9532_led *led;
199 led = container_of(work, struct pca9532_led, work);
200 if (led->state == PCA9532_PWM0)
201 pca9532_setpwm(led->client, 0);
202 pca9532_setled(led);
175} 203}
176 204
177static int pca9532_configure(struct i2c_client *client, 205static int pca9532_configure(struct i2c_client *client,
@@ -204,8 +232,9 @@ static int pca9532_configure(struct i2c_client *client,
204 led->ldev.brightness = LED_OFF; 232 led->ldev.brightness = LED_OFF;
205 led->ldev.brightness_set = pca9532_set_brightness; 233 led->ldev.brightness_set = pca9532_set_brightness;
206 led->ldev.blink_set = pca9532_set_blink; 234 led->ldev.blink_set = pca9532_set_blink;
207 if (led_classdev_register(&client->dev, 235 INIT_WORK(&led->work, pca9532_led_work);
208 &led->ldev) < 0) { 236 err = led_classdev_register(&client->dev, &led->ldev);
237 if (err < 0) {
209 dev_err(&client->dev, 238 dev_err(&client->dev,
210 "couldn't register LED %s\n", 239 "couldn't register LED %s\n",
211 led->name); 240 led->name);
@@ -233,9 +262,11 @@ static int pca9532_configure(struct i2c_client *client,
233 BIT_MASK(SND_TONE); 262 BIT_MASK(SND_TONE);
234 data->idev->event = pca9532_event; 263 data->idev->event = pca9532_event;
235 input_set_drvdata(data->idev, data); 264 input_set_drvdata(data->idev, data);
265 INIT_WORK(&data->work, pca9532_input_work);
236 err = input_register_device(data->idev); 266 err = input_register_device(data->idev);
237 if (err) { 267 if (err) {
238 input_free_device(data->idev); 268 input_free_device(data->idev);
269 cancel_work_sync(&data->work);
239 data->idev = NULL; 270 data->idev = NULL;
240 goto exit; 271 goto exit;
241 } 272 }
@@ -252,18 +283,19 @@ exit:
252 break; 283 break;
253 case PCA9532_TYPE_LED: 284 case PCA9532_TYPE_LED:
254 led_classdev_unregister(&data->leds[i].ldev); 285 led_classdev_unregister(&data->leds[i].ldev);
286 cancel_work_sync(&data->leds[i].work);
255 break; 287 break;
256 case PCA9532_TYPE_N2100_BEEP: 288 case PCA9532_TYPE_N2100_BEEP:
257 if (data->idev != NULL) { 289 if (data->idev != NULL) {
258 input_unregister_device(data->idev); 290 input_unregister_device(data->idev);
259 input_free_device(data->idev); 291 input_free_device(data->idev);
292 cancel_work_sync(&data->work);
260 data->idev = NULL; 293 data->idev = NULL;
261 } 294 }
262 break; 295 break;
263 } 296 }
264 297
265 return err; 298 return err;
266
267} 299}
268 300
269static int pca9532_probe(struct i2c_client *client, 301static int pca9532_probe(struct i2c_client *client,
@@ -271,12 +303,16 @@ static int pca9532_probe(struct i2c_client *client,
271{ 303{
272 struct pca9532_data *data = i2c_get_clientdata(client); 304 struct pca9532_data *data = i2c_get_clientdata(client);
273 struct pca9532_platform_data *pca9532_pdata = client->dev.platform_data; 305 struct pca9532_platform_data *pca9532_pdata = client->dev.platform_data;
306 int err;
307
308 if (!pca9532_pdata)
309 return -EIO;
274 310
275 if (!i2c_check_functionality(client->adapter, 311 if (!i2c_check_functionality(client->adapter,
276 I2C_FUNC_SMBUS_BYTE_DATA)) 312 I2C_FUNC_SMBUS_BYTE_DATA))
277 return -EIO; 313 return -EIO;
278 314
279 data = kzalloc(sizeof(struct pca9532_data), GFP_KERNEL); 315 data = kzalloc(sizeof(*data), GFP_KERNEL);
280 if (!data) 316 if (!data)
281 return -ENOMEM; 317 return -ENOMEM;
282 318
@@ -285,12 +321,13 @@ static int pca9532_probe(struct i2c_client *client,
285 data->client = client; 321 data->client = client;
286 mutex_init(&data->update_lock); 322 mutex_init(&data->update_lock);
287 323
288 if (pca9532_pdata == NULL) 324 err = pca9532_configure(client, data, pca9532_pdata);
289 return -EIO; 325 if (err) {
290 326 kfree(data);
291 pca9532_configure(client, data, pca9532_pdata); 327 i2c_set_clientdata(client, NULL);
292 return 0; 328 }
293 329
330 return err;
294} 331}
295 332
296static int pca9532_remove(struct i2c_client *client) 333static int pca9532_remove(struct i2c_client *client)
@@ -303,11 +340,13 @@ static int pca9532_remove(struct i2c_client *client)
303 break; 340 break;
304 case PCA9532_TYPE_LED: 341 case PCA9532_TYPE_LED:
305 led_classdev_unregister(&data->leds[i].ldev); 342 led_classdev_unregister(&data->leds[i].ldev);
343 cancel_work_sync(&data->leds[i].work);
306 break; 344 break;
307 case PCA9532_TYPE_N2100_BEEP: 345 case PCA9532_TYPE_N2100_BEEP:
308 if (data->idev != NULL) { 346 if (data->idev != NULL) {
309 input_unregister_device(data->idev); 347 input_unregister_device(data->idev);
310 input_free_device(data->idev); 348 input_free_device(data->idev);
349 cancel_work_sync(&data->work);
311 data->idev = NULL; 350 data->idev = NULL;
312 } 351 }
313 break; 352 break;
diff --git a/drivers/leds/leds-s3c24xx.c b/drivers/leds/leds-s3c24xx.c
index 25a07f2643ad..4d81131542ae 100644
--- a/drivers/leds/leds-s3c24xx.c
+++ b/drivers/leds/leds-s3c24xx.c
@@ -82,6 +82,7 @@ static int s3c24xx_led_probe(struct platform_device *dev)
82 led->cdev.brightness_set = s3c24xx_led_set; 82 led->cdev.brightness_set = s3c24xx_led_set;
83 led->cdev.default_trigger = pdata->def_trigger; 83 led->cdev.default_trigger = pdata->def_trigger;
84 led->cdev.name = pdata->name; 84 led->cdev.name = pdata->name;
85 led->cdev.flags |= LED_CORE_SUSPENDRESUME;
85 86
86 led->pdata = pdata; 87 led->pdata = pdata;
87 88
@@ -111,33 +112,9 @@ static int s3c24xx_led_probe(struct platform_device *dev)
111 return ret; 112 return ret;
112} 113}
113 114
114
115#ifdef CONFIG_PM
116static int s3c24xx_led_suspend(struct platform_device *dev, pm_message_t state)
117{
118 struct s3c24xx_gpio_led *led = pdev_to_gpio(dev);
119
120 led_classdev_suspend(&led->cdev);
121 return 0;
122}
123
124static int s3c24xx_led_resume(struct platform_device *dev)
125{
126 struct s3c24xx_gpio_led *led = pdev_to_gpio(dev);
127
128 led_classdev_resume(&led->cdev);
129 return 0;
130}
131#else
132#define s3c24xx_led_suspend NULL
133#define s3c24xx_led_resume NULL
134#endif
135
136static struct platform_driver s3c24xx_led_driver = { 115static struct platform_driver s3c24xx_led_driver = {
137 .probe = s3c24xx_led_probe, 116 .probe = s3c24xx_led_probe,
138 .remove = s3c24xx_led_remove, 117 .remove = s3c24xx_led_remove,
139 .suspend = s3c24xx_led_suspend,
140 .resume = s3c24xx_led_resume,
141 .driver = { 118 .driver = {
142 .name = "s3c24xx_led", 119 .name = "s3c24xx_led",
143 .owner = THIS_MODULE, 120 .owner = THIS_MODULE,
diff --git a/drivers/leds/leds-wm8350.c b/drivers/leds/leds-wm8350.c
new file mode 100644
index 000000000000..38c6bcb07e6c
--- /dev/null
+++ b/drivers/leds/leds-wm8350.c
@@ -0,0 +1,311 @@
1/*
2 * LED driver for WM8350 driven LEDS.
3 *
4 * Copyright(C) 2007, 2008 Wolfson Microelectronics PLC.
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 */
11
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/platform_device.h>
15#include <linux/leds.h>
16#include <linux/err.h>
17#include <linux/mfd/wm8350/pmic.h>
18#include <linux/regulator/consumer.h>
19
20/* Microamps */
21static const int isink_cur[] = {
22 4,
23 5,
24 6,
25 7,
26 8,
27 10,
28 11,
29 14,
30 16,
31 19,
32 23,
33 27,
34 32,
35 39,
36 46,
37 54,
38 65,
39 77,
40 92,
41 109,
42 130,
43 154,
44 183,
45 218,
46 259,
47 308,
48 367,
49 436,
50 518,
51 616,
52 733,
53 872,
54 1037,
55 1233,
56 1466,
57 1744,
58 2073,
59 2466,
60 2933,
61 3487,
62 4147,
63 4932,
64 5865,
65 6975,
66 8294,
67 9864,
68 11730,
69 13949,
70 16589,
71 19728,
72 23460,
73 27899,
74 33178,
75 39455,
76 46920,
77 55798,
78 66355,
79 78910,
80 93840,
81 111596,
82 132710,
83 157820,
84 187681,
85 223191
86};
87
88#define to_wm8350_led(led_cdev) \
89 container_of(led_cdev, struct wm8350_led, cdev)
90
91static void wm8350_led_enable(struct wm8350_led *led)
92{
93 int ret;
94
95 if (led->enabled)
96 return;
97
98 ret = regulator_enable(led->isink);
99 if (ret != 0) {
100 dev_err(led->cdev.dev, "Failed to enable ISINK: %d\n", ret);
101 return;
102 }
103
104 ret = regulator_enable(led->dcdc);
105 if (ret != 0) {
106 dev_err(led->cdev.dev, "Failed to enable DCDC: %d\n", ret);
107 regulator_disable(led->isink);
108 return;
109 }
110
111 led->enabled = 1;
112}
113
114static void wm8350_led_disable(struct wm8350_led *led)
115{
116 int ret;
117
118 if (!led->enabled)
119 return;
120
121 ret = regulator_disable(led->dcdc);
122 if (ret != 0) {
123 dev_err(led->cdev.dev, "Failed to disable DCDC: %d\n", ret);
124 return;
125 }
126
127 ret = regulator_disable(led->isink);
128 if (ret != 0) {
129 dev_err(led->cdev.dev, "Failed to disable ISINK: %d\n", ret);
130 regulator_enable(led->dcdc);
131 return;
132 }
133
134 led->enabled = 0;
135}
136
137static void led_work(struct work_struct *work)
138{
139 struct wm8350_led *led = container_of(work, struct wm8350_led, work);
140 int ret;
141 int uA;
142 unsigned long flags;
143
144 mutex_lock(&led->mutex);
145
146 spin_lock_irqsave(&led->value_lock, flags);
147
148 if (led->value == LED_OFF) {
149 spin_unlock_irqrestore(&led->value_lock, flags);
150 wm8350_led_disable(led);
151 goto out;
152 }
153
154 /* This scales linearly into the index of valid current
155 * settings which results in a linear scaling of perceived
156 * brightness due to the non-linear current settings provided
157 * by the hardware.
158 */
159 uA = (led->max_uA_index * led->value) / LED_FULL;
160 spin_unlock_irqrestore(&led->value_lock, flags);
161 BUG_ON(uA >= ARRAY_SIZE(isink_cur));
162
163 ret = regulator_set_current_limit(led->isink, isink_cur[uA],
164 isink_cur[uA]);
165 if (ret != 0)
166 dev_err(led->cdev.dev, "Failed to set %duA: %d\n",
167 isink_cur[uA], ret);
168
169 wm8350_led_enable(led);
170
171out:
172 mutex_unlock(&led->mutex);
173}
174
175static void wm8350_led_set(struct led_classdev *led_cdev,
176 enum led_brightness value)
177{
178 struct wm8350_led *led = to_wm8350_led(led_cdev);
179 unsigned long flags;
180
181 spin_lock_irqsave(&led->value_lock, flags);
182 led->value = value;
183 schedule_work(&led->work);
184 spin_unlock_irqrestore(&led->value_lock, flags);
185}
186
187static void wm8350_led_shutdown(struct platform_device *pdev)
188{
189 struct wm8350_led *led = platform_get_drvdata(pdev);
190
191 mutex_lock(&led->mutex);
192 led->value = LED_OFF;
193 wm8350_led_disable(led);
194 mutex_unlock(&led->mutex);
195}
196
197static int wm8350_led_probe(struct platform_device *pdev)
198{
199 struct regulator *isink, *dcdc;
200 struct wm8350_led *led;
201 struct wm8350_led_platform_data *pdata = pdev->dev.platform_data;
202 int ret, i;
203
204 if (pdata == NULL) {
205 dev_err(&pdev->dev, "no platform data\n");
206 return -ENODEV;
207 }
208
209 if (pdata->max_uA < isink_cur[0]) {
210 dev_err(&pdev->dev, "Invalid maximum current %duA\n",
211 pdata->max_uA);
212 return -EINVAL;
213 }
214
215 isink = regulator_get(&pdev->dev, "led_isink");
216 if (IS_ERR(isink)) {
217 printk(KERN_ERR "%s: cant get ISINK\n", __func__);
218 return PTR_ERR(isink);
219 }
220
221 dcdc = regulator_get(&pdev->dev, "led_vcc");
222 if (IS_ERR(dcdc)) {
223 printk(KERN_ERR "%s: cant get DCDC\n", __func__);
224 ret = PTR_ERR(dcdc);
225 goto err_isink;
226 }
227
228 led = kzalloc(sizeof(*led), GFP_KERNEL);
229 if (led == NULL) {
230 ret = -ENOMEM;
231 goto err_dcdc;
232 }
233
234 led->cdev.brightness_set = wm8350_led_set;
235 led->cdev.default_trigger = pdata->default_trigger;
236 led->cdev.name = pdata->name;
237 led->cdev.flags |= LED_CORE_SUSPENDRESUME;
238 led->enabled = regulator_is_enabled(isink);
239 led->isink = isink;
240 led->dcdc = dcdc;
241
242 for (i = 0; i < ARRAY_SIZE(isink_cur) - 1; i++)
243 if (isink_cur[i] >= pdata->max_uA)
244 break;
245 led->max_uA_index = i;
246 if (pdata->max_uA != isink_cur[i])
247 dev_warn(&pdev->dev,
248 "Maximum current %duA is not directly supported,"
249 " check platform data\n",
250 pdata->max_uA);
251
252 spin_lock_init(&led->value_lock);
253 mutex_init(&led->mutex);
254 INIT_WORK(&led->work, led_work);
255 led->value = LED_OFF;
256 platform_set_drvdata(pdev, led);
257
258 ret = led_classdev_register(&pdev->dev, &led->cdev);
259 if (ret < 0)
260 goto err_led;
261
262 return 0;
263
264 err_led:
265 kfree(led);
266 err_dcdc:
267 regulator_put(dcdc);
268 err_isink:
269 regulator_put(isink);
270 return ret;
271}
272
273static int wm8350_led_remove(struct platform_device *pdev)
274{
275 struct wm8350_led *led = platform_get_drvdata(pdev);
276
277 led_classdev_unregister(&led->cdev);
278 flush_scheduled_work();
279 wm8350_led_disable(led);
280 regulator_put(led->dcdc);
281 regulator_put(led->isink);
282 kfree(led);
283 return 0;
284}
285
286static struct platform_driver wm8350_led_driver = {
287 .driver = {
288 .name = "wm8350-led",
289 .owner = THIS_MODULE,
290 },
291 .probe = wm8350_led_probe,
292 .remove = wm8350_led_remove,
293 .shutdown = wm8350_led_shutdown,
294};
295
296static int __devinit wm8350_led_init(void)
297{
298 return platform_driver_register(&wm8350_led_driver);
299}
300module_init(wm8350_led_init);
301
302static void wm8350_led_exit(void)
303{
304 platform_driver_unregister(&wm8350_led_driver);
305}
306module_exit(wm8350_led_exit);
307
308MODULE_AUTHOR("Mark Brown");
309MODULE_DESCRIPTION("WM8350 LED driver");
310MODULE_LICENSE("GPL");
311MODULE_ALIAS("platform:wm8350-led");
diff --git a/drivers/leds/leds-wrap.c b/drivers/leds/leds-wrap.c
index 2f3aa87f2a1f..2982c86ac4cf 100644
--- a/drivers/leds/leds-wrap.c
+++ b/drivers/leds/leds-wrap.c
@@ -56,40 +56,21 @@ static struct led_classdev wrap_power_led = {
56 .name = "wrap::power", 56 .name = "wrap::power",
57 .brightness_set = wrap_power_led_set, 57 .brightness_set = wrap_power_led_set,
58 .default_trigger = "default-on", 58 .default_trigger = "default-on",
59 .flags = LED_CORE_SUSPENDRESUME,
59}; 60};
60 61
61static struct led_classdev wrap_error_led = { 62static struct led_classdev wrap_error_led = {
62 .name = "wrap::error", 63 .name = "wrap::error",
63 .brightness_set = wrap_error_led_set, 64 .brightness_set = wrap_error_led_set,
65 .flags = LED_CORE_SUSPENDRESUME,
64}; 66};
65 67
66static struct led_classdev wrap_extra_led = { 68static struct led_classdev wrap_extra_led = {
67 .name = "wrap::extra", 69 .name = "wrap::extra",
68 .brightness_set = wrap_extra_led_set, 70 .brightness_set = wrap_extra_led_set,
71 .flags = LED_CORE_SUSPENDRESUME,
69}; 72};
70 73
71#ifdef CONFIG_PM
72static int wrap_led_suspend(struct platform_device *dev,
73 pm_message_t state)
74{
75 led_classdev_suspend(&wrap_power_led);
76 led_classdev_suspend(&wrap_error_led);
77 led_classdev_suspend(&wrap_extra_led);
78 return 0;
79}
80
81static int wrap_led_resume(struct platform_device *dev)
82{
83 led_classdev_resume(&wrap_power_led);
84 led_classdev_resume(&wrap_error_led);
85 led_classdev_resume(&wrap_extra_led);
86 return 0;
87}
88#else
89#define wrap_led_suspend NULL
90#define wrap_led_resume NULL
91#endif
92
93static int wrap_led_probe(struct platform_device *pdev) 74static int wrap_led_probe(struct platform_device *pdev)
94{ 75{
95 int ret; 76 int ret;
@@ -127,8 +108,6 @@ static int wrap_led_remove(struct platform_device *pdev)
127static struct platform_driver wrap_led_driver = { 108static struct platform_driver wrap_led_driver = {
128 .probe = wrap_led_probe, 109 .probe = wrap_led_probe,
129 .remove = wrap_led_remove, 110 .remove = wrap_led_remove,
130 .suspend = wrap_led_suspend,
131 .resume = wrap_led_resume,
132 .driver = { 111 .driver = {
133 .name = DRVNAME, 112 .name = DRVNAME,
134 .owner = THIS_MODULE, 113 .owner = THIS_MODULE,
diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c
index db681962d7bb..3d6531396dda 100644
--- a/drivers/leds/ledtrig-timer.c
+++ b/drivers/leds/ledtrig-timer.c
@@ -199,6 +199,7 @@ err_out:
199static void timer_trig_deactivate(struct led_classdev *led_cdev) 199static void timer_trig_deactivate(struct led_classdev *led_cdev)
200{ 200{
201 struct timer_trig_data *timer_data = led_cdev->trigger_data; 201 struct timer_trig_data *timer_data = led_cdev->trigger_data;
202 unsigned long on = 0, off = 0;
202 203
203 if (timer_data) { 204 if (timer_data) {
204 device_remove_file(led_cdev->dev, &dev_attr_delay_on); 205 device_remove_file(led_cdev->dev, &dev_attr_delay_on);
@@ -206,6 +207,10 @@ static void timer_trig_deactivate(struct led_classdev *led_cdev)
206 del_timer_sync(&timer_data->timer); 207 del_timer_sync(&timer_data->timer);
207 kfree(timer_data); 208 kfree(timer_data);
208 } 209 }
210
211 /* If there is hardware support for blinking, stop it */
212 if (led_cdev->blink_set)
213 led_cdev->blink_set(led_cdev, &on, &off);
209} 214}
210 215
211static struct led_trigger timer_led_trigger = { 216static struct led_trigger timer_led_trigger = {
diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig
index b52659620d50..173cf55c64d0 100644
--- a/drivers/macintosh/Kconfig
+++ b/drivers/macintosh/Kconfig
@@ -138,7 +138,7 @@ config PMAC_BACKLIGHT
138 Say Y here to enable Macintosh specific extensions of the generic 138 Say Y here to enable Macintosh specific extensions of the generic
139 backlight code. With this enabled, the brightness keys on older 139 backlight code. With this enabled, the brightness keys on older
140 PowerBooks will be enabled so you can change the screen brightness. 140 PowerBooks will be enabled so you can change the screen brightness.
141 Newer models should use an userspace daemon like pbbuttonsd. 141 Newer models should use a userspace daemon like pbbuttonsd.
142 142
143config PMAC_BACKLIGHT_LEGACY 143config PMAC_BACKLIGHT_LEGACY
144 bool "Provide legacy ioctl's on /dev/pmu for the backlight" 144 bool "Provide legacy ioctl's on /dev/pmu for the backlight"
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index ab7c8e4a61f9..719943763391 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -215,7 +215,6 @@ static struct page *read_sb_page(mddev_t *mddev, long offset,
215 /* choose a good rdev and read the page from there */ 215 /* choose a good rdev and read the page from there */
216 216
217 mdk_rdev_t *rdev; 217 mdk_rdev_t *rdev;
218 struct list_head *tmp;
219 sector_t target; 218 sector_t target;
220 219
221 if (!page) 220 if (!page)
@@ -223,7 +222,7 @@ static struct page *read_sb_page(mddev_t *mddev, long offset,
223 if (!page) 222 if (!page)
224 return ERR_PTR(-ENOMEM); 223 return ERR_PTR(-ENOMEM);
225 224
226 rdev_for_each(rdev, tmp, mddev) { 225 list_for_each_entry(rdev, &mddev->disks, same_set) {
227 if (! test_bit(In_sync, &rdev->flags) 226 if (! test_bit(In_sync, &rdev->flags)
228 || test_bit(Faulty, &rdev->flags)) 227 || test_bit(Faulty, &rdev->flags))
229 continue; 228 continue;
@@ -964,9 +963,11 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
964 */ 963 */
965 page = bitmap->sb_page; 964 page = bitmap->sb_page;
966 offset = sizeof(bitmap_super_t); 965 offset = sizeof(bitmap_super_t);
967 read_sb_page(bitmap->mddev, bitmap->offset, 966 if (!file)
968 page, 967 read_sb_page(bitmap->mddev,
969 index, count); 968 bitmap->offset,
969 page,
970 index, count);
970 } else if (file) { 971 } else if (file) {
971 page = read_page(file, index, bitmap, count); 972 page = read_page(file, index, bitmap, count);
972 offset = 0; 973 offset = 0;
diff --git a/drivers/md/faulty.c b/drivers/md/faulty.c
index f26c1f9a475b..86d9adf90e79 100644
--- a/drivers/md/faulty.c
+++ b/drivers/md/faulty.c
@@ -283,7 +283,6 @@ static int reconfig(mddev_t *mddev, int layout, int chunk_size)
283static int run(mddev_t *mddev) 283static int run(mddev_t *mddev)
284{ 284{
285 mdk_rdev_t *rdev; 285 mdk_rdev_t *rdev;
286 struct list_head *tmp;
287 int i; 286 int i;
288 287
289 conf_t *conf = kmalloc(sizeof(*conf), GFP_KERNEL); 288 conf_t *conf = kmalloc(sizeof(*conf), GFP_KERNEL);
@@ -296,7 +295,7 @@ static int run(mddev_t *mddev)
296 } 295 }
297 conf->nfaults = 0; 296 conf->nfaults = 0;
298 297
299 rdev_for_each(rdev, tmp, mddev) 298 list_for_each_entry(rdev, &mddev->disks, same_set)
300 conf->rdev = rdev; 299 conf->rdev = rdev;
301 300
302 mddev->array_sectors = mddev->size * 2; 301 mddev->array_sectors = mddev->size * 2;
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index 3b90c5c924ec..1e3aea9eecf1 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -105,7 +105,6 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
105 int i, nb_zone, cnt; 105 int i, nb_zone, cnt;
106 sector_t min_sectors; 106 sector_t min_sectors;
107 sector_t curr_sector; 107 sector_t curr_sector;
108 struct list_head *tmp;
109 108
110 conf = kzalloc (sizeof (*conf) + raid_disks*sizeof(dev_info_t), 109 conf = kzalloc (sizeof (*conf) + raid_disks*sizeof(dev_info_t),
111 GFP_KERNEL); 110 GFP_KERNEL);
@@ -115,7 +114,7 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
115 cnt = 0; 114 cnt = 0;
116 conf->array_sectors = 0; 115 conf->array_sectors = 0;
117 116
118 rdev_for_each(rdev, tmp, mddev) { 117 list_for_each_entry(rdev, &mddev->disks, same_set) {
119 int j = rdev->raid_disk; 118 int j = rdev->raid_disk;
120 dev_info_t *disk = conf->disks + j; 119 dev_info_t *disk = conf->disks + j;
121 120
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 1b1d32694f6f..41e2509bf896 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -214,20 +214,33 @@ static inline mddev_t *mddev_get(mddev_t *mddev)
214 return mddev; 214 return mddev;
215} 215}
216 216
217static void mddev_delayed_delete(struct work_struct *ws)
218{
219 mddev_t *mddev = container_of(ws, mddev_t, del_work);
220 kobject_del(&mddev->kobj);
221 kobject_put(&mddev->kobj);
222}
223
217static void mddev_put(mddev_t *mddev) 224static void mddev_put(mddev_t *mddev)
218{ 225{
219 if (!atomic_dec_and_lock(&mddev->active, &all_mddevs_lock)) 226 if (!atomic_dec_and_lock(&mddev->active, &all_mddevs_lock))
220 return; 227 return;
221 if (!mddev->raid_disks && list_empty(&mddev->disks)) { 228 if (!mddev->raid_disks && list_empty(&mddev->disks) &&
229 !mddev->hold_active) {
222 list_del(&mddev->all_mddevs); 230 list_del(&mddev->all_mddevs);
223 spin_unlock(&all_mddevs_lock); 231 if (mddev->gendisk) {
224 blk_cleanup_queue(mddev->queue); 232 /* we did a probe so need to clean up.
225 if (mddev->sysfs_state) 233 * Call schedule_work inside the spinlock
226 sysfs_put(mddev->sysfs_state); 234 * so that flush_scheduled_work() after
227 mddev->sysfs_state = NULL; 235 * mddev_find will succeed in waiting for the
228 kobject_put(&mddev->kobj); 236 * work to be done.
229 } else 237 */
230 spin_unlock(&all_mddevs_lock); 238 INIT_WORK(&mddev->del_work, mddev_delayed_delete);
239 schedule_work(&mddev->del_work);
240 } else
241 kfree(mddev);
242 }
243 spin_unlock(&all_mddevs_lock);
231} 244}
232 245
233static mddev_t * mddev_find(dev_t unit) 246static mddev_t * mddev_find(dev_t unit)
@@ -236,15 +249,50 @@ static mddev_t * mddev_find(dev_t unit)
236 249
237 retry: 250 retry:
238 spin_lock(&all_mddevs_lock); 251 spin_lock(&all_mddevs_lock);
239 list_for_each_entry(mddev, &all_mddevs, all_mddevs) 252
240 if (mddev->unit == unit) { 253 if (unit) {
241 mddev_get(mddev); 254 list_for_each_entry(mddev, &all_mddevs, all_mddevs)
255 if (mddev->unit == unit) {
256 mddev_get(mddev);
257 spin_unlock(&all_mddevs_lock);
258 kfree(new);
259 return mddev;
260 }
261
262 if (new) {
263 list_add(&new->all_mddevs, &all_mddevs);
242 spin_unlock(&all_mddevs_lock); 264 spin_unlock(&all_mddevs_lock);
243 kfree(new); 265 new->hold_active = UNTIL_IOCTL;
244 return mddev; 266 return new;
245 } 267 }
246 268 } else if (new) {
247 if (new) { 269 /* find an unused unit number */
270 static int next_minor = 512;
271 int start = next_minor;
272 int is_free = 0;
273 int dev = 0;
274 while (!is_free) {
275 dev = MKDEV(MD_MAJOR, next_minor);
276 next_minor++;
277 if (next_minor > MINORMASK)
278 next_minor = 0;
279 if (next_minor == start) {
280 /* Oh dear, all in use. */
281 spin_unlock(&all_mddevs_lock);
282 kfree(new);
283 return NULL;
284 }
285
286 is_free = 1;
287 list_for_each_entry(mddev, &all_mddevs, all_mddevs)
288 if (mddev->unit == dev) {
289 is_free = 0;
290 break;
291 }
292 }
293 new->unit = dev;
294 new->md_minor = MINOR(dev);
295 new->hold_active = UNTIL_STOP;
248 list_add(&new->all_mddevs, &all_mddevs); 296 list_add(&new->all_mddevs, &all_mddevs);
249 spin_unlock(&all_mddevs_lock); 297 spin_unlock(&all_mddevs_lock);
250 return new; 298 return new;
@@ -275,16 +323,6 @@ static mddev_t * mddev_find(dev_t unit)
275 new->resync_max = MaxSector; 323 new->resync_max = MaxSector;
276 new->level = LEVEL_NONE; 324 new->level = LEVEL_NONE;
277 325
278 new->queue = blk_alloc_queue(GFP_KERNEL);
279 if (!new->queue) {
280 kfree(new);
281 return NULL;
282 }
283 /* Can be unlocked because the queue is new: no concurrency */
284 queue_flag_set_unlocked(QUEUE_FLAG_CLUSTER, new->queue);
285
286 blk_queue_make_request(new->queue, md_fail_request);
287
288 goto retry; 326 goto retry;
289} 327}
290 328
@@ -307,25 +345,23 @@ static inline void mddev_unlock(mddev_t * mddev)
307 345
308static mdk_rdev_t * find_rdev_nr(mddev_t *mddev, int nr) 346static mdk_rdev_t * find_rdev_nr(mddev_t *mddev, int nr)
309{ 347{
310 mdk_rdev_t * rdev; 348 mdk_rdev_t *rdev;
311 struct list_head *tmp;
312 349
313 rdev_for_each(rdev, tmp, mddev) { 350 list_for_each_entry(rdev, &mddev->disks, same_set)
314 if (rdev->desc_nr == nr) 351 if (rdev->desc_nr == nr)
315 return rdev; 352 return rdev;
316 } 353
317 return NULL; 354 return NULL;
318} 355}
319 356
320static mdk_rdev_t * find_rdev(mddev_t * mddev, dev_t dev) 357static mdk_rdev_t * find_rdev(mddev_t * mddev, dev_t dev)
321{ 358{
322 struct list_head *tmp;
323 mdk_rdev_t *rdev; 359 mdk_rdev_t *rdev;
324 360
325 rdev_for_each(rdev, tmp, mddev) { 361 list_for_each_entry(rdev, &mddev->disks, same_set)
326 if (rdev->bdev->bd_dev == dev) 362 if (rdev->bdev->bd_dev == dev)
327 return rdev; 363 return rdev;
328 } 364
329 return NULL; 365 return NULL;
330} 366}
331 367
@@ -861,7 +897,6 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev)
861static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev) 897static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev)
862{ 898{
863 mdp_super_t *sb; 899 mdp_super_t *sb;
864 struct list_head *tmp;
865 mdk_rdev_t *rdev2; 900 mdk_rdev_t *rdev2;
866 int next_spare = mddev->raid_disks; 901 int next_spare = mddev->raid_disks;
867 902
@@ -933,7 +968,7 @@ static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev)
933 sb->state |= (1<<MD_SB_BITMAP_PRESENT); 968 sb->state |= (1<<MD_SB_BITMAP_PRESENT);
934 969
935 sb->disks[0].state = (1<<MD_DISK_REMOVED); 970 sb->disks[0].state = (1<<MD_DISK_REMOVED);
936 rdev_for_each(rdev2, tmp, mddev) { 971 list_for_each_entry(rdev2, &mddev->disks, same_set) {
937 mdp_disk_t *d; 972 mdp_disk_t *d;
938 int desc_nr; 973 int desc_nr;
939 if (rdev2->raid_disk >= 0 && test_bit(In_sync, &rdev2->flags) 974 if (rdev2->raid_disk >= 0 && test_bit(In_sync, &rdev2->flags)
@@ -1259,7 +1294,6 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
1259static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev) 1294static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1260{ 1295{
1261 struct mdp_superblock_1 *sb; 1296 struct mdp_superblock_1 *sb;
1262 struct list_head *tmp;
1263 mdk_rdev_t *rdev2; 1297 mdk_rdev_t *rdev2;
1264 int max_dev, i; 1298 int max_dev, i;
1265 /* make rdev->sb match mddev and rdev data. */ 1299 /* make rdev->sb match mddev and rdev data. */
@@ -1307,7 +1341,7 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1307 } 1341 }
1308 1342
1309 max_dev = 0; 1343 max_dev = 0;
1310 rdev_for_each(rdev2, tmp, mddev) 1344 list_for_each_entry(rdev2, &mddev->disks, same_set)
1311 if (rdev2->desc_nr+1 > max_dev) 1345 if (rdev2->desc_nr+1 > max_dev)
1312 max_dev = rdev2->desc_nr+1; 1346 max_dev = rdev2->desc_nr+1;
1313 1347
@@ -1316,7 +1350,7 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1316 for (i=0; i<max_dev;i++) 1350 for (i=0; i<max_dev;i++)
1317 sb->dev_roles[i] = cpu_to_le16(0xfffe); 1351 sb->dev_roles[i] = cpu_to_le16(0xfffe);
1318 1352
1319 rdev_for_each(rdev2, tmp, mddev) { 1353 list_for_each_entry(rdev2, &mddev->disks, same_set) {
1320 i = rdev2->desc_nr; 1354 i = rdev2->desc_nr;
1321 if (test_bit(Faulty, &rdev2->flags)) 1355 if (test_bit(Faulty, &rdev2->flags))
1322 sb->dev_roles[i] = cpu_to_le16(0xfffe); 1356 sb->dev_roles[i] = cpu_to_le16(0xfffe);
@@ -1466,6 +1500,9 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev)
1466 1500
1467 list_add_rcu(&rdev->same_set, &mddev->disks); 1501 list_add_rcu(&rdev->same_set, &mddev->disks);
1468 bd_claim_by_disk(rdev->bdev, rdev->bdev->bd_holder, mddev->gendisk); 1502 bd_claim_by_disk(rdev->bdev, rdev->bdev->bd_holder, mddev->gendisk);
1503
1504 /* May as well allow recovery to be retried once */
1505 mddev->recovery_disabled = 0;
1469 return 0; 1506 return 0;
1470 1507
1471 fail: 1508 fail:
@@ -1571,8 +1608,7 @@ static void kick_rdev_from_array(mdk_rdev_t * rdev)
1571 1608
1572static void export_array(mddev_t *mddev) 1609static void export_array(mddev_t *mddev)
1573{ 1610{
1574 struct list_head *tmp; 1611 mdk_rdev_t *rdev, *tmp;
1575 mdk_rdev_t *rdev;
1576 1612
1577 rdev_for_each(rdev, tmp, mddev) { 1613 rdev_for_each(rdev, tmp, mddev) {
1578 if (!rdev->mddev) { 1614 if (!rdev->mddev) {
@@ -1593,7 +1629,7 @@ static void print_desc(mdp_disk_t *desc)
1593 desc->major,desc->minor,desc->raid_disk,desc->state); 1629 desc->major,desc->minor,desc->raid_disk,desc->state);
1594} 1630}
1595 1631
1596static void print_sb(mdp_super_t *sb) 1632static void print_sb_90(mdp_super_t *sb)
1597{ 1633{
1598 int i; 1634 int i;
1599 1635
@@ -1624,10 +1660,57 @@ static void print_sb(mdp_super_t *sb)
1624 } 1660 }
1625 printk(KERN_INFO "md: THIS: "); 1661 printk(KERN_INFO "md: THIS: ");
1626 print_desc(&sb->this_disk); 1662 print_desc(&sb->this_disk);
1627
1628} 1663}
1629 1664
1630static void print_rdev(mdk_rdev_t *rdev) 1665static void print_sb_1(struct mdp_superblock_1 *sb)
1666{
1667 __u8 *uuid;
1668
1669 uuid = sb->set_uuid;
1670 printk(KERN_INFO "md: SB: (V:%u) (F:0x%08x) Array-ID:<%02x%02x%02x%02x"
1671 ":%02x%02x:%02x%02x:%02x%02x:%02x%02x%02x%02x%02x%02x>\n"
1672 KERN_INFO "md: Name: \"%s\" CT:%llu\n",
1673 le32_to_cpu(sb->major_version),
1674 le32_to_cpu(sb->feature_map),
1675 uuid[0], uuid[1], uuid[2], uuid[3],
1676 uuid[4], uuid[5], uuid[6], uuid[7],
1677 uuid[8], uuid[9], uuid[10], uuid[11],
1678 uuid[12], uuid[13], uuid[14], uuid[15],
1679 sb->set_name,
1680 (unsigned long long)le64_to_cpu(sb->ctime)
1681 & MD_SUPERBLOCK_1_TIME_SEC_MASK);
1682
1683 uuid = sb->device_uuid;
1684 printk(KERN_INFO "md: L%u SZ%llu RD:%u LO:%u CS:%u DO:%llu DS:%llu SO:%llu"
1685 " RO:%llu\n"
1686 KERN_INFO "md: Dev:%08x UUID: %02x%02x%02x%02x:%02x%02x:%02x%02x:%02x%02x"
1687 ":%02x%02x%02x%02x%02x%02x\n"
1688 KERN_INFO "md: (F:0x%08x) UT:%llu Events:%llu ResyncOffset:%llu CSUM:0x%08x\n"
1689 KERN_INFO "md: (MaxDev:%u) \n",
1690 le32_to_cpu(sb->level),
1691 (unsigned long long)le64_to_cpu(sb->size),
1692 le32_to_cpu(sb->raid_disks),
1693 le32_to_cpu(sb->layout),
1694 le32_to_cpu(sb->chunksize),
1695 (unsigned long long)le64_to_cpu(sb->data_offset),
1696 (unsigned long long)le64_to_cpu(sb->data_size),
1697 (unsigned long long)le64_to_cpu(sb->super_offset),
1698 (unsigned long long)le64_to_cpu(sb->recovery_offset),
1699 le32_to_cpu(sb->dev_number),
1700 uuid[0], uuid[1], uuid[2], uuid[3],
1701 uuid[4], uuid[5], uuid[6], uuid[7],
1702 uuid[8], uuid[9], uuid[10], uuid[11],
1703 uuid[12], uuid[13], uuid[14], uuid[15],
1704 sb->devflags,
1705 (unsigned long long)le64_to_cpu(sb->utime) & MD_SUPERBLOCK_1_TIME_SEC_MASK,
1706 (unsigned long long)le64_to_cpu(sb->events),
1707 (unsigned long long)le64_to_cpu(sb->resync_offset),
1708 le32_to_cpu(sb->sb_csum),
1709 le32_to_cpu(sb->max_dev)
1710 );
1711}
1712
1713static void print_rdev(mdk_rdev_t *rdev, int major_version)
1631{ 1714{
1632 char b[BDEVNAME_SIZE]; 1715 char b[BDEVNAME_SIZE];
1633 printk(KERN_INFO "md: rdev %s, SZ:%08llu F:%d S:%d DN:%u\n", 1716 printk(KERN_INFO "md: rdev %s, SZ:%08llu F:%d S:%d DN:%u\n",
@@ -1635,15 +1718,22 @@ static void print_rdev(mdk_rdev_t *rdev)
1635 test_bit(Faulty, &rdev->flags), test_bit(In_sync, &rdev->flags), 1718 test_bit(Faulty, &rdev->flags), test_bit(In_sync, &rdev->flags),
1636 rdev->desc_nr); 1719 rdev->desc_nr);
1637 if (rdev->sb_loaded) { 1720 if (rdev->sb_loaded) {
1638 printk(KERN_INFO "md: rdev superblock:\n"); 1721 printk(KERN_INFO "md: rdev superblock (MJ:%d):\n", major_version);
1639 print_sb((mdp_super_t*)page_address(rdev->sb_page)); 1722 switch (major_version) {
1723 case 0:
1724 print_sb_90((mdp_super_t*)page_address(rdev->sb_page));
1725 break;
1726 case 1:
1727 print_sb_1((struct mdp_superblock_1 *)page_address(rdev->sb_page));
1728 break;
1729 }
1640 } else 1730 } else
1641 printk(KERN_INFO "md: no rdev superblock!\n"); 1731 printk(KERN_INFO "md: no rdev superblock!\n");
1642} 1732}
1643 1733
1644static void md_print_devices(void) 1734static void md_print_devices(void)
1645{ 1735{
1646 struct list_head *tmp, *tmp2; 1736 struct list_head *tmp;
1647 mdk_rdev_t *rdev; 1737 mdk_rdev_t *rdev;
1648 mddev_t *mddev; 1738 mddev_t *mddev;
1649 char b[BDEVNAME_SIZE]; 1739 char b[BDEVNAME_SIZE];
@@ -1658,12 +1748,12 @@ static void md_print_devices(void)
1658 bitmap_print_sb(mddev->bitmap); 1748 bitmap_print_sb(mddev->bitmap);
1659 else 1749 else
1660 printk("%s: ", mdname(mddev)); 1750 printk("%s: ", mdname(mddev));
1661 rdev_for_each(rdev, tmp2, mddev) 1751 list_for_each_entry(rdev, &mddev->disks, same_set)
1662 printk("<%s>", bdevname(rdev->bdev,b)); 1752 printk("<%s>", bdevname(rdev->bdev,b));
1663 printk("\n"); 1753 printk("\n");
1664 1754
1665 rdev_for_each(rdev, tmp2, mddev) 1755 list_for_each_entry(rdev, &mddev->disks, same_set)
1666 print_rdev(rdev); 1756 print_rdev(rdev, mddev->major_version);
1667 } 1757 }
1668 printk("md: **********************************\n"); 1758 printk("md: **********************************\n");
1669 printk("\n"); 1759 printk("\n");
@@ -1679,9 +1769,8 @@ static void sync_sbs(mddev_t * mddev, int nospares)
1679 * with the rest of the array) 1769 * with the rest of the array)
1680 */ 1770 */
1681 mdk_rdev_t *rdev; 1771 mdk_rdev_t *rdev;
1682 struct list_head *tmp;
1683 1772
1684 rdev_for_each(rdev, tmp, mddev) { 1773 list_for_each_entry(rdev, &mddev->disks, same_set) {
1685 if (rdev->sb_events == mddev->events || 1774 if (rdev->sb_events == mddev->events ||
1686 (nospares && 1775 (nospares &&
1687 rdev->raid_disk < 0 && 1776 rdev->raid_disk < 0 &&
@@ -1699,7 +1788,6 @@ static void sync_sbs(mddev_t * mddev, int nospares)
1699 1788
1700static void md_update_sb(mddev_t * mddev, int force_change) 1789static void md_update_sb(mddev_t * mddev, int force_change)
1701{ 1790{
1702 struct list_head *tmp;
1703 mdk_rdev_t *rdev; 1791 mdk_rdev_t *rdev;
1704 int sync_req; 1792 int sync_req;
1705 int nospares = 0; 1793 int nospares = 0;
@@ -1790,7 +1878,7 @@ repeat:
1790 mdname(mddev),mddev->in_sync); 1878 mdname(mddev),mddev->in_sync);
1791 1879
1792 bitmap_update_sb(mddev->bitmap); 1880 bitmap_update_sb(mddev->bitmap);
1793 rdev_for_each(rdev, tmp, mddev) { 1881 list_for_each_entry(rdev, &mddev->disks, same_set) {
1794 char b[BDEVNAME_SIZE]; 1882 char b[BDEVNAME_SIZE];
1795 dprintk(KERN_INFO "md: "); 1883 dprintk(KERN_INFO "md: ");
1796 if (rdev->sb_loaded != 1) 1884 if (rdev->sb_loaded != 1)
@@ -1999,7 +2087,6 @@ slot_store(mdk_rdev_t *rdev, const char *buf, size_t len)
1999 md_wakeup_thread(rdev->mddev->thread); 2087 md_wakeup_thread(rdev->mddev->thread);
2000 } else if (rdev->mddev->pers) { 2088 } else if (rdev->mddev->pers) {
2001 mdk_rdev_t *rdev2; 2089 mdk_rdev_t *rdev2;
2002 struct list_head *tmp;
2003 /* Activating a spare .. or possibly reactivating 2090 /* Activating a spare .. or possibly reactivating
2004 * if we every get bitmaps working here. 2091 * if we every get bitmaps working here.
2005 */ 2092 */
@@ -2010,7 +2097,7 @@ slot_store(mdk_rdev_t *rdev, const char *buf, size_t len)
2010 if (rdev->mddev->pers->hot_add_disk == NULL) 2097 if (rdev->mddev->pers->hot_add_disk == NULL)
2011 return -EINVAL; 2098 return -EINVAL;
2012 2099
2013 rdev_for_each(rdev2, tmp, rdev->mddev) 2100 list_for_each_entry(rdev2, &rdev->mddev->disks, same_set)
2014 if (rdev2->raid_disk == slot) 2101 if (rdev2->raid_disk == slot)
2015 return -EEXIST; 2102 return -EEXIST;
2016 2103
@@ -2125,14 +2212,14 @@ rdev_size_store(mdk_rdev_t *rdev, const char *buf, size_t len)
2125 */ 2212 */
2126 mddev_t *mddev; 2213 mddev_t *mddev;
2127 int overlap = 0; 2214 int overlap = 0;
2128 struct list_head *tmp, *tmp2; 2215 struct list_head *tmp;
2129 2216
2130 mddev_unlock(my_mddev); 2217 mddev_unlock(my_mddev);
2131 for_each_mddev(mddev, tmp) { 2218 for_each_mddev(mddev, tmp) {
2132 mdk_rdev_t *rdev2; 2219 mdk_rdev_t *rdev2;
2133 2220
2134 mddev_lock(mddev); 2221 mddev_lock(mddev);
2135 rdev_for_each(rdev2, tmp2, mddev) 2222 list_for_each_entry(rdev2, &mddev->disks, same_set)
2136 if (test_bit(AllReserved, &rdev2->flags) || 2223 if (test_bit(AllReserved, &rdev2->flags) ||
2137 (rdev->bdev == rdev2->bdev && 2224 (rdev->bdev == rdev2->bdev &&
2138 rdev != rdev2 && 2225 rdev != rdev2 &&
@@ -2328,8 +2415,7 @@ abort_free:
2328static void analyze_sbs(mddev_t * mddev) 2415static void analyze_sbs(mddev_t * mddev)
2329{ 2416{
2330 int i; 2417 int i;
2331 struct list_head *tmp; 2418 mdk_rdev_t *rdev, *freshest, *tmp;
2332 mdk_rdev_t *rdev, *freshest;
2333 char b[BDEVNAME_SIZE]; 2419 char b[BDEVNAME_SIZE];
2334 2420
2335 freshest = NULL; 2421 freshest = NULL;
@@ -3046,7 +3132,7 @@ action_store(mddev_t *mddev, const char *page, size_t len)
3046 } 3132 }
3047 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 3133 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
3048 md_wakeup_thread(mddev->thread); 3134 md_wakeup_thread(mddev->thread);
3049 sysfs_notify(&mddev->kobj, NULL, "sync_action"); 3135 sysfs_notify_dirent(mddev->sysfs_action);
3050 return len; 3136 return len;
3051} 3137}
3052 3138
@@ -3404,6 +3490,8 @@ md_attr_store(struct kobject *kobj, struct attribute *attr,
3404 if (!capable(CAP_SYS_ADMIN)) 3490 if (!capable(CAP_SYS_ADMIN))
3405 return -EACCES; 3491 return -EACCES;
3406 rv = mddev_lock(mddev); 3492 rv = mddev_lock(mddev);
3493 if (mddev->hold_active == UNTIL_IOCTL)
3494 mddev->hold_active = 0;
3407 if (!rv) { 3495 if (!rv) {
3408 rv = entry->store(mddev, page, length); 3496 rv = entry->store(mddev, page, length);
3409 mddev_unlock(mddev); 3497 mddev_unlock(mddev);
@@ -3414,6 +3502,17 @@ md_attr_store(struct kobject *kobj, struct attribute *attr,
3414static void md_free(struct kobject *ko) 3502static void md_free(struct kobject *ko)
3415{ 3503{
3416 mddev_t *mddev = container_of(ko, mddev_t, kobj); 3504 mddev_t *mddev = container_of(ko, mddev_t, kobj);
3505
3506 if (mddev->sysfs_state)
3507 sysfs_put(mddev->sysfs_state);
3508
3509 if (mddev->gendisk) {
3510 del_gendisk(mddev->gendisk);
3511 put_disk(mddev->gendisk);
3512 }
3513 if (mddev->queue)
3514 blk_cleanup_queue(mddev->queue);
3515
3417 kfree(mddev); 3516 kfree(mddev);
3418} 3517}
3419 3518
@@ -3429,34 +3528,74 @@ static struct kobj_type md_ktype = {
3429 3528
3430int mdp_major = 0; 3529int mdp_major = 0;
3431 3530
3432static struct kobject *md_probe(dev_t dev, int *part, void *data) 3531static int md_alloc(dev_t dev, char *name)
3433{ 3532{
3434 static DEFINE_MUTEX(disks_mutex); 3533 static DEFINE_MUTEX(disks_mutex);
3435 mddev_t *mddev = mddev_find(dev); 3534 mddev_t *mddev = mddev_find(dev);
3436 struct gendisk *disk; 3535 struct gendisk *disk;
3437 int partitioned = (MAJOR(dev) != MD_MAJOR); 3536 int partitioned;
3438 int shift = partitioned ? MdpMinorShift : 0; 3537 int shift;
3439 int unit = MINOR(dev) >> shift; 3538 int unit;
3440 int error; 3539 int error;
3441 3540
3442 if (!mddev) 3541 if (!mddev)
3443 return NULL; 3542 return -ENODEV;
3543
3544 partitioned = (MAJOR(mddev->unit) != MD_MAJOR);
3545 shift = partitioned ? MdpMinorShift : 0;
3546 unit = MINOR(mddev->unit) >> shift;
3547
3548 /* wait for any previous instance if this device
3549 * to be completed removed (mddev_delayed_delete).
3550 */
3551 flush_scheduled_work();
3444 3552
3445 mutex_lock(&disks_mutex); 3553 mutex_lock(&disks_mutex);
3446 if (mddev->gendisk) { 3554 if (mddev->gendisk) {
3447 mutex_unlock(&disks_mutex); 3555 mutex_unlock(&disks_mutex);
3448 mddev_put(mddev); 3556 mddev_put(mddev);
3449 return NULL; 3557 return -EEXIST;
3558 }
3559
3560 if (name) {
3561 /* Need to ensure that 'name' is not a duplicate.
3562 */
3563 mddev_t *mddev2;
3564 spin_lock(&all_mddevs_lock);
3565
3566 list_for_each_entry(mddev2, &all_mddevs, all_mddevs)
3567 if (mddev2->gendisk &&
3568 strcmp(mddev2->gendisk->disk_name, name) == 0) {
3569 spin_unlock(&all_mddevs_lock);
3570 return -EEXIST;
3571 }
3572 spin_unlock(&all_mddevs_lock);
3573 }
3574
3575 mddev->queue = blk_alloc_queue(GFP_KERNEL);
3576 if (!mddev->queue) {
3577 mutex_unlock(&disks_mutex);
3578 mddev_put(mddev);
3579 return -ENOMEM;
3450 } 3580 }
3581 /* Can be unlocked because the queue is new: no concurrency */
3582 queue_flag_set_unlocked(QUEUE_FLAG_CLUSTER, mddev->queue);
3583
3584 blk_queue_make_request(mddev->queue, md_fail_request);
3585
3451 disk = alloc_disk(1 << shift); 3586 disk = alloc_disk(1 << shift);
3452 if (!disk) { 3587 if (!disk) {
3453 mutex_unlock(&disks_mutex); 3588 mutex_unlock(&disks_mutex);
3589 blk_cleanup_queue(mddev->queue);
3590 mddev->queue = NULL;
3454 mddev_put(mddev); 3591 mddev_put(mddev);
3455 return NULL; 3592 return -ENOMEM;
3456 } 3593 }
3457 disk->major = MAJOR(dev); 3594 disk->major = MAJOR(mddev->unit);
3458 disk->first_minor = unit << shift; 3595 disk->first_minor = unit << shift;
3459 if (partitioned) 3596 if (name)
3597 strcpy(disk->disk_name, name);
3598 else if (partitioned)
3460 sprintf(disk->disk_name, "md_d%d", unit); 3599 sprintf(disk->disk_name, "md_d%d", unit);
3461 else 3600 else
3462 sprintf(disk->disk_name, "md%d", unit); 3601 sprintf(disk->disk_name, "md%d", unit);
@@ -3464,7 +3603,7 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data)
3464 disk->private_data = mddev; 3603 disk->private_data = mddev;
3465 disk->queue = mddev->queue; 3604 disk->queue = mddev->queue;
3466 /* Allow extended partitions. This makes the 3605 /* Allow extended partitions. This makes the
3467 * 'mdp' device redundant, but we can really 3606 * 'mdp' device redundant, but we can't really
3468 * remove it now. 3607 * remove it now.
3469 */ 3608 */
3470 disk->flags |= GENHD_FL_EXT_DEVT; 3609 disk->flags |= GENHD_FL_EXT_DEVT;
@@ -3480,9 +3619,35 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data)
3480 kobject_uevent(&mddev->kobj, KOBJ_ADD); 3619 kobject_uevent(&mddev->kobj, KOBJ_ADD);
3481 mddev->sysfs_state = sysfs_get_dirent(mddev->kobj.sd, "array_state"); 3620 mddev->sysfs_state = sysfs_get_dirent(mddev->kobj.sd, "array_state");
3482 } 3621 }
3622 mddev_put(mddev);
3623 return 0;
3624}
3625
3626static struct kobject *md_probe(dev_t dev, int *part, void *data)
3627{
3628 md_alloc(dev, NULL);
3483 return NULL; 3629 return NULL;
3484} 3630}
3485 3631
3632static int add_named_array(const char *val, struct kernel_param *kp)
3633{
3634 /* val must be "md_*" where * is not all digits.
3635 * We allocate an array with a large free minor number, and
3636 * set the name to val. val must not already be an active name.
3637 */
3638 int len = strlen(val);
3639 char buf[DISK_NAME_LEN];
3640
3641 while (len && val[len-1] == '\n')
3642 len--;
3643 if (len >= DISK_NAME_LEN)
3644 return -E2BIG;
3645 strlcpy(buf, val, len+1);
3646 if (strncmp(buf, "md_", 3) != 0)
3647 return -EINVAL;
3648 return md_alloc(0, buf);
3649}
3650
3486static void md_safemode_timeout(unsigned long data) 3651static void md_safemode_timeout(unsigned long data)
3487{ 3652{
3488 mddev_t *mddev = (mddev_t *) data; 3653 mddev_t *mddev = (mddev_t *) data;
@@ -3501,7 +3666,6 @@ static int do_md_run(mddev_t * mddev)
3501{ 3666{
3502 int err; 3667 int err;
3503 int chunk_size; 3668 int chunk_size;
3504 struct list_head *tmp;
3505 mdk_rdev_t *rdev; 3669 mdk_rdev_t *rdev;
3506 struct gendisk *disk; 3670 struct gendisk *disk;
3507 struct mdk_personality *pers; 3671 struct mdk_personality *pers;
@@ -3540,7 +3704,7 @@ static int do_md_run(mddev_t * mddev)
3540 } 3704 }
3541 3705
3542 /* devices must have minimum size of one chunk */ 3706 /* devices must have minimum size of one chunk */
3543 rdev_for_each(rdev, tmp, mddev) { 3707 list_for_each_entry(rdev, &mddev->disks, same_set) {
3544 if (test_bit(Faulty, &rdev->flags)) 3708 if (test_bit(Faulty, &rdev->flags))
3545 continue; 3709 continue;
3546 if (rdev->size < chunk_size / 1024) { 3710 if (rdev->size < chunk_size / 1024) {
@@ -3565,7 +3729,7 @@ static int do_md_run(mddev_t * mddev)
3565 * the only valid external interface is through the md 3729 * the only valid external interface is through the md
3566 * device. 3730 * device.
3567 */ 3731 */
3568 rdev_for_each(rdev, tmp, mddev) { 3732 list_for_each_entry(rdev, &mddev->disks, same_set) {
3569 if (test_bit(Faulty, &rdev->flags)) 3733 if (test_bit(Faulty, &rdev->flags))
3570 continue; 3734 continue;
3571 sync_blockdev(rdev->bdev); 3735 sync_blockdev(rdev->bdev);
@@ -3630,10 +3794,10 @@ static int do_md_run(mddev_t * mddev)
3630 */ 3794 */
3631 char b[BDEVNAME_SIZE], b2[BDEVNAME_SIZE]; 3795 char b[BDEVNAME_SIZE], b2[BDEVNAME_SIZE];
3632 mdk_rdev_t *rdev2; 3796 mdk_rdev_t *rdev2;
3633 struct list_head *tmp2;
3634 int warned = 0; 3797 int warned = 0;
3635 rdev_for_each(rdev, tmp, mddev) { 3798
3636 rdev_for_each(rdev2, tmp2, mddev) { 3799 list_for_each_entry(rdev, &mddev->disks, same_set)
3800 list_for_each_entry(rdev2, &mddev->disks, same_set) {
3637 if (rdev < rdev2 && 3801 if (rdev < rdev2 &&
3638 rdev->bdev->bd_contains == 3802 rdev->bdev->bd_contains ==
3639 rdev2->bdev->bd_contains) { 3803 rdev2->bdev->bd_contains) {
@@ -3647,7 +3811,7 @@ static int do_md_run(mddev_t * mddev)
3647 warned = 1; 3811 warned = 1;
3648 } 3812 }
3649 } 3813 }
3650 } 3814
3651 if (warned) 3815 if (warned)
3652 printk(KERN_WARNING 3816 printk(KERN_WARNING
3653 "True protection against single-disk" 3817 "True protection against single-disk"
@@ -3684,6 +3848,7 @@ static int do_md_run(mddev_t * mddev)
3684 printk(KERN_WARNING 3848 printk(KERN_WARNING
3685 "md: cannot register extra attributes for %s\n", 3849 "md: cannot register extra attributes for %s\n",
3686 mdname(mddev)); 3850 mdname(mddev));
3851 mddev->sysfs_action = sysfs_get_dirent(mddev->kobj.sd, "sync_action");
3687 } else if (mddev->ro == 2) /* auto-readonly not meaningful */ 3852 } else if (mddev->ro == 2) /* auto-readonly not meaningful */
3688 mddev->ro = 0; 3853 mddev->ro = 0;
3689 3854
@@ -3694,7 +3859,7 @@ static int do_md_run(mddev_t * mddev)
3694 mddev->safemode_delay = (200 * HZ)/1000 +1; /* 200 msec delay */ 3859 mddev->safemode_delay = (200 * HZ)/1000 +1; /* 200 msec delay */
3695 mddev->in_sync = 1; 3860 mddev->in_sync = 1;
3696 3861
3697 rdev_for_each(rdev, tmp, mddev) 3862 list_for_each_entry(rdev, &mddev->disks, same_set)
3698 if (rdev->raid_disk >= 0) { 3863 if (rdev->raid_disk >= 0) {
3699 char nm[20]; 3864 char nm[20];
3700 sprintf(nm, "rd%d", rdev->raid_disk); 3865 sprintf(nm, "rd%d", rdev->raid_disk);
@@ -3725,9 +3890,8 @@ static int do_md_run(mddev_t * mddev)
3725 * it will remove the drives and not do the right thing 3890 * it will remove the drives and not do the right thing
3726 */ 3891 */
3727 if (mddev->degraded && !mddev->sync_thread) { 3892 if (mddev->degraded && !mddev->sync_thread) {
3728 struct list_head *rtmp;
3729 int spares = 0; 3893 int spares = 0;
3730 rdev_for_each(rdev, rtmp, mddev) 3894 list_for_each_entry(rdev, &mddev->disks, same_set)
3731 if (rdev->raid_disk >= 0 && 3895 if (rdev->raid_disk >= 0 &&
3732 !test_bit(In_sync, &rdev->flags) && 3896 !test_bit(In_sync, &rdev->flags) &&
3733 !test_bit(Faulty, &rdev->flags)) 3897 !test_bit(Faulty, &rdev->flags))
@@ -3754,7 +3918,8 @@ static int do_md_run(mddev_t * mddev)
3754 mddev->changed = 1; 3918 mddev->changed = 1;
3755 md_new_event(mddev); 3919 md_new_event(mddev);
3756 sysfs_notify_dirent(mddev->sysfs_state); 3920 sysfs_notify_dirent(mddev->sysfs_state);
3757 sysfs_notify(&mddev->kobj, NULL, "sync_action"); 3921 if (mddev->sysfs_action)
3922 sysfs_notify_dirent(mddev->sysfs_action);
3758 sysfs_notify(&mddev->kobj, NULL, "degraded"); 3923 sysfs_notify(&mddev->kobj, NULL, "degraded");
3759 kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE); 3924 kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE);
3760 return 0; 3925 return 0;
@@ -3854,9 +4019,12 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
3854 mddev->queue->merge_bvec_fn = NULL; 4019 mddev->queue->merge_bvec_fn = NULL;
3855 mddev->queue->unplug_fn = NULL; 4020 mddev->queue->unplug_fn = NULL;
3856 mddev->queue->backing_dev_info.congested_fn = NULL; 4021 mddev->queue->backing_dev_info.congested_fn = NULL;
3857 if (mddev->pers->sync_request) 4022 if (mddev->pers->sync_request) {
3858 sysfs_remove_group(&mddev->kobj, &md_redundancy_group); 4023 sysfs_remove_group(&mddev->kobj, &md_redundancy_group);
3859 4024 if (mddev->sysfs_action)
4025 sysfs_put(mddev->sysfs_action);
4026 mddev->sysfs_action = NULL;
4027 }
3860 module_put(mddev->pers->owner); 4028 module_put(mddev->pers->owner);
3861 mddev->pers = NULL; 4029 mddev->pers = NULL;
3862 /* tell userspace to handle 'inactive' */ 4030 /* tell userspace to handle 'inactive' */
@@ -3883,7 +4051,6 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
3883 */ 4051 */
3884 if (mode == 0) { 4052 if (mode == 0) {
3885 mdk_rdev_t *rdev; 4053 mdk_rdev_t *rdev;
3886 struct list_head *tmp;
3887 4054
3888 printk(KERN_INFO "md: %s stopped.\n", mdname(mddev)); 4055 printk(KERN_INFO "md: %s stopped.\n", mdname(mddev));
3889 4056
@@ -3895,7 +4062,7 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
3895 } 4062 }
3896 mddev->bitmap_offset = 0; 4063 mddev->bitmap_offset = 0;
3897 4064
3898 rdev_for_each(rdev, tmp, mddev) 4065 list_for_each_entry(rdev, &mddev->disks, same_set)
3899 if (rdev->raid_disk >= 0) { 4066 if (rdev->raid_disk >= 0) {
3900 char nm[20]; 4067 char nm[20];
3901 sprintf(nm, "rd%d", rdev->raid_disk); 4068 sprintf(nm, "rd%d", rdev->raid_disk);
@@ -3941,6 +4108,8 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
3941 mddev->barriers_work = 0; 4108 mddev->barriers_work = 0;
3942 mddev->safemode = 0; 4109 mddev->safemode = 0;
3943 kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE); 4110 kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE);
4111 if (mddev->hold_active == UNTIL_STOP)
4112 mddev->hold_active = 0;
3944 4113
3945 } else if (mddev->pers) 4114 } else if (mddev->pers)
3946 printk(KERN_INFO "md: %s switched to read-only mode.\n", 4115 printk(KERN_INFO "md: %s switched to read-only mode.\n",
@@ -3956,7 +4125,6 @@ out:
3956static void autorun_array(mddev_t *mddev) 4125static void autorun_array(mddev_t *mddev)
3957{ 4126{
3958 mdk_rdev_t *rdev; 4127 mdk_rdev_t *rdev;
3959 struct list_head *tmp;
3960 int err; 4128 int err;
3961 4129
3962 if (list_empty(&mddev->disks)) 4130 if (list_empty(&mddev->disks))
@@ -3964,7 +4132,7 @@ static void autorun_array(mddev_t *mddev)
3964 4132
3965 printk(KERN_INFO "md: running: "); 4133 printk(KERN_INFO "md: running: ");
3966 4134
3967 rdev_for_each(rdev, tmp, mddev) { 4135 list_for_each_entry(rdev, &mddev->disks, same_set) {
3968 char b[BDEVNAME_SIZE]; 4136 char b[BDEVNAME_SIZE];
3969 printk("<%s>", bdevname(rdev->bdev,b)); 4137 printk("<%s>", bdevname(rdev->bdev,b));
3970 } 4138 }
@@ -3991,8 +4159,7 @@ static void autorun_array(mddev_t *mddev)
3991 */ 4159 */
3992static void autorun_devices(int part) 4160static void autorun_devices(int part)
3993{ 4161{
3994 struct list_head *tmp; 4162 mdk_rdev_t *rdev0, *rdev, *tmp;
3995 mdk_rdev_t *rdev0, *rdev;
3996 mddev_t *mddev; 4163 mddev_t *mddev;
3997 char b[BDEVNAME_SIZE]; 4164 char b[BDEVNAME_SIZE];
3998 4165
@@ -4007,7 +4174,7 @@ static void autorun_devices(int part)
4007 printk(KERN_INFO "md: considering %s ...\n", 4174 printk(KERN_INFO "md: considering %s ...\n",
4008 bdevname(rdev0->bdev,b)); 4175 bdevname(rdev0->bdev,b));
4009 INIT_LIST_HEAD(&candidates); 4176 INIT_LIST_HEAD(&candidates);
4010 rdev_for_each_list(rdev, tmp, pending_raid_disks) 4177 rdev_for_each_list(rdev, tmp, &pending_raid_disks)
4011 if (super_90_load(rdev, rdev0, 0) >= 0) { 4178 if (super_90_load(rdev, rdev0, 0) >= 0) {
4012 printk(KERN_INFO "md: adding %s ...\n", 4179 printk(KERN_INFO "md: adding %s ...\n",
4013 bdevname(rdev->bdev,b)); 4180 bdevname(rdev->bdev,b));
@@ -4053,7 +4220,7 @@ static void autorun_devices(int part)
4053 } else { 4220 } else {
4054 printk(KERN_INFO "md: created %s\n", mdname(mddev)); 4221 printk(KERN_INFO "md: created %s\n", mdname(mddev));
4055 mddev->persistent = 1; 4222 mddev->persistent = 1;
4056 rdev_for_each_list(rdev, tmp, candidates) { 4223 rdev_for_each_list(rdev, tmp, &candidates) {
4057 list_del_init(&rdev->same_set); 4224 list_del_init(&rdev->same_set);
4058 if (bind_rdev_to_array(rdev, mddev)) 4225 if (bind_rdev_to_array(rdev, mddev))
4059 export_rdev(rdev); 4226 export_rdev(rdev);
@@ -4064,7 +4231,7 @@ static void autorun_devices(int part)
4064 /* on success, candidates will be empty, on error 4231 /* on success, candidates will be empty, on error
4065 * it won't... 4232 * it won't...
4066 */ 4233 */
4067 rdev_for_each_list(rdev, tmp, candidates) { 4234 rdev_for_each_list(rdev, tmp, &candidates) {
4068 list_del_init(&rdev->same_set); 4235 list_del_init(&rdev->same_set);
4069 export_rdev(rdev); 4236 export_rdev(rdev);
4070 } 4237 }
@@ -4093,10 +4260,9 @@ static int get_array_info(mddev_t * mddev, void __user * arg)
4093 mdu_array_info_t info; 4260 mdu_array_info_t info;
4094 int nr,working,active,failed,spare; 4261 int nr,working,active,failed,spare;
4095 mdk_rdev_t *rdev; 4262 mdk_rdev_t *rdev;
4096 struct list_head *tmp;
4097 4263
4098 nr=working=active=failed=spare=0; 4264 nr=working=active=failed=spare=0;
4099 rdev_for_each(rdev, tmp, mddev) { 4265 list_for_each_entry(rdev, &mddev->disks, same_set) {
4100 nr++; 4266 nr++;
4101 if (test_bit(Faulty, &rdev->flags)) 4267 if (test_bit(Faulty, &rdev->flags))
4102 failed++; 4268 failed++;
@@ -4614,9 +4780,8 @@ static int set_array_info(mddev_t * mddev, mdu_array_info_t *info)
4614 4780
4615static int update_size(mddev_t *mddev, sector_t num_sectors) 4781static int update_size(mddev_t *mddev, sector_t num_sectors)
4616{ 4782{
4617 mdk_rdev_t * rdev; 4783 mdk_rdev_t *rdev;
4618 int rv; 4784 int rv;
4619 struct list_head *tmp;
4620 int fit = (num_sectors == 0); 4785 int fit = (num_sectors == 0);
4621 4786
4622 if (mddev->pers->resize == NULL) 4787 if (mddev->pers->resize == NULL)
@@ -4638,7 +4803,7 @@ static int update_size(mddev_t *mddev, sector_t num_sectors)
4638 * grow, and re-add. 4803 * grow, and re-add.
4639 */ 4804 */
4640 return -EBUSY; 4805 return -EBUSY;
4641 rdev_for_each(rdev, tmp, mddev) { 4806 list_for_each_entry(rdev, &mddev->disks, same_set) {
4642 sector_t avail; 4807 sector_t avail;
4643 avail = rdev->size * 2; 4808 avail = rdev->size * 2;
4644 4809
@@ -5000,6 +5165,9 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
5000 5165
5001done_unlock: 5166done_unlock:
5002abort_unlock: 5167abort_unlock:
5168 if (mddev->hold_active == UNTIL_IOCTL &&
5169 err != -EINVAL)
5170 mddev->hold_active = 0;
5003 mddev_unlock(mddev); 5171 mddev_unlock(mddev);
5004 5172
5005 return err; 5173 return err;
@@ -5016,14 +5184,25 @@ static int md_open(struct block_device *bdev, fmode_t mode)
5016 * Succeed if we can lock the mddev, which confirms that 5184 * Succeed if we can lock the mddev, which confirms that
5017 * it isn't being stopped right now. 5185 * it isn't being stopped right now.
5018 */ 5186 */
5019 mddev_t *mddev = bdev->bd_disk->private_data; 5187 mddev_t *mddev = mddev_find(bdev->bd_dev);
5020 int err; 5188 int err;
5021 5189
5190 if (mddev->gendisk != bdev->bd_disk) {
5191 /* we are racing with mddev_put which is discarding this
5192 * bd_disk.
5193 */
5194 mddev_put(mddev);
5195 /* Wait until bdev->bd_disk is definitely gone */
5196 flush_scheduled_work();
5197 /* Then retry the open from the top */
5198 return -ERESTARTSYS;
5199 }
5200 BUG_ON(mddev != bdev->bd_disk->private_data);
5201
5022 if ((err = mutex_lock_interruptible_nested(&mddev->reconfig_mutex, 1))) 5202 if ((err = mutex_lock_interruptible_nested(&mddev->reconfig_mutex, 1)))
5023 goto out; 5203 goto out;
5024 5204
5025 err = 0; 5205 err = 0;
5026 mddev_get(mddev);
5027 atomic_inc(&mddev->openers); 5206 atomic_inc(&mddev->openers);
5028 mddev_unlock(mddev); 5207 mddev_unlock(mddev);
5029 5208
@@ -5187,11 +5366,10 @@ static void status_unused(struct seq_file *seq)
5187{ 5366{
5188 int i = 0; 5367 int i = 0;
5189 mdk_rdev_t *rdev; 5368 mdk_rdev_t *rdev;
5190 struct list_head *tmp;
5191 5369
5192 seq_printf(seq, "unused devices: "); 5370 seq_printf(seq, "unused devices: ");
5193 5371
5194 rdev_for_each_list(rdev, tmp, pending_raid_disks) { 5372 list_for_each_entry(rdev, &pending_raid_disks, same_set) {
5195 char b[BDEVNAME_SIZE]; 5373 char b[BDEVNAME_SIZE];
5196 i++; 5374 i++;
5197 seq_printf(seq, "%s ", 5375 seq_printf(seq, "%s ",
@@ -5350,7 +5528,6 @@ static int md_seq_show(struct seq_file *seq, void *v)
5350{ 5528{
5351 mddev_t *mddev = v; 5529 mddev_t *mddev = v;
5352 sector_t size; 5530 sector_t size;
5353 struct list_head *tmp2;
5354 mdk_rdev_t *rdev; 5531 mdk_rdev_t *rdev;
5355 struct mdstat_info *mi = seq->private; 5532 struct mdstat_info *mi = seq->private;
5356 struct bitmap *bitmap; 5533 struct bitmap *bitmap;
@@ -5387,7 +5564,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
5387 } 5564 }
5388 5565
5389 size = 0; 5566 size = 0;
5390 rdev_for_each(rdev, tmp2, mddev) { 5567 list_for_each_entry(rdev, &mddev->disks, same_set) {
5391 char b[BDEVNAME_SIZE]; 5568 char b[BDEVNAME_SIZE];
5392 seq_printf(seq, " %s[%d]", 5569 seq_printf(seq, " %s[%d]",
5393 bdevname(rdev->bdev,b), rdev->desc_nr); 5570 bdevname(rdev->bdev,b), rdev->desc_nr);
@@ -5694,7 +5871,6 @@ void md_do_sync(mddev_t *mddev)
5694 struct list_head *tmp; 5871 struct list_head *tmp;
5695 sector_t last_check; 5872 sector_t last_check;
5696 int skipped = 0; 5873 int skipped = 0;
5697 struct list_head *rtmp;
5698 mdk_rdev_t *rdev; 5874 mdk_rdev_t *rdev;
5699 char *desc; 5875 char *desc;
5700 5876
@@ -5799,7 +5975,7 @@ void md_do_sync(mddev_t *mddev)
5799 /* recovery follows the physical size of devices */ 5975 /* recovery follows the physical size of devices */
5800 max_sectors = mddev->size << 1; 5976 max_sectors = mddev->size << 1;
5801 j = MaxSector; 5977 j = MaxSector;
5802 rdev_for_each(rdev, rtmp, mddev) 5978 list_for_each_entry(rdev, &mddev->disks, same_set)
5803 if (rdev->raid_disk >= 0 && 5979 if (rdev->raid_disk >= 0 &&
5804 !test_bit(Faulty, &rdev->flags) && 5980 !test_bit(Faulty, &rdev->flags) &&
5805 !test_bit(In_sync, &rdev->flags) && 5981 !test_bit(In_sync, &rdev->flags) &&
@@ -5949,7 +6125,7 @@ void md_do_sync(mddev_t *mddev)
5949 } else { 6125 } else {
5950 if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery)) 6126 if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery))
5951 mddev->curr_resync = MaxSector; 6127 mddev->curr_resync = MaxSector;
5952 rdev_for_each(rdev, rtmp, mddev) 6128 list_for_each_entry(rdev, &mddev->disks, same_set)
5953 if (rdev->raid_disk >= 0 && 6129 if (rdev->raid_disk >= 0 &&
5954 !test_bit(Faulty, &rdev->flags) && 6130 !test_bit(Faulty, &rdev->flags) &&
5955 !test_bit(In_sync, &rdev->flags) && 6131 !test_bit(In_sync, &rdev->flags) &&
@@ -5985,10 +6161,9 @@ EXPORT_SYMBOL_GPL(md_do_sync);
5985static int remove_and_add_spares(mddev_t *mddev) 6161static int remove_and_add_spares(mddev_t *mddev)
5986{ 6162{
5987 mdk_rdev_t *rdev; 6163 mdk_rdev_t *rdev;
5988 struct list_head *rtmp;
5989 int spares = 0; 6164 int spares = 0;
5990 6165
5991 rdev_for_each(rdev, rtmp, mddev) 6166 list_for_each_entry(rdev, &mddev->disks, same_set)
5992 if (rdev->raid_disk >= 0 && 6167 if (rdev->raid_disk >= 0 &&
5993 !test_bit(Blocked, &rdev->flags) && 6168 !test_bit(Blocked, &rdev->flags) &&
5994 (test_bit(Faulty, &rdev->flags) || 6169 (test_bit(Faulty, &rdev->flags) ||
@@ -6003,8 +6178,8 @@ static int remove_and_add_spares(mddev_t *mddev)
6003 } 6178 }
6004 } 6179 }
6005 6180
6006 if (mddev->degraded && ! mddev->ro) { 6181 if (mddev->degraded && ! mddev->ro && !mddev->recovery_disabled) {
6007 rdev_for_each(rdev, rtmp, mddev) { 6182 list_for_each_entry(rdev, &mddev->disks, same_set) {
6008 if (rdev->raid_disk >= 0 && 6183 if (rdev->raid_disk >= 0 &&
6009 !test_bit(In_sync, &rdev->flags) && 6184 !test_bit(In_sync, &rdev->flags) &&
6010 !test_bit(Blocked, &rdev->flags)) 6185 !test_bit(Blocked, &rdev->flags))
@@ -6056,7 +6231,6 @@ static int remove_and_add_spares(mddev_t *mddev)
6056void md_check_recovery(mddev_t *mddev) 6231void md_check_recovery(mddev_t *mddev)
6057{ 6232{
6058 mdk_rdev_t *rdev; 6233 mdk_rdev_t *rdev;
6059 struct list_head *rtmp;
6060 6234
6061 6235
6062 if (mddev->bitmap) 6236 if (mddev->bitmap)
@@ -6120,7 +6294,7 @@ void md_check_recovery(mddev_t *mddev)
6120 if (mddev->flags) 6294 if (mddev->flags)
6121 md_update_sb(mddev, 0); 6295 md_update_sb(mddev, 0);
6122 6296
6123 rdev_for_each(rdev, rtmp, mddev) 6297 list_for_each_entry(rdev, &mddev->disks, same_set)
6124 if (test_and_clear_bit(StateChanged, &rdev->flags)) 6298 if (test_and_clear_bit(StateChanged, &rdev->flags))
6125 sysfs_notify_dirent(rdev->sysfs_state); 6299 sysfs_notify_dirent(rdev->sysfs_state);
6126 6300
@@ -6149,13 +6323,13 @@ void md_check_recovery(mddev_t *mddev)
6149 * information must be scrapped 6323 * information must be scrapped
6150 */ 6324 */
6151 if (!mddev->degraded) 6325 if (!mddev->degraded)
6152 rdev_for_each(rdev, rtmp, mddev) 6326 list_for_each_entry(rdev, &mddev->disks, same_set)
6153 rdev->saved_raid_disk = -1; 6327 rdev->saved_raid_disk = -1;
6154 6328
6155 mddev->recovery = 0; 6329 mddev->recovery = 0;
6156 /* flag recovery needed just to double check */ 6330 /* flag recovery needed just to double check */
6157 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 6331 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
6158 sysfs_notify(&mddev->kobj, NULL, "sync_action"); 6332 sysfs_notify_dirent(mddev->sysfs_action);
6159 md_new_event(mddev); 6333 md_new_event(mddev);
6160 goto unlock; 6334 goto unlock;
6161 } 6335 }
@@ -6216,7 +6390,7 @@ void md_check_recovery(mddev_t *mddev)
6216 mddev->recovery = 0; 6390 mddev->recovery = 0;
6217 } else 6391 } else
6218 md_wakeup_thread(mddev->sync_thread); 6392 md_wakeup_thread(mddev->sync_thread);
6219 sysfs_notify(&mddev->kobj, NULL, "sync_action"); 6393 sysfs_notify_dirent(mddev->sysfs_action);
6220 md_new_event(mddev); 6394 md_new_event(mddev);
6221 } 6395 }
6222 unlock: 6396 unlock:
@@ -6224,7 +6398,8 @@ void md_check_recovery(mddev_t *mddev)
6224 clear_bit(MD_RECOVERY_RUNNING, &mddev->recovery); 6398 clear_bit(MD_RECOVERY_RUNNING, &mddev->recovery);
6225 if (test_and_clear_bit(MD_RECOVERY_RECOVER, 6399 if (test_and_clear_bit(MD_RECOVERY_RECOVER,
6226 &mddev->recovery)) 6400 &mddev->recovery))
6227 sysfs_notify(&mddev->kobj, NULL, "sync_action"); 6401 if (mddev->sysfs_action)
6402 sysfs_notify_dirent(mddev->sysfs_action);
6228 } 6403 }
6229 mddev_unlock(mddev); 6404 mddev_unlock(mddev);
6230 } 6405 }
@@ -6386,14 +6561,8 @@ static __exit void md_exit(void)
6386 unregister_sysctl_table(raid_table_header); 6561 unregister_sysctl_table(raid_table_header);
6387 remove_proc_entry("mdstat", NULL); 6562 remove_proc_entry("mdstat", NULL);
6388 for_each_mddev(mddev, tmp) { 6563 for_each_mddev(mddev, tmp) {
6389 struct gendisk *disk = mddev->gendisk;
6390 if (!disk)
6391 continue;
6392 export_array(mddev); 6564 export_array(mddev);
6393 del_gendisk(disk); 6565 mddev->hold_active = 0;
6394 put_disk(disk);
6395 mddev->gendisk = NULL;
6396 mddev_put(mddev);
6397 } 6566 }
6398} 6567}
6399 6568
@@ -6418,6 +6587,7 @@ static int set_ro(const char *val, struct kernel_param *kp)
6418module_param_call(start_ro, set_ro, get_ro, NULL, S_IRUSR|S_IWUSR); 6587module_param_call(start_ro, set_ro, get_ro, NULL, S_IRUSR|S_IWUSR);
6419module_param(start_dirty_degraded, int, S_IRUGO|S_IWUSR); 6588module_param(start_dirty_degraded, int, S_IRUGO|S_IWUSR);
6420 6589
6590module_param_call(new_array, add_named_array, NULL, NULL, S_IWUSR);
6421 6591
6422EXPORT_SYMBOL(register_md_personality); 6592EXPORT_SYMBOL(register_md_personality);
6423EXPORT_SYMBOL(unregister_md_personality); 6593EXPORT_SYMBOL(unregister_md_personality);
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index d4ac47d11279..f6d08f241671 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -408,7 +408,6 @@ static int multipath_run (mddev_t *mddev)
408 int disk_idx; 408 int disk_idx;
409 struct multipath_info *disk; 409 struct multipath_info *disk;
410 mdk_rdev_t *rdev; 410 mdk_rdev_t *rdev;
411 struct list_head *tmp;
412 411
413 if (mddev->level != LEVEL_MULTIPATH) { 412 if (mddev->level != LEVEL_MULTIPATH) {
414 printk("multipath: %s: raid level not set to multipath IO (%d)\n", 413 printk("multipath: %s: raid level not set to multipath IO (%d)\n",
@@ -441,7 +440,7 @@ static int multipath_run (mddev_t *mddev)
441 } 440 }
442 441
443 conf->working_disks = 0; 442 conf->working_disks = 0;
444 rdev_for_each(rdev, tmp, mddev) { 443 list_for_each_entry(rdev, &mddev->disks, same_set) {
445 disk_idx = rdev->raid_disk; 444 disk_idx = rdev->raid_disk;
446 if (disk_idx < 0 || 445 if (disk_idx < 0 ||
447 disk_idx >= mddev->raid_disks) 446 disk_idx >= mddev->raid_disks)
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 8ac6488ad0dc..c605ba805586 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -53,11 +53,10 @@ static int raid0_congested(void *data, int bits)
53static int create_strip_zones (mddev_t *mddev) 53static int create_strip_zones (mddev_t *mddev)
54{ 54{
55 int i, c, j; 55 int i, c, j;
56 sector_t current_offset, curr_zone_offset; 56 sector_t current_start, curr_zone_start;
57 sector_t min_spacing; 57 sector_t min_spacing;
58 raid0_conf_t *conf = mddev_to_conf(mddev); 58 raid0_conf_t *conf = mddev_to_conf(mddev);
59 mdk_rdev_t *smallest, *rdev1, *rdev2, *rdev; 59 mdk_rdev_t *smallest, *rdev1, *rdev2, *rdev;
60 struct list_head *tmp1, *tmp2;
61 struct strip_zone *zone; 60 struct strip_zone *zone;
62 int cnt; 61 int cnt;
63 char b[BDEVNAME_SIZE]; 62 char b[BDEVNAME_SIZE];
@@ -67,19 +66,19 @@ static int create_strip_zones (mddev_t *mddev)
67 */ 66 */
68 conf->nr_strip_zones = 0; 67 conf->nr_strip_zones = 0;
69 68
70 rdev_for_each(rdev1, tmp1, mddev) { 69 list_for_each_entry(rdev1, &mddev->disks, same_set) {
71 printk("raid0: looking at %s\n", 70 printk(KERN_INFO "raid0: looking at %s\n",
72 bdevname(rdev1->bdev,b)); 71 bdevname(rdev1->bdev,b));
73 c = 0; 72 c = 0;
74 rdev_for_each(rdev2, tmp2, mddev) { 73 list_for_each_entry(rdev2, &mddev->disks, same_set) {
75 printk("raid0: comparing %s(%llu)", 74 printk(KERN_INFO "raid0: comparing %s(%llu)",
76 bdevname(rdev1->bdev,b), 75 bdevname(rdev1->bdev,b),
77 (unsigned long long)rdev1->size); 76 (unsigned long long)rdev1->size);
78 printk(" with %s(%llu)\n", 77 printk(KERN_INFO " with %s(%llu)\n",
79 bdevname(rdev2->bdev,b), 78 bdevname(rdev2->bdev,b),
80 (unsigned long long)rdev2->size); 79 (unsigned long long)rdev2->size);
81 if (rdev2 == rdev1) { 80 if (rdev2 == rdev1) {
82 printk("raid0: END\n"); 81 printk(KERN_INFO "raid0: END\n");
83 break; 82 break;
84 } 83 }
85 if (rdev2->size == rdev1->size) 84 if (rdev2->size == rdev1->size)
@@ -88,19 +87,20 @@ static int create_strip_zones (mddev_t *mddev)
88 * Not unique, don't count it as a new 87 * Not unique, don't count it as a new
89 * group 88 * group
90 */ 89 */
91 printk("raid0: EQUAL\n"); 90 printk(KERN_INFO "raid0: EQUAL\n");
92 c = 1; 91 c = 1;
93 break; 92 break;
94 } 93 }
95 printk("raid0: NOT EQUAL\n"); 94 printk(KERN_INFO "raid0: NOT EQUAL\n");
96 } 95 }
97 if (!c) { 96 if (!c) {
98 printk("raid0: ==> UNIQUE\n"); 97 printk(KERN_INFO "raid0: ==> UNIQUE\n");
99 conf->nr_strip_zones++; 98 conf->nr_strip_zones++;
100 printk("raid0: %d zones\n", conf->nr_strip_zones); 99 printk(KERN_INFO "raid0: %d zones\n",
100 conf->nr_strip_zones);
101 } 101 }
102 } 102 }
103 printk("raid0: FINAL %d zones\n", conf->nr_strip_zones); 103 printk(KERN_INFO "raid0: FINAL %d zones\n", conf->nr_strip_zones);
104 104
105 conf->strip_zone = kzalloc(sizeof(struct strip_zone)* 105 conf->strip_zone = kzalloc(sizeof(struct strip_zone)*
106 conf->nr_strip_zones, GFP_KERNEL); 106 conf->nr_strip_zones, GFP_KERNEL);
@@ -119,16 +119,17 @@ static int create_strip_zones (mddev_t *mddev)
119 cnt = 0; 119 cnt = 0;
120 smallest = NULL; 120 smallest = NULL;
121 zone->dev = conf->devlist; 121 zone->dev = conf->devlist;
122 rdev_for_each(rdev1, tmp1, mddev) { 122 list_for_each_entry(rdev1, &mddev->disks, same_set) {
123 int j = rdev1->raid_disk; 123 int j = rdev1->raid_disk;
124 124
125 if (j < 0 || j >= mddev->raid_disks) { 125 if (j < 0 || j >= mddev->raid_disks) {
126 printk("raid0: bad disk number %d - aborting!\n", j); 126 printk(KERN_ERR "raid0: bad disk number %d - "
127 "aborting!\n", j);
127 goto abort; 128 goto abort;
128 } 129 }
129 if (zone->dev[j]) { 130 if (zone->dev[j]) {
130 printk("raid0: multiple devices for %d - aborting!\n", 131 printk(KERN_ERR "raid0: multiple devices for %d - "
131 j); 132 "aborting!\n", j);
132 goto abort; 133 goto abort;
133 } 134 }
134 zone->dev[j] = rdev1; 135 zone->dev[j] = rdev1;
@@ -149,16 +150,16 @@ static int create_strip_zones (mddev_t *mddev)
149 cnt++; 150 cnt++;
150 } 151 }
151 if (cnt != mddev->raid_disks) { 152 if (cnt != mddev->raid_disks) {
152 printk("raid0: too few disks (%d of %d) - aborting!\n", 153 printk(KERN_ERR "raid0: too few disks (%d of %d) - "
153 cnt, mddev->raid_disks); 154 "aborting!\n", cnt, mddev->raid_disks);
154 goto abort; 155 goto abort;
155 } 156 }
156 zone->nb_dev = cnt; 157 zone->nb_dev = cnt;
157 zone->size = smallest->size * cnt; 158 zone->sectors = smallest->size * cnt * 2;
158 zone->zone_offset = 0; 159 zone->zone_start = 0;
159 160
160 current_offset = smallest->size; 161 current_start = smallest->size * 2;
161 curr_zone_offset = zone->size; 162 curr_zone_start = zone->sectors;
162 163
163 /* now do the other zones */ 164 /* now do the other zones */
164 for (i = 1; i < conf->nr_strip_zones; i++) 165 for (i = 1; i < conf->nr_strip_zones; i++)
@@ -166,40 +167,41 @@ static int create_strip_zones (mddev_t *mddev)
166 zone = conf->strip_zone + i; 167 zone = conf->strip_zone + i;
167 zone->dev = conf->strip_zone[i-1].dev + mddev->raid_disks; 168 zone->dev = conf->strip_zone[i-1].dev + mddev->raid_disks;
168 169
169 printk("raid0: zone %d\n", i); 170 printk(KERN_INFO "raid0: zone %d\n", i);
170 zone->dev_offset = current_offset; 171 zone->dev_start = current_start;
171 smallest = NULL; 172 smallest = NULL;
172 c = 0; 173 c = 0;
173 174
174 for (j=0; j<cnt; j++) { 175 for (j=0; j<cnt; j++) {
175 char b[BDEVNAME_SIZE]; 176 char b[BDEVNAME_SIZE];
176 rdev = conf->strip_zone[0].dev[j]; 177 rdev = conf->strip_zone[0].dev[j];
177 printk("raid0: checking %s ...", bdevname(rdev->bdev,b)); 178 printk(KERN_INFO "raid0: checking %s ...",
178 if (rdev->size > current_offset) 179 bdevname(rdev->bdev, b));
179 { 180 if (rdev->size > current_start / 2) {
180 printk(" contained as device %d\n", c); 181 printk(KERN_INFO " contained as device %d\n",
182 c);
181 zone->dev[c] = rdev; 183 zone->dev[c] = rdev;
182 c++; 184 c++;
183 if (!smallest || (rdev->size <smallest->size)) { 185 if (!smallest || (rdev->size <smallest->size)) {
184 smallest = rdev; 186 smallest = rdev;
185 printk(" (%llu) is smallest!.\n", 187 printk(KERN_INFO " (%llu) is smallest!.\n",
186 (unsigned long long)rdev->size); 188 (unsigned long long)rdev->size);
187 } 189 }
188 } else 190 } else
189 printk(" nope.\n"); 191 printk(KERN_INFO " nope.\n");
190 } 192 }
191 193
192 zone->nb_dev = c; 194 zone->nb_dev = c;
193 zone->size = (smallest->size - current_offset) * c; 195 zone->sectors = (smallest->size * 2 - current_start) * c;
194 printk("raid0: zone->nb_dev: %d, size: %llu\n", 196 printk(KERN_INFO "raid0: zone->nb_dev: %d, sectors: %llu\n",
195 zone->nb_dev, (unsigned long long)zone->size); 197 zone->nb_dev, (unsigned long long)zone->sectors);
196 198
197 zone->zone_offset = curr_zone_offset; 199 zone->zone_start = curr_zone_start;
198 curr_zone_offset += zone->size; 200 curr_zone_start += zone->sectors;
199 201
200 current_offset = smallest->size; 202 current_start = smallest->size * 2;
201 printk("raid0: current zone offset: %llu\n", 203 printk(KERN_INFO "raid0: current zone start: %llu\n",
202 (unsigned long long)current_offset); 204 (unsigned long long)current_start);
203 } 205 }
204 206
205 /* Now find appropriate hash spacing. 207 /* Now find appropriate hash spacing.
@@ -210,16 +212,16 @@ static int create_strip_zones (mddev_t *mddev)
210 * strip though as it's size has no bearing on the efficacy of the hash 212 * strip though as it's size has no bearing on the efficacy of the hash
211 * table. 213 * table.
212 */ 214 */
213 conf->hash_spacing = curr_zone_offset; 215 conf->spacing = curr_zone_start;
214 min_spacing = curr_zone_offset; 216 min_spacing = curr_zone_start;
215 sector_div(min_spacing, PAGE_SIZE/sizeof(struct strip_zone*)); 217 sector_div(min_spacing, PAGE_SIZE/sizeof(struct strip_zone*));
216 for (i=0; i < conf->nr_strip_zones-1; i++) { 218 for (i=0; i < conf->nr_strip_zones-1; i++) {
217 sector_t sz = 0; 219 sector_t s = 0;
218 for (j=i; j<conf->nr_strip_zones-1 && 220 for (j = i; j < conf->nr_strip_zones - 1 &&
219 sz < min_spacing ; j++) 221 s < min_spacing; j++)
220 sz += conf->strip_zone[j].size; 222 s += conf->strip_zone[j].sectors;
221 if (sz >= min_spacing && sz < conf->hash_spacing) 223 if (s >= min_spacing && s < conf->spacing)
222 conf->hash_spacing = sz; 224 conf->spacing = s;
223 } 225 }
224 226
225 mddev->queue->unplug_fn = raid0_unplug; 227 mddev->queue->unplug_fn = raid0_unplug;
@@ -227,7 +229,7 @@ static int create_strip_zones (mddev_t *mddev)
227 mddev->queue->backing_dev_info.congested_fn = raid0_congested; 229 mddev->queue->backing_dev_info.congested_fn = raid0_congested;
228 mddev->queue->backing_dev_info.congested_data = mddev; 230 mddev->queue->backing_dev_info.congested_data = mddev;
229 231
230 printk("raid0: done.\n"); 232 printk(KERN_INFO "raid0: done.\n");
231 return 0; 233 return 0;
232 abort: 234 abort:
233 return 1; 235 return 1;
@@ -262,10 +264,9 @@ static int raid0_mergeable_bvec(struct request_queue *q,
262static int raid0_run (mddev_t *mddev) 264static int raid0_run (mddev_t *mddev)
263{ 265{
264 unsigned cur=0, i=0, nb_zone; 266 unsigned cur=0, i=0, nb_zone;
265 s64 size; 267 s64 sectors;
266 raid0_conf_t *conf; 268 raid0_conf_t *conf;
267 mdk_rdev_t *rdev; 269 mdk_rdev_t *rdev;
268 struct list_head *tmp;
269 270
270 if (mddev->chunk_size == 0) { 271 if (mddev->chunk_size == 0) {
271 printk(KERN_ERR "md/raid0: non-zero chunk size required.\n"); 272 printk(KERN_ERR "md/raid0: non-zero chunk size required.\n");
@@ -291,54 +292,54 @@ static int raid0_run (mddev_t *mddev)
291 292
292 /* calculate array device size */ 293 /* calculate array device size */
293 mddev->array_sectors = 0; 294 mddev->array_sectors = 0;
294 rdev_for_each(rdev, tmp, mddev) 295 list_for_each_entry(rdev, &mddev->disks, same_set)
295 mddev->array_sectors += rdev->size * 2; 296 mddev->array_sectors += rdev->size * 2;
296 297
297 printk("raid0 : md_size is %llu blocks.\n", 298 printk(KERN_INFO "raid0 : md_size is %llu sectors.\n",
298 (unsigned long long)mddev->array_sectors / 2); 299 (unsigned long long)mddev->array_sectors);
299 printk("raid0 : conf->hash_spacing is %llu blocks.\n", 300 printk(KERN_INFO "raid0 : conf->spacing is %llu sectors.\n",
300 (unsigned long long)conf->hash_spacing); 301 (unsigned long long)conf->spacing);
301 { 302 {
302 sector_t s = mddev->array_sectors / 2; 303 sector_t s = mddev->array_sectors;
303 sector_t space = conf->hash_spacing; 304 sector_t space = conf->spacing;
304 int round; 305 int round;
305 conf->preshift = 0; 306 conf->sector_shift = 0;
306 if (sizeof(sector_t) > sizeof(u32)) { 307 if (sizeof(sector_t) > sizeof(u32)) {
307 /*shift down space and s so that sector_div will work */ 308 /*shift down space and s so that sector_div will work */
308 while (space > (sector_t) (~(u32)0)) { 309 while (space > (sector_t) (~(u32)0)) {
309 s >>= 1; 310 s >>= 1;
310 space >>= 1; 311 space >>= 1;
311 s += 1; /* force round-up */ 312 s += 1; /* force round-up */
312 conf->preshift++; 313 conf->sector_shift++;
313 } 314 }
314 } 315 }
315 round = sector_div(s, (u32)space) ? 1 : 0; 316 round = sector_div(s, (u32)space) ? 1 : 0;
316 nb_zone = s + round; 317 nb_zone = s + round;
317 } 318 }
318 printk("raid0 : nb_zone is %d.\n", nb_zone); 319 printk(KERN_INFO "raid0 : nb_zone is %d.\n", nb_zone);
319 320
320 printk("raid0 : Allocating %Zd bytes for hash.\n", 321 printk(KERN_INFO "raid0 : Allocating %zu bytes for hash.\n",
321 nb_zone*sizeof(struct strip_zone*)); 322 nb_zone*sizeof(struct strip_zone*));
322 conf->hash_table = kmalloc (sizeof (struct strip_zone *)*nb_zone, GFP_KERNEL); 323 conf->hash_table = kmalloc (sizeof (struct strip_zone *)*nb_zone, GFP_KERNEL);
323 if (!conf->hash_table) 324 if (!conf->hash_table)
324 goto out_free_conf; 325 goto out_free_conf;
325 size = conf->strip_zone[cur].size; 326 sectors = conf->strip_zone[cur].sectors;
326 327
327 conf->hash_table[0] = conf->strip_zone + cur; 328 conf->hash_table[0] = conf->strip_zone + cur;
328 for (i=1; i< nb_zone; i++) { 329 for (i=1; i< nb_zone; i++) {
329 while (size <= conf->hash_spacing) { 330 while (sectors <= conf->spacing) {
330 cur++; 331 cur++;
331 size += conf->strip_zone[cur].size; 332 sectors += conf->strip_zone[cur].sectors;
332 } 333 }
333 size -= conf->hash_spacing; 334 sectors -= conf->spacing;
334 conf->hash_table[i] = conf->strip_zone + cur; 335 conf->hash_table[i] = conf->strip_zone + cur;
335 } 336 }
336 if (conf->preshift) { 337 if (conf->sector_shift) {
337 conf->hash_spacing >>= conf->preshift; 338 conf->spacing >>= conf->sector_shift;
338 /* round hash_spacing up so when we divide by it, we 339 /* round spacing up so when we divide by it, we
339 * err on the side of too-low, which is safest 340 * err on the side of too-low, which is safest
340 */ 341 */
341 conf->hash_spacing++; 342 conf->spacing++;
342 } 343 }
343 344
344 /* calculate the max read-ahead size. 345 /* calculate the max read-ahead size.
@@ -387,12 +388,12 @@ static int raid0_stop (mddev_t *mddev)
387static int raid0_make_request (struct request_queue *q, struct bio *bio) 388static int raid0_make_request (struct request_queue *q, struct bio *bio)
388{ 389{
389 mddev_t *mddev = q->queuedata; 390 mddev_t *mddev = q->queuedata;
390 unsigned int sect_in_chunk, chunksize_bits, chunk_size, chunk_sects; 391 unsigned int sect_in_chunk, chunksect_bits, chunk_sects;
391 raid0_conf_t *conf = mddev_to_conf(mddev); 392 raid0_conf_t *conf = mddev_to_conf(mddev);
392 struct strip_zone *zone; 393 struct strip_zone *zone;
393 mdk_rdev_t *tmp_dev; 394 mdk_rdev_t *tmp_dev;
394 sector_t chunk; 395 sector_t chunk;
395 sector_t block, rsect; 396 sector_t sector, rsect;
396 const int rw = bio_data_dir(bio); 397 const int rw = bio_data_dir(bio);
397 int cpu; 398 int cpu;
398 399
@@ -407,11 +408,9 @@ static int raid0_make_request (struct request_queue *q, struct bio *bio)
407 bio_sectors(bio)); 408 bio_sectors(bio));
408 part_stat_unlock(); 409 part_stat_unlock();
409 410
410 chunk_size = mddev->chunk_size >> 10;
411 chunk_sects = mddev->chunk_size >> 9; 411 chunk_sects = mddev->chunk_size >> 9;
412 chunksize_bits = ffz(~chunk_size); 412 chunksect_bits = ffz(~chunk_sects);
413 block = bio->bi_sector >> 1; 413 sector = bio->bi_sector;
414
415 414
416 if (unlikely(chunk_sects < (bio->bi_sector & (chunk_sects - 1)) + (bio->bi_size >> 9))) { 415 if (unlikely(chunk_sects < (bio->bi_sector & (chunk_sects - 1)) + (bio->bi_size >> 9))) {
417 struct bio_pair *bp; 416 struct bio_pair *bp;
@@ -434,28 +433,27 @@ static int raid0_make_request (struct request_queue *q, struct bio *bio)
434 433
435 434
436 { 435 {
437 sector_t x = block >> conf->preshift; 436 sector_t x = sector >> conf->sector_shift;
438 sector_div(x, (u32)conf->hash_spacing); 437 sector_div(x, (u32)conf->spacing);
439 zone = conf->hash_table[x]; 438 zone = conf->hash_table[x];
440 } 439 }
441 440
442 while (block >= (zone->zone_offset + zone->size)) 441 while (sector >= zone->zone_start + zone->sectors)
443 zone++; 442 zone++;
444 443
445 sect_in_chunk = bio->bi_sector & ((chunk_size<<1) -1); 444 sect_in_chunk = bio->bi_sector & (chunk_sects - 1);
446 445
447 446
448 { 447 {
449 sector_t x = (block - zone->zone_offset) >> chunksize_bits; 448 sector_t x = (sector - zone->zone_start) >> chunksect_bits;
450 449
451 sector_div(x, zone->nb_dev); 450 sector_div(x, zone->nb_dev);
452 chunk = x; 451 chunk = x;
453 452
454 x = block >> chunksize_bits; 453 x = sector >> chunksect_bits;
455 tmp_dev = zone->dev[sector_div(x, zone->nb_dev)]; 454 tmp_dev = zone->dev[sector_div(x, zone->nb_dev)];
456 } 455 }
457 rsect = (((chunk << chunksize_bits) + zone->dev_offset)<<1) 456 rsect = (chunk << chunksect_bits) + zone->dev_start + sect_in_chunk;
458 + sect_in_chunk;
459 457
460 bio->bi_bdev = tmp_dev->bdev; 458 bio->bi_bdev = tmp_dev->bdev;
461 bio->bi_sector = rsect + tmp_dev->data_offset; 459 bio->bi_sector = rsect + tmp_dev->data_offset;
@@ -467,7 +465,7 @@ static int raid0_make_request (struct request_queue *q, struct bio *bio)
467 465
468bad_map: 466bad_map:
469 printk("raid0_make_request bug: can't convert block across chunks" 467 printk("raid0_make_request bug: can't convert block across chunks"
470 " or bigger than %dk %llu %d\n", chunk_size, 468 " or bigger than %dk %llu %d\n", chunk_sects / 2,
471 (unsigned long long)bio->bi_sector, bio->bi_size >> 10); 469 (unsigned long long)bio->bi_sector, bio->bi_size >> 10);
472 470
473 bio_io_error(bio); 471 bio_io_error(bio);
@@ -492,10 +490,10 @@ static void raid0_status (struct seq_file *seq, mddev_t *mddev)
492 seq_printf(seq, "%s/", bdevname( 490 seq_printf(seq, "%s/", bdevname(
493 conf->strip_zone[j].dev[k]->bdev,b)); 491 conf->strip_zone[j].dev[k]->bdev,b));
494 492
495 seq_printf(seq, "] zo=%d do=%d s=%d\n", 493 seq_printf(seq, "] zs=%d ds=%d s=%d\n",
496 conf->strip_zone[j].zone_offset, 494 conf->strip_zone[j].zone_start,
497 conf->strip_zone[j].dev_offset, 495 conf->strip_zone[j].dev_start,
498 conf->strip_zone[j].size); 496 conf->strip_zone[j].sectors);
499 } 497 }
500#endif 498#endif
501 seq_printf(seq, " %dk chunks", mddev->chunk_size/1024); 499 seq_printf(seq, " %dk chunks", mddev->chunk_size/1024);
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 9c788e2489b1..7b4f5f7155d8 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1016,12 +1016,16 @@ static void error(mddev_t *mddev, mdk_rdev_t *rdev)
1016 * else mark the drive as failed 1016 * else mark the drive as failed
1017 */ 1017 */
1018 if (test_bit(In_sync, &rdev->flags) 1018 if (test_bit(In_sync, &rdev->flags)
1019 && (conf->raid_disks - mddev->degraded) == 1) 1019 && (conf->raid_disks - mddev->degraded) == 1) {
1020 /* 1020 /*
1021 * Don't fail the drive, act as though we were just a 1021 * Don't fail the drive, act as though we were just a
1022 * normal single drive 1022 * normal single drive.
1023 * However don't try a recovery from this drive as
1024 * it is very likely to fail.
1023 */ 1025 */
1026 mddev->recovery_disabled = 1;
1024 return; 1027 return;
1028 }
1025 if (test_and_clear_bit(In_sync, &rdev->flags)) { 1029 if (test_and_clear_bit(In_sync, &rdev->flags)) {
1026 unsigned long flags; 1030 unsigned long flags;
1027 spin_lock_irqsave(&conf->device_lock, flags); 1031 spin_lock_irqsave(&conf->device_lock, flags);
@@ -1919,7 +1923,6 @@ static int run(mddev_t *mddev)
1919 int i, j, disk_idx; 1923 int i, j, disk_idx;
1920 mirror_info_t *disk; 1924 mirror_info_t *disk;
1921 mdk_rdev_t *rdev; 1925 mdk_rdev_t *rdev;
1922 struct list_head *tmp;
1923 1926
1924 if (mddev->level != 1) { 1927 if (mddev->level != 1) {
1925 printk("raid1: %s: raid level not set to mirroring (%d)\n", 1928 printk("raid1: %s: raid level not set to mirroring (%d)\n",
@@ -1964,7 +1967,7 @@ static int run(mddev_t *mddev)
1964 spin_lock_init(&conf->device_lock); 1967 spin_lock_init(&conf->device_lock);
1965 mddev->queue->queue_lock = &conf->device_lock; 1968 mddev->queue->queue_lock = &conf->device_lock;
1966 1969
1967 rdev_for_each(rdev, tmp, mddev) { 1970 list_for_each_entry(rdev, &mddev->disks, same_set) {
1968 disk_idx = rdev->raid_disk; 1971 disk_idx = rdev->raid_disk;
1969 if (disk_idx >= mddev->raid_disks 1972 if (disk_idx >= mddev->raid_disks
1970 || disk_idx < 0) 1973 || disk_idx < 0)
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 970a96ef9b18..6736d6dff981 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -2025,7 +2025,6 @@ static int run(mddev_t *mddev)
2025 int i, disk_idx; 2025 int i, disk_idx;
2026 mirror_info_t *disk; 2026 mirror_info_t *disk;
2027 mdk_rdev_t *rdev; 2027 mdk_rdev_t *rdev;
2028 struct list_head *tmp;
2029 int nc, fc, fo; 2028 int nc, fc, fo;
2030 sector_t stride, size; 2029 sector_t stride, size;
2031 2030
@@ -2108,7 +2107,7 @@ static int run(mddev_t *mddev)
2108 spin_lock_init(&conf->device_lock); 2107 spin_lock_init(&conf->device_lock);
2109 mddev->queue->queue_lock = &conf->device_lock; 2108 mddev->queue->queue_lock = &conf->device_lock;
2110 2109
2111 rdev_for_each(rdev, tmp, mddev) { 2110 list_for_each_entry(rdev, &mddev->disks, same_set) {
2112 disk_idx = rdev->raid_disk; 2111 disk_idx = rdev->raid_disk;
2113 if (disk_idx >= mddev->raid_disks 2112 if (disk_idx >= mddev->raid_disks
2114 || disk_idx < 0) 2113 || disk_idx < 0)
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index a36a7435edf5..a5ba080d303b 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3998,7 +3998,6 @@ static int run(mddev_t *mddev)
3998 int raid_disk, memory; 3998 int raid_disk, memory;
3999 mdk_rdev_t *rdev; 3999 mdk_rdev_t *rdev;
4000 struct disk_info *disk; 4000 struct disk_info *disk;
4001 struct list_head *tmp;
4002 int working_disks = 0; 4001 int working_disks = 0;
4003 4002
4004 if (mddev->level != 5 && mddev->level != 4 && mddev->level != 6) { 4003 if (mddev->level != 5 && mddev->level != 4 && mddev->level != 6) {
@@ -4108,7 +4107,7 @@ static int run(mddev_t *mddev)
4108 4107
4109 pr_debug("raid5: run(%s) called.\n", mdname(mddev)); 4108 pr_debug("raid5: run(%s) called.\n", mdname(mddev));
4110 4109
4111 rdev_for_each(rdev, tmp, mddev) { 4110 list_for_each_entry(rdev, &mddev->disks, same_set) {
4112 raid_disk = rdev->raid_disk; 4111 raid_disk = rdev->raid_disk;
4113 if (raid_disk >= conf->raid_disks 4112 if (raid_disk >= conf->raid_disks
4114 || raid_disk < 0) 4113 || raid_disk < 0)
@@ -4533,7 +4532,6 @@ static int raid5_start_reshape(mddev_t *mddev)
4533{ 4532{
4534 raid5_conf_t *conf = mddev_to_conf(mddev); 4533 raid5_conf_t *conf = mddev_to_conf(mddev);
4535 mdk_rdev_t *rdev; 4534 mdk_rdev_t *rdev;
4536 struct list_head *rtmp;
4537 int spares = 0; 4535 int spares = 0;
4538 int added_devices = 0; 4536 int added_devices = 0;
4539 unsigned long flags; 4537 unsigned long flags;
@@ -4541,7 +4539,7 @@ static int raid5_start_reshape(mddev_t *mddev)
4541 if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)) 4539 if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery))
4542 return -EBUSY; 4540 return -EBUSY;
4543 4541
4544 rdev_for_each(rdev, rtmp, mddev) 4542 list_for_each_entry(rdev, &mddev->disks, same_set)
4545 if (rdev->raid_disk < 0 && 4543 if (rdev->raid_disk < 0 &&
4546 !test_bit(Faulty, &rdev->flags)) 4544 !test_bit(Faulty, &rdev->flags))
4547 spares++; 4545 spares++;
@@ -4563,7 +4561,7 @@ static int raid5_start_reshape(mddev_t *mddev)
4563 /* Add some new drives, as many as will fit. 4561 /* Add some new drives, as many as will fit.
4564 * We know there are enough to make the newly sized array work. 4562 * We know there are enough to make the newly sized array work.
4565 */ 4563 */
4566 rdev_for_each(rdev, rtmp, mddev) 4564 list_for_each_entry(rdev, &mddev->disks, same_set)
4567 if (rdev->raid_disk < 0 && 4565 if (rdev->raid_disk < 0 &&
4568 !test_bit(Faulty, &rdev->flags)) { 4566 !test_bit(Faulty, &rdev->flags)) {
4569 if (raid5_add_disk(mddev, rdev) == 0) { 4567 if (raid5_add_disk(mddev, rdev) == 0) {
diff --git a/drivers/media/common/tuners/tda8290.c b/drivers/media/common/tuners/tda8290.c
index 0ee79fd7c7a9..4b8662edb7cb 100644
--- a/drivers/media/common/tuners/tda8290.c
+++ b/drivers/media/common/tuners/tda8290.c
@@ -150,7 +150,7 @@ static void set_audio(struct dvb_frontend *fe,
150 } 150 }
151} 151}
152 152
153struct { 153static struct {
154 unsigned char seq[2]; 154 unsigned char seq[2];
155} fm_mode[] = { 155} fm_mode[] = {
156 { { 0x01, 0x81} }, /* Put device into expert mode */ 156 { { 0x01, 0x81} }, /* Put device into expert mode */
@@ -207,7 +207,6 @@ static void tda8290_set_params(struct dvb_frontend *fe,
207 msleep(1); 207 msleep(1);
208 208
209 if (params->mode == V4L2_TUNER_RADIO) { 209 if (params->mode == V4L2_TUNER_RADIO) {
210 int i;
211 unsigned char deemphasis[] = { 0x13, 1 }; 210 unsigned char deemphasis[] = { 0x13, 1 };
212 211
213 /* FIXME: allow using a different deemphasis */ 212 /* FIXME: allow using a different deemphasis */
@@ -767,7 +766,8 @@ struct dvb_frontend *tda829x_attach(struct dvb_frontend *fe,
767 fe->ops.analog_ops.info.name = name; 766 fe->ops.analog_ops.info.name = name;
768 767
769 if (priv->ver & TDA8290) { 768 if (priv->ver & TDA8290) {
770 tda8290_init_tuner(fe); 769 if (priv->ver & (TDA8275 | TDA8275A))
770 tda8290_init_tuner(fe);
771 tda8290_init_if(fe); 771 tda8290_init_if(fe);
772 } else if (priv->ver & TDA8295) 772 } else if (priv->ver & TDA8295)
773 tda8295_init_if(fe); 773 tda8295_init_if(fe);
diff --git a/drivers/media/dvb/dm1105/Kconfig b/drivers/media/dvb/dm1105/Kconfig
index 1332301ef3ae..43f4d44edca6 100644
--- a/drivers/media/dvb/dm1105/Kconfig
+++ b/drivers/media/dvb/dm1105/Kconfig
@@ -1,6 +1,7 @@
1config DVB_DM1105 1config DVB_DM1105
2 tristate "SDMC DM1105 based PCI cards" 2 tristate "SDMC DM1105 based PCI cards"
3 depends on DVB_CORE && PCI && I2C 3 depends on DVB_CORE && PCI && I2C
4 depends on INPUT
4 select DVB_PLL if !DVB_FE_CUSTOMISE 5 select DVB_PLL if !DVB_FE_CUSTOMISE
5 select DVB_STV0299 if !DVB_FE_CUSTOMISE 6 select DVB_STV0299 if !DVB_FE_CUSTOMISE
6 select DVB_STV0288 if !DVB_FE_CUSTOMISE 7 select DVB_STV0288 if !DVB_FE_CUSTOMISE
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 171f9ca124f7..843407785083 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -824,7 +824,7 @@ static int dvb_frontend_check_parameters(struct dvb_frontend *fe,
824 return 0; 824 return 0;
825} 825}
826 826
827struct dtv_cmds_h dtv_cmds[] = { 827static struct dtv_cmds_h dtv_cmds[] = {
828 [DTV_TUNE] = { 828 [DTV_TUNE] = {
829 .name = "DTV_TUNE", 829 .name = "DTV_TUNE",
830 .cmd = DTV_TUNE, 830 .cmd = DTV_TUNE,
@@ -962,7 +962,7 @@ struct dtv_cmds_h dtv_cmds[] = {
962 }, 962 },
963}; 963};
964 964
965void dtv_property_dump(struct dtv_property *tvp) 965static void dtv_property_dump(struct dtv_property *tvp)
966{ 966{
967 int i; 967 int i;
968 968
@@ -993,7 +993,7 @@ void dtv_property_dump(struct dtv_property *tvp)
993 dprintk("%s() tvp.u.data = 0x%08x\n", __func__, tvp->u.data); 993 dprintk("%s() tvp.u.data = 0x%08x\n", __func__, tvp->u.data);
994} 994}
995 995
996int is_legacy_delivery_system(fe_delivery_system_t s) 996static int is_legacy_delivery_system(fe_delivery_system_t s)
997{ 997{
998 if((s == SYS_UNDEFINED) || (s == SYS_DVBC_ANNEX_AC) || 998 if((s == SYS_UNDEFINED) || (s == SYS_DVBC_ANNEX_AC) ||
999 (s == SYS_DVBC_ANNEX_B) || (s == SYS_DVBT) || (s == SYS_DVBS) || 999 (s == SYS_DVBC_ANNEX_B) || (s == SYS_DVBT) || (s == SYS_DVBS) ||
@@ -1007,7 +1007,8 @@ int is_legacy_delivery_system(fe_delivery_system_t s)
1007 * drivers can use a single set_frontend tuning function, regardless of whether 1007 * drivers can use a single set_frontend tuning function, regardless of whether
1008 * it's being used for the legacy or new API, reducing code and complexity. 1008 * it's being used for the legacy or new API, reducing code and complexity.
1009 */ 1009 */
1010void dtv_property_cache_sync(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) 1010static void dtv_property_cache_sync(struct dvb_frontend *fe,
1011 struct dvb_frontend_parameters *p)
1011{ 1012{
1012 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 1013 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
1013 1014
@@ -1059,7 +1060,7 @@ void dtv_property_cache_sync(struct dvb_frontend *fe, struct dvb_frontend_parame
1059/* Ensure the cached values are set correctly in the frontend 1060/* Ensure the cached values are set correctly in the frontend
1060 * legacy tuning structures, for the advanced tuning API. 1061 * legacy tuning structures, for the advanced tuning API.
1061 */ 1062 */
1062void dtv_property_legacy_params_sync(struct dvb_frontend *fe) 1063static void dtv_property_legacy_params_sync(struct dvb_frontend *fe)
1063{ 1064{
1064 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 1065 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
1065 struct dvb_frontend_private *fepriv = fe->frontend_priv; 1066 struct dvb_frontend_private *fepriv = fe->frontend_priv;
@@ -1114,7 +1115,7 @@ void dtv_property_legacy_params_sync(struct dvb_frontend *fe)
1114/* Ensure the cached values are set correctly in the frontend 1115/* Ensure the cached values are set correctly in the frontend
1115 * legacy tuning structures, for the legacy tuning API. 1116 * legacy tuning structures, for the legacy tuning API.
1116 */ 1117 */
1117void dtv_property_adv_params_sync(struct dvb_frontend *fe) 1118static void dtv_property_adv_params_sync(struct dvb_frontend *fe)
1118{ 1119{
1119 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 1120 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
1120 struct dvb_frontend_private *fepriv = fe->frontend_priv; 1121 struct dvb_frontend_private *fepriv = fe->frontend_priv;
@@ -1149,7 +1150,7 @@ void dtv_property_adv_params_sync(struct dvb_frontend *fe)
1149 } 1150 }
1150} 1151}
1151 1152
1152void dtv_property_cache_submit(struct dvb_frontend *fe) 1153static void dtv_property_cache_submit(struct dvb_frontend *fe)
1153{ 1154{
1154 struct dtv_frontend_properties *c = &fe->dtv_property_cache; 1155 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
1155 1156
@@ -1180,8 +1181,9 @@ static int dvb_frontend_ioctl_legacy(struct inode *inode, struct file *file,
1180static int dvb_frontend_ioctl_properties(struct inode *inode, struct file *file, 1181static int dvb_frontend_ioctl_properties(struct inode *inode, struct file *file,
1181 unsigned int cmd, void *parg); 1182 unsigned int cmd, void *parg);
1182 1183
1183int dtv_property_process_get(struct dvb_frontend *fe, struct dtv_property *tvp, 1184static int dtv_property_process_get(struct dvb_frontend *fe,
1184 struct inode *inode, struct file *file) 1185 struct dtv_property *tvp,
1186 struct inode *inode, struct file *file)
1185{ 1187{
1186 int r = 0; 1188 int r = 0;
1187 1189
@@ -1253,8 +1255,10 @@ int dtv_property_process_get(struct dvb_frontend *fe, struct dtv_property *tvp,
1253 return r; 1255 return r;
1254} 1256}
1255 1257
1256int dtv_property_process_set(struct dvb_frontend *fe, struct dtv_property *tvp, 1258static int dtv_property_process_set(struct dvb_frontend *fe,
1257 struct inode *inode, struct file *file) 1259 struct dtv_property *tvp,
1260 struct inode *inode,
1261 struct file *file)
1258{ 1262{
1259 int r = 0; 1263 int r = 0;
1260 struct dvb_frontend_private *fepriv = fe->frontend_priv; 1264 struct dvb_frontend_private *fepriv = fe->frontend_priv;
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
index 03fd9dd5c685..f6ba8468858e 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -125,7 +125,6 @@ static void hexdump( const unsigned char *buf, unsigned short len )
125 125
126struct dvb_net_priv { 126struct dvb_net_priv {
127 int in_use; 127 int in_use;
128 struct net_device_stats stats;
129 u16 pid; 128 u16 pid;
130 struct net_device *net; 129 struct net_device *net;
131 struct dvb_net *host; 130 struct dvb_net *host;
@@ -384,8 +383,8 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
384 if (priv->ule_skb) { 383 if (priv->ule_skb) {
385 dev_kfree_skb( priv->ule_skb ); 384 dev_kfree_skb( priv->ule_skb );
386 /* Prepare for next SNDU. */ 385 /* Prepare for next SNDU. */
387 priv->stats.rx_errors++; 386 dev->stats.rx_errors++;
388 priv->stats.rx_frame_errors++; 387 dev->stats.rx_frame_errors++;
389 } 388 }
390 reset_ule(priv); 389 reset_ule(priv);
391 priv->need_pusi = 1; 390 priv->need_pusi = 1;
@@ -438,8 +437,8 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
438 dev_kfree_skb( priv->ule_skb ); 437 dev_kfree_skb( priv->ule_skb );
439 /* Prepare for next SNDU. */ 438 /* Prepare for next SNDU. */
440 // reset_ule(priv); moved to below. 439 // reset_ule(priv); moved to below.
441 priv->stats.rx_errors++; 440 dev->stats.rx_errors++;
442 priv->stats.rx_frame_errors++; 441 dev->stats.rx_frame_errors++;
443 } 442 }
444 reset_ule(priv); 443 reset_ule(priv);
445 /* skip to next PUSI. */ 444 /* skip to next PUSI. */
@@ -460,8 +459,8 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
460 /* Drop partly decoded SNDU, reset state, resync on PUSI. */ 459 /* Drop partly decoded SNDU, reset state, resync on PUSI. */
461 if (priv->ule_skb) { 460 if (priv->ule_skb) {
462 dev_kfree_skb( priv->ule_skb ); 461 dev_kfree_skb( priv->ule_skb );
463 priv->stats.rx_errors++; 462 dev->stats.rx_errors++;
464 priv->stats.rx_frame_errors++; 463 dev->stats.rx_frame_errors++;
465 } 464 }
466 reset_ule(priv); 465 reset_ule(priv);
467 priv->need_pusi = 1; 466 priv->need_pusi = 1;
@@ -477,8 +476,8 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
477 if (priv->ule_sndu_remain > 183) { 476 if (priv->ule_sndu_remain > 183) {
478 /* Current SNDU lacks more data than there could be available in the 477 /* Current SNDU lacks more data than there could be available in the
479 * current TS cell. */ 478 * current TS cell. */
480 priv->stats.rx_errors++; 479 dev->stats.rx_errors++;
481 priv->stats.rx_length_errors++; 480 dev->stats.rx_length_errors++;
482 printk(KERN_WARNING "%lu: Expected %d more SNDU bytes, but " 481 printk(KERN_WARNING "%lu: Expected %d more SNDU bytes, but "
483 "got PUSI (pf %d, ts_remain %d). Flushing incomplete payload.\n", 482 "got PUSI (pf %d, ts_remain %d). Flushing incomplete payload.\n",
484 priv->ts_count, priv->ule_sndu_remain, ts[4], ts_remain); 483 priv->ts_count, priv->ule_sndu_remain, ts[4], ts_remain);
@@ -520,8 +519,8 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
520 if (priv->ule_sndu_len < 5) { 519 if (priv->ule_sndu_len < 5) {
521 printk(KERN_WARNING "%lu: Invalid ULE SNDU length %u. " 520 printk(KERN_WARNING "%lu: Invalid ULE SNDU length %u. "
522 "Resyncing.\n", priv->ts_count, priv->ule_sndu_len); 521 "Resyncing.\n", priv->ts_count, priv->ule_sndu_len);
523 priv->stats.rx_errors++; 522 dev->stats.rx_errors++;
524 priv->stats.rx_length_errors++; 523 dev->stats.rx_length_errors++;
525 priv->ule_sndu_len = 0; 524 priv->ule_sndu_len = 0;
526 priv->need_pusi = 1; 525 priv->need_pusi = 1;
527 new_ts = 1; 526 new_ts = 1;
@@ -573,7 +572,7 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
573 if (priv->ule_skb == NULL) { 572 if (priv->ule_skb == NULL) {
574 printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", 573 printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n",
575 dev->name); 574 dev->name);
576 priv->stats.rx_dropped++; 575 dev->stats.rx_dropped++;
577 return; 576 return;
578 } 577 }
579 578
@@ -637,8 +636,8 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
637 ule_dump = 1; 636 ule_dump = 1;
638#endif 637#endif
639 638
640 priv->stats.rx_errors++; 639 dev->stats.rx_errors++;
641 priv->stats.rx_crc_errors++; 640 dev->stats.rx_crc_errors++;
642 dev_kfree_skb(priv->ule_skb); 641 dev_kfree_skb(priv->ule_skb);
643 } else { 642 } else {
644 /* CRC32 verified OK. */ 643 /* CRC32 verified OK. */
@@ -744,8 +743,8 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
744 * receive the packet anyhow. */ 743 * receive the packet anyhow. */
745 /* if (priv->ule_dbit && skb->pkt_type == PACKET_OTHERHOST) 744 /* if (priv->ule_dbit && skb->pkt_type == PACKET_OTHERHOST)
746 priv->ule_skb->pkt_type = PACKET_HOST; */ 745 priv->ule_skb->pkt_type = PACKET_HOST; */
747 priv->stats.rx_packets++; 746 dev->stats.rx_packets++;
748 priv->stats.rx_bytes += priv->ule_skb->len; 747 dev->stats.rx_bytes += priv->ule_skb->len;
749 netif_rx(priv->ule_skb); 748 netif_rx(priv->ule_skb);
750 } 749 }
751 sndu_done: 750 sndu_done:
@@ -800,8 +799,7 @@ static void dvb_net_sec(struct net_device *dev,
800{ 799{
801 u8 *eth; 800 u8 *eth;
802 struct sk_buff *skb; 801 struct sk_buff *skb;
803 struct net_device_stats *stats = 802 struct net_device_stats *stats = &dev->stats;
804 &((struct dvb_net_priv *) netdev_priv(dev))->stats;
805 int snap = 0; 803 int snap = 0;
806 804
807 /* note: pkt_len includes a 32bit checksum */ 805 /* note: pkt_len includes a 32bit checksum */
@@ -1216,28 +1214,29 @@ static int dvb_net_stop(struct net_device *dev)
1216 return dvb_net_feed_stop(dev); 1214 return dvb_net_feed_stop(dev);
1217} 1215}
1218 1216
1219static struct net_device_stats * dvb_net_get_stats(struct net_device *dev)
1220{
1221 return &((struct dvb_net_priv *) netdev_priv(dev))->stats;
1222}
1223
1224static const struct header_ops dvb_header_ops = { 1217static const struct header_ops dvb_header_ops = {
1225 .create = eth_header, 1218 .create = eth_header,
1226 .parse = eth_header_parse, 1219 .parse = eth_header_parse,
1227 .rebuild = eth_rebuild_header, 1220 .rebuild = eth_rebuild_header,
1228}; 1221};
1229 1222
1223
1224static const struct net_device_ops dvb_netdev_ops = {
1225 .ndo_open = dvb_net_open,
1226 .ndo_stop = dvb_net_stop,
1227 .ndo_start_xmit = dvb_net_tx,
1228 .ndo_set_multicast_list = dvb_net_set_multicast_list,
1229 .ndo_set_mac_address = dvb_net_set_mac,
1230 .ndo_change_mtu = eth_change_mtu,
1231 .ndo_validate_addr = eth_validate_addr,
1232};
1233
1230static void dvb_net_setup(struct net_device *dev) 1234static void dvb_net_setup(struct net_device *dev)
1231{ 1235{
1232 ether_setup(dev); 1236 ether_setup(dev);
1233 1237
1234 dev->header_ops = &dvb_header_ops; 1238 dev->header_ops = &dvb_header_ops;
1235 dev->open = dvb_net_open; 1239 dev->netdev_ops = &dvb_netdev_ops;
1236 dev->stop = dvb_net_stop;
1237 dev->hard_start_xmit = dvb_net_tx;
1238 dev->get_stats = dvb_net_get_stats;
1239 dev->set_multicast_list = dvb_net_set_multicast_list;
1240 dev->set_mac_address = dvb_net_set_mac;
1241 dev->mtu = 4096; 1240 dev->mtu = 4096;
1242 dev->mc_count = 0; 1241 dev->mc_count = 0;
1243 1242
diff --git a/drivers/media/dvb/dvb-usb/anysee.c b/drivers/media/dvb/dvb-usb/anysee.c
index 5017f08b14a6..c6e7b4215d6b 100644
--- a/drivers/media/dvb/dvb-usb/anysee.c
+++ b/drivers/media/dvb/dvb-usb/anysee.c
@@ -41,7 +41,7 @@
41static int dvb_usb_anysee_debug; 41static int dvb_usb_anysee_debug;
42module_param_named(debug, dvb_usb_anysee_debug, int, 0644); 42module_param_named(debug, dvb_usb_anysee_debug, int, 0644);
43MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS); 43MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS);
44int dvb_usb_anysee_delsys; 44static int dvb_usb_anysee_delsys;
45module_param_named(delsys, dvb_usb_anysee_delsys, int, 0644); 45module_param_named(delsys, dvb_usb_anysee_delsys, int, 0644);
46MODULE_PARM_DESC(delsys, "select delivery mode (0=DVB-C, 1=DVB-T)"); 46MODULE_PARM_DESC(delsys, "select delivery mode (0=DVB-C, 1=DVB-T)");
47DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 47DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
diff --git a/drivers/media/dvb/frontends/cx24116.c b/drivers/media/dvb/frontends/cx24116.c
index 4f514d39b98f..28ad609e73f4 100644
--- a/drivers/media/dvb/frontends/cx24116.c
+++ b/drivers/media/dvb/frontends/cx24116.c
@@ -369,7 +369,7 @@ static int cx24116_set_inversion(struct cx24116_state *state,
369 * Not all S2 mmodulation schemes are support and not all rates with 369 * Not all S2 mmodulation schemes are support and not all rates with
370 * a scheme are support. Especially, no auto detect when in S2 mode. 370 * a scheme are support. Especially, no auto detect when in S2 mode.
371 */ 371 */
372struct cx24116_modfec { 372static struct cx24116_modfec {
373 fe_delivery_system_t delivery_system; 373 fe_delivery_system_t delivery_system;
374 fe_modulation_t modulation; 374 fe_modulation_t modulation;
375 fe_code_rate_t fec; 375 fe_code_rate_t fec;
diff --git a/drivers/media/dvb/frontends/lgdt3304.c b/drivers/media/dvb/frontends/lgdt3304.c
index 469ace5692c6..3bb0c4394f8a 100644
--- a/drivers/media/dvb/frontends/lgdt3304.c
+++ b/drivers/media/dvb/frontends/lgdt3304.c
@@ -42,7 +42,7 @@ static int i2c_write_demod_bytes (struct dvb_frontend *fe, __u8 *buf, int len)
42 42
43 for (i=0; i<len-1; i+=3){ 43 for (i=0; i<len-1; i+=3){
44 if((err = i2c_transfer(state->i2c, &i2cmsgs, 1))<0) { 44 if((err = i2c_transfer(state->i2c, &i2cmsgs, 1))<0) {
45 printk("%s i2c_transfer error %d\n", __FUNCTION__, err); 45 printk("%s i2c_transfer error %d\n", __func__, err);
46 if (err < 0) 46 if (err < 0)
47 return err; 47 return err;
48 else 48 else
@@ -73,7 +73,7 @@ static int lgdt3304_i2c_read_reg(struct dvb_frontend *fe, unsigned int reg)
73 i2cmsgs[1].buf = &buf; 73 i2cmsgs[1].buf = &buf;
74 74
75 if((ret = i2c_transfer(state->i2c, i2cmsgs, 2))<0) { 75 if((ret = i2c_transfer(state->i2c, i2cmsgs, 2))<0) {
76 printk("%s i2c_transfer error %d\n", __FUNCTION__, ret); 76 printk("%s i2c_transfer error %d\n", __func__, ret);
77 return ret; 77 return ret;
78 } 78 }
79 79
@@ -94,7 +94,7 @@ static int lgdt3304_i2c_write_reg(struct dvb_frontend *fe, int reg, int val)
94 }; 94 };
95 ret = i2c_transfer(state->i2c, &i2cmsgs, 1); 95 ret = i2c_transfer(state->i2c, &i2cmsgs, 1);
96 if (ret != 1) { 96 if (ret != 1) {
97 printk("%s i2c_transfer error %d\n", __FUNCTION__, ret); 97 printk("%s i2c_transfer error %d\n", __func__, ret);
98 return ret; 98 return ret;
99 } 99 }
100 100
@@ -238,7 +238,7 @@ static int lgdt3304_set_parameters(struct dvb_frontend *fe, struct dvb_frontend_
238 } 238 }
239 239
240 if (err) { 240 if (err) {
241 printk("%s error setting modulation\n", __FUNCTION__); 241 printk("%s error setting modulation\n", __func__);
242 } else { 242 } else {
243 state->current_modulation = param->u.vsb.modulation; 243 state->current_modulation = param->u.vsb.modulation;
244 } 244 }
@@ -305,7 +305,7 @@ static int lgdt3304_read_status(struct dvb_frontend *fe, fe_status_t *status)
305 } 305 }
306 break; 306 break;
307 default: 307 default:
308 printk("%s unhandled modulation\n", __FUNCTION__); 308 printk("%s unhandled modulation\n", __func__);
309 } 309 }
310 310
311 311
diff --git a/drivers/media/dvb/frontends/s921_module.c b/drivers/media/dvb/frontends/s921_module.c
index 3cbb9cb2cf47..892af8c9ed57 100644
--- a/drivers/media/dvb/frontends/s921_module.c
+++ b/drivers/media/dvb/frontends/s921_module.c
@@ -136,7 +136,7 @@ static int s921_write(void *dev, u8 reg, u8 val) {
136 }; 136 };
137 137
138 if((err = i2c_transfer(state->i2c, &i2cmsgs, 1))<0) { 138 if((err = i2c_transfer(state->i2c, &i2cmsgs, 1))<0) {
139 printk("%s i2c_transfer error %d\n", __FUNCTION__, err); 139 printk("%s i2c_transfer error %d\n", __func__, err);
140 if (err < 0) 140 if (err < 0)
141 return err; 141 return err;
142 else 142 else
diff --git a/drivers/media/dvb/frontends/stb0899_algo.c b/drivers/media/dvb/frontends/stb0899_algo.c
index ced9b7ae7d50..83dc7e12d5f0 100644
--- a/drivers/media/dvb/frontends/stb0899_algo.c
+++ b/drivers/media/dvb/frontends/stb0899_algo.c
@@ -54,7 +54,7 @@ static u32 stb0899_calc_srate(u32 master_clk, u8 *sfr)
54 * stb0899_get_srate 54 * stb0899_get_srate
55 * Get the current symbol rate 55 * Get the current symbol rate
56 */ 56 */
57u32 stb0899_get_srate(struct stb0899_state *state) 57static u32 stb0899_get_srate(struct stb0899_state *state)
58{ 58{
59 struct stb0899_internal *internal = &state->internal; 59 struct stb0899_internal *internal = &state->internal;
60 u8 sfr[3]; 60 u8 sfr[3];
@@ -763,7 +763,7 @@ static void stb0899_dvbs2_config_csm_auto(struct stb0899_state *state)
763 stb0899_write_s2reg(state, STB0899_S2DEMOD, STB0899_BASE_CSM_CNTRL1, STB0899_OFF0_CSM_CNTRL1, reg); 763 stb0899_write_s2reg(state, STB0899_S2DEMOD, STB0899_BASE_CSM_CNTRL1, STB0899_OFF0_CSM_CNTRL1, reg);
764} 764}
765 765
766long Log2Int(int number) 766static long Log2Int(int number)
767{ 767{
768 int i; 768 int i;
769 769
diff --git a/drivers/media/dvb/frontends/stb0899_drv.c b/drivers/media/dvb/frontends/stb0899_drv.c
index bee28f77b93f..10613acf18f5 100644
--- a/drivers/media/dvb/frontends/stb0899_drv.c
+++ b/drivers/media/dvb/frontends/stb0899_drv.c
@@ -134,7 +134,7 @@ static const struct stb0899_tab stb0899_dvbs2rf_tab[] = {
134}; 134};
135 135
136/* DVB-S2 Es/N0 quant in dB/100 vs read value * 100*/ 136/* DVB-S2 Es/N0 quant in dB/100 vs read value * 100*/
137struct stb0899_tab stb0899_quant_tab[] = { 137static struct stb0899_tab stb0899_quant_tab[] = {
138 { 0, 0 }, 138 { 0, 0 },
139 { 0, 100 }, 139 { 0, 100 },
140 { 600, 200 }, 140 { 600, 200 },
@@ -177,7 +177,7 @@ struct stb0899_tab stb0899_quant_tab[] = {
177}; 177};
178 178
179/* DVB-S2 Es/N0 estimate in dB/100 vs read value */ 179/* DVB-S2 Es/N0 estimate in dB/100 vs read value */
180struct stb0899_tab stb0899_est_tab[] = { 180static struct stb0899_tab stb0899_est_tab[] = {
181 { 0, 0 }, 181 { 0, 0 },
182 { 0, 1 }, 182 { 0, 1 },
183 { 301, 2 }, 183 { 301, 2 },
@@ -217,7 +217,7 @@ struct stb0899_tab stb0899_est_tab[] = {
217 { 5721, 526017 }, 217 { 5721, 526017 },
218}; 218};
219 219
220int _stb0899_read_reg(struct stb0899_state *state, unsigned int reg) 220static int _stb0899_read_reg(struct stb0899_state *state, unsigned int reg)
221{ 221{
222 int ret; 222 int ret;
223 223
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index 3507463fdac9..bcbc5d41a0fe 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -1337,7 +1337,7 @@ static struct stb0899_config tt3200_config = {
1337 .tuner_set_rfsiggain = NULL 1337 .tuner_set_rfsiggain = NULL
1338}; 1338};
1339 1339
1340struct stb6100_config tt3200_stb6100_config = { 1340static struct stb6100_config tt3200_stb6100_config = {
1341 .tuner_address = 0x60, 1341 .tuner_address = 0x60,
1342 .refclock = 27000000, 1342 .refclock = 27000000,
1343}; 1343};
@@ -1450,7 +1450,7 @@ static void frontend_init(struct budget_ci *budget_ci)
1450 if (budget_ci->budget.dvb_frontend) { 1450 if (budget_ci->budget.dvb_frontend) {
1451 if (dvb_attach(stb6100_attach, budget_ci->budget.dvb_frontend, &tt3200_stb6100_config, &budget_ci->budget.i2c_adap)) { 1451 if (dvb_attach(stb6100_attach, budget_ci->budget.dvb_frontend, &tt3200_stb6100_config, &budget_ci->budget.i2c_adap)) {
1452 if (!dvb_attach(lnbp21_attach, budget_ci->budget.dvb_frontend, &budget_ci->budget.i2c_adap, 0, 0)) { 1452 if (!dvb_attach(lnbp21_attach, budget_ci->budget.dvb_frontend, &budget_ci->budget.i2c_adap, 0, 0)) {
1453 printk("%s: No LNBP21 found!\n", __FUNCTION__); 1453 printk("%s: No LNBP21 found!\n", __func__);
1454 dvb_frontend_detach(budget_ci->budget.dvb_frontend); 1454 dvb_frontend_detach(budget_ci->budget.dvb_frontend);
1455 budget_ci->budget.dvb_frontend = NULL; 1455 budget_ci->budget.dvb_frontend = NULL;
1456 } 1456 }
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c
index 34a39d2e4703..46fd573a4f15 100644
--- a/drivers/media/video/cafe_ccic.c
+++ b/drivers/media/video/cafe_ccic.c
@@ -569,7 +569,6 @@ static int cafe_smbus_setup(struct cafe_camera *cam)
569 569
570 cafe_smbus_enable_irq(cam); 570 cafe_smbus_enable_irq(cam);
571 adap->id = I2C_HW_SMBUS_CAFE; 571 adap->id = I2C_HW_SMBUS_CAFE;
572 adap->class = I2C_CLASS_CAM_DIGITAL;
573 adap->owner = THIS_MODULE; 572 adap->owner = THIS_MODULE;
574 adap->client_register = cafe_smbus_attach; 573 adap->client_register = cafe_smbus_attach;
575 adap->client_unregister = cafe_smbus_detach; 574 adap->client_unregister = cafe_smbus_detach;
diff --git a/drivers/media/video/cx88/Kconfig b/drivers/media/video/cx88/Kconfig
index b0f837588e01..2d250a2a7bc3 100644
--- a/drivers/media/video/cx88/Kconfig
+++ b/drivers/media/video/cx88/Kconfig
@@ -69,6 +69,11 @@ config VIDEO_CX88_DVB
69 To compile this driver as a module, choose M here: the 69 To compile this driver as a module, choose M here: the
70 module will be called cx88-dvb. 70 module will be called cx88-dvb.
71 71
72config VIDEO_CX88_MPEG
73 tristate
74 depends on VIDEO_CX88_DVB || VIDEO_CX88_BLACKBIRD
75 default y
76
72config VIDEO_CX88_VP3054 77config VIDEO_CX88_VP3054
73 tristate "VP-3054 Secondary I2C Bus Support" 78 tristate "VP-3054 Secondary I2C Bus Support"
74 default m 79 default m
diff --git a/drivers/media/video/cx88/Makefile b/drivers/media/video/cx88/Makefile
index 6ec30f242578..b06b1275a9ec 100644
--- a/drivers/media/video/cx88/Makefile
+++ b/drivers/media/video/cx88/Makefile
@@ -3,7 +3,8 @@ cx88xx-objs := cx88-cards.o cx88-core.o cx88-i2c.o cx88-tvaudio.o \
3cx8800-objs := cx88-video.o cx88-vbi.o 3cx8800-objs := cx88-video.o cx88-vbi.o
4cx8802-objs := cx88-mpeg.o 4cx8802-objs := cx88-mpeg.o
5 5
6obj-$(CONFIG_VIDEO_CX88) += cx88xx.o cx8800.o cx8802.o 6obj-$(CONFIG_VIDEO_CX88) += cx88xx.o cx8800.o
7obj-$(CONFIG_VIDEO_CX88_MPEG) += cx8802.o
7obj-$(CONFIG_VIDEO_CX88_ALSA) += cx88-alsa.o 8obj-$(CONFIG_VIDEO_CX88_ALSA) += cx88-alsa.o
8obj-$(CONFIG_VIDEO_CX88_BLACKBIRD) += cx88-blackbird.o 9obj-$(CONFIG_VIDEO_CX88_BLACKBIRD) += cx88-blackbird.o
9obj-$(CONFIG_VIDEO_CX88_DVB) += cx88-dvb.o 10obj-$(CONFIG_VIDEO_CX88_DVB) += cx88-dvb.o
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index da4dd4913d9f..613dfea4ff3e 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -138,6 +138,28 @@ static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
138 return ret; 138 return ret;
139} 139}
140 140
141static void cx88_dvb_gate_ctrl(struct cx88_core *core, int open)
142{
143 struct videobuf_dvb_frontends *f;
144 struct videobuf_dvb_frontend *fe;
145
146 if (!core->dvbdev)
147 return;
148
149 f = &core->dvbdev->frontends;
150
151 if (!f)
152 return;
153
154 if (f->gate <= 1) /* undefined or fe0 */
155 fe = videobuf_dvb_get_frontend(f, 1);
156 else
157 fe = videobuf_dvb_get_frontend(f, f->gate);
158
159 if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl)
160 fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open);
161}
162
141/* ------------------------------------------------------------------ */ 163/* ------------------------------------------------------------------ */
142 164
143static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe) 165static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
@@ -597,12 +619,30 @@ static int dvb_register(struct cx8802_dev *dev)
597 struct cx88_core *core = dev->core; 619 struct cx88_core *core = dev->core;
598 struct videobuf_dvb_frontend *fe0, *fe1 = NULL; 620 struct videobuf_dvb_frontend *fe0, *fe1 = NULL;
599 int mfe_shared = 0; /* bus not shared by default */ 621 int mfe_shared = 0; /* bus not shared by default */
622 int i;
600 623
601 if (0 != core->i2c_rc) { 624 if (0 != core->i2c_rc) {
602 printk(KERN_ERR "%s/2: no i2c-bus available, cannot attach dvb drivers\n", core->name); 625 printk(KERN_ERR "%s/2: no i2c-bus available, cannot attach dvb drivers\n", core->name);
603 goto frontend_detach; 626 goto frontend_detach;
604 } 627 }
605 628
629 if (!core->board.num_frontends)
630 return -EINVAL;
631
632 mutex_init(&dev->frontends.lock);
633 INIT_LIST_HEAD(&dev->frontends.felist);
634
635 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
636 core->board.num_frontends);
637 for (i = 1; i <= core->board.num_frontends; i++) {
638 fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, i);
639 if (!fe0) {
640 printk(KERN_ERR "%s() failed to alloc\n", __func__);
641 videobuf_dvb_dealloc_frontends(&dev->frontends);
642 goto frontend_detach;
643 }
644 }
645
606 /* Get the first frontend */ 646 /* Get the first frontend */
607 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1); 647 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
608 if (!fe0) 648 if (!fe0)
@@ -611,6 +651,9 @@ static int dvb_register(struct cx8802_dev *dev)
611 /* multi-frontend gate control is undefined or defaults to fe0 */ 651 /* multi-frontend gate control is undefined or defaults to fe0 */
612 dev->frontends.gate = 0; 652 dev->frontends.gate = 0;
613 653
654 /* Sets the gate control callback to be used by i2c command calls */
655 core->gate_ctrl = cx88_dvb_gate_ctrl;
656
614 /* init frontend(s) */ 657 /* init frontend(s) */
615 switch (core->boardnr) { 658 switch (core->boardnr) {
616 case CX88_BOARD_HAUPPAUGE_DVB_T1: 659 case CX88_BOARD_HAUPPAUGE_DVB_T1:
@@ -1109,6 +1152,7 @@ static int dvb_register(struct cx8802_dev *dev)
1109 &dev->pci->dev, adapter_nr, mfe_shared); 1152 &dev->pci->dev, adapter_nr, mfe_shared);
1110 1153
1111frontend_detach: 1154frontend_detach:
1155 core->gate_ctrl = NULL;
1112 videobuf_dvb_dealloc_frontends(&dev->frontends); 1156 videobuf_dvb_dealloc_frontends(&dev->frontends);
1113 return -EINVAL; 1157 return -EINVAL;
1114} 1158}
@@ -1270,6 +1314,8 @@ static int cx8802_dvb_remove(struct cx8802_driver *drv)
1270 1314
1271 vp3054_i2c_remove(dev); 1315 vp3054_i2c_remove(dev);
1272 1316
1317 core->gate_ctrl = NULL;
1318
1273 return 0; 1319 return 0;
1274} 1320}
1275 1321
diff --git a/drivers/media/video/cx88/cx88-i2c.c b/drivers/media/video/cx88/cx88-i2c.c
index 1ab691d20692..c0ff2305d804 100644
--- a/drivers/media/video/cx88/cx88-i2c.c
+++ b/drivers/media/video/cx88/cx88-i2c.c
@@ -116,30 +116,16 @@ static int detach_inform(struct i2c_client *client)
116 116
117void cx88_call_i2c_clients(struct cx88_core *core, unsigned int cmd, void *arg) 117void cx88_call_i2c_clients(struct cx88_core *core, unsigned int cmd, void *arg)
118{ 118{
119#if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE)
120 struct videobuf_dvb_frontends *f = &core->dvbdev->frontends;
121 struct videobuf_dvb_frontend *fe = NULL;
122#endif
123 if (0 != core->i2c_rc) 119 if (0 != core->i2c_rc)
124 return; 120 return;
125 121
126#if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE) 122 if (core->gate_ctrl)
127 if (core->dvbdev && f) { 123 core->gate_ctrl(core, 1);
128 if(f->gate <= 1) /* undefined or fe0 */
129 fe = videobuf_dvb_get_frontend(f, 1);
130 else
131 fe = videobuf_dvb_get_frontend(f, f->gate);
132 124
133 if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl) 125 i2c_clients_command(&core->i2c_adap, cmd, arg);
134 fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, 1);
135 126
136 i2c_clients_command(&core->i2c_adap, cmd, arg); 127 if (core->gate_ctrl)
137 128 core->gate_ctrl(core, 0);
138 if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl)
139 fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, 0);
140 } else
141#endif
142 i2c_clients_command(&core->i2c_adap, cmd, arg);
143} 129}
144 130
145static const struct i2c_algo_bit_data cx8800_i2c_algo_template = { 131static const struct i2c_algo_bit_data cx8800_i2c_algo_template = {
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c
index 59164fc94f5f..b295b76737e3 100644
--- a/drivers/media/video/cx88/cx88-mpeg.c
+++ b/drivers/media/video/cx88/cx88-mpeg.c
@@ -787,6 +787,9 @@ static int __devinit cx8802_probe(struct pci_dev *pci_dev,
787 dev->pci = pci_dev; 787 dev->pci = pci_dev;
788 dev->core = core; 788 dev->core = core;
789 789
790 /* Maintain a reference so cx88-video can query the 8802 device. */
791 core->dvbdev = dev;
792
790 err = cx8802_init_common(dev); 793 err = cx8802_init_common(dev);
791 if (err != 0) 794 if (err != 0)
792 goto fail_free; 795 goto fail_free;
@@ -794,32 +797,6 @@ static int __devinit cx8802_probe(struct pci_dev *pci_dev,
794 INIT_LIST_HEAD(&dev->drvlist); 797 INIT_LIST_HEAD(&dev->drvlist);
795 list_add_tail(&dev->devlist,&cx8802_devlist); 798 list_add_tail(&dev->devlist,&cx8802_devlist);
796 799
797#if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE)
798 mutex_init(&dev->frontends.lock);
799 INIT_LIST_HEAD(&dev->frontends.felist);
800
801 if (core->board.num_frontends) {
802 struct videobuf_dvb_frontend *fe;
803 int i;
804
805 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
806 core->board.num_frontends);
807 for (i = 1; i <= core->board.num_frontends; i++) {
808 fe = videobuf_dvb_alloc_frontend(&dev->frontends, i);
809 if(fe == NULL) {
810 printk(KERN_ERR "%s() failed to alloc\n",
811 __func__);
812 videobuf_dvb_dealloc_frontends(&dev->frontends);
813 err = -ENOMEM;
814 goto fail_free;
815 }
816 }
817 }
818#endif
819
820 /* Maintain a reference so cx88-video can query the 8802 device. */
821 core->dvbdev = dev;
822
823 /* now autoload cx88-dvb or cx88-blackbird */ 800 /* now autoload cx88-dvb or cx88-blackbird */
824 request_modules(dev); 801 request_modules(dev);
825 return 0; 802 return 0;
@@ -827,6 +804,7 @@ static int __devinit cx8802_probe(struct pci_dev *pci_dev,
827 fail_free: 804 fail_free:
828 kfree(dev); 805 kfree(dev);
829 fail_core: 806 fail_core:
807 core->dvbdev = NULL;
830 cx88_core_put(core,pci_dev); 808 cx88_core_put(core,pci_dev);
831 return err; 809 return err;
832} 810}
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index eb9ce30dc5e6..60a8b3187f14 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -302,6 +302,7 @@ struct cx88_dmaqueue {
302 struct btcx_riscmem stopper; 302 struct btcx_riscmem stopper;
303 u32 count; 303 u32 count;
304}; 304};
305struct cx88_core;
305 306
306struct cx88_core { 307struct cx88_core {
307 struct list_head devlist; 308 struct list_head devlist;
@@ -334,7 +335,8 @@ struct cx88_core {
334 335
335 /* config info -- dvb */ 336 /* config info -- dvb */
336#if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE) 337#if defined(CONFIG_VIDEO_CX88_DVB) || defined(CONFIG_VIDEO_CX88_DVB_MODULE)
337 int (*prev_set_voltage)(struct dvb_frontend* fe, fe_sec_voltage_t voltage); 338 int (*prev_set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t voltage);
339 void (*gate_ctrl)(struct cx88_core *core, int open);
338#endif 340#endif
339 341
340 /* state info */ 342 /* state info */
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index e776699b62f9..ef9bf008a924 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -1842,7 +1842,7 @@ void em28xx_release_resources(struct em28xx *dev)
1842 * em28xx_init_dev() 1842 * em28xx_init_dev()
1843 * allocates and inits the device structs, registers i2c bus and v4l device 1843 * allocates and inits the device structs, registers i2c bus and v4l device
1844 */ 1844 */
1845int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, 1845static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1846 int minor) 1846 int minor)
1847{ 1847{
1848 struct em28xx *dev = *devhandle; 1848 struct em28xx *dev = *devhandle;
@@ -1990,8 +1990,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
1990 int check_interface = 1; 1990 int check_interface = 1;
1991 isoc_pipe = 1; 1991 isoc_pipe = 1;
1992 endpoint = &interface->cur_altsetting->endpoint[1].desc; 1992 endpoint = &interface->cur_altsetting->endpoint[1].desc;
1993 if (usb_endpoint_type(endpoint) != 1993 if (!usb_endpoint_xfer_isoc(endpoint))
1994 USB_ENDPOINT_XFER_ISOC)
1995 check_interface = 0; 1994 check_interface = 0;
1996 1995
1997 if (usb_endpoint_dir_out(endpoint)) 1996 if (usb_endpoint_dir_out(endpoint))
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index 819cceaa6ef4..eb5fb05fab22 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -393,7 +393,7 @@ static int em28xx_set_audio_source(struct em28xx *dev)
393 return ret; 393 return ret;
394} 394}
395 395
396struct em28xx_vol_table outputs[] = { 396static const struct em28xx_vol_table outputs[] = {
397 { EM28XX_AOUT_MASTER, AC97_MASTER_VOL }, 397 { EM28XX_AOUT_MASTER, AC97_MASTER_VOL },
398 { EM28XX_AOUT_LINE, AC97_LINE_LEVEL_VOL }, 398 { EM28XX_AOUT_LINE, AC97_LINE_LEVEL_VOL },
399 { EM28XX_AOUT_MONO, AC97_MASTER_MONO_VOL }, 399 { EM28XX_AOUT_MONO, AC97_MASTER_MONO_VOL },
diff --git a/drivers/media/video/em28xx/em28xx-input.c b/drivers/media/video/em28xx/em28xx-input.c
index 42bbaf64aceb..0443afe09ff8 100644
--- a/drivers/media/video/em28xx/em28xx-input.c
+++ b/drivers/media/video/em28xx/em28xx-input.c
@@ -307,7 +307,7 @@ static void em28xx_ir_work(struct work_struct *work)
307 mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling)); 307 mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling));
308} 308}
309 309
310void em28xx_ir_start(struct em28xx_IR *ir) 310static void em28xx_ir_start(struct em28xx_IR *ir)
311{ 311{
312 setup_timer(&ir->timer, ir_timer, (unsigned long)ir); 312 setup_timer(&ir->timer, ir_timer, (unsigned long)ir);
313 INIT_WORK(&ir->work, em28xx_ir_work); 313 INIT_WORK(&ir->work, em28xx_ir_work);
diff --git a/drivers/media/video/gspca/m5602/m5602_s5k83a.c b/drivers/media/video/gspca/m5602/m5602_s5k83a.c
index af3f2dc2c702..ccea4a758464 100644
--- a/drivers/media/video/gspca/m5602/m5602_s5k83a.c
+++ b/drivers/media/video/gspca/m5602/m5602_s5k83a.c
@@ -113,7 +113,7 @@ int s5k83a_power_down(struct sd *sd)
113 return 0; 113 return 0;
114} 114}
115 115
116void s5k83a_dump_registers(struct sd *sd) 116static void s5k83a_dump_registers(struct sd *sd)
117{ 117{
118 int address; 118 int address;
119 u8 page, old_page; 119 u8 page, old_page;
diff --git a/drivers/media/video/ov7670.c b/drivers/media/video/ov7670.c
index ca26b0c50cf2..05c14a29375a 100644
--- a/drivers/media/video/ov7670.c
+++ b/drivers/media/video/ov7670.c
@@ -1347,7 +1347,6 @@ static struct i2c_driver ov7670_driver = {
1347 .name = "ov7670", 1347 .name = "ov7670",
1348 }, 1348 },
1349 .id = I2C_DRIVERID_OV7670, 1349 .id = I2C_DRIVERID_OV7670,
1350 .class = I2C_CLASS_CAM_DIGITAL,
1351 .attach_adapter = ov7670_attach, 1350 .attach_adapter = ov7670_attach,
1352 .detach_client = ov7670_detach, 1351 .detach_client = ov7670_detach,
1353 .command = ov7670_command, 1352 .command = ov7670_command,
diff --git a/drivers/media/video/ovcamchip/ovcamchip_core.c b/drivers/media/video/ovcamchip/ovcamchip_core.c
index 2c4acbf5a4fe..c841f4e4fbe4 100644
--- a/drivers/media/video/ovcamchip/ovcamchip_core.c
+++ b/drivers/media/video/ovcamchip/ovcamchip_core.c
@@ -405,7 +405,6 @@ static struct i2c_driver driver = {
405 .name = "ovcamchip", 405 .name = "ovcamchip",
406 }, 406 },
407 .id = I2C_DRIVERID_OVCAMCHIP, 407 .id = I2C_DRIVERID_OVCAMCHIP,
408 .class = I2C_CLASS_CAM_DIGITAL,
409 .attach_adapter = ovcamchip_attach, 408 .attach_adapter = ovcamchip_attach,
410 .detach_client = ovcamchip_detach, 409 .detach_client = ovcamchip_detach,
411 .command = ovcamchip_command, 410 .command = ovcamchip_command,
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 8fb92ac78c7b..fa304e5f252a 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -3655,7 +3655,7 @@ void pvr2_hdw_device_reset(struct pvr2_hdw *hdw)
3655 int ret; 3655 int ret;
3656 pvr2_trace(PVR2_TRACE_INIT,"Performing a device reset..."); 3656 pvr2_trace(PVR2_TRACE_INIT,"Performing a device reset...");
3657 ret = usb_lock_device_for_reset(hdw->usb_dev,NULL); 3657 ret = usb_lock_device_for_reset(hdw->usb_dev,NULL);
3658 if (ret == 1) { 3658 if (ret == 0) {
3659 ret = usb_reset_device(hdw->usb_dev); 3659 ret = usb_reset_device(hdw->usb_dev);
3660 usb_unlock_device(hdw->usb_dev); 3660 usb_unlock_device(hdw->usb_dev);
3661 } else { 3661 } else {
diff --git a/drivers/media/video/pxa_camera.c b/drivers/media/video/pxa_camera.c
index 9d33de22cc48..a1d6008efcbb 100644
--- a/drivers/media/video/pxa_camera.c
+++ b/drivers/media/video/pxa_camera.c
@@ -34,12 +34,10 @@
34 34
35#include <linux/videodev2.h> 35#include <linux/videodev2.h>
36 36
37#include <asm/dma.h> 37#include <mach/dma.h>
38#include <mach/pxa-regs.h> 38#include <mach/pxa-regs.h>
39#include <mach/camera.h> 39#include <mach/camera.h>
40 40
41#include "pxa_camera.h"
42
43#define PXA_CAM_VERSION_CODE KERNEL_VERSION(0, 0, 5) 41#define PXA_CAM_VERSION_CODE KERNEL_VERSION(0, 0, 5)
44#define PXA_CAM_DRV_NAME "pxa27x-camera" 42#define PXA_CAM_DRV_NAME "pxa27x-camera"
45 43
diff --git a/drivers/media/video/pxa_camera.h b/drivers/media/video/pxa_camera.h
deleted file mode 100644
index 89cbfc9a35c5..000000000000
--- a/drivers/media/video/pxa_camera.h
+++ /dev/null
@@ -1,95 +0,0 @@
1/* Camera Interface */
2#define CICR0 __REG(0x50000000)
3#define CICR1 __REG(0x50000004)
4#define CICR2 __REG(0x50000008)
5#define CICR3 __REG(0x5000000C)
6#define CICR4 __REG(0x50000010)
7#define CISR __REG(0x50000014)
8#define CIFR __REG(0x50000018)
9#define CITOR __REG(0x5000001C)
10#define CIBR0 __REG(0x50000028)
11#define CIBR1 __REG(0x50000030)
12#define CIBR2 __REG(0x50000038)
13
14#define CICR0_DMAEN (1 << 31) /* DMA request enable */
15#define CICR0_PAR_EN (1 << 30) /* Parity enable */
16#define CICR0_SL_CAP_EN (1 << 29) /* Capture enable for slave mode */
17#define CICR0_ENB (1 << 28) /* Camera interface enable */
18#define CICR0_DIS (1 << 27) /* Camera interface disable */
19#define CICR0_SIM (0x7 << 24) /* Sensor interface mode mask */
20#define CICR0_TOM (1 << 9) /* Time-out mask */
21#define CICR0_RDAVM (1 << 8) /* Receive-data-available mask */
22#define CICR0_FEM (1 << 7) /* FIFO-empty mask */
23#define CICR0_EOLM (1 << 6) /* End-of-line mask */
24#define CICR0_PERRM (1 << 5) /* Parity-error mask */
25#define CICR0_QDM (1 << 4) /* Quick-disable mask */
26#define CICR0_CDM (1 << 3) /* Disable-done mask */
27#define CICR0_SOFM (1 << 2) /* Start-of-frame mask */
28#define CICR0_EOFM (1 << 1) /* End-of-frame mask */
29#define CICR0_FOM (1 << 0) /* FIFO-overrun mask */
30
31#define CICR1_TBIT (1 << 31) /* Transparency bit */
32#define CICR1_RGBT_CONV (0x3 << 29) /* RGBT conversion mask */
33#define CICR1_PPL (0x7ff << 15) /* Pixels per line mask */
34#define CICR1_RGB_CONV (0x7 << 12) /* RGB conversion mask */
35#define CICR1_RGB_F (1 << 11) /* RGB format */
36#define CICR1_YCBCR_F (1 << 10) /* YCbCr format */
37#define CICR1_RGB_BPP (0x7 << 7) /* RGB bis per pixel mask */
38#define CICR1_RAW_BPP (0x3 << 5) /* Raw bis per pixel mask */
39#define CICR1_COLOR_SP (0x3 << 3) /* Color space mask */
40#define CICR1_DW (0x7 << 0) /* Data width mask */
41
42#define CICR2_BLW (0xff << 24) /* Beginning-of-line pixel clock
43 wait count mask */
44#define CICR2_ELW (0xff << 16) /* End-of-line pixel clock
45 wait count mask */
46#define CICR2_HSW (0x3f << 10) /* Horizontal sync pulse width mask */
47#define CICR2_BFPW (0x3f << 3) /* Beginning-of-frame pixel clock
48 wait count mask */
49#define CICR2_FSW (0x7 << 0) /* Frame stabilization
50 wait count mask */
51
52#define CICR3_BFW (0xff << 24) /* Beginning-of-frame line clock
53 wait count mask */
54#define CICR3_EFW (0xff << 16) /* End-of-frame line clock
55 wait count mask */
56#define CICR3_VSW (0x3f << 10) /* Vertical sync pulse width mask */
57#define CICR3_BFPW (0x3f << 3) /* Beginning-of-frame pixel clock
58 wait count mask */
59#define CICR3_LPF (0x7ff << 0) /* Lines per frame mask */
60
61#define CICR4_MCLK_DLY (0x3 << 24) /* MCLK Data Capture Delay mask */
62#define CICR4_PCLK_EN (1 << 23) /* Pixel clock enable */
63#define CICR4_PCP (1 << 22) /* Pixel clock polarity */
64#define CICR4_HSP (1 << 21) /* Horizontal sync polarity */
65#define CICR4_VSP (1 << 20) /* Vertical sync polarity */
66#define CICR4_MCLK_EN (1 << 19) /* MCLK enable */
67#define CICR4_FR_RATE (0x7 << 8) /* Frame rate mask */
68#define CICR4_DIV (0xff << 0) /* Clock divisor mask */
69
70#define CISR_FTO (1 << 15) /* FIFO time-out */
71#define CISR_RDAV_2 (1 << 14) /* Channel 2 receive data available */
72#define CISR_RDAV_1 (1 << 13) /* Channel 1 receive data available */
73#define CISR_RDAV_0 (1 << 12) /* Channel 0 receive data available */
74#define CISR_FEMPTY_2 (1 << 11) /* Channel 2 FIFO empty */
75#define CISR_FEMPTY_1 (1 << 10) /* Channel 1 FIFO empty */
76#define CISR_FEMPTY_0 (1 << 9) /* Channel 0 FIFO empty */
77#define CISR_EOL (1 << 8) /* End of line */
78#define CISR_PAR_ERR (1 << 7) /* Parity error */
79#define CISR_CQD (1 << 6) /* Camera interface quick disable */
80#define CISR_CDD (1 << 5) /* Camera interface disable done */
81#define CISR_SOF (1 << 4) /* Start of frame */
82#define CISR_EOF (1 << 3) /* End of frame */
83#define CISR_IFO_2 (1 << 2) /* FIFO overrun for Channel 2 */
84#define CISR_IFO_1 (1 << 1) /* FIFO overrun for Channel 1 */
85#define CISR_IFO_0 (1 << 0) /* FIFO overrun for Channel 0 */
86
87#define CIFR_FLVL2 (0x7f << 23) /* FIFO 2 level mask */
88#define CIFR_FLVL1 (0x7f << 16) /* FIFO 1 level mask */
89#define CIFR_FLVL0 (0xff << 8) /* FIFO 0 level mask */
90#define CIFR_THL_0 (0x3 << 4) /* Threshold Level for Channel 0 FIFO */
91#define CIFR_RESET_F (1 << 3) /* Reset input FIFOs */
92#define CIFR_FEN2 (1 << 2) /* FIFO enable for channel 2 */
93#define CIFR_FEN1 (1 << 1) /* FIFO enable for channel 1 */
94#define CIFR_FEN0 (1 << 0) /* FIFO enable for channel 0 */
95
diff --git a/drivers/media/video/usbvideo/ibmcam.c b/drivers/media/video/usbvideo/ibmcam.c
index f8d85ddb4804..b08549661781 100644
--- a/drivers/media/video/usbvideo/ibmcam.c
+++ b/drivers/media/video/usbvideo/ibmcam.c
@@ -3779,7 +3779,7 @@ static int ibmcam_probe(struct usb_interface *intf, const struct usb_device_id *
3779 err("Alternate settings have different endpoint addresses!"); 3779 err("Alternate settings have different endpoint addresses!");
3780 return -ENODEV; 3780 return -ENODEV;
3781 } 3781 }
3782 if (usb_endpoint_type(endpoint) != USB_ENDPOINT_XFER_ISOC) { 3782 if (!usb_endpoint_xfer_isoc(endpoint)) {
3783 err("Interface %d. has non-ISO endpoint!", ifnum); 3783 err("Interface %d. has non-ISO endpoint!", ifnum);
3784 return -ENODEV; 3784 return -ENODEV;
3785 } 3785 }
diff --git a/drivers/media/video/usbvideo/konicawc.c b/drivers/media/video/usbvideo/konicawc.c
index 90f0ce6a26bc..900ec2129ca1 100644
--- a/drivers/media/video/usbvideo/konicawc.c
+++ b/drivers/media/video/usbvideo/konicawc.c
@@ -823,7 +823,7 @@ static int konicawc_probe(struct usb_interface *intf, const struct usb_device_id
823 err("Alternate settings have different endpoint addresses!"); 823 err("Alternate settings have different endpoint addresses!");
824 return -ENODEV; 824 return -ENODEV;
825 } 825 }
826 if (usb_endpoint_type(endpoint) != USB_ENDPOINT_XFER_ISOC) { 826 if (!usb_endpoint_xfer_isoc(endpoint)) {
827 err("Interface %d. has non-ISO endpoint!", 827 err("Interface %d. has non-ISO endpoint!",
828 interface->desc.bInterfaceNumber); 828 interface->desc.bInterfaceNumber);
829 return -ENODEV; 829 return -ENODEV;
diff --git a/drivers/media/video/usbvideo/ultracam.c b/drivers/media/video/usbvideo/ultracam.c
index 839a08240c25..fbd1b6392290 100644
--- a/drivers/media/video/usbvideo/ultracam.c
+++ b/drivers/media/video/usbvideo/ultracam.c
@@ -556,7 +556,7 @@ static int ultracam_probe(struct usb_interface *intf, const struct usb_device_id
556 err("Alternate settings have different endpoint addresses!"); 556 err("Alternate settings have different endpoint addresses!");
557 return -ENODEV; 557 return -ENODEV;
558 } 558 }
559 if (usb_endpoint_type(endpoint) != USB_ENDPOINT_XFER_ISOC) { 559 if (!usb_endpoint_xfer_isoc(endpoint)) {
560 err("Interface %d. has non-ISO endpoint!", 560 err("Interface %d. has non-ISO endpoint!",
561 interface->desc.bInterfaceNumber); 561 interface->desc.bInterfaceNumber);
562 return -ENODEV; 562 return -ENODEV;
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index 2be5e47ed081..2622de003a45 100644
--- a/drivers/media/video/usbvision/usbvision-video.c
+++ b/drivers/media/video/usbvision/usbvision-video.c
@@ -1674,8 +1674,7 @@ static int __devinit usbvision_probe(struct usb_interface *intf,
1674 interface = &dev->actconfig->interface[ifnum]->altsetting[0]; 1674 interface = &dev->actconfig->interface[ifnum]->altsetting[0];
1675 } 1675 }
1676 endpoint = &interface->endpoint[1].desc; 1676 endpoint = &interface->endpoint[1].desc;
1677 if (usb_endpoint_type(endpoint) != 1677 if (!usb_endpoint_xfer_isoc(endpoint)) {
1678 USB_ENDPOINT_XFER_ISOC) {
1679 err("%s: interface %d. has non-ISO endpoint!", 1678 err("%s: interface %d. has non-ISO endpoint!",
1680 __func__, ifnum); 1679 __func__, ifnum);
1681 err("%s: Endpoint attributes %d", 1680 err("%s: Endpoint attributes %d",
diff --git a/drivers/media/video/v4l2-device.c b/drivers/media/video/v4l2-device.c
index 9eefde031597..cf9d4c7f571a 100644
--- a/drivers/media/video/v4l2-device.c
+++ b/drivers/media/video/v4l2-device.c
@@ -29,7 +29,7 @@ int v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev)
29 if (dev == NULL || v4l2_dev == NULL) 29 if (dev == NULL || v4l2_dev == NULL)
30 return -EINVAL; 30 return -EINVAL;
31 /* Warn if we apparently re-register a device */ 31 /* Warn if we apparently re-register a device */
32 WARN_ON(dev_get_drvdata(dev)); 32 WARN_ON(dev_get_drvdata(dev) != NULL);
33 INIT_LIST_HEAD(&v4l2_dev->subdevs); 33 INIT_LIST_HEAD(&v4l2_dev->subdevs);
34 spin_lock_init(&v4l2_dev->lock); 34 spin_lock_init(&v4l2_dev->lock);
35 v4l2_dev->dev = dev; 35 v4l2_dev->dev = dev;
@@ -61,7 +61,7 @@ int v4l2_device_register_subdev(struct v4l2_device *dev, struct v4l2_subdev *sd)
61 if (dev == NULL || sd == NULL || !sd->name[0]) 61 if (dev == NULL || sd == NULL || !sd->name[0])
62 return -EINVAL; 62 return -EINVAL;
63 /* Warn if we apparently re-register a subdev */ 63 /* Warn if we apparently re-register a subdev */
64 WARN_ON(sd->dev); 64 WARN_ON(sd->dev != NULL);
65 if (!try_module_get(sd->owner)) 65 if (!try_module_get(sd->owner))
66 return -ENODEV; 66 return -ENODEV;
67 sd->dev = dev; 67 sd->dev = dev;
diff --git a/drivers/media/video/videobuf-dma-sg.c b/drivers/media/video/videobuf-dma-sg.c
index bc6d5aba0fe6..da1790e57a86 100644
--- a/drivers/media/video/videobuf-dma-sg.c
+++ b/drivers/media/video/videobuf-dma-sg.c
@@ -388,8 +388,7 @@ videobuf_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
388 page = alloc_page(GFP_USER | __GFP_DMA32); 388 page = alloc_page(GFP_USER | __GFP_DMA32);
389 if (!page) 389 if (!page)
390 return VM_FAULT_OOM; 390 return VM_FAULT_OOM;
391 clear_user_page(page_address(page), (unsigned long)vmf->virtual_address, 391 clear_user_highpage(page, (unsigned long)vmf->virtual_address);
392 page);
393 vmf->page = page; 392 vmf->page = page;
394 return 0; 393 return 0;
395} 394}
diff --git a/drivers/media/video/w9968cf.c b/drivers/media/video/w9968cf.c
index a3997b7d4366..105a832531f2 100644
--- a/drivers/media/video/w9968cf.c
+++ b/drivers/media/video/w9968cf.c
@@ -1553,7 +1553,6 @@ static int w9968cf_i2c_init(struct w9968cf_device* cam)
1553 1553
1554 static struct i2c_adapter adap = { 1554 static struct i2c_adapter adap = {
1555 .id = I2C_HW_SMBUS_W9968CF, 1555 .id = I2C_HW_SMBUS_W9968CF,
1556 .class = I2C_CLASS_CAM_DIGITAL,
1557 .owner = THIS_MODULE, 1556 .owner = THIS_MODULE,
1558 .client_register = w9968cf_i2c_attach_inform, 1557 .client_register = w9968cf_i2c_attach_inform,
1559 .client_unregister = w9968cf_i2c_detach_inform, 1558 .client_unregister = w9968cf_i2c_detach_inform,
diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c
index 1f1e3982b1aa..de143deb06f0 100644
--- a/drivers/memstick/core/mspro_block.c
+++ b/drivers/memstick/core/mspro_block.c
@@ -52,14 +52,14 @@ struct mspro_sys_attr {
52}; 52};
53 53
54struct mspro_attr_entry { 54struct mspro_attr_entry {
55 unsigned int address; 55 __be32 address;
56 unsigned int size; 56 __be32 size;
57 unsigned char id; 57 unsigned char id;
58 unsigned char reserved[3]; 58 unsigned char reserved[3];
59} __attribute__((packed)); 59} __attribute__((packed));
60 60
61struct mspro_attribute { 61struct mspro_attribute {
62 unsigned short signature; 62 __be16 signature;
63 unsigned short version; 63 unsigned short version;
64 unsigned char count; 64 unsigned char count;
65 unsigned char reserved[11]; 65 unsigned char reserved[11];
@@ -69,28 +69,28 @@ struct mspro_attribute {
69struct mspro_sys_info { 69struct mspro_sys_info {
70 unsigned char class; 70 unsigned char class;
71 unsigned char reserved0; 71 unsigned char reserved0;
72 unsigned short block_size; 72 __be16 block_size;
73 unsigned short block_count; 73 __be16 block_count;
74 unsigned short user_block_count; 74 __be16 user_block_count;
75 unsigned short page_size; 75 __be16 page_size;
76 unsigned char reserved1[2]; 76 unsigned char reserved1[2];
77 unsigned char assembly_date[8]; 77 unsigned char assembly_date[8];
78 unsigned int serial_number; 78 __be32 serial_number;
79 unsigned char assembly_maker_code; 79 unsigned char assembly_maker_code;
80 unsigned char assembly_model_code[3]; 80 unsigned char assembly_model_code[3];
81 unsigned short memory_maker_code; 81 __be16 memory_maker_code;
82 unsigned short memory_model_code; 82 __be16 memory_model_code;
83 unsigned char reserved2[4]; 83 unsigned char reserved2[4];
84 unsigned char vcc; 84 unsigned char vcc;
85 unsigned char vpp; 85 unsigned char vpp;
86 unsigned short controller_number; 86 __be16 controller_number;
87 unsigned short controller_function; 87 __be16 controller_function;
88 unsigned short start_sector; 88 __be16 start_sector;
89 unsigned short unit_size; 89 __be16 unit_size;
90 unsigned char ms_sub_class; 90 unsigned char ms_sub_class;
91 unsigned char reserved3[4]; 91 unsigned char reserved3[4];
92 unsigned char interface_type; 92 unsigned char interface_type;
93 unsigned short controller_code; 93 __be16 controller_code;
94 unsigned char format_type; 94 unsigned char format_type;
95 unsigned char reserved4; 95 unsigned char reserved4;
96 unsigned char device_type; 96 unsigned char device_type;
@@ -124,11 +124,11 @@ struct mspro_specfile {
124} __attribute__((packed)); 124} __attribute__((packed));
125 125
126struct mspro_devinfo { 126struct mspro_devinfo {
127 unsigned short cylinders; 127 __be16 cylinders;
128 unsigned short heads; 128 __be16 heads;
129 unsigned short bytes_per_track; 129 __be16 bytes_per_track;
130 unsigned short bytes_per_sector; 130 __be16 bytes_per_sector;
131 unsigned short sectors_per_track; 131 __be16 sectors_per_track;
132 unsigned char reserved[6]; 132 unsigned char reserved[6];
133} __attribute__((packed)); 133} __attribute__((packed));
134 134
@@ -338,8 +338,7 @@ static ssize_t mspro_block_attr_show_sysinfo(struct device *dev,
338 rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "assembly date: " 338 rc += scnprintf(buffer + rc, PAGE_SIZE - rc, "assembly date: "
339 "GMT%+d:%d %04u-%02u-%02u %02u:%02u:%02u\n", 339 "GMT%+d:%d %04u-%02u-%02u %02u:%02u:%02u\n",
340 date_tz, date_tz_f, 340 date_tz, date_tz_f,
341 be16_to_cpu(*(unsigned short *) 341 be16_to_cpup((__be16 *)&x_sys->assembly_date[1]),
342 &x_sys->assembly_date[1]),
343 x_sys->assembly_date[3], x_sys->assembly_date[4], 342 x_sys->assembly_date[3], x_sys->assembly_date[4],
344 x_sys->assembly_date[5], x_sys->assembly_date[6], 343 x_sys->assembly_date[5], x_sys->assembly_date[6],
345 x_sys->assembly_date[7]); 344 x_sys->assembly_date[7]);
diff --git a/drivers/message/fusion/lsi/mpi.h b/drivers/message/fusion/lsi/mpi.h
index 10b6ef758725..11c0f461320e 100644
--- a/drivers/message/fusion/lsi/mpi.h
+++ b/drivers/message/fusion/lsi/mpi.h
@@ -6,7 +6,7 @@
6 * Title: MPI Message independent structures and definitions 6 * Title: MPI Message independent structures and definitions
7 * Creation Date: July 27, 2000 7 * Creation Date: July 27, 2000
8 * 8 *
9 * mpi.h Version: 01.05.13 9 * mpi.h Version: 01.05.16
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -79,6 +79,9 @@
79 * 03-27-06 01.05.11 Bumped MPI_HEADER_VERSION_UNIT. 79 * 03-27-06 01.05.11 Bumped MPI_HEADER_VERSION_UNIT.
80 * 10-11-06 01.05.12 Bumped MPI_HEADER_VERSION_UNIT. 80 * 10-11-06 01.05.12 Bumped MPI_HEADER_VERSION_UNIT.
81 * 05-24-07 01.05.13 Bumped MPI_HEADER_VERSION_UNIT. 81 * 05-24-07 01.05.13 Bumped MPI_HEADER_VERSION_UNIT.
82 * 08-07-07 01.05.14 Bumped MPI_HEADER_VERSION_UNIT.
83 * 01-15-08 01.05.15 Bumped MPI_HEADER_VERSION_UNIT.
84 * 03-28-08 01.05.16 Bumped MPI_HEADER_VERSION_UNIT.
82 * -------------------------------------------------------------------------- 85 * --------------------------------------------------------------------------
83 */ 86 */
84 87
@@ -109,7 +112,7 @@
109/* Note: The major versions of 0xe0 through 0xff are reserved */ 112/* Note: The major versions of 0xe0 through 0xff are reserved */
110 113
111/* versioning for this MPI header set */ 114/* versioning for this MPI header set */
112#define MPI_HEADER_VERSION_UNIT (0x10) 115#define MPI_HEADER_VERSION_UNIT (0x13)
113#define MPI_HEADER_VERSION_DEV (0x00) 116#define MPI_HEADER_VERSION_DEV (0x00)
114#define MPI_HEADER_VERSION_UNIT_MASK (0xFF00) 117#define MPI_HEADER_VERSION_UNIT_MASK (0xFF00)
115#define MPI_HEADER_VERSION_UNIT_SHIFT (8) 118#define MPI_HEADER_VERSION_UNIT_SHIFT (8)
diff --git a/drivers/message/fusion/lsi/mpi_cnfg.h b/drivers/message/fusion/lsi/mpi_cnfg.h
index b2db3330c591..013c7d881948 100644
--- a/drivers/message/fusion/lsi/mpi_cnfg.h
+++ b/drivers/message/fusion/lsi/mpi_cnfg.h
@@ -6,7 +6,7 @@
6 * Title: MPI Config message, structures, and Pages 6 * Title: MPI Config message, structures, and Pages
7 * Creation Date: July 27, 2000 7 * Creation Date: July 27, 2000
8 * 8 *
9 * mpi_cnfg.h Version: 01.05.15 9 * mpi_cnfg.h Version: 01.05.18
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -308,6 +308,20 @@
308 * Expander Page 0 Flags field. 308 * Expander Page 0 Flags field.
309 * Fixed define for 309 * Fixed define for
310 * MPI_SAS_EXPANDER1_DISCINFO_BAD_PHY_DISABLED. 310 * MPI_SAS_EXPANDER1_DISCINFO_BAD_PHY_DISABLED.
311 * 08-07-07 01.05.16 Added MPI_IOCPAGE6_CAP_FLAGS_MULTIPORT_DRIVE_SUPPORT
312 * define.
313 * Added BIOS Page 4 structure.
314 * Added MPI_RAID_PHYS_DISK1_PATH_MAX define for RAID
315 * Physcial Disk Page 1.
316 * 01-15-07 01.05.17 Added additional bit defines for ExtFlags field of
317 * Manufacturing Page 4.
318 * Added Solid State Drives Supported bit to IOC Page 6
319 * Capabilities Flags.
320 * Added new value for AccessStatus field of SAS Device
321 * Page 0 (_SATA_NEEDS_INITIALIZATION).
322 * 03-28-08 01.05.18 Defined new bits in Manufacturing Page 4 ExtFlags field
323 * to control coercion size and the mixing of SAS and SATA
324 * SSD drives.
311 * -------------------------------------------------------------------------- 325 * --------------------------------------------------------------------------
312 */ 326 */
313 327
@@ -686,6 +700,14 @@ typedef struct _CONFIG_PAGE_MANUFACTURING_4
686#define MPI_MANPAGE4_IR_NO_MIX_SAS_SATA (0x01) 700#define MPI_MANPAGE4_IR_NO_MIX_SAS_SATA (0x01)
687 701
688/* defines for the ExtFlags field */ 702/* defines for the ExtFlags field */
703#define MPI_MANPAGE4_EXTFLAGS_MASK_COERCION_SIZE (0x0180)
704#define MPI_MANPAGE4_EXTFLAGS_SHIFT_COERCION_SIZE (7)
705#define MPI_MANPAGE4_EXTFLAGS_1GB_COERCION_SIZE (0)
706#define MPI_MANPAGE4_EXTFLAGS_128MB_COERCION_SIZE (1)
707
708#define MPI_MANPAGE4_EXTFLAGS_NO_MIX_SSD_SAS_SATA (0x0040)
709#define MPI_MANPAGE4_EXTFLAGS_MIX_SSD_AND_NON_SSD (0x0020)
710#define MPI_MANPAGE4_EXTFLAGS_DUAL_PORT_SUPPORT (0x0010)
689#define MPI_MANPAGE4_EXTFLAGS_HIDE_NON_IR_METADATA (0x0008) 711#define MPI_MANPAGE4_EXTFLAGS_HIDE_NON_IR_METADATA (0x0008)
690#define MPI_MANPAGE4_EXTFLAGS_SAS_CACHE_DISABLE (0x0004) 712#define MPI_MANPAGE4_EXTFLAGS_SAS_CACHE_DISABLE (0x0004)
691#define MPI_MANPAGE4_EXTFLAGS_SATA_CACHE_DISABLE (0x0002) 713#define MPI_MANPAGE4_EXTFLAGS_SATA_CACHE_DISABLE (0x0002)
@@ -1159,6 +1181,8 @@ typedef struct _CONFIG_PAGE_IOC_6
1159 1181
1160/* IOC Page 6 Capabilities Flags */ 1182/* IOC Page 6 Capabilities Flags */
1161 1183
1184#define MPI_IOCPAGE6_CAP_FLAGS_SSD_SUPPORT (0x00000020)
1185#define MPI_IOCPAGE6_CAP_FLAGS_MULTIPORT_DRIVE_SUPPORT (0x00000010)
1162#define MPI_IOCPAGE6_CAP_FLAGS_DISABLE_SMART_POLLING (0x00000008) 1186#define MPI_IOCPAGE6_CAP_FLAGS_DISABLE_SMART_POLLING (0x00000008)
1163 1187
1164#define MPI_IOCPAGE6_CAP_FLAGS_MASK_METADATA_SIZE (0x00000006) 1188#define MPI_IOCPAGE6_CAP_FLAGS_MASK_METADATA_SIZE (0x00000006)
@@ -1428,6 +1452,15 @@ typedef struct _CONFIG_PAGE_BIOS_2
1428#define MPI_BIOSPAGE2_FORM_SAS_WWN (0x05) 1452#define MPI_BIOSPAGE2_FORM_SAS_WWN (0x05)
1429#define MPI_BIOSPAGE2_FORM_ENCLOSURE_SLOT (0x06) 1453#define MPI_BIOSPAGE2_FORM_ENCLOSURE_SLOT (0x06)
1430 1454
1455typedef struct _CONFIG_PAGE_BIOS_4
1456{
1457 CONFIG_PAGE_HEADER Header; /* 00h */
1458 U64 ReassignmentBaseWWID; /* 04h */
1459} CONFIG_PAGE_BIOS_4, MPI_POINTER PTR_CONFIG_PAGE_BIOS_4,
1460 BIOSPage4_t, MPI_POINTER pBIOSPage4_t;
1461
1462#define MPI_BIOSPAGE4_PAGEVERSION (0x00)
1463
1431 1464
1432/**************************************************************************** 1465/****************************************************************************
1433* SCSI Port Config Pages 1466* SCSI Port Config Pages
@@ -2419,6 +2452,15 @@ typedef struct _RAID_PHYS_DISK1_PATH
2419#define MPI_RAID_PHYSDISK1_FLAG_BROKEN (0x0002) 2452#define MPI_RAID_PHYSDISK1_FLAG_BROKEN (0x0002)
2420#define MPI_RAID_PHYSDISK1_FLAG_INVALID (0x0001) 2453#define MPI_RAID_PHYSDISK1_FLAG_INVALID (0x0001)
2421 2454
2455
2456/*
2457 * Host code (drivers, BIOS, utilities, etc.) should leave this define set to
2458 * one and check Header.PageLength or NumPhysDiskPaths at runtime.
2459 */
2460#ifndef MPI_RAID_PHYS_DISK1_PATH_MAX
2461#define MPI_RAID_PHYS_DISK1_PATH_MAX (1)
2462#endif
2463
2422typedef struct _CONFIG_PAGE_RAID_PHYS_DISK_1 2464typedef struct _CONFIG_PAGE_RAID_PHYS_DISK_1
2423{ 2465{
2424 CONFIG_PAGE_HEADER Header; /* 00h */ 2466 CONFIG_PAGE_HEADER Header; /* 00h */
@@ -2426,7 +2468,7 @@ typedef struct _CONFIG_PAGE_RAID_PHYS_DISK_1
2426 U8 PhysDiskNum; /* 05h */ 2468 U8 PhysDiskNum; /* 05h */
2427 U16 Reserved2; /* 06h */ 2469 U16 Reserved2; /* 06h */
2428 U32 Reserved1; /* 08h */ 2470 U32 Reserved1; /* 08h */
2429 RAID_PHYS_DISK1_PATH Path[1]; /* 0Ch */ 2471 RAID_PHYS_DISK1_PATH Path[MPI_RAID_PHYS_DISK1_PATH_MAX];/* 0Ch */
2430} CONFIG_PAGE_RAID_PHYS_DISK_1, MPI_POINTER PTR_CONFIG_PAGE_RAID_PHYS_DISK_1, 2472} CONFIG_PAGE_RAID_PHYS_DISK_1, MPI_POINTER PTR_CONFIG_PAGE_RAID_PHYS_DISK_1,
2431 RaidPhysDiskPage1_t, MPI_POINTER pRaidPhysDiskPage1_t; 2473 RaidPhysDiskPage1_t, MPI_POINTER pRaidPhysDiskPage1_t;
2432 2474
@@ -2844,6 +2886,7 @@ typedef struct _CONFIG_PAGE_SAS_DEVICE_0
2844#define MPI_SAS_DEVICE0_ASTATUS_SATA_INIT_FAILED (0x01) 2886#define MPI_SAS_DEVICE0_ASTATUS_SATA_INIT_FAILED (0x01)
2845#define MPI_SAS_DEVICE0_ASTATUS_SATA_CAPABILITY_FAILED (0x02) 2887#define MPI_SAS_DEVICE0_ASTATUS_SATA_CAPABILITY_FAILED (0x02)
2846#define MPI_SAS_DEVICE0_ASTATUS_SATA_AFFILIATION_CONFLICT (0x03) 2888#define MPI_SAS_DEVICE0_ASTATUS_SATA_AFFILIATION_CONFLICT (0x03)
2889#define MPI_SAS_DEVICE0_ASTATUS_SATA_NEEDS_INITIALIZATION (0x04)
2847/* specific values for SATA Init failures */ 2890/* specific values for SATA Init failures */
2848#define MPI_SAS_DEVICE0_ASTATUS_SIF_UNKNOWN (0x10) 2891#define MPI_SAS_DEVICE0_ASTATUS_SIF_UNKNOWN (0x10)
2849#define MPI_SAS_DEVICE0_ASTATUS_SIF_AFFILIATION_CONFLICT (0x11) 2892#define MPI_SAS_DEVICE0_ASTATUS_SIF_AFFILIATION_CONFLICT (0x11)
diff --git a/drivers/message/fusion/lsi/mpi_fc.h b/drivers/message/fusion/lsi/mpi_fc.h
index 627acfbb8623..7d663ce76f8c 100644
--- a/drivers/message/fusion/lsi/mpi_fc.h
+++ b/drivers/message/fusion/lsi/mpi_fc.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2000-2004 LSI Corporation. 2 * Copyright (c) 2000-2008 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi_fc.h 5 * Name: mpi_fc.h
diff --git a/drivers/message/fusion/lsi/mpi_history.txt b/drivers/message/fusion/lsi/mpi_history.txt
index 3f15fcfe4a2e..693e4b511354 100644
--- a/drivers/message/fusion/lsi/mpi_history.txt
+++ b/drivers/message/fusion/lsi/mpi_history.txt
@@ -3,28 +3,28 @@
3 MPI Header File Change History 3 MPI Header File Change History
4 ============================== 4 ==============================
5 5
6 Copyright (c) 2000-2007 LSI Corporation. 6 Copyright (c) 2000-2008 LSI Corporation.
7 7
8 --------------------------------------- 8 ---------------------------------------
9 Header Set Release Version: 01.05.16 9 Header Set Release Version: 01.05.19
10 Header Set Release Date: 05-24-07 10 Header Set Release Date: 03-28-08
11 --------------------------------------- 11 ---------------------------------------
12 12
13 Filename Current version Prior version 13 Filename Current version Prior version
14 ---------- --------------- ------------- 14 ---------- --------------- -------------
15 mpi.h 01.05.13 01.05.12 15 mpi.h 01.05.16 01.05.15
16 mpi_ioc.h 01.05.14 01.05.13 16 mpi_ioc.h 01.05.16 01.05.15
17 mpi_cnfg.h 01.05.15 01.05.14 17 mpi_cnfg.h 01.05.18 01.05.17
18 mpi_init.h 01.05.09 01.05.09 18 mpi_init.h 01.05.09 01.05.09
19 mpi_targ.h 01.05.06 01.05.06 19 mpi_targ.h 01.05.06 01.05.06
20 mpi_fc.h 01.05.01 01.05.01 20 mpi_fc.h 01.05.01 01.05.01
21 mpi_lan.h 01.05.01 01.05.01 21 mpi_lan.h 01.05.01 01.05.01
22 mpi_raid.h 01.05.03 01.05.03 22 mpi_raid.h 01.05.05 01.05.05
23 mpi_tool.h 01.05.03 01.05.03 23 mpi_tool.h 01.05.03 01.05.03
24 mpi_inb.h 01.05.01 01.05.01 24 mpi_inb.h 01.05.01 01.05.01
25 mpi_sas.h 01.05.04 01.05.04 25 mpi_sas.h 01.05.05 01.05.05
26 mpi_type.h 01.05.02 01.05.02 26 mpi_type.h 01.05.02 01.05.02
27 mpi_history.txt 01.05.14 01.05.14 27 mpi_history.txt 01.05.19 01.05.18
28 28
29 29
30 * Date Version Description 30 * Date Version Description
@@ -96,6 +96,9 @@ mpi.h
96 * 03-27-06 01.05.11 Bumped MPI_HEADER_VERSION_UNIT. 96 * 03-27-06 01.05.11 Bumped MPI_HEADER_VERSION_UNIT.
97 * 10-11-06 01.05.12 Bumped MPI_HEADER_VERSION_UNIT. 97 * 10-11-06 01.05.12 Bumped MPI_HEADER_VERSION_UNIT.
98 * 05-24-07 01.05.13 Bumped MPI_HEADER_VERSION_UNIT. 98 * 05-24-07 01.05.13 Bumped MPI_HEADER_VERSION_UNIT.
99 * 08-07-07 01.05.14 Bumped MPI_HEADER_VERSION_UNIT.
100 * 01-15-08 01.05.15 Bumped MPI_HEADER_VERSION_UNIT.
101 * 03-28-08 01.05.16 Bumped MPI_HEADER_VERSION_UNIT.
99 * -------------------------------------------------------------------------- 102 * --------------------------------------------------------------------------
100 103
101mpi_ioc.h 104mpi_ioc.h
@@ -127,7 +130,7 @@ mpi_ioc.h
127 * 08-08-01 01.02.01 Original release for v1.2 work. 130 * 08-08-01 01.02.01 Original release for v1.2 work.
128 * New format for FWVersion and ProductId in 131 * New format for FWVersion and ProductId in
129 * MSG_IOC_FACTS_REPLY and MPI_FW_HEADER. 132 * MSG_IOC_FACTS_REPLY and MPI_FW_HEADER.
130 * 08-31-01 01.02.02 Added event MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE and 133 * 08-31-01 01.02.02 Addded event MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE and
131 * related structure and defines. 134 * related structure and defines.
132 * Added event MPI_EVENT_ON_BUS_TIMER_EXPIRED. 135 * Added event MPI_EVENT_ON_BUS_TIMER_EXPIRED.
133 * Added MPI_IOCINIT_FLAGS_DISCARD_FW_IMAGE. 136 * Added MPI_IOCINIT_FLAGS_DISCARD_FW_IMAGE.
@@ -187,7 +190,7 @@ mpi_ioc.h
187 * 10-11-06 01.05.12 Added MPI_IOCFACTS_EXCEPT_METADATA_UNSUPPORTED. 190 * 10-11-06 01.05.12 Added MPI_IOCFACTS_EXCEPT_METADATA_UNSUPPORTED.
188 * Added MaxInitiators field to PortFacts reply. 191 * Added MaxInitiators field to PortFacts reply.
189 * Added SAS Device Status Change ReasonCode for 192 * Added SAS Device Status Change ReasonCode for
190 * asynchronous notification. 193 * asynchronous notificaiton.
191 * Added MPI_EVENT_SAS_EXPANDER_STATUS_CHANGE and event 194 * Added MPI_EVENT_SAS_EXPANDER_STATUS_CHANGE and event
192 * data structure. 195 * data structure.
193 * Added new ImageType values for FWDownload and FWUpload 196 * Added new ImageType values for FWDownload and FWUpload
@@ -199,6 +202,16 @@ mpi_ioc.h
199 * added _MULTI_PORT_DOMAIN. 202 * added _MULTI_PORT_DOMAIN.
200 * 05-24-07 01.05.14 Added Common Boot Block type to FWDownload Request. 203 * 05-24-07 01.05.14 Added Common Boot Block type to FWDownload Request.
201 * Added Common Boot Block type to FWUpload Request. 204 * Added Common Boot Block type to FWUpload Request.
205 * 08-07-07 01.05.15 Added MPI_EVENT_SAS_INIT_RC_REMOVED define.
206 * Added MPI_EVENT_IR2_RC_DUAL_PORT_ADDED and
207 * MPI_EVENT_IR2_RC_DUAL_PORT_REMOVED for IR2 event data.
208 * Added SASAddress field to SAS Initiator Device Table
209 * Overflow event data structure.
210 * 03-28-08 01.05.16 Added two new ReasonCode values to SAS Device Status
211 * Change Event data to indicate completion of internally
212 * generated task management.
213 * Added MPI_EVENT_DSCVRY_ERR_DS_SATA_INIT_FAILURE define.
214 * Added MPI_EVENT_SAS_INIT_RC_INACCESSIBLE define.
202 * -------------------------------------------------------------------------- 215 * --------------------------------------------------------------------------
203 216
204mpi_cnfg.h 217mpi_cnfg.h
@@ -213,7 +226,7 @@ mpi_cnfg.h
213 * Added _RESPONSE_ID_MASK definition to SCSI_PORT_1 226 * Added _RESPONSE_ID_MASK definition to SCSI_PORT_1
214 * page and updated the page version. 227 * page and updated the page version.
215 * Added Information field and _INFO_PARAMS_NEGOTIATED 228 * Added Information field and _INFO_PARAMS_NEGOTIATED
216 * definition to SCSI_DEVICE_0 page. 229 * definitionto SCSI_DEVICE_0 page.
217 * 06-22-00 01.00.03 Removed batch controls from LAN_0 page and updated the 230 * 06-22-00 01.00.03 Removed batch controls from LAN_0 page and updated the
218 * page version. 231 * page version.
219 * Added BucketsRemaining to LAN_1 page, redefined the 232 * Added BucketsRemaining to LAN_1 page, redefined the
@@ -496,6 +509,20 @@ mpi_cnfg.h
496 * Expander Page 0 Flags field. 509 * Expander Page 0 Flags field.
497 * Fixed define for 510 * Fixed define for
498 * MPI_SAS_EXPANDER1_DISCINFO_BAD_PHY_DISABLED. 511 * MPI_SAS_EXPANDER1_DISCINFO_BAD_PHY_DISABLED.
512 * 08-07-07 01.05.16 Added MPI_IOCPAGE6_CAP_FLAGS_MULTIPORT_DRIVE_SUPPORT
513 * define.
514 * Added BIOS Page 4 structure.
515 * Added MPI_RAID_PHYS_DISK1_PATH_MAX define for RAID
516 * Physcial Disk Page 1.
517 * 01-15-07 01.05.17 Added additional bit defines for ExtFlags field of
518 * Manufacturing Page 4.
519 * Added Solid State Drives Supported bit to IOC Page 6
520 * Capabilities Flags.
521 * Added new value for AccessStatus field of SAS Device
522 * Page 0 (_SATA_NEEDS_INITIALIZATION).
523 * 03-28-08 01.05.18 Defined new bits in Manufacturing Page 4 ExtFlags field
524 * to control coercion size and the mixing of SAS and SATA
525 * SSD drives.
499 * -------------------------------------------------------------------------- 526 * --------------------------------------------------------------------------
500 527
501mpi_init.h 528mpi_init.h
@@ -661,6 +688,9 @@ mpi_raid.h
661 * _SET_RESYNC_RATE and _SET_DATA_SCRUB_RATE. 688 * _SET_RESYNC_RATE and _SET_DATA_SCRUB_RATE.
662 * 02-28-07 01.05.03 Added new RAID Action, Device FW Update Mode, and 689 * 02-28-07 01.05.03 Added new RAID Action, Device FW Update Mode, and
663 * associated defines. 690 * associated defines.
691 * 08-07-07 01.05.04 Added Disable Full Rebuild bit to the ActionDataWord
692 * for the RAID Action MPI_RAID_ACTION_DISABLE_VOLUME.
693 * 01-15-08 01.05.05 Added define for MPI_RAID_ACTION_SET_VOLUME_NAME.
664 * -------------------------------------------------------------------------- 694 * --------------------------------------------------------------------------
665 695
666mpi_tool.h 696mpi_tool.h
@@ -694,6 +724,10 @@ mpi_sas.h
694 * reply. 724 * reply.
695 * 10-11-06 01.05.04 Fixed the name of a define for Operation field of SAS IO 725 * 10-11-06 01.05.04 Fixed the name of a define for Operation field of SAS IO
696 * Unit Control request. 726 * Unit Control request.
727 * 01-15-08 01.05.05 Added support for MPI_SAS_OP_SET_IOC_PARAMETER,
728 * including adding IOCParameter and IOCParameter value
729 * fields to SAS IO Unit Control Request.
730 * Added MPI_SAS_DEVICE_INFO_PRODUCT_SPECIFIC define.
697 * -------------------------------------------------------------------------- 731 * --------------------------------------------------------------------------
698 732
699mpi_type.h 733mpi_type.h
@@ -709,20 +743,20 @@ mpi_type.h
709 743
710mpi_history.txt Parts list history 744mpi_history.txt Parts list history
711 745
712Filename 01.05.15 01.05.15 746Filename 01.05.19 01.05.18 01.05.17 01.05.16 01.05.15
713---------- -------- -------- 747---------- -------- -------- -------- -------- --------
714mpi.h 01.05.12 01.05.13 748mpi.h 01.05.16 01.05.15 01.05.14 01.05.13 01.05.12
715mpi_ioc.h 01.05.13 01.05.14 749mpi_ioc.h 01.05.16 01.05.15 01.05.15 01.05.14 01.05.13
716mpi_cnfg.h 01.05.14 01.05.15 750mpi_cnfg.h 01.05.18 01.05.17 01.05.16 01.05.15 01.05.14
717mpi_init.h 01.05.09 01.05.09 751mpi_init.h 01.05.09 01.05.09 01.05.09 01.05.09 01.05.09
718mpi_targ.h 01.05.06 01.05.06 752mpi_targ.h 01.05.06 01.05.06 01.05.06 01.05.06 01.05.06
719mpi_fc.h 01.05.01 01.05.01 753mpi_fc.h 01.05.01 01.05.01 01.05.01 01.05.01 01.05.01
720mpi_lan.h 01.05.01 01.05.01 754mpi_lan.h 01.05.01 01.05.01 01.05.01 01.05.01 01.05.01
721mpi_raid.h 01.05.03 01.05.03 755mpi_raid.h 01.05.05 01.05.05 01.05.04 01.05.03 01.05.03
722mpi_tool.h 01.05.03 01.05.03 756mpi_tool.h 01.05.03 01.05.03 01.05.03 01.05.03 01.05.03
723mpi_inb.h 01.05.01 01.05.01 757mpi_inb.h 01.05.01 01.05.01 01.05.01 01.05.01 01.05.01
724mpi_sas.h 01.05.04 01.05.04 758mpi_sas.h 01.05.05 01.05.05 01.05.04 01.05.04 01.05.04
725mpi_type.h 01.05.02 01.05.02 759mpi_type.h 01.05.02 01.05.02 01.05.02 01.05.02 01.05.02
726 760
727Filename 01.05.14 01.05.13 01.05.12 01.05.11 01.05.10 01.05.09 761Filename 01.05.14 01.05.13 01.05.12 01.05.11 01.05.10 01.05.09
728---------- -------- -------- -------- -------- -------- -------- 762---------- -------- -------- -------- -------- -------- --------
diff --git a/drivers/message/fusion/lsi/mpi_init.h b/drivers/message/fusion/lsi/mpi_init.h
index a9e3693601a7..4295d062caa7 100644
--- a/drivers/message/fusion/lsi/mpi_init.h
+++ b/drivers/message/fusion/lsi/mpi_init.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2000-2007 LSI Corporation. 2 * Copyright (c) 2000-2008 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi_init.h 5 * Name: mpi_init.h
diff --git a/drivers/message/fusion/lsi/mpi_ioc.h b/drivers/message/fusion/lsi/mpi_ioc.h
index 5cbb6bd048e1..8faa4fab7b89 100644
--- a/drivers/message/fusion/lsi/mpi_ioc.h
+++ b/drivers/message/fusion/lsi/mpi_ioc.h
@@ -1,12 +1,12 @@
1/* 1/*
2 * Copyright (c) 2000-2007 LSI Corporation. 2 * Copyright (c) 2000-2008 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi_ioc.h 5 * Name: mpi_ioc.h
6 * Title: MPI IOC, Port, Event, FW Download, and FW Upload messages 6 * Title: MPI IOC, Port, Event, FW Download, and FW Upload messages
7 * Creation Date: August 11, 2000 7 * Creation Date: August 11, 2000
8 * 8 *
9 * mpi_ioc.h Version: 01.05.14 9 * mpi_ioc.h Version: 01.05.16
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -113,6 +113,16 @@
113 * added _MULTI_PORT_DOMAIN. 113 * added _MULTI_PORT_DOMAIN.
114 * 05-24-07 01.05.14 Added Common Boot Block type to FWDownload Request. 114 * 05-24-07 01.05.14 Added Common Boot Block type to FWDownload Request.
115 * Added Common Boot Block type to FWUpload Request. 115 * Added Common Boot Block type to FWUpload Request.
116 * 08-07-07 01.05.15 Added MPI_EVENT_SAS_INIT_RC_REMOVED define.
117 * Added MPI_EVENT_IR2_RC_DUAL_PORT_ADDED and
118 * MPI_EVENT_IR2_RC_DUAL_PORT_REMOVED for IR2 event data.
119 * Added SASAddress field to SAS Initiator Device Table
120 * Overflow event data structure.
121 * 03-28-08 01.05.16 Added two new ReasonCode values to SAS Device Status
122 * Change Event data to indicate completion of internally
123 * generated task management.
124 * Added MPI_EVENT_DSCVRY_ERR_DS_SATA_INIT_FAILURE define.
125 * Added MPI_EVENT_SAS_INIT_RC_INACCESSIBLE define.
116 * -------------------------------------------------------------------------- 126 * --------------------------------------------------------------------------
117 */ 127 */
118 128
@@ -612,6 +622,8 @@ typedef struct _EVENT_DATA_SAS_DEVICE_STATUS_CHANGE
612#define MPI_EVENT_SAS_DEV_STAT_RC_CLEAR_TASK_SET_INTERNAL (0x0B) 622#define MPI_EVENT_SAS_DEV_STAT_RC_CLEAR_TASK_SET_INTERNAL (0x0B)
613#define MPI_EVENT_SAS_DEV_STAT_RC_QUERY_TASK_INTERNAL (0x0C) 623#define MPI_EVENT_SAS_DEV_STAT_RC_QUERY_TASK_INTERNAL (0x0C)
614#define MPI_EVENT_SAS_DEV_STAT_RC_ASYNC_NOTIFICATION (0x0D) 624#define MPI_EVENT_SAS_DEV_STAT_RC_ASYNC_NOTIFICATION (0x0D)
625#define MPI_EVENT_SAS_DEV_STAT_RC_CMPL_INTERNAL_DEV_RESET (0x0E)
626#define MPI_EVENT_SAS_DEV_STAT_RC_CMPL_TASK_ABORT_INTERNAL (0x0F)
615 627
616 628
617/* SCSI Event data for Queue Full event */ 629/* SCSI Event data for Queue Full event */
@@ -708,6 +720,8 @@ typedef struct _MPI_EVENT_DATA_IR2
708#define MPI_EVENT_IR2_RC_PD_REMOVED (0x05) 720#define MPI_EVENT_IR2_RC_PD_REMOVED (0x05)
709#define MPI_EVENT_IR2_RC_FOREIGN_CFG_DETECTED (0x06) 721#define MPI_EVENT_IR2_RC_FOREIGN_CFG_DETECTED (0x06)
710#define MPI_EVENT_IR2_RC_REBUILD_MEDIUM_ERROR (0x07) 722#define MPI_EVENT_IR2_RC_REBUILD_MEDIUM_ERROR (0x07)
723#define MPI_EVENT_IR2_RC_DUAL_PORT_ADDED (0x08)
724#define MPI_EVENT_IR2_RC_DUAL_PORT_REMOVED (0x09)
711 725
712/* defines for logical disk states */ 726/* defines for logical disk states */
713#define MPI_LD_STATE_OPTIMAL (0x00) 727#define MPI_LD_STATE_OPTIMAL (0x00)
@@ -867,6 +881,7 @@ typedef struct _EVENT_DATA_DISCOVERY_ERROR
867#define MPI_EVENT_DSCVRY_ERR_DS_UNSUPPORTED_DEVICE (0x00000800) 881#define MPI_EVENT_DSCVRY_ERR_DS_UNSUPPORTED_DEVICE (0x00000800)
868#define MPI_EVENT_DSCVRY_ERR_DS_MAX_SATA_TARGETS (0x00001000) 882#define MPI_EVENT_DSCVRY_ERR_DS_MAX_SATA_TARGETS (0x00001000)
869#define MPI_EVENT_DSCVRY_ERR_DS_MULTI_PORT_DOMAIN (0x00002000) 883#define MPI_EVENT_DSCVRY_ERR_DS_MULTI_PORT_DOMAIN (0x00002000)
884#define MPI_EVENT_DSCVRY_ERR_DS_SATA_INIT_FAILURE (0x00004000)
870 885
871/* SAS SMP Error Event data */ 886/* SAS SMP Error Event data */
872 887
@@ -902,6 +917,8 @@ typedef struct _EVENT_DATA_SAS_INIT_DEV_STATUS_CHANGE
902 917
903/* defines for the ReasonCode field of the SAS Initiator Device Status Change event */ 918/* defines for the ReasonCode field of the SAS Initiator Device Status Change event */
904#define MPI_EVENT_SAS_INIT_RC_ADDED (0x01) 919#define MPI_EVENT_SAS_INIT_RC_ADDED (0x01)
920#define MPI_EVENT_SAS_INIT_RC_REMOVED (0x02)
921#define MPI_EVENT_SAS_INIT_RC_INACCESSIBLE (0x03)
905 922
906/* SAS Initiator Device Table Overflow Event data */ 923/* SAS Initiator Device Table Overflow Event data */
907 924
@@ -910,6 +927,7 @@ typedef struct _EVENT_DATA_SAS_INIT_TABLE_OVERFLOW
910 U8 MaxInit; /* 00h */ 927 U8 MaxInit; /* 00h */
911 U8 CurrentInit; /* 01h */ 928 U8 CurrentInit; /* 01h */
912 U16 Reserved1; /* 02h */ 929 U16 Reserved1; /* 02h */
930 U64 SASAddress; /* 04h */
913} EVENT_DATA_SAS_INIT_TABLE_OVERFLOW, 931} EVENT_DATA_SAS_INIT_TABLE_OVERFLOW,
914 MPI_POINTER PTR_EVENT_DATA_SAS_INIT_TABLE_OVERFLOW, 932 MPI_POINTER PTR_EVENT_DATA_SAS_INIT_TABLE_OVERFLOW,
915 MpiEventDataSasInitTableOverflow_t, 933 MpiEventDataSasInitTableOverflow_t,
diff --git a/drivers/message/fusion/lsi/mpi_lan.h b/drivers/message/fusion/lsi/mpi_lan.h
index 03253b53b785..f41fcb69b359 100644
--- a/drivers/message/fusion/lsi/mpi_lan.h
+++ b/drivers/message/fusion/lsi/mpi_lan.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2000-2004 LSI Corporation. 2 * Copyright (c) 2000-2008 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi_lan.h 5 * Name: mpi_lan.h
diff --git a/drivers/message/fusion/lsi/mpi_log_fc.h b/drivers/message/fusion/lsi/mpi_log_fc.h
index e4dafcefeecd..face6e7acc72 100644
--- a/drivers/message/fusion/lsi/mpi_log_fc.h
+++ b/drivers/message/fusion/lsi/mpi_log_fc.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2000-2001 LSI Corporation. All rights reserved. 2 * Copyright (c) 2000-2008 LSI Corporation. All rights reserved.
3 * 3 *
4 * NAME: fc_log.h 4 * NAME: fc_log.h
5 * SUMMARY: MPI IocLogInfo definitions for the SYMFC9xx chips 5 * SUMMARY: MPI IocLogInfo definitions for the SYMFC9xx chips
diff --git a/drivers/message/fusion/lsi/mpi_log_sas.h b/drivers/message/fusion/lsi/mpi_log_sas.h
index af9da03e95e5..691620dbedd2 100644
--- a/drivers/message/fusion/lsi/mpi_log_sas.h
+++ b/drivers/message/fusion/lsi/mpi_log_sas.h
@@ -1,6 +1,6 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * Copyright 2003 LSI Corporation. All rights reserved. * 3 * Copyright (c) 2000-2008 LSI Corporation. All rights reserved. *
4 * * 4 * *
5 * Description * 5 * Description *
6 * ------------ * 6 * ------------ *
@@ -73,6 +73,8 @@
73#define IOP_LOGINFO_CODE_TARGET_MODE_ABORT_EXACT_IO (0x00070004) 73#define IOP_LOGINFO_CODE_TARGET_MODE_ABORT_EXACT_IO (0x00070004)
74#define IOP_LOGINFO_CODE_TARGET_MODE_ABORT_EXACT_IO_REQ (0x00070005) 74#define IOP_LOGINFO_CODE_TARGET_MODE_ABORT_EXACT_IO_REQ (0x00070005)
75 75
76#define IOP_LOGINFO_CODE_LOG_TIMESTAMP_EVENT (0x00080000)
77
76/****************************************************************************/ 78/****************************************************************************/
77/* PL LOGINFO_CODE defines, valid if IOC_LOGINFO_ORIGINATOR = PL */ 79/* PL LOGINFO_CODE defines, valid if IOC_LOGINFO_ORIGINATOR = PL */
78/****************************************************************************/ 80/****************************************************************************/
@@ -92,7 +94,7 @@
92#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_OPEN_TIMEOUT_EXP (0x0000000C) 94#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_OPEN_TIMEOUT_EXP (0x0000000C)
93#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_UNUSED_0D (0x0000000D) 95#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_UNUSED_0D (0x0000000D)
94#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_DVTBLE_ACCSS_FAIL (0x0000000E) 96#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_DVTBLE_ACCSS_FAIL (0x0000000E)
95#define PL_LOGINFO_SUB CODE_OPEN_FAIL_BAD_DEST (0x00000011) 97#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_BAD_DEST (0x00000011)
96#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_RATE_NOT_SUPP (0x00000012) 98#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_RATE_NOT_SUPP (0x00000012)
97#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_PROT_NOT_SUPP (0x00000013) 99#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_PROT_NOT_SUPP (0x00000013)
98#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_RESERVED_ABANDON0 (0x00000014) 100#define PL_LOGINFO_SUB_CODE_OPEN_FAIL_RESERVED_ABANDON0 (0x00000014)
@@ -159,10 +161,11 @@
159 161
160#define PL_LOGINFO_SUB_CODE_INVALID_SGL (0x00000200) 162#define PL_LOGINFO_SUB_CODE_INVALID_SGL (0x00000200)
161#define PL_LOGINFO_SUB_CODE_WRONG_REL_OFF_OR_FRAME_LENGTH (0x00000300) 163#define PL_LOGINFO_SUB_CODE_WRONG_REL_OFF_OR_FRAME_LENGTH (0x00000300)
162#define PL_LOGINFO_SUB_CODE_FRAME_XFER_ERROR (0x00000400) /* Bits 0-3 encode Transport Status Register (offset 0x08) */ 164#define PL_LOGINFO_SUB_CODE_FRAME_XFER_ERROR (0x00000400)
163 /* Bit 0 is Status Bit 0: FrameXferErr */ 165/* Bits 0-3 encode Transport Status Register (offset 0x08) */
164 /* Bit 1 & 2 are Status Bits 16 and 17: FrameXmitErrStatus */ 166/* Bit 0 is Status Bit 0: FrameXferErr */
165 /* Bit 3 is Status Bit 18 WriteDataLengthGTDataLengthErr */ 167/* Bit 1 & 2 are Status Bits 16 and 17: FrameXmitErrStatus */
168/* Bit 3 is Status Bit 18 WriteDataLenghtGTDataLengthErr */
166 169
167#define PL_LOGINFO_SUB_CODE_TX_FM_CONNECTED_LOW (0x00000500) 170#define PL_LOGINFO_SUB_CODE_TX_FM_CONNECTED_LOW (0x00000500)
168#define PL_LOGINFO_SUB_CODE_SATA_NON_NCQ_RW_ERR_BIT_SET (0x00000600) 171#define PL_LOGINFO_SUB_CODE_SATA_NON_NCQ_RW_ERR_BIT_SET (0x00000600)
@@ -177,6 +180,11 @@
177#define PL_LOGINFO_SUB_CODE_DISCOVERY_REMOTE_SEP_RESET (0x00000E01) 180#define PL_LOGINFO_SUB_CODE_DISCOVERY_REMOTE_SEP_RESET (0x00000E01)
178#define PL_LOGINFO_SUB_CODE_SECOND_OPEN (0x00000F00) 181#define PL_LOGINFO_SUB_CODE_SECOND_OPEN (0x00000F00)
179#define PL_LOGINFO_SUB_CODE_DSCVRY_SATA_INIT_TIMEOUT (0x00001000) 182#define PL_LOGINFO_SUB_CODE_DSCVRY_SATA_INIT_TIMEOUT (0x00001000)
183#define PL_LOGINFO_SUB_CODE_BREAK_ON_SATA_CONNECTION (0x00002000)
184/* not currently used in mainline */
185#define PL_LOGINFO_SUB_CODE_BREAK_ON_STUCK_LINK (0x00003000)
186#define PL_LOGINFO_SUB_CODE_BREAK_ON_STUCK_LINK_AIP (0x00004000)
187#define PL_LOGINFO_SUB_CODE_BREAK_ON_INCOMPLETE_BREAK_RCVD (0x00005000)
180 188
181#define PL_LOGINFO_CODE_ENCL_MGMT_SMP_FRAME_FAILURE (0x00200000) /* Can't get SMP Frame */ 189#define PL_LOGINFO_CODE_ENCL_MGMT_SMP_FRAME_FAILURE (0x00200000) /* Can't get SMP Frame */
182#define PL_LOGINFO_CODE_ENCL_MGMT_SMP_READ_ERROR (0x00200010) /* Error occured on SMP Read */ 190#define PL_LOGINFO_CODE_ENCL_MGMT_SMP_READ_ERROR (0x00200010) /* Error occured on SMP Read */
@@ -243,6 +251,8 @@
243#define IR_LOGINFO_VOLUME_ACTIVATE_VOLUME_FAILED (0x00010014) 251#define IR_LOGINFO_VOLUME_ACTIVATE_VOLUME_FAILED (0x00010014)
244/* Activation failed trying to import the volume */ 252/* Activation failed trying to import the volume */
245#define IR_LOGINFO_VOLUME_ACTIVATING_IMPORT_VOLUME_FAILED (0x00010015) 253#define IR_LOGINFO_VOLUME_ACTIVATING_IMPORT_VOLUME_FAILED (0x00010015)
254/* Activation failed trying to import the volume */
255#define IR_LOGINFO_VOLUME_ACTIVATING_TOO_MANY_PHYS_DISKS (0x00010016)
246 256
247/* Phys Disk failed, too many phys disks */ 257/* Phys Disk failed, too many phys disks */
248#define IR_LOGINFO_PHYSDISK_CREATE_TOO_MANY_DISKS (0x00010020) 258#define IR_LOGINFO_PHYSDISK_CREATE_TOO_MANY_DISKS (0x00010020)
@@ -285,6 +295,21 @@
285/* Compatibility Error : IME size limited to < 2TB */ 295/* Compatibility Error : IME size limited to < 2TB */
286#define IR_LOGINFO_COMPAT_ERROR_IME_VOL_NOT_CURRENTLY_SUPPORTED (0x0001003D) 296#define IR_LOGINFO_COMPAT_ERROR_IME_VOL_NOT_CURRENTLY_SUPPORTED (0x0001003D)
287 297
298/* Device Firmware Update: DFU can only be started once */
299#define IR_LOGINFO_DEV_FW_UPDATE_ERR_DFU_IN_PROGRESS (0x00010050)
300/* Device Firmware Update: Volume must be Optimal/Active/non-Quiesced */
301#define IR_LOGINFO_DEV_FW_UPDATE_ERR_DEVICE_IN_INVALID_STATE (0x00010051)
302/* Device Firmware Update: DFU Timeout cannot be zero */
303#define IR_LOGINFO_DEV_FW_UPDATE_ERR_INVALID_TIMEOUT (0x00010052)
304/* Device Firmware Update: CREATE TIMER FAILED */
305#define IR_LOGINFO_DEV_FW_UPDATE_ERR_NO_TIMERS (0x00010053)
306/* Device Firmware Update: Failed to read SAS_IO_UNIT_PG_1 */
307#define IR_LOGINFO_DEV_FW_UPDATE_ERR_READING_CFG_PAGE (0x00010054)
308/* Device Firmware Update: Invalid SAS_IO_UNIT_PG_1 value(s) */
309#define IR_LOGINFO_DEV_FW_UPDATE_ERR_PORT_IO_TIMEOUTS_REQUIRED (0x00010055)
310/* Device Firmware Update: Unable to allocate memory for page */
311#define IR_LOGINFO_DEV_FW_UPDATE_ERR_ALLOC_CFG_PAGE (0x00010056)
312
288 313
289/****************************************************************************/ 314/****************************************************************************/
290/* Defines for convenience */ 315/* Defines for convenience */
diff --git a/drivers/message/fusion/lsi/mpi_raid.h b/drivers/message/fusion/lsi/mpi_raid.h
index 2856108421d7..add60cc85be1 100644
--- a/drivers/message/fusion/lsi/mpi_raid.h
+++ b/drivers/message/fusion/lsi/mpi_raid.h
@@ -1,12 +1,12 @@
1/* 1/*
2 * Copyright (c) 2001-2007 LSI Corporation. 2 * Copyright (c) 2001-2008 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi_raid.h 5 * Name: mpi_raid.h
6 * Title: MPI RAID message and structures 6 * Title: MPI RAID message and structures
7 * Creation Date: February 27, 2001 7 * Creation Date: February 27, 2001
8 * 8 *
9 * mpi_raid.h Version: 01.05.03 9 * mpi_raid.h Version: 01.05.05
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -34,6 +34,9 @@
34 * _SET_RESYNC_RATE and _SET_DATA_SCRUB_RATE. 34 * _SET_RESYNC_RATE and _SET_DATA_SCRUB_RATE.
35 * 02-28-07 01.05.03 Added new RAID Action, Device FW Update Mode, and 35 * 02-28-07 01.05.03 Added new RAID Action, Device FW Update Mode, and
36 * associated defines. 36 * associated defines.
37 * 08-07-07 01.05.04 Added Disable Full Rebuild bit to the ActionDataWord
38 * for the RAID Action MPI_RAID_ACTION_DISABLE_VOLUME.
39 * 01-15-08 01.05.05 Added define for MPI_RAID_ACTION_SET_VOLUME_NAME.
37 * -------------------------------------------------------------------------- 40 * --------------------------------------------------------------------------
38 */ 41 */
39 42
@@ -93,6 +96,7 @@ typedef struct _MSG_RAID_ACTION
93#define MPI_RAID_ACTION_SET_RESYNC_RATE (0x13) 96#define MPI_RAID_ACTION_SET_RESYNC_RATE (0x13)
94#define MPI_RAID_ACTION_SET_DATA_SCRUB_RATE (0x14) 97#define MPI_RAID_ACTION_SET_DATA_SCRUB_RATE (0x14)
95#define MPI_RAID_ACTION_DEVICE_FW_UPDATE_MODE (0x15) 98#define MPI_RAID_ACTION_DEVICE_FW_UPDATE_MODE (0x15)
99#define MPI_RAID_ACTION_SET_VOLUME_NAME (0x16)
96 100
97/* ActionDataWord defines for use with MPI_RAID_ACTION_CREATE_VOLUME action */ 101/* ActionDataWord defines for use with MPI_RAID_ACTION_CREATE_VOLUME action */
98#define MPI_RAID_ACTION_ADATA_DO_NOT_SYNC (0x00000001) 102#define MPI_RAID_ACTION_ADATA_DO_NOT_SYNC (0x00000001)
@@ -105,6 +109,9 @@ typedef struct _MSG_RAID_ACTION
105#define MPI_RAID_ACTION_ADATA_KEEP_LBA0 (0x00000000) 109#define MPI_RAID_ACTION_ADATA_KEEP_LBA0 (0x00000000)
106#define MPI_RAID_ACTION_ADATA_ZERO_LBA0 (0x00000002) 110#define MPI_RAID_ACTION_ADATA_ZERO_LBA0 (0x00000002)
107 111
112/* ActionDataWord defines for use with MPI_RAID_ACTION_DISABLE_VOLUME action */
113#define MPI_RAID_ACTION_ADATA_DISABLE_FULL_REBUILD (0x00000001)
114
108/* ActionDataWord defines for use with MPI_RAID_ACTION_ACTIVATE_VOLUME action */ 115/* ActionDataWord defines for use with MPI_RAID_ACTION_ACTIVATE_VOLUME action */
109#define MPI_RAID_ACTION_ADATA_INACTIVATE_ALL (0x00000001) 116#define MPI_RAID_ACTION_ADATA_INACTIVATE_ALL (0x00000001)
110 117
diff --git a/drivers/message/fusion/lsi/mpi_sas.h b/drivers/message/fusion/lsi/mpi_sas.h
index 33fca83cefc2..ab410036bbfc 100644
--- a/drivers/message/fusion/lsi/mpi_sas.h
+++ b/drivers/message/fusion/lsi/mpi_sas.h
@@ -1,12 +1,12 @@
1/* 1/*
2 * Copyright (c) 2004-2006 LSI Corporation. 2 * Copyright (c) 2004-2008 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi_sas.h 5 * Name: mpi_sas.h
6 * Title: MPI Serial Attached SCSI structures and definitions 6 * Title: MPI Serial Attached SCSI structures and definitions
7 * Creation Date: August 19, 2004 7 * Creation Date: August 19, 2004
8 * 8 *
9 * mpi_sas.h Version: 01.05.04 9 * mpi_sas.h Version: 01.05.05
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
@@ -23,6 +23,10 @@
23 * reply. 23 * reply.
24 * 10-11-06 01.05.04 Fixed the name of a define for Operation field of SAS IO 24 * 10-11-06 01.05.04 Fixed the name of a define for Operation field of SAS IO
25 * Unit Control request. 25 * Unit Control request.
26 * 01-15-08 01.05.05 Added support for MPI_SAS_OP_SET_IOC_PARAMETER,
27 * including adding IOCParameter and IOCParameter value
28 * fields to SAS IO Unit Control Request.
29 * Added MPI_SAS_DEVICE_INFO_PRODUCT_SPECIFIC define.
26 * -------------------------------------------------------------------------- 30 * --------------------------------------------------------------------------
27 */ 31 */
28 32
@@ -60,6 +64,8 @@
60 * Values for the SAS DeviceInfo field used in SAS Device Status Change Event 64 * Values for the SAS DeviceInfo field used in SAS Device Status Change Event
61 * data and SAS IO Unit Configuration pages. 65 * data and SAS IO Unit Configuration pages.
62 */ 66 */
67#define MPI_SAS_DEVICE_INFO_PRODUCT_SPECIFIC (0xF0000000)
68
63#define MPI_SAS_DEVICE_INFO_SEP (0x00004000) 69#define MPI_SAS_DEVICE_INFO_SEP (0x00004000)
64#define MPI_SAS_DEVICE_INFO_ATAPI_DEVICE (0x00002000) 70#define MPI_SAS_DEVICE_INFO_ATAPI_DEVICE (0x00002000)
65#define MPI_SAS_DEVICE_INFO_LSI_DEVICE (0x00001000) 71#define MPI_SAS_DEVICE_INFO_LSI_DEVICE (0x00001000)
@@ -216,7 +222,7 @@ typedef struct _MSG_SAS_IOUNIT_CONTROL_REQUEST
216 U8 ChainOffset; /* 02h */ 222 U8 ChainOffset; /* 02h */
217 U8 Function; /* 03h */ 223 U8 Function; /* 03h */
218 U16 DevHandle; /* 04h */ 224 U16 DevHandle; /* 04h */
219 U8 Reserved3; /* 06h */ 225 U8 IOCParameter; /* 06h */
220 U8 MsgFlags; /* 07h */ 226 U8 MsgFlags; /* 07h */
221 U32 MsgContext; /* 08h */ 227 U32 MsgContext; /* 08h */
222 U8 TargetID; /* 0Ch */ 228 U8 TargetID; /* 0Ch */
@@ -225,7 +231,7 @@ typedef struct _MSG_SAS_IOUNIT_CONTROL_REQUEST
225 U8 PrimFlags; /* 0Fh */ 231 U8 PrimFlags; /* 0Fh */
226 U32 Primitive; /* 10h */ 232 U32 Primitive; /* 10h */
227 U64 SASAddress; /* 14h */ 233 U64 SASAddress; /* 14h */
228 U32 Reserved4; /* 1Ch */ 234 U32 IOCParameterValue; /* 1Ch */
229} MSG_SAS_IOUNIT_CONTROL_REQUEST, MPI_POINTER PTR_MSG_SAS_IOUNIT_CONTROL_REQUEST, 235} MSG_SAS_IOUNIT_CONTROL_REQUEST, MPI_POINTER PTR_MSG_SAS_IOUNIT_CONTROL_REQUEST,
230 SasIoUnitControlRequest_t, MPI_POINTER pSasIoUnitControlRequest_t; 236 SasIoUnitControlRequest_t, MPI_POINTER pSasIoUnitControlRequest_t;
231 237
@@ -241,6 +247,8 @@ typedef struct _MSG_SAS_IOUNIT_CONTROL_REQUEST
241#define MPI_SAS_OP_TRANSMIT_PORT_SELECT_SIGNAL (0x0C) 247#define MPI_SAS_OP_TRANSMIT_PORT_SELECT_SIGNAL (0x0C)
242#define MPI_SAS_OP_TRANSMIT_REMOVE_DEVICE (0x0D) /* obsolete name */ 248#define MPI_SAS_OP_TRANSMIT_REMOVE_DEVICE (0x0D) /* obsolete name */
243#define MPI_SAS_OP_REMOVE_DEVICE (0x0D) 249#define MPI_SAS_OP_REMOVE_DEVICE (0x0D)
250#define MPI_SAS_OP_SET_IOC_PARAMETER (0x0E)
251#define MPI_SAS_OP_PRODUCT_SPECIFIC_MIN (0x80)
244 252
245/* values for the PrimFlags field */ 253/* values for the PrimFlags field */
246#define MPI_SAS_PRIMFLAGS_SINGLE (0x08) 254#define MPI_SAS_PRIMFLAGS_SINGLE (0x08)
@@ -256,7 +264,7 @@ typedef struct _MSG_SAS_IOUNIT_CONTROL_REPLY
256 U8 MsgLength; /* 02h */ 264 U8 MsgLength; /* 02h */
257 U8 Function; /* 03h */ 265 U8 Function; /* 03h */
258 U16 DevHandle; /* 04h */ 266 U16 DevHandle; /* 04h */
259 U8 Reserved3; /* 06h */ 267 U8 IOCParameter; /* 06h */
260 U8 MsgFlags; /* 07h */ 268 U8 MsgFlags; /* 07h */
261 U32 MsgContext; /* 08h */ 269 U32 MsgContext; /* 08h */
262 U16 Reserved4; /* 0Ch */ 270 U16 Reserved4; /* 0Ch */
diff --git a/drivers/message/fusion/lsi/mpi_targ.h b/drivers/message/fusion/lsi/mpi_targ.h
index ff8c37d3fdcb..c3dea7f6909d 100644
--- a/drivers/message/fusion/lsi/mpi_targ.h
+++ b/drivers/message/fusion/lsi/mpi_targ.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2000-2004 LSI Corporation. 2 * Copyright (c) 2000-2008 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi_targ.h 5 * Name: mpi_targ.h
diff --git a/drivers/message/fusion/lsi/mpi_tool.h b/drivers/message/fusion/lsi/mpi_tool.h
index 8834ae6ce0f2..53cd715aa7e4 100644
--- a/drivers/message/fusion/lsi/mpi_tool.h
+++ b/drivers/message/fusion/lsi/mpi_tool.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2001-2005 LSI Corporation. 2 * Copyright (c) 2001-2008 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi_tool.h 5 * Name: mpi_tool.h
diff --git a/drivers/message/fusion/lsi/mpi_type.h b/drivers/message/fusion/lsi/mpi_type.h
index 08dad9c1e446..888b26dbc413 100644
--- a/drivers/message/fusion/lsi/mpi_type.h
+++ b/drivers/message/fusion/lsi/mpi_type.h
@@ -1,12 +1,12 @@
1/* 1/*
2 * Copyright (c) 2000-2004 LSI Corporation. 2 * Copyright (c) 2000-2008 LSI Corporation.
3 * 3 *
4 * 4 *
5 * Name: mpi_type.h 5 * Name: mpi_type.h
6 * Title: MPI Basic type definitions 6 * Title: MPI Basic type definitions
7 * Creation Date: June 6, 2000 7 * Creation Date: June 6, 2000
8 * 8 *
9 * mpi_type.h Version: 01.05.01 9 * mpi_type.h Version: 01.05.02
10 * 10 *
11 * Version History 11 * Version History
12 * --------------- 12 * ---------------
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index c4e8b9aa3827..96ac88317b8e 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -79,9 +79,22 @@ MODULE_VERSION(my_VERSION);
79/* 79/*
80 * cmd line parameters 80 * cmd line parameters
81 */ 81 */
82static int mpt_msi_enable = -1; 82
83module_param(mpt_msi_enable, int, 0); 83static int mpt_msi_enable_spi;
84MODULE_PARM_DESC(mpt_msi_enable, " MSI Support Enable (default=0)"); 84module_param(mpt_msi_enable_spi, int, 0);
85MODULE_PARM_DESC(mpt_msi_enable_spi, " Enable MSI Support for SPI \
86 controllers (default=0)");
87
88static int mpt_msi_enable_fc;
89module_param(mpt_msi_enable_fc, int, 0);
90MODULE_PARM_DESC(mpt_msi_enable_fc, " Enable MSI Support for FC \
91 controllers (default=0)");
92
93static int mpt_msi_enable_sas;
94module_param(mpt_msi_enable_sas, int, 1);
95MODULE_PARM_DESC(mpt_msi_enable_sas, " Enable MSI Support for SAS \
96 controllers (default=1)");
97
85 98
86static int mpt_channel_mapping; 99static int mpt_channel_mapping;
87module_param(mpt_channel_mapping, int, 0); 100module_param(mpt_channel_mapping, int, 0);
@@ -91,7 +104,17 @@ static int mpt_debug_level;
91static int mpt_set_debug_level(const char *val, struct kernel_param *kp); 104static int mpt_set_debug_level(const char *val, struct kernel_param *kp);
92module_param_call(mpt_debug_level, mpt_set_debug_level, param_get_int, 105module_param_call(mpt_debug_level, mpt_set_debug_level, param_get_int,
93 &mpt_debug_level, 0600); 106 &mpt_debug_level, 0600);
94MODULE_PARM_DESC(mpt_debug_level, " debug level - refer to mptdebug.h - (default=0)"); 107MODULE_PARM_DESC(mpt_debug_level, " debug level - refer to mptdebug.h \
108 - (default=0)");
109
110int mpt_fwfault_debug;
111EXPORT_SYMBOL(mpt_fwfault_debug);
112module_param_call(mpt_fwfault_debug, param_set_int, param_get_int,
113 &mpt_fwfault_debug, 0600);
114MODULE_PARM_DESC(mpt_fwfault_debug, "Enable detection of Firmware fault"
115 " and halt Firmware on fault - (default=0)");
116
117
95 118
96#ifdef MFCNT 119#ifdef MFCNT
97static int mfcounter = 0; 120static int mfcounter = 0;
@@ -1751,16 +1774,25 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1751 ioc->bus_type = SAS; 1774 ioc->bus_type = SAS;
1752 } 1775 }
1753 1776
1754 if (mpt_msi_enable == -1) {
1755 /* Enable on SAS, disable on FC and SPI */
1756 if (ioc->bus_type == SAS)
1757 ioc->msi_enable = 1;
1758 else
1759 ioc->msi_enable = 0;
1760 } else
1761 /* follow flag: 0 - disable; 1 - enable */
1762 ioc->msi_enable = mpt_msi_enable;
1763 1777
1778 switch (ioc->bus_type) {
1779
1780 case SAS:
1781 ioc->msi_enable = mpt_msi_enable_sas;
1782 break;
1783
1784 case SPI:
1785 ioc->msi_enable = mpt_msi_enable_spi;
1786 break;
1787
1788 case FC:
1789 ioc->msi_enable = mpt_msi_enable_fc;
1790 break;
1791
1792 default:
1793 ioc->msi_enable = 0;
1794 break;
1795 }
1764 if (ioc->errata_flag_1064) 1796 if (ioc->errata_flag_1064)
1765 pci_disable_io_access(pdev); 1797 pci_disable_io_access(pdev);
1766 1798
@@ -6313,6 +6345,33 @@ mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buffer, int *size, int len, int sh
6313 *size = y; 6345 *size = y;
6314} 6346}
6315 6347
6348
6349/**
6350 * mpt_halt_firmware - Halts the firmware if it is operational and panic
6351 * the kernel
6352 * @ioc: Pointer to MPT_ADAPTER structure
6353 *
6354 **/
6355void
6356mpt_halt_firmware(MPT_ADAPTER *ioc)
6357{
6358 u32 ioc_raw_state;
6359
6360 ioc_raw_state = mpt_GetIocState(ioc, 0);
6361
6362 if ((ioc_raw_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_FAULT) {
6363 printk(MYIOC_s_ERR_FMT "IOC is in FAULT state (%04xh)!!!\n",
6364 ioc->name, ioc_raw_state & MPI_DOORBELL_DATA_MASK);
6365 panic("%s: IOC Fault (%04xh)!!!\n", ioc->name,
6366 ioc_raw_state & MPI_DOORBELL_DATA_MASK);
6367 } else {
6368 CHIPREG_WRITE32(&ioc->chip->Doorbell, 0xC0FFEE00);
6369 panic("%s: Firmware is halted due to command timeout\n",
6370 ioc->name);
6371 }
6372}
6373EXPORT_SYMBOL(mpt_halt_firmware);
6374
6316/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6375/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6317/* 6376/*
6318 * Reset Handling 6377 * Reset Handling
@@ -6345,6 +6404,8 @@ mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag)
6345 printk(MYIOC_s_INFO_FMT "HardResetHandler Entered!\n", ioc->name); 6404 printk(MYIOC_s_INFO_FMT "HardResetHandler Entered!\n", ioc->name);
6346 printk("MF count 0x%x !\n", ioc->mfcnt); 6405 printk("MF count 0x%x !\n", ioc->mfcnt);
6347#endif 6406#endif
6407 if (mpt_fwfault_debug)
6408 mpt_halt_firmware(ioc);
6348 6409
6349 /* Reset the adapter. Prevent more than 1 call to 6410 /* Reset the adapter. Prevent more than 1 call to
6350 * mpt_do_ioc_recovery at any instant in time. 6411 * mpt_do_ioc_recovery at any instant in time.
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index dff048cfa101..b3e981d2a506 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -922,11 +922,14 @@ extern void mpt_free_fw_memory(MPT_ADAPTER *ioc);
922extern int mpt_findImVolumes(MPT_ADAPTER *ioc); 922extern int mpt_findImVolumes(MPT_ADAPTER *ioc);
923extern int mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode); 923extern int mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode);
924extern int mpt_raid_phys_disk_pg0(MPT_ADAPTER *ioc, u8 phys_disk_num, pRaidPhysDiskPage0_t phys_disk); 924extern int mpt_raid_phys_disk_pg0(MPT_ADAPTER *ioc, u8 phys_disk_num, pRaidPhysDiskPage0_t phys_disk);
925extern void mpt_halt_firmware(MPT_ADAPTER *ioc);
926
925 927
926/* 928/*
927 * Public data decl's... 929 * Public data decl's...
928 */ 930 */
929extern struct list_head ioc_list; 931extern struct list_head ioc_list;
932extern int mpt_fwfault_debug;
930 933
931/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 934/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
932#endif /* } __KERNEL__ */ 935#endif /* } __KERNEL__ */
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
index b89f476cd0a9..c63817117c0a 100644
--- a/drivers/message/fusion/mptctl.c
+++ b/drivers/message/fusion/mptctl.c
@@ -308,10 +308,11 @@ static void mptctl_timeout_expired (MPT_IOCTL *ioctl)
308{ 308{
309 int rc = 1; 309 int rc = 1;
310 310
311 dctlprintk(ioctl->ioc, printk(MYIOC_s_DEBUG_FMT ": Timeout Expired! Host %d\n",
312 ioctl->ioc->name, ioctl->ioc->id));
313 if (ioctl == NULL) 311 if (ioctl == NULL)
314 return; 312 return;
313 dctlprintk(ioctl->ioc,
314 printk(MYIOC_s_DEBUG_FMT ": Timeout Expired! Host %d\n",
315 ioctl->ioc->name, ioctl->ioc->id));
315 316
316 ioctl->wait_done = 0; 317 ioctl->wait_done = 0;
317 if (ioctl->reset & MPTCTL_RESET_OK) 318 if (ioctl->reset & MPTCTL_RESET_OK)
diff --git a/drivers/message/fusion/mptlan.c b/drivers/message/fusion/mptlan.c
index a13f6eecd25b..c2804f26cb44 100644
--- a/drivers/message/fusion/mptlan.c
+++ b/drivers/message/fusion/mptlan.c
@@ -106,7 +106,6 @@ struct mpt_lan_priv {
106 106
107 u32 total_posted; 107 u32 total_posted;
108 u32 total_received; 108 u32 total_received;
109 struct net_device_stats stats; /* Per device statistics */
110 109
111 struct delayed_work post_buckets_task; 110 struct delayed_work post_buckets_task;
112 struct net_device *dev; 111 struct net_device *dev;
@@ -548,15 +547,6 @@ mpt_lan_close(struct net_device *dev)
548} 547}
549 548
550/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 549/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
551static struct net_device_stats *
552mpt_lan_get_stats(struct net_device *dev)
553{
554 struct mpt_lan_priv *priv = netdev_priv(dev);
555
556 return (struct net_device_stats *) &priv->stats;
557}
558
559/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
560static int 550static int
561mpt_lan_change_mtu(struct net_device *dev, int new_mtu) 551mpt_lan_change_mtu(struct net_device *dev, int new_mtu)
562{ 552{
@@ -594,8 +584,8 @@ mpt_lan_send_turbo(struct net_device *dev, u32 tmsg)
594 ctx = GET_LAN_BUFFER_CONTEXT(tmsg); 584 ctx = GET_LAN_BUFFER_CONTEXT(tmsg);
595 sent = priv->SendCtl[ctx].skb; 585 sent = priv->SendCtl[ctx].skb;
596 586
597 priv->stats.tx_packets++; 587 dev->stats.tx_packets++;
598 priv->stats.tx_bytes += sent->len; 588 dev->stats.tx_bytes += sent->len;
599 589
600 dioprintk((KERN_INFO MYNAM ": %s/%s: @%s, skb %p sent.\n", 590 dioprintk((KERN_INFO MYNAM ": %s/%s: @%s, skb %p sent.\n",
601 IOC_AND_NETDEV_NAMES_s_s(dev), 591 IOC_AND_NETDEV_NAMES_s_s(dev),
@@ -636,7 +626,7 @@ mpt_lan_send_reply(struct net_device *dev, LANSendReply_t *pSendRep)
636 626
637 switch (le16_to_cpu(pSendRep->IOCStatus) & MPI_IOCSTATUS_MASK) { 627 switch (le16_to_cpu(pSendRep->IOCStatus) & MPI_IOCSTATUS_MASK) {
638 case MPI_IOCSTATUS_SUCCESS: 628 case MPI_IOCSTATUS_SUCCESS:
639 priv->stats.tx_packets += count; 629 dev->stats.tx_packets += count;
640 break; 630 break;
641 631
642 case MPI_IOCSTATUS_LAN_CANCELED: 632 case MPI_IOCSTATUS_LAN_CANCELED:
@@ -644,13 +634,13 @@ mpt_lan_send_reply(struct net_device *dev, LANSendReply_t *pSendRep)
644 break; 634 break;
645 635
646 case MPI_IOCSTATUS_INVALID_SGL: 636 case MPI_IOCSTATUS_INVALID_SGL:
647 priv->stats.tx_errors += count; 637 dev->stats.tx_errors += count;
648 printk (KERN_ERR MYNAM ": %s/%s: ERROR - Invalid SGL sent to IOC!\n", 638 printk (KERN_ERR MYNAM ": %s/%s: ERROR - Invalid SGL sent to IOC!\n",
649 IOC_AND_NETDEV_NAMES_s_s(dev)); 639 IOC_AND_NETDEV_NAMES_s_s(dev));
650 goto out; 640 goto out;
651 641
652 default: 642 default:
653 priv->stats.tx_errors += count; 643 dev->stats.tx_errors += count;
654 break; 644 break;
655 } 645 }
656 646
@@ -661,7 +651,7 @@ mpt_lan_send_reply(struct net_device *dev, LANSendReply_t *pSendRep)
661 ctx = GET_LAN_BUFFER_CONTEXT(le32_to_cpu(*pContext)); 651 ctx = GET_LAN_BUFFER_CONTEXT(le32_to_cpu(*pContext));
662 652
663 sent = priv->SendCtl[ctx].skb; 653 sent = priv->SendCtl[ctx].skb;
664 priv->stats.tx_bytes += sent->len; 654 dev->stats.tx_bytes += sent->len;
665 655
666 dioprintk((KERN_INFO MYNAM ": %s/%s: @%s, skb %p sent.\n", 656 dioprintk((KERN_INFO MYNAM ": %s/%s: @%s, skb %p sent.\n",
667 IOC_AND_NETDEV_NAMES_s_s(dev), 657 IOC_AND_NETDEV_NAMES_s_s(dev),
@@ -842,8 +832,8 @@ mpt_lan_receive_skb(struct net_device *dev, struct sk_buff *skb)
842 "delivered to upper level.\n", 832 "delivered to upper level.\n",
843 IOC_AND_NETDEV_NAMES_s_s(dev), skb->len)); 833 IOC_AND_NETDEV_NAMES_s_s(dev), skb->len));
844 834
845 priv->stats.rx_bytes += skb->len; 835 dev->stats.rx_bytes += skb->len;
846 priv->stats.rx_packets++; 836 dev->stats.rx_packets++;
847 837
848 skb->dev = dev; 838 skb->dev = dev;
849 netif_rx(skb); 839 netif_rx(skb);
@@ -1308,6 +1298,14 @@ mpt_lan_post_receive_buckets_work(struct work_struct *work)
1308 post_buckets_task.work)); 1298 post_buckets_task.work));
1309} 1299}
1310 1300
1301static const struct net_device_ops mpt_netdev_ops = {
1302 .ndo_open = mpt_lan_open,
1303 .ndo_stop = mpt_lan_close,
1304 .ndo_start_xmit = mpt_lan_sdu_send,
1305 .ndo_change_mtu = mpt_lan_change_mtu,
1306 .ndo_tx_timeout = mpt_lan_tx_timeout,
1307};
1308
1311/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1309/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1312static struct net_device * 1310static struct net_device *
1313mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum) 1311mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum)
@@ -1372,15 +1370,7 @@ mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum)
1372 priv->tx_max_out = (tx_max_out_p <= MPT_TX_MAX_OUT_LIM) ? 1370 priv->tx_max_out = (tx_max_out_p <= MPT_TX_MAX_OUT_LIM) ?
1373 tx_max_out_p : MPT_TX_MAX_OUT_LIM; 1371 tx_max_out_p : MPT_TX_MAX_OUT_LIM;
1374 1372
1375 dev->open = mpt_lan_open; 1373 dev->netdev_ops = &mpt_netdev_ops;
1376 dev->stop = mpt_lan_close;
1377 dev->get_stats = mpt_lan_get_stats;
1378 dev->set_multicast_list = NULL;
1379 dev->change_mtu = mpt_lan_change_mtu;
1380 dev->hard_start_xmit = mpt_lan_sdu_send;
1381
1382/* Not in 2.3.42. Need 2.3.45+ */
1383 dev->tx_timeout = mpt_lan_tx_timeout;
1384 dev->watchdog_timeo = MPT_LAN_TX_TIMEOUT; 1374 dev->watchdog_timeo = MPT_LAN_TX_TIMEOUT;
1385 1375
1386 dlprintk((KERN_INFO MYNAM ": Finished registering dev " 1376 dlprintk((KERN_INFO MYNAM ": Finished registering dev "
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index ee090413e598..e62c6bc4ad33 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -1846,6 +1846,9 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1846 if (hd->timeouts < -1) 1846 if (hd->timeouts < -1)
1847 hd->timeouts++; 1847 hd->timeouts++;
1848 1848
1849 if (mpt_fwfault_debug)
1850 mpt_halt_firmware(ioc);
1851
1849 /* Most important! Set TaskMsgContext to SCpnt's MsgContext! 1852 /* Most important! Set TaskMsgContext to SCpnt's MsgContext!
1850 * (the IO to be ABORT'd) 1853 * (the IO to be ABORT'd)
1851 * 1854 *
diff --git a/drivers/message/i2o/i2o_scsi.c b/drivers/message/i2o/i2o_scsi.c
index 1bcdbbb9e7d3..3d45817e6dcd 100644
--- a/drivers/message/i2o/i2o_scsi.c
+++ b/drivers/message/i2o/i2o_scsi.c
@@ -390,7 +390,7 @@ static int i2o_scsi_reply(struct i2o_controller *c, u32 m,
390 * @i2o_dev: the I2O device which was added 390 * @i2o_dev: the I2O device which was added
391 * 391 *
392 * If a I2O device is added we catch the notification, because I2O classes 392 * If a I2O device is added we catch the notification, because I2O classes
393 * other then SCSI peripheral will not be received through 393 * other than SCSI peripheral will not be received through
394 * i2o_scsi_probe(). 394 * i2o_scsi_probe().
395 */ 395 */
396static void i2o_scsi_notify_device_add(struct i2o_device *i2o_dev) 396static void i2o_scsi_notify_device_add(struct i2o_device *i2o_dev)
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 416f9e7286ba..06a2b0f7737c 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -217,6 +217,29 @@ config MFD_WM8350_I2C
217 I2C as the control interface. Additional options must be 217 I2C as the control interface. Additional options must be
218 selected to enable support for the functionality of the chip. 218 selected to enable support for the functionality of the chip.
219 219
220config MFD_PCF50633
221 tristate "Support for NXP PCF50633"
222 depends on I2C
223 help
224 Say yes here if you have NXP PCF50633 chip on your board.
225 This core driver provides register access and IRQ handling
226 facilities, and registers devices for the various functions
227 so that function-specific drivers can bind to them.
228
229config PCF50633_ADC
230 tristate "Support for NXP PCF50633 ADC"
231 depends on MFD_PCF50633
232 help
233 Say yes here if you want to include support for ADC in the
234 NXP PCF50633 chip.
235
236config PCF50633_GPIO
237 tristate "Support for NXP PCF50633 GPIO"
238 depends on MFD_PCF50633
239 help
240 Say yes here if you want to include support GPIO for pins on
241 the PCF50633 chip.
242
220endmenu 243endmenu
221 244
222menu "Multimedia Capabilities Port drivers" 245menu "Multimedia Capabilities Port drivers"
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 0c9418b36c26..3afb5192e4da 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -37,3 +37,7 @@ endif
37obj-$(CONFIG_UCB1400_CORE) += ucb1400_core.o 37obj-$(CONFIG_UCB1400_CORE) += ucb1400_core.o
38 38
39obj-$(CONFIG_PMIC_DA903X) += da903x.o 39obj-$(CONFIG_PMIC_DA903X) += da903x.o
40
41obj-$(CONFIG_MFD_PCF50633) += pcf50633-core.o
42obj-$(CONFIG_PCF50633_ADC) += pcf50633-adc.o
43obj-$(CONFIG_PCF50633_GPIO) += pcf50633-gpio.o \ No newline at end of file
diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c
index 4214b3f72426..7ac12cb0be4a 100644
--- a/drivers/mfd/dm355evm_msp.c
+++ b/drivers/mfd/dm355evm_msp.c
@@ -107,6 +107,9 @@ static const u8 msp_gpios[] = {
107 MSP_GPIO(0, SWITCH1), MSP_GPIO(1, SWITCH1), 107 MSP_GPIO(0, SWITCH1), MSP_GPIO(1, SWITCH1),
108 MSP_GPIO(2, SWITCH1), MSP_GPIO(3, SWITCH1), 108 MSP_GPIO(2, SWITCH1), MSP_GPIO(3, SWITCH1),
109 MSP_GPIO(4, SWITCH1), 109 MSP_GPIO(4, SWITCH1),
110 /* switches on MMC/SD sockets */
111 MSP_GPIO(1, SDMMC), MSP_GPIO(2, SDMMC), /* mmc0 WP, nCD */
112 MSP_GPIO(3, SDMMC), MSP_GPIO(4, SDMMC), /* mmc1 WP, nCD */
110}; 113};
111 114
112#define MSP_GPIO_REG(offset) (msp_gpios[(offset)] >> 3) 115#define MSP_GPIO_REG(offset) (msp_gpios[(offset)] >> 3)
@@ -304,6 +307,13 @@ static int add_children(struct i2c_client *client)
304 gpio_export(gpio, false); 307 gpio_export(gpio, false);
305 } 308 }
306 309
310 /* MMC/SD inputs -- right after the last config input */
311 if (client->dev.platform_data) {
312 void (*mmcsd_setup)(unsigned) = client->dev.platform_data;
313
314 mmcsd_setup(dm355evm_msp_gpio.base + 8 + 5);
315 }
316
307 /* RTC is a 32 bit counter, no alarm */ 317 /* RTC is a 32 bit counter, no alarm */
308 if (msp_has_rtc()) { 318 if (msp_has_rtc()) {
309 child = add_child(client, "rtc-dm355evm", 319 child = add_child(client, "rtc-dm355evm",
diff --git a/drivers/mfd/pcf50633-adc.c b/drivers/mfd/pcf50633-adc.c
new file mode 100644
index 000000000000..c2d05becfa97
--- /dev/null
+++ b/drivers/mfd/pcf50633-adc.c
@@ -0,0 +1,277 @@
1/* NXP PCF50633 ADC Driver
2 *
3 * (C) 2006-2008 by Openmoko, Inc.
4 * Author: Balaji Rao <balajirrao@openmoko.org>
5 * All rights reserved.
6 *
7 * Broken down from monstrous PCF50633 driver mainly by
8 * Harald Welte, Andy Green and Werner Almesberger
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 * NOTE: This driver does not yet support subtractive ADC mode, which means
16 * you can do only one measurement per read request.
17 */
18
19#include <linux/kernel.h>
20#include <linux/module.h>
21#include <linux/init.h>
22#include <linux/device.h>
23#include <linux/platform_device.h>
24#include <linux/completion.h>
25
26#include <linux/mfd/pcf50633/core.h>
27#include <linux/mfd/pcf50633/adc.h>
28
29struct pcf50633_adc_request {
30 int mux;
31 int avg;
32 int result;
33 void (*callback)(struct pcf50633 *, void *, int);
34 void *callback_param;
35
36 /* Used in case of sync requests */
37 struct completion completion;
38
39};
40
41#define PCF50633_MAX_ADC_FIFO_DEPTH 8
42
43struct pcf50633_adc {
44 struct pcf50633 *pcf;
45
46 /* Private stuff */
47 struct pcf50633_adc_request *queue[PCF50633_MAX_ADC_FIFO_DEPTH];
48 int queue_head;
49 int queue_tail;
50 struct mutex queue_mutex;
51};
52
53static inline struct pcf50633_adc *__to_adc(struct pcf50633 *pcf)
54{
55 return platform_get_drvdata(pcf->adc_pdev);
56}
57
58static void adc_setup(struct pcf50633 *pcf, int channel, int avg)
59{
60 channel &= PCF50633_ADCC1_ADCMUX_MASK;
61
62 /* kill ratiometric, but enable ACCSW biasing */
63 pcf50633_reg_write(pcf, PCF50633_REG_ADCC2, 0x00);
64 pcf50633_reg_write(pcf, PCF50633_REG_ADCC3, 0x01);
65
66 /* start ADC conversion on selected channel */
67 pcf50633_reg_write(pcf, PCF50633_REG_ADCC1, channel | avg |
68 PCF50633_ADCC1_ADCSTART | PCF50633_ADCC1_RES_10BIT);
69}
70
71static void trigger_next_adc_job_if_any(struct pcf50633 *pcf)
72{
73 struct pcf50633_adc *adc = __to_adc(pcf);
74 int head;
75
76 mutex_lock(&adc->queue_mutex);
77
78 head = adc->queue_head;
79
80 if (!adc->queue[head]) {
81 mutex_unlock(&adc->queue_mutex);
82 return;
83 }
84 mutex_unlock(&adc->queue_mutex);
85
86 adc_setup(pcf, adc->queue[head]->mux, adc->queue[head]->avg);
87}
88
89static int
90adc_enqueue_request(struct pcf50633 *pcf, struct pcf50633_adc_request *req)
91{
92 struct pcf50633_adc *adc = __to_adc(pcf);
93 int head, tail;
94
95 mutex_lock(&adc->queue_mutex);
96
97 head = adc->queue_head;
98 tail = adc->queue_tail;
99
100 if (adc->queue[tail]) {
101 mutex_unlock(&adc->queue_mutex);
102 return -EBUSY;
103 }
104
105 adc->queue[tail] = req;
106 adc->queue_tail = (tail + 1) & (PCF50633_MAX_ADC_FIFO_DEPTH - 1);
107
108 mutex_unlock(&adc->queue_mutex);
109
110 trigger_next_adc_job_if_any(pcf);
111
112 return 0;
113}
114
115static void
116pcf50633_adc_sync_read_callback(struct pcf50633 *pcf, void *param, int result)
117{
118 struct pcf50633_adc_request *req = param;
119
120 req->result = result;
121 complete(&req->completion);
122}
123
124int pcf50633_adc_sync_read(struct pcf50633 *pcf, int mux, int avg)
125{
126 struct pcf50633_adc_request *req;
127
128 /* req is freed when the result is ready, in interrupt handler */
129 req = kzalloc(sizeof(*req), GFP_KERNEL);
130 if (!req)
131 return -ENOMEM;
132
133 req->mux = mux;
134 req->avg = avg;
135 req->callback = pcf50633_adc_sync_read_callback;
136 req->callback_param = req;
137
138 init_completion(&req->completion);
139 adc_enqueue_request(pcf, req);
140 wait_for_completion(&req->completion);
141
142 return req->result;
143}
144EXPORT_SYMBOL_GPL(pcf50633_adc_sync_read);
145
146int pcf50633_adc_async_read(struct pcf50633 *pcf, int mux, int avg,
147 void (*callback)(struct pcf50633 *, void *, int),
148 void *callback_param)
149{
150 struct pcf50633_adc_request *req;
151
152 /* req is freed when the result is ready, in interrupt handler */
153 req = kmalloc(sizeof(*req), GFP_KERNEL);
154 if (!req)
155 return -ENOMEM;
156
157 req->mux = mux;
158 req->avg = avg;
159 req->callback = callback;
160 req->callback_param = callback_param;
161
162 adc_enqueue_request(pcf, req);
163
164 return 0;
165}
166EXPORT_SYMBOL_GPL(pcf50633_adc_async_read);
167
168static int adc_result(struct pcf50633 *pcf)
169{
170 u8 adcs1, adcs3;
171 u16 result;
172
173 adcs1 = pcf50633_reg_read(pcf, PCF50633_REG_ADCS1);
174 adcs3 = pcf50633_reg_read(pcf, PCF50633_REG_ADCS3);
175 result = (adcs1 << 2) | (adcs3 & PCF50633_ADCS3_ADCDAT1L_MASK);
176
177 dev_dbg(pcf->dev, "adc result = %d\n", result);
178
179 return result;
180}
181
182static void pcf50633_adc_irq(int irq, void *data)
183{
184 struct pcf50633_adc *adc = data;
185 struct pcf50633 *pcf = adc->pcf;
186 struct pcf50633_adc_request *req;
187 int head;
188
189 mutex_lock(&adc->queue_mutex);
190 head = adc->queue_head;
191
192 req = adc->queue[head];
193 if (WARN_ON(!req)) {
194 dev_err(pcf->dev, "pcf50633-adc irq: ADC queue empty!\n");
195 mutex_unlock(&adc->queue_mutex);
196 return;
197 }
198 adc->queue[head] = NULL;
199 adc->queue_head = (head + 1) &
200 (PCF50633_MAX_ADC_FIFO_DEPTH - 1);
201
202 mutex_unlock(&adc->queue_mutex);
203
204 req->callback(pcf, req->callback_param, adc_result(pcf));
205 kfree(req);
206
207 trigger_next_adc_job_if_any(pcf);
208}
209
210static int __devinit pcf50633_adc_probe(struct platform_device *pdev)
211{
212 struct pcf50633_subdev_pdata *pdata = pdev->dev.platform_data;
213 struct pcf50633_adc *adc;
214
215 adc = kzalloc(sizeof(*adc), GFP_KERNEL);
216 if (!adc)
217 return -ENOMEM;
218
219 adc->pcf = pdata->pcf;
220 platform_set_drvdata(pdev, adc);
221
222 pcf50633_register_irq(pdata->pcf, PCF50633_IRQ_ADCRDY,
223 pcf50633_adc_irq, adc);
224
225 mutex_init(&adc->queue_mutex);
226
227 return 0;
228}
229
230static int __devexit pcf50633_adc_remove(struct platform_device *pdev)
231{
232 struct pcf50633_adc *adc = platform_get_drvdata(pdev);
233 int i, head;
234
235 pcf50633_free_irq(adc->pcf, PCF50633_IRQ_ADCRDY);
236
237 mutex_lock(&adc->queue_mutex);
238 head = adc->queue_head;
239
240 if (WARN_ON(adc->queue[head]))
241 dev_err(adc->pcf->dev,
242 "adc driver removed with request pending\n");
243
244 for (i = 0; i < PCF50633_MAX_ADC_FIFO_DEPTH; i++)
245 kfree(adc->queue[i]);
246
247 mutex_unlock(&adc->queue_mutex);
248 kfree(adc);
249
250 return 0;
251}
252
253static struct platform_driver pcf50633_adc_driver = {
254 .driver = {
255 .name = "pcf50633-adc",
256 },
257 .probe = pcf50633_adc_probe,
258 .remove = __devexit_p(pcf50633_adc_remove),
259};
260
261static int __init pcf50633_adc_init(void)
262{
263 return platform_driver_register(&pcf50633_adc_driver);
264}
265module_init(pcf50633_adc_init);
266
267static void __exit pcf50633_adc_exit(void)
268{
269 platform_driver_unregister(&pcf50633_adc_driver);
270}
271module_exit(pcf50633_adc_exit);
272
273MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>");
274MODULE_DESCRIPTION("PCF50633 adc driver");
275MODULE_LICENSE("GPL");
276MODULE_ALIAS("platform:pcf50633-adc");
277
diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c
new file mode 100644
index 000000000000..24508e28e3fb
--- /dev/null
+++ b/drivers/mfd/pcf50633-core.c
@@ -0,0 +1,710 @@
1/* NXP PCF50633 Power Management Unit (PMU) driver
2 *
3 * (C) 2006-2008 by Openmoko, Inc.
4 * Author: Harald Welte <laforge@openmoko.org>
5 * Balaji Rao <balajirrao@openmoko.org>
6 * All rights reserved.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */
14
15#include <linux/kernel.h>
16#include <linux/device.h>
17#include <linux/sysfs.h>
18#include <linux/device.h>
19#include <linux/module.h>
20#include <linux/types.h>
21#include <linux/interrupt.h>
22#include <linux/workqueue.h>
23#include <linux/platform_device.h>
24#include <linux/i2c.h>
25#include <linux/irq.h>
26
27#include <linux/mfd/pcf50633/core.h>
28
29/* Two MBCS registers used during cold start */
30#define PCF50633_REG_MBCS1 0x4b
31#define PCF50633_REG_MBCS2 0x4c
32#define PCF50633_MBCS1_USBPRES 0x01
33#define PCF50633_MBCS1_ADAPTPRES 0x01
34
35static int __pcf50633_read(struct pcf50633 *pcf, u8 reg, int num, u8 *data)
36{
37 int ret;
38
39 ret = i2c_smbus_read_i2c_block_data(pcf->i2c_client, reg,
40 num, data);
41 if (ret < 0)
42 dev_err(pcf->dev, "Error reading %d regs at %d\n", num, reg);
43
44 return ret;
45}
46
47static int __pcf50633_write(struct pcf50633 *pcf, u8 reg, int num, u8 *data)
48{
49 int ret;
50
51 ret = i2c_smbus_write_i2c_block_data(pcf->i2c_client, reg,
52 num, data);
53 if (ret < 0)
54 dev_err(pcf->dev, "Error writing %d regs at %d\n", num, reg);
55
56 return ret;
57
58}
59
60/* Read a block of upto 32 regs */
61int pcf50633_read_block(struct pcf50633 *pcf, u8 reg,
62 int nr_regs, u8 *data)
63{
64 int ret;
65
66 mutex_lock(&pcf->lock);
67 ret = __pcf50633_read(pcf, reg, nr_regs, data);
68 mutex_unlock(&pcf->lock);
69
70 return ret;
71}
72EXPORT_SYMBOL_GPL(pcf50633_read_block);
73
74/* Write a block of upto 32 regs */
75int pcf50633_write_block(struct pcf50633 *pcf , u8 reg,
76 int nr_regs, u8 *data)
77{
78 int ret;
79
80 mutex_lock(&pcf->lock);
81 ret = __pcf50633_write(pcf, reg, nr_regs, data);
82 mutex_unlock(&pcf->lock);
83
84 return ret;
85}
86EXPORT_SYMBOL_GPL(pcf50633_write_block);
87
88u8 pcf50633_reg_read(struct pcf50633 *pcf, u8 reg)
89{
90 u8 val;
91
92 mutex_lock(&pcf->lock);
93 __pcf50633_read(pcf, reg, 1, &val);
94 mutex_unlock(&pcf->lock);
95
96 return val;
97}
98EXPORT_SYMBOL_GPL(pcf50633_reg_read);
99
100int pcf50633_reg_write(struct pcf50633 *pcf, u8 reg, u8 val)
101{
102 int ret;
103
104 mutex_lock(&pcf->lock);
105 ret = __pcf50633_write(pcf, reg, 1, &val);
106 mutex_unlock(&pcf->lock);
107
108 return ret;
109}
110EXPORT_SYMBOL_GPL(pcf50633_reg_write);
111
112int pcf50633_reg_set_bit_mask(struct pcf50633 *pcf, u8 reg, u8 mask, u8 val)
113{
114 int ret;
115 u8 tmp;
116
117 val &= mask;
118
119 mutex_lock(&pcf->lock);
120 ret = __pcf50633_read(pcf, reg, 1, &tmp);
121 if (ret < 0)
122 goto out;
123
124 tmp &= ~mask;
125 tmp |= val;
126 ret = __pcf50633_write(pcf, reg, 1, &tmp);
127
128out:
129 mutex_unlock(&pcf->lock);
130
131 return ret;
132}
133EXPORT_SYMBOL_GPL(pcf50633_reg_set_bit_mask);
134
135int pcf50633_reg_clear_bits(struct pcf50633 *pcf, u8 reg, u8 val)
136{
137 int ret;
138 u8 tmp;
139
140 mutex_lock(&pcf->lock);
141 ret = __pcf50633_read(pcf, reg, 1, &tmp);
142 if (ret < 0)
143 goto out;
144
145 tmp &= ~val;
146 ret = __pcf50633_write(pcf, reg, 1, &tmp);
147
148out:
149 mutex_unlock(&pcf->lock);
150
151 return ret;
152}
153EXPORT_SYMBOL_GPL(pcf50633_reg_clear_bits);
154
155/* sysfs attributes */
156static ssize_t show_dump_regs(struct device *dev, struct device_attribute *attr,
157 char *buf)
158{
159 struct pcf50633 *pcf = dev_get_drvdata(dev);
160 u8 dump[16];
161 int n, n1, idx = 0;
162 char *buf1 = buf;
163 static u8 address_no_read[] = { /* must be ascending */
164 PCF50633_REG_INT1,
165 PCF50633_REG_INT2,
166 PCF50633_REG_INT3,
167 PCF50633_REG_INT4,
168 PCF50633_REG_INT5,
169 0 /* terminator */
170 };
171
172 for (n = 0; n < 256; n += sizeof(dump)) {
173 for (n1 = 0; n1 < sizeof(dump); n1++)
174 if (n == address_no_read[idx]) {
175 idx++;
176 dump[n1] = 0x00;
177 } else
178 dump[n1] = pcf50633_reg_read(pcf, n + n1);
179
180 hex_dump_to_buffer(dump, sizeof(dump), 16, 1, buf1, 128, 0);
181 buf1 += strlen(buf1);
182 *buf1++ = '\n';
183 *buf1 = '\0';
184 }
185
186 return buf1 - buf;
187}
188static DEVICE_ATTR(dump_regs, 0400, show_dump_regs, NULL);
189
190static ssize_t show_resume_reason(struct device *dev,
191 struct device_attribute *attr, char *buf)
192{
193 struct pcf50633 *pcf = dev_get_drvdata(dev);
194 int n;
195
196 n = sprintf(buf, "%02x%02x%02x%02x%02x\n",
197 pcf->resume_reason[0],
198 pcf->resume_reason[1],
199 pcf->resume_reason[2],
200 pcf->resume_reason[3],
201 pcf->resume_reason[4]);
202
203 return n;
204}
205static DEVICE_ATTR(resume_reason, 0400, show_resume_reason, NULL);
206
207static struct attribute *pcf_sysfs_entries[] = {
208 &dev_attr_dump_regs.attr,
209 &dev_attr_resume_reason.attr,
210 NULL,
211};
212
213static struct attribute_group pcf_attr_group = {
214 .name = NULL, /* put in device directory */
215 .attrs = pcf_sysfs_entries,
216};
217
218int pcf50633_register_irq(struct pcf50633 *pcf, int irq,
219 void (*handler) (int, void *), void *data)
220{
221 if (irq < 0 || irq > PCF50633_NUM_IRQ || !handler)
222 return -EINVAL;
223
224 if (WARN_ON(pcf->irq_handler[irq].handler))
225 return -EBUSY;
226
227 mutex_lock(&pcf->lock);
228 pcf->irq_handler[irq].handler = handler;
229 pcf->irq_handler[irq].data = data;
230 mutex_unlock(&pcf->lock);
231
232 return 0;
233}
234EXPORT_SYMBOL_GPL(pcf50633_register_irq);
235
236int pcf50633_free_irq(struct pcf50633 *pcf, int irq)
237{
238 if (irq < 0 || irq > PCF50633_NUM_IRQ)
239 return -EINVAL;
240
241 mutex_lock(&pcf->lock);
242 pcf->irq_handler[irq].handler = NULL;
243 mutex_unlock(&pcf->lock);
244
245 return 0;
246}
247EXPORT_SYMBOL_GPL(pcf50633_free_irq);
248
249static int __pcf50633_irq_mask_set(struct pcf50633 *pcf, int irq, u8 mask)
250{
251 u8 reg, bits, tmp;
252 int ret = 0, idx;
253
254 idx = irq >> 3;
255 reg = PCF50633_REG_INT1M + idx;
256 bits = 1 << (irq & 0x07);
257
258 mutex_lock(&pcf->lock);
259
260 if (mask) {
261 ret = __pcf50633_read(pcf, reg, 1, &tmp);
262 if (ret < 0)
263 goto out;
264
265 tmp |= bits;
266
267 ret = __pcf50633_write(pcf, reg, 1, &tmp);
268 if (ret < 0)
269 goto out;
270
271 pcf->mask_regs[idx] &= ~bits;
272 pcf->mask_regs[idx] |= bits;
273 } else {
274 ret = __pcf50633_read(pcf, reg, 1, &tmp);
275 if (ret < 0)
276 goto out;
277
278 tmp &= ~bits;
279
280 ret = __pcf50633_write(pcf, reg, 1, &tmp);
281 if (ret < 0)
282 goto out;
283
284 pcf->mask_regs[idx] &= ~bits;
285 }
286out:
287 mutex_unlock(&pcf->lock);
288
289 return ret;
290}
291
292int pcf50633_irq_mask(struct pcf50633 *pcf, int irq)
293{
294 dev_info(pcf->dev, "Masking IRQ %d\n", irq);
295
296 return __pcf50633_irq_mask_set(pcf, irq, 1);
297}
298EXPORT_SYMBOL_GPL(pcf50633_irq_mask);
299
300int pcf50633_irq_unmask(struct pcf50633 *pcf, int irq)
301{
302 dev_info(pcf->dev, "Unmasking IRQ %d\n", irq);
303
304 return __pcf50633_irq_mask_set(pcf, irq, 0);
305}
306EXPORT_SYMBOL_GPL(pcf50633_irq_unmask);
307
308int pcf50633_irq_mask_get(struct pcf50633 *pcf, int irq)
309{
310 u8 reg, bits;
311
312 reg = irq >> 3;
313 bits = 1 << (irq & 0x07);
314
315 return pcf->mask_regs[reg] & bits;
316}
317EXPORT_SYMBOL_GPL(pcf50633_irq_mask_get);
318
319static void pcf50633_irq_call_handler(struct pcf50633 *pcf, int irq)
320{
321 if (pcf->irq_handler[irq].handler)
322 pcf->irq_handler[irq].handler(irq, pcf->irq_handler[irq].data);
323}
324
325/* Maximum amount of time ONKEY is held before emergency action is taken */
326#define PCF50633_ONKEY1S_TIMEOUT 8
327
328static void pcf50633_irq_worker(struct work_struct *work)
329{
330 struct pcf50633 *pcf;
331 int ret, i, j;
332 u8 pcf_int[5], chgstat;
333
334 pcf = container_of(work, struct pcf50633, irq_work);
335
336 /* Read the 5 INT regs in one transaction */
337 ret = pcf50633_read_block(pcf, PCF50633_REG_INT1,
338 ARRAY_SIZE(pcf_int), pcf_int);
339 if (ret != ARRAY_SIZE(pcf_int)) {
340 dev_err(pcf->dev, "Error reading INT registers\n");
341
342 /*
343 * If this doesn't ACK the interrupt to the chip, we'll be
344 * called once again as we're level triggered.
345 */
346 goto out;
347 }
348
349 /* We immediately read the usb and adapter status. We thus make sure
350 * only of USBINS/USBREM IRQ handlers are called */
351 if (pcf_int[0] & (PCF50633_INT1_USBINS | PCF50633_INT1_USBREM)) {
352 chgstat = pcf50633_reg_read(pcf, PCF50633_REG_MBCS2);
353 if (chgstat & (0x3 << 4))
354 pcf_int[0] &= ~(1 << PCF50633_INT1_USBREM);
355 else
356 pcf_int[0] &= ~(1 << PCF50633_INT1_USBINS);
357 }
358
359 /* Make sure only one of ADPINS or ADPREM is set */
360 if (pcf_int[0] & (PCF50633_INT1_ADPINS | PCF50633_INT1_ADPREM)) {
361 chgstat = pcf50633_reg_read(pcf, PCF50633_REG_MBCS2);
362 if (chgstat & (0x3 << 4))
363 pcf_int[0] &= ~(1 << PCF50633_INT1_ADPREM);
364 else
365 pcf_int[0] &= ~(1 << PCF50633_INT1_ADPINS);
366 }
367
368 dev_dbg(pcf->dev, "INT1=0x%02x INT2=0x%02x INT3=0x%02x "
369 "INT4=0x%02x INT5=0x%02x\n", pcf_int[0],
370 pcf_int[1], pcf_int[2], pcf_int[3], pcf_int[4]);
371
372 /* Some revisions of the chip don't have a 8s standby mode on
373 * ONKEY1S press. We try to manually do it in such cases. */
374 if ((pcf_int[0] & PCF50633_INT1_SECOND) && pcf->onkey1s_held) {
375 dev_info(pcf->dev, "ONKEY1S held for %d secs\n",
376 pcf->onkey1s_held);
377 if (pcf->onkey1s_held++ == PCF50633_ONKEY1S_TIMEOUT)
378 if (pcf->pdata->force_shutdown)
379 pcf->pdata->force_shutdown(pcf);
380 }
381
382 if (pcf_int[2] & PCF50633_INT3_ONKEY1S) {
383 dev_info(pcf->dev, "ONKEY1S held\n");
384 pcf->onkey1s_held = 1 ;
385
386 /* Unmask IRQ_SECOND */
387 pcf50633_reg_clear_bits(pcf, PCF50633_REG_INT1M,
388 PCF50633_INT1_SECOND);
389
390 /* Unmask IRQ_ONKEYR */
391 pcf50633_reg_clear_bits(pcf, PCF50633_REG_INT2M,
392 PCF50633_INT2_ONKEYR);
393 }
394
395 if ((pcf_int[1] & PCF50633_INT2_ONKEYR) && pcf->onkey1s_held) {
396 pcf->onkey1s_held = 0;
397
398 /* Mask SECOND and ONKEYR interrupts */
399 if (pcf->mask_regs[0] & PCF50633_INT1_SECOND)
400 pcf50633_reg_set_bit_mask(pcf,
401 PCF50633_REG_INT1M,
402 PCF50633_INT1_SECOND,
403 PCF50633_INT1_SECOND);
404
405 if (pcf->mask_regs[1] & PCF50633_INT2_ONKEYR)
406 pcf50633_reg_set_bit_mask(pcf,
407 PCF50633_REG_INT2M,
408 PCF50633_INT2_ONKEYR,
409 PCF50633_INT2_ONKEYR);
410 }
411
412 /* Have we just resumed ? */
413 if (pcf->is_suspended) {
414 pcf->is_suspended = 0;
415
416 /* Set the resume reason filtering out non resumers */
417 for (i = 0; i < ARRAY_SIZE(pcf_int); i++)
418 pcf->resume_reason[i] = pcf_int[i] &
419 pcf->pdata->resumers[i];
420
421 /* Make sure we don't pass on any ONKEY events to
422 * userspace now */
423 pcf_int[1] &= ~(PCF50633_INT2_ONKEYR | PCF50633_INT2_ONKEYF);
424 }
425
426 for (i = 0; i < ARRAY_SIZE(pcf_int); i++) {
427 /* Unset masked interrupts */
428 pcf_int[i] &= ~pcf->mask_regs[i];
429
430 for (j = 0; j < 8 ; j++)
431 if (pcf_int[i] & (1 << j))
432 pcf50633_irq_call_handler(pcf, (i * 8) + j);
433 }
434
435out:
436 put_device(pcf->dev);
437 enable_irq(pcf->irq);
438}
439
440static irqreturn_t pcf50633_irq(int irq, void *data)
441{
442 struct pcf50633 *pcf = data;
443
444 dev_dbg(pcf->dev, "pcf50633_irq\n");
445
446 get_device(pcf->dev);
447 disable_irq(pcf->irq);
448 schedule_work(&pcf->irq_work);
449
450 return IRQ_HANDLED;
451}
452
453static void
454pcf50633_client_dev_register(struct pcf50633 *pcf, const char *name,
455 struct platform_device **pdev)
456{
457 struct pcf50633_subdev_pdata *subdev_pdata;
458 int ret;
459
460 *pdev = platform_device_alloc(name, -1);
461 if (!*pdev) {
462 dev_err(pcf->dev, "Falied to allocate %s\n", name);
463 return;
464 }
465
466 subdev_pdata = kmalloc(sizeof(*subdev_pdata), GFP_KERNEL);
467 if (!subdev_pdata) {
468 dev_err(pcf->dev, "Error allocating subdev pdata\n");
469 platform_device_put(*pdev);
470 }
471
472 subdev_pdata->pcf = pcf;
473 platform_device_add_data(*pdev, subdev_pdata, sizeof(*subdev_pdata));
474
475 (*pdev)->dev.parent = pcf->dev;
476
477 ret = platform_device_add(*pdev);
478 if (ret) {
479 dev_err(pcf->dev, "Failed to register %s: %d\n", name, ret);
480 platform_device_put(*pdev);
481 *pdev = NULL;
482 }
483}
484
485#ifdef CONFIG_PM
486static int pcf50633_suspend(struct device *dev, pm_message_t state)
487{
488 struct pcf50633 *pcf;
489 int ret = 0, i;
490 u8 res[5];
491
492 pcf = dev_get_drvdata(dev);
493
494 /* Make sure our interrupt handlers are not called
495 * henceforth */
496 disable_irq(pcf->irq);
497
498 /* Make sure that any running IRQ worker has quit */
499 cancel_work_sync(&pcf->irq_work);
500
501 /* Save the masks */
502 ret = pcf50633_read_block(pcf, PCF50633_REG_INT1M,
503 ARRAY_SIZE(pcf->suspend_irq_masks),
504 pcf->suspend_irq_masks);
505 if (ret < 0) {
506 dev_err(pcf->dev, "error saving irq masks\n");
507 goto out;
508 }
509
510 /* Write wakeup irq masks */
511 for (i = 0; i < ARRAY_SIZE(res); i++)
512 res[i] = ~pcf->pdata->resumers[i];
513
514 ret = pcf50633_write_block(pcf, PCF50633_REG_INT1M,
515 ARRAY_SIZE(res), &res[0]);
516 if (ret < 0) {
517 dev_err(pcf->dev, "error writing wakeup irq masks\n");
518 goto out;
519 }
520
521 pcf->is_suspended = 1;
522
523out:
524 return ret;
525}
526
527static int pcf50633_resume(struct device *dev)
528{
529 struct pcf50633 *pcf;
530 int ret;
531
532 pcf = dev_get_drvdata(dev);
533
534 /* Write the saved mask registers */
535 ret = pcf50633_write_block(pcf, PCF50633_REG_INT1M,
536 ARRAY_SIZE(pcf->suspend_irq_masks),
537 pcf->suspend_irq_masks);
538 if (ret < 0)
539 dev_err(pcf->dev, "Error restoring saved suspend masks\n");
540
541 /* Restore regulators' state */
542
543
544 get_device(pcf->dev);
545
546 /*
547 * Clear any pending interrupts and set resume reason if any.
548 * This will leave with enable_irq()
549 */
550 pcf50633_irq_worker(&pcf->irq_work);
551
552 return 0;
553}
554#else
555#define pcf50633_suspend NULL
556#define pcf50633_resume NULL
557#endif
558
559static int __devinit pcf50633_probe(struct i2c_client *client,
560 const struct i2c_device_id *ids)
561{
562 struct pcf50633 *pcf;
563 struct pcf50633_platform_data *pdata = client->dev.platform_data;
564 int i, ret = 0;
565 int version, variant;
566
567 pcf = kzalloc(sizeof(*pcf), GFP_KERNEL);
568 if (!pcf)
569 return -ENOMEM;
570
571 pcf->pdata = pdata;
572
573 mutex_init(&pcf->lock);
574
575 i2c_set_clientdata(client, pcf);
576 pcf->dev = &client->dev;
577 pcf->i2c_client = client;
578 pcf->irq = client->irq;
579
580 INIT_WORK(&pcf->irq_work, pcf50633_irq_worker);
581
582 version = pcf50633_reg_read(pcf, 0);
583 variant = pcf50633_reg_read(pcf, 1);
584 if (version < 0 || variant < 0) {
585 dev_err(pcf->dev, "Unable to probe pcf50633\n");
586 ret = -ENODEV;
587 goto err;
588 }
589
590 dev_info(pcf->dev, "Probed device version %d variant %d\n",
591 version, variant);
592
593 /* Enable all interrupts except RTC SECOND */
594 pcf->mask_regs[0] = 0x80;
595 pcf50633_reg_write(pcf, PCF50633_REG_INT1M, pcf->mask_regs[0]);
596 pcf50633_reg_write(pcf, PCF50633_REG_INT2M, 0x00);
597 pcf50633_reg_write(pcf, PCF50633_REG_INT3M, 0x00);
598 pcf50633_reg_write(pcf, PCF50633_REG_INT4M, 0x00);
599 pcf50633_reg_write(pcf, PCF50633_REG_INT5M, 0x00);
600
601 /* Create sub devices */
602 pcf50633_client_dev_register(pcf, "pcf50633-input",
603 &pcf->input_pdev);
604 pcf50633_client_dev_register(pcf, "pcf50633-rtc",
605 &pcf->rtc_pdev);
606 pcf50633_client_dev_register(pcf, "pcf50633-mbc",
607 &pcf->mbc_pdev);
608 pcf50633_client_dev_register(pcf, "pcf50633-adc",
609 &pcf->adc_pdev);
610
611 for (i = 0; i < PCF50633_NUM_REGULATORS; i++) {
612 struct platform_device *pdev;
613
614 pdev = platform_device_alloc("pcf50633-regltr", i);
615 if (!pdev) {
616 dev_err(pcf->dev, "Cannot create regulator\n");
617 continue;
618 }
619
620 pdev->dev.parent = pcf->dev;
621 pdev->dev.platform_data = &pdata->reg_init_data[i];
622 pdev->dev.driver_data = pcf;
623 pcf->regulator_pdev[i] = pdev;
624
625 platform_device_add(pdev);
626 }
627
628 if (client->irq) {
629 set_irq_handler(client->irq, handle_level_irq);
630 ret = request_irq(client->irq, pcf50633_irq,
631 IRQF_TRIGGER_LOW, "pcf50633", pcf);
632
633 if (ret) {
634 dev_err(pcf->dev, "Failed to request IRQ %d\n", ret);
635 goto err;
636 }
637 } else {
638 dev_err(pcf->dev, "No IRQ configured\n");
639 goto err;
640 }
641
642 if (enable_irq_wake(client->irq) < 0)
643 dev_err(pcf->dev, "IRQ %u cannot be enabled as wake-up source"
644 "in this hardware revision", client->irq);
645
646 ret = sysfs_create_group(&client->dev.kobj, &pcf_attr_group);
647 if (ret)
648 dev_err(pcf->dev, "error creating sysfs entries\n");
649
650 if (pdata->probe_done)
651 pdata->probe_done(pcf);
652
653 return 0;
654
655err:
656 kfree(pcf);
657 return ret;
658}
659
660static int __devexit pcf50633_remove(struct i2c_client *client)
661{
662 struct pcf50633 *pcf = i2c_get_clientdata(client);
663 int i;
664
665 free_irq(pcf->irq, pcf);
666
667 platform_device_unregister(pcf->input_pdev);
668 platform_device_unregister(pcf->rtc_pdev);
669 platform_device_unregister(pcf->mbc_pdev);
670 platform_device_unregister(pcf->adc_pdev);
671
672 for (i = 0; i < PCF50633_NUM_REGULATORS; i++)
673 platform_device_unregister(pcf->regulator_pdev[i]);
674
675 kfree(pcf);
676
677 return 0;
678}
679
680static struct i2c_device_id pcf50633_id_table[] = {
681 {"pcf50633", 0x73},
682};
683
684static struct i2c_driver pcf50633_driver = {
685 .driver = {
686 .name = "pcf50633",
687 .suspend = pcf50633_suspend,
688 .resume = pcf50633_resume,
689 },
690 .id_table = pcf50633_id_table,
691 .probe = pcf50633_probe,
692 .remove = __devexit_p(pcf50633_remove),
693};
694
695static int __init pcf50633_init(void)
696{
697 return i2c_add_driver(&pcf50633_driver);
698}
699
700static void __exit pcf50633_exit(void)
701{
702 i2c_del_driver(&pcf50633_driver);
703}
704
705MODULE_DESCRIPTION("I2C chip driver for NXP PCF50633 PMU");
706MODULE_AUTHOR("Harald Welte <laforge@openmoko.org>");
707MODULE_LICENSE("GPL");
708
709module_init(pcf50633_init);
710module_exit(pcf50633_exit);
diff --git a/drivers/mfd/pcf50633-gpio.c b/drivers/mfd/pcf50633-gpio.c
new file mode 100644
index 000000000000..2fa2eca5c9cc
--- /dev/null
+++ b/drivers/mfd/pcf50633-gpio.c
@@ -0,0 +1,118 @@
1/* NXP PCF50633 GPIO Driver
2 *
3 * (C) 2006-2008 by Openmoko, Inc.
4 * Author: Balaji Rao <balajirrao@openmoko.org>
5 * All rights reserved.
6 *
7 * Broken down from monstrous PCF50633 driver mainly by
8 * Harald Welte, Andy Green and Werner Almesberger
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#include <linux/kernel.h>
18
19#include <linux/mfd/pcf50633/core.h>
20#include <linux/mfd/pcf50633/gpio.h>
21
22enum pcf50633_regulator_id {
23 PCF50633_REGULATOR_AUTO,
24 PCF50633_REGULATOR_DOWN1,
25 PCF50633_REGULATOR_DOWN2,
26 PCF50633_REGULATOR_LDO1,
27 PCF50633_REGULATOR_LDO2,
28 PCF50633_REGULATOR_LDO3,
29 PCF50633_REGULATOR_LDO4,
30 PCF50633_REGULATOR_LDO5,
31 PCF50633_REGULATOR_LDO6,
32 PCF50633_REGULATOR_HCLDO,
33 PCF50633_REGULATOR_MEMLDO,
34};
35
36#define PCF50633_REG_AUTOOUT 0x1a
37#define PCF50633_REG_DOWN1OUT 0x1e
38#define PCF50633_REG_DOWN2OUT 0x22
39#define PCF50633_REG_MEMLDOOUT 0x26
40#define PCF50633_REG_LDO1OUT 0x2d
41#define PCF50633_REG_LDO2OUT 0x2f
42#define PCF50633_REG_LDO3OUT 0x31
43#define PCF50633_REG_LDO4OUT 0x33
44#define PCF50633_REG_LDO5OUT 0x35
45#define PCF50633_REG_LDO6OUT 0x37
46#define PCF50633_REG_HCLDOOUT 0x39
47
48static const u8 pcf50633_regulator_registers[PCF50633_NUM_REGULATORS] = {
49 [PCF50633_REGULATOR_AUTO] = PCF50633_REG_AUTOOUT,
50 [PCF50633_REGULATOR_DOWN1] = PCF50633_REG_DOWN1OUT,
51 [PCF50633_REGULATOR_DOWN2] = PCF50633_REG_DOWN2OUT,
52 [PCF50633_REGULATOR_MEMLDO] = PCF50633_REG_MEMLDOOUT,
53 [PCF50633_REGULATOR_LDO1] = PCF50633_REG_LDO1OUT,
54 [PCF50633_REGULATOR_LDO2] = PCF50633_REG_LDO2OUT,
55 [PCF50633_REGULATOR_LDO3] = PCF50633_REG_LDO3OUT,
56 [PCF50633_REGULATOR_LDO4] = PCF50633_REG_LDO4OUT,
57 [PCF50633_REGULATOR_LDO5] = PCF50633_REG_LDO5OUT,
58 [PCF50633_REGULATOR_LDO6] = PCF50633_REG_LDO6OUT,
59 [PCF50633_REGULATOR_HCLDO] = PCF50633_REG_HCLDOOUT,
60};
61
62int pcf50633_gpio_set(struct pcf50633 *pcf, int gpio, u8 val)
63{
64 u8 reg;
65
66 reg = gpio - PCF50633_GPIO1 + PCF50633_REG_GPIO1CFG;
67
68 return pcf50633_reg_set_bit_mask(pcf, reg, 0x07, val);
69}
70EXPORT_SYMBOL_GPL(pcf50633_gpio_set);
71
72u8 pcf50633_gpio_get(struct pcf50633 *pcf, int gpio)
73{
74 u8 reg, val;
75
76 reg = gpio - PCF50633_GPIO1 + PCF50633_REG_GPIO1CFG;
77 val = pcf50633_reg_read(pcf, reg) & 0x07;
78
79 return val;
80}
81EXPORT_SYMBOL_GPL(pcf50633_gpio_get);
82
83int pcf50633_gpio_invert_set(struct pcf50633 *pcf, int gpio, int invert)
84{
85 u8 val, reg;
86
87 reg = gpio - PCF50633_GPIO1 + PCF50633_REG_GPIO1CFG;
88 val = !!invert << 3;
89
90 return pcf50633_reg_set_bit_mask(pcf, reg, 1 << 3, val);
91}
92EXPORT_SYMBOL_GPL(pcf50633_gpio_invert_set);
93
94int pcf50633_gpio_invert_get(struct pcf50633 *pcf, int gpio)
95{
96 u8 reg, val;
97
98 reg = gpio - PCF50633_GPIO1 + PCF50633_REG_GPIO1CFG;
99 val = pcf50633_reg_read(pcf, reg);
100
101 return val & (1 << 3);
102}
103EXPORT_SYMBOL_GPL(pcf50633_gpio_invert_get);
104
105int pcf50633_gpio_power_supply_set(struct pcf50633 *pcf,
106 int gpio, int regulator, int on)
107{
108 u8 reg, val, mask;
109
110 /* the *ENA register is always one after the *OUT register */
111 reg = pcf50633_regulator_registers[regulator] + 1;
112
113 val = !!on << (gpio - PCF50633_GPIO1);
114 mask = 1 << (gpio - PCF50633_GPIO1);
115
116 return pcf50633_reg_set_bit_mask(pcf, reg, mask, val);
117}
118EXPORT_SYMBOL_GPL(pcf50633_gpio_power_supply_set);
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
index 170f9d47c2f9..0e5761f12634 100644
--- a/drivers/mfd/sm501.c
+++ b/drivers/mfd/sm501.c
@@ -41,6 +41,7 @@ struct sm501_gpio_chip {
41 struct gpio_chip gpio; 41 struct gpio_chip gpio;
42 struct sm501_gpio *ourgpio; /* to get back to parent. */ 42 struct sm501_gpio *ourgpio; /* to get back to parent. */
43 void __iomem *regbase; 43 void __iomem *regbase;
44 void __iomem *control; /* address of control reg. */
44}; 45};
45 46
46struct sm501_gpio { 47struct sm501_gpio {
@@ -908,6 +909,25 @@ static int sm501_gpio_get(struct gpio_chip *chip, unsigned offset)
908 return result & 1UL; 909 return result & 1UL;
909} 910}
910 911
912static void sm501_gpio_ensure_gpio(struct sm501_gpio_chip *smchip,
913 unsigned long bit)
914{
915 unsigned long ctrl;
916
917 /* check and modify if this pin is not set as gpio. */
918
919 if (readl(smchip->control) & bit) {
920 dev_info(sm501_gpio_to_dev(smchip->ourgpio)->dev,
921 "changing mode of gpio, bit %08lx\n", bit);
922
923 ctrl = readl(smchip->control);
924 ctrl &= ~bit;
925 writel(ctrl, smchip->control);
926
927 sm501_sync_regs(sm501_gpio_to_dev(smchip->ourgpio));
928 }
929}
930
911static void sm501_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 931static void sm501_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
912 932
913{ 933{
@@ -929,6 +949,8 @@ static void sm501_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
929 writel(val, regs); 949 writel(val, regs);
930 950
931 sm501_sync_regs(sm501_gpio_to_dev(smgpio)); 951 sm501_sync_regs(sm501_gpio_to_dev(smgpio));
952 sm501_gpio_ensure_gpio(smchip, bit);
953
932 spin_unlock_irqrestore(&smgpio->lock, save); 954 spin_unlock_irqrestore(&smgpio->lock, save);
933} 955}
934 956
@@ -941,8 +963,8 @@ static int sm501_gpio_input(struct gpio_chip *chip, unsigned offset)
941 unsigned long save; 963 unsigned long save;
942 unsigned long ddr; 964 unsigned long ddr;
943 965
944 dev_info(sm501_gpio_to_dev(smgpio)->dev, "%s(%p,%d)\n", 966 dev_dbg(sm501_gpio_to_dev(smgpio)->dev, "%s(%p,%d)\n",
945 __func__, chip, offset); 967 __func__, chip, offset);
946 968
947 spin_lock_irqsave(&smgpio->lock, save); 969 spin_lock_irqsave(&smgpio->lock, save);
948 970
@@ -950,6 +972,8 @@ static int sm501_gpio_input(struct gpio_chip *chip, unsigned offset)
950 writel(ddr & ~bit, regs + SM501_GPIO_DDR_LOW); 972 writel(ddr & ~bit, regs + SM501_GPIO_DDR_LOW);
951 973
952 sm501_sync_regs(sm501_gpio_to_dev(smgpio)); 974 sm501_sync_regs(sm501_gpio_to_dev(smgpio));
975 sm501_gpio_ensure_gpio(smchip, bit);
976
953 spin_unlock_irqrestore(&smgpio->lock, save); 977 spin_unlock_irqrestore(&smgpio->lock, save);
954 978
955 return 0; 979 return 0;
@@ -1012,9 +1036,11 @@ static int __devinit sm501_gpio_register_chip(struct sm501_devdata *sm,
1012 if (base > 0) 1036 if (base > 0)
1013 base += 32; 1037 base += 32;
1014 chip->regbase = gpio->regs + SM501_GPIO_DATA_HIGH; 1038 chip->regbase = gpio->regs + SM501_GPIO_DATA_HIGH;
1039 chip->control = sm->regs + SM501_GPIO63_32_CONTROL;
1015 gchip->label = "SM501-HIGH"; 1040 gchip->label = "SM501-HIGH";
1016 } else { 1041 } else {
1017 chip->regbase = gpio->regs + SM501_GPIO_DATA_LOW; 1042 chip->regbase = gpio->regs + SM501_GPIO_DATA_LOW;
1043 chip->control = sm->regs + SM501_GPIO31_0_CONTROL;
1018 gchip->label = "SM501-LOW"; 1044 gchip->label = "SM501-LOW";
1019 } 1045 }
1020 1046
diff --git a/drivers/mfd/twl4030-core.c b/drivers/mfd/twl4030-core.c
index b59c385cbc12..e7ab0035d305 100644
--- a/drivers/mfd/twl4030-core.c
+++ b/drivers/mfd/twl4030-core.c
@@ -38,6 +38,9 @@
38#include <linux/i2c.h> 38#include <linux/i2c.h>
39#include <linux/i2c/twl4030.h> 39#include <linux/i2c/twl4030.h>
40 40
41#ifdef CONFIG_ARM
42#include <mach/cpu.h>
43#endif
41 44
42/* 45/*
43 * The TWL4030 "Triton 2" is one of a family of a multi-function "Power 46 * The TWL4030 "Triton 2" is one of a family of a multi-function "Power
@@ -646,7 +649,7 @@ static inline int __init unprotect_pm_master(void)
646 return e; 649 return e;
647} 650}
648 651
649static void __init clocks_init(void) 652static void __init clocks_init(struct device *dev)
650{ 653{
651 int e = 0; 654 int e = 0;
652 struct clk *osc; 655 struct clk *osc;
@@ -655,9 +658,9 @@ static void __init clocks_init(void)
655 658
656#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) 659#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
657 if (cpu_is_omap2430()) 660 if (cpu_is_omap2430())
658 osc = clk_get(NULL, "osc_ck"); 661 osc = clk_get(dev, "osc_ck");
659 else 662 else
660 osc = clk_get(NULL, "osc_sys_ck"); 663 osc = clk_get(dev, "osc_sys_ck");
661 664
662 if (IS_ERR(osc)) { 665 if (IS_ERR(osc)) {
663 printk(KERN_WARNING "Skipping twl4030 internal clock init and " 666 printk(KERN_WARNING "Skipping twl4030 internal clock init and "
@@ -773,7 +776,7 @@ twl4030_probe(struct i2c_client *client, const struct i2c_device_id *id)
773 inuse = true; 776 inuse = true;
774 777
775 /* setup clock framework */ 778 /* setup clock framework */
776 clocks_init(); 779 clocks_init(&client->dev);
777 780
778 /* Maybe init the T2 Interrupt subsystem */ 781 /* Maybe init the T2 Interrupt subsystem */
779 if (client->irq 782 if (client->irq
diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c
index 3a273ccef3f2..f92595c8f165 100644
--- a/drivers/mfd/wm8350-core.c
+++ b/drivers/mfd/wm8350-core.c
@@ -1453,6 +1453,9 @@ void wm8350_device_exit(struct wm8350 *wm8350)
1453{ 1453{
1454 int i; 1454 int i;
1455 1455
1456 for (i = 0; i < ARRAY_SIZE(wm8350->pmic.led); i++)
1457 platform_device_unregister(wm8350->pmic.led[i].pdev);
1458
1456 for (i = 0; i < ARRAY_SIZE(wm8350->pmic.pdev); i++) 1459 for (i = 0; i < ARRAY_SIZE(wm8350->pmic.pdev); i++)
1457 platform_device_unregister(wm8350->pmic.pdev[i]); 1460 platform_device_unregister(wm8350->pmic.pdev[i]);
1458 1461
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index fee7304102af..419c378bd24b 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -120,7 +120,7 @@ config TIFM_CORE
120 cards are supported via 'MMC/SD Card support: TI Flash Media MMC/SD 120 cards are supported via 'MMC/SD Card support: TI Flash Media MMC/SD
121 Interface support (MMC_TIFM_SD)'. 121 Interface support (MMC_TIFM_SD)'.
122 122
123 To compile this driver as a module, choose M here: the module will 123 To compile this driver as a module, choose M here: the module will
124 be called tifm_core. 124 be called tifm_core.
125 125
126config TIFM_7XX1 126config TIFM_7XX1
@@ -133,100 +133,9 @@ config TIFM_7XX1
133 To make actual use of the device, you will have to select some 133 To make actual use of the device, you will have to select some
134 flash card format drivers, as outlined in the TIFM_CORE Help. 134 flash card format drivers, as outlined in the TIFM_CORE Help.
135 135
136 To compile this driver as a module, choose M here: the module will 136 To compile this driver as a module, choose M here: the module will
137 be called tifm_7xx1. 137 be called tifm_7xx1.
138 138
139config ACER_WMI
140 tristate "Acer WMI Laptop Extras (EXPERIMENTAL)"
141 depends on X86
142 depends on EXPERIMENTAL
143 depends on ACPI
144 depends on LEDS_CLASS
145 depends on NEW_LEDS
146 depends on BACKLIGHT_CLASS_DEVICE
147 depends on SERIO_I8042
148 depends on RFKILL
149 select ACPI_WMI
150 ---help---
151 This is a driver for newer Acer (and Wistron) laptops. It adds
152 wireless radio and bluetooth control, and on some laptops,
153 exposes the mail LED and LCD backlight.
154
155 For more information about this driver see
156 <file:Documentation/laptops/acer-wmi.txt>
157
158 If you have an ACPI-WMI compatible Acer/ Wistron laptop, say Y or M
159 here.
160
161config ASUS_LAPTOP
162 tristate "Asus Laptop Extras (EXPERIMENTAL)"
163 depends on X86
164 depends on ACPI
165 depends on EXPERIMENTAL && !ACPI_ASUS
166 depends on LEDS_CLASS
167 depends on NEW_LEDS
168 depends on BACKLIGHT_CLASS_DEVICE
169 ---help---
170 This is the new Linux driver for Asus laptops. It may also support some
171 MEDION, JVC or VICTOR laptops. It makes all the extra buttons generate
172 standard ACPI events that go through /proc/acpi/events. It also adds
173 support for video output switching, LCD backlight control, Bluetooth and
174 Wlan control, and most importantly, allows you to blink those fancy LEDs.
175
176 For more information and a userspace daemon for handling the extra
177 buttons see <http://acpi4asus.sf.net/>.
178
179 If you have an ACPI-compatible ASUS laptop, say Y or M here.
180
181config FUJITSU_LAPTOP
182 tristate "Fujitsu Laptop Extras"
183 depends on X86
184 depends on ACPI
185 depends on INPUT
186 depends on BACKLIGHT_CLASS_DEVICE
187 ---help---
188 This is a driver for laptops built by Fujitsu:
189
190 * P2xxx/P5xxx/S6xxx/S7xxx series Lifebooks
191 * Possibly other Fujitsu laptop models
192 * Tested with S6410 and S7020
193
194 It adds support for LCD brightness control and some hotkeys.
195
196 If you have a Fujitsu laptop, say Y or M here.
197
198config FUJITSU_LAPTOP_DEBUG
199 bool "Verbose debug mode for Fujitsu Laptop Extras"
200 depends on FUJITSU_LAPTOP
201 default n
202 ---help---
203 Enables extra debug output from the fujitsu extras driver, at the
204 expense of a slight increase in driver size.
205
206 If you are not sure, say N here.
207
208config TC1100_WMI
209 tristate "HP Compaq TC1100 Tablet WMI Extras (EXPERIMENTAL)"
210 depends on X86 && !X86_64
211 depends on EXPERIMENTAL
212 depends on ACPI
213 select ACPI_WMI
214 ---help---
215 This is a driver for the WMI extensions (wireless and bluetooth power
216 control) of the HP Compaq TC1100 tablet.
217
218config HP_WMI
219 tristate "HP WMI extras"
220 depends on ACPI_WMI
221 depends on INPUT
222 depends on RFKILL
223 help
224 Say Y here if you want to support WMI-based hotkeys on HP laptops and
225 to read data from WMI such as docking or ambient light sensor state.
226
227 To compile this driver as a module, choose M here: the module will
228 be called hp-wmi.
229
230config ICS932S401 139config ICS932S401
231 tristate "Integrated Circuits ICS932S401" 140 tristate "Integrated Circuits ICS932S401"
232 depends on I2C && EXPERIMENTAL 141 depends on I2C && EXPERIMENTAL
@@ -237,170 +146,6 @@ config ICS932S401
237 This driver can also be built as a module. If so, the module 146 This driver can also be built as a module. If so, the module
238 will be called ics932s401. 147 will be called ics932s401.
239 148
240config MSI_LAPTOP
241 tristate "MSI Laptop Extras"
242 depends on X86
243 depends on ACPI
244 depends on BACKLIGHT_CLASS_DEVICE
245 ---help---
246 This is a driver for laptops built by MSI (MICRO-STAR
247 INTERNATIONAL):
248
249 MSI MegaBook S270 (MS-1013)
250 Cytron/TCM/Medion/Tchibo MD96100/SAM2000
251
252 It adds support for Bluetooth, WLAN and LCD brightness control.
253
254 More information about this driver is available at
255 <http://0pointer.de/lennart/tchibo.html>.
256
257 If you have an MSI S270 laptop, say Y or M here.
258
259config PANASONIC_LAPTOP
260 tristate "Panasonic Laptop Extras"
261 depends on X86 && INPUT && ACPI
262 depends on BACKLIGHT_CLASS_DEVICE
263 ---help---
264 This driver adds support for access to backlight control and hotkeys
265 on Panasonic Let's Note laptops.
266
267 If you have a Panasonic Let's note laptop (such as the R1(N variant),
268 R2, R3, R5, T2, W2 and Y2 series), say Y.
269
270config COMPAL_LAPTOP
271 tristate "Compal Laptop Extras"
272 depends on X86
273 depends on ACPI
274 depends on BACKLIGHT_CLASS_DEVICE
275 ---help---
276 This is a driver for laptops built by Compal:
277
278 Compal FL90/IFL90
279 Compal FL91/IFL91
280 Compal FL92/JFL92
281 Compal FT00/IFT00
282
283 It adds support for Bluetooth, WLAN and LCD brightness control.
284
285 If you have an Compal FL9x/IFL9x/FT00 laptop, say Y or M here.
286
287config SONY_LAPTOP
288 tristate "Sony Laptop Extras"
289 depends on X86 && ACPI
290 select BACKLIGHT_CLASS_DEVICE
291 depends on INPUT
292 ---help---
293 This mini-driver drives the SNC and SPIC devices present in the ACPI
294 BIOS of the Sony Vaio laptops.
295
296 It gives access to some extra laptop functionalities like Bluetooth,
297 screen brightness control, Fn keys and allows powering on/off some
298 devices.
299
300 Read <file:Documentation/laptops/sony-laptop.txt> for more information.
301
302config SONYPI_COMPAT
303 bool "Sonypi compatibility"
304 depends on SONY_LAPTOP
305 ---help---
306 Build the sonypi driver compatibility code into the sony-laptop driver.
307
308config THINKPAD_ACPI
309 tristate "ThinkPad ACPI Laptop Extras"
310 depends on X86 && ACPI
311 select BACKLIGHT_LCD_SUPPORT
312 select BACKLIGHT_CLASS_DEVICE
313 select HWMON
314 select NVRAM
315 select INPUT
316 select NEW_LEDS
317 select LEDS_CLASS
318 select NET
319 select RFKILL
320 ---help---
321 This is a driver for the IBM and Lenovo ThinkPad laptops. It adds
322 support for Fn-Fx key combinations, Bluetooth control, video
323 output switching, ThinkLight control, UltraBay eject and more.
324 For more information about this driver see
325 <file:Documentation/laptops/thinkpad-acpi.txt> and
326 <http://ibm-acpi.sf.net/> .
327
328 This driver was formerly known as ibm-acpi.
329
330 If you have an IBM or Lenovo ThinkPad laptop, say Y or M here.
331
332config THINKPAD_ACPI_DEBUG
333 bool "Verbose debug mode"
334 depends on THINKPAD_ACPI
335 default n
336 ---help---
337 Enables extra debugging information, at the expense of a slightly
338 increase in driver size.
339
340 If you are not sure, say N here.
341
342config THINKPAD_ACPI_DOCK
343 bool "Legacy Docking Station Support"
344 depends on THINKPAD_ACPI
345 depends on ACPI_DOCK=n
346 default n
347 ---help---
348 Allows the thinkpad_acpi driver to handle docking station events.
349 This support was made obsolete by the generic ACPI docking station
350 support (CONFIG_ACPI_DOCK). It will allow locking and removing the
351 laptop from the docking station, but will not properly connect PCI
352 devices.
353
354 If you are not sure, say N here.
355
356config THINKPAD_ACPI_BAY
357 bool "Legacy Removable Bay Support"
358 depends on THINKPAD_ACPI
359 default y
360 ---help---
361 Allows the thinkpad_acpi driver to handle removable bays. It will
362 electrically disable the device in the bay, and also generate
363 notifications when the bay lever is ejected or inserted.
364
365 If you are not sure, say Y here.
366
367config THINKPAD_ACPI_VIDEO
368 bool "Video output control support"
369 depends on THINKPAD_ACPI
370 default y
371 ---help---
372 Allows the thinkpad_acpi driver to provide an interface to control
373 the various video output ports.
374
375 This feature often won't work well, depending on ThinkPad model,
376 display state, video output devices in use, whether there is a X
377 server running, phase of the moon, and the current mood of
378 Schroedinger's cat. If you can use X.org's RandR to control
379 your ThinkPad's video output ports instead of this feature,
380 don't think twice: do it and say N here to save some memory.
381
382 If you are not sure, say Y here.
383
384config THINKPAD_ACPI_HOTKEY_POLL
385 bool "Support NVRAM polling for hot keys"
386 depends on THINKPAD_ACPI
387 default y
388 ---help---
389 Some thinkpad models benefit from NVRAM polling to detect a few of
390 the hot key press events. If you know your ThinkPad model does not
391 need to do NVRAM polling to support any of the hot keys you use,
392 unselecting this option will save about 1kB of memory.
393
394 ThinkPads T40 and newer, R52 and newer, and X31 and newer are
395 unlikely to need NVRAM polling in their latest BIOS versions.
396
397 NVRAM polling can detect at most the following keys: ThinkPad/Access
398 IBM, Zoom, Switch Display (fn+F7), ThinkLight, Volume up/down/mute,
399 Brightness up/down, Display Expand (fn+F8), Hibernate (fn+F12).
400
401 If you are not sure, say Y here. The driver enables polling only if
402 it is strictly necessary to do so.
403
404config ATMEL_SSC 149config ATMEL_SSC
405 tristate "Device driver for Atmel SSC peripheral" 150 tristate "Device driver for Atmel SSC peripheral"
406 depends on AVR32 || ARCH_AT91 151 depends on AVR32 || ARCH_AT91
@@ -413,31 +158,6 @@ config ATMEL_SSC
413 158
414 If unsure, say N. 159 If unsure, say N.
415 160
416config INTEL_MENLOW
417 tristate "Thermal Management driver for Intel menlow platform"
418 depends on ACPI_THERMAL
419 select THERMAL
420 depends on X86
421 ---help---
422 ACPI thermal management enhancement driver on
423 Intel Menlow platform.
424
425 If unsure, say N.
426
427config EEEPC_LAPTOP
428 tristate "Eee PC Hotkey Driver (EXPERIMENTAL)"
429 depends on X86
430 depends on ACPI
431 depends on BACKLIGHT_CLASS_DEVICE
432 depends on HWMON
433 depends on EXPERIMENTAL
434 depends on RFKILL
435 ---help---
436 This driver supports the Fn-Fx keys on Eee PC laptops.
437 It also adds the ability to switch camera/wlan on/off.
438
439 If you have an Eee PC laptop, say Y or M here.
440
441config ENCLOSURE_SERVICES 161config ENCLOSURE_SERVICES
442 tristate "Enclosure Services" 162 tristate "Enclosure Services"
443 default n 163 default n
@@ -498,6 +218,18 @@ config SGI_GRU_DEBUG
498 This option enables addition debugging code for the SGI GRU driver. If 218 This option enables addition debugging code for the SGI GRU driver. If
499 you are unsure, say N. 219 you are unsure, say N.
500 220
221config DELL_LAPTOP
222 tristate "Dell Laptop Extras (EXPERIMENTAL)"
223 depends on X86
224 depends on DCDBAS
225 depends on EXPERIMENTAL
226 depends on BACKLIGHT_CLASS_DEVICE
227 depends on RFKILL
228 default n
229 ---help---
230 This driver adds support for rfkill and backlight control to Dell
231 laptops.
232
501source "drivers/misc/c2port/Kconfig" 233source "drivers/misc/c2port/Kconfig"
502 234
503endif # MISC_DEVICES 235endif # MISC_DEVICES
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 817f7f5ab3bd..d5749a7bc777 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -1,32 +1,19 @@
1# 1#
2# Makefile for misc devices that really don't fit anywhere else. 2# Makefile for misc devices that really don't fit anywhere else.
3# 3#
4obj- := misc.o # Dummy rule to force built-in.o to be made
5 4
6obj-$(CONFIG_IBM_ASM) += ibmasm/ 5obj-$(CONFIG_IBM_ASM) += ibmasm/
7obj-$(CONFIG_HDPU_FEATURES) += hdpuftrs/ 6obj-$(CONFIG_HDPU_FEATURES) += hdpuftrs/
8obj-$(CONFIG_ASUS_LAPTOP) += asus-laptop.o
9obj-$(CONFIG_EEEPC_LAPTOP) += eeepc-laptop.o
10obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o
11obj-$(CONFIG_COMPAL_LAPTOP) += compal-laptop.o
12obj-$(CONFIG_ACER_WMI) += acer-wmi.o
13obj-$(CONFIG_ATMEL_PWM) += atmel_pwm.o 7obj-$(CONFIG_ATMEL_PWM) += atmel_pwm.o
14obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o 8obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o
15obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o 9obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o
16obj-$(CONFIG_HP_WMI) += hp-wmi.o
17obj-$(CONFIG_ICS932S401) += ics932s401.o 10obj-$(CONFIG_ICS932S401) += ics932s401.o
18obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o
19obj-$(CONFIG_LKDTM) += lkdtm.o 11obj-$(CONFIG_LKDTM) += lkdtm.o
20obj-$(CONFIG_TIFM_CORE) += tifm_core.o 12obj-$(CONFIG_TIFM_CORE) += tifm_core.o
21obj-$(CONFIG_TIFM_7XX1) += tifm_7xx1.o 13obj-$(CONFIG_TIFM_7XX1) += tifm_7xx1.o
22obj-$(CONFIG_PHANTOM) += phantom.o 14obj-$(CONFIG_PHANTOM) += phantom.o
23obj-$(CONFIG_SGI_IOC4) += ioc4.o 15obj-$(CONFIG_SGI_IOC4) += ioc4.o
24obj-$(CONFIG_SONY_LAPTOP) += sony-laptop.o
25obj-$(CONFIG_THINKPAD_ACPI) += thinkpad_acpi.o
26obj-$(CONFIG_FUJITSU_LAPTOP) += fujitsu-laptop.o
27obj-$(CONFIG_PANASONIC_LAPTOP) += panasonic-laptop.o
28obj-$(CONFIG_EEPROM_93CX6) += eeprom_93cx6.o 16obj-$(CONFIG_EEPROM_93CX6) += eeprom_93cx6.o
29obj-$(CONFIG_INTEL_MENLOW) += intel_menlow.o
30obj-$(CONFIG_ENCLOSURE_SERVICES) += enclosure.o 17obj-$(CONFIG_ENCLOSURE_SERVICES) += enclosure.o
31obj-$(CONFIG_KGDB_TESTS) += kgdbts.o 18obj-$(CONFIG_KGDB_TESTS) += kgdbts.o
32obj-$(CONFIG_SGI_XP) += sgi-xp/ 19obj-$(CONFIG_SGI_XP) += sgi-xp/
diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
index 0736cff9d97a..3cf61ece71d7 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -119,7 +119,7 @@ enclosure_register(struct device *dev, const char *name, int components,
119 edev->edev.class = &enclosure_class; 119 edev->edev.class = &enclosure_class;
120 edev->edev.parent = get_device(dev); 120 edev->edev.parent = get_device(dev);
121 edev->cb = cb; 121 edev->cb = cb;
122 snprintf(edev->edev.bus_id, BUS_ID_SIZE, "%s", name); 122 dev_set_name(&edev->edev, name);
123 err = device_register(&edev->edev); 123 err = device_register(&edev->edev);
124 if (err) 124 if (err)
125 goto err; 125 goto err;
@@ -170,7 +170,7 @@ EXPORT_SYMBOL_GPL(enclosure_unregister);
170static void enclosure_link_name(struct enclosure_component *cdev, char *name) 170static void enclosure_link_name(struct enclosure_component *cdev, char *name)
171{ 171{
172 strcpy(name, "enclosure_device:"); 172 strcpy(name, "enclosure_device:");
173 strcat(name, cdev->cdev.bus_id); 173 strcat(name, dev_name(&cdev->cdev));
174} 174}
175 175
176static void enclosure_remove_links(struct enclosure_component *cdev) 176static void enclosure_remove_links(struct enclosure_component *cdev)
@@ -256,9 +256,9 @@ enclosure_component_register(struct enclosure_device *edev,
256 cdev = &ecomp->cdev; 256 cdev = &ecomp->cdev;
257 cdev->parent = get_device(&edev->edev); 257 cdev->parent = get_device(&edev->edev);
258 if (name) 258 if (name)
259 snprintf(cdev->bus_id, BUS_ID_SIZE, "%s", name); 259 dev_set_name(cdev, name);
260 else 260 else
261 snprintf(cdev->bus_id, BUS_ID_SIZE, "%u", number); 261 dev_set_name(cdev, "%u", number);
262 262
263 cdev->release = enclosure_component_release; 263 cdev->release = enclosure_component_release;
264 cdev->groups = enclosure_groups; 264 cdev->groups = enclosure_groups;
diff --git a/drivers/misc/ibmasm/event.c b/drivers/misc/ibmasm/event.c
index fda6a4d3bf23..68a0a5b94795 100644
--- a/drivers/misc/ibmasm/event.c
+++ b/drivers/misc/ibmasm/event.c
@@ -50,7 +50,7 @@ static void wake_up_event_readers(struct service_processor *sp)
50 * Store the event in the circular event buffer, wake up any sleeping 50 * Store the event in the circular event buffer, wake up any sleeping
51 * event readers. 51 * event readers.
52 * There is no reader marker in the buffer, therefore readers are 52 * There is no reader marker in the buffer, therefore readers are
53 * responsible for keeping up with the writer, or they will loose events. 53 * responsible for keeping up with the writer, or they will lose events.
54 */ 54 */
55void ibmasm_receive_event(struct service_processor *sp, void *data, unsigned int data_size) 55void ibmasm_receive_event(struct service_processor *sp, void *data, unsigned int data_size)
56{ 56{
diff --git a/drivers/misc/phantom.c b/drivers/misc/phantom.c
index abdebe347383..fa57b67593ae 100644
--- a/drivers/misc/phantom.c
+++ b/drivers/misc/phantom.c
@@ -6,7 +6,7 @@
6 * the Free Software Foundation; either version 2 of the License, or 6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version. 7 * (at your option) any later version.
8 * 8 *
9 * You need an userspace library to cooperate with this driver. It (and other 9 * You need a userspace library to cooperate with this driver. It (and other
10 * info) may be obtained here: 10 * info) may be obtained here:
11 * http://www.fi.muni.cz/~xslaby/phantom.html 11 * http://www.fi.muni.cz/~xslaby/phantom.html
12 * or alternatively, you might use OpenHaptics provided by Sensable. 12 * or alternatively, you might use OpenHaptics provided by Sensable.
diff --git a/drivers/misc/sgi-xp/xpc_sn2.c b/drivers/misc/sgi-xp/xpc_sn2.c
index 73b7fb8de47a..82fb9958f22f 100644
--- a/drivers/misc/sgi-xp/xpc_sn2.c
+++ b/drivers/misc/sgi-xp/xpc_sn2.c
@@ -899,7 +899,7 @@ xpc_update_partition_info_sn2(struct xpc_partition *part, u8 remote_rp_version,
899 dev_dbg(xpc_part, " remote_vars_pa = 0x%016lx\n", 899 dev_dbg(xpc_part, " remote_vars_pa = 0x%016lx\n",
900 part_sn2->remote_vars_pa); 900 part_sn2->remote_vars_pa);
901 901
902 part->last_heartbeat = remote_vars->heartbeat; 902 part->last_heartbeat = remote_vars->heartbeat - 1;
903 dev_dbg(xpc_part, " last_heartbeat = 0x%016lx\n", 903 dev_dbg(xpc_part, " last_heartbeat = 0x%016lx\n",
904 part->last_heartbeat); 904 part->last_heartbeat);
905 905
diff --git a/drivers/misc/sgi-xp/xpnet.c b/drivers/misc/sgi-xp/xpnet.c
index 81152b3e360c..7957f525b2f4 100644
--- a/drivers/misc/sgi-xp/xpnet.c
+++ b/drivers/misc/sgi-xp/xpnet.c
@@ -95,11 +95,6 @@ struct xpnet_pending_msg {
95 atomic_t use_count; 95 atomic_t use_count;
96}; 96};
97 97
98/* driver specific structure pointed to by the device structure */
99struct xpnet_dev_private {
100 struct net_device_stats stats;
101};
102
103struct net_device *xpnet_device; 98struct net_device *xpnet_device;
104 99
105/* 100/*
@@ -153,7 +148,6 @@ xpnet_receive(short partid, int channel, struct xpnet_message *msg)
153 struct sk_buff *skb; 148 struct sk_buff *skb;
154 void *dst; 149 void *dst;
155 enum xp_retval ret; 150 enum xp_retval ret;
156 struct xpnet_dev_private *priv = netdev_priv(xpnet_device);
157 151
158 if (!XPNET_VALID_MSG(msg)) { 152 if (!XPNET_VALID_MSG(msg)) {
159 /* 153 /*
@@ -161,7 +155,7 @@ xpnet_receive(short partid, int channel, struct xpnet_message *msg)
161 */ 155 */
162 xpc_received(partid, channel, (void *)msg); 156 xpc_received(partid, channel, (void *)msg);
163 157
164 priv->stats.rx_errors++; 158 xpnet_device->stats.rx_errors++;
165 159
166 return; 160 return;
167 } 161 }
@@ -176,7 +170,7 @@ xpnet_receive(short partid, int channel, struct xpnet_message *msg)
176 170
177 xpc_received(partid, channel, (void *)msg); 171 xpc_received(partid, channel, (void *)msg);
178 172
179 priv->stats.rx_errors++; 173 xpnet_device->stats.rx_errors++;
180 174
181 return; 175 return;
182 } 176 }
@@ -226,7 +220,7 @@ xpnet_receive(short partid, int channel, struct xpnet_message *msg)
226 220
227 xpc_received(partid, channel, (void *)msg); 221 xpc_received(partid, channel, (void *)msg);
228 222
229 priv->stats.rx_errors++; 223 xpnet_device->stats.rx_errors++;
230 224
231 return; 225 return;
232 } 226 }
@@ -247,8 +241,8 @@ xpnet_receive(short partid, int channel, struct xpnet_message *msg)
247 skb_end_pointer(skb), skb->len); 241 skb_end_pointer(skb), skb->len);
248 242
249 xpnet_device->last_rx = jiffies; 243 xpnet_device->last_rx = jiffies;
250 priv->stats.rx_packets++; 244 xpnet_device->stats.rx_packets++;
251 priv->stats.rx_bytes += skb->len + ETH_HLEN; 245 xpnet_device->stats.rx_bytes += skb->len + ETH_HLEN;
252 246
253 netif_rx_ni(skb); 247 netif_rx_ni(skb);
254 xpc_received(partid, channel, (void *)msg); 248 xpc_received(partid, channel, (void *)msg);
@@ -353,26 +347,6 @@ xpnet_dev_change_mtu(struct net_device *dev, int new_mtu)
353} 347}
354 348
355/* 349/*
356 * Required for the net_device structure.
357 */
358static int
359xpnet_dev_set_config(struct net_device *dev, struct ifmap *new_map)
360{
361 return 0;
362}
363
364/*
365 * Return statistics to the caller.
366 */
367static struct net_device_stats *
368xpnet_dev_get_stats(struct net_device *dev)
369{
370 struct xpnet_dev_private *priv = netdev_priv(dev);
371
372 return &priv->stats;
373}
374
375/*
376 * Notification that the other end has received the message and 350 * Notification that the other end has received the message and
377 * DMA'd the skb information. At this point, they are done with 351 * DMA'd the skb information. At this point, they are done with
378 * our side. When all recipients are done processing, we 352 * our side. When all recipients are done processing, we
@@ -453,7 +427,6 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
453 struct xpnet_pending_msg *queued_msg; 427 struct xpnet_pending_msg *queued_msg;
454 u64 start_addr, end_addr; 428 u64 start_addr, end_addr;
455 short dest_partid; 429 short dest_partid;
456 struct xpnet_dev_private *priv = netdev_priv(dev);
457 u16 embedded_bytes = 0; 430 u16 embedded_bytes = 0;
458 431
459 dev_dbg(xpnet, ">skb->head=0x%p skb->data=0x%p skb->tail=0x%p " 432 dev_dbg(xpnet, ">skb->head=0x%p skb->data=0x%p skb->tail=0x%p "
@@ -476,7 +449,7 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
476 dev_warn(xpnet, "failed to kmalloc %ld bytes; dropping " 449 dev_warn(xpnet, "failed to kmalloc %ld bytes; dropping "
477 "packet\n", sizeof(struct xpnet_pending_msg)); 450 "packet\n", sizeof(struct xpnet_pending_msg));
478 451
479 priv->stats.tx_errors++; 452 dev->stats.tx_errors++;
480 return -ENOMEM; 453 return -ENOMEM;
481 } 454 }
482 455
@@ -526,8 +499,8 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
526 kfree(queued_msg); 499 kfree(queued_msg);
527 } 500 }
528 501
529 priv->stats.tx_packets++; 502 dev->stats.tx_packets++;
530 priv->stats.tx_bytes += skb->len; 503 dev->stats.tx_bytes += skb->len;
531 504
532 return 0; 505 return 0;
533} 506}
@@ -538,12 +511,19 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
538static void 511static void
539xpnet_dev_tx_timeout(struct net_device *dev) 512xpnet_dev_tx_timeout(struct net_device *dev)
540{ 513{
541 struct xpnet_dev_private *priv = netdev_priv(dev); 514 dev->stats.tx_errors++;
542
543 priv->stats.tx_errors++;
544 return;
545} 515}
546 516
517static const struct net_device_ops xpnet_netdev_ops = {
518 .ndo_open = xpnet_dev_open,
519 .ndo_stop = xpnet_dev_stop,
520 .ndo_start_xmit = xpnet_dev_hard_start_xmit,
521 .ndo_change_mtu = xpnet_dev_change_mtu,
522 .ndo_tx_timeout = xpnet_dev_tx_timeout,
523 .ndo_set_mac_address = eth_mac_addr,
524 .ndo_validate_addr = eth_validate_addr,
525};
526
547static int __init 527static int __init
548xpnet_init(void) 528xpnet_init(void)
549{ 529{
@@ -563,8 +543,7 @@ xpnet_init(void)
563 * use ether_setup() to init the majority of our device 543 * use ether_setup() to init the majority of our device
564 * structure and then override the necessary pieces. 544 * structure and then override the necessary pieces.
565 */ 545 */
566 xpnet_device = alloc_netdev(sizeof(struct xpnet_dev_private), 546 xpnet_device = alloc_netdev(0, XPNET_DEVICE_NAME, ether_setup);
567 XPNET_DEVICE_NAME, ether_setup);
568 if (xpnet_device == NULL) { 547 if (xpnet_device == NULL) {
569 kfree(xpnet_broadcast_partitions); 548 kfree(xpnet_broadcast_partitions);
570 return -ENOMEM; 549 return -ENOMEM;
@@ -573,13 +552,6 @@ xpnet_init(void)
573 netif_carrier_off(xpnet_device); 552 netif_carrier_off(xpnet_device);
574 553
575 xpnet_device->mtu = XPNET_DEF_MTU; 554 xpnet_device->mtu = XPNET_DEF_MTU;
576 xpnet_device->change_mtu = xpnet_dev_change_mtu;
577 xpnet_device->open = xpnet_dev_open;
578 xpnet_device->get_stats = xpnet_dev_get_stats;
579 xpnet_device->stop = xpnet_dev_stop;
580 xpnet_device->hard_start_xmit = xpnet_dev_hard_start_xmit;
581 xpnet_device->tx_timeout = xpnet_dev_tx_timeout;
582 xpnet_device->set_config = xpnet_dev_set_config;
583 555
584 /* 556 /*
585 * Multicast assumes the LSB of the first octet is set for multicast 557 * Multicast assumes the LSB of the first octet is set for multicast
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 7a3f2436b011..76bfe16c09b1 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -25,8 +25,8 @@
25#include <linux/stat.h> 25#include <linux/stat.h>
26 26
27#include <linux/mmc/host.h> 27#include <linux/mmc/host.h>
28#include <linux/atmel-mci.h>
28 29
29#include <asm/atmel-mci.h>
30#include <asm/io.h> 30#include <asm/io.h>
31#include <asm/unaligned.h> 31#include <asm/unaligned.h>
32 32
@@ -55,7 +55,6 @@ enum atmel_mci_state {
55 55
56struct atmel_mci_dma { 56struct atmel_mci_dma {
57#ifdef CONFIG_MMC_ATMELMCI_DMA 57#ifdef CONFIG_MMC_ATMELMCI_DMA
58 struct dma_client client;
59 struct dma_chan *chan; 58 struct dma_chan *chan;
60 struct dma_async_tx_descriptor *data_desc; 59 struct dma_async_tx_descriptor *data_desc;
61#endif 60#endif
@@ -593,10 +592,8 @@ atmci_submit_data_dma(struct atmel_mci *host, struct mmc_data *data)
593 592
594 /* If we don't have a channel, we can't do DMA */ 593 /* If we don't have a channel, we can't do DMA */
595 chan = host->dma.chan; 594 chan = host->dma.chan;
596 if (chan) { 595 if (chan)
597 dma_chan_get(chan);
598 host->data_chan = chan; 596 host->data_chan = chan;
599 }
600 597
601 if (!chan) 598 if (!chan)
602 return -ENODEV; 599 return -ENODEV;
@@ -1443,60 +1440,6 @@ static irqreturn_t atmci_detect_interrupt(int irq, void *dev_id)
1443 return IRQ_HANDLED; 1440 return IRQ_HANDLED;
1444} 1441}
1445 1442
1446#ifdef CONFIG_MMC_ATMELMCI_DMA
1447
1448static inline struct atmel_mci *
1449dma_client_to_atmel_mci(struct dma_client *client)
1450{
1451 return container_of(client, struct atmel_mci, dma.client);
1452}
1453
1454static enum dma_state_client atmci_dma_event(struct dma_client *client,
1455 struct dma_chan *chan, enum dma_state state)
1456{
1457 struct atmel_mci *host;
1458 enum dma_state_client ret = DMA_NAK;
1459
1460 host = dma_client_to_atmel_mci(client);
1461
1462 switch (state) {
1463 case DMA_RESOURCE_AVAILABLE:
1464 spin_lock_bh(&host->lock);
1465 if (!host->dma.chan) {
1466 host->dma.chan = chan;
1467 ret = DMA_ACK;
1468 }
1469 spin_unlock_bh(&host->lock);
1470
1471 if (ret == DMA_ACK)
1472 dev_info(&host->pdev->dev,
1473 "Using %s for DMA transfers\n",
1474 chan->dev.bus_id);
1475 break;
1476
1477 case DMA_RESOURCE_REMOVED:
1478 spin_lock_bh(&host->lock);
1479 if (host->dma.chan == chan) {
1480 host->dma.chan = NULL;
1481 ret = DMA_ACK;
1482 }
1483 spin_unlock_bh(&host->lock);
1484
1485 if (ret == DMA_ACK)
1486 dev_info(&host->pdev->dev,
1487 "Lost %s, falling back to PIO\n",
1488 chan->dev.bus_id);
1489 break;
1490
1491 default:
1492 break;
1493 }
1494
1495
1496 return ret;
1497}
1498#endif /* CONFIG_MMC_ATMELMCI_DMA */
1499
1500static int __init atmci_init_slot(struct atmel_mci *host, 1443static int __init atmci_init_slot(struct atmel_mci *host,
1501 struct mci_slot_pdata *slot_data, unsigned int id, 1444 struct mci_slot_pdata *slot_data, unsigned int id,
1502 u32 sdc_reg) 1445 u32 sdc_reg)
@@ -1600,6 +1543,18 @@ static void __exit atmci_cleanup_slot(struct atmel_mci_slot *slot,
1600 mmc_free_host(slot->mmc); 1543 mmc_free_host(slot->mmc);
1601} 1544}
1602 1545
1546#ifdef CONFIG_MMC_ATMELMCI_DMA
1547static bool filter(struct dma_chan *chan, void *slave)
1548{
1549 struct dw_dma_slave *dws = slave;
1550
1551 if (dws->dma_dev == chan->device->dev)
1552 return true;
1553 else
1554 return false;
1555}
1556#endif
1557
1603static int __init atmci_probe(struct platform_device *pdev) 1558static int __init atmci_probe(struct platform_device *pdev)
1604{ 1559{
1605 struct mci_platform_data *pdata; 1560 struct mci_platform_data *pdata;
@@ -1652,22 +1607,20 @@ static int __init atmci_probe(struct platform_device *pdev)
1652 goto err_request_irq; 1607 goto err_request_irq;
1653 1608
1654#ifdef CONFIG_MMC_ATMELMCI_DMA 1609#ifdef CONFIG_MMC_ATMELMCI_DMA
1655 if (pdata->dma_slave) { 1610 if (pdata->dma_slave.dma_dev) {
1656 struct dma_slave *slave = pdata->dma_slave; 1611 struct dw_dma_slave *dws = &pdata->dma_slave;
1612 dma_cap_mask_t mask;
1657 1613
1658 slave->tx_reg = regs->start + MCI_TDR; 1614 dws->tx_reg = regs->start + MCI_TDR;
1659 slave->rx_reg = regs->start + MCI_RDR; 1615 dws->rx_reg = regs->start + MCI_RDR;
1660 1616
1661 /* Try to grab a DMA channel */ 1617 /* Try to grab a DMA channel */
1662 host->dma.client.event_callback = atmci_dma_event; 1618 dma_cap_zero(mask);
1663 dma_cap_set(DMA_SLAVE, host->dma.client.cap_mask); 1619 dma_cap_set(DMA_SLAVE, mask);
1664 host->dma.client.slave = slave; 1620 host->dma.chan = dma_request_channel(mask, filter, dws);
1665
1666 dma_async_client_register(&host->dma.client);
1667 dma_async_client_chan_request(&host->dma.client);
1668 } else {
1669 dev_notice(&pdev->dev, "DMA not available, using PIO\n");
1670 } 1621 }
1622 if (!host->dma.chan)
1623 dev_notice(&pdev->dev, "DMA not available, using PIO\n");
1671#endif /* CONFIG_MMC_ATMELMCI_DMA */ 1624#endif /* CONFIG_MMC_ATMELMCI_DMA */
1672 1625
1673 platform_set_drvdata(pdev, host); 1626 platform_set_drvdata(pdev, host);
@@ -1699,8 +1652,8 @@ static int __init atmci_probe(struct platform_device *pdev)
1699 1652
1700err_init_slot: 1653err_init_slot:
1701#ifdef CONFIG_MMC_ATMELMCI_DMA 1654#ifdef CONFIG_MMC_ATMELMCI_DMA
1702 if (pdata->dma_slave) 1655 if (host->dma.chan)
1703 dma_async_client_unregister(&host->dma.client); 1656 dma_release_channel(host->dma.chan);
1704#endif 1657#endif
1705 free_irq(irq, host); 1658 free_irq(irq, host);
1706err_request_irq: 1659err_request_irq:
@@ -1731,8 +1684,8 @@ static int __exit atmci_remove(struct platform_device *pdev)
1731 clk_disable(host->mck); 1684 clk_disable(host->mck);
1732 1685
1733#ifdef CONFIG_MMC_ATMELMCI_DMA 1686#ifdef CONFIG_MMC_ATMELMCI_DMA
1734 if (host->dma.client.slave) 1687 if (host->dma.chan)
1735 dma_async_client_unregister(&host->dma.client); 1688 dma_release_channel(host->dma.chan);
1736#endif 1689#endif
1737 1690
1738 free_irq(platform_get_irq(pdev, 0), host); 1691 free_irq(platform_get_irq(pdev, 0), host);
@@ -1761,7 +1714,7 @@ static void __exit atmci_exit(void)
1761 platform_driver_unregister(&atmci_driver); 1714 platform_driver_unregister(&atmci_driver);
1762} 1715}
1763 1716
1764module_init(atmci_init); 1717late_initcall(atmci_init); /* try to load after dma driver when built-in */
1765module_exit(atmci_exit); 1718module_exit(atmci_exit);
1766 1719
1767MODULE_DESCRIPTION("Atmel Multimedia Card Interface driver"); 1720MODULE_DESCRIPTION("Atmel Multimedia Card Interface driver");
diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index a90d50c2c3e5..7d04fb9ddcaa 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -45,6 +45,14 @@ config MTD_PARTITIONS
45 devices. Partitioning on NFTL 'devices' is a different - that's the 45 devices. Partitioning on NFTL 'devices' is a different - that's the
46 'normal' form of partitioning used on a block device. 46 'normal' form of partitioning used on a block device.
47 47
48config MTD_TESTS
49 tristate "MTD tests support"
50 depends on m
51 help
52 This option includes various MTD tests into compilation. The tests
53 should normally be compiled as kernel modules. The modules perform
54 various checks and verifications when loaded.
55
48config MTD_REDBOOT_PARTS 56config MTD_REDBOOT_PARTS
49 tristate "RedBoot partition table parsing" 57 tristate "RedBoot partition table parsing"
50 depends on MTD_PARTITIONS 58 depends on MTD_PARTITIONS
@@ -316,6 +324,8 @@ source "drivers/mtd/nand/Kconfig"
316 324
317source "drivers/mtd/onenand/Kconfig" 325source "drivers/mtd/onenand/Kconfig"
318 326
327source "drivers/mtd/lpddr/Kconfig"
328
319source "drivers/mtd/ubi/Kconfig" 329source "drivers/mtd/ubi/Kconfig"
320 330
321endif # MTD 331endif # MTD
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
index 4b77335715f0..4521b1ecce45 100644
--- a/drivers/mtd/Makefile
+++ b/drivers/mtd/Makefile
@@ -29,6 +29,6 @@ obj-$(CONFIG_MTD_OOPS) += mtdoops.o
29nftl-objs := nftlcore.o nftlmount.o 29nftl-objs := nftlcore.o nftlmount.o
30inftl-objs := inftlcore.o inftlmount.o 30inftl-objs := inftlcore.o inftlmount.o
31 31
32obj-y += chips/ maps/ devices/ nand/ onenand/ 32obj-y += chips/ lpddr/ maps/ devices/ nand/ onenand/ tests/
33 33
34obj-$(CONFIG_MTD_UBI) += ubi/ 34obj-$(CONFIG_MTD_UBI) += ubi/
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index c93a8be5d5f1..f5ab6fa1057b 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -58,8 +58,8 @@ static int cfi_intelext_write_buffers(struct mtd_info *, loff_t, size_t, size_t
58static int cfi_intelext_writev(struct mtd_info *, const struct kvec *, unsigned long, loff_t, size_t *); 58static int cfi_intelext_writev(struct mtd_info *, const struct kvec *, unsigned long, loff_t, size_t *);
59static int cfi_intelext_erase_varsize(struct mtd_info *, struct erase_info *); 59static int cfi_intelext_erase_varsize(struct mtd_info *, struct erase_info *);
60static void cfi_intelext_sync (struct mtd_info *); 60static void cfi_intelext_sync (struct mtd_info *);
61static int cfi_intelext_lock(struct mtd_info *mtd, loff_t ofs, size_t len); 61static int cfi_intelext_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
62static int cfi_intelext_unlock(struct mtd_info *mtd, loff_t ofs, size_t len); 62static int cfi_intelext_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
63#ifdef CONFIG_MTD_OTP 63#ifdef CONFIG_MTD_OTP
64static int cfi_intelext_read_fact_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *); 64static int cfi_intelext_read_fact_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
65static int cfi_intelext_read_user_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *); 65static int cfi_intelext_read_user_prot_reg (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
@@ -558,8 +558,8 @@ static struct mtd_info *cfi_intelext_setup(struct mtd_info *mtd)
558 } 558 }
559 559
560 for (i=0; i<mtd->numeraseregions;i++){ 560 for (i=0; i<mtd->numeraseregions;i++){
561 printk(KERN_DEBUG "erase region %d: offset=0x%x,size=0x%x,blocks=%d\n", 561 printk(KERN_DEBUG "erase region %d: offset=0x%llx,size=0x%x,blocks=%d\n",
562 i,mtd->eraseregions[i].offset, 562 i,(unsigned long long)mtd->eraseregions[i].offset,
563 mtd->eraseregions[i].erasesize, 563 mtd->eraseregions[i].erasesize,
564 mtd->eraseregions[i].numblocks); 564 mtd->eraseregions[i].numblocks);
565 } 565 }
@@ -2058,7 +2058,7 @@ out: put_chip(map, chip, adr);
2058 return ret; 2058 return ret;
2059} 2059}
2060 2060
2061static int cfi_intelext_lock(struct mtd_info *mtd, loff_t ofs, size_t len) 2061static int cfi_intelext_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
2062{ 2062{
2063 int ret; 2063 int ret;
2064 2064
@@ -2082,7 +2082,7 @@ static int cfi_intelext_lock(struct mtd_info *mtd, loff_t ofs, size_t len)
2082 return ret; 2082 return ret;
2083} 2083}
2084 2084
2085static int cfi_intelext_unlock(struct mtd_info *mtd, loff_t ofs, size_t len) 2085static int cfi_intelext_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
2086{ 2086{
2087 int ret; 2087 int ret;
2088 2088
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
index d74ec46aa032..94bb61e19047 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -71,8 +71,8 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
71static void put_chip(struct map_info *map, struct flchip *chip, unsigned long adr); 71static void put_chip(struct map_info *map, struct flchip *chip, unsigned long adr);
72#include "fwh_lock.h" 72#include "fwh_lock.h"
73 73
74static int cfi_atmel_lock(struct mtd_info *mtd, loff_t ofs, size_t len); 74static int cfi_atmel_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
75static int cfi_atmel_unlock(struct mtd_info *mtd, loff_t ofs, size_t len); 75static int cfi_atmel_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
76 76
77static struct mtd_chip_driver cfi_amdstd_chipdrv = { 77static struct mtd_chip_driver cfi_amdstd_chipdrv = {
78 .probe = NULL, /* Not usable directly */ 78 .probe = NULL, /* Not usable directly */
@@ -322,6 +322,14 @@ static struct cfi_fixup fixup_table[] = {
322}; 322};
323 323
324 324
325static void cfi_fixup_major_minor(struct cfi_private *cfi,
326 struct cfi_pri_amdstd *extp)
327{
328 if (cfi->mfr == CFI_MFR_SAMSUNG && cfi->id == 0x257e &&
329 extp->MajorVersion == '0')
330 extp->MajorVersion = '1';
331}
332
325struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary) 333struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
326{ 334{
327 struct cfi_private *cfi = map->fldrv_priv; 335 struct cfi_private *cfi = map->fldrv_priv;
@@ -363,6 +371,8 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
363 return NULL; 371 return NULL;
364 } 372 }
365 373
374 cfi_fixup_major_minor(cfi, extp);
375
366 if (extp->MajorVersion != '1' || 376 if (extp->MajorVersion != '1' ||
367 (extp->MinorVersion < '0' || extp->MinorVersion > '4')) { 377 (extp->MinorVersion < '0' || extp->MinorVersion > '4')) {
368 printk(KERN_ERR " Unknown Amd/Fujitsu Extended Query " 378 printk(KERN_ERR " Unknown Amd/Fujitsu Extended Query "
@@ -1774,12 +1784,12 @@ out_unlock:
1774 return ret; 1784 return ret;
1775} 1785}
1776 1786
1777static int cfi_atmel_lock(struct mtd_info *mtd, loff_t ofs, size_t len) 1787static int cfi_atmel_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
1778{ 1788{
1779 return cfi_varsize_frob(mtd, do_atmel_lock, ofs, len, NULL); 1789 return cfi_varsize_frob(mtd, do_atmel_lock, ofs, len, NULL);
1780} 1790}
1781 1791
1782static int cfi_atmel_unlock(struct mtd_info *mtd, loff_t ofs, size_t len) 1792static int cfi_atmel_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
1783{ 1793{
1784 return cfi_varsize_frob(mtd, do_atmel_unlock, ofs, len, NULL); 1794 return cfi_varsize_frob(mtd, do_atmel_unlock, ofs, len, NULL);
1785} 1795}
diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
index d4714dd9f7ab..6c740f346f91 100644
--- a/drivers/mtd/chips/cfi_cmdset_0020.c
+++ b/drivers/mtd/chips/cfi_cmdset_0020.c
@@ -42,8 +42,8 @@ static int cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
42 unsigned long count, loff_t to, size_t *retlen); 42 unsigned long count, loff_t to, size_t *retlen);
43static int cfi_staa_erase_varsize(struct mtd_info *, struct erase_info *); 43static int cfi_staa_erase_varsize(struct mtd_info *, struct erase_info *);
44static void cfi_staa_sync (struct mtd_info *); 44static void cfi_staa_sync (struct mtd_info *);
45static int cfi_staa_lock(struct mtd_info *mtd, loff_t ofs, size_t len); 45static int cfi_staa_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
46static int cfi_staa_unlock(struct mtd_info *mtd, loff_t ofs, size_t len); 46static int cfi_staa_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
47static int cfi_staa_suspend (struct mtd_info *); 47static int cfi_staa_suspend (struct mtd_info *);
48static void cfi_staa_resume (struct mtd_info *); 48static void cfi_staa_resume (struct mtd_info *);
49 49
@@ -221,8 +221,8 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
221 } 221 }
222 222
223 for (i=0; i<mtd->numeraseregions;i++){ 223 for (i=0; i<mtd->numeraseregions;i++){
224 printk(KERN_DEBUG "%d: offset=0x%x,size=0x%x,blocks=%d\n", 224 printk(KERN_DEBUG "%d: offset=0x%llx,size=0x%x,blocks=%d\n",
225 i,mtd->eraseregions[i].offset, 225 i, (unsigned long long)mtd->eraseregions[i].offset,
226 mtd->eraseregions[i].erasesize, 226 mtd->eraseregions[i].erasesize,
227 mtd->eraseregions[i].numblocks); 227 mtd->eraseregions[i].numblocks);
228 } 228 }
@@ -964,7 +964,7 @@ static int cfi_staa_erase_varsize(struct mtd_info *mtd,
964 adr += regions[i].erasesize; 964 adr += regions[i].erasesize;
965 len -= regions[i].erasesize; 965 len -= regions[i].erasesize;
966 966
967 if (adr % (1<< cfi->chipshift) == ((regions[i].offset + (regions[i].erasesize * regions[i].numblocks)) %( 1<< cfi->chipshift))) 967 if (adr % (1<< cfi->chipshift) == (((unsigned long)regions[i].offset + (regions[i].erasesize * regions[i].numblocks)) %( 1<< cfi->chipshift)))
968 i++; 968 i++;
969 969
970 if (adr >> cfi->chipshift) { 970 if (adr >> cfi->chipshift) {
@@ -1135,7 +1135,7 @@ retry:
1135 spin_unlock_bh(chip->mutex); 1135 spin_unlock_bh(chip->mutex);
1136 return 0; 1136 return 0;
1137} 1137}
1138static int cfi_staa_lock(struct mtd_info *mtd, loff_t ofs, size_t len) 1138static int cfi_staa_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
1139{ 1139{
1140 struct map_info *map = mtd->priv; 1140 struct map_info *map = mtd->priv;
1141 struct cfi_private *cfi = map->fldrv_priv; 1141 struct cfi_private *cfi = map->fldrv_priv;
@@ -1284,7 +1284,7 @@ retry:
1284 spin_unlock_bh(chip->mutex); 1284 spin_unlock_bh(chip->mutex);
1285 return 0; 1285 return 0;
1286} 1286}
1287static int cfi_staa_unlock(struct mtd_info *mtd, loff_t ofs, size_t len) 1287static int cfi_staa_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
1288{ 1288{
1289 struct map_info *map = mtd->priv; 1289 struct map_info *map = mtd->priv;
1290 struct cfi_private *cfi = map->fldrv_priv; 1290 struct cfi_private *cfi = map->fldrv_priv;
diff --git a/drivers/mtd/chips/fwh_lock.h b/drivers/mtd/chips/fwh_lock.h
index ab44f2b996f8..57e0e4e921f9 100644
--- a/drivers/mtd/chips/fwh_lock.h
+++ b/drivers/mtd/chips/fwh_lock.h
@@ -77,7 +77,7 @@ static int fwh_xxlock_oneblock(struct map_info *map, struct flchip *chip,
77} 77}
78 78
79 79
80static int fwh_lock_varsize(struct mtd_info *mtd, loff_t ofs, size_t len) 80static int fwh_lock_varsize(struct mtd_info *mtd, loff_t ofs, uint64_t len)
81{ 81{
82 int ret; 82 int ret;
83 83
@@ -88,7 +88,7 @@ static int fwh_lock_varsize(struct mtd_info *mtd, loff_t ofs, size_t len)
88} 88}
89 89
90 90
91static int fwh_unlock_varsize(struct mtd_info *mtd, loff_t ofs, size_t len) 91static int fwh_unlock_varsize(struct mtd_info *mtd, loff_t ofs, uint64_t len)
92{ 92{
93 int ret; 93 int ret;
94 94
diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig
index 6fde0a2e3567..bc33200535fc 100644
--- a/drivers/mtd/devices/Kconfig
+++ b/drivers/mtd/devices/Kconfig
@@ -120,6 +120,13 @@ config MTD_PHRAM
120 doesn't have access to, memory beyond the mem=xxx limit, nvram, 120 doesn't have access to, memory beyond the mem=xxx limit, nvram,
121 memory on the video card, etc... 121 memory on the video card, etc...
122 122
123config MTD_PS3VRAM
124 tristate "PS3 video RAM"
125 depends on FB_PS3
126 help
127 This driver allows you to use excess PS3 video RAM as volatile
128 storage or system swap.
129
123config MTD_LART 130config MTD_LART
124 tristate "28F160xx flash driver for LART" 131 tristate "28F160xx flash driver for LART"
125 depends on SA1100_LART 132 depends on SA1100_LART
diff --git a/drivers/mtd/devices/Makefile b/drivers/mtd/devices/Makefile
index 0993d5cf3923..e51521df4e40 100644
--- a/drivers/mtd/devices/Makefile
+++ b/drivers/mtd/devices/Makefile
@@ -16,3 +16,4 @@ obj-$(CONFIG_MTD_LART) += lart.o
16obj-$(CONFIG_MTD_BLOCK2MTD) += block2mtd.o 16obj-$(CONFIG_MTD_BLOCK2MTD) += block2mtd.o
17obj-$(CONFIG_MTD_DATAFLASH) += mtd_dataflash.o 17obj-$(CONFIG_MTD_DATAFLASH) += mtd_dataflash.o
18obj-$(CONFIG_MTD_M25P80) += m25p80.o 18obj-$(CONFIG_MTD_M25P80) += m25p80.o
19obj-$(CONFIG_MTD_PS3VRAM) += ps3vram.o
diff --git a/drivers/mtd/devices/lart.c b/drivers/mtd/devices/lart.c
index f4bda4cee495..578de1c67bfe 100644
--- a/drivers/mtd/devices/lart.c
+++ b/drivers/mtd/devices/lart.c
@@ -619,7 +619,7 @@ static struct mtd_partition lart_partitions[] = {
619}; 619};
620#endif 620#endif
621 621
622int __init lart_flash_init (void) 622static int __init lart_flash_init (void)
623{ 623{
624 int result; 624 int result;
625 memset (&mtd,0,sizeof (mtd)); 625 memset (&mtd,0,sizeof (mtd));
@@ -690,7 +690,7 @@ int __init lart_flash_init (void)
690 return (result); 690 return (result);
691} 691}
692 692
693void __exit lart_flash_exit (void) 693static void __exit lart_flash_exit (void)
694{ 694{
695#ifndef HAVE_PARTITIONS 695#ifndef HAVE_PARTITIONS
696 del_mtd_device (&mtd); 696 del_mtd_device (&mtd);
@@ -705,5 +705,3 @@ module_exit (lart_flash_exit);
705MODULE_LICENSE("GPL"); 705MODULE_LICENSE("GPL");
706MODULE_AUTHOR("Abraham vd Merwe <abraham@2d3d.co.za>"); 706MODULE_AUTHOR("Abraham vd Merwe <abraham@2d3d.co.za>");
707MODULE_DESCRIPTION("MTD driver for Intel 28F160F3 on LART board"); 707MODULE_DESCRIPTION("MTD driver for Intel 28F160F3 on LART board");
708
709
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 5733f0643843..7c3fc766dcf1 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -20,6 +20,7 @@
20#include <linux/device.h> 20#include <linux/device.h>
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/mutex.h> 22#include <linux/mutex.h>
23#include <linux/math64.h>
23 24
24#include <linux/mtd/mtd.h> 25#include <linux/mtd/mtd.h>
25#include <linux/mtd/partitions.h> 26#include <linux/mtd/partitions.h>
@@ -169,9 +170,9 @@ static int wait_till_ready(struct m25p *flash)
169 */ 170 */
170static int erase_chip(struct m25p *flash) 171static int erase_chip(struct m25p *flash)
171{ 172{
172 DEBUG(MTD_DEBUG_LEVEL3, "%s: %s %dKiB\n", 173 DEBUG(MTD_DEBUG_LEVEL3, "%s: %s %lldKiB\n",
173 dev_name(&flash->spi->dev), __func__, 174 dev_name(&flash->spi->dev), __func__,
174 flash->mtd.size / 1024); 175 (long long)(flash->mtd.size >> 10));
175 176
176 /* Wait until finished previous write command. */ 177 /* Wait until finished previous write command. */
177 if (wait_till_ready(flash)) 178 if (wait_till_ready(flash))
@@ -232,18 +233,18 @@ static int m25p80_erase(struct mtd_info *mtd, struct erase_info *instr)
232{ 233{
233 struct m25p *flash = mtd_to_m25p(mtd); 234 struct m25p *flash = mtd_to_m25p(mtd);
234 u32 addr,len; 235 u32 addr,len;
236 uint32_t rem;
235 237
236 DEBUG(MTD_DEBUG_LEVEL2, "%s: %s %s 0x%08x, len %d\n", 238 DEBUG(MTD_DEBUG_LEVEL2, "%s: %s %s 0x%llx, len %lld\n",
237 dev_name(&flash->spi->dev), __func__, "at", 239 dev_name(&flash->spi->dev), __func__, "at",
238 (u32)instr->addr, instr->len); 240 (long long)instr->addr, (long long)instr->len);
239 241
240 /* sanity checks */ 242 /* sanity checks */
241 if (instr->addr + instr->len > flash->mtd.size) 243 if (instr->addr + instr->len > flash->mtd.size)
242 return -EINVAL; 244 return -EINVAL;
243 if ((instr->addr % mtd->erasesize) != 0 245 div_u64_rem(instr->len, mtd->erasesize, &rem);
244 || (instr->len % mtd->erasesize) != 0) { 246 if (rem)
245 return -EINVAL; 247 return -EINVAL;
246 }
247 248
248 addr = instr->addr; 249 addr = instr->addr;
249 len = instr->len; 250 len = instr->len;
@@ -677,24 +678,24 @@ static int __devinit m25p_probe(struct spi_device *spi)
677 flash->mtd.erasesize = info->sector_size; 678 flash->mtd.erasesize = info->sector_size;
678 } 679 }
679 680
680 dev_info(&spi->dev, "%s (%d Kbytes)\n", info->name, 681 dev_info(&spi->dev, "%s (%lld Kbytes)\n", info->name,
681 flash->mtd.size / 1024); 682 (long long)flash->mtd.size >> 10);
682 683
683 DEBUG(MTD_DEBUG_LEVEL2, 684 DEBUG(MTD_DEBUG_LEVEL2,
684 "mtd .name = %s, .size = 0x%.8x (%uMiB) " 685 "mtd .name = %s, .size = 0x%llx (%lldMiB) "
685 ".erasesize = 0x%.8x (%uKiB) .numeraseregions = %d\n", 686 ".erasesize = 0x%.8x (%uKiB) .numeraseregions = %d\n",
686 flash->mtd.name, 687 flash->mtd.name,
687 flash->mtd.size, flash->mtd.size / (1024*1024), 688 (long long)flash->mtd.size, (long long)(flash->mtd.size >> 20),
688 flash->mtd.erasesize, flash->mtd.erasesize / 1024, 689 flash->mtd.erasesize, flash->mtd.erasesize / 1024,
689 flash->mtd.numeraseregions); 690 flash->mtd.numeraseregions);
690 691
691 if (flash->mtd.numeraseregions) 692 if (flash->mtd.numeraseregions)
692 for (i = 0; i < flash->mtd.numeraseregions; i++) 693 for (i = 0; i < flash->mtd.numeraseregions; i++)
693 DEBUG(MTD_DEBUG_LEVEL2, 694 DEBUG(MTD_DEBUG_LEVEL2,
694 "mtd.eraseregions[%d] = { .offset = 0x%.8x, " 695 "mtd.eraseregions[%d] = { .offset = 0x%llx, "
695 ".erasesize = 0x%.8x (%uKiB), " 696 ".erasesize = 0x%.8x (%uKiB), "
696 ".numblocks = %d }\n", 697 ".numblocks = %d }\n",
697 i, flash->mtd.eraseregions[i].offset, 698 i, (long long)flash->mtd.eraseregions[i].offset,
698 flash->mtd.eraseregions[i].erasesize, 699 flash->mtd.eraseregions[i].erasesize,
699 flash->mtd.eraseregions[i].erasesize / 1024, 700 flash->mtd.eraseregions[i].erasesize / 1024,
700 flash->mtd.eraseregions[i].numblocks); 701 flash->mtd.eraseregions[i].numblocks);
@@ -722,12 +723,12 @@ static int __devinit m25p_probe(struct spi_device *spi)
722 if (nr_parts > 0) { 723 if (nr_parts > 0) {
723 for (i = 0; i < nr_parts; i++) { 724 for (i = 0; i < nr_parts; i++) {
724 DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = " 725 DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = "
725 "{.name = %s, .offset = 0x%.8x, " 726 "{.name = %s, .offset = 0x%llx, "
726 ".size = 0x%.8x (%uKiB) }\n", 727 ".size = 0x%llx (%lldKiB) }\n",
727 i, parts[i].name, 728 i, parts[i].name,
728 parts[i].offset, 729 (long long)parts[i].offset,
729 parts[i].size, 730 (long long)parts[i].size,
730 parts[i].size / 1024); 731 (long long)(parts[i].size >> 10));
731 } 732 }
732 flash->partitioned = 1; 733 flash->partitioned = 1;
733 return add_mtd_partitions(&flash->mtd, parts, nr_parts); 734 return add_mtd_partitions(&flash->mtd, parts, nr_parts);
diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
index 65126cd668ff..d44f741ae229 100644
--- a/drivers/mtd/devices/mtd_dataflash.c
+++ b/drivers/mtd/devices/mtd_dataflash.c
@@ -16,6 +16,7 @@
16#include <linux/device.h> 16#include <linux/device.h>
17#include <linux/mutex.h> 17#include <linux/mutex.h>
18#include <linux/err.h> 18#include <linux/err.h>
19#include <linux/math64.h>
19 20
20#include <linux/spi/spi.h> 21#include <linux/spi/spi.h>
21#include <linux/spi/flash.h> 22#include <linux/spi/flash.h>
@@ -152,15 +153,20 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
152 struct spi_message msg; 153 struct spi_message msg;
153 unsigned blocksize = priv->page_size << 3; 154 unsigned blocksize = priv->page_size << 3;
154 uint8_t *command; 155 uint8_t *command;
156 uint32_t rem;
155 157
156 DEBUG(MTD_DEBUG_LEVEL2, "%s: erase addr=0x%x len 0x%x\n", 158 DEBUG(MTD_DEBUG_LEVEL2, "%s: erase addr=0x%llx len 0x%llx\n",
157 dev_name(&spi->dev), 159 dev_name(&spi->dev), (long long)instr->addr,
158 instr->addr, instr->len); 160 (long long)instr->len);
159 161
160 /* Sanity checks */ 162 /* Sanity checks */
161 if ((instr->addr + instr->len) > mtd->size 163 if (instr->addr + instr->len > mtd->size)
162 || (instr->len % priv->page_size) != 0 164 return -EINVAL;
163 || (instr->addr % priv->page_size) != 0) 165 div_u64_rem(instr->len, priv->page_size, &rem);
166 if (rem)
167 return -EINVAL;
168 div_u64_rem(instr->addr, priv->page_size, &rem);
169 if (rem)
164 return -EINVAL; 170 return -EINVAL;
165 171
166 spi_message_init(&msg); 172 spi_message_init(&msg);
@@ -178,7 +184,7 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
178 /* Calculate flash page address; use block erase (for speed) if 184 /* Calculate flash page address; use block erase (for speed) if
179 * we're at a block boundary and need to erase the whole block. 185 * we're at a block boundary and need to erase the whole block.
180 */ 186 */
181 pageaddr = instr->addr / priv->page_size; 187 pageaddr = div_u64(instr->len, priv->page_size);
182 do_block = (pageaddr & 0x7) == 0 && instr->len >= blocksize; 188 do_block = (pageaddr & 0x7) == 0 && instr->len >= blocksize;
183 pageaddr = pageaddr << priv->page_offset; 189 pageaddr = pageaddr << priv->page_offset;
184 190
@@ -667,8 +673,8 @@ add_dataflash_otp(struct spi_device *spi, char *name,
667 if (revision >= 'c') 673 if (revision >= 'c')
668 otp_tag = otp_setup(device, revision); 674 otp_tag = otp_setup(device, revision);
669 675
670 dev_info(&spi->dev, "%s (%d KBytes) pagesize %d bytes%s\n", 676 dev_info(&spi->dev, "%s (%lld KBytes) pagesize %d bytes%s\n",
671 name, DIV_ROUND_UP(device->size, 1024), 677 name, (long long)((device->size + 1023) >> 10),
672 pagesize, otp_tag); 678 pagesize, otp_tag);
673 dev_set_drvdata(&spi->dev, priv); 679 dev_set_drvdata(&spi->dev, priv);
674 680
diff --git a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c
index d38bca64bb15..d2fd550f7e09 100644
--- a/drivers/mtd/devices/pmc551.c
+++ b/drivers/mtd/devices/pmc551.c
@@ -34,7 +34,7 @@
34 * aperture size, not the dram size, and the V370PDC supplies no 34 * aperture size, not the dram size, and the V370PDC supplies no
35 * other method for memory size discovery. This problem is 35 * other method for memory size discovery. This problem is
36 * mostly only relevant when compiled as a module, as the 36 * mostly only relevant when compiled as a module, as the
37 * unloading of the module with an aperture size smaller then 37 * unloading of the module with an aperture size smaller than
38 * the ram will cause the driver to detect the onboard memory 38 * the ram will cause the driver to detect the onboard memory
39 * size to be equal to the aperture size when the module is 39 * size to be equal to the aperture size when the module is
40 * reloaded. Soooo, to help, the module supports an msize 40 * reloaded. Soooo, to help, the module supports an msize
diff --git a/drivers/mtd/devices/ps3vram.c b/drivers/mtd/devices/ps3vram.c
new file mode 100644
index 000000000000..d21e9beb7ed2
--- /dev/null
+++ b/drivers/mtd/devices/ps3vram.c
@@ -0,0 +1,768 @@
1/**
2 * ps3vram - Use extra PS3 video ram as MTD block device.
3 *
4 * Copyright (c) 2007-2008 Jim Paris <jim@jtan.com>
5 * Added support RSX DMA Vivien Chappelier <vivien.chappelier@free.fr>
6 */
7
8#include <linux/io.h>
9#include <linux/mm.h>
10#include <linux/init.h>
11#include <linux/kernel.h>
12#include <linux/list.h>
13#include <linux/module.h>
14#include <linux/moduleparam.h>
15#include <linux/slab.h>
16#include <linux/version.h>
17#include <linux/gfp.h>
18#include <linux/delay.h>
19#include <linux/mtd/mtd.h>
20
21#include <asm/lv1call.h>
22#include <asm/ps3.h>
23
24#define DEVICE_NAME "ps3vram"
25
26#define XDR_BUF_SIZE (2 * 1024 * 1024) /* XDR buffer (must be 1MiB aligned) */
27#define XDR_IOIF 0x0c000000
28
29#define FIFO_BASE XDR_IOIF
30#define FIFO_SIZE (64 * 1024)
31
32#define DMA_PAGE_SIZE (4 * 1024)
33
34#define CACHE_PAGE_SIZE (256 * 1024)
35#define CACHE_PAGE_COUNT ((XDR_BUF_SIZE - FIFO_SIZE) / CACHE_PAGE_SIZE)
36
37#define CACHE_OFFSET CACHE_PAGE_SIZE
38#define FIFO_OFFSET 0
39
40#define CTRL_PUT 0x10
41#define CTRL_GET 0x11
42#define CTRL_TOP 0x15
43
44#define UPLOAD_SUBCH 1
45#define DOWNLOAD_SUBCH 2
46
47#define NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN 0x0000030c
48#define NV_MEMORY_TO_MEMORY_FORMAT_NOTIFY 0x00000104
49
50#define L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT 0x601
51
52struct mtd_info ps3vram_mtd;
53
54#define CACHE_PAGE_PRESENT 1
55#define CACHE_PAGE_DIRTY 2
56
57struct ps3vram_tag {
58 unsigned int address;
59 unsigned int flags;
60};
61
62struct ps3vram_cache {
63 unsigned int page_count;
64 unsigned int page_size;
65 struct ps3vram_tag *tags;
66};
67
68struct ps3vram_priv {
69 u64 memory_handle;
70 u64 context_handle;
71 u32 *ctrl;
72 u32 *reports;
73 u8 __iomem *ddr_base;
74 u8 *xdr_buf;
75
76 u32 *fifo_base;
77 u32 *fifo_ptr;
78
79 struct device *dev;
80 struct ps3vram_cache cache;
81
82 /* Used to serialize cache/DMA operations */
83 struct mutex lock;
84};
85
86#define DMA_NOTIFIER_HANDLE_BASE 0x66604200 /* first DMA notifier handle */
87#define DMA_NOTIFIER_OFFSET_BASE 0x1000 /* first DMA notifier offset */
88#define DMA_NOTIFIER_SIZE 0x40
89#define NOTIFIER 7 /* notifier used for completion report */
90
91/* A trailing '-' means to subtract off ps3fb_videomemory.size */
92char *size = "256M-";
93module_param(size, charp, 0);
94MODULE_PARM_DESC(size, "memory size");
95
96static u32 *ps3vram_get_notifier(u32 *reports, int notifier)
97{
98 return (void *) reports +
99 DMA_NOTIFIER_OFFSET_BASE +
100 DMA_NOTIFIER_SIZE * notifier;
101}
102
103static void ps3vram_notifier_reset(struct mtd_info *mtd)
104{
105 int i;
106
107 struct ps3vram_priv *priv = mtd->priv;
108 u32 *notify = ps3vram_get_notifier(priv->reports, NOTIFIER);
109 for (i = 0; i < 4; i++)
110 notify[i] = 0xffffffff;
111}
112
113static int ps3vram_notifier_wait(struct mtd_info *mtd, unsigned int timeout_ms)
114{
115 struct ps3vram_priv *priv = mtd->priv;
116 u32 *notify = ps3vram_get_notifier(priv->reports, NOTIFIER);
117 unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
118
119 do {
120 if (!notify[3])
121 return 0;
122 msleep(1);
123 } while (time_before(jiffies, timeout));
124
125 return -ETIMEDOUT;
126}
127
128static void ps3vram_init_ring(struct mtd_info *mtd)
129{
130 struct ps3vram_priv *priv = mtd->priv;
131
132 priv->ctrl[CTRL_PUT] = FIFO_BASE + FIFO_OFFSET;
133 priv->ctrl[CTRL_GET] = FIFO_BASE + FIFO_OFFSET;
134}
135
136static int ps3vram_wait_ring(struct mtd_info *mtd, unsigned int timeout_ms)
137{
138 struct ps3vram_priv *priv = mtd->priv;
139 unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
140
141 do {
142 if (priv->ctrl[CTRL_PUT] == priv->ctrl[CTRL_GET])
143 return 0;
144 msleep(1);
145 } while (time_before(jiffies, timeout));
146
147 dev_dbg(priv->dev, "%s:%d: FIFO timeout (%08x/%08x/%08x)\n", __func__,
148 __LINE__, priv->ctrl[CTRL_PUT], priv->ctrl[CTRL_GET],
149 priv->ctrl[CTRL_TOP]);
150
151 return -ETIMEDOUT;
152}
153
154static void ps3vram_out_ring(struct ps3vram_priv *priv, u32 data)
155{
156 *(priv->fifo_ptr)++ = data;
157}
158
159static void ps3vram_begin_ring(struct ps3vram_priv *priv, u32 chan,
160 u32 tag, u32 size)
161{
162 ps3vram_out_ring(priv, (size << 18) | (chan << 13) | tag);
163}
164
165static void ps3vram_rewind_ring(struct mtd_info *mtd)
166{
167 struct ps3vram_priv *priv = mtd->priv;
168 u64 status;
169
170 ps3vram_out_ring(priv, 0x20000000 | (FIFO_BASE + FIFO_OFFSET));
171
172 priv->ctrl[CTRL_PUT] = FIFO_BASE + FIFO_OFFSET;
173
174 /* asking the HV for a blit will kick the fifo */
175 status = lv1_gpu_context_attribute(priv->context_handle,
176 L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT,
177 0, 0, 0, 0);
178 if (status)
179 dev_err(priv->dev, "%s:%d: lv1_gpu_context_attribute failed\n",
180 __func__, __LINE__);
181
182 priv->fifo_ptr = priv->fifo_base;
183}
184
185static void ps3vram_fire_ring(struct mtd_info *mtd)
186{
187 struct ps3vram_priv *priv = mtd->priv;
188 u64 status;
189
190 mutex_lock(&ps3_gpu_mutex);
191
192 priv->ctrl[CTRL_PUT] = FIFO_BASE + FIFO_OFFSET +
193 (priv->fifo_ptr - priv->fifo_base) * sizeof(u32);
194
195 /* asking the HV for a blit will kick the fifo */
196 status = lv1_gpu_context_attribute(priv->context_handle,
197 L1GPU_CONTEXT_ATTRIBUTE_FB_BLIT,
198 0, 0, 0, 0);
199 if (status)
200 dev_err(priv->dev, "%s:%d: lv1_gpu_context_attribute failed\n",
201 __func__, __LINE__);
202
203 if ((priv->fifo_ptr - priv->fifo_base) * sizeof(u32) >
204 FIFO_SIZE - 1024) {
205 dev_dbg(priv->dev, "%s:%d: fifo full, rewinding\n", __func__,
206 __LINE__);
207 ps3vram_wait_ring(mtd, 200);
208 ps3vram_rewind_ring(mtd);
209 }
210
211 mutex_unlock(&ps3_gpu_mutex);
212}
213
214static void ps3vram_bind(struct mtd_info *mtd)
215{
216 struct ps3vram_priv *priv = mtd->priv;
217
218 ps3vram_begin_ring(priv, UPLOAD_SUBCH, 0, 1);
219 ps3vram_out_ring(priv, 0x31337303);
220 ps3vram_begin_ring(priv, UPLOAD_SUBCH, 0x180, 3);
221 ps3vram_out_ring(priv, DMA_NOTIFIER_HANDLE_BASE + NOTIFIER);
222 ps3vram_out_ring(priv, 0xfeed0001); /* DMA system RAM instance */
223 ps3vram_out_ring(priv, 0xfeed0000); /* DMA video RAM instance */
224
225 ps3vram_begin_ring(priv, DOWNLOAD_SUBCH, 0, 1);
226 ps3vram_out_ring(priv, 0x3137c0de);
227 ps3vram_begin_ring(priv, DOWNLOAD_SUBCH, 0x180, 3);
228 ps3vram_out_ring(priv, DMA_NOTIFIER_HANDLE_BASE + NOTIFIER);
229 ps3vram_out_ring(priv, 0xfeed0000); /* DMA video RAM instance */
230 ps3vram_out_ring(priv, 0xfeed0001); /* DMA system RAM instance */
231
232 ps3vram_fire_ring(mtd);
233}
234
235static int ps3vram_upload(struct mtd_info *mtd, unsigned int src_offset,
236 unsigned int dst_offset, int len, int count)
237{
238 struct ps3vram_priv *priv = mtd->priv;
239
240 ps3vram_begin_ring(priv, UPLOAD_SUBCH,
241 NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN, 8);
242 ps3vram_out_ring(priv, XDR_IOIF + src_offset);
243 ps3vram_out_ring(priv, dst_offset);
244 ps3vram_out_ring(priv, len);
245 ps3vram_out_ring(priv, len);
246 ps3vram_out_ring(priv, len);
247 ps3vram_out_ring(priv, count);
248 ps3vram_out_ring(priv, (1 << 8) | 1);
249 ps3vram_out_ring(priv, 0);
250
251 ps3vram_notifier_reset(mtd);
252 ps3vram_begin_ring(priv, UPLOAD_SUBCH,
253 NV_MEMORY_TO_MEMORY_FORMAT_NOTIFY, 1);
254 ps3vram_out_ring(priv, 0);
255 ps3vram_begin_ring(priv, UPLOAD_SUBCH, 0x100, 1);
256 ps3vram_out_ring(priv, 0);
257 ps3vram_fire_ring(mtd);
258 if (ps3vram_notifier_wait(mtd, 200) < 0) {
259 dev_dbg(priv->dev, "%s:%d: notifier timeout\n", __func__,
260 __LINE__);
261 return -1;
262 }
263
264 return 0;
265}
266
267static int ps3vram_download(struct mtd_info *mtd, unsigned int src_offset,
268 unsigned int dst_offset, int len, int count)
269{
270 struct ps3vram_priv *priv = mtd->priv;
271
272 ps3vram_begin_ring(priv, DOWNLOAD_SUBCH,
273 NV_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN, 8);
274 ps3vram_out_ring(priv, src_offset);
275 ps3vram_out_ring(priv, XDR_IOIF + dst_offset);
276 ps3vram_out_ring(priv, len);
277 ps3vram_out_ring(priv, len);
278 ps3vram_out_ring(priv, len);
279 ps3vram_out_ring(priv, count);
280 ps3vram_out_ring(priv, (1 << 8) | 1);
281 ps3vram_out_ring(priv, 0);
282
283 ps3vram_notifier_reset(mtd);
284 ps3vram_begin_ring(priv, DOWNLOAD_SUBCH,
285 NV_MEMORY_TO_MEMORY_FORMAT_NOTIFY, 1);
286 ps3vram_out_ring(priv, 0);
287 ps3vram_begin_ring(priv, DOWNLOAD_SUBCH, 0x100, 1);
288 ps3vram_out_ring(priv, 0);
289 ps3vram_fire_ring(mtd);
290 if (ps3vram_notifier_wait(mtd, 200) < 0) {
291 dev_dbg(priv->dev, "%s:%d: notifier timeout\n", __func__,
292 __LINE__);
293 return -1;
294 }
295
296 return 0;
297}
298
299static void ps3vram_cache_evict(struct mtd_info *mtd, int entry)
300{
301 struct ps3vram_priv *priv = mtd->priv;
302 struct ps3vram_cache *cache = &priv->cache;
303
304 if (cache->tags[entry].flags & CACHE_PAGE_DIRTY) {
305 dev_dbg(priv->dev, "%s:%d: flushing %d : 0x%08x\n", __func__,
306 __LINE__, entry, cache->tags[entry].address);
307 if (ps3vram_upload(mtd,
308 CACHE_OFFSET + entry * cache->page_size,
309 cache->tags[entry].address,
310 DMA_PAGE_SIZE,
311 cache->page_size / DMA_PAGE_SIZE) < 0) {
312 dev_dbg(priv->dev, "%s:%d: failed to upload from "
313 "0x%x to 0x%x size 0x%x\n", __func__, __LINE__,
314 entry * cache->page_size,
315 cache->tags[entry].address, cache->page_size);
316 }
317 cache->tags[entry].flags &= ~CACHE_PAGE_DIRTY;
318 }
319}
320
321static void ps3vram_cache_load(struct mtd_info *mtd, int entry,
322 unsigned int address)
323{
324 struct ps3vram_priv *priv = mtd->priv;
325 struct ps3vram_cache *cache = &priv->cache;
326
327 dev_dbg(priv->dev, "%s:%d: fetching %d : 0x%08x\n", __func__, __LINE__,
328 entry, address);
329 if (ps3vram_download(mtd,
330 address,
331 CACHE_OFFSET + entry * cache->page_size,
332 DMA_PAGE_SIZE,
333 cache->page_size / DMA_PAGE_SIZE) < 0) {
334 dev_err(priv->dev, "%s:%d: failed to download from "
335 "0x%x to 0x%x size 0x%x\n", __func__, __LINE__, address,
336 entry * cache->page_size, cache->page_size);
337 }
338
339 cache->tags[entry].address = address;
340 cache->tags[entry].flags |= CACHE_PAGE_PRESENT;
341}
342
343
344static void ps3vram_cache_flush(struct mtd_info *mtd)
345{
346 struct ps3vram_priv *priv = mtd->priv;
347 struct ps3vram_cache *cache = &priv->cache;
348 int i;
349
350 dev_dbg(priv->dev, "%s:%d: FLUSH\n", __func__, __LINE__);
351 for (i = 0; i < cache->page_count; i++) {
352 ps3vram_cache_evict(mtd, i);
353 cache->tags[i].flags = 0;
354 }
355}
356
357static unsigned int ps3vram_cache_match(struct mtd_info *mtd, loff_t address)
358{
359 struct ps3vram_priv *priv = mtd->priv;
360 struct ps3vram_cache *cache = &priv->cache;
361 unsigned int base;
362 unsigned int offset;
363 int i;
364 static int counter;
365
366 offset = (unsigned int) (address & (cache->page_size - 1));
367 base = (unsigned int) (address - offset);
368
369 /* fully associative check */
370 for (i = 0; i < cache->page_count; i++) {
371 if ((cache->tags[i].flags & CACHE_PAGE_PRESENT) &&
372 cache->tags[i].address == base) {
373 dev_dbg(priv->dev, "%s:%d: found entry %d : 0x%08x\n",
374 __func__, __LINE__, i, cache->tags[i].address);
375 return i;
376 }
377 }
378
379 /* choose a random entry */
380 i = (jiffies + (counter++)) % cache->page_count;
381 dev_dbg(priv->dev, "%s:%d: using entry %d\n", __func__, __LINE__, i);
382
383 ps3vram_cache_evict(mtd, i);
384 ps3vram_cache_load(mtd, i, base);
385
386 return i;
387}
388
389static int ps3vram_cache_init(struct mtd_info *mtd)
390{
391 struct ps3vram_priv *priv = mtd->priv;
392
393 priv->cache.page_count = CACHE_PAGE_COUNT;
394 priv->cache.page_size = CACHE_PAGE_SIZE;
395 priv->cache.tags = kzalloc(sizeof(struct ps3vram_tag) *
396 CACHE_PAGE_COUNT, GFP_KERNEL);
397 if (priv->cache.tags == NULL) {
398 dev_err(priv->dev, "%s:%d: could not allocate cache tags\n",
399 __func__, __LINE__);
400 return -ENOMEM;
401 }
402
403 dev_info(priv->dev, "created ram cache: %d entries, %d KiB each\n",
404 CACHE_PAGE_COUNT, CACHE_PAGE_SIZE / 1024);
405
406 return 0;
407}
408
409static void ps3vram_cache_cleanup(struct mtd_info *mtd)
410{
411 struct ps3vram_priv *priv = mtd->priv;
412
413 ps3vram_cache_flush(mtd);
414 kfree(priv->cache.tags);
415}
416
417static int ps3vram_erase(struct mtd_info *mtd, struct erase_info *instr)
418{
419 struct ps3vram_priv *priv = mtd->priv;
420
421 if (instr->addr + instr->len > mtd->size)
422 return -EINVAL;
423
424 mutex_lock(&priv->lock);
425
426 ps3vram_cache_flush(mtd);
427
428 /* Set bytes to 0xFF */
429 memset_io(priv->ddr_base + instr->addr, 0xFF, instr->len);
430
431 mutex_unlock(&priv->lock);
432
433 instr->state = MTD_ERASE_DONE;
434 mtd_erase_callback(instr);
435
436 return 0;
437}
438
439static int ps3vram_read(struct mtd_info *mtd, loff_t from, size_t len,
440 size_t *retlen, u_char *buf)
441{
442 struct ps3vram_priv *priv = mtd->priv;
443 unsigned int cached, count;
444
445 dev_dbg(priv->dev, "%s:%d: from=0x%08x len=0x%zx\n", __func__, __LINE__,
446 (unsigned int)from, len);
447
448 if (from >= mtd->size)
449 return -EINVAL;
450
451 if (len > mtd->size - from)
452 len = mtd->size - from;
453
454 /* Copy from vram to buf */
455 count = len;
456 while (count) {
457 unsigned int offset, avail;
458 unsigned int entry;
459
460 offset = (unsigned int) (from & (priv->cache.page_size - 1));
461 avail = priv->cache.page_size - offset;
462
463 mutex_lock(&priv->lock);
464
465 entry = ps3vram_cache_match(mtd, from);
466 cached = CACHE_OFFSET + entry * priv->cache.page_size + offset;
467
468 dev_dbg(priv->dev, "%s:%d: from=%08x cached=%08x offset=%08x "
469 "avail=%08x count=%08x\n", __func__, __LINE__,
470 (unsigned int)from, cached, offset, avail, count);
471
472 if (avail > count)
473 avail = count;
474 memcpy(buf, priv->xdr_buf + cached, avail);
475
476 mutex_unlock(&priv->lock);
477
478 buf += avail;
479 count -= avail;
480 from += avail;
481 }
482
483 *retlen = len;
484 return 0;
485}
486
487static int ps3vram_write(struct mtd_info *mtd, loff_t to, size_t len,
488 size_t *retlen, const u_char *buf)
489{
490 struct ps3vram_priv *priv = mtd->priv;
491 unsigned int cached, count;
492
493 if (to >= mtd->size)
494 return -EINVAL;
495
496 if (len > mtd->size - to)
497 len = mtd->size - to;
498
499 /* Copy from buf to vram */
500 count = len;
501 while (count) {
502 unsigned int offset, avail;
503 unsigned int entry;
504
505 offset = (unsigned int) (to & (priv->cache.page_size - 1));
506 avail = priv->cache.page_size - offset;
507
508 mutex_lock(&priv->lock);
509
510 entry = ps3vram_cache_match(mtd, to);
511 cached = CACHE_OFFSET + entry * priv->cache.page_size + offset;
512
513 dev_dbg(priv->dev, "%s:%d: to=%08x cached=%08x offset=%08x "
514 "avail=%08x count=%08x\n", __func__, __LINE__,
515 (unsigned int)to, cached, offset, avail, count);
516
517 if (avail > count)
518 avail = count;
519 memcpy(priv->xdr_buf + cached, buf, avail);
520
521 priv->cache.tags[entry].flags |= CACHE_PAGE_DIRTY;
522
523 mutex_unlock(&priv->lock);
524
525 buf += avail;
526 count -= avail;
527 to += avail;
528 }
529
530 *retlen = len;
531 return 0;
532}
533
534static int __devinit ps3vram_probe(struct ps3_system_bus_device *dev)
535{
536 struct ps3vram_priv *priv;
537 int status;
538 u64 ddr_lpar;
539 u64 ctrl_lpar;
540 u64 info_lpar;
541 u64 reports_lpar;
542 u64 ddr_size;
543 u64 reports_size;
544 int ret = -ENOMEM;
545 char *rest;
546
547 ret = -EIO;
548 ps3vram_mtd.priv = kzalloc(sizeof(struct ps3vram_priv), GFP_KERNEL);
549 if (!ps3vram_mtd.priv)
550 goto out;
551 priv = ps3vram_mtd.priv;
552
553 mutex_init(&priv->lock);
554 priv->dev = &dev->core;
555
556 /* Allocate XDR buffer (1MiB aligned) */
557 priv->xdr_buf = (void *)__get_free_pages(GFP_KERNEL,
558 get_order(XDR_BUF_SIZE));
559 if (priv->xdr_buf == NULL) {
560 dev_dbg(&dev->core, "%s:%d: could not allocate XDR buffer\n",
561 __func__, __LINE__);
562 ret = -ENOMEM;
563 goto out_free_priv;
564 }
565
566 /* Put FIFO at begginning of XDR buffer */
567 priv->fifo_base = (u32 *) (priv->xdr_buf + FIFO_OFFSET);
568 priv->fifo_ptr = priv->fifo_base;
569
570 /* XXX: Need to open GPU, in case ps3fb or snd_ps3 aren't loaded */
571 if (ps3_open_hv_device(dev)) {
572 dev_err(&dev->core, "%s:%d: ps3_open_hv_device failed\n",
573 __func__, __LINE__);
574 ret = -EAGAIN;
575 goto out_close_gpu;
576 }
577
578 /* Request memory */
579 status = -1;
580 ddr_size = memparse(size, &rest);
581 if (*rest == '-')
582 ddr_size -= ps3fb_videomemory.size;
583 ddr_size = ALIGN(ddr_size, 1024*1024);
584 if (ddr_size <= 0) {
585 dev_err(&dev->core, "%s:%d: specified size is too small\n",
586 __func__, __LINE__);
587 ret = -EINVAL;
588 goto out_close_gpu;
589 }
590
591 while (ddr_size > 0) {
592 status = lv1_gpu_memory_allocate(ddr_size, 0, 0, 0, 0,
593 &priv->memory_handle,
594 &ddr_lpar);
595 if (!status)
596 break;
597 ddr_size -= 1024*1024;
598 }
599 if (status || ddr_size <= 0) {
600 dev_err(&dev->core, "%s:%d: lv1_gpu_memory_allocate failed\n",
601 __func__, __LINE__);
602 ret = -ENOMEM;
603 goto out_free_xdr_buf;
604 }
605
606 /* Request context */
607 status = lv1_gpu_context_allocate(priv->memory_handle,
608 0,
609 &priv->context_handle,
610 &ctrl_lpar,
611 &info_lpar,
612 &reports_lpar,
613 &reports_size);
614 if (status) {
615 dev_err(&dev->core, "%s:%d: lv1_gpu_context_allocate failed\n",
616 __func__, __LINE__);
617 ret = -ENOMEM;
618 goto out_free_memory;
619 }
620
621 /* Map XDR buffer to RSX */
622 status = lv1_gpu_context_iomap(priv->context_handle, XDR_IOIF,
623 ps3_mm_phys_to_lpar(__pa(priv->xdr_buf)),
624 XDR_BUF_SIZE, 0);
625 if (status) {
626 dev_err(&dev->core, "%s:%d: lv1_gpu_context_iomap failed\n",
627 __func__, __LINE__);
628 ret = -ENOMEM;
629 goto out_free_context;
630 }
631
632 priv->ddr_base = ioremap_flags(ddr_lpar, ddr_size, _PAGE_NO_CACHE);
633
634 if (!priv->ddr_base) {
635 dev_err(&dev->core, "%s:%d: ioremap failed\n", __func__,
636 __LINE__);
637 ret = -ENOMEM;
638 goto out_free_context;
639 }
640
641 priv->ctrl = ioremap(ctrl_lpar, 64 * 1024);
642 if (!priv->ctrl) {
643 dev_err(&dev->core, "%s:%d: ioremap failed\n", __func__,
644 __LINE__);
645 ret = -ENOMEM;
646 goto out_unmap_vram;
647 }
648
649 priv->reports = ioremap(reports_lpar, reports_size);
650 if (!priv->reports) {
651 dev_err(&dev->core, "%s:%d: ioremap failed\n", __func__,
652 __LINE__);
653 ret = -ENOMEM;
654 goto out_unmap_ctrl;
655 }
656
657 mutex_lock(&ps3_gpu_mutex);
658 ps3vram_init_ring(&ps3vram_mtd);
659 mutex_unlock(&ps3_gpu_mutex);
660
661 ps3vram_mtd.name = "ps3vram";
662 ps3vram_mtd.size = ddr_size;
663 ps3vram_mtd.flags = MTD_CAP_RAM;
664 ps3vram_mtd.erase = ps3vram_erase;
665 ps3vram_mtd.point = NULL;
666 ps3vram_mtd.unpoint = NULL;
667 ps3vram_mtd.read = ps3vram_read;
668 ps3vram_mtd.write = ps3vram_write;
669 ps3vram_mtd.owner = THIS_MODULE;
670 ps3vram_mtd.type = MTD_RAM;
671 ps3vram_mtd.erasesize = CACHE_PAGE_SIZE;
672 ps3vram_mtd.writesize = 1;
673
674 ps3vram_bind(&ps3vram_mtd);
675
676 mutex_lock(&ps3_gpu_mutex);
677 ret = ps3vram_wait_ring(&ps3vram_mtd, 100);
678 mutex_unlock(&ps3_gpu_mutex);
679 if (ret < 0) {
680 dev_err(&dev->core, "%s:%d: failed to initialize channels\n",
681 __func__, __LINE__);
682 ret = -ETIMEDOUT;
683 goto out_unmap_reports;
684 }
685
686 ps3vram_cache_init(&ps3vram_mtd);
687
688 if (add_mtd_device(&ps3vram_mtd)) {
689 dev_err(&dev->core, "%s:%d: add_mtd_device failed\n",
690 __func__, __LINE__);
691 ret = -EAGAIN;
692 goto out_cache_cleanup;
693 }
694
695 dev_info(&dev->core, "reserved %u MiB of gpu memory\n",
696 (unsigned int)(ddr_size / 1024 / 1024));
697
698 return 0;
699
700out_cache_cleanup:
701 ps3vram_cache_cleanup(&ps3vram_mtd);
702out_unmap_reports:
703 iounmap(priv->reports);
704out_unmap_ctrl:
705 iounmap(priv->ctrl);
706out_unmap_vram:
707 iounmap(priv->ddr_base);
708out_free_context:
709 lv1_gpu_context_free(priv->context_handle);
710out_free_memory:
711 lv1_gpu_memory_free(priv->memory_handle);
712out_close_gpu:
713 ps3_close_hv_device(dev);
714out_free_xdr_buf:
715 free_pages((unsigned long) priv->xdr_buf, get_order(XDR_BUF_SIZE));
716out_free_priv:
717 kfree(ps3vram_mtd.priv);
718 ps3vram_mtd.priv = NULL;
719out:
720 return ret;
721}
722
723static int ps3vram_shutdown(struct ps3_system_bus_device *dev)
724{
725 struct ps3vram_priv *priv;
726
727 priv = ps3vram_mtd.priv;
728
729 del_mtd_device(&ps3vram_mtd);
730 ps3vram_cache_cleanup(&ps3vram_mtd);
731 iounmap(priv->reports);
732 iounmap(priv->ctrl);
733 iounmap(priv->ddr_base);
734 lv1_gpu_context_free(priv->context_handle);
735 lv1_gpu_memory_free(priv->memory_handle);
736 ps3_close_hv_device(dev);
737 free_pages((unsigned long) priv->xdr_buf, get_order(XDR_BUF_SIZE));
738 kfree(priv);
739 return 0;
740}
741
742static struct ps3_system_bus_driver ps3vram_driver = {
743 .match_id = PS3_MATCH_ID_GPU,
744 .match_sub_id = PS3_MATCH_SUB_ID_GPU_RAMDISK,
745 .core.name = DEVICE_NAME,
746 .core.owner = THIS_MODULE,
747 .probe = ps3vram_probe,
748 .remove = ps3vram_shutdown,
749 .shutdown = ps3vram_shutdown,
750};
751
752static int __init ps3vram_init(void)
753{
754 return ps3_system_bus_driver_register(&ps3vram_driver);
755}
756
757static void __exit ps3vram_exit(void)
758{
759 ps3_system_bus_driver_unregister(&ps3vram_driver);
760}
761
762module_init(ps3vram_init);
763module_exit(ps3vram_exit);
764
765MODULE_LICENSE("GPL");
766MODULE_AUTHOR("Jim Paris <jim@jtan.com>");
767MODULE_DESCRIPTION("MTD driver for PS3 video RAM");
768MODULE_ALIAS(PS3_MODULE_ALIAS_GPU_RAMDISK);
diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c
index 9bf581c4f740..a790c062af1f 100644
--- a/drivers/mtd/ftl.c
+++ b/drivers/mtd/ftl.c
@@ -109,25 +109,25 @@ module_param(shuffle_freq, int, 0);
109/* Each memory region corresponds to a minor device */ 109/* Each memory region corresponds to a minor device */
110typedef struct partition_t { 110typedef struct partition_t {
111 struct mtd_blktrans_dev mbd; 111 struct mtd_blktrans_dev mbd;
112 u_int32_t state; 112 uint32_t state;
113 u_int32_t *VirtualBlockMap; 113 uint32_t *VirtualBlockMap;
114 u_int32_t *VirtualPageMap; 114 uint32_t *VirtualPageMap;
115 u_int32_t FreeTotal; 115 uint32_t FreeTotal;
116 struct eun_info_t { 116 struct eun_info_t {
117 u_int32_t Offset; 117 uint32_t Offset;
118 u_int32_t EraseCount; 118 uint32_t EraseCount;
119 u_int32_t Free; 119 uint32_t Free;
120 u_int32_t Deleted; 120 uint32_t Deleted;
121 } *EUNInfo; 121 } *EUNInfo;
122 struct xfer_info_t { 122 struct xfer_info_t {
123 u_int32_t Offset; 123 uint32_t Offset;
124 u_int32_t EraseCount; 124 uint32_t EraseCount;
125 u_int16_t state; 125 uint16_t state;
126 } *XferInfo; 126 } *XferInfo;
127 u_int16_t bam_index; 127 uint16_t bam_index;
128 u_int32_t *bam_cache; 128 uint32_t *bam_cache;
129 u_int16_t DataUnits; 129 uint16_t DataUnits;
130 u_int32_t BlocksPerUnit; 130 uint32_t BlocksPerUnit;
131 erase_unit_header_t header; 131 erase_unit_header_t header;
132} partition_t; 132} partition_t;
133 133
@@ -199,8 +199,8 @@ static int scan_header(partition_t *part)
199static int build_maps(partition_t *part) 199static int build_maps(partition_t *part)
200{ 200{
201 erase_unit_header_t header; 201 erase_unit_header_t header;
202 u_int16_t xvalid, xtrans, i; 202 uint16_t xvalid, xtrans, i;
203 u_int blocks, j; 203 unsigned blocks, j;
204 int hdr_ok, ret = -1; 204 int hdr_ok, ret = -1;
205 ssize_t retval; 205 ssize_t retval;
206 loff_t offset; 206 loff_t offset;
@@ -269,14 +269,14 @@ static int build_maps(partition_t *part)
269 269
270 /* Set up virtual page map */ 270 /* Set up virtual page map */
271 blocks = le32_to_cpu(header.FormattedSize) >> header.BlockSize; 271 blocks = le32_to_cpu(header.FormattedSize) >> header.BlockSize;
272 part->VirtualBlockMap = vmalloc(blocks * sizeof(u_int32_t)); 272 part->VirtualBlockMap = vmalloc(blocks * sizeof(uint32_t));
273 if (!part->VirtualBlockMap) 273 if (!part->VirtualBlockMap)
274 goto out_XferInfo; 274 goto out_XferInfo;
275 275
276 memset(part->VirtualBlockMap, 0xff, blocks * sizeof(u_int32_t)); 276 memset(part->VirtualBlockMap, 0xff, blocks * sizeof(uint32_t));
277 part->BlocksPerUnit = (1 << header.EraseUnitSize) >> header.BlockSize; 277 part->BlocksPerUnit = (1 << header.EraseUnitSize) >> header.BlockSize;
278 278
279 part->bam_cache = kmalloc(part->BlocksPerUnit * sizeof(u_int32_t), 279 part->bam_cache = kmalloc(part->BlocksPerUnit * sizeof(uint32_t),
280 GFP_KERNEL); 280 GFP_KERNEL);
281 if (!part->bam_cache) 281 if (!part->bam_cache)
282 goto out_VirtualBlockMap; 282 goto out_VirtualBlockMap;
@@ -290,7 +290,7 @@ static int build_maps(partition_t *part)
290 offset = part->EUNInfo[i].Offset + le32_to_cpu(header.BAMOffset); 290 offset = part->EUNInfo[i].Offset + le32_to_cpu(header.BAMOffset);
291 291
292 ret = part->mbd.mtd->read(part->mbd.mtd, offset, 292 ret = part->mbd.mtd->read(part->mbd.mtd, offset,
293 part->BlocksPerUnit * sizeof(u_int32_t), &retval, 293 part->BlocksPerUnit * sizeof(uint32_t), &retval,
294 (unsigned char *)part->bam_cache); 294 (unsigned char *)part->bam_cache);
295 295
296 if (ret) 296 if (ret)
@@ -332,7 +332,7 @@ out:
332======================================================================*/ 332======================================================================*/
333 333
334static int erase_xfer(partition_t *part, 334static int erase_xfer(partition_t *part,
335 u_int16_t xfernum) 335 uint16_t xfernum)
336{ 336{
337 int ret; 337 int ret;
338 struct xfer_info_t *xfer; 338 struct xfer_info_t *xfer;
@@ -408,7 +408,7 @@ static int prepare_xfer(partition_t *part, int i)
408 erase_unit_header_t header; 408 erase_unit_header_t header;
409 struct xfer_info_t *xfer; 409 struct xfer_info_t *xfer;
410 int nbam, ret; 410 int nbam, ret;
411 u_int32_t ctl; 411 uint32_t ctl;
412 ssize_t retlen; 412 ssize_t retlen;
413 loff_t offset; 413 loff_t offset;
414 414
@@ -430,15 +430,15 @@ static int prepare_xfer(partition_t *part, int i)
430 } 430 }
431 431
432 /* Write the BAM stub */ 432 /* Write the BAM stub */
433 nbam = (part->BlocksPerUnit * sizeof(u_int32_t) + 433 nbam = (part->BlocksPerUnit * sizeof(uint32_t) +
434 le32_to_cpu(part->header.BAMOffset) + SECTOR_SIZE - 1) / SECTOR_SIZE; 434 le32_to_cpu(part->header.BAMOffset) + SECTOR_SIZE - 1) / SECTOR_SIZE;
435 435
436 offset = xfer->Offset + le32_to_cpu(part->header.BAMOffset); 436 offset = xfer->Offset + le32_to_cpu(part->header.BAMOffset);
437 ctl = cpu_to_le32(BLOCK_CONTROL); 437 ctl = cpu_to_le32(BLOCK_CONTROL);
438 438
439 for (i = 0; i < nbam; i++, offset += sizeof(u_int32_t)) { 439 for (i = 0; i < nbam; i++, offset += sizeof(uint32_t)) {
440 440
441 ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(u_int32_t), 441 ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(uint32_t),
442 &retlen, (u_char *)&ctl); 442 &retlen, (u_char *)&ctl);
443 443
444 if (ret) 444 if (ret)
@@ -461,18 +461,18 @@ static int prepare_xfer(partition_t *part, int i)
461 461
462======================================================================*/ 462======================================================================*/
463 463
464static int copy_erase_unit(partition_t *part, u_int16_t srcunit, 464static int copy_erase_unit(partition_t *part, uint16_t srcunit,
465 u_int16_t xferunit) 465 uint16_t xferunit)
466{ 466{
467 u_char buf[SECTOR_SIZE]; 467 u_char buf[SECTOR_SIZE];
468 struct eun_info_t *eun; 468 struct eun_info_t *eun;
469 struct xfer_info_t *xfer; 469 struct xfer_info_t *xfer;
470 u_int32_t src, dest, free, i; 470 uint32_t src, dest, free, i;
471 u_int16_t unit; 471 uint16_t unit;
472 int ret; 472 int ret;
473 ssize_t retlen; 473 ssize_t retlen;
474 loff_t offset; 474 loff_t offset;
475 u_int16_t srcunitswap = cpu_to_le16(srcunit); 475 uint16_t srcunitswap = cpu_to_le16(srcunit);
476 476
477 eun = &part->EUNInfo[srcunit]; 477 eun = &part->EUNInfo[srcunit];
478 xfer = &part->XferInfo[xferunit]; 478 xfer = &part->XferInfo[xferunit];
@@ -486,7 +486,7 @@ static int copy_erase_unit(partition_t *part, u_int16_t srcunit,
486 offset = eun->Offset + le32_to_cpu(part->header.BAMOffset); 486 offset = eun->Offset + le32_to_cpu(part->header.BAMOffset);
487 487
488 ret = part->mbd.mtd->read(part->mbd.mtd, offset, 488 ret = part->mbd.mtd->read(part->mbd.mtd, offset,
489 part->BlocksPerUnit * sizeof(u_int32_t), 489 part->BlocksPerUnit * sizeof(uint32_t),
490 &retlen, (u_char *) (part->bam_cache)); 490 &retlen, (u_char *) (part->bam_cache));
491 491
492 /* mark the cache bad, in case we get an error later */ 492 /* mark the cache bad, in case we get an error later */
@@ -503,7 +503,7 @@ static int copy_erase_unit(partition_t *part, u_int16_t srcunit,
503 offset = xfer->Offset + 20; /* Bad! */ 503 offset = xfer->Offset + 20; /* Bad! */
504 unit = cpu_to_le16(0x7fff); 504 unit = cpu_to_le16(0x7fff);
505 505
506 ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(u_int16_t), 506 ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(uint16_t),
507 &retlen, (u_char *) &unit); 507 &retlen, (u_char *) &unit);
508 508
509 if (ret) { 509 if (ret) {
@@ -560,7 +560,7 @@ static int copy_erase_unit(partition_t *part, u_int16_t srcunit,
560 560
561 561
562 /* All clear? Then update the LogicalEUN again */ 562 /* All clear? Then update the LogicalEUN again */
563 ret = part->mbd.mtd->write(part->mbd.mtd, xfer->Offset + 20, sizeof(u_int16_t), 563 ret = part->mbd.mtd->write(part->mbd.mtd, xfer->Offset + 20, sizeof(uint16_t),
564 &retlen, (u_char *)&srcunitswap); 564 &retlen, (u_char *)&srcunitswap);
565 565
566 if (ret) { 566 if (ret) {
@@ -605,8 +605,8 @@ static int copy_erase_unit(partition_t *part, u_int16_t srcunit,
605 605
606static int reclaim_block(partition_t *part) 606static int reclaim_block(partition_t *part)
607{ 607{
608 u_int16_t i, eun, xfer; 608 uint16_t i, eun, xfer;
609 u_int32_t best; 609 uint32_t best;
610 int queued, ret; 610 int queued, ret;
611 611
612 DEBUG(0, "ftl_cs: reclaiming space...\n"); 612 DEBUG(0, "ftl_cs: reclaiming space...\n");
@@ -723,10 +723,10 @@ static void dump_lists(partition_t *part)
723} 723}
724#endif 724#endif
725 725
726static u_int32_t find_free(partition_t *part) 726static uint32_t find_free(partition_t *part)
727{ 727{
728 u_int16_t stop, eun; 728 uint16_t stop, eun;
729 u_int32_t blk; 729 uint32_t blk;
730 size_t retlen; 730 size_t retlen;
731 int ret; 731 int ret;
732 732
@@ -749,7 +749,7 @@ static u_int32_t find_free(partition_t *part)
749 749
750 ret = part->mbd.mtd->read(part->mbd.mtd, 750 ret = part->mbd.mtd->read(part->mbd.mtd,
751 part->EUNInfo[eun].Offset + le32_to_cpu(part->header.BAMOffset), 751 part->EUNInfo[eun].Offset + le32_to_cpu(part->header.BAMOffset),
752 part->BlocksPerUnit * sizeof(u_int32_t), 752 part->BlocksPerUnit * sizeof(uint32_t),
753 &retlen, (u_char *) (part->bam_cache)); 753 &retlen, (u_char *) (part->bam_cache));
754 754
755 if (ret) { 755 if (ret) {
@@ -786,7 +786,7 @@ static u_int32_t find_free(partition_t *part)
786static int ftl_read(partition_t *part, caddr_t buffer, 786static int ftl_read(partition_t *part, caddr_t buffer,
787 u_long sector, u_long nblocks) 787 u_long sector, u_long nblocks)
788{ 788{
789 u_int32_t log_addr, bsize; 789 uint32_t log_addr, bsize;
790 u_long i; 790 u_long i;
791 int ret; 791 int ret;
792 size_t offset, retlen; 792 size_t offset, retlen;
@@ -829,14 +829,14 @@ static int ftl_read(partition_t *part, caddr_t buffer,
829 829
830======================================================================*/ 830======================================================================*/
831 831
832static int set_bam_entry(partition_t *part, u_int32_t log_addr, 832static int set_bam_entry(partition_t *part, uint32_t log_addr,
833 u_int32_t virt_addr) 833 uint32_t virt_addr)
834{ 834{
835 u_int32_t bsize, blk, le_virt_addr; 835 uint32_t bsize, blk, le_virt_addr;
836#ifdef PSYCHO_DEBUG 836#ifdef PSYCHO_DEBUG
837 u_int32_t old_addr; 837 uint32_t old_addr;
838#endif 838#endif
839 u_int16_t eun; 839 uint16_t eun;
840 int ret; 840 int ret;
841 size_t retlen, offset; 841 size_t retlen, offset;
842 842
@@ -845,11 +845,11 @@ static int set_bam_entry(partition_t *part, u_int32_t log_addr,
845 bsize = 1 << part->header.EraseUnitSize; 845 bsize = 1 << part->header.EraseUnitSize;
846 eun = log_addr / bsize; 846 eun = log_addr / bsize;
847 blk = (log_addr % bsize) / SECTOR_SIZE; 847 blk = (log_addr % bsize) / SECTOR_SIZE;
848 offset = (part->EUNInfo[eun].Offset + blk * sizeof(u_int32_t) + 848 offset = (part->EUNInfo[eun].Offset + blk * sizeof(uint32_t) +
849 le32_to_cpu(part->header.BAMOffset)); 849 le32_to_cpu(part->header.BAMOffset));
850 850
851#ifdef PSYCHO_DEBUG 851#ifdef PSYCHO_DEBUG
852 ret = part->mbd.mtd->read(part->mbd.mtd, offset, sizeof(u_int32_t), 852 ret = part->mbd.mtd->read(part->mbd.mtd, offset, sizeof(uint32_t),
853 &retlen, (u_char *)&old_addr); 853 &retlen, (u_char *)&old_addr);
854 if (ret) { 854 if (ret) {
855 printk(KERN_WARNING"ftl: Error reading old_addr in set_bam_entry: %d\n",ret); 855 printk(KERN_WARNING"ftl: Error reading old_addr in set_bam_entry: %d\n",ret);
@@ -886,7 +886,7 @@ static int set_bam_entry(partition_t *part, u_int32_t log_addr,
886#endif 886#endif
887 part->bam_cache[blk] = le_virt_addr; 887 part->bam_cache[blk] = le_virt_addr;
888 } 888 }
889 ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(u_int32_t), 889 ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(uint32_t),
890 &retlen, (u_char *)&le_virt_addr); 890 &retlen, (u_char *)&le_virt_addr);
891 891
892 if (ret) { 892 if (ret) {
@@ -900,7 +900,7 @@ static int set_bam_entry(partition_t *part, u_int32_t log_addr,
900static int ftl_write(partition_t *part, caddr_t buffer, 900static int ftl_write(partition_t *part, caddr_t buffer,
901 u_long sector, u_long nblocks) 901 u_long sector, u_long nblocks)
902{ 902{
903 u_int32_t bsize, log_addr, virt_addr, old_addr, blk; 903 uint32_t bsize, log_addr, virt_addr, old_addr, blk;
904 u_long i; 904 u_long i;
905 int ret; 905 int ret;
906 size_t retlen, offset; 906 size_t retlen, offset;
diff --git a/drivers/mtd/inftlcore.c b/drivers/mtd/inftlcore.c
index 50ce13887f63..73f05227dc8c 100644
--- a/drivers/mtd/inftlcore.c
+++ b/drivers/mtd/inftlcore.c
@@ -50,7 +50,7 @@ static void inftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
50 struct INFTLrecord *inftl; 50 struct INFTLrecord *inftl;
51 unsigned long temp; 51 unsigned long temp;
52 52
53 if (mtd->type != MTD_NANDFLASH) 53 if (mtd->type != MTD_NANDFLASH || mtd->size > UINT_MAX)
54 return; 54 return;
55 /* OK, this is moderately ugly. But probably safe. Alternatives? */ 55 /* OK, this is moderately ugly. But probably safe. Alternatives? */
56 if (memcmp(mtd->name, "DiskOnChip", 10)) 56 if (memcmp(mtd->name, "DiskOnChip", 10))
diff --git a/drivers/mtd/inftlmount.c b/drivers/mtd/inftlmount.c
index 9113628ed1ef..f751dd97c549 100644
--- a/drivers/mtd/inftlmount.c
+++ b/drivers/mtd/inftlmount.c
@@ -63,7 +63,7 @@ static int find_boot_record(struct INFTLrecord *inftl)
63 * otherwise. 63 * otherwise.
64 */ 64 */
65 inftl->EraseSize = inftl->mbd.mtd->erasesize; 65 inftl->EraseSize = inftl->mbd.mtd->erasesize;
66 inftl->nb_blocks = inftl->mbd.mtd->size / inftl->EraseSize; 66 inftl->nb_blocks = (u32)inftl->mbd.mtd->size / inftl->EraseSize;
67 67
68 inftl->MediaUnit = BLOCK_NIL; 68 inftl->MediaUnit = BLOCK_NIL;
69 69
@@ -187,7 +187,7 @@ static int find_boot_record(struct INFTLrecord *inftl)
187 mh->BlockMultiplierBits); 187 mh->BlockMultiplierBits);
188 inftl->EraseSize = inftl->mbd.mtd->erasesize << 188 inftl->EraseSize = inftl->mbd.mtd->erasesize <<
189 mh->BlockMultiplierBits; 189 mh->BlockMultiplierBits;
190 inftl->nb_blocks = inftl->mbd.mtd->size / inftl->EraseSize; 190 inftl->nb_blocks = (u32)inftl->mbd.mtd->size / inftl->EraseSize;
191 block >>= mh->BlockMultiplierBits; 191 block >>= mh->BlockMultiplierBits;
192 } 192 }
193 193
diff --git a/drivers/mtd/lpddr/Kconfig b/drivers/mtd/lpddr/Kconfig
new file mode 100644
index 000000000000..acd4ea9b2278
--- /dev/null
+++ b/drivers/mtd/lpddr/Kconfig
@@ -0,0 +1,22 @@
1# drivers/mtd/chips/Kconfig
2
3menu "LPDDR flash memory drivers"
4 depends on MTD!=n
5
6config MTD_LPDDR
7 tristate "Support for LPDDR flash chips"
8 select MTD_QINFO_PROBE
9 help
10 This option enables support of LPDDR (Low power double data rate)
11 flash chips. Synonymous with Mobile-DDR. It is a new standard for
12 DDR memories, intended for battery-operated systems.
13
14config MTD_QINFO_PROBE
15 tristate "Detect flash chips by QINFO probe"
16 help
17 Device Information for LPDDR chips is offered through the Overlay
18 Window QINFO interface, permits software to be used for entire
19 families of devices. This serves similar purpose of CFI on legacy
20 Flash products
21endmenu
22
diff --git a/drivers/mtd/lpddr/Makefile b/drivers/mtd/lpddr/Makefile
new file mode 100644
index 000000000000..da48e46b5812
--- /dev/null
+++ b/drivers/mtd/lpddr/Makefile
@@ -0,0 +1,6 @@
1#
2# linux/drivers/mtd/lpddr/Makefile
3#
4
5obj-$(CONFIG_MTD_QINFO_PROBE) += qinfo_probe.o
6obj-$(CONFIG_MTD_LPDDR) += lpddr_cmds.o
diff --git a/drivers/mtd/lpddr/lpddr_cmds.c b/drivers/mtd/lpddr/lpddr_cmds.c
new file mode 100644
index 000000000000..e22ca49583e7
--- /dev/null
+++ b/drivers/mtd/lpddr/lpddr_cmds.c
@@ -0,0 +1,796 @@
1/*
2 * LPDDR flash memory device operations. This module provides read, write,
3 * erase, lock/unlock support for LPDDR flash memories
4 * (C) 2008 Korolev Alexey <akorolev@infradead.org>
5 * (C) 2008 Vasiliy Leonenko <vasiliy.leonenko@gmail.com>
6 * Many thanks to Roman Borisov for intial enabling
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301, USA.
22 * TODO:
23 * Implement VPP management
24 * Implement XIP support
25 * Implement OTP support
26 */
27#include <linux/mtd/pfow.h>
28#include <linux/mtd/qinfo.h>
29
30static int lpddr_read(struct mtd_info *mtd, loff_t adr, size_t len,
31 size_t *retlen, u_char *buf);
32static int lpddr_write_buffers(struct mtd_info *mtd, loff_t to,
33 size_t len, size_t *retlen, const u_char *buf);
34static int lpddr_writev(struct mtd_info *mtd, const struct kvec *vecs,
35 unsigned long count, loff_t to, size_t *retlen);
36static int lpddr_erase(struct mtd_info *mtd, struct erase_info *instr);
37static int lpddr_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
38static int lpddr_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len);
39static int lpddr_point(struct mtd_info *mtd, loff_t adr, size_t len,
40 size_t *retlen, void **mtdbuf, resource_size_t *phys);
41static void lpddr_unpoint(struct mtd_info *mtd, loff_t adr, size_t len);
42static int get_chip(struct map_info *map, struct flchip *chip, int mode);
43static int chip_ready(struct map_info *map, struct flchip *chip, int mode);
44static void put_chip(struct map_info *map, struct flchip *chip);
45
46struct mtd_info *lpddr_cmdset(struct map_info *map)
47{
48 struct lpddr_private *lpddr = map->fldrv_priv;
49 struct flchip_shared *shared;
50 struct flchip *chip;
51 struct mtd_info *mtd;
52 int numchips;
53 int i, j;
54
55 mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
56 if (!mtd) {
57 printk(KERN_ERR "Failed to allocate memory for MTD device\n");
58 return NULL;
59 }
60 mtd->priv = map;
61 mtd->type = MTD_NORFLASH;
62
63 /* Fill in the default mtd operations */
64 mtd->read = lpddr_read;
65 mtd->type = MTD_NORFLASH;
66 mtd->flags = MTD_CAP_NORFLASH;
67 mtd->flags &= ~MTD_BIT_WRITEABLE;
68 mtd->erase = lpddr_erase;
69 mtd->write = lpddr_write_buffers;
70 mtd->writev = lpddr_writev;
71 mtd->read_oob = NULL;
72 mtd->write_oob = NULL;
73 mtd->sync = NULL;
74 mtd->lock = lpddr_lock;
75 mtd->unlock = lpddr_unlock;
76 mtd->suspend = NULL;
77 mtd->resume = NULL;
78 if (map_is_linear(map)) {
79 mtd->point = lpddr_point;
80 mtd->unpoint = lpddr_unpoint;
81 }
82 mtd->block_isbad = NULL;
83 mtd->block_markbad = NULL;
84 mtd->size = 1 << lpddr->qinfo->DevSizeShift;
85 mtd->erasesize = 1 << lpddr->qinfo->UniformBlockSizeShift;
86 mtd->writesize = 1 << lpddr->qinfo->BufSizeShift;
87
88 shared = kmalloc(sizeof(struct flchip_shared) * lpddr->numchips,
89 GFP_KERNEL);
90 if (!shared) {
91 kfree(lpddr);
92 kfree(mtd);
93 return NULL;
94 }
95
96 chip = &lpddr->chips[0];
97 numchips = lpddr->numchips / lpddr->qinfo->HWPartsNum;
98 for (i = 0; i < numchips; i++) {
99 shared[i].writing = shared[i].erasing = NULL;
100 spin_lock_init(&shared[i].lock);
101 for (j = 0; j < lpddr->qinfo->HWPartsNum; j++) {
102 *chip = lpddr->chips[i];
103 chip->start += j << lpddr->chipshift;
104 chip->oldstate = chip->state = FL_READY;
105 chip->priv = &shared[i];
106 /* those should be reset too since
107 they create memory references. */
108 init_waitqueue_head(&chip->wq);
109 spin_lock_init(&chip->_spinlock);
110 chip->mutex = &chip->_spinlock;
111 chip++;
112 }
113 }
114
115 return mtd;
116}
117EXPORT_SYMBOL(lpddr_cmdset);
118
119static int wait_for_ready(struct map_info *map, struct flchip *chip,
120 unsigned int chip_op_time)
121{
122 unsigned int timeo, reset_timeo, sleep_time;
123 unsigned int dsr;
124 flstate_t chip_state = chip->state;
125 int ret = 0;
126
127 /* set our timeout to 8 times the expected delay */
128 timeo = chip_op_time * 8;
129 if (!timeo)
130 timeo = 500000;
131 reset_timeo = timeo;
132 sleep_time = chip_op_time / 2;
133
134 for (;;) {
135 dsr = CMDVAL(map_read(map, map->pfow_base + PFOW_DSR));
136 if (dsr & DSR_READY_STATUS)
137 break;
138 if (!timeo) {
139 printk(KERN_ERR "%s: Flash timeout error state %d \n",
140 map->name, chip_state);
141 ret = -ETIME;
142 break;
143 }
144
145 /* OK Still waiting. Drop the lock, wait a while and retry. */
146 spin_unlock(chip->mutex);
147 if (sleep_time >= 1000000/HZ) {
148 /*
149 * Half of the normal delay still remaining
150 * can be performed with a sleeping delay instead
151 * of busy waiting.
152 */
153 msleep(sleep_time/1000);
154 timeo -= sleep_time;
155 sleep_time = 1000000/HZ;
156 } else {
157 udelay(1);
158 cond_resched();
159 timeo--;
160 }
161 spin_lock(chip->mutex);
162
163 while (chip->state != chip_state) {
164 /* Someone's suspended the operation: sleep */
165 DECLARE_WAITQUEUE(wait, current);
166 set_current_state(TASK_UNINTERRUPTIBLE);
167 add_wait_queue(&chip->wq, &wait);
168 spin_unlock(chip->mutex);
169 schedule();
170 remove_wait_queue(&chip->wq, &wait);
171 spin_lock(chip->mutex);
172 }
173 if (chip->erase_suspended || chip->write_suspended) {
174 /* Suspend has occured while sleep: reset timeout */
175 timeo = reset_timeo;
176 chip->erase_suspended = chip->write_suspended = 0;
177 }
178 }
179 /* check status for errors */
180 if (dsr & DSR_ERR) {
181 /* Clear DSR*/
182 map_write(map, CMD(~(DSR_ERR)), map->pfow_base + PFOW_DSR);
183 printk(KERN_WARNING"%s: Bad status on wait: 0x%x \n",
184 map->name, dsr);
185 print_drs_error(dsr);
186 ret = -EIO;
187 }
188 chip->state = FL_READY;
189 return ret;
190}
191
192static int get_chip(struct map_info *map, struct flchip *chip, int mode)
193{
194 int ret;
195 DECLARE_WAITQUEUE(wait, current);
196
197 retry:
198 if (chip->priv && (mode == FL_WRITING || mode == FL_ERASING)
199 && chip->state != FL_SYNCING) {
200 /*
201 * OK. We have possibility for contension on the write/erase
202 * operations which are global to the real chip and not per
203 * partition. So let's fight it over in the partition which
204 * currently has authority on the operation.
205 *
206 * The rules are as follows:
207 *
208 * - any write operation must own shared->writing.
209 *
210 * - any erase operation must own _both_ shared->writing and
211 * shared->erasing.
212 *
213 * - contension arbitration is handled in the owner's context.
214 *
215 * The 'shared' struct can be read and/or written only when
216 * its lock is taken.
217 */
218 struct flchip_shared *shared = chip->priv;
219 struct flchip *contender;
220 spin_lock(&shared->lock);
221 contender = shared->writing;
222 if (contender && contender != chip) {
223 /*
224 * The engine to perform desired operation on this
225 * partition is already in use by someone else.
226 * Let's fight over it in the context of the chip
227 * currently using it. If it is possible to suspend,
228 * that other partition will do just that, otherwise
229 * it'll happily send us to sleep. In any case, when
230 * get_chip returns success we're clear to go ahead.
231 */
232 ret = spin_trylock(contender->mutex);
233 spin_unlock(&shared->lock);
234 if (!ret)
235 goto retry;
236 spin_unlock(chip->mutex);
237 ret = chip_ready(map, contender, mode);
238 spin_lock(chip->mutex);
239
240 if (ret == -EAGAIN) {
241 spin_unlock(contender->mutex);
242 goto retry;
243 }
244 if (ret) {
245 spin_unlock(contender->mutex);
246 return ret;
247 }
248 spin_lock(&shared->lock);
249
250 /* We should not own chip if it is already in FL_SYNCING
251 * state. Put contender and retry. */
252 if (chip->state == FL_SYNCING) {
253 put_chip(map, contender);
254 spin_unlock(contender->mutex);
255 goto retry;
256 }
257 spin_unlock(contender->mutex);
258 }
259
260 /* Check if we have suspended erase on this chip.
261 Must sleep in such a case. */
262 if (mode == FL_ERASING && shared->erasing
263 && shared->erasing->oldstate == FL_ERASING) {
264 spin_unlock(&shared->lock);
265 set_current_state(TASK_UNINTERRUPTIBLE);
266 add_wait_queue(&chip->wq, &wait);
267 spin_unlock(chip->mutex);
268 schedule();
269 remove_wait_queue(&chip->wq, &wait);
270 spin_lock(chip->mutex);
271 goto retry;
272 }
273
274 /* We now own it */
275 shared->writing = chip;
276 if (mode == FL_ERASING)
277 shared->erasing = chip;
278 spin_unlock(&shared->lock);
279 }
280
281 ret = chip_ready(map, chip, mode);
282 if (ret == -EAGAIN)
283 goto retry;
284
285 return ret;
286}
287
288static int chip_ready(struct map_info *map, struct flchip *chip, int mode)
289{
290 struct lpddr_private *lpddr = map->fldrv_priv;
291 int ret = 0;
292 DECLARE_WAITQUEUE(wait, current);
293
294 /* Prevent setting state FL_SYNCING for chip in suspended state. */
295 if (FL_SYNCING == mode && FL_READY != chip->oldstate)
296 goto sleep;
297
298 switch (chip->state) {
299 case FL_READY:
300 case FL_JEDEC_QUERY:
301 return 0;
302
303 case FL_ERASING:
304 if (!lpddr->qinfo->SuspEraseSupp ||
305 !(mode == FL_READY || mode == FL_POINT))
306 goto sleep;
307
308 map_write(map, CMD(LPDDR_SUSPEND),
309 map->pfow_base + PFOW_PROGRAM_ERASE_SUSPEND);
310 chip->oldstate = FL_ERASING;
311 chip->state = FL_ERASE_SUSPENDING;
312 ret = wait_for_ready(map, chip, 0);
313 if (ret) {
314 /* Oops. something got wrong. */
315 /* Resume and pretend we weren't here. */
316 map_write(map, CMD(LPDDR_RESUME),
317 map->pfow_base + PFOW_COMMAND_CODE);
318 map_write(map, CMD(LPDDR_START_EXECUTION),
319 map->pfow_base + PFOW_COMMAND_EXECUTE);
320 chip->state = FL_ERASING;
321 chip->oldstate = FL_READY;
322 printk(KERN_ERR "%s: suspend operation failed."
323 "State may be wrong \n", map->name);
324 return -EIO;
325 }
326 chip->erase_suspended = 1;
327 chip->state = FL_READY;
328 return 0;
329 /* Erase suspend */
330 case FL_POINT:
331 /* Only if there's no operation suspended... */
332 if (mode == FL_READY && chip->oldstate == FL_READY)
333 return 0;
334
335 default:
336sleep:
337 set_current_state(TASK_UNINTERRUPTIBLE);
338 add_wait_queue(&chip->wq, &wait);
339 spin_unlock(chip->mutex);
340 schedule();
341 remove_wait_queue(&chip->wq, &wait);
342 spin_lock(chip->mutex);
343 return -EAGAIN;
344 }
345}
346
347static void put_chip(struct map_info *map, struct flchip *chip)
348{
349 if (chip->priv) {
350 struct flchip_shared *shared = chip->priv;
351 spin_lock(&shared->lock);
352 if (shared->writing == chip && chip->oldstate == FL_READY) {
353 /* We own the ability to write, but we're done */
354 shared->writing = shared->erasing;
355 if (shared->writing && shared->writing != chip) {
356 /* give back the ownership */
357 struct flchip *loaner = shared->writing;
358 spin_lock(loaner->mutex);
359 spin_unlock(&shared->lock);
360 spin_unlock(chip->mutex);
361 put_chip(map, loaner);
362 spin_lock(chip->mutex);
363 spin_unlock(loaner->mutex);
364 wake_up(&chip->wq);
365 return;
366 }
367 shared->erasing = NULL;
368 shared->writing = NULL;
369 } else if (shared->erasing == chip && shared->writing != chip) {
370 /*
371 * We own the ability to erase without the ability
372 * to write, which means the erase was suspended
373 * and some other partition is currently writing.
374 * Don't let the switch below mess things up since
375 * we don't have ownership to resume anything.
376 */
377 spin_unlock(&shared->lock);
378 wake_up(&chip->wq);
379 return;
380 }
381 spin_unlock(&shared->lock);
382 }
383
384 switch (chip->oldstate) {
385 case FL_ERASING:
386 chip->state = chip->oldstate;
387 map_write(map, CMD(LPDDR_RESUME),
388 map->pfow_base + PFOW_COMMAND_CODE);
389 map_write(map, CMD(LPDDR_START_EXECUTION),
390 map->pfow_base + PFOW_COMMAND_EXECUTE);
391 chip->oldstate = FL_READY;
392 chip->state = FL_ERASING;
393 break;
394 case FL_READY:
395 break;
396 default:
397 printk(KERN_ERR "%s: put_chip() called with oldstate %d!\n",
398 map->name, chip->oldstate);
399 }
400 wake_up(&chip->wq);
401}
402
403int do_write_buffer(struct map_info *map, struct flchip *chip,
404 unsigned long adr, const struct kvec **pvec,
405 unsigned long *pvec_seek, int len)
406{
407 struct lpddr_private *lpddr = map->fldrv_priv;
408 map_word datum;
409 int ret, wbufsize, word_gap, words;
410 const struct kvec *vec;
411 unsigned long vec_seek;
412 unsigned long prog_buf_ofs;
413
414 wbufsize = 1 << lpddr->qinfo->BufSizeShift;
415
416 spin_lock(chip->mutex);
417 ret = get_chip(map, chip, FL_WRITING);
418 if (ret) {
419 spin_unlock(chip->mutex);
420 return ret;
421 }
422 /* Figure out the number of words to write */
423 word_gap = (-adr & (map_bankwidth(map)-1));
424 words = (len - word_gap + map_bankwidth(map) - 1) / map_bankwidth(map);
425 if (!word_gap) {
426 words--;
427 } else {
428 word_gap = map_bankwidth(map) - word_gap;
429 adr -= word_gap;
430 datum = map_word_ff(map);
431 }
432 /* Write data */
433 /* Get the program buffer offset from PFOW register data first*/
434 prog_buf_ofs = map->pfow_base + CMDVAL(map_read(map,
435 map->pfow_base + PFOW_PROGRAM_BUFFER_OFFSET));
436 vec = *pvec;
437 vec_seek = *pvec_seek;
438 do {
439 int n = map_bankwidth(map) - word_gap;
440
441 if (n > vec->iov_len - vec_seek)
442 n = vec->iov_len - vec_seek;
443 if (n > len)
444 n = len;
445
446 if (!word_gap && (len < map_bankwidth(map)))
447 datum = map_word_ff(map);
448
449 datum = map_word_load_partial(map, datum,
450 vec->iov_base + vec_seek, word_gap, n);
451
452 len -= n;
453 word_gap += n;
454 if (!len || word_gap == map_bankwidth(map)) {
455 map_write(map, datum, prog_buf_ofs);
456 prog_buf_ofs += map_bankwidth(map);
457 word_gap = 0;
458 }
459
460 vec_seek += n;
461 if (vec_seek == vec->iov_len) {
462 vec++;
463 vec_seek = 0;
464 }
465 } while (len);
466 *pvec = vec;
467 *pvec_seek = vec_seek;
468
469 /* GO GO GO */
470 send_pfow_command(map, LPDDR_BUFF_PROGRAM, adr, wbufsize, NULL);
471 chip->state = FL_WRITING;
472 ret = wait_for_ready(map, chip, (1<<lpddr->qinfo->ProgBufferTime));
473 if (ret) {
474 printk(KERN_WARNING"%s Buffer program error: %d at %lx; \n",
475 map->name, ret, adr);
476 goto out;
477 }
478
479 out: put_chip(map, chip);
480 spin_unlock(chip->mutex);
481 return ret;
482}
483
484int do_erase_oneblock(struct mtd_info *mtd, loff_t adr)
485{
486 struct map_info *map = mtd->priv;
487 struct lpddr_private *lpddr = map->fldrv_priv;
488 int chipnum = adr >> lpddr->chipshift;
489 struct flchip *chip = &lpddr->chips[chipnum];
490 int ret;
491
492 spin_lock(chip->mutex);
493 ret = get_chip(map, chip, FL_ERASING);
494 if (ret) {
495 spin_unlock(chip->mutex);
496 return ret;
497 }
498 send_pfow_command(map, LPDDR_BLOCK_ERASE, adr, 0, NULL);
499 chip->state = FL_ERASING;
500 ret = wait_for_ready(map, chip, (1<<lpddr->qinfo->BlockEraseTime)*1000);
501 if (ret) {
502 printk(KERN_WARNING"%s Erase block error %d at : %llx\n",
503 map->name, ret, adr);
504 goto out;
505 }
506 out: put_chip(map, chip);
507 spin_unlock(chip->mutex);
508 return ret;
509}
510
511static int lpddr_read(struct mtd_info *mtd, loff_t adr, size_t len,
512 size_t *retlen, u_char *buf)
513{
514 struct map_info *map = mtd->priv;
515 struct lpddr_private *lpddr = map->fldrv_priv;
516 int chipnum = adr >> lpddr->chipshift;
517 struct flchip *chip = &lpddr->chips[chipnum];
518 int ret = 0;
519
520 spin_lock(chip->mutex);
521 ret = get_chip(map, chip, FL_READY);
522 if (ret) {
523 spin_unlock(chip->mutex);
524 return ret;
525 }
526
527 map_copy_from(map, buf, adr, len);
528 *retlen = len;
529
530 put_chip(map, chip);
531 spin_unlock(chip->mutex);
532 return ret;
533}
534
535static int lpddr_point(struct mtd_info *mtd, loff_t adr, size_t len,
536 size_t *retlen, void **mtdbuf, resource_size_t *phys)
537{
538 struct map_info *map = mtd->priv;
539 struct lpddr_private *lpddr = map->fldrv_priv;
540 int chipnum = adr >> lpddr->chipshift;
541 unsigned long ofs, last_end = 0;
542 struct flchip *chip = &lpddr->chips[chipnum];
543 int ret = 0;
544
545 if (!map->virt || (adr + len > mtd->size))
546 return -EINVAL;
547
548 /* ofs: offset within the first chip that the first read should start */
549 ofs = adr - (chipnum << lpddr->chipshift);
550
551 *mtdbuf = (void *)map->virt + chip->start + ofs;
552 *retlen = 0;
553
554 while (len) {
555 unsigned long thislen;
556
557 if (chipnum >= lpddr->numchips)
558 break;
559
560 /* We cannot point across chips that are virtually disjoint */
561 if (!last_end)
562 last_end = chip->start;
563 else if (chip->start != last_end)
564 break;
565
566 if ((len + ofs - 1) >> lpddr->chipshift)
567 thislen = (1<<lpddr->chipshift) - ofs;
568 else
569 thislen = len;
570 /* get the chip */
571 spin_lock(chip->mutex);
572 ret = get_chip(map, chip, FL_POINT);
573 spin_unlock(chip->mutex);
574 if (ret)
575 break;
576
577 chip->state = FL_POINT;
578 chip->ref_point_counter++;
579 *retlen += thislen;
580 len -= thislen;
581
582 ofs = 0;
583 last_end += 1 << lpddr->chipshift;
584 chipnum++;
585 chip = &lpddr->chips[chipnum];
586 }
587 return 0;
588}
589
590static void lpddr_unpoint (struct mtd_info *mtd, loff_t adr, size_t len)
591{
592 struct map_info *map = mtd->priv;
593 struct lpddr_private *lpddr = map->fldrv_priv;
594 int chipnum = adr >> lpddr->chipshift;
595 unsigned long ofs;
596
597 /* ofs: offset within the first chip that the first read should start */
598 ofs = adr - (chipnum << lpddr->chipshift);
599
600 while (len) {
601 unsigned long thislen;
602 struct flchip *chip;
603
604 chip = &lpddr->chips[chipnum];
605 if (chipnum >= lpddr->numchips)
606 break;
607
608 if ((len + ofs - 1) >> lpddr->chipshift)
609 thislen = (1<<lpddr->chipshift) - ofs;
610 else
611 thislen = len;
612
613 spin_lock(chip->mutex);
614 if (chip->state == FL_POINT) {
615 chip->ref_point_counter--;
616 if (chip->ref_point_counter == 0)
617 chip->state = FL_READY;
618 } else
619 printk(KERN_WARNING "%s: Warning: unpoint called on non"
620 "pointed region\n", map->name);
621
622 put_chip(map, chip);
623 spin_unlock(chip->mutex);
624
625 len -= thislen;
626 ofs = 0;
627 chipnum++;
628 }
629}
630
631static int lpddr_write_buffers(struct mtd_info *mtd, loff_t to, size_t len,
632 size_t *retlen, const u_char *buf)
633{
634 struct kvec vec;
635
636 vec.iov_base = (void *) buf;
637 vec.iov_len = len;
638
639 return lpddr_writev(mtd, &vec, 1, to, retlen);
640}
641
642
643static int lpddr_writev(struct mtd_info *mtd, const struct kvec *vecs,
644 unsigned long count, loff_t to, size_t *retlen)
645{
646 struct map_info *map = mtd->priv;
647 struct lpddr_private *lpddr = map->fldrv_priv;
648 int ret = 0;
649 int chipnum;
650 unsigned long ofs, vec_seek, i;
651 int wbufsize = 1 << lpddr->qinfo->BufSizeShift;
652
653 size_t len = 0;
654
655 for (i = 0; i < count; i++)
656 len += vecs[i].iov_len;
657
658 *retlen = 0;
659 if (!len)
660 return 0;
661
662 chipnum = to >> lpddr->chipshift;
663
664 ofs = to;
665 vec_seek = 0;
666
667 do {
668 /* We must not cross write block boundaries */
669 int size = wbufsize - (ofs & (wbufsize-1));
670
671 if (size > len)
672 size = len;
673
674 ret = do_write_buffer(map, &lpddr->chips[chipnum],
675 ofs, &vecs, &vec_seek, size);
676 if (ret)
677 return ret;
678
679 ofs += size;
680 (*retlen) += size;
681 len -= size;
682
683 /* Be nice and reschedule with the chip in a usable
684 * state for other processes */
685 cond_resched();
686
687 } while (len);
688
689 return 0;
690}
691
692static int lpddr_erase(struct mtd_info *mtd, struct erase_info *instr)
693{
694 unsigned long ofs, len;
695 int ret;
696 struct map_info *map = mtd->priv;
697 struct lpddr_private *lpddr = map->fldrv_priv;
698 int size = 1 << lpddr->qinfo->UniformBlockSizeShift;
699
700 ofs = instr->addr;
701 len = instr->len;
702
703 if (ofs > mtd->size || (len + ofs) > mtd->size)
704 return -EINVAL;
705
706 while (len > 0) {
707 ret = do_erase_oneblock(mtd, ofs);
708 if (ret)
709 return ret;
710 ofs += size;
711 len -= size;
712 }
713 instr->state = MTD_ERASE_DONE;
714 mtd_erase_callback(instr);
715
716 return 0;
717}
718
719#define DO_XXLOCK_LOCK 1
720#define DO_XXLOCK_UNLOCK 2
721int do_xxlock(struct mtd_info *mtd, loff_t adr, uint32_t len, int thunk)
722{
723 int ret = 0;
724 struct map_info *map = mtd->priv;
725 struct lpddr_private *lpddr = map->fldrv_priv;
726 int chipnum = adr >> lpddr->chipshift;
727 struct flchip *chip = &lpddr->chips[chipnum];
728
729 spin_lock(chip->mutex);
730 ret = get_chip(map, chip, FL_LOCKING);
731 if (ret) {
732 spin_unlock(chip->mutex);
733 return ret;
734 }
735
736 if (thunk == DO_XXLOCK_LOCK) {
737 send_pfow_command(map, LPDDR_LOCK_BLOCK, adr, adr + len, NULL);
738 chip->state = FL_LOCKING;
739 } else if (thunk == DO_XXLOCK_UNLOCK) {
740 send_pfow_command(map, LPDDR_UNLOCK_BLOCK, adr, adr + len, NULL);
741 chip->state = FL_UNLOCKING;
742 } else
743 BUG();
744
745 ret = wait_for_ready(map, chip, 1);
746 if (ret) {
747 printk(KERN_ERR "%s: block unlock error status %d \n",
748 map->name, ret);
749 goto out;
750 }
751out: put_chip(map, chip);
752 spin_unlock(chip->mutex);
753 return ret;
754}
755
756static int lpddr_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
757{
758 return do_xxlock(mtd, ofs, len, DO_XXLOCK_LOCK);
759}
760
761static int lpddr_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
762{
763 return do_xxlock(mtd, ofs, len, DO_XXLOCK_UNLOCK);
764}
765
766int word_program(struct map_info *map, loff_t adr, uint32_t curval)
767{
768 int ret;
769 struct lpddr_private *lpddr = map->fldrv_priv;
770 int chipnum = adr >> lpddr->chipshift;
771 struct flchip *chip = &lpddr->chips[chipnum];
772
773 spin_lock(chip->mutex);
774 ret = get_chip(map, chip, FL_WRITING);
775 if (ret) {
776 spin_unlock(chip->mutex);
777 return ret;
778 }
779
780 send_pfow_command(map, LPDDR_WORD_PROGRAM, adr, 0x00, (map_word *)&curval);
781
782 ret = wait_for_ready(map, chip, (1<<lpddr->qinfo->SingleWordProgTime));
783 if (ret) {
784 printk(KERN_WARNING"%s word_program error at: %llx; val: %x\n",
785 map->name, adr, curval);
786 goto out;
787 }
788
789out: put_chip(map, chip);
790 spin_unlock(chip->mutex);
791 return ret;
792}
793
794MODULE_LICENSE("GPL");
795MODULE_AUTHOR("Alexey Korolev <akorolev@infradead.org>");
796MODULE_DESCRIPTION("MTD driver for LPDDR flash chips");
diff --git a/drivers/mtd/lpddr/qinfo_probe.c b/drivers/mtd/lpddr/qinfo_probe.c
new file mode 100644
index 000000000000..79bf40f48b75
--- /dev/null
+++ b/drivers/mtd/lpddr/qinfo_probe.c
@@ -0,0 +1,255 @@
1/*
2 * Probing flash chips with QINFO records.
3 * (C) 2008 Korolev Alexey <akorolev@infradead.org>
4 * (C) 2008 Vasiliy Leonenko <vasiliy.leonenko@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
20 */
21#include <linux/module.h>
22#include <linux/types.h>
23#include <linux/kernel.h>
24#include <linux/init.h>
25#include <linux/errno.h>
26#include <linux/slab.h>
27#include <linux/interrupt.h>
28
29#include <linux/mtd/xip.h>
30#include <linux/mtd/map.h>
31#include <linux/mtd/pfow.h>
32#include <linux/mtd/qinfo.h>
33
34static int lpddr_chip_setup(struct map_info *map, struct lpddr_private *lpddr);
35struct mtd_info *lpddr_probe(struct map_info *map);
36static struct lpddr_private *lpddr_probe_chip(struct map_info *map);
37static int lpddr_pfow_present(struct map_info *map,
38 struct lpddr_private *lpddr);
39
40static struct qinfo_query_info qinfo_array[] = {
41 /* General device info */
42 {0, 0, "DevSizeShift", "Device size 2^n bytes"},
43 {0, 3, "BufSizeShift", "Program buffer size 2^n bytes"},
44 /* Erase block information */
45 {1, 1, "TotalBlocksNum", "Total number of blocks"},
46 {1, 2, "UniformBlockSizeShift", "Uniform block size 2^n bytes"},
47 /* Partition information */
48 {2, 1, "HWPartsNum", "Number of hardware partitions"},
49 /* Optional features */
50 {5, 1, "SuspEraseSupp", "Suspend erase supported"},
51 /* Operation typical time */
52 {10, 0, "SingleWordProgTime", "Single word program 2^n u-sec"},
53 {10, 1, "ProgBufferTime", "Program buffer write 2^n u-sec"},
54 {10, 2, "BlockEraseTime", "Block erase 2^n m-sec"},
55 {10, 3, "FullChipEraseTime", "Full chip erase 2^n m-sec"},
56};
57
58static long lpddr_get_qinforec_pos(struct map_info *map, char *id_str)
59{
60 int qinfo_lines = sizeof(qinfo_array)/sizeof(struct qinfo_query_info);
61 int i;
62 int bankwidth = map_bankwidth(map) * 8;
63 int major, minor;
64
65 for (i = 0; i < qinfo_lines; i++) {
66 if (strcmp(id_str, qinfo_array[i].id_str) == 0) {
67 major = qinfo_array[i].major & ((1 << bankwidth) - 1);
68 minor = qinfo_array[i].minor & ((1 << bankwidth) - 1);
69 return minor | (major << bankwidth);
70 }
71 }
72 printk(KERN_ERR"%s qinfo id string is wrong! \n", map->name);
73 BUG();
74 return -1;
75}
76
77static uint16_t lpddr_info_query(struct map_info *map, char *id_str)
78{
79 unsigned int dsr, val;
80 int bits_per_chip = map_bankwidth(map) * 8;
81 unsigned long adr = lpddr_get_qinforec_pos(map, id_str);
82 int attempts = 20;
83
84 /* Write a request for the PFOW record */
85 map_write(map, CMD(LPDDR_INFO_QUERY),
86 map->pfow_base + PFOW_COMMAND_CODE);
87 map_write(map, CMD(adr & ((1 << bits_per_chip) - 1)),
88 map->pfow_base + PFOW_COMMAND_ADDRESS_L);
89 map_write(map, CMD(adr >> bits_per_chip),
90 map->pfow_base + PFOW_COMMAND_ADDRESS_H);
91 map_write(map, CMD(LPDDR_START_EXECUTION),
92 map->pfow_base + PFOW_COMMAND_EXECUTE);
93
94 while ((attempts--) > 0) {
95 dsr = CMDVAL(map_read(map, map->pfow_base + PFOW_DSR));
96 if (dsr & DSR_READY_STATUS)
97 break;
98 udelay(10);
99 }
100
101 val = CMDVAL(map_read(map, map->pfow_base + PFOW_COMMAND_DATA));
102 return val;
103}
104
105static int lpddr_pfow_present(struct map_info *map, struct lpddr_private *lpddr)
106{
107 map_word pfow_val[4];
108
109 /* Check identification string */
110 pfow_val[0] = map_read(map, map->pfow_base + PFOW_QUERY_STRING_P);
111 pfow_val[1] = map_read(map, map->pfow_base + PFOW_QUERY_STRING_F);
112 pfow_val[2] = map_read(map, map->pfow_base + PFOW_QUERY_STRING_O);
113 pfow_val[3] = map_read(map, map->pfow_base + PFOW_QUERY_STRING_W);
114
115 if (!map_word_equal(map, CMD('P'), pfow_val[0]))
116 goto out;
117
118 if (!map_word_equal(map, CMD('F'), pfow_val[1]))
119 goto out;
120
121 if (!map_word_equal(map, CMD('O'), pfow_val[2]))
122 goto out;
123
124 if (!map_word_equal(map, CMD('W'), pfow_val[3]))
125 goto out;
126
127 return 1; /* "PFOW" is found */
128out:
129 printk(KERN_WARNING"%s: PFOW string at 0x%lx is not found \n",
130 map->name, map->pfow_base);
131 return 0;
132}
133
134static int lpddr_chip_setup(struct map_info *map, struct lpddr_private *lpddr)
135{
136
137 lpddr->qinfo = kmalloc(sizeof(struct qinfo_chip), GFP_KERNEL);
138 if (!lpddr->qinfo) {
139 printk(KERN_WARNING "%s: no memory for LPDDR qinfo structure\n",
140 map->name);
141 return 0;
142 }
143 memset(lpddr->qinfo, 0, sizeof(struct qinfo_chip));
144
145 /* Get the ManuID */
146 lpddr->ManufactId = CMDVAL(map_read(map, map->pfow_base + PFOW_MANUFACTURER_ID));
147 /* Get the DeviceID */
148 lpddr->DevId = CMDVAL(map_read(map, map->pfow_base + PFOW_DEVICE_ID));
149 /* read parameters from chip qinfo table */
150 lpddr->qinfo->DevSizeShift = lpddr_info_query(map, "DevSizeShift");
151 lpddr->qinfo->TotalBlocksNum = lpddr_info_query(map, "TotalBlocksNum");
152 lpddr->qinfo->BufSizeShift = lpddr_info_query(map, "BufSizeShift");
153 lpddr->qinfo->HWPartsNum = lpddr_info_query(map, "HWPartsNum");
154 lpddr->qinfo->UniformBlockSizeShift =
155 lpddr_info_query(map, "UniformBlockSizeShift");
156 lpddr->qinfo->SuspEraseSupp = lpddr_info_query(map, "SuspEraseSupp");
157 lpddr->qinfo->SingleWordProgTime =
158 lpddr_info_query(map, "SingleWordProgTime");
159 lpddr->qinfo->ProgBufferTime = lpddr_info_query(map, "ProgBufferTime");
160 lpddr->qinfo->BlockEraseTime = lpddr_info_query(map, "BlockEraseTime");
161 return 1;
162}
163static struct lpddr_private *lpddr_probe_chip(struct map_info *map)
164{
165 struct lpddr_private lpddr;
166 struct lpddr_private *retlpddr;
167 int numvirtchips;
168
169
170 if ((map->pfow_base + 0x1000) >= map->size) {
171 printk(KERN_NOTICE"%s Probe at base (0x%08lx) past the end of"
172 "the map(0x%08lx)\n", map->name,
173 (unsigned long)map->pfow_base, map->size - 1);
174 return NULL;
175 }
176 memset(&lpddr, 0, sizeof(struct lpddr_private));
177 if (!lpddr_pfow_present(map, &lpddr))
178 return NULL;
179
180 if (!lpddr_chip_setup(map, &lpddr))
181 return NULL;
182
183 /* Ok so we found a chip */
184 lpddr.chipshift = lpddr.qinfo->DevSizeShift;
185 lpddr.numchips = 1;
186
187 numvirtchips = lpddr.numchips * lpddr.qinfo->HWPartsNum;
188 retlpddr = kmalloc(sizeof(struct lpddr_private) +
189 numvirtchips * sizeof(struct flchip), GFP_KERNEL);
190 if (!retlpddr)
191 return NULL;
192
193 memset(retlpddr, 0, sizeof(struct lpddr_private) +
194 numvirtchips * sizeof(struct flchip));
195 memcpy(retlpddr, &lpddr, sizeof(struct lpddr_private));
196
197 retlpddr->numchips = numvirtchips;
198 retlpddr->chipshift = retlpddr->qinfo->DevSizeShift -
199 __ffs(retlpddr->qinfo->HWPartsNum);
200
201 return retlpddr;
202}
203
204struct mtd_info *lpddr_probe(struct map_info *map)
205{
206 struct mtd_info *mtd = NULL;
207 struct lpddr_private *lpddr;
208
209 /* First probe the map to see if we havecan open PFOW here */
210 lpddr = lpddr_probe_chip(map);
211 if (!lpddr)
212 return NULL;
213
214 map->fldrv_priv = lpddr;
215 mtd = lpddr_cmdset(map);
216 if (mtd) {
217 if (mtd->size > map->size) {
218 printk(KERN_WARNING "Reducing visibility of %ldKiB chip"
219 "to %ldKiB\n", (unsigned long)mtd->size >> 10,
220 (unsigned long)map->size >> 10);
221 mtd->size = map->size;
222 }
223 return mtd;
224 }
225
226 kfree(lpddr->qinfo);
227 kfree(lpddr);
228 map->fldrv_priv = NULL;
229 return NULL;
230}
231
232static struct mtd_chip_driver lpddr_chipdrv = {
233 .probe = lpddr_probe,
234 .name = "qinfo_probe",
235 .module = THIS_MODULE
236};
237
238static int __init lpddr_probe_init(void)
239{
240 register_mtd_chip_driver(&lpddr_chipdrv);
241 return 0;
242}
243
244static void __exit lpddr_probe_exit(void)
245{
246 unregister_mtd_chip_driver(&lpddr_chipdrv);
247}
248
249module_init(lpddr_probe_init);
250module_exit(lpddr_probe_exit);
251
252MODULE_LICENSE("GPL");
253MODULE_AUTHOR("Vasiliy Leonenko <vasiliy.leonenko@gmail.com>");
254MODULE_DESCRIPTION("Driver to probe qinfo flash chips");
255
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index 5ea169362164..0225cbbf22de 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -10,8 +10,8 @@ config MTD_COMPLEX_MAPPINGS
10 paged mappings of flash chips. 10 paged mappings of flash chips.
11 11
12config MTD_PHYSMAP 12config MTD_PHYSMAP
13 tristate "CFI Flash device in physical memory map" 13 tristate "Flash device in physical memory map"
14 depends on MTD_CFI || MTD_JEDECPROBE || MTD_ROM 14 depends on MTD_CFI || MTD_JEDECPROBE || MTD_ROM || MTD_LPDDR
15 help 15 help
16 This provides a 'mapping' driver which allows the NOR Flash and 16 This provides a 'mapping' driver which allows the NOR Flash and
17 ROM driver code to communicate with chips which are mapped 17 ROM driver code to communicate with chips which are mapped
@@ -23,9 +23,20 @@ config MTD_PHYSMAP
23 To compile this driver as a module, choose M here: the 23 To compile this driver as a module, choose M here: the
24 module will be called physmap. 24 module will be called physmap.
25 25
26config MTD_PHYSMAP_COMPAT
27 bool "Physmap compat support"
28 depends on MTD_PHYSMAP
29 default n
30 help
31 Setup a simple mapping via the Kconfig options. Normally the
32 physmap configuration options are done via your board's
33 resource file.
34
35 If unsure, say N here.
36
26config MTD_PHYSMAP_START 37config MTD_PHYSMAP_START
27 hex "Physical start address of flash mapping" 38 hex "Physical start address of flash mapping"
28 depends on MTD_PHYSMAP 39 depends on MTD_PHYSMAP_COMPAT
29 default "0x8000000" 40 default "0x8000000"
30 help 41 help
31 This is the physical memory location at which the flash chips 42 This is the physical memory location at which the flash chips
@@ -37,7 +48,7 @@ config MTD_PHYSMAP_START
37 48
38config MTD_PHYSMAP_LEN 49config MTD_PHYSMAP_LEN
39 hex "Physical length of flash mapping" 50 hex "Physical length of flash mapping"
40 depends on MTD_PHYSMAP 51 depends on MTD_PHYSMAP_COMPAT
41 default "0" 52 default "0"
42 help 53 help
43 This is the total length of the mapping of the flash chips on 54 This is the total length of the mapping of the flash chips on
@@ -51,7 +62,7 @@ config MTD_PHYSMAP_LEN
51 62
52config MTD_PHYSMAP_BANKWIDTH 63config MTD_PHYSMAP_BANKWIDTH
53 int "Bank width in octets" 64 int "Bank width in octets"
54 depends on MTD_PHYSMAP 65 depends on MTD_PHYSMAP_COMPAT
55 default "2" 66 default "2"
56 help 67 help
57 This is the total width of the data bus of the flash devices 68 This is the total width of the data bus of the flash devices
diff --git a/drivers/mtd/maps/alchemy-flash.c b/drivers/mtd/maps/alchemy-flash.c
index 82811bcb0436..845ad4f2a542 100644
--- a/drivers/mtd/maps/alchemy-flash.c
+++ b/drivers/mtd/maps/alchemy-flash.c
@@ -111,7 +111,7 @@ static struct mtd_partition alchemy_partitions[] = {
111 111
112static struct mtd_info *mymtd; 112static struct mtd_info *mymtd;
113 113
114int __init alchemy_mtd_init(void) 114static int __init alchemy_mtd_init(void)
115{ 115{
116 struct mtd_partition *parts; 116 struct mtd_partition *parts;
117 int nb_parts = 0; 117 int nb_parts = 0;
diff --git a/drivers/mtd/maps/amd76xrom.c b/drivers/mtd/maps/amd76xrom.c
index d1eec7d3243f..237733d094c4 100644
--- a/drivers/mtd/maps/amd76xrom.c
+++ b/drivers/mtd/maps/amd76xrom.c
@@ -232,8 +232,8 @@ static int __devinit amd76xrom_init_one (struct pci_dev *pdev,
232 /* Trim the size if we are larger than the map */ 232 /* Trim the size if we are larger than the map */
233 if (map->mtd->size > map->map.size) { 233 if (map->mtd->size > map->map.size) {
234 printk(KERN_WARNING MOD_NAME 234 printk(KERN_WARNING MOD_NAME
235 " rom(%u) larger than window(%lu). fixing...\n", 235 " rom(%llu) larger than window(%lu). fixing...\n",
236 map->mtd->size, map->map.size); 236 (unsigned long long)map->mtd->size, map->map.size);
237 map->mtd->size = map->map.size; 237 map->mtd->size = map->map.size;
238 } 238 }
239 if (window->rsrc.parent) { 239 if (window->rsrc.parent) {
diff --git a/drivers/mtd/maps/cfi_flagadm.c b/drivers/mtd/maps/cfi_flagadm.c
index 0ecc3f6d735b..b4ed81611918 100644
--- a/drivers/mtd/maps/cfi_flagadm.c
+++ b/drivers/mtd/maps/cfi_flagadm.c
@@ -88,7 +88,7 @@ struct mtd_partition flagadm_parts[] = {
88 88
89static struct mtd_info *mymtd; 89static struct mtd_info *mymtd;
90 90
91int __init init_flagadm(void) 91static int __init init_flagadm(void)
92{ 92{
93 printk(KERN_NOTICE "FlagaDM flash device: %x at %x\n", 93 printk(KERN_NOTICE "FlagaDM flash device: %x at %x\n",
94 FLASH_SIZE, FLASH_PHYS_ADDR); 94 FLASH_SIZE, FLASH_PHYS_ADDR);
diff --git a/drivers/mtd/maps/ck804xrom.c b/drivers/mtd/maps/ck804xrom.c
index 1a6feb4474de..5f7a245ed132 100644
--- a/drivers/mtd/maps/ck804xrom.c
+++ b/drivers/mtd/maps/ck804xrom.c
@@ -263,8 +263,8 @@ static int __devinit ck804xrom_init_one (struct pci_dev *pdev,
263 /* Trim the size if we are larger than the map */ 263 /* Trim the size if we are larger than the map */
264 if (map->mtd->size > map->map.size) { 264 if (map->mtd->size > map->map.size) {
265 printk(KERN_WARNING MOD_NAME 265 printk(KERN_WARNING MOD_NAME
266 " rom(%u) larger than window(%lu). fixing...\n", 266 " rom(%llu) larger than window(%lu). fixing...\n",
267 map->mtd->size, map->map.size); 267 (unsigned long long)map->mtd->size, map->map.size);
268 map->mtd->size = map->map.size; 268 map->mtd->size = map->map.size;
269 } 269 }
270 if (window->rsrc.parent) { 270 if (window->rsrc.parent) {
diff --git a/drivers/mtd/maps/dbox2-flash.c b/drivers/mtd/maps/dbox2-flash.c
index e115667bf1d0..cfacfa6f45dd 100644
--- a/drivers/mtd/maps/dbox2-flash.c
+++ b/drivers/mtd/maps/dbox2-flash.c
@@ -69,7 +69,7 @@ struct map_info dbox2_flash_map = {
69 .phys = WINDOW_ADDR, 69 .phys = WINDOW_ADDR,
70}; 70};
71 71
72int __init init_dbox2_flash(void) 72static int __init init_dbox2_flash(void)
73{ 73{
74 printk(KERN_NOTICE "D-Box 2 flash driver (size->0x%X mem->0x%X)\n", WINDOW_SIZE, WINDOW_ADDR); 74 printk(KERN_NOTICE "D-Box 2 flash driver (size->0x%X mem->0x%X)\n", WINDOW_SIZE, WINDOW_ADDR);
75 dbox2_flash_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE); 75 dbox2_flash_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
diff --git a/drivers/mtd/maps/edb7312.c b/drivers/mtd/maps/edb7312.c
index 9433738c1664..be9e90b44587 100644
--- a/drivers/mtd/maps/edb7312.c
+++ b/drivers/mtd/maps/edb7312.c
@@ -71,7 +71,7 @@ static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
71static int mtd_parts_nb = 0; 71static int mtd_parts_nb = 0;
72static struct mtd_partition *mtd_parts = 0; 72static struct mtd_partition *mtd_parts = 0;
73 73
74int __init init_edb7312nor(void) 74static int __init init_edb7312nor(void)
75{ 75{
76 static const char *rom_probe_types[] = PROBETYPES; 76 static const char *rom_probe_types[] = PROBETYPES;
77 const char **type; 77 const char **type;
diff --git a/drivers/mtd/maps/esb2rom.c b/drivers/mtd/maps/esb2rom.c
index bbbcdd4c8d13..11a2f57df9cf 100644
--- a/drivers/mtd/maps/esb2rom.c
+++ b/drivers/mtd/maps/esb2rom.c
@@ -324,8 +324,8 @@ static int __devinit esb2rom_init_one(struct pci_dev *pdev,
324 /* Trim the size if we are larger than the map */ 324 /* Trim the size if we are larger than the map */
325 if (map->mtd->size > map->map.size) { 325 if (map->mtd->size > map->map.size) {
326 printk(KERN_WARNING MOD_NAME 326 printk(KERN_WARNING MOD_NAME
327 " rom(%u) larger than window(%lu). fixing...\n", 327 " rom(%llu) larger than window(%lu). fixing...\n",
328 map->mtd->size, map->map.size); 328 (unsigned long long)map->mtd->size, map->map.size);
329 map->mtd->size = map->map.size; 329 map->mtd->size = map->map.size;
330 } 330 }
331 if (window->rsrc.parent) { 331 if (window->rsrc.parent) {
diff --git a/drivers/mtd/maps/fortunet.c b/drivers/mtd/maps/fortunet.c
index a8e3fde4cbd5..1e43124d498b 100644
--- a/drivers/mtd/maps/fortunet.c
+++ b/drivers/mtd/maps/fortunet.c
@@ -181,7 +181,7 @@ __setup("MTD_Partition=", MTD_New_Partition);
181/* Backwards-spelling-compatibility */ 181/* Backwards-spelling-compatibility */
182__setup("MTD_Partion=", MTD_New_Partition); 182__setup("MTD_Partion=", MTD_New_Partition);
183 183
184int __init init_fortunet(void) 184static int __init init_fortunet(void)
185{ 185{
186 int ix,iy; 186 int ix,iy;
187 for(iy=ix=0;ix<MAX_NUM_REGIONS;ix++) 187 for(iy=ix=0;ix<MAX_NUM_REGIONS;ix++)
diff --git a/drivers/mtd/maps/h720x-flash.c b/drivers/mtd/maps/h720x-flash.c
index 3b959fad1c4e..72c724fa8c27 100644
--- a/drivers/mtd/maps/h720x-flash.c
+++ b/drivers/mtd/maps/h720x-flash.c
@@ -65,7 +65,7 @@ static const char *probes[] = { "cmdlinepart", NULL };
65/* 65/*
66 * Initialize FLASH support 66 * Initialize FLASH support
67 */ 67 */
68int __init h720x_mtd_init(void) 68static int __init h720x_mtd_init(void)
69{ 69{
70 70
71 char *part_type = NULL; 71 char *part_type = NULL;
diff --git a/drivers/mtd/maps/ichxrom.c b/drivers/mtd/maps/ichxrom.c
index aeb6c916e23f..c32bc28920b3 100644
--- a/drivers/mtd/maps/ichxrom.c
+++ b/drivers/mtd/maps/ichxrom.c
@@ -258,8 +258,8 @@ static int __devinit ichxrom_init_one (struct pci_dev *pdev,
258 /* Trim the size if we are larger than the map */ 258 /* Trim the size if we are larger than the map */
259 if (map->mtd->size > map->map.size) { 259 if (map->mtd->size > map->map.size) {
260 printk(KERN_WARNING MOD_NAME 260 printk(KERN_WARNING MOD_NAME
261 " rom(%u) larger than window(%lu). fixing...\n", 261 " rom(%llu) larger than window(%lu). fixing...\n",
262 map->mtd->size, map->map.size); 262 (unsigned long long)map->mtd->size, map->map.size);
263 map->mtd->size = map->map.size; 263 map->mtd->size = map->map.size;
264 } 264 }
265 if (window->rsrc.parent) { 265 if (window->rsrc.parent) {
diff --git a/drivers/mtd/maps/impa7.c b/drivers/mtd/maps/impa7.c
index 2682ab51a367..998a27da97f3 100644
--- a/drivers/mtd/maps/impa7.c
+++ b/drivers/mtd/maps/impa7.c
@@ -70,7 +70,7 @@ static struct mtd_partition *mtd_parts[NUM_FLASHBANKS];
70 70
71static const char *probes[] = { "cmdlinepart", NULL }; 71static const char *probes[] = { "cmdlinepart", NULL };
72 72
73int __init init_impa7(void) 73static int __init init_impa7(void)
74{ 74{
75 static const char *rom_probe_types[] = PROBETYPES; 75 static const char *rom_probe_types[] = PROBETYPES;
76 const char **type; 76 const char **type;
diff --git a/drivers/mtd/maps/ipaq-flash.c b/drivers/mtd/maps/ipaq-flash.c
index ed58f6a77bd9..748c85f635f1 100644
--- a/drivers/mtd/maps/ipaq-flash.c
+++ b/drivers/mtd/maps/ipaq-flash.c
@@ -202,7 +202,7 @@ static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
202 202
203static int __init h1900_special_case(void); 203static int __init h1900_special_case(void);
204 204
205int __init ipaq_mtd_init(void) 205static int __init ipaq_mtd_init(void)
206{ 206{
207 struct mtd_partition *parts = NULL; 207 struct mtd_partition *parts = NULL;
208 int nb_parts = 0; 208 int nb_parts = 0;
diff --git a/drivers/mtd/maps/mbx860.c b/drivers/mtd/maps/mbx860.c
index 706f67394b07..0eb5a7c85380 100644
--- a/drivers/mtd/maps/mbx860.c
+++ b/drivers/mtd/maps/mbx860.c
@@ -55,7 +55,7 @@ struct map_info mbx_map = {
55 .bankwidth = 4, 55 .bankwidth = 4,
56}; 56};
57 57
58int __init init_mbx(void) 58static int __init init_mbx(void)
59{ 59{
60 printk(KERN_NOTICE "Motorola MBX flash device: 0x%x at 0x%x\n", WINDOW_SIZE*4, WINDOW_ADDR); 60 printk(KERN_NOTICE "Motorola MBX flash device: 0x%x at 0x%x\n", WINDOW_SIZE*4, WINDOW_ADDR);
61 mbx_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE * 4); 61 mbx_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE * 4);
diff --git a/drivers/mtd/maps/nettel.c b/drivers/mtd/maps/nettel.c
index 965e6c6d6ab0..a97133eb9d70 100644
--- a/drivers/mtd/maps/nettel.c
+++ b/drivers/mtd/maps/nettel.c
@@ -226,7 +226,7 @@ static int __init nettel_init(void)
226 226
227 if ((amd_mtd = do_map_probe("jedec_probe", &nettel_amd_map))) { 227 if ((amd_mtd = do_map_probe("jedec_probe", &nettel_amd_map))) {
228 printk(KERN_NOTICE "SNAPGEAR: AMD flash device size = %dK\n", 228 printk(KERN_NOTICE "SNAPGEAR: AMD flash device size = %dK\n",
229 amd_mtd->size>>10); 229 (int)(amd_mtd->size>>10));
230 230
231 amd_mtd->owner = THIS_MODULE; 231 amd_mtd->owner = THIS_MODULE;
232 232
@@ -357,13 +357,12 @@ static int __init nettel_init(void)
357 *intel1par = 0; 357 *intel1par = 0;
358 } 358 }
359 359
360 printk(KERN_NOTICE "SNAPGEAR: Intel flash device size = %dK\n", 360 printk(KERN_NOTICE "SNAPGEAR: Intel flash device size = %lldKiB\n",
361 (intel_mtd->size >> 10)); 361 (unsigned long long)(intel_mtd->size >> 10));
362 362
363 intel_mtd->owner = THIS_MODULE; 363 intel_mtd->owner = THIS_MODULE;
364 364
365 num_intel_partitions = sizeof(nettel_intel_partitions) / 365 num_intel_partitions = ARRAY_SIZE(nettel_intel_partitions);
366 sizeof(nettel_intel_partitions[0]);
367 366
368 if (intelboot) { 367 if (intelboot) {
369 /* 368 /*
diff --git a/drivers/mtd/maps/octagon-5066.c b/drivers/mtd/maps/octagon-5066.c
index 43e04c1d22a9..2b2e45093218 100644
--- a/drivers/mtd/maps/octagon-5066.c
+++ b/drivers/mtd/maps/octagon-5066.c
@@ -184,7 +184,7 @@ void cleanup_oct5066(void)
184 release_region(PAGE_IO, 1); 184 release_region(PAGE_IO, 1);
185} 185}
186 186
187int __init init_oct5066(void) 187static int __init init_oct5066(void)
188{ 188{
189 int i; 189 int i;
190 int ret = 0; 190 int ret = 0;
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index 1db16e549e38..87743661d48e 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -29,7 +29,6 @@ struct physmap_flash_info {
29 struct map_info map[MAX_RESOURCES]; 29 struct map_info map[MAX_RESOURCES];
30#ifdef CONFIG_MTD_PARTITIONS 30#ifdef CONFIG_MTD_PARTITIONS
31 int nr_parts; 31 int nr_parts;
32 struct mtd_partition *parts;
33#endif 32#endif
34}; 33};
35 34
@@ -56,14 +55,10 @@ static int physmap_flash_remove(struct platform_device *dev)
56 for (i = 0; i < MAX_RESOURCES; i++) { 55 for (i = 0; i < MAX_RESOURCES; i++) {
57 if (info->mtd[i] != NULL) { 56 if (info->mtd[i] != NULL) {
58#ifdef CONFIG_MTD_PARTITIONS 57#ifdef CONFIG_MTD_PARTITIONS
59 if (info->nr_parts) { 58 if (info->nr_parts || physmap_data->nr_parts)
60 del_mtd_partitions(info->mtd[i]); 59 del_mtd_partitions(info->mtd[i]);
61 kfree(info->parts); 60 else
62 } else if (physmap_data->nr_parts) {
63 del_mtd_partitions(info->mtd[i]);
64 } else {
65 del_mtd_device(info->mtd[i]); 61 del_mtd_device(info->mtd[i]);
66 }
67#else 62#else
68 del_mtd_device(info->mtd[i]); 63 del_mtd_device(info->mtd[i]);
69#endif 64#endif
@@ -73,7 +68,12 @@ static int physmap_flash_remove(struct platform_device *dev)
73 return 0; 68 return 0;
74} 69}
75 70
76static const char *rom_probe_types[] = { "cfi_probe", "jedec_probe", "map_rom", NULL }; 71static const char *rom_probe_types[] = {
72 "cfi_probe",
73 "jedec_probe",
74 "qinfo_probe",
75 "map_rom",
76 NULL };
77#ifdef CONFIG_MTD_PARTITIONS 77#ifdef CONFIG_MTD_PARTITIONS
78static const char *part_probe_types[] = { "cmdlinepart", "RedBoot", NULL }; 78static const char *part_probe_types[] = { "cmdlinepart", "RedBoot", NULL };
79#endif 79#endif
@@ -86,6 +86,9 @@ static int physmap_flash_probe(struct platform_device *dev)
86 int err = 0; 86 int err = 0;
87 int i; 87 int i;
88 int devices_found = 0; 88 int devices_found = 0;
89#ifdef CONFIG_MTD_PARTITIONS
90 struct mtd_partition *parts;
91#endif
89 92
90 physmap_data = dev->dev.platform_data; 93 physmap_data = dev->dev.platform_data;
91 if (physmap_data == NULL) 94 if (physmap_data == NULL)
@@ -119,6 +122,7 @@ static int physmap_flash_probe(struct platform_device *dev)
119 info->map[i].size = dev->resource[i].end - dev->resource[i].start + 1; 122 info->map[i].size = dev->resource[i].end - dev->resource[i].start + 1;
120 info->map[i].bankwidth = physmap_data->width; 123 info->map[i].bankwidth = physmap_data->width;
121 info->map[i].set_vpp = physmap_data->set_vpp; 124 info->map[i].set_vpp = physmap_data->set_vpp;
125 info->map[i].pfow_base = physmap_data->pfow_base;
122 126
123 info->map[i].virt = devm_ioremap(&dev->dev, info->map[i].phys, 127 info->map[i].virt = devm_ioremap(&dev->dev, info->map[i].phys,
124 info->map[i].size); 128 info->map[i].size);
@@ -163,9 +167,10 @@ static int physmap_flash_probe(struct platform_device *dev)
163 goto err_out; 167 goto err_out;
164 168
165#ifdef CONFIG_MTD_PARTITIONS 169#ifdef CONFIG_MTD_PARTITIONS
166 err = parse_mtd_partitions(info->cmtd, part_probe_types, &info->parts, 0); 170 err = parse_mtd_partitions(info->cmtd, part_probe_types, &parts, 0);
167 if (err > 0) { 171 if (err > 0) {
168 add_mtd_partitions(info->cmtd, info->parts, err); 172 add_mtd_partitions(info->cmtd, parts, err);
173 kfree(parts);
169 return 0; 174 return 0;
170 } 175 }
171 176
@@ -251,14 +256,7 @@ static struct platform_driver physmap_flash_driver = {
251}; 256};
252 257
253 258
254#ifdef CONFIG_MTD_PHYSMAP_LEN 259#ifdef CONFIG_MTD_PHYSMAP_COMPAT
255#if CONFIG_MTD_PHYSMAP_LEN != 0
256#warning using PHYSMAP compat code
257#define PHYSMAP_COMPAT
258#endif
259#endif
260
261#ifdef PHYSMAP_COMPAT
262static struct physmap_flash_data physmap_flash_data = { 260static struct physmap_flash_data physmap_flash_data = {
263 .width = CONFIG_MTD_PHYSMAP_BANKWIDTH, 261 .width = CONFIG_MTD_PHYSMAP_BANKWIDTH,
264}; 262};
@@ -302,7 +300,7 @@ static int __init physmap_init(void)
302 int err; 300 int err;
303 301
304 err = platform_driver_register(&physmap_flash_driver); 302 err = platform_driver_register(&physmap_flash_driver);
305#ifdef PHYSMAP_COMPAT 303#ifdef CONFIG_MTD_PHYSMAP_COMPAT
306 if (err == 0) 304 if (err == 0)
307 platform_device_register(&physmap_flash); 305 platform_device_register(&physmap_flash);
308#endif 306#endif
@@ -312,7 +310,7 @@ static int __init physmap_init(void)
312 310
313static void __exit physmap_exit(void) 311static void __exit physmap_exit(void)
314{ 312{
315#ifdef PHYSMAP_COMPAT 313#ifdef CONFIG_MTD_PHYSMAP_COMPAT
316 platform_device_unregister(&physmap_flash); 314 platform_device_unregister(&physmap_flash);
317#endif 315#endif
318 platform_driver_unregister(&physmap_flash_driver); 316 platform_driver_unregister(&physmap_flash_driver);
@@ -326,8 +324,7 @@ MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
326MODULE_DESCRIPTION("Generic configurable MTD map driver"); 324MODULE_DESCRIPTION("Generic configurable MTD map driver");
327 325
328/* legacy platform drivers can't hotplug or coldplg */ 326/* legacy platform drivers can't hotplug or coldplg */
329#ifndef PHYSMAP_COMPAT 327#ifndef CONFIG_MTD_PHYSMAP_COMPAT
330/* work with hotplug and coldplug */ 328/* work with hotplug and coldplug */
331MODULE_ALIAS("platform:physmap-flash"); 329MODULE_ALIAS("platform:physmap-flash");
332#endif 330#endif
333
diff --git a/drivers/mtd/maps/pmcmsp-flash.c b/drivers/mtd/maps/pmcmsp-flash.c
index f43ba2815cbb..4768bd5459d6 100644
--- a/drivers/mtd/maps/pmcmsp-flash.c
+++ b/drivers/mtd/maps/pmcmsp-flash.c
@@ -48,7 +48,7 @@ static int fcnt;
48 48
49#define DEBUG_MARKER printk(KERN_NOTICE "%s[%d]\n", __func__, __LINE__) 49#define DEBUG_MARKER printk(KERN_NOTICE "%s[%d]\n", __func__, __LINE__)
50 50
51int __init init_msp_flash(void) 51static int __init init_msp_flash(void)
52{ 52{
53 int i, j; 53 int i, j;
54 int offset, coff; 54 int offset, coff;
diff --git a/drivers/mtd/maps/redwood.c b/drivers/mtd/maps/redwood.c
index de002eb1a7fe..933c0b63b016 100644
--- a/drivers/mtd/maps/redwood.c
+++ b/drivers/mtd/maps/redwood.c
@@ -122,7 +122,7 @@ struct map_info redwood_flash_map = {
122 122
123static struct mtd_info *redwood_mtd; 123static struct mtd_info *redwood_mtd;
124 124
125int __init init_redwood_flash(void) 125static int __init init_redwood_flash(void)
126{ 126{
127 int err; 127 int err;
128 128
diff --git a/drivers/mtd/maps/rpxlite.c b/drivers/mtd/maps/rpxlite.c
index 14d90edb4430..3e3ef53d4fd4 100644
--- a/drivers/mtd/maps/rpxlite.c
+++ b/drivers/mtd/maps/rpxlite.c
@@ -23,7 +23,7 @@ static struct map_info rpxlite_map = {
23 .phys = WINDOW_ADDR, 23 .phys = WINDOW_ADDR,
24}; 24};
25 25
26int __init init_rpxlite(void) 26static int __init init_rpxlite(void)
27{ 27{
28 printk(KERN_NOTICE "RPX Lite or CLLF flash device: %x at %x\n", WINDOW_SIZE*4, WINDOW_ADDR); 28 printk(KERN_NOTICE "RPX Lite or CLLF flash device: %x at %x\n", WINDOW_SIZE*4, WINDOW_ADDR);
29 rpxlite_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE * 4); 29 rpxlite_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE * 4);
diff --git a/drivers/mtd/maps/sbc8240.c b/drivers/mtd/maps/sbc8240.c
index 6e1e99cd2b59..d5374cdcb163 100644
--- a/drivers/mtd/maps/sbc8240.c
+++ b/drivers/mtd/maps/sbc8240.c
@@ -136,7 +136,7 @@ static struct mtd_part_def sbc8240_part_banks[NUM_FLASH_BANKS];
136#endif /* CONFIG_MTD_PARTITIONS */ 136#endif /* CONFIG_MTD_PARTITIONS */
137 137
138 138
139int __init init_sbc8240_mtd (void) 139static int __init init_sbc8240_mtd (void)
140{ 140{
141 static struct _cjs { 141 static struct _cjs {
142 u_long addr; 142 u_long addr;
diff --git a/drivers/mtd/maps/scb2_flash.c b/drivers/mtd/maps/scb2_flash.c
index 21169e6d646c..7e329f09a548 100644
--- a/drivers/mtd/maps/scb2_flash.c
+++ b/drivers/mtd/maps/scb2_flash.c
@@ -118,7 +118,8 @@ scb2_fixup_mtd(struct mtd_info *mtd)
118 struct mtd_erase_region_info *region = &mtd->eraseregions[i]; 118 struct mtd_erase_region_info *region = &mtd->eraseregions[i];
119 119
120 if (region->numblocks * region->erasesize > mtd->size) { 120 if (region->numblocks * region->erasesize > mtd->size) {
121 region->numblocks = (mtd->size / region->erasesize); 121 region->numblocks = ((unsigned long)mtd->size /
122 region->erasesize);
122 done = 1; 123 done = 1;
123 } else { 124 } else {
124 region->numblocks = 0; 125 region->numblocks = 0;
@@ -187,8 +188,9 @@ scb2_flash_probe(struct pci_dev *dev, const struct pci_device_id *ent)
187 return -ENODEV; 188 return -ENODEV;
188 } 189 }
189 190
190 printk(KERN_NOTICE MODNAME ": chip size 0x%x at offset 0x%x\n", 191 printk(KERN_NOTICE MODNAME ": chip size 0x%llx at offset 0x%llx\n",
191 scb2_mtd->size, SCB2_WINDOW - scb2_mtd->size); 192 (unsigned long long)scb2_mtd->size,
193 (unsigned long long)(SCB2_WINDOW - scb2_mtd->size));
192 194
193 add_mtd_device(scb2_mtd); 195 add_mtd_device(scb2_mtd);
194 196
diff --git a/drivers/mtd/maps/sharpsl-flash.c b/drivers/mtd/maps/sharpsl-flash.c
index 026eab028189..b392f096c706 100644
--- a/drivers/mtd/maps/sharpsl-flash.c
+++ b/drivers/mtd/maps/sharpsl-flash.c
@@ -47,7 +47,7 @@ static struct mtd_partition sharpsl_partitions[1] = {
47 } 47 }
48}; 48};
49 49
50int __init init_sharpsl(void) 50static int __init init_sharpsl(void)
51{ 51{
52 struct mtd_partition *parts; 52 struct mtd_partition *parts;
53 int nb_parts = 0; 53 int nb_parts = 0;
diff --git a/drivers/mtd/maps/tqm8xxl.c b/drivers/mtd/maps/tqm8xxl.c
index a5d3d8531faa..60146984f4be 100644
--- a/drivers/mtd/maps/tqm8xxl.c
+++ b/drivers/mtd/maps/tqm8xxl.c
@@ -109,7 +109,7 @@ static struct mtd_partition tqm8xxl_fs_partitions[] = {
109}; 109};
110#endif 110#endif
111 111
112int __init init_tqm_mtd(void) 112static int __init init_tqm_mtd(void)
113{ 113{
114 int idx = 0, ret = 0; 114 int idx = 0, ret = 0;
115 unsigned long flash_addr, flash_size, mtd_size = 0; 115 unsigned long flash_addr, flash_size, mtd_size = 0;
diff --git a/drivers/mtd/maps/uclinux.c b/drivers/mtd/maps/uclinux.c
index 0dc645f8152f..81756e397711 100644
--- a/drivers/mtd/maps/uclinux.c
+++ b/drivers/mtd/maps/uclinux.c
@@ -51,7 +51,7 @@ int uclinux_point(struct mtd_info *mtd, loff_t from, size_t len,
51 51
52/****************************************************************************/ 52/****************************************************************************/
53 53
54int __init uclinux_mtd_init(void) 54static int __init uclinux_mtd_init(void)
55{ 55{
56 struct mtd_info *mtd; 56 struct mtd_info *mtd;
57 struct map_info *mapp; 57 struct map_info *mapp;
@@ -94,7 +94,7 @@ int __init uclinux_mtd_init(void)
94 94
95/****************************************************************************/ 95/****************************************************************************/
96 96
97void __exit uclinux_mtd_cleanup(void) 97static void __exit uclinux_mtd_cleanup(void)
98{ 98{
99 if (uclinux_ram_mtdinfo) { 99 if (uclinux_ram_mtdinfo) {
100 del_mtd_partitions(uclinux_ram_mtdinfo); 100 del_mtd_partitions(uclinux_ram_mtdinfo);
diff --git a/drivers/mtd/maps/vmax301.c b/drivers/mtd/maps/vmax301.c
index 5a0c9a353b0f..6d452dcdfe34 100644
--- a/drivers/mtd/maps/vmax301.c
+++ b/drivers/mtd/maps/vmax301.c
@@ -146,7 +146,7 @@ static void __exit cleanup_vmax301(void)
146 iounmap((void *)vmax_map[0].map_priv_1 - WINDOW_START); 146 iounmap((void *)vmax_map[0].map_priv_1 - WINDOW_START);
147} 147}
148 148
149int __init init_vmax301(void) 149static int __init init_vmax301(void)
150{ 150{
151 int i; 151 int i;
152 unsigned long iomapadr; 152 unsigned long iomapadr;
diff --git a/drivers/mtd/maps/wr_sbc82xx_flash.c b/drivers/mtd/maps/wr_sbc82xx_flash.c
index 413b0cf9bbd2..933a2b6598b4 100644
--- a/drivers/mtd/maps/wr_sbc82xx_flash.c
+++ b/drivers/mtd/maps/wr_sbc82xx_flash.c
@@ -74,7 +74,7 @@ do { \
74 } \ 74 } \
75} while (0); 75} while (0);
76 76
77int __init init_sbc82xx_flash(void) 77static int __init init_sbc82xx_flash(void)
78{ 78{
79 volatile memctl_cpm2_t *mc = &cpm2_immr->im_memctl; 79 volatile memctl_cpm2_t *mc = &cpm2_immr->im_memctl;
80 int bigflash; 80 int bigflash;
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index bcffeda2df3d..e9ec59e9a566 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -450,16 +450,20 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
450 if (!erase) 450 if (!erase)
451 ret = -ENOMEM; 451 ret = -ENOMEM;
452 else { 452 else {
453 struct erase_info_user einfo;
454
453 wait_queue_head_t waitq; 455 wait_queue_head_t waitq;
454 DECLARE_WAITQUEUE(wait, current); 456 DECLARE_WAITQUEUE(wait, current);
455 457
456 init_waitqueue_head(&waitq); 458 init_waitqueue_head(&waitq);
457 459
458 if (copy_from_user(&erase->addr, argp, 460 if (copy_from_user(&einfo, argp,
459 sizeof(struct erase_info_user))) { 461 sizeof(struct erase_info_user))) {
460 kfree(erase); 462 kfree(erase);
461 return -EFAULT; 463 return -EFAULT;
462 } 464 }
465 erase->addr = einfo.start;
466 erase->len = einfo.length;
463 erase->mtd = mtd; 467 erase->mtd = mtd;
464 erase->callback = mtdchar_erase_callback; 468 erase->callback = mtdchar_erase_callback;
465 erase->priv = (unsigned long)&waitq; 469 erase->priv = (unsigned long)&waitq;
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
index 1a05cf37851e..3dbb1b38db66 100644
--- a/drivers/mtd/mtdconcat.c
+++ b/drivers/mtd/mtdconcat.c
@@ -197,7 +197,7 @@ concat_writev(struct mtd_info *mtd, const struct kvec *vecs,
197 continue; 197 continue;
198 } 198 }
199 199
200 size = min(total_len, (size_t)(subdev->size - to)); 200 size = min_t(uint64_t, total_len, subdev->size - to);
201 wsize = size; /* store for future use */ 201 wsize = size; /* store for future use */
202 202
203 entry_high = entry_low; 203 entry_high = entry_low;
@@ -385,7 +385,7 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr)
385 struct mtd_concat *concat = CONCAT(mtd); 385 struct mtd_concat *concat = CONCAT(mtd);
386 struct mtd_info *subdev; 386 struct mtd_info *subdev;
387 int i, err; 387 int i, err;
388 u_int32_t length, offset = 0; 388 uint64_t length, offset = 0;
389 struct erase_info *erase; 389 struct erase_info *erase;
390 390
391 if (!(mtd->flags & MTD_WRITEABLE)) 391 if (!(mtd->flags & MTD_WRITEABLE))
@@ -518,7 +518,7 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr)
518 return 0; 518 return 0;
519} 519}
520 520
521static int concat_lock(struct mtd_info *mtd, loff_t ofs, size_t len) 521static int concat_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
522{ 522{
523 struct mtd_concat *concat = CONCAT(mtd); 523 struct mtd_concat *concat = CONCAT(mtd);
524 int i, err = -EINVAL; 524 int i, err = -EINVAL;
@@ -528,7 +528,7 @@ static int concat_lock(struct mtd_info *mtd, loff_t ofs, size_t len)
528 528
529 for (i = 0; i < concat->num_subdev; i++) { 529 for (i = 0; i < concat->num_subdev; i++) {
530 struct mtd_info *subdev = concat->subdev[i]; 530 struct mtd_info *subdev = concat->subdev[i];
531 size_t size; 531 uint64_t size;
532 532
533 if (ofs >= subdev->size) { 533 if (ofs >= subdev->size) {
534 size = 0; 534 size = 0;
@@ -556,7 +556,7 @@ static int concat_lock(struct mtd_info *mtd, loff_t ofs, size_t len)
556 return err; 556 return err;
557} 557}
558 558
559static int concat_unlock(struct mtd_info *mtd, loff_t ofs, size_t len) 559static int concat_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
560{ 560{
561 struct mtd_concat *concat = CONCAT(mtd); 561 struct mtd_concat *concat = CONCAT(mtd);
562 int i, err = 0; 562 int i, err = 0;
@@ -566,7 +566,7 @@ static int concat_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)
566 566
567 for (i = 0; i < concat->num_subdev; i++) { 567 for (i = 0; i < concat->num_subdev; i++) {
568 struct mtd_info *subdev = concat->subdev[i]; 568 struct mtd_info *subdev = concat->subdev[i];
569 size_t size; 569 uint64_t size;
570 570
571 if (ofs >= subdev->size) { 571 if (ofs >= subdev->size) {
572 size = 0; 572 size = 0;
@@ -696,7 +696,7 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c
696 int i; 696 int i;
697 size_t size; 697 size_t size;
698 struct mtd_concat *concat; 698 struct mtd_concat *concat;
699 u_int32_t max_erasesize, curr_erasesize; 699 uint32_t max_erasesize, curr_erasesize;
700 int num_erase_region; 700 int num_erase_region;
701 701
702 printk(KERN_NOTICE "Concatenating MTD devices:\n"); 702 printk(KERN_NOTICE "Concatenating MTD devices:\n");
@@ -842,12 +842,14 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c
842 concat->mtd.erasesize = curr_erasesize; 842 concat->mtd.erasesize = curr_erasesize;
843 concat->mtd.numeraseregions = 0; 843 concat->mtd.numeraseregions = 0;
844 } else { 844 } else {
845 uint64_t tmp64;
846
845 /* 847 /*
846 * erase block size varies across the subdevices: allocate 848 * erase block size varies across the subdevices: allocate
847 * space to store the data describing the variable erase regions 849 * space to store the data describing the variable erase regions
848 */ 850 */
849 struct mtd_erase_region_info *erase_region_p; 851 struct mtd_erase_region_info *erase_region_p;
850 u_int32_t begin, position; 852 uint64_t begin, position;
851 853
852 concat->mtd.erasesize = max_erasesize; 854 concat->mtd.erasesize = max_erasesize;
853 concat->mtd.numeraseregions = num_erase_region; 855 concat->mtd.numeraseregions = num_erase_region;
@@ -879,8 +881,9 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c
879 erase_region_p->offset = begin; 881 erase_region_p->offset = begin;
880 erase_region_p->erasesize = 882 erase_region_p->erasesize =
881 curr_erasesize; 883 curr_erasesize;
882 erase_region_p->numblocks = 884 tmp64 = position - begin;
883 (position - begin) / curr_erasesize; 885 do_div(tmp64, curr_erasesize);
886 erase_region_p->numblocks = tmp64;
884 begin = position; 887 begin = position;
885 888
886 curr_erasesize = subdev[i]->erasesize; 889 curr_erasesize = subdev[i]->erasesize;
@@ -897,9 +900,9 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c
897 erase_region_p->offset = begin; 900 erase_region_p->offset = begin;
898 erase_region_p->erasesize = 901 erase_region_p->erasesize =
899 curr_erasesize; 902 curr_erasesize;
900 erase_region_p->numblocks = 903 tmp64 = position - begin;
901 (position - 904 do_div(tmp64, curr_erasesize);
902 begin) / curr_erasesize; 905 erase_region_p->numblocks = tmp64;
903 begin = position; 906 begin = position;
904 907
905 curr_erasesize = 908 curr_erasesize =
@@ -909,14 +912,16 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c
909 } 912 }
910 position += 913 position +=
911 subdev[i]->eraseregions[j]. 914 subdev[i]->eraseregions[j].
912 numblocks * curr_erasesize; 915 numblocks * (uint64_t)curr_erasesize;
913 } 916 }
914 } 917 }
915 } 918 }
916 /* Now write the final entry */ 919 /* Now write the final entry */
917 erase_region_p->offset = begin; 920 erase_region_p->offset = begin;
918 erase_region_p->erasesize = curr_erasesize; 921 erase_region_p->erasesize = curr_erasesize;
919 erase_region_p->numblocks = (position - begin) / curr_erasesize; 922 tmp64 = position - begin;
923 do_div(tmp64, curr_erasesize);
924 erase_region_p->numblocks = tmp64;
920 } 925 }
921 926
922 return &concat->mtd; 927 return &concat->mtd;
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index a9d246949820..76fe0a1e7a5e 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -57,6 +57,19 @@ int add_mtd_device(struct mtd_info *mtd)
57 mtd->index = i; 57 mtd->index = i;
58 mtd->usecount = 0; 58 mtd->usecount = 0;
59 59
60 if (is_power_of_2(mtd->erasesize))
61 mtd->erasesize_shift = ffs(mtd->erasesize) - 1;
62 else
63 mtd->erasesize_shift = 0;
64
65 if (is_power_of_2(mtd->writesize))
66 mtd->writesize_shift = ffs(mtd->writesize) - 1;
67 else
68 mtd->writesize_shift = 0;
69
70 mtd->erasesize_mask = (1 << mtd->erasesize_shift) - 1;
71 mtd->writesize_mask = (1 << mtd->writesize_shift) - 1;
72
60 /* Some chips always power up locked. Unlock them now */ 73 /* Some chips always power up locked. Unlock them now */
61 if ((mtd->flags & MTD_WRITEABLE) 74 if ((mtd->flags & MTD_WRITEABLE)
62 && (mtd->flags & MTD_POWERUP_LOCK) && mtd->unlock) { 75 && (mtd->flags & MTD_POWERUP_LOCK) && mtd->unlock) {
@@ -344,7 +357,8 @@ static inline int mtd_proc_info (char *buf, int i)
344 if (!this) 357 if (!this)
345 return 0; 358 return 0;
346 359
347 return sprintf(buf, "mtd%d: %8.8x %8.8x \"%s\"\n", i, this->size, 360 return sprintf(buf, "mtd%d: %8.8llx %8.8x \"%s\"\n", i,
361 (unsigned long long)this->size,
348 this->erasesize, this->name); 362 this->erasesize, this->name);
349} 363}
350 364
diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c
index aebb3b27edbd..1a6b3beabe8d 100644
--- a/drivers/mtd/mtdoops.c
+++ b/drivers/mtd/mtdoops.c
@@ -80,9 +80,9 @@ static int mtdoops_erase_block(struct mtd_info *mtd, int offset)
80 if (ret) { 80 if (ret) {
81 set_current_state(TASK_RUNNING); 81 set_current_state(TASK_RUNNING);
82 remove_wait_queue(&wait_q, &wait); 82 remove_wait_queue(&wait_q, &wait);
83 printk (KERN_WARNING "mtdoops: erase of region [0x%x, 0x%x] " 83 printk (KERN_WARNING "mtdoops: erase of region [0x%llx, 0x%llx] "
84 "on \"%s\" failed\n", 84 "on \"%s\" failed\n",
85 erase.addr, erase.len, mtd->name); 85 (unsigned long long)erase.addr, (unsigned long long)erase.len, mtd->name);
86 return ret; 86 return ret;
87 } 87 }
88 88
@@ -289,7 +289,10 @@ static void mtdoops_notify_add(struct mtd_info *mtd)
289 } 289 }
290 290
291 cxt->mtd = mtd; 291 cxt->mtd = mtd;
292 cxt->oops_pages = mtd->size / OOPS_PAGE_SIZE; 292 if (mtd->size > INT_MAX)
293 cxt->oops_pages = INT_MAX / OOPS_PAGE_SIZE;
294 else
295 cxt->oops_pages = (int)mtd->size / OOPS_PAGE_SIZE;
293 296
294 find_next_position(cxt); 297 find_next_position(cxt);
295 298
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 3728913fa5fa..144e6b613a77 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -26,7 +26,7 @@ static LIST_HEAD(mtd_partitions);
26struct mtd_part { 26struct mtd_part {
27 struct mtd_info mtd; 27 struct mtd_info mtd;
28 struct mtd_info *master; 28 struct mtd_info *master;
29 u_int32_t offset; 29 uint64_t offset;
30 int index; 30 int index;
31 struct list_head list; 31 struct list_head list;
32 int registered; 32 int registered;
@@ -235,7 +235,7 @@ void mtd_erase_callback(struct erase_info *instr)
235} 235}
236EXPORT_SYMBOL_GPL(mtd_erase_callback); 236EXPORT_SYMBOL_GPL(mtd_erase_callback);
237 237
238static int part_lock(struct mtd_info *mtd, loff_t ofs, size_t len) 238static int part_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
239{ 239{
240 struct mtd_part *part = PART(mtd); 240 struct mtd_part *part = PART(mtd);
241 if ((len + ofs) > mtd->size) 241 if ((len + ofs) > mtd->size)
@@ -243,7 +243,7 @@ static int part_lock(struct mtd_info *mtd, loff_t ofs, size_t len)
243 return part->master->lock(part->master, ofs + part->offset, len); 243 return part->master->lock(part->master, ofs + part->offset, len);
244} 244}
245 245
246static int part_unlock(struct mtd_info *mtd, loff_t ofs, size_t len) 246static int part_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
247{ 247{
248 struct mtd_part *part = PART(mtd); 248 struct mtd_part *part = PART(mtd);
249 if ((len + ofs) > mtd->size) 249 if ((len + ofs) > mtd->size)
@@ -317,7 +317,7 @@ EXPORT_SYMBOL(del_mtd_partitions);
317 317
318static struct mtd_part *add_one_partition(struct mtd_info *master, 318static struct mtd_part *add_one_partition(struct mtd_info *master,
319 const struct mtd_partition *part, int partno, 319 const struct mtd_partition *part, int partno,
320 u_int32_t cur_offset) 320 uint64_t cur_offset)
321{ 321{
322 struct mtd_part *slave; 322 struct mtd_part *slave;
323 323
@@ -395,19 +395,19 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
395 slave->offset = cur_offset; 395 slave->offset = cur_offset;
396 if (slave->offset == MTDPART_OFS_NXTBLK) { 396 if (slave->offset == MTDPART_OFS_NXTBLK) {
397 slave->offset = cur_offset; 397 slave->offset = cur_offset;
398 if ((cur_offset % master->erasesize) != 0) { 398 if (mtd_mod_by_eb(cur_offset, master) != 0) {
399 /* Round up to next erasesize */ 399 /* Round up to next erasesize */
400 slave->offset = ((cur_offset / master->erasesize) + 1) * master->erasesize; 400 slave->offset = (mtd_div_by_eb(cur_offset, master) + 1) * master->erasesize;
401 printk(KERN_NOTICE "Moving partition %d: " 401 printk(KERN_NOTICE "Moving partition %d: "
402 "0x%08x -> 0x%08x\n", partno, 402 "0x%012llx -> 0x%012llx\n", partno,
403 cur_offset, slave->offset); 403 (unsigned long long)cur_offset, (unsigned long long)slave->offset);
404 } 404 }
405 } 405 }
406 if (slave->mtd.size == MTDPART_SIZ_FULL) 406 if (slave->mtd.size == MTDPART_SIZ_FULL)
407 slave->mtd.size = master->size - slave->offset; 407 slave->mtd.size = master->size - slave->offset;
408 408
409 printk(KERN_NOTICE "0x%08x-0x%08x : \"%s\"\n", slave->offset, 409 printk(KERN_NOTICE "0x%012llx-0x%012llx : \"%s\"\n", (unsigned long long)slave->offset,
410 slave->offset + slave->mtd.size, slave->mtd.name); 410 (unsigned long long)(slave->offset + slave->mtd.size), slave->mtd.name);
411 411
412 /* let's do some sanity checks */ 412 /* let's do some sanity checks */
413 if (slave->offset >= master->size) { 413 if (slave->offset >= master->size) {
@@ -420,13 +420,13 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
420 } 420 }
421 if (slave->offset + slave->mtd.size > master->size) { 421 if (slave->offset + slave->mtd.size > master->size) {
422 slave->mtd.size = master->size - slave->offset; 422 slave->mtd.size = master->size - slave->offset;
423 printk(KERN_WARNING"mtd: partition \"%s\" extends beyond the end of device \"%s\" -- size truncated to %#x\n", 423 printk(KERN_WARNING"mtd: partition \"%s\" extends beyond the end of device \"%s\" -- size truncated to %#llx\n",
424 part->name, master->name, slave->mtd.size); 424 part->name, master->name, (unsigned long long)slave->mtd.size);
425 } 425 }
426 if (master->numeraseregions > 1) { 426 if (master->numeraseregions > 1) {
427 /* Deal with variable erase size stuff */ 427 /* Deal with variable erase size stuff */
428 int i, max = master->numeraseregions; 428 int i, max = master->numeraseregions;
429 u32 end = slave->offset + slave->mtd.size; 429 u64 end = slave->offset + slave->mtd.size;
430 struct mtd_erase_region_info *regions = master->eraseregions; 430 struct mtd_erase_region_info *regions = master->eraseregions;
431 431
432 /* Find the first erase regions which is part of this 432 /* Find the first erase regions which is part of this
@@ -449,7 +449,7 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
449 } 449 }
450 450
451 if ((slave->mtd.flags & MTD_WRITEABLE) && 451 if ((slave->mtd.flags & MTD_WRITEABLE) &&
452 (slave->offset % slave->mtd.erasesize)) { 452 mtd_mod_by_eb(slave->offset, &slave->mtd)) {
453 /* Doesn't start on a boundary of major erase size */ 453 /* Doesn't start on a boundary of major erase size */
454 /* FIXME: Let it be writable if it is on a boundary of 454 /* FIXME: Let it be writable if it is on a boundary of
455 * _minor_ erase size though */ 455 * _minor_ erase size though */
@@ -458,7 +458,7 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
458 part->name); 458 part->name);
459 } 459 }
460 if ((slave->mtd.flags & MTD_WRITEABLE) && 460 if ((slave->mtd.flags & MTD_WRITEABLE) &&
461 (slave->mtd.size % slave->mtd.erasesize)) { 461 mtd_mod_by_eb(slave->mtd.size, &slave->mtd)) {
462 slave->mtd.flags &= ~MTD_WRITEABLE; 462 slave->mtd.flags &= ~MTD_WRITEABLE;
463 printk(KERN_WARNING"mtd: partition \"%s\" doesn't end on an erase block -- force read-only\n", 463 printk(KERN_WARNING"mtd: partition \"%s\" doesn't end on an erase block -- force read-only\n",
464 part->name); 464 part->name);
@@ -466,7 +466,7 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
466 466
467 slave->mtd.ecclayout = master->ecclayout; 467 slave->mtd.ecclayout = master->ecclayout;
468 if (master->block_isbad) { 468 if (master->block_isbad) {
469 uint32_t offs = 0; 469 uint64_t offs = 0;
470 470
471 while (offs < slave->mtd.size) { 471 while (offs < slave->mtd.size) {
472 if (master->block_isbad(master, 472 if (master->block_isbad(master,
@@ -501,7 +501,7 @@ int add_mtd_partitions(struct mtd_info *master,
501 int nbparts) 501 int nbparts)
502{ 502{
503 struct mtd_part *slave; 503 struct mtd_part *slave;
504 u_int32_t cur_offset = 0; 504 uint64_t cur_offset = 0;
505 int i; 505 int i;
506 506
507 printk(KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name); 507 printk(KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name);
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index f8ae0400c49c..8b12e6e109d3 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -163,6 +163,13 @@ config MTD_NAND_S3C2410_HWECC
163 incorrect ECC generation, and if using these, the default of 163 incorrect ECC generation, and if using these, the default of
164 software ECC is preferable. 164 software ECC is preferable.
165 165
166config MTD_NAND_NDFC
167 tristate "NDFC NanD Flash Controller"
168 depends on 4xx
169 select MTD_NAND_ECC_SMC
170 help
171 NDFC Nand Flash Controllers are integrated in IBM/AMCC's 4xx SoCs
172
166config MTD_NAND_S3C2410_CLKSTOP 173config MTD_NAND_S3C2410_CLKSTOP
167 bool "S3C2410 NAND IDLE clock stop" 174 bool "S3C2410 NAND IDLE clock stop"
168 depends on MTD_NAND_S3C2410 175 depends on MTD_NAND_S3C2410
diff --git a/drivers/mtd/nand/alauda.c b/drivers/mtd/nand/alauda.c
index 962380394855..6d9649159a18 100644
--- a/drivers/mtd/nand/alauda.c
+++ b/drivers/mtd/nand/alauda.c
@@ -676,11 +676,11 @@ static int alauda_probe(struct usb_interface *interface,
676 goto error; 676 goto error;
677 677
678 al->write_out = usb_sndbulkpipe(al->dev, 678 al->write_out = usb_sndbulkpipe(al->dev,
679 ep_wr->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); 679 usb_endpoint_num(ep_wr));
680 al->bulk_in = usb_rcvbulkpipe(al->dev, 680 al->bulk_in = usb_rcvbulkpipe(al->dev,
681 ep_in->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); 681 usb_endpoint_num(ep_in));
682 al->bulk_out = usb_sndbulkpipe(al->dev, 682 al->bulk_out = usb_sndbulkpipe(al->dev,
683 ep_out->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); 683 usb_endpoint_num(ep_out));
684 684
685 /* second device is identical up to now */ 685 /* second device is identical up to now */
686 memcpy(al+1, al, sizeof(*al)); 686 memcpy(al+1, al, sizeof(*al));
diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c
index b8064bf3aee4..22a6b2e50e91 100644
--- a/drivers/mtd/nand/cafe_nand.c
+++ b/drivers/mtd/nand/cafe_nand.c
@@ -90,7 +90,7 @@ static int timing[3];
90module_param_array(timing, int, &numtimings, 0644); 90module_param_array(timing, int, &numtimings, 0644);
91 91
92#ifdef CONFIG_MTD_PARTITIONS 92#ifdef CONFIG_MTD_PARTITIONS
93static const char *part_probes[] = { "RedBoot", NULL }; 93static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
94#endif 94#endif
95 95
96/* Hrm. Why isn't this already conditional on something in the struct device? */ 96/* Hrm. Why isn't this already conditional on something in the struct device? */
@@ -805,10 +805,13 @@ static int __devinit cafe_nand_probe(struct pci_dev *pdev,
805 add_mtd_device(mtd); 805 add_mtd_device(mtd);
806 806
807#ifdef CONFIG_MTD_PARTITIONS 807#ifdef CONFIG_MTD_PARTITIONS
808#ifdef CONFIG_MTD_CMDLINE_PARTS
809 mtd->name = "cafe_nand";
810#endif
808 nr_parts = parse_mtd_partitions(mtd, part_probes, &parts, 0); 811 nr_parts = parse_mtd_partitions(mtd, part_probes, &parts, 0);
809 if (nr_parts > 0) { 812 if (nr_parts > 0) {
810 cafe->parts = parts; 813 cafe->parts = parts;
811 dev_info(&cafe->pdev->dev, "%d RedBoot partitions found\n", nr_parts); 814 dev_info(&cafe->pdev->dev, "%d partitions found\n", nr_parts);
812 add_mtd_partitions(mtd, parts, nr_parts); 815 add_mtd_partitions(mtd, parts, nr_parts);
813 } 816 }
814#endif 817#endif
diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index 4aa5bd6158da..65929db29446 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -777,7 +777,9 @@ static int fsl_elbc_chip_init(struct fsl_elbc_mtd *priv)
777 /* Fill in fsl_elbc_mtd structure */ 777 /* Fill in fsl_elbc_mtd structure */
778 priv->mtd.priv = chip; 778 priv->mtd.priv = chip;
779 priv->mtd.owner = THIS_MODULE; 779 priv->mtd.owner = THIS_MODULE;
780 priv->fmr = 0; /* rest filled in later */ 780
781 /* Set the ECCM according to the settings in bootloader.*/
782 priv->fmr = in_be32(&lbc->fmr) & FMR_ECCM;
781 783
782 /* fill in nand_chip structure */ 784 /* fill in nand_chip structure */
783 /* set up function call table */ 785 /* set up function call table */
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 0a9c9cd33f96..0c3afccde8a2 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2014,13 +2014,14 @@ static int nand_erase(struct mtd_info *mtd, struct erase_info *instr)
2014int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, 2014int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
2015 int allowbbt) 2015 int allowbbt)
2016{ 2016{
2017 int page, len, status, pages_per_block, ret, chipnr; 2017 int page, status, pages_per_block, ret, chipnr;
2018 struct nand_chip *chip = mtd->priv; 2018 struct nand_chip *chip = mtd->priv;
2019 int rewrite_bbt[NAND_MAX_CHIPS]={0}; 2019 loff_t rewrite_bbt[NAND_MAX_CHIPS]={0};
2020 unsigned int bbt_masked_page = 0xffffffff; 2020 unsigned int bbt_masked_page = 0xffffffff;
2021 loff_t len;
2021 2022
2022 DEBUG(MTD_DEBUG_LEVEL3, "nand_erase: start = 0x%08x, len = %i\n", 2023 DEBUG(MTD_DEBUG_LEVEL3, "nand_erase: start = 0x%012llx, len = %llu\n",
2023 (unsigned int)instr->addr, (unsigned int)instr->len); 2024 (unsigned long long)instr->addr, (unsigned long long)instr->len);
2024 2025
2025 /* Start address must align on block boundary */ 2026 /* Start address must align on block boundary */
2026 if (instr->addr & ((1 << chip->phys_erase_shift) - 1)) { 2027 if (instr->addr & ((1 << chip->phys_erase_shift) - 1)) {
@@ -2116,7 +2117,8 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
2116 DEBUG(MTD_DEBUG_LEVEL0, "nand_erase: " 2117 DEBUG(MTD_DEBUG_LEVEL0, "nand_erase: "
2117 "Failed erase, page 0x%08x\n", page); 2118 "Failed erase, page 0x%08x\n", page);
2118 instr->state = MTD_ERASE_FAILED; 2119 instr->state = MTD_ERASE_FAILED;
2119 instr->fail_addr = (page << chip->page_shift); 2120 instr->fail_addr =
2121 ((loff_t)page << chip->page_shift);
2120 goto erase_exit; 2122 goto erase_exit;
2121 } 2123 }
2122 2124
@@ -2126,7 +2128,8 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
2126 */ 2128 */
2127 if (bbt_masked_page != 0xffffffff && 2129 if (bbt_masked_page != 0xffffffff &&
2128 (page & BBT_PAGE_MASK) == bbt_masked_page) 2130 (page & BBT_PAGE_MASK) == bbt_masked_page)
2129 rewrite_bbt[chipnr] = (page << chip->page_shift); 2131 rewrite_bbt[chipnr] =
2132 ((loff_t)page << chip->page_shift);
2130 2133
2131 /* Increment page address and decrement length */ 2134 /* Increment page address and decrement length */
2132 len -= (1 << chip->phys_erase_shift); 2135 len -= (1 << chip->phys_erase_shift);
@@ -2173,7 +2176,7 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
2173 continue; 2176 continue;
2174 /* update the BBT for chip */ 2177 /* update the BBT for chip */
2175 DEBUG(MTD_DEBUG_LEVEL0, "nand_erase_nand: nand_update_bbt " 2178 DEBUG(MTD_DEBUG_LEVEL0, "nand_erase_nand: nand_update_bbt "
2176 "(%d:0x%0x 0x%0x)\n", chipnr, rewrite_bbt[chipnr], 2179 "(%d:0x%0llx 0x%0x)\n", chipnr, rewrite_bbt[chipnr],
2177 chip->bbt_td->pages[chipnr]); 2180 chip->bbt_td->pages[chipnr]);
2178 nand_update_bbt(mtd, rewrite_bbt[chipnr]); 2181 nand_update_bbt(mtd, rewrite_bbt[chipnr]);
2179 } 2182 }
@@ -2365,7 +2368,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
2365 if (!mtd->name) 2368 if (!mtd->name)
2366 mtd->name = type->name; 2369 mtd->name = type->name;
2367 2370
2368 chip->chipsize = type->chipsize << 20; 2371 chip->chipsize = (uint64_t)type->chipsize << 20;
2369 2372
2370 /* Newer devices have all the information in additional id bytes */ 2373 /* Newer devices have all the information in additional id bytes */
2371 if (!type->pagesize) { 2374 if (!type->pagesize) {
@@ -2423,7 +2426,10 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
2423 2426
2424 chip->bbt_erase_shift = chip->phys_erase_shift = 2427 chip->bbt_erase_shift = chip->phys_erase_shift =
2425 ffs(mtd->erasesize) - 1; 2428 ffs(mtd->erasesize) - 1;
2426 chip->chip_shift = ffs(chip->chipsize) - 1; 2429 if (chip->chipsize & 0xffffffff)
2430 chip->chip_shift = ffs((unsigned)chip->chipsize) - 1;
2431 else
2432 chip->chip_shift = ffs((unsigned)(chip->chipsize >> 32)) + 32 - 1;
2427 2433
2428 /* Set the bad block position */ 2434 /* Set the bad block position */
2429 chip->badblockpos = mtd->writesize > 512 ? 2435 chip->badblockpos = mtd->writesize > 512 ?
@@ -2517,7 +2523,6 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips)
2517/** 2523/**
2518 * nand_scan_tail - [NAND Interface] Scan for the NAND device 2524 * nand_scan_tail - [NAND Interface] Scan for the NAND device
2519 * @mtd: MTD device structure 2525 * @mtd: MTD device structure
2520 * @maxchips: Number of chips to scan for
2521 * 2526 *
2522 * This is the second phase of the normal nand_scan() function. It 2527 * This is the second phase of the normal nand_scan() function. It
2523 * fills out all the uninitialized function pointers with the defaults 2528 * fills out all the uninitialized function pointers with the defaults
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index 0b1c48595f12..55c23e5cd210 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -171,16 +171,16 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num,
171 if (tmp == msk) 171 if (tmp == msk)
172 continue; 172 continue;
173 if (reserved_block_code && (tmp == reserved_block_code)) { 173 if (reserved_block_code && (tmp == reserved_block_code)) {
174 printk(KERN_DEBUG "nand_read_bbt: Reserved block at 0x%08x\n", 174 printk(KERN_DEBUG "nand_read_bbt: Reserved block at 0x%012llx\n",
175 ((offs << 2) + (act >> 1)) << this->bbt_erase_shift); 175 (loff_t)((offs << 2) + (act >> 1)) << this->bbt_erase_shift);
176 this->bbt[offs + (act >> 3)] |= 0x2 << (act & 0x06); 176 this->bbt[offs + (act >> 3)] |= 0x2 << (act & 0x06);
177 mtd->ecc_stats.bbtblocks++; 177 mtd->ecc_stats.bbtblocks++;
178 continue; 178 continue;
179 } 179 }
180 /* Leave it for now, if its matured we can move this 180 /* Leave it for now, if its matured we can move this
181 * message to MTD_DEBUG_LEVEL0 */ 181 * message to MTD_DEBUG_LEVEL0 */
182 printk(KERN_DEBUG "nand_read_bbt: Bad block at 0x%08x\n", 182 printk(KERN_DEBUG "nand_read_bbt: Bad block at 0x%012llx\n",
183 ((offs << 2) + (act >> 1)) << this->bbt_erase_shift); 183 (loff_t)((offs << 2) + (act >> 1)) << this->bbt_erase_shift);
184 /* Factory marked bad or worn out ? */ 184 /* Factory marked bad or worn out ? */
185 if (tmp == 0) 185 if (tmp == 0)
186 this->bbt[offs + (act >> 3)] |= 0x3 << (act & 0x06); 186 this->bbt[offs + (act >> 3)] |= 0x3 << (act & 0x06);
@@ -284,7 +284,7 @@ static int read_abs_bbts(struct mtd_info *mtd, uint8_t *buf,
284 284
285 /* Read the primary version, if available */ 285 /* Read the primary version, if available */
286 if (td->options & NAND_BBT_VERSION) { 286 if (td->options & NAND_BBT_VERSION) {
287 scan_read_raw(mtd, buf, td->pages[0] << this->page_shift, 287 scan_read_raw(mtd, buf, (loff_t)td->pages[0] << this->page_shift,
288 mtd->writesize); 288 mtd->writesize);
289 td->version[0] = buf[mtd->writesize + td->veroffs]; 289 td->version[0] = buf[mtd->writesize + td->veroffs];
290 printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", 290 printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n",
@@ -293,7 +293,7 @@ static int read_abs_bbts(struct mtd_info *mtd, uint8_t *buf,
293 293
294 /* Read the mirror version, if available */ 294 /* Read the mirror version, if available */
295 if (md && (md->options & NAND_BBT_VERSION)) { 295 if (md && (md->options & NAND_BBT_VERSION)) {
296 scan_read_raw(mtd, buf, md->pages[0] << this->page_shift, 296 scan_read_raw(mtd, buf, (loff_t)md->pages[0] << this->page_shift,
297 mtd->writesize); 297 mtd->writesize);
298 md->version[0] = buf[mtd->writesize + md->veroffs]; 298 md->version[0] = buf[mtd->writesize + md->veroffs];
299 printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n", 299 printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n",
@@ -411,7 +411,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf,
411 numblocks = this->chipsize >> (this->bbt_erase_shift - 1); 411 numblocks = this->chipsize >> (this->bbt_erase_shift - 1);
412 startblock = chip * numblocks; 412 startblock = chip * numblocks;
413 numblocks += startblock; 413 numblocks += startblock;
414 from = startblock << (this->bbt_erase_shift - 1); 414 from = (loff_t)startblock << (this->bbt_erase_shift - 1);
415 } 415 }
416 416
417 for (i = startblock; i < numblocks;) { 417 for (i = startblock; i < numblocks;) {
@@ -428,8 +428,8 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf,
428 428
429 if (ret) { 429 if (ret) {
430 this->bbt[i >> 3] |= 0x03 << (i & 0x6); 430 this->bbt[i >> 3] |= 0x03 << (i & 0x6);
431 printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n", 431 printk(KERN_WARNING "Bad eraseblock %d at 0x%012llx\n",
432 i >> 1, (unsigned int)from); 432 i >> 1, (unsigned long long)from);
433 mtd->ecc_stats.badblocks++; 433 mtd->ecc_stats.badblocks++;
434 } 434 }
435 435
@@ -495,7 +495,7 @@ static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
495 for (block = 0; block < td->maxblocks; block++) { 495 for (block = 0; block < td->maxblocks; block++) {
496 496
497 int actblock = startblock + dir * block; 497 int actblock = startblock + dir * block;
498 loff_t offs = actblock << this->bbt_erase_shift; 498 loff_t offs = (loff_t)actblock << this->bbt_erase_shift;
499 499
500 /* Read first page */ 500 /* Read first page */
501 scan_read_raw(mtd, buf, offs, mtd->writesize); 501 scan_read_raw(mtd, buf, offs, mtd->writesize);
@@ -719,7 +719,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
719 719
720 memset(&einfo, 0, sizeof(einfo)); 720 memset(&einfo, 0, sizeof(einfo));
721 einfo.mtd = mtd; 721 einfo.mtd = mtd;
722 einfo.addr = (unsigned long)to; 722 einfo.addr = to;
723 einfo.len = 1 << this->bbt_erase_shift; 723 einfo.len = 1 << this->bbt_erase_shift;
724 res = nand_erase_nand(mtd, &einfo, 1); 724 res = nand_erase_nand(mtd, &einfo, 1);
725 if (res < 0) 725 if (res < 0)
@@ -729,8 +729,8 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
729 if (res < 0) 729 if (res < 0)
730 goto outerr; 730 goto outerr;
731 731
732 printk(KERN_DEBUG "Bad block table written to 0x%08x, version " 732 printk(KERN_DEBUG "Bad block table written to 0x%012llx, version "
733 "0x%02X\n", (unsigned int)to, td->version[chip]); 733 "0x%02X\n", (unsigned long long)to, td->version[chip]);
734 734
735 /* Mark it as used */ 735 /* Mark it as used */
736 td->pages[chip] = page; 736 td->pages[chip] = page;
@@ -910,7 +910,7 @@ static void mark_bbt_region(struct mtd_info *mtd, struct nand_bbt_descr *td)
910 newval = oldval | (0x2 << (block & 0x06)); 910 newval = oldval | (0x2 << (block & 0x06));
911 this->bbt[(block >> 3)] = newval; 911 this->bbt[(block >> 3)] = newval;
912 if ((oldval != newval) && td->reserved_block_code) 912 if ((oldval != newval) && td->reserved_block_code)
913 nand_update_bbt(mtd, block << (this->bbt_erase_shift - 1)); 913 nand_update_bbt(mtd, (loff_t)block << (this->bbt_erase_shift - 1));
914 continue; 914 continue;
915 } 915 }
916 update = 0; 916 update = 0;
@@ -931,7 +931,7 @@ static void mark_bbt_region(struct mtd_info *mtd, struct nand_bbt_descr *td)
931 new ones have been marked, then we need to update the stored 931 new ones have been marked, then we need to update the stored
932 bbts. This should only happen once. */ 932 bbts. This should only happen once. */
933 if (update && td->reserved_block_code) 933 if (update && td->reserved_block_code)
934 nand_update_bbt(mtd, (block - 2) << (this->bbt_erase_shift - 1)); 934 nand_update_bbt(mtd, (loff_t)(block - 2) << (this->bbt_erase_shift - 1));
935 } 935 }
936} 936}
937 937
@@ -1027,7 +1027,6 @@ int nand_update_bbt(struct mtd_info *mtd, loff_t offs)
1027 if (!this->bbt || !td) 1027 if (!this->bbt || !td)
1028 return -EINVAL; 1028 return -EINVAL;
1029 1029
1030 len = mtd->size >> (this->bbt_erase_shift + 2);
1031 /* Allocate a temporary buffer for one eraseblock incl. oob */ 1030 /* Allocate a temporary buffer for one eraseblock incl. oob */
1032 len = (1 << this->bbt_erase_shift); 1031 len = (1 << this->bbt_erase_shift);
1033 len += (len >> this->page_shift) * mtd->oobsize; 1032 len += (len >> this->page_shift) * mtd->oobsize;
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index ae7c57781a68..cd0711b83ac4 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -38,6 +38,9 @@
38#include <linux/delay.h> 38#include <linux/delay.h>
39#include <linux/list.h> 39#include <linux/list.h>
40#include <linux/random.h> 40#include <linux/random.h>
41#include <linux/sched.h>
42#include <linux/fs.h>
43#include <linux/pagemap.h>
41 44
42/* Default simulator parameters values */ 45/* Default simulator parameters values */
43#if !defined(CONFIG_NANDSIM_FIRST_ID_BYTE) || \ 46#if !defined(CONFIG_NANDSIM_FIRST_ID_BYTE) || \
@@ -100,6 +103,7 @@ static unsigned int bitflips = 0;
100static char *gravepages = NULL; 103static char *gravepages = NULL;
101static unsigned int rptwear = 0; 104static unsigned int rptwear = 0;
102static unsigned int overridesize = 0; 105static unsigned int overridesize = 0;
106static char *cache_file = NULL;
103 107
104module_param(first_id_byte, uint, 0400); 108module_param(first_id_byte, uint, 0400);
105module_param(second_id_byte, uint, 0400); 109module_param(second_id_byte, uint, 0400);
@@ -122,12 +126,13 @@ module_param(bitflips, uint, 0400);
122module_param(gravepages, charp, 0400); 126module_param(gravepages, charp, 0400);
123module_param(rptwear, uint, 0400); 127module_param(rptwear, uint, 0400);
124module_param(overridesize, uint, 0400); 128module_param(overridesize, uint, 0400);
129module_param(cache_file, charp, 0400);
125 130
126MODULE_PARM_DESC(first_id_byte, "The first byte returned by NAND Flash 'read ID' command (manufacturer ID)"); 131MODULE_PARM_DESC(first_id_byte, "The first byte returned by NAND Flash 'read ID' command (manufacturer ID)");
127MODULE_PARM_DESC(second_id_byte, "The second byte returned by NAND Flash 'read ID' command (chip ID)"); 132MODULE_PARM_DESC(second_id_byte, "The second byte returned by NAND Flash 'read ID' command (chip ID)");
128MODULE_PARM_DESC(third_id_byte, "The third byte returned by NAND Flash 'read ID' command"); 133MODULE_PARM_DESC(third_id_byte, "The third byte returned by NAND Flash 'read ID' command");
129MODULE_PARM_DESC(fourth_id_byte, "The fourth byte returned by NAND Flash 'read ID' command"); 134MODULE_PARM_DESC(fourth_id_byte, "The fourth byte returned by NAND Flash 'read ID' command");
130MODULE_PARM_DESC(access_delay, "Initial page access delay (microiseconds)"); 135MODULE_PARM_DESC(access_delay, "Initial page access delay (microseconds)");
131MODULE_PARM_DESC(programm_delay, "Page programm delay (microseconds"); 136MODULE_PARM_DESC(programm_delay, "Page programm delay (microseconds");
132MODULE_PARM_DESC(erase_delay, "Sector erase delay (milliseconds)"); 137MODULE_PARM_DESC(erase_delay, "Sector erase delay (milliseconds)");
133MODULE_PARM_DESC(output_cycle, "Word output (from flash) time (nanodeconds)"); 138MODULE_PARM_DESC(output_cycle, "Word output (from flash) time (nanodeconds)");
@@ -153,6 +158,7 @@ MODULE_PARM_DESC(rptwear, "Number of erases inbetween reporting wear, if
153MODULE_PARM_DESC(overridesize, "Specifies the NAND Flash size overriding the ID bytes. " 158MODULE_PARM_DESC(overridesize, "Specifies the NAND Flash size overriding the ID bytes. "
154 "The size is specified in erase blocks and as the exponent of a power of two" 159 "The size is specified in erase blocks and as the exponent of a power of two"
155 " e.g. 5 means a size of 32 erase blocks"); 160 " e.g. 5 means a size of 32 erase blocks");
161MODULE_PARM_DESC(cache_file, "File to use to cache nand pages instead of memory");
156 162
157/* The largest possible page size */ 163/* The largest possible page size */
158#define NS_LARGEST_PAGE_SIZE 2048 164#define NS_LARGEST_PAGE_SIZE 2048
@@ -266,6 +272,9 @@ MODULE_PARM_DESC(overridesize, "Specifies the NAND Flash size overriding the I
266 */ 272 */
267#define NS_MAX_PREVSTATES 1 273#define NS_MAX_PREVSTATES 1
268 274
275/* Maximum page cache pages needed to read or write a NAND page to the cache_file */
276#define NS_MAX_HELD_PAGES 16
277
269/* 278/*
270 * A union to represent flash memory contents and flash buffer. 279 * A union to represent flash memory contents and flash buffer.
271 */ 280 */
@@ -295,6 +304,9 @@ struct nandsim {
295 /* The simulated NAND flash pages array */ 304 /* The simulated NAND flash pages array */
296 union ns_mem *pages; 305 union ns_mem *pages;
297 306
307 /* Slab allocator for nand pages */
308 struct kmem_cache *nand_pages_slab;
309
298 /* Internal buffer of page + OOB size bytes */ 310 /* Internal buffer of page + OOB size bytes */
299 union ns_mem buf; 311 union ns_mem buf;
300 312
@@ -335,6 +347,13 @@ struct nandsim {
335 int ale; /* address Latch Enable */ 347 int ale; /* address Latch Enable */
336 int wp; /* write Protect */ 348 int wp; /* write Protect */
337 } lines; 349 } lines;
350
351 /* Fields needed when using a cache file */
352 struct file *cfile; /* Open file */
353 unsigned char *pages_written; /* Which pages have been written */
354 void *file_buf;
355 struct page *held_pages[NS_MAX_HELD_PAGES];
356 int held_cnt;
338}; 357};
339 358
340/* 359/*
@@ -420,25 +439,69 @@ static struct mtd_info *nsmtd;
420static u_char ns_verify_buf[NS_LARGEST_PAGE_SIZE]; 439static u_char ns_verify_buf[NS_LARGEST_PAGE_SIZE];
421 440
422/* 441/*
423 * Allocate array of page pointers and initialize the array to NULL 442 * Allocate array of page pointers, create slab allocation for an array
424 * pointers. 443 * and initialize the array by NULL pointers.
425 * 444 *
426 * RETURNS: 0 if success, -ENOMEM if memory alloc fails. 445 * RETURNS: 0 if success, -ENOMEM if memory alloc fails.
427 */ 446 */
428static int alloc_device(struct nandsim *ns) 447static int alloc_device(struct nandsim *ns)
429{ 448{
430 int i; 449 struct file *cfile;
450 int i, err;
451
452 if (cache_file) {
453 cfile = filp_open(cache_file, O_CREAT | O_RDWR | O_LARGEFILE, 0600);
454 if (IS_ERR(cfile))
455 return PTR_ERR(cfile);
456 if (!cfile->f_op || (!cfile->f_op->read && !cfile->f_op->aio_read)) {
457 NS_ERR("alloc_device: cache file not readable\n");
458 err = -EINVAL;
459 goto err_close;
460 }
461 if (!cfile->f_op->write && !cfile->f_op->aio_write) {
462 NS_ERR("alloc_device: cache file not writeable\n");
463 err = -EINVAL;
464 goto err_close;
465 }
466 ns->pages_written = vmalloc(ns->geom.pgnum);
467 if (!ns->pages_written) {
468 NS_ERR("alloc_device: unable to allocate pages written array\n");
469 err = -ENOMEM;
470 goto err_close;
471 }
472 ns->file_buf = kmalloc(ns->geom.pgszoob, GFP_KERNEL);
473 if (!ns->file_buf) {
474 NS_ERR("alloc_device: unable to allocate file buf\n");
475 err = -ENOMEM;
476 goto err_free;
477 }
478 ns->cfile = cfile;
479 memset(ns->pages_written, 0, ns->geom.pgnum);
480 return 0;
481 }
431 482
432 ns->pages = vmalloc(ns->geom.pgnum * sizeof(union ns_mem)); 483 ns->pages = vmalloc(ns->geom.pgnum * sizeof(union ns_mem));
433 if (!ns->pages) { 484 if (!ns->pages) {
434 NS_ERR("alloc_map: unable to allocate page array\n"); 485 NS_ERR("alloc_device: unable to allocate page array\n");
435 return -ENOMEM; 486 return -ENOMEM;
436 } 487 }
437 for (i = 0; i < ns->geom.pgnum; i++) { 488 for (i = 0; i < ns->geom.pgnum; i++) {
438 ns->pages[i].byte = NULL; 489 ns->pages[i].byte = NULL;
439 } 490 }
491 ns->nand_pages_slab = kmem_cache_create("nandsim",
492 ns->geom.pgszoob, 0, 0, NULL);
493 if (!ns->nand_pages_slab) {
494 NS_ERR("cache_create: unable to create kmem_cache\n");
495 return -ENOMEM;
496 }
440 497
441 return 0; 498 return 0;
499
500err_free:
501 vfree(ns->pages_written);
502err_close:
503 filp_close(cfile, NULL);
504 return err;
442} 505}
443 506
444/* 507/*
@@ -448,11 +511,20 @@ static void free_device(struct nandsim *ns)
448{ 511{
449 int i; 512 int i;
450 513
514 if (ns->cfile) {
515 kfree(ns->file_buf);
516 vfree(ns->pages_written);
517 filp_close(ns->cfile, NULL);
518 return;
519 }
520
451 if (ns->pages) { 521 if (ns->pages) {
452 for (i = 0; i < ns->geom.pgnum; i++) { 522 for (i = 0; i < ns->geom.pgnum; i++) {
453 if (ns->pages[i].byte) 523 if (ns->pages[i].byte)
454 kfree(ns->pages[i].byte); 524 kmem_cache_free(ns->nand_pages_slab,
525 ns->pages[i].byte);
455 } 526 }
527 kmem_cache_destroy(ns->nand_pages_slab);
456 vfree(ns->pages); 528 vfree(ns->pages);
457 } 529 }
458} 530}
@@ -464,7 +536,7 @@ static char *get_partition_name(int i)
464 return kstrdup(buf, GFP_KERNEL); 536 return kstrdup(buf, GFP_KERNEL);
465} 537}
466 538
467static u_int64_t divide(u_int64_t n, u_int32_t d) 539static uint64_t divide(uint64_t n, uint32_t d)
468{ 540{
469 do_div(n, d); 541 do_div(n, d);
470 return n; 542 return n;
@@ -480,8 +552,8 @@ static int init_nandsim(struct mtd_info *mtd)
480 struct nand_chip *chip = (struct nand_chip *)mtd->priv; 552 struct nand_chip *chip = (struct nand_chip *)mtd->priv;
481 struct nandsim *ns = (struct nandsim *)(chip->priv); 553 struct nandsim *ns = (struct nandsim *)(chip->priv);
482 int i, ret = 0; 554 int i, ret = 0;
483 u_int64_t remains; 555 uint64_t remains;
484 u_int64_t next_offset; 556 uint64_t next_offset;
485 557
486 if (NS_IS_INITIALIZED(ns)) { 558 if (NS_IS_INITIALIZED(ns)) {
487 NS_ERR("init_nandsim: nandsim is already initialized\n"); 559 NS_ERR("init_nandsim: nandsim is already initialized\n");
@@ -548,7 +620,7 @@ static int init_nandsim(struct mtd_info *mtd)
548 remains = ns->geom.totsz; 620 remains = ns->geom.totsz;
549 next_offset = 0; 621 next_offset = 0;
550 for (i = 0; i < parts_num; ++i) { 622 for (i = 0; i < parts_num; ++i) {
551 u_int64_t part_sz = (u_int64_t)parts[i] * ns->geom.secsz; 623 uint64_t part_sz = (uint64_t)parts[i] * ns->geom.secsz;
552 624
553 if (!part_sz || part_sz > remains) { 625 if (!part_sz || part_sz > remains) {
554 NS_ERR("bad partition size.\n"); 626 NS_ERR("bad partition size.\n");
@@ -1211,6 +1283,97 @@ static int find_operation(struct nandsim *ns, uint32_t flag)
1211 return -1; 1283 return -1;
1212} 1284}
1213 1285
1286static void put_pages(struct nandsim *ns)
1287{
1288 int i;
1289
1290 for (i = 0; i < ns->held_cnt; i++)
1291 page_cache_release(ns->held_pages[i]);
1292}
1293
1294/* Get page cache pages in advance to provide NOFS memory allocation */
1295static int get_pages(struct nandsim *ns, struct file *file, size_t count, loff_t pos)
1296{
1297 pgoff_t index, start_index, end_index;
1298 struct page *page;
1299 struct address_space *mapping = file->f_mapping;
1300
1301 start_index = pos >> PAGE_CACHE_SHIFT;
1302 end_index = (pos + count - 1) >> PAGE_CACHE_SHIFT;
1303 if (end_index - start_index + 1 > NS_MAX_HELD_PAGES)
1304 return -EINVAL;
1305 ns->held_cnt = 0;
1306 for (index = start_index; index <= end_index; index++) {
1307 page = find_get_page(mapping, index);
1308 if (page == NULL) {
1309 page = find_or_create_page(mapping, index, GFP_NOFS);
1310 if (page == NULL) {
1311 write_inode_now(mapping->host, 1);
1312 page = find_or_create_page(mapping, index, GFP_NOFS);
1313 }
1314 if (page == NULL) {
1315 put_pages(ns);
1316 return -ENOMEM;
1317 }
1318 unlock_page(page);
1319 }
1320 ns->held_pages[ns->held_cnt++] = page;
1321 }
1322 return 0;
1323}
1324
1325static int set_memalloc(void)
1326{
1327 if (current->flags & PF_MEMALLOC)
1328 return 0;
1329 current->flags |= PF_MEMALLOC;
1330 return 1;
1331}
1332
1333static void clear_memalloc(int memalloc)
1334{
1335 if (memalloc)
1336 current->flags &= ~PF_MEMALLOC;
1337}
1338
1339static ssize_t read_file(struct nandsim *ns, struct file *file, void *buf, size_t count, loff_t *pos)
1340{
1341 mm_segment_t old_fs;
1342 ssize_t tx;
1343 int err, memalloc;
1344
1345 err = get_pages(ns, file, count, *pos);
1346 if (err)
1347 return err;
1348 old_fs = get_fs();
1349 set_fs(get_ds());
1350 memalloc = set_memalloc();
1351 tx = vfs_read(file, (char __user *)buf, count, pos);
1352 clear_memalloc(memalloc);
1353 set_fs(old_fs);
1354 put_pages(ns);
1355 return tx;
1356}
1357
1358static ssize_t write_file(struct nandsim *ns, struct file *file, void *buf, size_t count, loff_t *pos)
1359{
1360 mm_segment_t old_fs;
1361 ssize_t tx;
1362 int err, memalloc;
1363
1364 err = get_pages(ns, file, count, *pos);
1365 if (err)
1366 return err;
1367 old_fs = get_fs();
1368 set_fs(get_ds());
1369 memalloc = set_memalloc();
1370 tx = vfs_write(file, (char __user *)buf, count, pos);
1371 clear_memalloc(memalloc);
1372 set_fs(old_fs);
1373 put_pages(ns);
1374 return tx;
1375}
1376
1214/* 1377/*
1215 * Returns a pointer to the current page. 1378 * Returns a pointer to the current page.
1216 */ 1379 */
@@ -1227,6 +1390,38 @@ static inline u_char *NS_PAGE_BYTE_OFF(struct nandsim *ns)
1227 return NS_GET_PAGE(ns)->byte + ns->regs.column + ns->regs.off; 1390 return NS_GET_PAGE(ns)->byte + ns->regs.column + ns->regs.off;
1228} 1391}
1229 1392
1393int do_read_error(struct nandsim *ns, int num)
1394{
1395 unsigned int page_no = ns->regs.row;
1396
1397 if (read_error(page_no)) {
1398 int i;
1399 memset(ns->buf.byte, 0xFF, num);
1400 for (i = 0; i < num; ++i)
1401 ns->buf.byte[i] = random32();
1402 NS_WARN("simulating read error in page %u\n", page_no);
1403 return 1;
1404 }
1405 return 0;
1406}
1407
1408void do_bit_flips(struct nandsim *ns, int num)
1409{
1410 if (bitflips && random32() < (1 << 22)) {
1411 int flips = 1;
1412 if (bitflips > 1)
1413 flips = (random32() % (int) bitflips) + 1;
1414 while (flips--) {
1415 int pos = random32() % (num * 8);
1416 ns->buf.byte[pos / 8] ^= (1 << (pos % 8));
1417 NS_WARN("read_page: flipping bit %d in page %d "
1418 "reading from %d ecc: corrected=%u failed=%u\n",
1419 pos, ns->regs.row, ns->regs.column + ns->regs.off,
1420 nsmtd->ecc_stats.corrected, nsmtd->ecc_stats.failed);
1421 }
1422 }
1423}
1424
1230/* 1425/*
1231 * Fill the NAND buffer with data read from the specified page. 1426 * Fill the NAND buffer with data read from the specified page.
1232 */ 1427 */
@@ -1234,36 +1429,40 @@ static void read_page(struct nandsim *ns, int num)
1234{ 1429{
1235 union ns_mem *mypage; 1430 union ns_mem *mypage;
1236 1431
1432 if (ns->cfile) {
1433 if (!ns->pages_written[ns->regs.row]) {
1434 NS_DBG("read_page: page %d not written\n", ns->regs.row);
1435 memset(ns->buf.byte, 0xFF, num);
1436 } else {
1437 loff_t pos;
1438 ssize_t tx;
1439
1440 NS_DBG("read_page: page %d written, reading from %d\n",
1441 ns->regs.row, ns->regs.column + ns->regs.off);
1442 if (do_read_error(ns, num))
1443 return;
1444 pos = (loff_t)ns->regs.row * ns->geom.pgszoob + ns->regs.column + ns->regs.off;
1445 tx = read_file(ns, ns->cfile, ns->buf.byte, num, &pos);
1446 if (tx != num) {
1447 NS_ERR("read_page: read error for page %d ret %ld\n", ns->regs.row, (long)tx);
1448 return;
1449 }
1450 do_bit_flips(ns, num);
1451 }
1452 return;
1453 }
1454
1237 mypage = NS_GET_PAGE(ns); 1455 mypage = NS_GET_PAGE(ns);
1238 if (mypage->byte == NULL) { 1456 if (mypage->byte == NULL) {
1239 NS_DBG("read_page: page %d not allocated\n", ns->regs.row); 1457 NS_DBG("read_page: page %d not allocated\n", ns->regs.row);
1240 memset(ns->buf.byte, 0xFF, num); 1458 memset(ns->buf.byte, 0xFF, num);
1241 } else { 1459 } else {
1242 unsigned int page_no = ns->regs.row;
1243 NS_DBG("read_page: page %d allocated, reading from %d\n", 1460 NS_DBG("read_page: page %d allocated, reading from %d\n",
1244 ns->regs.row, ns->regs.column + ns->regs.off); 1461 ns->regs.row, ns->regs.column + ns->regs.off);
1245 if (read_error(page_no)) { 1462 if (do_read_error(ns, num))
1246 int i;
1247 memset(ns->buf.byte, 0xFF, num);
1248 for (i = 0; i < num; ++i)
1249 ns->buf.byte[i] = random32();
1250 NS_WARN("simulating read error in page %u\n", page_no);
1251 return; 1463 return;
1252 }
1253 memcpy(ns->buf.byte, NS_PAGE_BYTE_OFF(ns), num); 1464 memcpy(ns->buf.byte, NS_PAGE_BYTE_OFF(ns), num);
1254 if (bitflips && random32() < (1 << 22)) { 1465 do_bit_flips(ns, num);
1255 int flips = 1;
1256 if (bitflips > 1)
1257 flips = (random32() % (int) bitflips) + 1;
1258 while (flips--) {
1259 int pos = random32() % (num * 8);
1260 ns->buf.byte[pos / 8] ^= (1 << (pos % 8));
1261 NS_WARN("read_page: flipping bit %d in page %d "
1262 "reading from %d ecc: corrected=%u failed=%u\n",
1263 pos, ns->regs.row, ns->regs.column + ns->regs.off,
1264 nsmtd->ecc_stats.corrected, nsmtd->ecc_stats.failed);
1265 }
1266 }
1267 } 1466 }
1268} 1467}
1269 1468
@@ -1275,11 +1474,20 @@ static void erase_sector(struct nandsim *ns)
1275 union ns_mem *mypage; 1474 union ns_mem *mypage;
1276 int i; 1475 int i;
1277 1476
1477 if (ns->cfile) {
1478 for (i = 0; i < ns->geom.pgsec; i++)
1479 if (ns->pages_written[ns->regs.row + i]) {
1480 NS_DBG("erase_sector: freeing page %d\n", ns->regs.row + i);
1481 ns->pages_written[ns->regs.row + i] = 0;
1482 }
1483 return;
1484 }
1485
1278 mypage = NS_GET_PAGE(ns); 1486 mypage = NS_GET_PAGE(ns);
1279 for (i = 0; i < ns->geom.pgsec; i++) { 1487 for (i = 0; i < ns->geom.pgsec; i++) {
1280 if (mypage->byte != NULL) { 1488 if (mypage->byte != NULL) {
1281 NS_DBG("erase_sector: freeing page %d\n", ns->regs.row+i); 1489 NS_DBG("erase_sector: freeing page %d\n", ns->regs.row+i);
1282 kfree(mypage->byte); 1490 kmem_cache_free(ns->nand_pages_slab, mypage->byte);
1283 mypage->byte = NULL; 1491 mypage->byte = NULL;
1284 } 1492 }
1285 mypage++; 1493 mypage++;
@@ -1295,16 +1503,57 @@ static int prog_page(struct nandsim *ns, int num)
1295 union ns_mem *mypage; 1503 union ns_mem *mypage;
1296 u_char *pg_off; 1504 u_char *pg_off;
1297 1505
1506 if (ns->cfile) {
1507 loff_t off, pos;
1508 ssize_t tx;
1509 int all;
1510
1511 NS_DBG("prog_page: writing page %d\n", ns->regs.row);
1512 pg_off = ns->file_buf + ns->regs.column + ns->regs.off;
1513 off = (loff_t)ns->regs.row * ns->geom.pgszoob + ns->regs.column + ns->regs.off;
1514 if (!ns->pages_written[ns->regs.row]) {
1515 all = 1;
1516 memset(ns->file_buf, 0xff, ns->geom.pgszoob);
1517 } else {
1518 all = 0;
1519 pos = off;
1520 tx = read_file(ns, ns->cfile, pg_off, num, &pos);
1521 if (tx != num) {
1522 NS_ERR("prog_page: read error for page %d ret %ld\n", ns->regs.row, (long)tx);
1523 return -1;
1524 }
1525 }
1526 for (i = 0; i < num; i++)
1527 pg_off[i] &= ns->buf.byte[i];
1528 if (all) {
1529 pos = (loff_t)ns->regs.row * ns->geom.pgszoob;
1530 tx = write_file(ns, ns->cfile, ns->file_buf, ns->geom.pgszoob, &pos);
1531 if (tx != ns->geom.pgszoob) {
1532 NS_ERR("prog_page: write error for page %d ret %ld\n", ns->regs.row, (long)tx);
1533 return -1;
1534 }
1535 ns->pages_written[ns->regs.row] = 1;
1536 } else {
1537 pos = off;
1538 tx = write_file(ns, ns->cfile, pg_off, num, &pos);
1539 if (tx != num) {
1540 NS_ERR("prog_page: write error for page %d ret %ld\n", ns->regs.row, (long)tx);
1541 return -1;
1542 }
1543 }
1544 return 0;
1545 }
1546
1298 mypage = NS_GET_PAGE(ns); 1547 mypage = NS_GET_PAGE(ns);
1299 if (mypage->byte == NULL) { 1548 if (mypage->byte == NULL) {
1300 NS_DBG("prog_page: allocating page %d\n", ns->regs.row); 1549 NS_DBG("prog_page: allocating page %d\n", ns->regs.row);
1301 /* 1550 /*
1302 * We allocate memory with GFP_NOFS because a flash FS may 1551 * We allocate memory with GFP_NOFS because a flash FS may
1303 * utilize this. If it is holding an FS lock, then gets here, 1552 * utilize this. If it is holding an FS lock, then gets here,
1304 * then kmalloc runs writeback which goes to the FS again 1553 * then kernel memory alloc runs writeback which goes to the FS
1305 * and deadlocks. This was seen in practice. 1554 * again and deadlocks. This was seen in practice.
1306 */ 1555 */
1307 mypage->byte = kmalloc(ns->geom.pgszoob, GFP_NOFS); 1556 mypage->byte = kmem_cache_alloc(ns->nand_pages_slab, GFP_NOFS);
1308 if (mypage->byte == NULL) { 1557 if (mypage->byte == NULL) {
1309 NS_ERR("prog_page: error allocating memory for page %d\n", ns->regs.row); 1558 NS_ERR("prog_page: error allocating memory for page %d\n", ns->regs.row);
1310 return -1; 1559 return -1;
@@ -1736,13 +1985,17 @@ static void ns_nand_write_byte(struct mtd_info *mtd, u_char byte)
1736 1985
1737 /* Check if chip is expecting command */ 1986 /* Check if chip is expecting command */
1738 if (NS_STATE(ns->nxstate) != STATE_UNKNOWN && !(ns->nxstate & STATE_CMD_MASK)) { 1987 if (NS_STATE(ns->nxstate) != STATE_UNKNOWN && !(ns->nxstate & STATE_CMD_MASK)) {
1739 /* 1988 /* Do not warn if only 2 id bytes are read */
1740 * We are in situation when something else (not command) 1989 if (!(ns->regs.command == NAND_CMD_READID &&
1741 * was expected but command was input. In this case ignore 1990 NS_STATE(ns->state) == STATE_DATAOUT_ID && ns->regs.count == 2)) {
1742 * previous command(s)/state(s) and accept the last one. 1991 /*
1743 */ 1992 * We are in situation when something else (not command)
1744 NS_WARN("write_byte: command (%#x) wasn't expected, expected state is %s, " 1993 * was expected but command was input. In this case ignore
1745 "ignore previous states\n", (uint)byte, get_state_name(ns->nxstate)); 1994 * previous command(s)/state(s) and accept the last one.
1995 */
1996 NS_WARN("write_byte: command (%#x) wasn't expected, expected state is %s, "
1997 "ignore previous states\n", (uint)byte, get_state_name(ns->nxstate));
1998 }
1746 switch_to_ready_state(ns, NS_STATUS_FAILED(ns)); 1999 switch_to_ready_state(ns, NS_STATUS_FAILED(ns));
1747 } 2000 }
1748 2001
@@ -2044,7 +2297,7 @@ static int __init ns_init_module(void)
2044 } 2297 }
2045 2298
2046 if (overridesize) { 2299 if (overridesize) {
2047 u_int64_t new_size = (u_int64_t)nsmtd->erasesize << overridesize; 2300 uint64_t new_size = (uint64_t)nsmtd->erasesize << overridesize;
2048 if (new_size >> overridesize != nsmtd->erasesize) { 2301 if (new_size >> overridesize != nsmtd->erasesize) {
2049 NS_ERR("overridesize is too big\n"); 2302 NS_ERR("overridesize is too big\n");
2050 goto err_exit; 2303 goto err_exit;
diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c
index 955959eb02d4..582cf80f555a 100644
--- a/drivers/mtd/nand/ndfc.c
+++ b/drivers/mtd/nand/ndfc.c
@@ -2,12 +2,20 @@
2 * drivers/mtd/ndfc.c 2 * drivers/mtd/ndfc.c
3 * 3 *
4 * Overview: 4 * Overview:
5 * Platform independend driver for NDFC (NanD Flash Controller) 5 * Platform independent driver for NDFC (NanD Flash Controller)
6 * integrated into EP440 cores 6 * integrated into EP440 cores
7 * 7 *
8 * Ported to an OF platform driver by Sean MacLennan
9 *
10 * The NDFC supports multiple chips, but this driver only supports a
11 * single chip since I do not have access to any boards with
12 * multiple chips.
13 *
8 * Author: Thomas Gleixner 14 * Author: Thomas Gleixner
9 * 15 *
10 * Copyright 2006 IBM 16 * Copyright 2006 IBM
17 * Copyright 2008 PIKA Technologies
18 * Sean MacLennan <smaclennan@pikatech.com>
11 * 19 *
12 * This program is free software; you can redistribute it and/or modify it 20 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the 21 * under the terms of the GNU General Public License as published by the
@@ -21,27 +29,20 @@
21#include <linux/mtd/partitions.h> 29#include <linux/mtd/partitions.h>
22#include <linux/mtd/ndfc.h> 30#include <linux/mtd/ndfc.h>
23#include <linux/mtd/mtd.h> 31#include <linux/mtd/mtd.h>
24#include <linux/platform_device.h> 32#include <linux/of_platform.h>
25
26#include <asm/io.h> 33#include <asm/io.h>
27#ifdef CONFIG_40x
28#include <asm/ibm405.h>
29#else
30#include <asm/ibm44x.h>
31#endif
32
33struct ndfc_nand_mtd {
34 struct mtd_info mtd;
35 struct nand_chip chip;
36 struct platform_nand_chip *pl_chip;
37};
38 34
39static struct ndfc_nand_mtd ndfc_mtd[NDFC_MAX_BANKS];
40 35
41struct ndfc_controller { 36struct ndfc_controller {
42 void __iomem *ndfcbase; 37 struct of_device *ofdev;
43 struct nand_hw_control ndfc_control; 38 void __iomem *ndfcbase;
44 atomic_t childs_active; 39 struct mtd_info mtd;
40 struct nand_chip chip;
41 int chip_select;
42 struct nand_hw_control ndfc_control;
43#ifdef CONFIG_MTD_PARTITIONS
44 struct mtd_partition *parts;
45#endif
45}; 46};
46 47
47static struct ndfc_controller ndfc_ctrl; 48static struct ndfc_controller ndfc_ctrl;
@@ -50,17 +51,14 @@ static void ndfc_select_chip(struct mtd_info *mtd, int chip)
50{ 51{
51 uint32_t ccr; 52 uint32_t ccr;
52 struct ndfc_controller *ndfc = &ndfc_ctrl; 53 struct ndfc_controller *ndfc = &ndfc_ctrl;
53 struct nand_chip *nandchip = mtd->priv;
54 struct ndfc_nand_mtd *nandmtd = nandchip->priv;
55 struct platform_nand_chip *pchip = nandmtd->pl_chip;
56 54
57 ccr = __raw_readl(ndfc->ndfcbase + NDFC_CCR); 55 ccr = in_be32(ndfc->ndfcbase + NDFC_CCR);
58 if (chip >= 0) { 56 if (chip >= 0) {
59 ccr &= ~NDFC_CCR_BS_MASK; 57 ccr &= ~NDFC_CCR_BS_MASK;
60 ccr |= NDFC_CCR_BS(chip + pchip->chip_offset); 58 ccr |= NDFC_CCR_BS(chip + ndfc->chip_select);
61 } else 59 } else
62 ccr |= NDFC_CCR_RESET_CE; 60 ccr |= NDFC_CCR_RESET_CE;
63 __raw_writel(ccr, ndfc->ndfcbase + NDFC_CCR); 61 out_be32(ndfc->ndfcbase + NDFC_CCR, ccr);
64} 62}
65 63
66static void ndfc_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl) 64static void ndfc_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
@@ -80,7 +78,7 @@ static int ndfc_ready(struct mtd_info *mtd)
80{ 78{
81 struct ndfc_controller *ndfc = &ndfc_ctrl; 79 struct ndfc_controller *ndfc = &ndfc_ctrl;
82 80
83 return __raw_readl(ndfc->ndfcbase + NDFC_STAT) & NDFC_STAT_IS_READY; 81 return in_be32(ndfc->ndfcbase + NDFC_STAT) & NDFC_STAT_IS_READY;
84} 82}
85 83
86static void ndfc_enable_hwecc(struct mtd_info *mtd, int mode) 84static void ndfc_enable_hwecc(struct mtd_info *mtd, int mode)
@@ -88,9 +86,9 @@ static void ndfc_enable_hwecc(struct mtd_info *mtd, int mode)
88 uint32_t ccr; 86 uint32_t ccr;
89 struct ndfc_controller *ndfc = &ndfc_ctrl; 87 struct ndfc_controller *ndfc = &ndfc_ctrl;
90 88
91 ccr = __raw_readl(ndfc->ndfcbase + NDFC_CCR); 89 ccr = in_be32(ndfc->ndfcbase + NDFC_CCR);
92 ccr |= NDFC_CCR_RESET_ECC; 90 ccr |= NDFC_CCR_RESET_ECC;
93 __raw_writel(ccr, ndfc->ndfcbase + NDFC_CCR); 91 out_be32(ndfc->ndfcbase + NDFC_CCR, ccr);
94 wmb(); 92 wmb();
95} 93}
96 94
@@ -102,9 +100,10 @@ static int ndfc_calculate_ecc(struct mtd_info *mtd,
102 uint8_t *p = (uint8_t *)&ecc; 100 uint8_t *p = (uint8_t *)&ecc;
103 101
104 wmb(); 102 wmb();
105 ecc = __raw_readl(ndfc->ndfcbase + NDFC_ECC); 103 ecc = in_be32(ndfc->ndfcbase + NDFC_ECC);
106 ecc_code[0] = p[1]; 104 /* The NDFC uses Smart Media (SMC) bytes order */
107 ecc_code[1] = p[2]; 105 ecc_code[0] = p[2];
106 ecc_code[1] = p[1];
108 ecc_code[2] = p[3]; 107 ecc_code[2] = p[3];
109 108
110 return 0; 109 return 0;
@@ -123,7 +122,7 @@ static void ndfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
123 uint32_t *p = (uint32_t *) buf; 122 uint32_t *p = (uint32_t *) buf;
124 123
125 for(;len > 0; len -= 4) 124 for(;len > 0; len -= 4)
126 *p++ = __raw_readl(ndfc->ndfcbase + NDFC_DATA); 125 *p++ = in_be32(ndfc->ndfcbase + NDFC_DATA);
127} 126}
128 127
129static void ndfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) 128static void ndfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
@@ -132,7 +131,7 @@ static void ndfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
132 uint32_t *p = (uint32_t *) buf; 131 uint32_t *p = (uint32_t *) buf;
133 132
134 for(;len > 0; len -= 4) 133 for(;len > 0; len -= 4)
135 __raw_writel(*p++, ndfc->ndfcbase + NDFC_DATA); 134 out_be32(ndfc->ndfcbase + NDFC_DATA, *p++);
136} 135}
137 136
138static int ndfc_verify_buf(struct mtd_info *mtd, const uint8_t *buf, int len) 137static int ndfc_verify_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
@@ -141,7 +140,7 @@ static int ndfc_verify_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
141 uint32_t *p = (uint32_t *) buf; 140 uint32_t *p = (uint32_t *) buf;
142 141
143 for(;len > 0; len -= 4) 142 for(;len > 0; len -= 4)
144 if (*p++ != __raw_readl(ndfc->ndfcbase + NDFC_DATA)) 143 if (*p++ != in_be32(ndfc->ndfcbase + NDFC_DATA))
145 return -EFAULT; 144 return -EFAULT;
146 return 0; 145 return 0;
147} 146}
@@ -149,10 +148,19 @@ static int ndfc_verify_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
149/* 148/*
150 * Initialize chip structure 149 * Initialize chip structure
151 */ 150 */
152static void ndfc_chip_init(struct ndfc_nand_mtd *mtd) 151static int ndfc_chip_init(struct ndfc_controller *ndfc,
152 struct device_node *node)
153{ 153{
154 struct ndfc_controller *ndfc = &ndfc_ctrl; 154#ifdef CONFIG_MTD_PARTITIONS
155 struct nand_chip *chip = &mtd->chip; 155#ifdef CONFIG_MTD_CMDLINE_PARTS
156 static const char *part_types[] = { "cmdlinepart", NULL };
157#else
158 static const char *part_types[] = { NULL };
159#endif
160#endif
161 struct device_node *flash_np;
162 struct nand_chip *chip = &ndfc->chip;
163 int ret;
156 164
157 chip->IO_ADDR_R = ndfc->ndfcbase + NDFC_DATA; 165 chip->IO_ADDR_R = ndfc->ndfcbase + NDFC_DATA;
158 chip->IO_ADDR_W = ndfc->ndfcbase + NDFC_DATA; 166 chip->IO_ADDR_W = ndfc->ndfcbase + NDFC_DATA;
@@ -160,8 +168,6 @@ static void ndfc_chip_init(struct ndfc_nand_mtd *mtd)
160 chip->dev_ready = ndfc_ready; 168 chip->dev_ready = ndfc_ready;
161 chip->select_chip = ndfc_select_chip; 169 chip->select_chip = ndfc_select_chip;
162 chip->chip_delay = 50; 170 chip->chip_delay = 50;
163 chip->priv = mtd;
164 chip->options = mtd->pl_chip->options;
165 chip->controller = &ndfc->ndfc_control; 171 chip->controller = &ndfc->ndfc_control;
166 chip->read_buf = ndfc_read_buf; 172 chip->read_buf = ndfc_read_buf;
167 chip->write_buf = ndfc_write_buf; 173 chip->write_buf = ndfc_write_buf;
@@ -172,143 +178,136 @@ static void ndfc_chip_init(struct ndfc_nand_mtd *mtd)
172 chip->ecc.mode = NAND_ECC_HW; 178 chip->ecc.mode = NAND_ECC_HW;
173 chip->ecc.size = 256; 179 chip->ecc.size = 256;
174 chip->ecc.bytes = 3; 180 chip->ecc.bytes = 3;
175 chip->ecclayout = chip->ecc.layout = mtd->pl_chip->ecclayout;
176 mtd->mtd.priv = chip;
177 mtd->mtd.owner = THIS_MODULE;
178}
179
180static int ndfc_chip_probe(struct platform_device *pdev)
181{
182 struct platform_nand_chip *nc = pdev->dev.platform_data;
183 struct ndfc_chip_settings *settings = nc->priv;
184 struct ndfc_controller *ndfc = &ndfc_ctrl;
185 struct ndfc_nand_mtd *nandmtd;
186
187 if (nc->chip_offset >= NDFC_MAX_BANKS || nc->nr_chips > NDFC_MAX_BANKS)
188 return -EINVAL;
189
190 /* Set the bank settings */
191 __raw_writel(settings->bank_settings,
192 ndfc->ndfcbase + NDFC_BCFG0 + (nc->chip_offset << 2));
193 181
194 nandmtd = &ndfc_mtd[pdev->id]; 182 ndfc->mtd.priv = chip;
195 if (nandmtd->pl_chip) 183 ndfc->mtd.owner = THIS_MODULE;
196 return -EBUSY;
197 184
198 nandmtd->pl_chip = nc; 185 flash_np = of_get_next_child(node, NULL);
199 ndfc_chip_init(nandmtd); 186 if (!flash_np)
200
201 /* Scan for chips */
202 if (nand_scan(&nandmtd->mtd, nc->nr_chips)) {
203 nandmtd->pl_chip = NULL;
204 return -ENODEV; 187 return -ENODEV;
188
189 ndfc->mtd.name = kasprintf(GFP_KERNEL, "%s.%s",
190 ndfc->ofdev->dev.bus_id, flash_np->name);
191 if (!ndfc->mtd.name) {
192 ret = -ENOMEM;
193 goto err;
205 } 194 }
206 195
207#ifdef CONFIG_MTD_PARTITIONS 196 ret = nand_scan(&ndfc->mtd, 1);
208 printk("Number of partitions %d\n", nc->nr_partitions); 197 if (ret)
209 if (nc->nr_partitions) { 198 goto err;
210 /* Add the full device, so complete dumps can be made */
211 add_mtd_device(&nandmtd->mtd);
212 add_mtd_partitions(&nandmtd->mtd, nc->partitions,
213 nc->nr_partitions);
214 199
215 } else 200#ifdef CONFIG_MTD_PARTITIONS
216#else 201 ret = parse_mtd_partitions(&ndfc->mtd, part_types, &ndfc->parts, 0);
217 add_mtd_device(&nandmtd->mtd); 202 if (ret < 0)
203 goto err;
204
205#ifdef CONFIG_MTD_OF_PARTS
206 if (ret == 0) {
207 ret = of_mtd_parse_partitions(&ndfc->ofdev->dev, flash_np,
208 &ndfc->parts);
209 if (ret < 0)
210 goto err;
211 }
218#endif 212#endif
219 213
220 atomic_inc(&ndfc->childs_active); 214 if (ret > 0)
221 return 0; 215 ret = add_mtd_partitions(&ndfc->mtd, ndfc->parts, ret);
222} 216 else
217#endif
218 ret = add_mtd_device(&ndfc->mtd);
223 219
224static int ndfc_chip_remove(struct platform_device *pdev) 220err:
225{ 221 of_node_put(flash_np);
226 return 0; 222 if (ret)
223 kfree(ndfc->mtd.name);
224 return ret;
227} 225}
228 226
229static int ndfc_nand_probe(struct platform_device *pdev) 227static int __devinit ndfc_probe(struct of_device *ofdev,
228 const struct of_device_id *match)
230{ 229{
231 struct platform_nand_ctrl *nc = pdev->dev.platform_data;
232 struct ndfc_controller_settings *settings = nc->priv;
233 struct resource *res = pdev->resource;
234 struct ndfc_controller *ndfc = &ndfc_ctrl; 230 struct ndfc_controller *ndfc = &ndfc_ctrl;
235 unsigned long long phys = settings->ndfc_erpn | res->start; 231 const u32 *reg;
232 u32 ccr;
233 int err, len;
236 234
237#ifndef CONFIG_PHYS_64BIT 235 spin_lock_init(&ndfc->ndfc_control.lock);
238 ndfc->ndfcbase = ioremap((phys_addr_t)phys, res->end - res->start + 1); 236 init_waitqueue_head(&ndfc->ndfc_control.wq);
239#else 237 ndfc->ofdev = ofdev;
240 ndfc->ndfcbase = ioremap64(phys, res->end - res->start + 1); 238 dev_set_drvdata(&ofdev->dev, ndfc);
241#endif 239
240 /* Read the reg property to get the chip select */
241 reg = of_get_property(ofdev->node, "reg", &len);
242 if (reg == NULL || len != 12) {
243 dev_err(&ofdev->dev, "unable read reg property (%d)\n", len);
244 return -ENOENT;
245 }
246 ndfc->chip_select = reg[0];
247
248 ndfc->ndfcbase = of_iomap(ofdev->node, 0);
242 if (!ndfc->ndfcbase) { 249 if (!ndfc->ndfcbase) {
243 printk(KERN_ERR "NDFC: ioremap failed\n"); 250 dev_err(&ofdev->dev, "failed to get memory\n");
244 return -EIO; 251 return -EIO;
245 } 252 }
246 253
247 __raw_writel(settings->ccr_settings, ndfc->ndfcbase + NDFC_CCR); 254 ccr = NDFC_CCR_BS(ndfc->chip_select);
248 255
249 spin_lock_init(&ndfc->ndfc_control.lock); 256 /* It is ok if ccr does not exist - just default to 0 */
250 init_waitqueue_head(&ndfc->ndfc_control.wq); 257 reg = of_get_property(ofdev->node, "ccr", NULL);
258 if (reg)
259 ccr |= *reg;
251 260
252 platform_set_drvdata(pdev, ndfc); 261 out_be32(ndfc->ndfcbase + NDFC_CCR, ccr);
253 262
254 printk("NDFC NAND Driver initialized. Chip-Rev: 0x%08x\n", 263 /* Set the bank settings if given */
255 __raw_readl(ndfc->ndfcbase + NDFC_REVID)); 264 reg = of_get_property(ofdev->node, "bank-settings", NULL);
265 if (reg) {
266 int offset = NDFC_BCFG0 + (ndfc->chip_select << 2);
267 out_be32(ndfc->ndfcbase + offset, *reg);
268 }
269
270 err = ndfc_chip_init(ndfc, ofdev->node);
271 if (err) {
272 iounmap(ndfc->ndfcbase);
273 return err;
274 }
256 275
257 return 0; 276 return 0;
258} 277}
259 278
260static int ndfc_nand_remove(struct platform_device *pdev) 279static int __devexit ndfc_remove(struct of_device *ofdev)
261{ 280{
262 struct ndfc_controller *ndfc = platform_get_drvdata(pdev); 281 struct ndfc_controller *ndfc = dev_get_drvdata(&ofdev->dev);
263 282
264 if (atomic_read(&ndfc->childs_active)) 283 nand_release(&ndfc->mtd);
265 return -EBUSY;
266 284
267 if (ndfc) {
268 platform_set_drvdata(pdev, NULL);
269 iounmap(ndfc_ctrl.ndfcbase);
270 ndfc_ctrl.ndfcbase = NULL;
271 }
272 return 0; 285 return 0;
273} 286}
274 287
275/* driver device registration */ 288static const struct of_device_id ndfc_match[] = {
276 289 { .compatible = "ibm,ndfc", },
277static struct platform_driver ndfc_chip_driver = { 290 {}
278 .probe = ndfc_chip_probe,
279 .remove = ndfc_chip_remove,
280 .driver = {
281 .name = "ndfc-chip",
282 .owner = THIS_MODULE,
283 },
284}; 291};
292MODULE_DEVICE_TABLE(of, ndfc_match);
285 293
286static struct platform_driver ndfc_nand_driver = { 294static struct of_platform_driver ndfc_driver = {
287 .probe = ndfc_nand_probe, 295 .driver = {
288 .remove = ndfc_nand_remove, 296 .name = "ndfc",
289 .driver = {
290 .name = "ndfc-nand",
291 .owner = THIS_MODULE,
292 }, 297 },
298 .match_table = ndfc_match,
299 .probe = ndfc_probe,
300 .remove = __devexit_p(ndfc_remove),
293}; 301};
294 302
295static int __init ndfc_nand_init(void) 303static int __init ndfc_nand_init(void)
296{ 304{
297 int ret; 305 return of_register_platform_driver(&ndfc_driver);
298
299 spin_lock_init(&ndfc_ctrl.ndfc_control.lock);
300 init_waitqueue_head(&ndfc_ctrl.ndfc_control.wq);
301
302 ret = platform_driver_register(&ndfc_nand_driver);
303 if (!ret)
304 ret = platform_driver_register(&ndfc_chip_driver);
305 return ret;
306} 306}
307 307
308static void __exit ndfc_nand_exit(void) 308static void __exit ndfc_nand_exit(void)
309{ 309{
310 platform_driver_unregister(&ndfc_chip_driver); 310 of_unregister_platform_driver(&ndfc_driver);
311 platform_driver_unregister(&ndfc_nand_driver);
312} 311}
313 312
314module_init(ndfc_nand_init); 313module_init(ndfc_nand_init);
@@ -316,6 +315,4 @@ module_exit(ndfc_nand_exit);
316 315
317MODULE_LICENSE("GPL"); 316MODULE_LICENSE("GPL");
318MODULE_AUTHOR("Thomas Gleixner <tglx@linutronix.de>"); 317MODULE_AUTHOR("Thomas Gleixner <tglx@linutronix.de>");
319MODULE_DESCRIPTION("Platform driver for NDFC"); 318MODULE_DESCRIPTION("OF Platform driver for NDFC");
320MODULE_ALIAS("platform:ndfc-chip");
321MODULE_ALIAS("platform:ndfc-nand");
diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index fc4144495610..cc55cbc2b308 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -298,7 +298,7 @@ static struct pxa3xx_nand_flash *builtin_flash_types[] = {
298#define NDTR1_tAR(c) (min((c), 15) << 0) 298#define NDTR1_tAR(c) (min((c), 15) << 0)
299 299
300/* convert nano-seconds to nand flash controller clock cycles */ 300/* convert nano-seconds to nand flash controller clock cycles */
301#define ns2cycle(ns, clk) (int)(((ns) * (clk / 1000000) / 1000) + 1) 301#define ns2cycle(ns, clk) (int)(((ns) * (clk / 1000000) / 1000) - 1)
302 302
303static void pxa3xx_nand_set_timing(struct pxa3xx_nand_info *info, 303static void pxa3xx_nand_set_timing(struct pxa3xx_nand_info *info,
304 const struct pxa3xx_nand_timing *t) 304 const struct pxa3xx_nand_timing *t)
@@ -368,14 +368,14 @@ static int prepare_read_prog_cmd(struct pxa3xx_nand_info *info,
368 /* large block, 2 cycles for column address 368 /* large block, 2 cycles for column address
369 * row address starts from 3rd cycle 369 * row address starts from 3rd cycle
370 */ 370 */
371 info->ndcb1 |= (page_addr << 16) | (column & 0xffff); 371 info->ndcb1 |= page_addr << 16;
372 if (info->row_addr_cycles == 3) 372 if (info->row_addr_cycles == 3)
373 info->ndcb2 = (page_addr >> 16) & 0xff; 373 info->ndcb2 = (page_addr >> 16) & 0xff;
374 } else 374 } else
375 /* small block, 1 cycles for column address 375 /* small block, 1 cycles for column address
376 * row address starts from 2nd cycle 376 * row address starts from 2nd cycle
377 */ 377 */
378 info->ndcb1 = (page_addr << 8) | (column & 0xff); 378 info->ndcb1 = page_addr << 8;
379 379
380 if (cmd == cmdset->program) 380 if (cmd == cmdset->program)
381 info->ndcb0 |= NDCB0_CMD_TYPE(1) | NDCB0_AUTO_RS; 381 info->ndcb0 |= NDCB0_CMD_TYPE(1) | NDCB0_AUTO_RS;
diff --git a/drivers/mtd/nand/sharpsl.c b/drivers/mtd/nand/sharpsl.c
index 30a518e211bd..54ec7542a7b7 100644
--- a/drivers/mtd/nand/sharpsl.c
+++ b/drivers/mtd/nand/sharpsl.c
@@ -2,6 +2,7 @@
2 * drivers/mtd/nand/sharpsl.c 2 * drivers/mtd/nand/sharpsl.c
3 * 3 *
4 * Copyright (C) 2004 Richard Purdie 4 * Copyright (C) 2004 Richard Purdie
5 * Copyright (C) 2008 Dmitry Baryshkov
5 * 6 *
6 * Based on Sharp's NAND driver sharp_sl.c 7 * Based on Sharp's NAND driver sharp_sl.c
7 * 8 *
@@ -19,22 +20,31 @@
19#include <linux/mtd/nand.h> 20#include <linux/mtd/nand.h>
20#include <linux/mtd/nand_ecc.h> 21#include <linux/mtd/nand_ecc.h>
21#include <linux/mtd/partitions.h> 22#include <linux/mtd/partitions.h>
23#include <linux/mtd/sharpsl.h>
22#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/platform_device.h>
26
23#include <asm/io.h> 27#include <asm/io.h>
24#include <mach/hardware.h> 28#include <mach/hardware.h>
25#include <asm/mach-types.h> 29#include <asm/mach-types.h>
26 30
27static void __iomem *sharpsl_io_base; 31struct sharpsl_nand {
28static int sharpsl_phys_base = 0x0C000000; 32 struct mtd_info mtd;
33 struct nand_chip chip;
34
35 void __iomem *io;
36};
37
38#define mtd_to_sharpsl(_mtd) container_of(_mtd, struct sharpsl_nand, mtd)
29 39
30/* register offset */ 40/* register offset */
31#define ECCLPLB sharpsl_io_base+0x00 /* line parity 7 - 0 bit */ 41#define ECCLPLB 0x00 /* line parity 7 - 0 bit */
32#define ECCLPUB sharpsl_io_base+0x04 /* line parity 15 - 8 bit */ 42#define ECCLPUB 0x04 /* line parity 15 - 8 bit */
33#define ECCCP sharpsl_io_base+0x08 /* column parity 5 - 0 bit */ 43#define ECCCP 0x08 /* column parity 5 - 0 bit */
34#define ECCCNTR sharpsl_io_base+0x0C /* ECC byte counter */ 44#define ECCCNTR 0x0C /* ECC byte counter */
35#define ECCCLRR sharpsl_io_base+0x10 /* cleare ECC */ 45#define ECCCLRR 0x10 /* cleare ECC */
36#define FLASHIO sharpsl_io_base+0x14 /* Flash I/O */ 46#define FLASHIO 0x14 /* Flash I/O */
37#define FLASHCTL sharpsl_io_base+0x18 /* Flash Control */ 47#define FLASHCTL 0x18 /* Flash Control */
38 48
39/* Flash control bit */ 49/* Flash control bit */
40#define FLRYBY (1 << 5) 50#define FLRYBY (1 << 5)
@@ -45,35 +55,6 @@ static int sharpsl_phys_base = 0x0C000000;
45#define FLCE0 (1 << 0) 55#define FLCE0 (1 << 0)
46 56
47/* 57/*
48 * MTD structure for SharpSL
49 */
50static struct mtd_info *sharpsl_mtd = NULL;
51
52/*
53 * Define partitions for flash device
54 */
55#define DEFAULT_NUM_PARTITIONS 3
56
57static int nr_partitions;
58static struct mtd_partition sharpsl_nand_default_partition_info[] = {
59 {
60 .name = "System Area",
61 .offset = 0,
62 .size = 7 * 1024 * 1024,
63 },
64 {
65 .name = "Root Filesystem",
66 .offset = 7 * 1024 * 1024,
67 .size = 30 * 1024 * 1024,
68 },
69 {
70 .name = "Home Filesystem",
71 .offset = MTDPART_OFS_APPEND,
72 .size = MTDPART_SIZ_FULL,
73 },
74};
75
76/*
77 * hardware specific access to control-lines 58 * hardware specific access to control-lines
78 * ctrl: 59 * ctrl:
79 * NAND_CNE: bit 0 -> ! bit 0 & 4 60 * NAND_CNE: bit 0 -> ! bit 0 & 4
@@ -84,6 +65,7 @@ static struct mtd_partition sharpsl_nand_default_partition_info[] = {
84static void sharpsl_nand_hwcontrol(struct mtd_info *mtd, int cmd, 65static void sharpsl_nand_hwcontrol(struct mtd_info *mtd, int cmd,
85 unsigned int ctrl) 66 unsigned int ctrl)
86{ 67{
68 struct sharpsl_nand *sharpsl = mtd_to_sharpsl(mtd);
87 struct nand_chip *chip = mtd->priv; 69 struct nand_chip *chip = mtd->priv;
88 70
89 if (ctrl & NAND_CTRL_CHANGE) { 71 if (ctrl & NAND_CTRL_CHANGE) {
@@ -93,103 +75,97 @@ static void sharpsl_nand_hwcontrol(struct mtd_info *mtd, int cmd,
93 75
94 bits ^= 0x11; 76 bits ^= 0x11;
95 77
96 writeb((readb(FLASHCTL) & ~0x17) | bits, FLASHCTL); 78 writeb((readb(sharpsl->io + FLASHCTL) & ~0x17) | bits, sharpsl->io + FLASHCTL);
97 } 79 }
98 80
99 if (cmd != NAND_CMD_NONE) 81 if (cmd != NAND_CMD_NONE)
100 writeb(cmd, chip->IO_ADDR_W); 82 writeb(cmd, chip->IO_ADDR_W);
101} 83}
102 84
103static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
104
105static struct nand_bbt_descr sharpsl_bbt = {
106 .options = 0,
107 .offs = 4,
108 .len = 2,
109 .pattern = scan_ff_pattern
110};
111
112static struct nand_bbt_descr sharpsl_akita_bbt = {
113 .options = 0,
114 .offs = 4,
115 .len = 1,
116 .pattern = scan_ff_pattern
117};
118
119static struct nand_ecclayout akita_oobinfo = {
120 .eccbytes = 24,
121 .eccpos = {
122 0x5, 0x1, 0x2, 0x3, 0x6, 0x7, 0x15, 0x11,
123 0x12, 0x13, 0x16, 0x17, 0x25, 0x21, 0x22, 0x23,
124 0x26, 0x27, 0x35, 0x31, 0x32, 0x33, 0x36, 0x37},
125 .oobfree = {{0x08, 0x09}}
126};
127
128static int sharpsl_nand_dev_ready(struct mtd_info *mtd) 85static int sharpsl_nand_dev_ready(struct mtd_info *mtd)
129{ 86{
130 return !((readb(FLASHCTL) & FLRYBY) == 0); 87 struct sharpsl_nand *sharpsl = mtd_to_sharpsl(mtd);
88 return !((readb(sharpsl->io + FLASHCTL) & FLRYBY) == 0);
131} 89}
132 90
133static void sharpsl_nand_enable_hwecc(struct mtd_info *mtd, int mode) 91static void sharpsl_nand_enable_hwecc(struct mtd_info *mtd, int mode)
134{ 92{
135 writeb(0, ECCCLRR); 93 struct sharpsl_nand *sharpsl = mtd_to_sharpsl(mtd);
94 writeb(0, sharpsl->io + ECCCLRR);
136} 95}
137 96
138static int sharpsl_nand_calculate_ecc(struct mtd_info *mtd, const u_char * dat, u_char * ecc_code) 97static int sharpsl_nand_calculate_ecc(struct mtd_info *mtd, const u_char * dat, u_char * ecc_code)
139{ 98{
140 ecc_code[0] = ~readb(ECCLPUB); 99 struct sharpsl_nand *sharpsl = mtd_to_sharpsl(mtd);
141 ecc_code[1] = ~readb(ECCLPLB); 100 ecc_code[0] = ~readb(sharpsl->io + ECCLPUB);
142 ecc_code[2] = (~readb(ECCCP) << 2) | 0x03; 101 ecc_code[1] = ~readb(sharpsl->io + ECCLPLB);
143 return readb(ECCCNTR) != 0; 102 ecc_code[2] = (~readb(sharpsl->io + ECCCP) << 2) | 0x03;
103 return readb(sharpsl->io + ECCCNTR) != 0;
144} 104}
145 105
146#ifdef CONFIG_MTD_PARTITIONS 106#ifdef CONFIG_MTD_PARTITIONS
147const char *part_probes[] = { "cmdlinepart", NULL }; 107static const char *part_probes[] = { "cmdlinepart", NULL };
148#endif 108#endif
149 109
150/* 110/*
151 * Main initialization routine 111 * Main initialization routine
152 */ 112 */
153static int __init sharpsl_nand_init(void) 113static int __devinit sharpsl_nand_probe(struct platform_device *pdev)
154{ 114{
155 struct nand_chip *this; 115 struct nand_chip *this;
116#ifdef CONFIG_MTD_PARTITIONS
156 struct mtd_partition *sharpsl_partition_info; 117 struct mtd_partition *sharpsl_partition_info;
118 int nr_partitions;
119#endif
120 struct resource *r;
157 int err = 0; 121 int err = 0;
122 struct sharpsl_nand *sharpsl;
123 struct sharpsl_nand_platform_data *data = pdev->dev.platform_data;
124
125 if (!data) {
126 dev_err(&pdev->dev, "no platform data!\n");
127 return -EINVAL;
128 }
158 129
159 /* Allocate memory for MTD device structure and private data */ 130 /* Allocate memory for MTD device structure and private data */
160 sharpsl_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); 131 sharpsl = kzalloc(sizeof(struct sharpsl_nand), GFP_KERNEL);
161 if (!sharpsl_mtd) { 132 if (!sharpsl) {
162 printk("Unable to allocate SharpSL NAND MTD device structure.\n"); 133 printk("Unable to allocate SharpSL NAND MTD device structure.\n");
163 return -ENOMEM; 134 return -ENOMEM;
164 } 135 }
165 136
137 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
138 if (!r) {
139 dev_err(&pdev->dev, "no io memory resource defined!\n");
140 err = -ENODEV;
141 goto err_get_res;
142 }
143
166 /* map physical address */ 144 /* map physical address */
167 sharpsl_io_base = ioremap(sharpsl_phys_base, 0x1000); 145 sharpsl->io = ioremap(r->start, resource_size(r));
168 if (!sharpsl_io_base) { 146 if (!sharpsl->io) {
169 printk("ioremap to access Sharp SL NAND chip failed\n"); 147 printk("ioremap to access Sharp SL NAND chip failed\n");
170 kfree(sharpsl_mtd); 148 err = -EIO;
171 return -EIO; 149 goto err_ioremap;
172 } 150 }
173 151
174 /* Get pointer to private data */ 152 /* Get pointer to private data */
175 this = (struct nand_chip *)(&sharpsl_mtd[1]); 153 this = (struct nand_chip *)(&sharpsl->chip);
176
177 /* Initialize structures */
178 memset(sharpsl_mtd, 0, sizeof(struct mtd_info));
179 memset(this, 0, sizeof(struct nand_chip));
180 154
181 /* Link the private data with the MTD structure */ 155 /* Link the private data with the MTD structure */
182 sharpsl_mtd->priv = this; 156 sharpsl->mtd.priv = this;
183 sharpsl_mtd->owner = THIS_MODULE; 157 sharpsl->mtd.owner = THIS_MODULE;
158
159 platform_set_drvdata(pdev, sharpsl);
184 160
185 /* 161 /*
186 * PXA initialize 162 * PXA initialize
187 */ 163 */
188 writeb(readb(FLASHCTL) | FLWP, FLASHCTL); 164 writeb(readb(sharpsl->io + FLASHCTL) | FLWP, sharpsl->io + FLASHCTL);
189 165
190 /* Set address of NAND IO lines */ 166 /* Set address of NAND IO lines */
191 this->IO_ADDR_R = FLASHIO; 167 this->IO_ADDR_R = sharpsl->io + FLASHIO;
192 this->IO_ADDR_W = FLASHIO; 168 this->IO_ADDR_W = sharpsl->io + FLASHIO;
193 /* Set address of hardware control function */ 169 /* Set address of hardware control function */
194 this->cmd_ctrl = sharpsl_nand_hwcontrol; 170 this->cmd_ctrl = sharpsl_nand_hwcontrol;
195 this->dev_ready = sharpsl_nand_dev_ready; 171 this->dev_ready = sharpsl_nand_dev_ready;
@@ -199,68 +175,89 @@ static int __init sharpsl_nand_init(void)
199 this->ecc.mode = NAND_ECC_HW; 175 this->ecc.mode = NAND_ECC_HW;
200 this->ecc.size = 256; 176 this->ecc.size = 256;
201 this->ecc.bytes = 3; 177 this->ecc.bytes = 3;
202 this->badblock_pattern = &sharpsl_bbt; 178 this->badblock_pattern = data->badblock_pattern;
203 if (machine_is_akita() || machine_is_borzoi()) { 179 this->ecc.layout = data->ecc_layout;
204 this->badblock_pattern = &sharpsl_akita_bbt;
205 this->ecc.layout = &akita_oobinfo;
206 }
207 this->ecc.hwctl = sharpsl_nand_enable_hwecc; 180 this->ecc.hwctl = sharpsl_nand_enable_hwecc;
208 this->ecc.calculate = sharpsl_nand_calculate_ecc; 181 this->ecc.calculate = sharpsl_nand_calculate_ecc;
209 this->ecc.correct = nand_correct_data; 182 this->ecc.correct = nand_correct_data;
210 183
211 /* Scan to find existence of the device */ 184 /* Scan to find existence of the device */
212 err = nand_scan(sharpsl_mtd, 1); 185 err = nand_scan(&sharpsl->mtd, 1);
213 if (err) { 186 if (err)
214 iounmap(sharpsl_io_base); 187 goto err_scan;
215 kfree(sharpsl_mtd);
216 return err;
217 }
218 188
219 /* Register the partitions */ 189 /* Register the partitions */
220 sharpsl_mtd->name = "sharpsl-nand"; 190 sharpsl->mtd.name = "sharpsl-nand";
221 nr_partitions = parse_mtd_partitions(sharpsl_mtd, part_probes, &sharpsl_partition_info, 0); 191#ifdef CONFIG_MTD_PARTITIONS
222 192 nr_partitions = parse_mtd_partitions(&sharpsl->mtd, part_probes, &sharpsl_partition_info, 0);
223 if (nr_partitions <= 0) { 193 if (nr_partitions <= 0) {
224 nr_partitions = DEFAULT_NUM_PARTITIONS; 194 nr_partitions = data->nr_partitions;
225 sharpsl_partition_info = sharpsl_nand_default_partition_info; 195 sharpsl_partition_info = data->partitions;
226 if (machine_is_poodle()) {
227 sharpsl_partition_info[1].size = 22 * 1024 * 1024;
228 } else if (machine_is_corgi() || machine_is_shepherd()) {
229 sharpsl_partition_info[1].size = 25 * 1024 * 1024;
230 } else if (machine_is_husky()) {
231 sharpsl_partition_info[1].size = 53 * 1024 * 1024;
232 } else if (machine_is_spitz()) {
233 sharpsl_partition_info[1].size = 5 * 1024 * 1024;
234 } else if (machine_is_akita()) {
235 sharpsl_partition_info[1].size = 58 * 1024 * 1024;
236 } else if (machine_is_borzoi()) {
237 sharpsl_partition_info[1].size = 32 * 1024 * 1024;
238 }
239 } 196 }
240 197
241 add_mtd_partitions(sharpsl_mtd, sharpsl_partition_info, nr_partitions); 198 if (nr_partitions > 0)
199 err = add_mtd_partitions(&sharpsl->mtd, sharpsl_partition_info, nr_partitions);
200 else
201#endif
202 err = add_mtd_device(&sharpsl->mtd);
203 if (err)
204 goto err_add;
242 205
243 /* Return happy */ 206 /* Return happy */
244 return 0; 207 return 0;
245}
246 208
247module_init(sharpsl_nand_init); 209err_add:
210 nand_release(&sharpsl->mtd);
211
212err_scan:
213 platform_set_drvdata(pdev, NULL);
214 iounmap(sharpsl->io);
215err_ioremap:
216err_get_res:
217 kfree(sharpsl);
218 return err;
219}
248 220
249/* 221/*
250 * Clean up routine 222 * Clean up routine
251 */ 223 */
252static void __exit sharpsl_nand_cleanup(void) 224static int __devexit sharpsl_nand_remove(struct platform_device *pdev)
253{ 225{
226 struct sharpsl_nand *sharpsl = platform_get_drvdata(pdev);
227
254 /* Release resources, unregister device */ 228 /* Release resources, unregister device */
255 nand_release(sharpsl_mtd); 229 nand_release(&sharpsl->mtd);
256 230
257 iounmap(sharpsl_io_base); 231 platform_set_drvdata(pdev, NULL);
232
233 iounmap(sharpsl->io);
258 234
259 /* Free the MTD device structure */ 235 /* Free the MTD device structure */
260 kfree(sharpsl_mtd); 236 kfree(sharpsl);
237
238 return 0;
239}
240
241static struct platform_driver sharpsl_nand_driver = {
242 .driver = {
243 .name = "sharpsl-nand",
244 .owner = THIS_MODULE,
245 },
246 .probe = sharpsl_nand_probe,
247 .remove = __devexit_p(sharpsl_nand_remove),
248};
249
250static int __init sharpsl_nand_init(void)
251{
252 return platform_driver_register(&sharpsl_nand_driver);
261} 253}
254module_init(sharpsl_nand_init);
262 255
263module_exit(sharpsl_nand_cleanup); 256static void __exit sharpsl_nand_exit(void)
257{
258 platform_driver_unregister(&sharpsl_nand_driver);
259}
260module_exit(sharpsl_nand_exit);
264 261
265MODULE_LICENSE("GPL"); 262MODULE_LICENSE("GPL");
266MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>"); 263MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
diff --git a/drivers/mtd/nftlcore.c b/drivers/mtd/nftlcore.c
index 320b929abe79..d1c4546513f7 100644
--- a/drivers/mtd/nftlcore.c
+++ b/drivers/mtd/nftlcore.c
@@ -39,7 +39,7 @@ static void nftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
39 struct NFTLrecord *nftl; 39 struct NFTLrecord *nftl;
40 unsigned long temp; 40 unsigned long temp;
41 41
42 if (mtd->type != MTD_NANDFLASH) 42 if (mtd->type != MTD_NANDFLASH || mtd->size > UINT_MAX)
43 return; 43 return;
44 /* OK, this is moderately ugly. But probably safe. Alternatives? */ 44 /* OK, this is moderately ugly. But probably safe. Alternatives? */
45 if (memcmp(mtd->name, "DiskOnChip", 10)) 45 if (memcmp(mtd->name, "DiskOnChip", 10))
diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
index ccc4f209fbb5..8b22b1836e9f 100644
--- a/drivers/mtd/nftlmount.c
+++ b/drivers/mtd/nftlmount.c
@@ -51,7 +51,7 @@ static int find_boot_record(struct NFTLrecord *nftl)
51 the mtd device accordingly. We could even get rid of 51 the mtd device accordingly. We could even get rid of
52 nftl->EraseSize if there were any point in doing so. */ 52 nftl->EraseSize if there were any point in doing so. */
53 nftl->EraseSize = nftl->mbd.mtd->erasesize; 53 nftl->EraseSize = nftl->mbd.mtd->erasesize;
54 nftl->nb_blocks = nftl->mbd.mtd->size / nftl->EraseSize; 54 nftl->nb_blocks = (u32)nftl->mbd.mtd->size / nftl->EraseSize;
55 55
56 nftl->MediaUnit = BLOCK_NIL; 56 nftl->MediaUnit = BLOCK_NIL;
57 nftl->SpareMediaUnit = BLOCK_NIL; 57 nftl->SpareMediaUnit = BLOCK_NIL;
@@ -168,7 +168,7 @@ device is already correct.
168 printk(KERN_NOTICE "WARNING: Support for NFTL with UnitSizeFactor 0x%02x is experimental\n", 168 printk(KERN_NOTICE "WARNING: Support for NFTL with UnitSizeFactor 0x%02x is experimental\n",
169 mh->UnitSizeFactor); 169 mh->UnitSizeFactor);
170 nftl->EraseSize = nftl->mbd.mtd->erasesize << (0xff - mh->UnitSizeFactor); 170 nftl->EraseSize = nftl->mbd.mtd->erasesize << (0xff - mh->UnitSizeFactor);
171 nftl->nb_blocks = nftl->mbd.mtd->size / nftl->EraseSize; 171 nftl->nb_blocks = (u32)nftl->mbd.mtd->size / nftl->EraseSize;
172 } 172 }
173#endif 173#endif
174 nftl->nb_boot_blocks = le16_to_cpu(mh->FirstPhysicalEUN); 174 nftl->nb_boot_blocks = le16_to_cpu(mh->FirstPhysicalEUN);
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index 90ed319f26e6..529af271db17 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -1772,7 +1772,7 @@ static int onenand_erase(struct mtd_info *mtd, struct erase_info *instr)
1772 int len; 1772 int len;
1773 int ret = 0; 1773 int ret = 0;
1774 1774
1775 DEBUG(MTD_DEBUG_LEVEL3, "onenand_erase: start = 0x%08x, len = %i\n", (unsigned int) instr->addr, (unsigned int) instr->len); 1775 DEBUG(MTD_DEBUG_LEVEL3, "onenand_erase: start = 0x%012llx, len = %llu\n", (unsigned long long) instr->addr, (unsigned long long) instr->len);
1776 1776
1777 block_size = (1 << this->erase_shift); 1777 block_size = (1 << this->erase_shift);
1778 1778
@@ -1810,7 +1810,7 @@ static int onenand_erase(struct mtd_info *mtd, struct erase_info *instr)
1810 1810
1811 /* Check if we have a bad block, we do not erase bad blocks */ 1811 /* Check if we have a bad block, we do not erase bad blocks */
1812 if (onenand_block_isbad_nolock(mtd, addr, 0)) { 1812 if (onenand_block_isbad_nolock(mtd, addr, 0)) {
1813 printk (KERN_WARNING "onenand_erase: attempt to erase a bad block at addr 0x%08x\n", (unsigned int) addr); 1813 printk (KERN_WARNING "onenand_erase: attempt to erase a bad block at addr 0x%012llx\n", (unsigned long long) addr);
1814 instr->state = MTD_ERASE_FAILED; 1814 instr->state = MTD_ERASE_FAILED;
1815 goto erase_exit; 1815 goto erase_exit;
1816 } 1816 }
@@ -2029,7 +2029,7 @@ static int onenand_do_lock_cmd(struct mtd_info *mtd, loff_t ofs, size_t len, int
2029 * 2029 *
2030 * Lock one or more blocks 2030 * Lock one or more blocks
2031 */ 2031 */
2032static int onenand_lock(struct mtd_info *mtd, loff_t ofs, size_t len) 2032static int onenand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
2033{ 2033{
2034 int ret; 2034 int ret;
2035 2035
@@ -2047,7 +2047,7 @@ static int onenand_lock(struct mtd_info *mtd, loff_t ofs, size_t len)
2047 * 2047 *
2048 * Unlock one or more blocks 2048 * Unlock one or more blocks
2049 */ 2049 */
2050static int onenand_unlock(struct mtd_info *mtd, loff_t ofs, size_t len) 2050static int onenand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
2051{ 2051{
2052 int ret; 2052 int ret;
2053 2053
diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c
index e538c0a72abb..d2aa9c46530f 100644
--- a/drivers/mtd/rfd_ftl.c
+++ b/drivers/mtd/rfd_ftl.c
@@ -21,8 +21,6 @@
21 21
22#include <asm/types.h> 22#include <asm/types.h>
23 23
24#define const_cpu_to_le16 __constant_cpu_to_le16
25
26static int block_size = 0; 24static int block_size = 0;
27module_param(block_size, int, 0); 25module_param(block_size, int, 0);
28MODULE_PARM_DESC(block_size, "Block size to use by RFD, defaults to erase unit size"); 26MODULE_PARM_DESC(block_size, "Block size to use by RFD, defaults to erase unit size");
@@ -156,7 +154,7 @@ static int scan_header(struct partition *part)
156 size_t retlen; 154 size_t retlen;
157 155
158 sectors_per_block = part->block_size / SECTOR_SIZE; 156 sectors_per_block = part->block_size / SECTOR_SIZE;
159 part->total_blocks = part->mbd.mtd->size / part->block_size; 157 part->total_blocks = (u32)part->mbd.mtd->size / part->block_size;
160 158
161 if (part->total_blocks < 2) 159 if (part->total_blocks < 2)
162 return -ENOENT; 160 return -ENOENT;
@@ -276,16 +274,17 @@ static void erase_callback(struct erase_info *erase)
276 274
277 part = (struct partition*)erase->priv; 275 part = (struct partition*)erase->priv;
278 276
279 i = erase->addr / part->block_size; 277 i = (u32)erase->addr / part->block_size;
280 if (i >= part->total_blocks || part->blocks[i].offset != erase->addr) { 278 if (i >= part->total_blocks || part->blocks[i].offset != erase->addr ||
281 printk(KERN_ERR PREFIX "erase callback for unknown offset %x " 279 erase->addr > UINT_MAX) {
282 "on '%s'\n", erase->addr, part->mbd.mtd->name); 280 printk(KERN_ERR PREFIX "erase callback for unknown offset %llx "
281 "on '%s'\n", (unsigned long long)erase->addr, part->mbd.mtd->name);
283 return; 282 return;
284 } 283 }
285 284
286 if (erase->state != MTD_ERASE_DONE) { 285 if (erase->state != MTD_ERASE_DONE) {
287 printk(KERN_WARNING PREFIX "erase failed at 0x%x on '%s', " 286 printk(KERN_WARNING PREFIX "erase failed at 0x%llx on '%s', "
288 "state %d\n", erase->addr, 287 "state %d\n", (unsigned long long)erase->addr,
289 part->mbd.mtd->name, erase->state); 288 part->mbd.mtd->name, erase->state);
290 289
291 part->blocks[i].state = BLOCK_FAILED; 290 part->blocks[i].state = BLOCK_FAILED;
@@ -297,7 +296,7 @@ static void erase_callback(struct erase_info *erase)
297 return; 296 return;
298 } 297 }
299 298
300 magic = const_cpu_to_le16(RFD_MAGIC); 299 magic = cpu_to_le16(RFD_MAGIC);
301 300
302 part->blocks[i].state = BLOCK_ERASED; 301 part->blocks[i].state = BLOCK_ERASED;
303 part->blocks[i].free_sectors = part->data_sectors_per_block; 302 part->blocks[i].free_sectors = part->data_sectors_per_block;
@@ -345,9 +344,9 @@ static int erase_block(struct partition *part, int block)
345 rc = part->mbd.mtd->erase(part->mbd.mtd, erase); 344 rc = part->mbd.mtd->erase(part->mbd.mtd, erase);
346 345
347 if (rc) { 346 if (rc) {
348 printk(KERN_ERR PREFIX "erase of region %x,%x on '%s' " 347 printk(KERN_ERR PREFIX "erase of region %llx,%llx on '%s' "
349 "failed\n", erase->addr, erase->len, 348 "failed\n", (unsigned long long)erase->addr,
350 part->mbd.mtd->name); 349 (unsigned long long)erase->len, part->mbd.mtd->name);
351 kfree(erase); 350 kfree(erase);
352 } 351 }
353 352
@@ -587,7 +586,7 @@ static int mark_sector_deleted(struct partition *part, u_long old_addr)
587 int block, offset, rc; 586 int block, offset, rc;
588 u_long addr; 587 u_long addr;
589 size_t retlen; 588 size_t retlen;
590 u16 del = const_cpu_to_le16(SECTOR_DELETED); 589 u16 del = cpu_to_le16(SECTOR_DELETED);
591 590
592 block = old_addr / part->block_size; 591 block = old_addr / part->block_size;
593 offset = (old_addr % part->block_size) / SECTOR_SIZE - 592 offset = (old_addr % part->block_size) / SECTOR_SIZE -
@@ -763,7 +762,7 @@ static void rfd_ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
763{ 762{
764 struct partition *part; 763 struct partition *part;
765 764
766 if (mtd->type != MTD_NORFLASH) 765 if (mtd->type != MTD_NORFLASH || mtd->size > UINT_MAX)
767 return; 766 return;
768 767
769 part = kzalloc(sizeof(struct partition), GFP_KERNEL); 768 part = kzalloc(sizeof(struct partition), GFP_KERNEL);
diff --git a/drivers/mtd/ssfdc.c b/drivers/mtd/ssfdc.c
index 33a5d6ed6f18..3f67e00d98e0 100644
--- a/drivers/mtd/ssfdc.c
+++ b/drivers/mtd/ssfdc.c
@@ -294,7 +294,8 @@ static void ssfdcr_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
294 int cis_sector; 294 int cis_sector;
295 295
296 /* Check for small page NAND flash */ 296 /* Check for small page NAND flash */
297 if (mtd->type != MTD_NANDFLASH || mtd->oobsize != OOB_SIZE) 297 if (mtd->type != MTD_NANDFLASH || mtd->oobsize != OOB_SIZE ||
298 mtd->size > UINT_MAX)
298 return; 299 return;
299 300
300 /* Check for SSDFC format by reading CIS/IDI sector */ 301 /* Check for SSDFC format by reading CIS/IDI sector */
@@ -316,7 +317,7 @@ static void ssfdcr_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
316 317
317 ssfdc->cis_block = cis_sector / (mtd->erasesize >> SECTOR_SHIFT); 318 ssfdc->cis_block = cis_sector / (mtd->erasesize >> SECTOR_SHIFT);
318 ssfdc->erase_size = mtd->erasesize; 319 ssfdc->erase_size = mtd->erasesize;
319 ssfdc->map_len = mtd->size / mtd->erasesize; 320 ssfdc->map_len = (u32)mtd->size / mtd->erasesize;
320 321
321 DEBUG(MTD_DEBUG_LEVEL1, 322 DEBUG(MTD_DEBUG_LEVEL1,
322 "SSFDC_RO: cis_block=%d,erase_size=%d,map_len=%d,n_zones=%d\n", 323 "SSFDC_RO: cis_block=%d,erase_size=%d,map_len=%d,n_zones=%d\n",
@@ -327,7 +328,7 @@ static void ssfdcr_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
327 ssfdc->heads = 16; 328 ssfdc->heads = 16;
328 ssfdc->sectors = 32; 329 ssfdc->sectors = 32;
329 get_chs(mtd->size, NULL, &ssfdc->heads, &ssfdc->sectors); 330 get_chs(mtd->size, NULL, &ssfdc->heads, &ssfdc->sectors);
330 ssfdc->cylinders = (unsigned short)((mtd->size >> SECTOR_SHIFT) / 331 ssfdc->cylinders = (unsigned short)(((u32)mtd->size >> SECTOR_SHIFT) /
331 ((long)ssfdc->sectors * (long)ssfdc->heads)); 332 ((long)ssfdc->sectors * (long)ssfdc->heads));
332 333
333 DEBUG(MTD_DEBUG_LEVEL1, "SSFDC_RO: using C:%d H:%d S:%d == %ld sects\n", 334 DEBUG(MTD_DEBUG_LEVEL1, "SSFDC_RO: using C:%d H:%d S:%d == %ld sects\n",
diff --git a/drivers/mtd/tests/Makefile b/drivers/mtd/tests/Makefile
new file mode 100644
index 000000000000..c1d501335006
--- /dev/null
+++ b/drivers/mtd/tests/Makefile
@@ -0,0 +1,7 @@
1obj-$(CONFIG_MTD_TESTS) += mtd_oobtest.o
2obj-$(CONFIG_MTD_TESTS) += mtd_pagetest.o
3obj-$(CONFIG_MTD_TESTS) += mtd_readtest.o
4obj-$(CONFIG_MTD_TESTS) += mtd_speedtest.o
5obj-$(CONFIG_MTD_TESTS) += mtd_stresstest.o
6obj-$(CONFIG_MTD_TESTS) += mtd_subpagetest.o
7obj-$(CONFIG_MTD_TESTS) += mtd_torturetest.o
diff --git a/drivers/mtd/tests/mtd_oobtest.c b/drivers/mtd/tests/mtd_oobtest.c
new file mode 100644
index 000000000000..afbc3f8126db
--- /dev/null
+++ b/drivers/mtd/tests/mtd_oobtest.c
@@ -0,0 +1,742 @@
1/*
2 * Copyright (C) 2006-2008 Nokia Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; see the file COPYING. If not, write to the Free Software
15 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 *
17 * Test OOB read and write on MTD device.
18 *
19 * Author: Adrian Hunter <ext-adrian.hunter@nokia.com>
20 */
21
22#include <asm/div64.h>
23#include <linux/init.h>
24#include <linux/module.h>
25#include <linux/moduleparam.h>
26#include <linux/err.h>
27#include <linux/mtd/mtd.h>
28#include <linux/sched.h>
29
30#define PRINT_PREF KERN_INFO "mtd_oobtest: "
31
32static int dev;
33module_param(dev, int, S_IRUGO);
34MODULE_PARM_DESC(dev, "MTD device number to use");
35
36static struct mtd_info *mtd;
37static unsigned char *readbuf;
38static unsigned char *writebuf;
39static unsigned char *bbt;
40
41static int ebcnt;
42static int pgcnt;
43static int errcnt;
44static int use_offset;
45static int use_len;
46static int use_len_max;
47static int vary_offset;
48static unsigned long next = 1;
49
50static inline unsigned int simple_rand(void)
51{
52 next = next * 1103515245 + 12345;
53 return (unsigned int)((next / 65536) % 32768);
54}
55
56static inline void simple_srand(unsigned long seed)
57{
58 next = seed;
59}
60
61static void set_random_data(unsigned char *buf, size_t len)
62{
63 size_t i;
64
65 for (i = 0; i < len; ++i)
66 buf[i] = simple_rand();
67}
68
69static int erase_eraseblock(int ebnum)
70{
71 int err;
72 struct erase_info ei;
73 loff_t addr = ebnum * mtd->erasesize;
74
75 memset(&ei, 0, sizeof(struct erase_info));
76 ei.mtd = mtd;
77 ei.addr = addr;
78 ei.len = mtd->erasesize;
79
80 err = mtd->erase(mtd, &ei);
81 if (err) {
82 printk(PRINT_PREF "error %d while erasing EB %d\n", err, ebnum);
83 return err;
84 }
85
86 if (ei.state == MTD_ERASE_FAILED) {
87 printk(PRINT_PREF "some erase error occurred at EB %d\n",
88 ebnum);
89 return -EIO;
90 }
91
92 return 0;
93}
94
95static int erase_whole_device(void)
96{
97 int err;
98 unsigned int i;
99
100 printk(PRINT_PREF "erasing whole device\n");
101 for (i = 0; i < ebcnt; ++i) {
102 if (bbt[i])
103 continue;
104 err = erase_eraseblock(i);
105 if (err)
106 return err;
107 cond_resched();
108 }
109 printk(PRINT_PREF "erased %u eraseblocks\n", i);
110 return 0;
111}
112
113static void do_vary_offset(void)
114{
115 use_len -= 1;
116 if (use_len < 1) {
117 use_offset += 1;
118 if (use_offset >= use_len_max)
119 use_offset = 0;
120 use_len = use_len_max - use_offset;
121 }
122}
123
124static int write_eraseblock(int ebnum)
125{
126 int i;
127 struct mtd_oob_ops ops;
128 int err = 0;
129 loff_t addr = ebnum * mtd->erasesize;
130
131 for (i = 0; i < pgcnt; ++i, addr += mtd->writesize) {
132 set_random_data(writebuf, use_len);
133 ops.mode = MTD_OOB_AUTO;
134 ops.len = 0;
135 ops.retlen = 0;
136 ops.ooblen = use_len;
137 ops.oobretlen = 0;
138 ops.ooboffs = use_offset;
139 ops.datbuf = 0;
140 ops.oobbuf = writebuf;
141 err = mtd->write_oob(mtd, addr, &ops);
142 if (err || ops.oobretlen != use_len) {
143 printk(PRINT_PREF "error: writeoob failed at %#llx\n",
144 (long long)addr);
145 printk(PRINT_PREF "error: use_len %d, use_offset %d\n",
146 use_len, use_offset);
147 errcnt += 1;
148 return err ? err : -1;
149 }
150 if (vary_offset)
151 do_vary_offset();
152 }
153
154 return err;
155}
156
157static int write_whole_device(void)
158{
159 int err;
160 unsigned int i;
161
162 printk(PRINT_PREF "writing OOBs of whole device\n");
163 for (i = 0; i < ebcnt; ++i) {
164 if (bbt[i])
165 continue;
166 err = write_eraseblock(i);
167 if (err)
168 return err;
169 if (i % 256 == 0)
170 printk(PRINT_PREF "written up to eraseblock %u\n", i);
171 cond_resched();
172 }
173 printk(PRINT_PREF "written %u eraseblocks\n", i);
174 return 0;
175}
176
177static int verify_eraseblock(int ebnum)
178{
179 int i;
180 struct mtd_oob_ops ops;
181 int err = 0;
182 loff_t addr = ebnum * mtd->erasesize;
183
184 for (i = 0; i < pgcnt; ++i, addr += mtd->writesize) {
185 set_random_data(writebuf, use_len);
186 ops.mode = MTD_OOB_AUTO;
187 ops.len = 0;
188 ops.retlen = 0;
189 ops.ooblen = use_len;
190 ops.oobretlen = 0;
191 ops.ooboffs = use_offset;
192 ops.datbuf = 0;
193 ops.oobbuf = readbuf;
194 err = mtd->read_oob(mtd, addr, &ops);
195 if (err || ops.oobretlen != use_len) {
196 printk(PRINT_PREF "error: readoob failed at %#llx\n",
197 (long long)addr);
198 errcnt += 1;
199 return err ? err : -1;
200 }
201 if (memcmp(readbuf, writebuf, use_len)) {
202 printk(PRINT_PREF "error: verify failed at %#llx\n",
203 (long long)addr);
204 errcnt += 1;
205 if (errcnt > 1000) {
206 printk(PRINT_PREF "error: too many errors\n");
207 return -1;
208 }
209 }
210 if (use_offset != 0 || use_len < mtd->ecclayout->oobavail) {
211 int k;
212
213 ops.mode = MTD_OOB_AUTO;
214 ops.len = 0;
215 ops.retlen = 0;
216 ops.ooblen = mtd->ecclayout->oobavail;
217 ops.oobretlen = 0;
218 ops.ooboffs = 0;
219 ops.datbuf = 0;
220 ops.oobbuf = readbuf;
221 err = mtd->read_oob(mtd, addr, &ops);
222 if (err || ops.oobretlen != mtd->ecclayout->oobavail) {
223 printk(PRINT_PREF "error: readoob failed at "
224 "%#llx\n", (long long)addr);
225 errcnt += 1;
226 return err ? err : -1;
227 }
228 if (memcmp(readbuf + use_offset, writebuf, use_len)) {
229 printk(PRINT_PREF "error: verify failed at "
230 "%#llx\n", (long long)addr);
231 errcnt += 1;
232 if (errcnt > 1000) {
233 printk(PRINT_PREF "error: too many "
234 "errors\n");
235 return -1;
236 }
237 }
238 for (k = 0; k < use_offset; ++k)
239 if (readbuf[k] != 0xff) {
240 printk(PRINT_PREF "error: verify 0xff "
241 "failed at %#llx\n",
242 (long long)addr);
243 errcnt += 1;
244 if (errcnt > 1000) {
245 printk(PRINT_PREF "error: too "
246 "many errors\n");
247 return -1;
248 }
249 }
250 for (k = use_offset + use_len;
251 k < mtd->ecclayout->oobavail; ++k)
252 if (readbuf[k] != 0xff) {
253 printk(PRINT_PREF "error: verify 0xff "
254 "failed at %#llx\n",
255 (long long)addr);
256 errcnt += 1;
257 if (errcnt > 1000) {
258 printk(PRINT_PREF "error: too "
259 "many errors\n");
260 return -1;
261 }
262 }
263 }
264 if (vary_offset)
265 do_vary_offset();
266 }
267 return err;
268}
269
270static int verify_eraseblock_in_one_go(int ebnum)
271{
272 struct mtd_oob_ops ops;
273 int err = 0;
274 loff_t addr = ebnum * mtd->erasesize;
275 size_t len = mtd->ecclayout->oobavail * pgcnt;
276
277 set_random_data(writebuf, len);
278 ops.mode = MTD_OOB_AUTO;
279 ops.len = 0;
280 ops.retlen = 0;
281 ops.ooblen = len;
282 ops.oobretlen = 0;
283 ops.ooboffs = 0;
284 ops.datbuf = 0;
285 ops.oobbuf = readbuf;
286 err = mtd->read_oob(mtd, addr, &ops);
287 if (err || ops.oobretlen != len) {
288 printk(PRINT_PREF "error: readoob failed at %#llx\n",
289 (long long)addr);
290 errcnt += 1;
291 return err ? err : -1;
292 }
293 if (memcmp(readbuf, writebuf, len)) {
294 printk(PRINT_PREF "error: verify failed at %#llx\n",
295 (long long)addr);
296 errcnt += 1;
297 if (errcnt > 1000) {
298 printk(PRINT_PREF "error: too many errors\n");
299 return -1;
300 }
301 }
302
303 return err;
304}
305
306static int verify_all_eraseblocks(void)
307{
308 int err;
309 unsigned int i;
310
311 printk(PRINT_PREF "verifying all eraseblocks\n");
312 for (i = 0; i < ebcnt; ++i) {
313 if (bbt[i])
314 continue;
315 err = verify_eraseblock(i);
316 if (err)
317 return err;
318 if (i % 256 == 0)
319 printk(PRINT_PREF "verified up to eraseblock %u\n", i);
320 cond_resched();
321 }
322 printk(PRINT_PREF "verified %u eraseblocks\n", i);
323 return 0;
324}
325
326static int is_block_bad(int ebnum)
327{
328 int ret;
329 loff_t addr = ebnum * mtd->erasesize;
330
331 ret = mtd->block_isbad(mtd, addr);
332 if (ret)
333 printk(PRINT_PREF "block %d is bad\n", ebnum);
334 return ret;
335}
336
337static int scan_for_bad_eraseblocks(void)
338{
339 int i, bad = 0;
340
341 bbt = kmalloc(ebcnt, GFP_KERNEL);
342 if (!bbt) {
343 printk(PRINT_PREF "error: cannot allocate memory\n");
344 return -ENOMEM;
345 }
346 memset(bbt, 0 , ebcnt);
347
348 printk(PRINT_PREF "scanning for bad eraseblocks\n");
349 for (i = 0; i < ebcnt; ++i) {
350 bbt[i] = is_block_bad(i) ? 1 : 0;
351 if (bbt[i])
352 bad += 1;
353 cond_resched();
354 }
355 printk(PRINT_PREF "scanned %d eraseblocks, %d are bad\n", i, bad);
356 return 0;
357}
358
359static int __init mtd_oobtest_init(void)
360{
361 int err = 0;
362 unsigned int i;
363 uint64_t tmp;
364 struct mtd_oob_ops ops;
365 loff_t addr = 0, addr0;
366
367 printk(KERN_INFO "\n");
368 printk(KERN_INFO "=================================================\n");
369 printk(PRINT_PREF "MTD device: %d\n", dev);
370
371 mtd = get_mtd_device(NULL, dev);
372 if (IS_ERR(mtd)) {
373 err = PTR_ERR(mtd);
374 printk(PRINT_PREF "error: cannot get MTD device\n");
375 return err;
376 }
377
378 if (mtd->type != MTD_NANDFLASH) {
379 printk(PRINT_PREF "this test requires NAND flash\n");
380 goto out;
381 }
382
383 tmp = mtd->size;
384 do_div(tmp, mtd->erasesize);
385 ebcnt = tmp;
386 pgcnt = mtd->erasesize / mtd->writesize;
387
388 printk(PRINT_PREF "MTD device size %llu, eraseblock size %u, "
389 "page size %u, count of eraseblocks %u, pages per "
390 "eraseblock %u, OOB size %u\n",
391 (unsigned long long)mtd->size, mtd->erasesize,
392 mtd->writesize, ebcnt, pgcnt, mtd->oobsize);
393
394 err = -ENOMEM;
395 mtd->erasesize = mtd->erasesize;
396 readbuf = kmalloc(mtd->erasesize, GFP_KERNEL);
397 if (!readbuf) {
398 printk(PRINT_PREF "error: cannot allocate memory\n");
399 goto out;
400 }
401 writebuf = kmalloc(mtd->erasesize, GFP_KERNEL);
402 if (!writebuf) {
403 printk(PRINT_PREF "error: cannot allocate memory\n");
404 goto out;
405 }
406
407 err = scan_for_bad_eraseblocks();
408 if (err)
409 goto out;
410
411 use_offset = 0;
412 use_len = mtd->ecclayout->oobavail;
413 use_len_max = mtd->ecclayout->oobavail;
414 vary_offset = 0;
415
416 /* First test: write all OOB, read it back and verify */
417 printk(PRINT_PREF "test 1 of 5\n");
418
419 err = erase_whole_device();
420 if (err)
421 goto out;
422
423 simple_srand(1);
424 err = write_whole_device();
425 if (err)
426 goto out;
427
428 simple_srand(1);
429 err = verify_all_eraseblocks();
430 if (err)
431 goto out;
432
433 /*
434 * Second test: write all OOB, a block at a time, read it back and
435 * verify.
436 */
437 printk(PRINT_PREF "test 2 of 5\n");
438
439 err = erase_whole_device();
440 if (err)
441 goto out;
442
443 simple_srand(3);
444 err = write_whole_device();
445 if (err)
446 goto out;
447
448 /* Check all eraseblocks */
449 simple_srand(3);
450 printk(PRINT_PREF "verifying all eraseblocks\n");
451 for (i = 0; i < ebcnt; ++i) {
452 if (bbt[i])
453 continue;
454 err = verify_eraseblock_in_one_go(i);
455 if (err)
456 goto out;
457 if (i % 256 == 0)
458 printk(PRINT_PREF "verified up to eraseblock %u\n", i);
459 cond_resched();
460 }
461 printk(PRINT_PREF "verified %u eraseblocks\n", i);
462
463 /*
464 * Third test: write OOB at varying offsets and lengths, read it back
465 * and verify.
466 */
467 printk(PRINT_PREF "test 3 of 5\n");
468
469 err = erase_whole_device();
470 if (err)
471 goto out;
472
473 /* Write all eraseblocks */
474 use_offset = 0;
475 use_len = mtd->ecclayout->oobavail;
476 use_len_max = mtd->ecclayout->oobavail;
477 vary_offset = 1;
478 simple_srand(5);
479 printk(PRINT_PREF "writing OOBs of whole device\n");
480 for (i = 0; i < ebcnt; ++i) {
481 if (bbt[i])
482 continue;
483 err = write_eraseblock(i);
484 if (err)
485 goto out;
486 if (i % 256 == 0)
487 printk(PRINT_PREF "written up to eraseblock %u\n", i);
488 cond_resched();
489 }
490 printk(PRINT_PREF "written %u eraseblocks\n", i);
491
492 /* Check all eraseblocks */
493 use_offset = 0;
494 use_len = mtd->ecclayout->oobavail;
495 use_len_max = mtd->ecclayout->oobavail;
496 vary_offset = 1;
497 simple_srand(5);
498 err = verify_all_eraseblocks();
499 if (err)
500 goto out;
501
502 use_offset = 0;
503 use_len = mtd->ecclayout->oobavail;
504 use_len_max = mtd->ecclayout->oobavail;
505 vary_offset = 0;
506
507 /* Fourth test: try to write off end of device */
508 printk(PRINT_PREF "test 4 of 5\n");
509
510 err = erase_whole_device();
511 if (err)
512 goto out;
513
514 addr0 = 0;
515 for (i = 0; bbt[i] && i < ebcnt; ++i)
516 addr0 += mtd->erasesize;
517
518 /* Attempt to write off end of OOB */
519 ops.mode = MTD_OOB_AUTO;
520 ops.len = 0;
521 ops.retlen = 0;
522 ops.ooblen = 1;
523 ops.oobretlen = 0;
524 ops.ooboffs = mtd->ecclayout->oobavail;
525 ops.datbuf = 0;
526 ops.oobbuf = writebuf;
527 printk(PRINT_PREF "attempting to start write past end of OOB\n");
528 printk(PRINT_PREF "an error is expected...\n");
529 err = mtd->write_oob(mtd, addr0, &ops);
530 if (err) {
531 printk(PRINT_PREF "error occurred as expected\n");
532 err = 0;
533 } else {
534 printk(PRINT_PREF "error: can write past end of OOB\n");
535 errcnt += 1;
536 }
537
538 /* Attempt to read off end of OOB */
539 ops.mode = MTD_OOB_AUTO;
540 ops.len = 0;
541 ops.retlen = 0;
542 ops.ooblen = 1;
543 ops.oobretlen = 0;
544 ops.ooboffs = mtd->ecclayout->oobavail;
545 ops.datbuf = 0;
546 ops.oobbuf = readbuf;
547 printk(PRINT_PREF "attempting to start read past end of OOB\n");
548 printk(PRINT_PREF "an error is expected...\n");
549 err = mtd->read_oob(mtd, addr0, &ops);
550 if (err) {
551 printk(PRINT_PREF "error occurred as expected\n");
552 err = 0;
553 } else {
554 printk(PRINT_PREF "error: can read past end of OOB\n");
555 errcnt += 1;
556 }
557
558 if (bbt[ebcnt - 1])
559 printk(PRINT_PREF "skipping end of device tests because last "
560 "block is bad\n");
561 else {
562 /* Attempt to write off end of device */
563 ops.mode = MTD_OOB_AUTO;
564 ops.len = 0;
565 ops.retlen = 0;
566 ops.ooblen = mtd->ecclayout->oobavail + 1;
567 ops.oobretlen = 0;
568 ops.ooboffs = 0;
569 ops.datbuf = 0;
570 ops.oobbuf = writebuf;
571 printk(PRINT_PREF "attempting to write past end of device\n");
572 printk(PRINT_PREF "an error is expected...\n");
573 err = mtd->write_oob(mtd, mtd->size - mtd->writesize, &ops);
574 if (err) {
575 printk(PRINT_PREF "error occurred as expected\n");
576 err = 0;
577 } else {
578 printk(PRINT_PREF "error: wrote past end of device\n");
579 errcnt += 1;
580 }
581
582 /* Attempt to read off end of device */
583 ops.mode = MTD_OOB_AUTO;
584 ops.len = 0;
585 ops.retlen = 0;
586 ops.ooblen = mtd->ecclayout->oobavail + 1;
587 ops.oobretlen = 0;
588 ops.ooboffs = 0;
589 ops.datbuf = 0;
590 ops.oobbuf = readbuf;
591 printk(PRINT_PREF "attempting to read past end of device\n");
592 printk(PRINT_PREF "an error is expected...\n");
593 err = mtd->read_oob(mtd, mtd->size - mtd->writesize, &ops);
594 if (err) {
595 printk(PRINT_PREF "error occurred as expected\n");
596 err = 0;
597 } else {
598 printk(PRINT_PREF "error: read past end of device\n");
599 errcnt += 1;
600 }
601
602 err = erase_eraseblock(ebcnt - 1);
603 if (err)
604 goto out;
605
606 /* Attempt to write off end of device */
607 ops.mode = MTD_OOB_AUTO;
608 ops.len = 0;
609 ops.retlen = 0;
610 ops.ooblen = mtd->ecclayout->oobavail;
611 ops.oobretlen = 0;
612 ops.ooboffs = 1;
613 ops.datbuf = 0;
614 ops.oobbuf = writebuf;
615 printk(PRINT_PREF "attempting to write past end of device\n");
616 printk(PRINT_PREF "an error is expected...\n");
617 err = mtd->write_oob(mtd, mtd->size - mtd->writesize, &ops);
618 if (err) {
619 printk(PRINT_PREF "error occurred as expected\n");
620 err = 0;
621 } else {
622 printk(PRINT_PREF "error: wrote past end of device\n");
623 errcnt += 1;
624 }
625
626 /* Attempt to read off end of device */
627 ops.mode = MTD_OOB_AUTO;
628 ops.len = 0;
629 ops.retlen = 0;
630 ops.ooblen = mtd->ecclayout->oobavail;
631 ops.oobretlen = 0;
632 ops.ooboffs = 1;
633 ops.datbuf = 0;
634 ops.oobbuf = readbuf;
635 printk(PRINT_PREF "attempting to read past end of device\n");
636 printk(PRINT_PREF "an error is expected...\n");
637 err = mtd->read_oob(mtd, mtd->size - mtd->writesize, &ops);
638 if (err) {
639 printk(PRINT_PREF "error occurred as expected\n");
640 err = 0;
641 } else {
642 printk(PRINT_PREF "error: read past end of device\n");
643 errcnt += 1;
644 }
645 }
646
647 /* Fifth test: write / read across block boundaries */
648 printk(PRINT_PREF "test 5 of 5\n");
649
650 /* Erase all eraseblocks */
651 err = erase_whole_device();
652 if (err)
653 goto out;
654
655 /* Write all eraseblocks */
656 simple_srand(11);
657 printk(PRINT_PREF "writing OOBs of whole device\n");
658 for (i = 0; i < ebcnt - 1; ++i) {
659 int cnt = 2;
660 int pg;
661 size_t sz = mtd->ecclayout->oobavail;
662 if (bbt[i] || bbt[i + 1])
663 continue;
664 addr = (i + 1) * mtd->erasesize - mtd->writesize;
665 for (pg = 0; pg < cnt; ++pg) {
666 set_random_data(writebuf, sz);
667 ops.mode = MTD_OOB_AUTO;
668 ops.len = 0;
669 ops.retlen = 0;
670 ops.ooblen = sz;
671 ops.oobretlen = 0;
672 ops.ooboffs = 0;
673 ops.datbuf = 0;
674 ops.oobbuf = writebuf;
675 err = mtd->write_oob(mtd, addr, &ops);
676 if (err)
677 goto out;
678 if (i % 256 == 0)
679 printk(PRINT_PREF "written up to eraseblock "
680 "%u\n", i);
681 cond_resched();
682 addr += mtd->writesize;
683 }
684 }
685 printk(PRINT_PREF "written %u eraseblocks\n", i);
686
687 /* Check all eraseblocks */
688 simple_srand(11);
689 printk(PRINT_PREF "verifying all eraseblocks\n");
690 for (i = 0; i < ebcnt - 1; ++i) {
691 if (bbt[i] || bbt[i + 1])
692 continue;
693 set_random_data(writebuf, mtd->ecclayout->oobavail * 2);
694 addr = (i + 1) * mtd->erasesize - mtd->writesize;
695 ops.mode = MTD_OOB_AUTO;
696 ops.len = 0;
697 ops.retlen = 0;
698 ops.ooblen = mtd->ecclayout->oobavail * 2;
699 ops.oobretlen = 0;
700 ops.ooboffs = 0;
701 ops.datbuf = 0;
702 ops.oobbuf = readbuf;
703 err = mtd->read_oob(mtd, addr, &ops);
704 if (err)
705 goto out;
706 if (memcmp(readbuf, writebuf, mtd->ecclayout->oobavail * 2)) {
707 printk(PRINT_PREF "error: verify failed at %#llx\n",
708 (long long)addr);
709 errcnt += 1;
710 if (errcnt > 1000) {
711 printk(PRINT_PREF "error: too many errors\n");
712 goto out;
713 }
714 }
715 if (i % 256 == 0)
716 printk(PRINT_PREF "verified up to eraseblock %u\n", i);
717 cond_resched();
718 }
719 printk(PRINT_PREF "verified %u eraseblocks\n", i);
720
721 printk(PRINT_PREF "finished with %d errors\n", errcnt);
722out:
723 kfree(bbt);
724 kfree(writebuf);
725 kfree(readbuf);
726 put_mtd_device(mtd);
727 if (err)
728 printk(PRINT_PREF "error %d occurred\n", err);
729 printk(KERN_INFO "=================================================\n");
730 return err;
731}
732module_init(mtd_oobtest_init);
733
734static void __exit mtd_oobtest_exit(void)
735{
736 return;
737}
738module_exit(mtd_oobtest_exit);
739
740MODULE_DESCRIPTION("Out-of-band test module");
741MODULE_AUTHOR("Adrian Hunter");
742MODULE_LICENSE("GPL");
diff --git a/drivers/mtd/tests/mtd_pagetest.c b/drivers/mtd/tests/mtd_pagetest.c
new file mode 100644
index 000000000000..9648818b9e2c
--- /dev/null
+++ b/drivers/mtd/tests/mtd_pagetest.c
@@ -0,0 +1,632 @@
1/*
2 * Copyright (C) 2006-2008 Nokia Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; see the file COPYING. If not, write to the Free Software
15 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 *
17 * Test page read and write on MTD device.
18 *
19 * Author: Adrian Hunter <ext-adrian.hunter@nokia.com>
20 */
21
22#include <asm/div64.h>
23#include <linux/init.h>
24#include <linux/module.h>
25#include <linux/moduleparam.h>
26#include <linux/err.h>
27#include <linux/mtd/mtd.h>
28#include <linux/sched.h>
29
30#define PRINT_PREF KERN_INFO "mtd_pagetest: "
31
32static int dev;
33module_param(dev, int, S_IRUGO);
34MODULE_PARM_DESC(dev, "MTD device number to use");
35
36static struct mtd_info *mtd;
37static unsigned char *twopages;
38static unsigned char *writebuf;
39static unsigned char *boundary;
40static unsigned char *bbt;
41
42static int pgsize;
43static int bufsize;
44static int ebcnt;
45static int pgcnt;
46static int errcnt;
47static unsigned long next = 1;
48
49static inline unsigned int simple_rand(void)
50{
51 next = next * 1103515245 + 12345;
52 return (unsigned int)((next / 65536) % 32768);
53}
54
55static inline void simple_srand(unsigned long seed)
56{
57 next = seed;
58}
59
60static void set_random_data(unsigned char *buf, size_t len)
61{
62 size_t i;
63
64 for (i = 0; i < len; ++i)
65 buf[i] = simple_rand();
66}
67
68static int erase_eraseblock(int ebnum)
69{
70 int err;
71 struct erase_info ei;
72 loff_t addr = ebnum * mtd->erasesize;
73
74 memset(&ei, 0, sizeof(struct erase_info));
75 ei.mtd = mtd;
76 ei.addr = addr;
77 ei.len = mtd->erasesize;
78
79 err = mtd->erase(mtd, &ei);
80 if (err) {
81 printk(PRINT_PREF "error %d while erasing EB %d\n", err, ebnum);
82 return err;
83 }
84
85 if (ei.state == MTD_ERASE_FAILED) {
86 printk(PRINT_PREF "some erase error occurred at EB %d\n",
87 ebnum);
88 return -EIO;
89 }
90
91 return 0;
92}
93
94static int write_eraseblock(int ebnum)
95{
96 int err = 0;
97 size_t written = 0;
98 loff_t addr = ebnum * mtd->erasesize;
99
100 set_random_data(writebuf, mtd->erasesize);
101 cond_resched();
102 err = mtd->write(mtd, addr, mtd->erasesize, &written, writebuf);
103 if (err || written != mtd->erasesize)
104 printk(PRINT_PREF "error: write failed at %#llx\n",
105 (long long)addr);
106
107 return err;
108}
109
110static int verify_eraseblock(int ebnum)
111{
112 uint32_t j;
113 size_t read = 0;
114 int err = 0, i;
115 loff_t addr0, addrn;
116 loff_t addr = ebnum * mtd->erasesize;
117
118 addr0 = 0;
119 for (i = 0; bbt[i] && i < ebcnt; ++i)
120 addr0 += mtd->erasesize;
121
122 addrn = mtd->size;
123 for (i = 0; bbt[ebcnt - i - 1] && i < ebcnt; ++i)
124 addrn -= mtd->erasesize;
125
126 set_random_data(writebuf, mtd->erasesize);
127 for (j = 0; j < pgcnt - 1; ++j, addr += pgsize) {
128 /* Do a read to set the internal dataRAMs to different data */
129 err = mtd->read(mtd, addr0, bufsize, &read, twopages);
130 if (err == -EUCLEAN)
131 err = 0;
132 if (err || read != bufsize) {
133 printk(PRINT_PREF "error: read failed at %#llx\n",
134 (long long)addr0);
135 return err;
136 }
137 err = mtd->read(mtd, addrn - bufsize, bufsize, &read, twopages);
138 if (err == -EUCLEAN)
139 err = 0;
140 if (err || read != bufsize) {
141 printk(PRINT_PREF "error: read failed at %#llx\n",
142 (long long)(addrn - bufsize));
143 return err;
144 }
145 memset(twopages, 0, bufsize);
146 read = 0;
147 err = mtd->read(mtd, addr, bufsize, &read, twopages);
148 if (err == -EUCLEAN)
149 err = 0;
150 if (err || read != bufsize) {
151 printk(PRINT_PREF "error: read failed at %#llx\n",
152 (long long)addr);
153 break;
154 }
155 if (memcmp(twopages, writebuf + (j * pgsize), bufsize)) {
156 printk(PRINT_PREF "error: verify failed at %#llx\n",
157 (long long)addr);
158 errcnt += 1;
159 }
160 }
161 /* Check boundary between eraseblocks */
162 if (addr <= addrn - pgsize - pgsize && !bbt[ebnum + 1]) {
163 unsigned long oldnext = next;
164 /* Do a read to set the internal dataRAMs to different data */
165 err = mtd->read(mtd, addr0, bufsize, &read, twopages);
166 if (err == -EUCLEAN)
167 err = 0;
168 if (err || read != bufsize) {
169 printk(PRINT_PREF "error: read failed at %#llx\n",
170 (long long)addr0);
171 return err;
172 }
173 err = mtd->read(mtd, addrn - bufsize, bufsize, &read, twopages);
174 if (err == -EUCLEAN)
175 err = 0;
176 if (err || read != bufsize) {
177 printk(PRINT_PREF "error: read failed at %#llx\n",
178 (long long)(addrn - bufsize));
179 return err;
180 }
181 memset(twopages, 0, bufsize);
182 read = 0;
183 err = mtd->read(mtd, addr, bufsize, &read, twopages);
184 if (err == -EUCLEAN)
185 err = 0;
186 if (err || read != bufsize) {
187 printk(PRINT_PREF "error: read failed at %#llx\n",
188 (long long)addr);
189 return err;
190 }
191 memcpy(boundary, writebuf + mtd->erasesize - pgsize, pgsize);
192 set_random_data(boundary + pgsize, pgsize);
193 if (memcmp(twopages, boundary, bufsize)) {
194 printk(PRINT_PREF "error: verify failed at %#llx\n",
195 (long long)addr);
196 errcnt += 1;
197 }
198 next = oldnext;
199 }
200 return err;
201}
202
203static int crosstest(void)
204{
205 size_t read = 0;
206 int err = 0, i;
207 loff_t addr, addr0, addrn;
208 unsigned char *pp1, *pp2, *pp3, *pp4;
209
210 printk(PRINT_PREF "crosstest\n");
211 pp1 = kmalloc(pgsize * 4, GFP_KERNEL);
212 if (!pp1) {
213 printk(PRINT_PREF "error: cannot allocate memory\n");
214 return -ENOMEM;
215 }
216 pp2 = pp1 + pgsize;
217 pp3 = pp2 + pgsize;
218 pp4 = pp3 + pgsize;
219 memset(pp1, 0, pgsize * 4);
220
221 addr0 = 0;
222 for (i = 0; bbt[i] && i < ebcnt; ++i)
223 addr0 += mtd->erasesize;
224
225 addrn = mtd->size;
226 for (i = 0; bbt[ebcnt - i - 1] && i < ebcnt; ++i)
227 addrn -= mtd->erasesize;
228
229 /* Read 2nd-to-last page to pp1 */
230 read = 0;
231 addr = addrn - pgsize - pgsize;
232 err = mtd->read(mtd, addr, pgsize, &read, pp1);
233 if (err == -EUCLEAN)
234 err = 0;
235 if (err || read != pgsize) {
236 printk(PRINT_PREF "error: read failed at %#llx\n",
237 (long long)addr);
238 kfree(pp1);
239 return err;
240 }
241
242 /* Read 3rd-to-last page to pp1 */
243 read = 0;
244 addr = addrn - pgsize - pgsize - pgsize;
245 err = mtd->read(mtd, addr, pgsize, &read, pp1);
246 if (err == -EUCLEAN)
247 err = 0;
248 if (err || read != pgsize) {
249 printk(PRINT_PREF "error: read failed at %#llx\n",
250 (long long)addr);
251 kfree(pp1);
252 return err;
253 }
254
255 /* Read first page to pp2 */
256 read = 0;
257 addr = addr0;
258 printk(PRINT_PREF "reading page at %#llx\n", (long long)addr);
259 err = mtd->read(mtd, addr, pgsize, &read, pp2);
260 if (err == -EUCLEAN)
261 err = 0;
262 if (err || read != pgsize) {
263 printk(PRINT_PREF "error: read failed at %#llx\n",
264 (long long)addr);
265 kfree(pp1);
266 return err;
267 }
268
269 /* Read last page to pp3 */
270 read = 0;
271 addr = addrn - pgsize;
272 printk(PRINT_PREF "reading page at %#llx\n", (long long)addr);
273 err = mtd->read(mtd, addr, pgsize, &read, pp3);
274 if (err == -EUCLEAN)
275 err = 0;
276 if (err || read != pgsize) {
277 printk(PRINT_PREF "error: read failed at %#llx\n",
278 (long long)addr);
279 kfree(pp1);
280 return err;
281 }
282
283 /* Read first page again to pp4 */
284 read = 0;
285 addr = addr0;
286 printk(PRINT_PREF "reading page at %#llx\n", (long long)addr);
287 err = mtd->read(mtd, addr, pgsize, &read, pp4);
288 if (err == -EUCLEAN)
289 err = 0;
290 if (err || read != pgsize) {
291 printk(PRINT_PREF "error: read failed at %#llx\n",
292 (long long)addr);
293 kfree(pp1);
294 return err;
295 }
296
297 /* pp2 and pp4 should be the same */
298 printk(PRINT_PREF "verifying pages read at %#llx match\n",
299 (long long)addr0);
300 if (memcmp(pp2, pp4, pgsize)) {
301 printk(PRINT_PREF "verify failed!\n");
302 errcnt += 1;
303 } else if (!err)
304 printk(PRINT_PREF "crosstest ok\n");
305 kfree(pp1);
306 return err;
307}
308
309static int erasecrosstest(void)
310{
311 size_t read = 0, written = 0;
312 int err = 0, i, ebnum, ok = 1, ebnum2;
313 loff_t addr0;
314 char *readbuf = twopages;
315
316 printk(PRINT_PREF "erasecrosstest\n");
317
318 ebnum = 0;
319 addr0 = 0;
320 for (i = 0; bbt[i] && i < ebcnt; ++i) {
321 addr0 += mtd->erasesize;
322 ebnum += 1;
323 }
324
325 ebnum2 = ebcnt - 1;
326 while (ebnum2 && bbt[ebnum2])
327 ebnum2 -= 1;
328
329 printk(PRINT_PREF "erasing block %d\n", ebnum);
330 err = erase_eraseblock(ebnum);
331 if (err)
332 return err;
333
334 printk(PRINT_PREF "writing 1st page of block %d\n", ebnum);
335 set_random_data(writebuf, pgsize);
336 strcpy(writebuf, "There is no data like this!");
337 err = mtd->write(mtd, addr0, pgsize, &written, writebuf);
338 if (err || written != pgsize) {
339 printk(PRINT_PREF "error: write failed at %#llx\n",
340 (long long)addr0);
341 return err ? err : -1;
342 }
343
344 printk(PRINT_PREF "reading 1st page of block %d\n", ebnum);
345 memset(readbuf, 0, pgsize);
346 err = mtd->read(mtd, addr0, pgsize, &read, readbuf);
347 if (err == -EUCLEAN)
348 err = 0;
349 if (err || read != pgsize) {
350 printk(PRINT_PREF "error: read failed at %#llx\n",
351 (long long)addr0);
352 return err ? err : -1;
353 }
354
355 printk(PRINT_PREF "verifying 1st page of block %d\n", ebnum);
356 if (memcmp(writebuf, readbuf, pgsize)) {
357 printk(PRINT_PREF "verify failed!\n");
358 errcnt += 1;
359 ok = 0;
360 return err;
361 }
362
363 printk(PRINT_PREF "erasing block %d\n", ebnum);
364 err = erase_eraseblock(ebnum);
365 if (err)
366 return err;
367
368 printk(PRINT_PREF "writing 1st page of block %d\n", ebnum);
369 set_random_data(writebuf, pgsize);
370 strcpy(writebuf, "There is no data like this!");
371 err = mtd->write(mtd, addr0, pgsize, &written, writebuf);
372 if (err || written != pgsize) {
373 printk(PRINT_PREF "error: write failed at %#llx\n",
374 (long long)addr0);
375 return err ? err : -1;
376 }
377
378 printk(PRINT_PREF "erasing block %d\n", ebnum2);
379 err = erase_eraseblock(ebnum2);
380 if (err)
381 return err;
382
383 printk(PRINT_PREF "reading 1st page of block %d\n", ebnum);
384 memset(readbuf, 0, pgsize);
385 err = mtd->read(mtd, addr0, pgsize, &read, readbuf);
386 if (err == -EUCLEAN)
387 err = 0;
388 if (err || read != pgsize) {
389 printk(PRINT_PREF "error: read failed at %#llx\n",
390 (long long)addr0);
391 return err ? err : -1;
392 }
393
394 printk(PRINT_PREF "verifying 1st page of block %d\n", ebnum);
395 if (memcmp(writebuf, readbuf, pgsize)) {
396 printk(PRINT_PREF "verify failed!\n");
397 errcnt += 1;
398 ok = 0;
399 }
400
401 if (ok && !err)
402 printk(PRINT_PREF "erasecrosstest ok\n");
403 return err;
404}
405
406static int erasetest(void)
407{
408 size_t read = 0, written = 0;
409 int err = 0, i, ebnum, ok = 1;
410 loff_t addr0;
411
412 printk(PRINT_PREF "erasetest\n");
413
414 ebnum = 0;
415 addr0 = 0;
416 for (i = 0; bbt[i] && i < ebcnt; ++i) {
417 addr0 += mtd->erasesize;
418 ebnum += 1;
419 }
420
421 printk(PRINT_PREF "erasing block %d\n", ebnum);
422 err = erase_eraseblock(ebnum);
423 if (err)
424 return err;
425
426 printk(PRINT_PREF "writing 1st page of block %d\n", ebnum);
427 set_random_data(writebuf, pgsize);
428 err = mtd->write(mtd, addr0, pgsize, &written, writebuf);
429 if (err || written != pgsize) {
430 printk(PRINT_PREF "error: write failed at %#llx\n",
431 (long long)addr0);
432 return err ? err : -1;
433 }
434
435 printk(PRINT_PREF "erasing block %d\n", ebnum);
436 err = erase_eraseblock(ebnum);
437 if (err)
438 return err;
439
440 printk(PRINT_PREF "reading 1st page of block %d\n", ebnum);
441 err = mtd->read(mtd, addr0, pgsize, &read, twopages);
442 if (err == -EUCLEAN)
443 err = 0;
444 if (err || read != pgsize) {
445 printk(PRINT_PREF "error: read failed at %#llx\n",
446 (long long)addr0);
447 return err ? err : -1;
448 }
449
450 printk(PRINT_PREF "verifying 1st page of block %d is all 0xff\n",
451 ebnum);
452 for (i = 0; i < pgsize; ++i)
453 if (twopages[i] != 0xff) {
454 printk(PRINT_PREF "verifying all 0xff failed at %d\n",
455 i);
456 errcnt += 1;
457 ok = 0;
458 break;
459 }
460
461 if (ok && !err)
462 printk(PRINT_PREF "erasetest ok\n");
463
464 return err;
465}
466
467static int is_block_bad(int ebnum)
468{
469 loff_t addr = ebnum * mtd->erasesize;
470 int ret;
471
472 ret = mtd->block_isbad(mtd, addr);
473 if (ret)
474 printk(PRINT_PREF "block %d is bad\n", ebnum);
475 return ret;
476}
477
478static int scan_for_bad_eraseblocks(void)
479{
480 int i, bad = 0;
481
482 bbt = kmalloc(ebcnt, GFP_KERNEL);
483 if (!bbt) {
484 printk(PRINT_PREF "error: cannot allocate memory\n");
485 return -ENOMEM;
486 }
487 memset(bbt, 0 , ebcnt);
488
489 printk(PRINT_PREF "scanning for bad eraseblocks\n");
490 for (i = 0; i < ebcnt; ++i) {
491 bbt[i] = is_block_bad(i) ? 1 : 0;
492 if (bbt[i])
493 bad += 1;
494 cond_resched();
495 }
496 printk(PRINT_PREF "scanned %d eraseblocks, %d are bad\n", i, bad);
497 return 0;
498}
499
500static int __init mtd_pagetest_init(void)
501{
502 int err = 0;
503 uint64_t tmp;
504 uint32_t i;
505
506 printk(KERN_INFO "\n");
507 printk(KERN_INFO "=================================================\n");
508 printk(PRINT_PREF "MTD device: %d\n", dev);
509
510 mtd = get_mtd_device(NULL, dev);
511 if (IS_ERR(mtd)) {
512 err = PTR_ERR(mtd);
513 printk(PRINT_PREF "error: cannot get MTD device\n");
514 return err;
515 }
516
517 if (mtd->type != MTD_NANDFLASH) {
518 printk(PRINT_PREF "this test requires NAND flash\n");
519 goto out;
520 }
521
522 tmp = mtd->size;
523 do_div(tmp, mtd->erasesize);
524 ebcnt = tmp;
525 pgcnt = mtd->erasesize / mtd->writesize;
526
527 printk(PRINT_PREF "MTD device size %llu, eraseblock size %u, "
528 "page size %u, count of eraseblocks %u, pages per "
529 "eraseblock %u, OOB size %u\n",
530 (unsigned long long)mtd->size, mtd->erasesize,
531 pgsize, ebcnt, pgcnt, mtd->oobsize);
532
533 err = -ENOMEM;
534 bufsize = pgsize * 2;
535 writebuf = kmalloc(mtd->erasesize, GFP_KERNEL);
536 if (!writebuf) {
537 printk(PRINT_PREF "error: cannot allocate memory\n");
538 goto out;
539 }
540 twopages = kmalloc(bufsize, GFP_KERNEL);
541 if (!twopages) {
542 printk(PRINT_PREF "error: cannot allocate memory\n");
543 goto out;
544 }
545 boundary = kmalloc(bufsize, GFP_KERNEL);
546 if (!boundary) {
547 printk(PRINT_PREF "error: cannot allocate memory\n");
548 goto out;
549 }
550
551 err = scan_for_bad_eraseblocks();
552 if (err)
553 goto out;
554
555 /* Erase all eraseblocks */
556 printk(PRINT_PREF "erasing whole device\n");
557 for (i = 0; i < ebcnt; ++i) {
558 if (bbt[i])
559 continue;
560 err = erase_eraseblock(i);
561 if (err)
562 goto out;
563 cond_resched();
564 }
565 printk(PRINT_PREF "erased %u eraseblocks\n", i);
566
567 /* Write all eraseblocks */
568 simple_srand(1);
569 printk(PRINT_PREF "writing whole device\n");
570 for (i = 0; i < ebcnt; ++i) {
571 if (bbt[i])
572 continue;
573 err = write_eraseblock(i);
574 if (err)
575 goto out;
576 if (i % 256 == 0)
577 printk(PRINT_PREF "written up to eraseblock %u\n", i);
578 cond_resched();
579 }
580 printk(PRINT_PREF "written %u eraseblocks\n", i);
581
582 /* Check all eraseblocks */
583 simple_srand(1);
584 printk(PRINT_PREF "verifying all eraseblocks\n");
585 for (i = 0; i < ebcnt; ++i) {
586 if (bbt[i])
587 continue;
588 err = verify_eraseblock(i);
589 if (err)
590 goto out;
591 if (i % 256 == 0)
592 printk(PRINT_PREF "verified up to eraseblock %u\n", i);
593 cond_resched();
594 }
595 printk(PRINT_PREF "verified %u eraseblocks\n", i);
596
597 err = crosstest();
598 if (err)
599 goto out;
600
601 err = erasecrosstest();
602 if (err)
603 goto out;
604
605 err = erasetest();
606 if (err)
607 goto out;
608
609 printk(PRINT_PREF "finished with %d errors\n", errcnt);
610out:
611
612 kfree(bbt);
613 kfree(boundary);
614 kfree(twopages);
615 kfree(writebuf);
616 put_mtd_device(mtd);
617 if (err)
618 printk(PRINT_PREF "error %d occurred\n", err);
619 printk(KERN_INFO "=================================================\n");
620 return err;
621}
622module_init(mtd_pagetest_init);
623
624static void __exit mtd_pagetest_exit(void)
625{
626 return;
627}
628module_exit(mtd_pagetest_exit);
629
630MODULE_DESCRIPTION("NAND page test");
631MODULE_AUTHOR("Adrian Hunter");
632MODULE_LICENSE("GPL");
diff --git a/drivers/mtd/tests/mtd_readtest.c b/drivers/mtd/tests/mtd_readtest.c
new file mode 100644
index 000000000000..645e77fdc63d
--- /dev/null
+++ b/drivers/mtd/tests/mtd_readtest.c
@@ -0,0 +1,253 @@
1/*
2 * Copyright (C) 2006-2008 Nokia Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; see the file COPYING. If not, write to the Free Software
15 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 *
17 * Check MTD device read.
18 *
19 * Author: Adrian Hunter <ext-adrian.hunter@nokia.com>
20 */
21
22#include <linux/init.h>
23#include <linux/module.h>
24#include <linux/moduleparam.h>
25#include <linux/err.h>
26#include <linux/mtd/mtd.h>
27#include <linux/sched.h>
28
29#define PRINT_PREF KERN_INFO "mtd_readtest: "
30
31static int dev;
32module_param(dev, int, S_IRUGO);
33MODULE_PARM_DESC(dev, "MTD device number to use");
34
35static struct mtd_info *mtd;
36static unsigned char *iobuf;
37static unsigned char *iobuf1;
38static unsigned char *bbt;
39
40static int pgsize;
41static int ebcnt;
42static int pgcnt;
43
44static int read_eraseblock_by_page(int ebnum)
45{
46 size_t read = 0;
47 int i, ret, err = 0;
48 loff_t addr = ebnum * mtd->erasesize;
49 void *buf = iobuf;
50 void *oobbuf = iobuf1;
51
52 for (i = 0; i < pgcnt; i++) {
53 memset(buf, 0 , pgcnt);
54 ret = mtd->read(mtd, addr, pgsize, &read, buf);
55 if (ret == -EUCLEAN)
56 ret = 0;
57 if (ret || read != pgsize) {
58 printk(PRINT_PREF "error: read failed at %#llx\n",
59 (long long)addr);
60 if (!err)
61 err = ret;
62 if (!err)
63 err = -EINVAL;
64 }
65 if (mtd->oobsize) {
66 struct mtd_oob_ops ops;
67
68 ops.mode = MTD_OOB_PLACE;
69 ops.len = 0;
70 ops.retlen = 0;
71 ops.ooblen = mtd->oobsize;
72 ops.oobretlen = 0;
73 ops.ooboffs = 0;
74 ops.datbuf = 0;
75 ops.oobbuf = oobbuf;
76 ret = mtd->read_oob(mtd, addr, &ops);
77 if (ret || ops.oobretlen != mtd->oobsize) {
78 printk(PRINT_PREF "error: read oob failed at "
79 "%#llx\n", (long long)addr);
80 if (!err)
81 err = ret;
82 if (!err)
83 err = -EINVAL;
84 }
85 oobbuf += mtd->oobsize;
86 }
87 addr += pgsize;
88 buf += pgsize;
89 }
90
91 return err;
92}
93
94static void dump_eraseblock(int ebnum)
95{
96 int i, j, n;
97 char line[128];
98 int pg, oob;
99
100 printk(PRINT_PREF "dumping eraseblock %d\n", ebnum);
101 n = mtd->erasesize;
102 for (i = 0; i < n;) {
103 char *p = line;
104
105 p += sprintf(p, "%05x: ", i);
106 for (j = 0; j < 32 && i < n; j++, i++)
107 p += sprintf(p, "%02x", (unsigned int)iobuf[i]);
108 printk(KERN_CRIT "%s\n", line);
109 cond_resched();
110 }
111 if (!mtd->oobsize)
112 return;
113 printk(PRINT_PREF "dumping oob from eraseblock %d\n", ebnum);
114 n = mtd->oobsize;
115 for (pg = 0, i = 0; pg < pgcnt; pg++)
116 for (oob = 0; oob < n;) {
117 char *p = line;
118
119 p += sprintf(p, "%05x: ", i);
120 for (j = 0; j < 32 && oob < n; j++, oob++, i++)
121 p += sprintf(p, "%02x",
122 (unsigned int)iobuf1[i]);
123 printk(KERN_CRIT "%s\n", line);
124 cond_resched();
125 }
126}
127
128static int is_block_bad(int ebnum)
129{
130 loff_t addr = ebnum * mtd->erasesize;
131 int ret;
132
133 ret = mtd->block_isbad(mtd, addr);
134 if (ret)
135 printk(PRINT_PREF "block %d is bad\n", ebnum);
136 return ret;
137}
138
139static int scan_for_bad_eraseblocks(void)
140{
141 int i, bad = 0;
142
143 bbt = kmalloc(ebcnt, GFP_KERNEL);
144 if (!bbt) {
145 printk(PRINT_PREF "error: cannot allocate memory\n");
146 return -ENOMEM;
147 }
148 memset(bbt, 0 , ebcnt);
149
150 printk(PRINT_PREF "scanning for bad eraseblocks\n");
151 for (i = 0; i < ebcnt; ++i) {
152 bbt[i] = is_block_bad(i) ? 1 : 0;
153 if (bbt[i])
154 bad += 1;
155 cond_resched();
156 }
157 printk(PRINT_PREF "scanned %d eraseblocks, %d are bad\n", i, bad);
158 return 0;
159}
160
161static int __init mtd_readtest_init(void)
162{
163 uint64_t tmp;
164 int err, i;
165
166 printk(KERN_INFO "\n");
167 printk(KERN_INFO "=================================================\n");
168 printk(PRINT_PREF "MTD device: %d\n", dev);
169
170 mtd = get_mtd_device(NULL, dev);
171 if (IS_ERR(mtd)) {
172 err = PTR_ERR(mtd);
173 printk(PRINT_PREF "error: Cannot get MTD device\n");
174 return err;
175 }
176
177 if (mtd->writesize == 1) {
178 printk(PRINT_PREF "not NAND flash, assume page size is 512 "
179 "bytes.\n");
180 pgsize = 512;
181 } else
182 pgsize = mtd->writesize;
183
184 tmp = mtd->size;
185 do_div(tmp, mtd->erasesize);
186 ebcnt = tmp;
187 pgcnt = mtd->erasesize / mtd->writesize;
188
189 printk(PRINT_PREF "MTD device size %llu, eraseblock size %u, "
190 "page size %u, count of eraseblocks %u, pages per "
191 "eraseblock %u, OOB size %u\n",
192 (unsigned long long)mtd->size, mtd->erasesize,
193 pgsize, ebcnt, pgcnt, mtd->oobsize);
194
195 err = -ENOMEM;
196 iobuf = kmalloc(mtd->erasesize, GFP_KERNEL);
197 if (!iobuf) {
198 printk(PRINT_PREF "error: cannot allocate memory\n");
199 goto out;
200 }
201 iobuf1 = kmalloc(mtd->erasesize, GFP_KERNEL);
202 if (!iobuf1) {
203 printk(PRINT_PREF "error: cannot allocate memory\n");
204 goto out;
205 }
206
207 err = scan_for_bad_eraseblocks();
208 if (err)
209 goto out;
210
211 /* Read all eraseblocks 1 page at a time */
212 printk(PRINT_PREF "testing page read\n");
213 for (i = 0; i < ebcnt; ++i) {
214 int ret;
215
216 if (bbt[i])
217 continue;
218 ret = read_eraseblock_by_page(i);
219 if (ret) {
220 dump_eraseblock(i);
221 if (!err)
222 err = ret;
223 }
224 cond_resched();
225 }
226
227 if (err)
228 printk(PRINT_PREF "finished with errors\n");
229 else
230 printk(PRINT_PREF "finished\n");
231
232out:
233
234 kfree(iobuf);
235 kfree(iobuf1);
236 kfree(bbt);
237 put_mtd_device(mtd);
238 if (err)
239 printk(PRINT_PREF "error %d occurred\n", err);
240 printk(KERN_INFO "=================================================\n");
241 return err;
242}
243module_init(mtd_readtest_init);
244
245static void __exit mtd_readtest_exit(void)
246{
247 return;
248}
249module_exit(mtd_readtest_exit);
250
251MODULE_DESCRIPTION("Read test module");
252MODULE_AUTHOR("Adrian Hunter");
253MODULE_LICENSE("GPL");
diff --git a/drivers/mtd/tests/mtd_speedtest.c b/drivers/mtd/tests/mtd_speedtest.c
new file mode 100644
index 000000000000..141363a7e805
--- /dev/null
+++ b/drivers/mtd/tests/mtd_speedtest.c
@@ -0,0 +1,502 @@
1/*
2 * Copyright (C) 2007 Nokia Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; see the file COPYING. If not, write to the Free Software
15 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 *
17 * Test read and write speed of a MTD device.
18 *
19 * Author: Adrian Hunter <ext-adrian.hunter@nokia.com>
20 */
21
22#include <linux/init.h>
23#include <linux/module.h>
24#include <linux/moduleparam.h>
25#include <linux/err.h>
26#include <linux/mtd/mtd.h>
27#include <linux/sched.h>
28
29#define PRINT_PREF KERN_INFO "mtd_speedtest: "
30
31static int dev;
32module_param(dev, int, S_IRUGO);
33MODULE_PARM_DESC(dev, "MTD device number to use");
34
35static struct mtd_info *mtd;
36static unsigned char *iobuf;
37static unsigned char *bbt;
38
39static int pgsize;
40static int ebcnt;
41static int pgcnt;
42static int goodebcnt;
43static struct timeval start, finish;
44static unsigned long next = 1;
45
46static inline unsigned int simple_rand(void)
47{
48 next = next * 1103515245 + 12345;
49 return (unsigned int)((next / 65536) % 32768);
50}
51
52static inline void simple_srand(unsigned long seed)
53{
54 next = seed;
55}
56
57static void set_random_data(unsigned char *buf, size_t len)
58{
59 size_t i;
60
61 for (i = 0; i < len; ++i)
62 buf[i] = simple_rand();
63}
64
65static int erase_eraseblock(int ebnum)
66{
67 int err;
68 struct erase_info ei;
69 loff_t addr = ebnum * mtd->erasesize;
70
71 memset(&ei, 0, sizeof(struct erase_info));
72 ei.mtd = mtd;
73 ei.addr = addr;
74 ei.len = mtd->erasesize;
75
76 err = mtd->erase(mtd, &ei);
77 if (err) {
78 printk(PRINT_PREF "error %d while erasing EB %d\n", err, ebnum);
79 return err;
80 }
81
82 if (ei.state == MTD_ERASE_FAILED) {
83 printk(PRINT_PREF "some erase error occurred at EB %d\n",
84 ebnum);
85 return -EIO;
86 }
87
88 return 0;
89}
90
91static int erase_whole_device(void)
92{
93 int err;
94 unsigned int i;
95
96 for (i = 0; i < ebcnt; ++i) {
97 if (bbt[i])
98 continue;
99 err = erase_eraseblock(i);
100 if (err)
101 return err;
102 cond_resched();
103 }
104 return 0;
105}
106
107static int write_eraseblock(int ebnum)
108{
109 size_t written = 0;
110 int err = 0;
111 loff_t addr = ebnum * mtd->erasesize;
112
113 err = mtd->write(mtd, addr, mtd->erasesize, &written, iobuf);
114 if (err || written != mtd->erasesize) {
115 printk(PRINT_PREF "error: write failed at %#llx\n", addr);
116 if (!err)
117 err = -EINVAL;
118 }
119
120 return err;
121}
122
123static int write_eraseblock_by_page(int ebnum)
124{
125 size_t written = 0;
126 int i, err = 0;
127 loff_t addr = ebnum * mtd->erasesize;
128 void *buf = iobuf;
129
130 for (i = 0; i < pgcnt; i++) {
131 err = mtd->write(mtd, addr, pgsize, &written, buf);
132 if (err || written != pgsize) {
133 printk(PRINT_PREF "error: write failed at %#llx\n",
134 addr);
135 if (!err)
136 err = -EINVAL;
137 break;
138 }
139 addr += pgsize;
140 buf += pgsize;
141 }
142
143 return err;
144}
145
146static int write_eraseblock_by_2pages(int ebnum)
147{
148 size_t written = 0, sz = pgsize * 2;
149 int i, n = pgcnt / 2, err = 0;
150 loff_t addr = ebnum * mtd->erasesize;
151 void *buf = iobuf;
152
153 for (i = 0; i < n; i++) {
154 err = mtd->write(mtd, addr, sz, &written, buf);
155 if (err || written != sz) {
156 printk(PRINT_PREF "error: write failed at %#llx\n",
157 addr);
158 if (!err)
159 err = -EINVAL;
160 return err;
161 }
162 addr += sz;
163 buf += sz;
164 }
165 if (pgcnt % 2) {
166 err = mtd->write(mtd, addr, pgsize, &written, buf);
167 if (err || written != pgsize) {
168 printk(PRINT_PREF "error: write failed at %#llx\n",
169 addr);
170 if (!err)
171 err = -EINVAL;
172 }
173 }
174
175 return err;
176}
177
178static int read_eraseblock(int ebnum)
179{
180 size_t read = 0;
181 int err = 0;
182 loff_t addr = ebnum * mtd->erasesize;
183
184 err = mtd->read(mtd, addr, mtd->erasesize, &read, iobuf);
185 /* Ignore corrected ECC errors */
186 if (err == -EUCLEAN)
187 err = 0;
188 if (err || read != mtd->erasesize) {
189 printk(PRINT_PREF "error: read failed at %#llx\n", addr);
190 if (!err)
191 err = -EINVAL;
192 }
193
194 return err;
195}
196
197static int read_eraseblock_by_page(int ebnum)
198{
199 size_t read = 0;
200 int i, err = 0;
201 loff_t addr = ebnum * mtd->erasesize;
202 void *buf = iobuf;
203
204 for (i = 0; i < pgcnt; i++) {
205 err = mtd->read(mtd, addr, pgsize, &read, buf);
206 /* Ignore corrected ECC errors */
207 if (err == -EUCLEAN)
208 err = 0;
209 if (err || read != pgsize) {
210 printk(PRINT_PREF "error: read failed at %#llx\n",
211 addr);
212 if (!err)
213 err = -EINVAL;
214 break;
215 }
216 addr += pgsize;
217 buf += pgsize;
218 }
219
220 return err;
221}
222
223static int read_eraseblock_by_2pages(int ebnum)
224{
225 size_t read = 0, sz = pgsize * 2;
226 int i, n = pgcnt / 2, err = 0;
227 loff_t addr = ebnum * mtd->erasesize;
228 void *buf = iobuf;
229
230 for (i = 0; i < n; i++) {
231 err = mtd->read(mtd, addr, sz, &read, buf);
232 /* Ignore corrected ECC errors */
233 if (err == -EUCLEAN)
234 err = 0;
235 if (err || read != sz) {
236 printk(PRINT_PREF "error: read failed at %#llx\n",
237 addr);
238 if (!err)
239 err = -EINVAL;
240 return err;
241 }
242 addr += sz;
243 buf += sz;
244 }
245 if (pgcnt % 2) {
246 err = mtd->read(mtd, addr, pgsize, &read, buf);
247 /* Ignore corrected ECC errors */
248 if (err == -EUCLEAN)
249 err = 0;
250 if (err || read != pgsize) {
251 printk(PRINT_PREF "error: read failed at %#llx\n",
252 addr);
253 if (!err)
254 err = -EINVAL;
255 }
256 }
257
258 return err;
259}
260
261static int is_block_bad(int ebnum)
262{
263 loff_t addr = ebnum * mtd->erasesize;
264 int ret;
265
266 ret = mtd->block_isbad(mtd, addr);
267 if (ret)
268 printk(PRINT_PREF "block %d is bad\n", ebnum);
269 return ret;
270}
271
272static inline void start_timing(void)
273{
274 do_gettimeofday(&start);
275}
276
277static inline void stop_timing(void)
278{
279 do_gettimeofday(&finish);
280}
281
282static long calc_speed(void)
283{
284 long ms, k, speed;
285
286 ms = (finish.tv_sec - start.tv_sec) * 1000 +
287 (finish.tv_usec - start.tv_usec) / 1000;
288 k = goodebcnt * mtd->erasesize / 1024;
289 speed = (k * 1000) / ms;
290 return speed;
291}
292
293static int scan_for_bad_eraseblocks(void)
294{
295 int i, bad = 0;
296
297 bbt = kmalloc(ebcnt, GFP_KERNEL);
298 if (!bbt) {
299 printk(PRINT_PREF "error: cannot allocate memory\n");
300 return -ENOMEM;
301 }
302 memset(bbt, 0 , ebcnt);
303
304 printk(PRINT_PREF "scanning for bad eraseblocks\n");
305 for (i = 0; i < ebcnt; ++i) {
306 bbt[i] = is_block_bad(i) ? 1 : 0;
307 if (bbt[i])
308 bad += 1;
309 cond_resched();
310 }
311 printk(PRINT_PREF "scanned %d eraseblocks, %d are bad\n", i, bad);
312 goodebcnt = ebcnt - bad;
313 return 0;
314}
315
316static int __init mtd_speedtest_init(void)
317{
318 int err, i;
319 long speed;
320 uint64_t tmp;
321
322 printk(KERN_INFO "\n");
323 printk(KERN_INFO "=================================================\n");
324 printk(PRINT_PREF "MTD device: %d\n", dev);
325
326 mtd = get_mtd_device(NULL, dev);
327 if (IS_ERR(mtd)) {
328 err = PTR_ERR(mtd);
329 printk(PRINT_PREF "error: cannot get MTD device\n");
330 return err;
331 }
332
333 if (mtd->writesize == 1) {
334 printk(PRINT_PREF "not NAND flash, assume page size is 512 "
335 "bytes.\n");
336 pgsize = 512;
337 } else
338 pgsize = mtd->writesize;
339
340 tmp = mtd->size;
341 do_div(tmp, mtd->erasesize);
342 ebcnt = tmp;
343 pgcnt = mtd->erasesize / mtd->writesize;
344
345 printk(PRINT_PREF "MTD device size %llu, eraseblock size %u, "
346 "page size %u, count of eraseblocks %u, pages per "
347 "eraseblock %u, OOB size %u\n",
348 (unsigned long long)mtd->size, mtd->erasesize,
349 pgsize, ebcnt, pgcnt, mtd->oobsize);
350
351 err = -ENOMEM;
352 iobuf = kmalloc(mtd->erasesize, GFP_KERNEL);
353 if (!iobuf) {
354 printk(PRINT_PREF "error: cannot allocate memory\n");
355 goto out;
356 }
357
358 simple_srand(1);
359 set_random_data(iobuf, mtd->erasesize);
360
361 err = scan_for_bad_eraseblocks();
362 if (err)
363 goto out;
364
365 err = erase_whole_device();
366 if (err)
367 goto out;
368
369 /* Write all eraseblocks, 1 eraseblock at a time */
370 printk(PRINT_PREF "testing eraseblock write speed\n");
371 start_timing();
372 for (i = 0; i < ebcnt; ++i) {
373 if (bbt[i])
374 continue;
375 err = write_eraseblock(i);
376 if (err)
377 goto out;
378 cond_resched();
379 }
380 stop_timing();
381 speed = calc_speed();
382 printk(PRINT_PREF "eraseblock write speed is %ld KiB/s\n", speed);
383
384 /* Read all eraseblocks, 1 eraseblock at a time */
385 printk(PRINT_PREF "testing eraseblock read speed\n");
386 start_timing();
387 for (i = 0; i < ebcnt; ++i) {
388 if (bbt[i])
389 continue;
390 err = read_eraseblock(i);
391 if (err)
392 goto out;
393 cond_resched();
394 }
395 stop_timing();
396 speed = calc_speed();
397 printk(PRINT_PREF "eraseblock read speed is %ld KiB/s\n", speed);
398
399 err = erase_whole_device();
400 if (err)
401 goto out;
402
403 /* Write all eraseblocks, 1 page at a time */
404 printk(PRINT_PREF "testing page write speed\n");
405 start_timing();
406 for (i = 0; i < ebcnt; ++i) {
407 if (bbt[i])
408 continue;
409 err = write_eraseblock_by_page(i);
410 if (err)
411 goto out;
412 cond_resched();
413 }
414 stop_timing();
415 speed = calc_speed();
416 printk(PRINT_PREF "page write speed is %ld KiB/s\n", speed);
417
418 /* Read all eraseblocks, 1 page at a time */
419 printk(PRINT_PREF "testing page read speed\n");
420 start_timing();
421 for (i = 0; i < ebcnt; ++i) {
422 if (bbt[i])
423 continue;
424 err = read_eraseblock_by_page(i);
425 if (err)
426 goto out;
427 cond_resched();
428 }
429 stop_timing();
430 speed = calc_speed();
431 printk(PRINT_PREF "page read speed is %ld KiB/s\n", speed);
432
433 err = erase_whole_device();
434 if (err)
435 goto out;
436
437 /* Write all eraseblocks, 2 pages at a time */
438 printk(PRINT_PREF "testing 2 page write speed\n");
439 start_timing();
440 for (i = 0; i < ebcnt; ++i) {
441 if (bbt[i])
442 continue;
443 err = write_eraseblock_by_2pages(i);
444 if (err)
445 goto out;
446 cond_resched();
447 }
448 stop_timing();
449 speed = calc_speed();
450 printk(PRINT_PREF "2 page write speed is %ld KiB/s\n", speed);
451
452 /* Read all eraseblocks, 2 pages at a time */
453 printk(PRINT_PREF "testing 2 page read speed\n");
454 start_timing();
455 for (i = 0; i < ebcnt; ++i) {
456 if (bbt[i])
457 continue;
458 err = read_eraseblock_by_2pages(i);
459 if (err)
460 goto out;
461 cond_resched();
462 }
463 stop_timing();
464 speed = calc_speed();
465 printk(PRINT_PREF "2 page read speed is %ld KiB/s\n", speed);
466
467 /* Erase all eraseblocks */
468 printk(PRINT_PREF "Testing erase speed\n");
469 start_timing();
470 for (i = 0; i < ebcnt; ++i) {
471 if (bbt[i])
472 continue;
473 err = erase_eraseblock(i);
474 if (err)
475 goto out;
476 cond_resched();
477 }
478 stop_timing();
479 speed = calc_speed();
480 printk(PRINT_PREF "erase speed is %ld KiB/s\n", speed);
481
482 printk(PRINT_PREF "finished\n");
483out:
484 kfree(iobuf);
485 kfree(bbt);
486 put_mtd_device(mtd);
487 if (err)
488 printk(PRINT_PREF "error %d occurred\n", err);
489 printk(KERN_INFO "=================================================\n");
490 return err;
491}
492module_init(mtd_speedtest_init);
493
494static void __exit mtd_speedtest_exit(void)
495{
496 return;
497}
498module_exit(mtd_speedtest_exit);
499
500MODULE_DESCRIPTION("Speed test module");
501MODULE_AUTHOR("Adrian Hunter");
502MODULE_LICENSE("GPL");
diff --git a/drivers/mtd/tests/mtd_stresstest.c b/drivers/mtd/tests/mtd_stresstest.c
new file mode 100644
index 000000000000..63920476b57a
--- /dev/null
+++ b/drivers/mtd/tests/mtd_stresstest.c
@@ -0,0 +1,330 @@
1/*
2 * Copyright (C) 2006-2008 Nokia Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; see the file COPYING. If not, write to the Free Software
15 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 *
17 * Test random reads, writes and erases on MTD device.
18 *
19 * Author: Adrian Hunter <ext-adrian.hunter@nokia.com>
20 */
21
22#include <linux/init.h>
23#include <linux/module.h>
24#include <linux/moduleparam.h>
25#include <linux/err.h>
26#include <linux/mtd/mtd.h>
27#include <linux/sched.h>
28#include <linux/vmalloc.h>
29
30#define PRINT_PREF KERN_INFO "mtd_stresstest: "
31
32static int dev;
33module_param(dev, int, S_IRUGO);
34MODULE_PARM_DESC(dev, "MTD device number to use");
35
36static int count = 10000;
37module_param(count, int, S_IRUGO);
38MODULE_PARM_DESC(count, "Number of operations to do (default is 10000)");
39
40static struct mtd_info *mtd;
41static unsigned char *writebuf;
42static unsigned char *readbuf;
43static unsigned char *bbt;
44static int *offsets;
45
46static int pgsize;
47static int bufsize;
48static int ebcnt;
49static int pgcnt;
50static unsigned long next = 1;
51
52static inline unsigned int simple_rand(void)
53{
54 next = next * 1103515245 + 12345;
55 return (unsigned int)((next / 65536) % 32768);
56}
57
58static inline void simple_srand(unsigned long seed)
59{
60 next = seed;
61}
62
63static int rand_eb(void)
64{
65 int eb;
66
67again:
68 if (ebcnt < 32768)
69 eb = simple_rand();
70 else
71 eb = (simple_rand() << 15) | simple_rand();
72 /* Read or write up 2 eraseblocks at a time - hence 'ebcnt - 1' */
73 eb %= (ebcnt - 1);
74 if (bbt[eb])
75 goto again;
76 return eb;
77}
78
79static int rand_offs(void)
80{
81 int offs;
82
83 if (bufsize < 32768)
84 offs = simple_rand();
85 else
86 offs = (simple_rand() << 15) | simple_rand();
87 offs %= bufsize;
88 return offs;
89}
90
91static int rand_len(int offs)
92{
93 int len;
94
95 if (bufsize < 32768)
96 len = simple_rand();
97 else
98 len = (simple_rand() << 15) | simple_rand();
99 len %= (bufsize - offs);
100 return len;
101}
102
103static int erase_eraseblock(int ebnum)
104{
105 int err;
106 struct erase_info ei;
107 loff_t addr = ebnum * mtd->erasesize;
108
109 memset(&ei, 0, sizeof(struct erase_info));
110 ei.mtd = mtd;
111 ei.addr = addr;
112 ei.len = mtd->erasesize;
113
114 err = mtd->erase(mtd, &ei);
115 if (unlikely(err)) {
116 printk(PRINT_PREF "error %d while erasing EB %d\n", err, ebnum);
117 return err;
118 }
119
120 if (unlikely(ei.state == MTD_ERASE_FAILED)) {
121 printk(PRINT_PREF "some erase error occurred at EB %d\n",
122 ebnum);
123 return -EIO;
124 }
125
126 return 0;
127}
128
129static int is_block_bad(int ebnum)
130{
131 loff_t addr = ebnum * mtd->erasesize;
132 int ret;
133
134 ret = mtd->block_isbad(mtd, addr);
135 if (ret)
136 printk(PRINT_PREF "block %d is bad\n", ebnum);
137 return ret;
138}
139
140static int do_read(void)
141{
142 size_t read = 0;
143 int eb = rand_eb();
144 int offs = rand_offs();
145 int len = rand_len(offs), err;
146 loff_t addr;
147
148 if (bbt[eb + 1]) {
149 if (offs >= mtd->erasesize)
150 offs -= mtd->erasesize;
151 if (offs + len > mtd->erasesize)
152 len = mtd->erasesize - offs;
153 }
154 addr = eb * mtd->erasesize + offs;
155 err = mtd->read(mtd, addr, len, &read, readbuf);
156 if (err == -EUCLEAN)
157 err = 0;
158 if (unlikely(err || read != len)) {
159 printk(PRINT_PREF "error: read failed at 0x%llx\n",
160 (long long)addr);
161 if (!err)
162 err = -EINVAL;
163 return err;
164 }
165 return 0;
166}
167
168static int do_write(void)
169{
170 int eb = rand_eb(), offs, err, len;
171 size_t written = 0;
172 loff_t addr;
173
174 offs = offsets[eb];
175 if (offs >= mtd->erasesize) {
176 err = erase_eraseblock(eb);
177 if (err)
178 return err;
179 offs = offsets[eb] = 0;
180 }
181 len = rand_len(offs);
182 len = ((len + pgsize - 1) / pgsize) * pgsize;
183 if (offs + len > mtd->erasesize) {
184 if (bbt[eb + 1])
185 len = mtd->erasesize - offs;
186 else {
187 err = erase_eraseblock(eb + 1);
188 if (err)
189 return err;
190 offsets[eb + 1] = 0;
191 }
192 }
193 addr = eb * mtd->erasesize + offs;
194 err = mtd->write(mtd, addr, len, &written, writebuf);
195 if (unlikely(err || written != len)) {
196 printk(PRINT_PREF "error: write failed at 0x%llx\n",
197 (long long)addr);
198 if (!err)
199 err = -EINVAL;
200 return err;
201 }
202 offs += len;
203 while (offs > mtd->erasesize) {
204 offsets[eb++] = mtd->erasesize;
205 offs -= mtd->erasesize;
206 }
207 offsets[eb] = offs;
208 return 0;
209}
210
211static int do_operation(void)
212{
213 if (simple_rand() & 1)
214 return do_read();
215 else
216 return do_write();
217}
218
219static int scan_for_bad_eraseblocks(void)
220{
221 int i, bad = 0;
222
223 bbt = kmalloc(ebcnt, GFP_KERNEL);
224 if (!bbt) {
225 printk(PRINT_PREF "error: cannot allocate memory\n");
226 return -ENOMEM;
227 }
228 memset(bbt, 0 , ebcnt);
229
230 printk(PRINT_PREF "scanning for bad eraseblocks\n");
231 for (i = 0; i < ebcnt; ++i) {
232 bbt[i] = is_block_bad(i) ? 1 : 0;
233 if (bbt[i])
234 bad += 1;
235 cond_resched();
236 }
237 printk(PRINT_PREF "scanned %d eraseblocks, %d are bad\n", i, bad);
238 return 0;
239}
240
241static int __init mtd_stresstest_init(void)
242{
243 int err;
244 int i, op;
245 uint64_t tmp;
246
247 printk(KERN_INFO "\n");
248 printk(KERN_INFO "=================================================\n");
249 printk(PRINT_PREF "MTD device: %d\n", dev);
250
251 mtd = get_mtd_device(NULL, dev);
252 if (IS_ERR(mtd)) {
253 err = PTR_ERR(mtd);
254 printk(PRINT_PREF "error: cannot get MTD device\n");
255 return err;
256 }
257
258 if (mtd->writesize == 1) {
259 printk(PRINT_PREF "not NAND flash, assume page size is 512 "
260 "bytes.\n");
261 pgsize = 512;
262 } else
263 pgsize = mtd->writesize;
264
265 tmp = mtd->size;
266 do_div(tmp, mtd->erasesize);
267 ebcnt = tmp;
268 pgcnt = mtd->erasesize / mtd->writesize;
269
270 printk(PRINT_PREF "MTD device size %llu, eraseblock size %u, "
271 "page size %u, count of eraseblocks %u, pages per "
272 "eraseblock %u, OOB size %u\n",
273 (unsigned long long)mtd->size, mtd->erasesize,
274 pgsize, ebcnt, pgcnt, mtd->oobsize);
275
276 /* Read or write up 2 eraseblocks at a time */
277 bufsize = mtd->erasesize * 2;
278
279 err = -ENOMEM;
280 readbuf = vmalloc(bufsize);
281 writebuf = vmalloc(bufsize);
282 offsets = kmalloc(ebcnt * sizeof(int), GFP_KERNEL);
283 if (!readbuf || !writebuf || !offsets) {
284 printk(PRINT_PREF "error: cannot allocate memory\n");
285 goto out;
286 }
287 for (i = 0; i < ebcnt; i++)
288 offsets[i] = mtd->erasesize;
289 simple_srand(current->pid);
290 for (i = 0; i < bufsize; i++)
291 writebuf[i] = simple_rand();
292
293 err = scan_for_bad_eraseblocks();
294 if (err)
295 goto out;
296
297 /* Do operations */
298 printk(PRINT_PREF "doing operations\n");
299 for (op = 0; op < count; op++) {
300 if ((op & 1023) == 0)
301 printk(PRINT_PREF "%d operations done\n", op);
302 err = do_operation();
303 if (err)
304 goto out;
305 cond_resched();
306 }
307 printk(PRINT_PREF "finished, %d operations done\n", op);
308
309out:
310 kfree(offsets);
311 kfree(bbt);
312 vfree(writebuf);
313 vfree(readbuf);
314 put_mtd_device(mtd);
315 if (err)
316 printk(PRINT_PREF "error %d occurred\n", err);
317 printk(KERN_INFO "=================================================\n");
318 return err;
319}
320module_init(mtd_stresstest_init);
321
322static void __exit mtd_stresstest_exit(void)
323{
324 return;
325}
326module_exit(mtd_stresstest_exit);
327
328MODULE_DESCRIPTION("Stress test module");
329MODULE_AUTHOR("Adrian Hunter");
330MODULE_LICENSE("GPL");
diff --git a/drivers/mtd/tests/mtd_subpagetest.c b/drivers/mtd/tests/mtd_subpagetest.c
new file mode 100644
index 000000000000..5b889724268e
--- /dev/null
+++ b/drivers/mtd/tests/mtd_subpagetest.c
@@ -0,0 +1,525 @@
1/*
2 * Copyright (C) 2006-2007 Nokia Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; see the file COPYING. If not, write to the Free Software
15 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 *
17 * Test sub-page read and write on MTD device.
18 * Author: Adrian Hunter <ext-adrian.hunter@nokia.com>
19 *
20 */
21
22#include <linux/init.h>
23#include <linux/module.h>
24#include <linux/moduleparam.h>
25#include <linux/err.h>
26#include <linux/mtd/mtd.h>
27#include <linux/sched.h>
28
29#define PRINT_PREF KERN_INFO "mtd_subpagetest: "
30
31static int dev;
32module_param(dev, int, S_IRUGO);
33MODULE_PARM_DESC(dev, "MTD device number to use");
34
35static struct mtd_info *mtd;
36static unsigned char *writebuf;
37static unsigned char *readbuf;
38static unsigned char *bbt;
39
40static int subpgsize;
41static int bufsize;
42static int ebcnt;
43static int pgcnt;
44static int errcnt;
45static unsigned long next = 1;
46
47static inline unsigned int simple_rand(void)
48{
49 next = next * 1103515245 + 12345;
50 return (unsigned int)((next / 65536) % 32768);
51}
52
53static inline void simple_srand(unsigned long seed)
54{
55 next = seed;
56}
57
58static void set_random_data(unsigned char *buf, size_t len)
59{
60 size_t i;
61
62 for (i = 0; i < len; ++i)
63 buf[i] = simple_rand();
64}
65
66static inline void clear_data(unsigned char *buf, size_t len)
67{
68 memset(buf, 0, len);
69}
70
71static int erase_eraseblock(int ebnum)
72{
73 int err;
74 struct erase_info ei;
75 loff_t addr = ebnum * mtd->erasesize;
76
77 memset(&ei, 0, sizeof(struct erase_info));
78 ei.mtd = mtd;
79 ei.addr = addr;
80 ei.len = mtd->erasesize;
81
82 err = mtd->erase(mtd, &ei);
83 if (err) {
84 printk(PRINT_PREF "error %d while erasing EB %d\n", err, ebnum);
85 return err;
86 }
87
88 if (ei.state == MTD_ERASE_FAILED) {
89 printk(PRINT_PREF "some erase error occurred at EB %d\n",
90 ebnum);
91 return -EIO;
92 }
93
94 return 0;
95}
96
97static int erase_whole_device(void)
98{
99 int err;
100 unsigned int i;
101
102 printk(PRINT_PREF "erasing whole device\n");
103 for (i = 0; i < ebcnt; ++i) {
104 if (bbt[i])
105 continue;
106 err = erase_eraseblock(i);
107 if (err)
108 return err;
109 cond_resched();
110 }
111 printk(PRINT_PREF "erased %u eraseblocks\n", i);
112 return 0;
113}
114
115static int write_eraseblock(int ebnum)
116{
117 size_t written = 0;
118 int err = 0;
119 loff_t addr = ebnum * mtd->erasesize;
120
121 set_random_data(writebuf, subpgsize);
122 err = mtd->write(mtd, addr, subpgsize, &written, writebuf);
123 if (unlikely(err || written != subpgsize)) {
124 printk(PRINT_PREF "error: write failed at %#llx\n",
125 (long long)addr);
126 if (written != subpgsize) {
127 printk(PRINT_PREF " write size: %#x\n", subpgsize);
128 printk(PRINT_PREF " written: %#zx\n", written);
129 }
130 return err ? err : -1;
131 }
132
133 addr += subpgsize;
134
135 set_random_data(writebuf, subpgsize);
136 err = mtd->write(mtd, addr, subpgsize, &written, writebuf);
137 if (unlikely(err || written != subpgsize)) {
138 printk(PRINT_PREF "error: write failed at %#llx\n",
139 (long long)addr);
140 if (written != subpgsize) {
141 printk(PRINT_PREF " write size: %#x\n", subpgsize);
142 printk(PRINT_PREF " written: %#zx\n", written);
143 }
144 return err ? err : -1;
145 }
146
147 return err;
148}
149
150static int write_eraseblock2(int ebnum)
151{
152 size_t written = 0;
153 int err = 0, k;
154 loff_t addr = ebnum * mtd->erasesize;
155
156 for (k = 1; k < 33; ++k) {
157 if (addr + (subpgsize * k) > (ebnum + 1) * mtd->erasesize)
158 break;
159 set_random_data(writebuf, subpgsize * k);
160 err = mtd->write(mtd, addr, subpgsize * k, &written, writebuf);
161 if (unlikely(err || written != subpgsize * k)) {
162 printk(PRINT_PREF "error: write failed at %#llx\n",
163 (long long)addr);
164 if (written != subpgsize) {
165 printk(PRINT_PREF " write size: %#x\n",
166 subpgsize * k);
167 printk(PRINT_PREF " written: %#08zx\n",
168 written);
169 }
170 return err ? err : -1;
171 }
172 addr += subpgsize * k;
173 }
174
175 return err;
176}
177
178static void print_subpage(unsigned char *p)
179{
180 int i, j;
181
182 for (i = 0; i < subpgsize; ) {
183 for (j = 0; i < subpgsize && j < 32; ++i, ++j)
184 printk("%02x", *p++);
185 printk("\n");
186 }
187}
188
189static int verify_eraseblock(int ebnum)
190{
191 size_t read = 0;
192 int err = 0;
193 loff_t addr = ebnum * mtd->erasesize;
194
195 set_random_data(writebuf, subpgsize);
196 clear_data(readbuf, subpgsize);
197 read = 0;
198 err = mtd->read(mtd, addr, subpgsize, &read, readbuf);
199 if (unlikely(err || read != subpgsize)) {
200 if (err == -EUCLEAN && read == subpgsize) {
201 printk(PRINT_PREF "ECC correction at %#llx\n",
202 (long long)addr);
203 err = 0;
204 } else {
205 printk(PRINT_PREF "error: read failed at %#llx\n",
206 (long long)addr);
207 return err ? err : -1;
208 }
209 }
210 if (unlikely(memcmp(readbuf, writebuf, subpgsize))) {
211 printk(PRINT_PREF "error: verify failed at %#llx\n",
212 (long long)addr);
213 printk(PRINT_PREF "------------- written----------------\n");
214 print_subpage(writebuf);
215 printk(PRINT_PREF "------------- read ------------------\n");
216 print_subpage(readbuf);
217 printk(PRINT_PREF "-------------------------------------\n");
218 errcnt += 1;
219 }
220
221 addr += subpgsize;
222
223 set_random_data(writebuf, subpgsize);
224 clear_data(readbuf, subpgsize);
225 read = 0;
226 err = mtd->read(mtd, addr, subpgsize, &read, readbuf);
227 if (unlikely(err || read != subpgsize)) {
228 if (err == -EUCLEAN && read == subpgsize) {
229 printk(PRINT_PREF "ECC correction at %#llx\n",
230 (long long)addr);
231 err = 0;
232 } else {
233 printk(PRINT_PREF "error: read failed at %#llx\n",
234 (long long)addr);
235 return err ? err : -1;
236 }
237 }
238 if (unlikely(memcmp(readbuf, writebuf, subpgsize))) {
239 printk(PRINT_PREF "error: verify failed at %#llx\n",
240 (long long)addr);
241 printk(PRINT_PREF "------------- written----------------\n");
242 print_subpage(writebuf);
243 printk(PRINT_PREF "------------- read ------------------\n");
244 print_subpage(readbuf);
245 printk(PRINT_PREF "-------------------------------------\n");
246 errcnt += 1;
247 }
248
249 return err;
250}
251
252static int verify_eraseblock2(int ebnum)
253{
254 size_t read = 0;
255 int err = 0, k;
256 loff_t addr = ebnum * mtd->erasesize;
257
258 for (k = 1; k < 33; ++k) {
259 if (addr + (subpgsize * k) > (ebnum + 1) * mtd->erasesize)
260 break;
261 set_random_data(writebuf, subpgsize * k);
262 clear_data(readbuf, subpgsize * k);
263 read = 0;
264 err = mtd->read(mtd, addr, subpgsize * k, &read, readbuf);
265 if (unlikely(err || read != subpgsize * k)) {
266 if (err == -EUCLEAN && read == subpgsize * k) {
267 printk(PRINT_PREF "ECC correction at %#llx\n",
268 (long long)addr);
269 err = 0;
270 } else {
271 printk(PRINT_PREF "error: read failed at "
272 "%#llx\n", (long long)addr);
273 return err ? err : -1;
274 }
275 }
276 if (unlikely(memcmp(readbuf, writebuf, subpgsize * k))) {
277 printk(PRINT_PREF "error: verify failed at %#llx\n",
278 (long long)addr);
279 errcnt += 1;
280 }
281 addr += subpgsize * k;
282 }
283
284 return err;
285}
286
287static int verify_eraseblock_ff(int ebnum)
288{
289 uint32_t j;
290 size_t read = 0;
291 int err = 0;
292 loff_t addr = ebnum * mtd->erasesize;
293
294 memset(writebuf, 0xff, subpgsize);
295 for (j = 0; j < mtd->erasesize / subpgsize; ++j) {
296 clear_data(readbuf, subpgsize);
297 read = 0;
298 err = mtd->read(mtd, addr, subpgsize, &read, readbuf);
299 if (unlikely(err || read != subpgsize)) {
300 if (err == -EUCLEAN && read == subpgsize) {
301 printk(PRINT_PREF "ECC correction at %#llx\n",
302 (long long)addr);
303 err = 0;
304 } else {
305 printk(PRINT_PREF "error: read failed at "
306 "%#llx\n", (long long)addr);
307 return err ? err : -1;
308 }
309 }
310 if (unlikely(memcmp(readbuf, writebuf, subpgsize))) {
311 printk(PRINT_PREF "error: verify 0xff failed at "
312 "%#llx\n", (long long)addr);
313 errcnt += 1;
314 }
315 addr += subpgsize;
316 }
317
318 return err;
319}
320
321static int verify_all_eraseblocks_ff(void)
322{
323 int err;
324 unsigned int i;
325
326 printk(PRINT_PREF "verifying all eraseblocks for 0xff\n");
327 for (i = 0; i < ebcnt; ++i) {
328 if (bbt[i])
329 continue;
330 err = verify_eraseblock_ff(i);
331 if (err)
332 return err;
333 if (i % 256 == 0)
334 printk(PRINT_PREF "verified up to eraseblock %u\n", i);
335 cond_resched();
336 }
337 printk(PRINT_PREF "verified %u eraseblocks\n", i);
338 return 0;
339}
340
341static int is_block_bad(int ebnum)
342{
343 loff_t addr = ebnum * mtd->erasesize;
344 int ret;
345
346 ret = mtd->block_isbad(mtd, addr);
347 if (ret)
348 printk(PRINT_PREF "block %d is bad\n", ebnum);
349 return ret;
350}
351
352static int scan_for_bad_eraseblocks(void)
353{
354 int i, bad = 0;
355
356 bbt = kmalloc(ebcnt, GFP_KERNEL);
357 if (!bbt) {
358 printk(PRINT_PREF "error: cannot allocate memory\n");
359 return -ENOMEM;
360 }
361 memset(bbt, 0 , ebcnt);
362
363 printk(PRINT_PREF "scanning for bad eraseblocks\n");
364 for (i = 0; i < ebcnt; ++i) {
365 bbt[i] = is_block_bad(i) ? 1 : 0;
366 if (bbt[i])
367 bad += 1;
368 cond_resched();
369 }
370 printk(PRINT_PREF "scanned %d eraseblocks, %d are bad\n", i, bad);
371 return 0;
372}
373
374static int __init mtd_subpagetest_init(void)
375{
376 int err = 0;
377 uint32_t i;
378 uint64_t tmp;
379
380 printk(KERN_INFO "\n");
381 printk(KERN_INFO "=================================================\n");
382 printk(PRINT_PREF "MTD device: %d\n", dev);
383
384 mtd = get_mtd_device(NULL, dev);
385 if (IS_ERR(mtd)) {
386 err = PTR_ERR(mtd);
387 printk(PRINT_PREF "error: cannot get MTD device\n");
388 return err;
389 }
390
391 if (mtd->type != MTD_NANDFLASH) {
392 printk(PRINT_PREF "this test requires NAND flash\n");
393 goto out;
394 }
395
396 subpgsize = mtd->writesize >> mtd->subpage_sft;
397 printk(PRINT_PREF "MTD device size %llu, eraseblock size %u, "
398 "page size %u, subpage size %u, count of eraseblocks %u, "
399 "pages per eraseblock %u, OOB size %u\n",
400 (unsigned long long)mtd->size, mtd->erasesize,
401 mtd->writesize, subpgsize, ebcnt, pgcnt, mtd->oobsize);
402
403 err = -ENOMEM;
404 bufsize = subpgsize * 32;
405 writebuf = kmalloc(bufsize, GFP_KERNEL);
406 if (!writebuf) {
407 printk(PRINT_PREF "error: cannot allocate memory\n");
408 goto out;
409 }
410 readbuf = kmalloc(bufsize, GFP_KERNEL);
411 if (!readbuf) {
412 printk(PRINT_PREF "error: cannot allocate memory\n");
413 goto out;
414 }
415
416 tmp = mtd->size;
417 do_div(tmp, mtd->erasesize);
418 ebcnt = tmp;
419 pgcnt = mtd->erasesize / mtd->writesize;
420
421 err = scan_for_bad_eraseblocks();
422 if (err)
423 goto out;
424
425 err = erase_whole_device();
426 if (err)
427 goto out;
428
429 printk(PRINT_PREF "writing whole device\n");
430 simple_srand(1);
431 for (i = 0; i < ebcnt; ++i) {
432 if (bbt[i])
433 continue;
434 err = write_eraseblock(i);
435 if (unlikely(err))
436 goto out;
437 if (i % 256 == 0)
438 printk(PRINT_PREF "written up to eraseblock %u\n", i);
439 cond_resched();
440 }
441 printk(PRINT_PREF "written %u eraseblocks\n", i);
442
443 simple_srand(1);
444 printk(PRINT_PREF "verifying all eraseblocks\n");
445 for (i = 0; i < ebcnt; ++i) {
446 if (bbt[i])
447 continue;
448 err = verify_eraseblock(i);
449 if (unlikely(err))
450 goto out;
451 if (i % 256 == 0)
452 printk(PRINT_PREF "verified up to eraseblock %u\n", i);
453 cond_resched();
454 }
455 printk(PRINT_PREF "verified %u eraseblocks\n", i);
456
457 err = erase_whole_device();
458 if (err)
459 goto out;
460
461 err = verify_all_eraseblocks_ff();
462 if (err)
463 goto out;
464
465 /* Write all eraseblocks */
466 simple_srand(3);
467 printk(PRINT_PREF "writing whole device\n");
468 for (i = 0; i < ebcnt; ++i) {
469 if (bbt[i])
470 continue;
471 err = write_eraseblock2(i);
472 if (unlikely(err))
473 goto out;
474 if (i % 256 == 0)
475 printk(PRINT_PREF "written up to eraseblock %u\n", i);
476 cond_resched();
477 }
478 printk(PRINT_PREF "written %u eraseblocks\n", i);
479
480 /* Check all eraseblocks */
481 simple_srand(3);
482 printk(PRINT_PREF "verifying all eraseblocks\n");
483 for (i = 0; i < ebcnt; ++i) {
484 if (bbt[i])
485 continue;
486 err = verify_eraseblock2(i);
487 if (unlikely(err))
488 goto out;
489 if (i % 256 == 0)
490 printk(PRINT_PREF "verified up to eraseblock %u\n", i);
491 cond_resched();
492 }
493 printk(PRINT_PREF "verified %u eraseblocks\n", i);
494
495 err = erase_whole_device();
496 if (err)
497 goto out;
498
499 err = verify_all_eraseblocks_ff();
500 if (err)
501 goto out;
502
503 printk(PRINT_PREF "finished with %d errors\n", errcnt);
504
505out:
506 kfree(bbt);
507 kfree(readbuf);
508 kfree(writebuf);
509 put_mtd_device(mtd);
510 if (err)
511 printk(PRINT_PREF "error %d occurred\n", err);
512 printk(KERN_INFO "=================================================\n");
513 return err;
514}
515module_init(mtd_subpagetest_init);
516
517static void __exit mtd_subpagetest_exit(void)
518{
519 return;
520}
521module_exit(mtd_subpagetest_exit);
522
523MODULE_DESCRIPTION("Subpage test module");
524MODULE_AUTHOR("Adrian Hunter");
525MODULE_LICENSE("GPL");
diff --git a/drivers/mtd/tests/mtd_torturetest.c b/drivers/mtd/tests/mtd_torturetest.c
new file mode 100644
index 000000000000..631a0ab3a33c
--- /dev/null
+++ b/drivers/mtd/tests/mtd_torturetest.c
@@ -0,0 +1,530 @@
1/*
2 * Copyright (C) 2006-2008 Artem Bityutskiy
3 * Copyright (C) 2006-2008 Jarkko Lavinen
4 * Copyright (C) 2006-2008 Adrian Hunter
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published by
8 * the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; see the file COPYING. If not, write to the Free Software
17 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 *
19 * Authors: Artem Bityutskiy, Jarkko Lavinen, Adria Hunter
20 *
21 * WARNING: this test program may kill your flash and your device. Do not
22 * use it unless you know what you do. Authors are not responsible for any
23 * damage caused by this program.
24 */
25
26#include <linux/init.h>
27#include <linux/module.h>
28#include <linux/moduleparam.h>
29#include <linux/err.h>
30#include <linux/mtd/mtd.h>
31#include <linux/sched.h>
32
33#define PRINT_PREF KERN_INFO "mtd_torturetest: "
34#define RETRIES 3
35
36static int eb = 8;
37module_param(eb, int, S_IRUGO);
38MODULE_PARM_DESC(eb, "eraseblock number within the selected MTD device");
39
40static int ebcnt = 32;
41module_param(ebcnt, int, S_IRUGO);
42MODULE_PARM_DESC(ebcnt, "number of consecutive eraseblocks to torture");
43
44static int pgcnt;
45module_param(pgcnt, int, S_IRUGO);
46MODULE_PARM_DESC(pgcnt, "number of pages per eraseblock to torture (0 => all)");
47
48static int dev;
49module_param(dev, int, S_IRUGO);
50MODULE_PARM_DESC(dev, "MTD device number to use");
51
52static int gran = 512;
53module_param(gran, int, S_IRUGO);
54MODULE_PARM_DESC(gran, "how often the status information should be printed");
55
56static int check = 1;
57module_param(check, int, S_IRUGO);
58MODULE_PARM_DESC(check, "if the written data should be checked");
59
60static unsigned int cycles_count;
61module_param(cycles_count, uint, S_IRUGO);
62MODULE_PARM_DESC(cycles_count, "how many erase cycles to do "
63 "(infinite by default)");
64
65static struct mtd_info *mtd;
66
67/* This buffer contains 0x555555...0xAAAAAA... pattern */
68static unsigned char *patt_5A5;
69/* This buffer contains 0xAAAAAA...0x555555... pattern */
70static unsigned char *patt_A5A;
71/* This buffer contains all 0xFF bytes */
72static unsigned char *patt_FF;
73/* This a temporary buffer is use when checking data */
74static unsigned char *check_buf;
75/* How many erase cycles were done */
76static unsigned int erase_cycles;
77
78static int pgsize;
79static struct timeval start, finish;
80
81static void report_corrupt(unsigned char *read, unsigned char *written);
82
83static inline void start_timing(void)
84{
85 do_gettimeofday(&start);
86}
87
88static inline void stop_timing(void)
89{
90 do_gettimeofday(&finish);
91}
92
93/*
94 * Erase eraseblock number @ebnum.
95 */
96static inline int erase_eraseblock(int ebnum)
97{
98 int err;
99 struct erase_info ei;
100 loff_t addr = ebnum * mtd->erasesize;
101
102 memset(&ei, 0, sizeof(struct erase_info));
103 ei.mtd = mtd;
104 ei.addr = addr;
105 ei.len = mtd->erasesize;
106
107 err = mtd->erase(mtd, &ei);
108 if (err) {
109 printk(PRINT_PREF "error %d while erasing EB %d\n", err, ebnum);
110 return err;
111 }
112
113 if (ei.state == MTD_ERASE_FAILED) {
114 printk(PRINT_PREF "some erase error occurred at EB %d\n",
115 ebnum);
116 return -EIO;
117 }
118
119 return 0;
120}
121
122/*
123 * Check that the contents of eraseblock number @enbum is equivalent to the
124 * @buf buffer.
125 */
126static inline int check_eraseblock(int ebnum, unsigned char *buf)
127{
128 int err, retries = 0;
129 size_t read = 0;
130 loff_t addr = ebnum * mtd->erasesize;
131 size_t len = mtd->erasesize;
132
133 if (pgcnt) {
134 addr = (ebnum + 1) * mtd->erasesize - pgcnt * pgsize;
135 len = pgcnt * pgsize;
136 }
137
138retry:
139 err = mtd->read(mtd, addr, len, &read, check_buf);
140 if (err == -EUCLEAN)
141 printk(PRINT_PREF "single bit flip occurred at EB %d "
142 "MTD reported that it was fixed.\n", ebnum);
143 else if (err) {
144 printk(PRINT_PREF "error %d while reading EB %d, "
145 "read %zd\n", err, ebnum, read);
146 return err;
147 }
148
149 if (read != len) {
150 printk(PRINT_PREF "failed to read %zd bytes from EB %d, "
151 "read only %zd, but no error reported\n",
152 len, ebnum, read);
153 return -EIO;
154 }
155
156 if (memcmp(buf, check_buf, len)) {
157 printk(PRINT_PREF "read wrong data from EB %d\n", ebnum);
158 report_corrupt(check_buf, buf);
159
160 if (retries++ < RETRIES) {
161 /* Try read again */
162 yield();
163 printk(PRINT_PREF "re-try reading data from EB %d\n",
164 ebnum);
165 goto retry;
166 } else {
167 printk(PRINT_PREF "retried %d times, still errors, "
168 "give-up\n", RETRIES);
169 return -EINVAL;
170 }
171 }
172
173 if (retries != 0)
174 printk(PRINT_PREF "only attempt number %d was OK (!!!)\n",
175 retries);
176
177 return 0;
178}
179
180static inline int write_pattern(int ebnum, void *buf)
181{
182 int err;
183 size_t written = 0;
184 loff_t addr = ebnum * mtd->erasesize;
185 size_t len = mtd->erasesize;
186
187 if (pgcnt) {
188 addr = (ebnum + 1) * mtd->erasesize - pgcnt * pgsize;
189 len = pgcnt * pgsize;
190 }
191 err = mtd->write(mtd, addr, len, &written, buf);
192 if (err) {
193 printk(PRINT_PREF "error %d while writing EB %d, written %zd"
194 " bytes\n", err, ebnum, written);
195 return err;
196 }
197 if (written != len) {
198 printk(PRINT_PREF "written only %zd bytes of %zd, but no error"
199 " reported\n", written, len);
200 return -EIO;
201 }
202
203 return 0;
204}
205
206static int __init tort_init(void)
207{
208 int err = 0, i, infinite = !cycles_count;
209 int bad_ebs[ebcnt];
210
211 printk(KERN_INFO "\n");
212 printk(KERN_INFO "=================================================\n");
213 printk(PRINT_PREF "Warning: this program is trying to wear out your "
214 "flash, stop it if this is not wanted.\n");
215 printk(PRINT_PREF "MTD device: %d\n", dev);
216 printk(PRINT_PREF "torture %d eraseblocks (%d-%d) of mtd%d\n",
217 ebcnt, eb, eb + ebcnt - 1, dev);
218 if (pgcnt)
219 printk(PRINT_PREF "torturing just %d pages per eraseblock\n",
220 pgcnt);
221 printk(PRINT_PREF "write verify %s\n", check ? "enabled" : "disabled");
222
223 mtd = get_mtd_device(NULL, dev);
224 if (IS_ERR(mtd)) {
225 err = PTR_ERR(mtd);
226 printk(PRINT_PREF "error: cannot get MTD device\n");
227 return err;
228 }
229
230 if (mtd->writesize == 1) {
231 printk(PRINT_PREF "not NAND flash, assume page size is 512 "
232 "bytes.\n");
233 pgsize = 512;
234 } else
235 pgsize = mtd->writesize;
236
237 if (pgcnt && (pgcnt > mtd->erasesize / pgsize || pgcnt < 0)) {
238 printk(PRINT_PREF "error: invalid pgcnt value %d\n", pgcnt);
239 goto out_mtd;
240 }
241
242 err = -ENOMEM;
243 patt_5A5 = kmalloc(mtd->erasesize, GFP_KERNEL);
244 if (!patt_5A5) {
245 printk(PRINT_PREF "error: cannot allocate memory\n");
246 goto out_mtd;
247 }
248
249 patt_A5A = kmalloc(mtd->erasesize, GFP_KERNEL);
250 if (!patt_A5A) {
251 printk(PRINT_PREF "error: cannot allocate memory\n");
252 goto out_patt_5A5;
253 }
254
255 patt_FF = kmalloc(mtd->erasesize, GFP_KERNEL);
256 if (!patt_FF) {
257 printk(PRINT_PREF "error: cannot allocate memory\n");
258 goto out_patt_A5A;
259 }
260
261 check_buf = kmalloc(mtd->erasesize, GFP_KERNEL);
262 if (!check_buf) {
263 printk(PRINT_PREF "error: cannot allocate memory\n");
264 goto out_patt_FF;
265 }
266
267 err = 0;
268
269 /* Initialize patterns */
270 memset(patt_FF, 0xFF, mtd->erasesize);
271 for (i = 0; i < mtd->erasesize / pgsize; i++) {
272 if (!(i & 1)) {
273 memset(patt_5A5 + i * pgsize, 0x55, pgsize);
274 memset(patt_A5A + i * pgsize, 0xAA, pgsize);
275 } else {
276 memset(patt_5A5 + i * pgsize, 0xAA, pgsize);
277 memset(patt_A5A + i * pgsize, 0x55, pgsize);
278 }
279 }
280
281 /*
282 * Check if there is a bad eraseblock among those we are going to test.
283 */
284 memset(&bad_ebs[0], 0, sizeof(int) * ebcnt);
285 if (mtd->block_isbad) {
286 for (i = eb; i < eb + ebcnt; i++) {
287 err = mtd->block_isbad(mtd,
288 (loff_t)i * mtd->erasesize);
289
290 if (err < 0) {
291 printk(PRINT_PREF "block_isbad() returned %d "
292 "for EB %d\n", err, i);
293 goto out;
294 }
295
296 if (err) {
297 printk("EB %d is bad. Skip it.\n", i);
298 bad_ebs[i - eb] = 1;
299 }
300 }
301 }
302
303 start_timing();
304 while (1) {
305 int i;
306 void *patt;
307
308 /* Erase all eraseblocks */
309 for (i = eb; i < eb + ebcnt; i++) {
310 if (bad_ebs[i - eb])
311 continue;
312 err = erase_eraseblock(i);
313 if (err)
314 goto out;
315 cond_resched();
316 }
317
318 /* Check if the eraseblocks contain only 0xFF bytes */
319 if (check) {
320 for (i = eb; i < eb + ebcnt; i++) {
321 if (bad_ebs[i - eb])
322 continue;
323 err = check_eraseblock(i, patt_FF);
324 if (err) {
325 printk(PRINT_PREF "verify failed"
326 " for 0xFF... pattern\n");
327 goto out;
328 }
329 cond_resched();
330 }
331 }
332
333 /* Write the pattern */
334 for (i = eb; i < eb + ebcnt; i++) {
335 if (bad_ebs[i - eb])
336 continue;
337 if ((eb + erase_cycles) & 1)
338 patt = patt_5A5;
339 else
340 patt = patt_A5A;
341 err = write_pattern(i, patt);
342 if (err)
343 goto out;
344 cond_resched();
345 }
346
347 /* Verify what we wrote */
348 if (check) {
349 for (i = eb; i < eb + ebcnt; i++) {
350 if (bad_ebs[i - eb])
351 continue;
352 if ((eb + erase_cycles) & 1)
353 patt = patt_5A5;
354 else
355 patt = patt_A5A;
356 err = check_eraseblock(i, patt);
357 if (err) {
358 printk(PRINT_PREF "verify failed for %s"
359 " pattern\n",
360 ((eb + erase_cycles) & 1) ?
361 "0x55AA55..." : "0xAA55AA...");
362 goto out;
363 }
364 cond_resched();
365 }
366 }
367
368 erase_cycles += 1;
369
370 if (erase_cycles % gran == 0) {
371 long ms;
372
373 stop_timing();
374 ms = (finish.tv_sec - start.tv_sec) * 1000 +
375 (finish.tv_usec - start.tv_usec) / 1000;
376 printk(PRINT_PREF "%08u erase cycles done, took %lu "
377 "milliseconds (%lu seconds)\n",
378 erase_cycles, ms, ms / 1000);
379 start_timing();
380 }
381
382 if (!infinite && --cycles_count == 0)
383 break;
384 }
385out:
386
387 printk(PRINT_PREF "finished after %u erase cycles\n",
388 erase_cycles);
389 kfree(check_buf);
390out_patt_FF:
391 kfree(patt_FF);
392out_patt_A5A:
393 kfree(patt_A5A);
394out_patt_5A5:
395 kfree(patt_5A5);
396out_mtd:
397 put_mtd_device(mtd);
398 if (err)
399 printk(PRINT_PREF "error %d occurred during torturing\n", err);
400 printk(KERN_INFO "=================================================\n");
401 return err;
402}
403module_init(tort_init);
404
405static void __exit tort_exit(void)
406{
407 return;
408}
409module_exit(tort_exit);
410
411static int countdiffs(unsigned char *buf, unsigned char *check_buf,
412 unsigned offset, unsigned len, unsigned *bytesp,
413 unsigned *bitsp);
414static void print_bufs(unsigned char *read, unsigned char *written, int start,
415 int len);
416
417/*
418 * Report the detailed information about how the read EB differs from what was
419 * written.
420 */
421static void report_corrupt(unsigned char *read, unsigned char *written)
422{
423 int i;
424 int bytes, bits, pages, first;
425 int offset, len;
426 size_t check_len = mtd->erasesize;
427
428 if (pgcnt)
429 check_len = pgcnt * pgsize;
430
431 bytes = bits = pages = 0;
432 for (i = 0; i < check_len; i += pgsize)
433 if (countdiffs(written, read, i, pgsize, &bytes,
434 &bits) >= 0)
435 pages++;
436
437 printk(PRINT_PREF "verify fails on %d pages, %d bytes/%d bits\n",
438 pages, bytes, bits);
439 printk(PRINT_PREF "The following is a list of all differences between"
440 " what was read from flash and what was expected\n");
441
442 for (i = 0; i < check_len; i += pgsize) {
443 cond_resched();
444 bytes = bits = 0;
445 first = countdiffs(written, read, i, pgsize, &bytes,
446 &bits);
447 if (first < 0)
448 continue;
449
450 printk("-------------------------------------------------------"
451 "----------------------------------\n");
452
453 printk(PRINT_PREF "Page %zd has %d bytes/%d bits failing verify,"
454 " starting at offset 0x%x\n",
455 (mtd->erasesize - check_len + i) / pgsize,
456 bytes, bits, first);
457
458 offset = first & ~0x7;
459 len = ((first + bytes) | 0x7) + 1 - offset;
460
461 print_bufs(read, written, offset, len);
462 }
463}
464
465static void print_bufs(unsigned char *read, unsigned char *written, int start,
466 int len)
467{
468 int i = 0, j1, j2;
469 char *diff;
470
471 printk("Offset Read Written\n");
472 while (i < len) {
473 printk("0x%08x: ", start + i);
474 diff = " ";
475 for (j1 = 0; j1 < 8 && i + j1 < len; j1++) {
476 printk(" %02x", read[start + i + j1]);
477 if (read[start + i + j1] != written[start + i + j1])
478 diff = "***";
479 }
480
481 while (j1 < 8) {
482 printk(" ");
483 j1 += 1;
484 }
485
486 printk(" %s ", diff);
487
488 for (j2 = 0; j2 < 8 && i + j2 < len; j2++)
489 printk(" %02x", written[start + i + j2]);
490 printk("\n");
491 i += 8;
492 }
493}
494
495/*
496 * Count the number of differing bytes and bits and return the first differing
497 * offset.
498 */
499static int countdiffs(unsigned char *buf, unsigned char *check_buf,
500 unsigned offset, unsigned len, unsigned *bytesp,
501 unsigned *bitsp)
502{
503 unsigned i, bit;
504 int first = -1;
505
506 for (i = offset; i < offset + len; i++)
507 if (buf[i] != check_buf[i]) {
508 first = i;
509 break;
510 }
511
512 while (i < offset + len) {
513 if (buf[i] != check_buf[i]) {
514 (*bytesp)++;
515 bit = 1;
516 while (bit < 256) {
517 if ((buf[i] & bit) != (check_buf[i] & bit))
518 (*bitsp)++;
519 bit <<= 1;
520 }
521 }
522 i++;
523 }
524
525 return first;
526}
527
528MODULE_DESCRIPTION("Eraseblock torturing module");
529MODULE_AUTHOR("Artem Bityutskiy, Jarkko Lavinen, Adrian Hunter");
530MODULE_LICENSE("GPL");
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 7caf22cd5ad0..9082768cc6c3 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -561,7 +561,7 @@ static int io_init(struct ubi_device *ubi)
561 */ 561 */
562 562
563 ubi->peb_size = ubi->mtd->erasesize; 563 ubi->peb_size = ubi->mtd->erasesize;
564 ubi->peb_count = ubi->mtd->size / ubi->mtd->erasesize; 564 ubi->peb_count = mtd_div_by_eb(ubi->mtd->size, ubi->mtd);
565 ubi->flash_size = ubi->mtd->size; 565 ubi->flash_size = ubi->mtd->size;
566 566
567 if (ubi->mtd->block_isbad && ubi->mtd->block_markbad) 567 if (ubi->mtd->block_isbad && ubi->mtd->block_markbad)
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
index 048a606cebde..25def348e5ba 100644
--- a/drivers/mtd/ubi/eba.c
+++ b/drivers/mtd/ubi/eba.c
@@ -717,7 +717,7 @@ write_error:
717 * to the real data size, although the @buf buffer has to contain the 717 * to the real data size, although the @buf buffer has to contain the
718 * alignment. In all other cases, @len has to be aligned. 718 * alignment. In all other cases, @len has to be aligned.
719 * 719 *
720 * It is prohibited to write more then once to logical eraseblocks of static 720 * It is prohibited to write more than once to logical eraseblocks of static
721 * volumes. This function returns zero in case of success and a negative error 721 * volumes. This function returns zero in case of success and a negative error
722 * code in case of failure. 722 * code in case of failure.
723 */ 723 */
diff --git a/drivers/mtd/ubi/gluebi.c b/drivers/mtd/ubi/gluebi.c
index 605812bb0b1a..6dd4f5e77f82 100644
--- a/drivers/mtd/ubi/gluebi.c
+++ b/drivers/mtd/ubi/gluebi.c
@@ -215,7 +215,8 @@ static int gluebi_erase(struct mtd_info *mtd, struct erase_info *instr)
215 struct ubi_volume *vol; 215 struct ubi_volume *vol;
216 struct ubi_device *ubi; 216 struct ubi_device *ubi;
217 217
218 dbg_gen("erase %u bytes at offset %u", instr->len, instr->addr); 218 dbg_gen("erase %llu bytes at offset %llu", (unsigned long long)instr->len,
219 (unsigned long long)instr->addr);
219 220
220 if (instr->addr < 0 || instr->addr > mtd->size - mtd->erasesize) 221 if (instr->addr < 0 || instr->addr > mtd->size - mtd->erasesize)
221 return -EINVAL; 222 return -EINVAL;
@@ -223,11 +224,11 @@ static int gluebi_erase(struct mtd_info *mtd, struct erase_info *instr)
223 if (instr->len < 0 || instr->addr + instr->len > mtd->size) 224 if (instr->len < 0 || instr->addr + instr->len > mtd->size)
224 return -EINVAL; 225 return -EINVAL;
225 226
226 if (instr->addr % mtd->writesize || instr->len % mtd->writesize) 227 if (mtd_mod_by_ws(instr->addr, mtd) || mtd_mod_by_ws(instr->len, mtd))
227 return -EINVAL; 228 return -EINVAL;
228 229
229 lnum = instr->addr / mtd->erasesize; 230 lnum = mtd_div_by_eb(instr->addr, mtd);
230 count = instr->len / mtd->erasesize; 231 count = mtd_div_by_eb(instr->len, mtd);
231 232
232 vol = container_of(mtd, struct ubi_volume, gluebi_mtd); 233 vol = container_of(mtd, struct ubi_volume, gluebi_mtd);
233 ubi = vol->ubi; 234 ubi = vol->ubi;
@@ -255,7 +256,7 @@ static int gluebi_erase(struct mtd_info *mtd, struct erase_info *instr)
255 256
256out_err: 257out_err:
257 instr->state = MTD_ERASE_FAILED; 258 instr->state = MTD_ERASE_FAILED;
258 instr->fail_addr = lnum * mtd->erasesize; 259 instr->fail_addr = (long long)lnum * mtd->erasesize;
259 return err; 260 return err;
260} 261}
261 262
@@ -294,7 +295,7 @@ int ubi_create_gluebi(struct ubi_device *ubi, struct ubi_volume *vol)
294 * bytes. 295 * bytes.
295 */ 296 */
296 if (vol->vol_type == UBI_DYNAMIC_VOLUME) 297 if (vol->vol_type == UBI_DYNAMIC_VOLUME)
297 mtd->size = vol->usable_leb_size * vol->reserved_pebs; 298 mtd->size = (long long)vol->usable_leb_size * vol->reserved_pebs;
298 else 299 else
299 mtd->size = vol->used_bytes; 300 mtd->size = vol->used_bytes;
300 301
@@ -304,8 +305,8 @@ int ubi_create_gluebi(struct ubi_device *ubi, struct ubi_volume *vol)
304 return -ENFILE; 305 return -ENFILE;
305 } 306 }
306 307
307 dbg_gen("added mtd%d (\"%s\"), size %u, EB size %u", 308 dbg_gen("added mtd%d (\"%s\"), size %llu, EB size %u",
308 mtd->index, mtd->name, mtd->size, mtd->erasesize); 309 mtd->index, mtd->name, (unsigned long long)mtd->size, mtd->erasesize);
309 return 0; 310 return 0;
310} 311}
311 312
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index a74118c05745..fe81039f2a7c 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -465,7 +465,7 @@ out:
465 * This function synchronously erases physical eraseblock @pnum. If @torture 465 * This function synchronously erases physical eraseblock @pnum. If @torture
466 * flag is not zero, the physical eraseblock is checked by means of writing 466 * flag is not zero, the physical eraseblock is checked by means of writing
467 * different patterns to it and reading them back. If the torturing is enabled, 467 * different patterns to it and reading them back. If the torturing is enabled,
468 * the physical eraseblock is erased more then once. 468 * the physical eraseblock is erased more than once.
469 * 469 *
470 * This function returns the number of erasures made in case of success, %-EIO 470 * This function returns the number of erasures made in case of success, %-EIO
471 * if the erasure failed or the torturing test failed, and other negative error 471 * if the erasure failed or the torturing test failed, and other negative error
diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c
index 5d9bcf109c13..4abbe573fa40 100644
--- a/drivers/mtd/ubi/kapi.c
+++ b/drivers/mtd/ubi/kapi.c
@@ -564,7 +564,7 @@ EXPORT_SYMBOL_GPL(ubi_leb_unmap);
564 * @dtype: expected data type 564 * @dtype: expected data type
565 * 565 *
566 * This function maps an un-mapped logical eraseblock @lnum to a physical 566 * This function maps an un-mapped logical eraseblock @lnum to a physical
567 * eraseblock. This means, that after a successfull invocation of this 567 * eraseblock. This means, that after a successful invocation of this
568 * function the logical eraseblock @lnum will be empty (contain only %0xFF 568 * function the logical eraseblock @lnum will be empty (contain only %0xFF
569 * bytes) and be mapped to a physical eraseblock, even if an unclean reboot 569 * bytes) and be mapped to a physical eraseblock, even if an unclean reboot
570 * happens. 570 * happens.
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index 41d47e1cf15c..ecde202a5a12 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -478,7 +478,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si,
478 return 0; 478 return 0;
479 } else { 479 } else {
480 /* 480 /*
481 * This logical eraseblock is older then the one found 481 * This logical eraseblock is older than the one found
482 * previously. 482 * previously.
483 */ 483 */
484 if (cmp_res & 4) 484 if (cmp_res & 4)
diff --git a/drivers/mtd/ubi/ubi-media.h b/drivers/mtd/ubi/ubi-media.h
index 2ad940409053..8419fdccc79c 100644
--- a/drivers/mtd/ubi/ubi-media.h
+++ b/drivers/mtd/ubi/ubi-media.h
@@ -135,7 +135,7 @@ enum {
135 * The erase counter header takes 64 bytes and has a plenty of unused space for 135 * The erase counter header takes 64 bytes and has a plenty of unused space for
136 * future usage. The unused fields are zeroed. The @version field is used to 136 * future usage. The unused fields are zeroed. The @version field is used to
137 * indicate the version of UBI implementation which is supposed to be able to 137 * indicate the version of UBI implementation which is supposed to be able to
138 * work with this UBI image. If @version is greater then the current UBI 138 * work with this UBI image. If @version is greater than the current UBI
139 * version, the image is rejected. This may be useful in future if something 139 * version, the image is rejected. This may be useful in future if something
140 * is changed radically. This field is duplicated in the volume identifier 140 * is changed radically. This field is duplicated in the volume identifier
141 * header. 141 * header.
@@ -187,7 +187,7 @@ struct ubi_ec_hdr {
187 * (sequence number) is used to distinguish between older and newer versions of 187 * (sequence number) is used to distinguish between older and newer versions of
188 * logical eraseblocks. 188 * logical eraseblocks.
189 * 189 *
190 * There are 2 situations when there may be more then one physical eraseblock 190 * There are 2 situations when there may be more than one physical eraseblock
191 * corresponding to the same logical eraseblock, i.e., having the same @vol_id 191 * corresponding to the same logical eraseblock, i.e., having the same @vol_id
192 * and @lnum values in the volume identifier header. Suppose we have a logical 192 * and @lnum values in the volume identifier header. Suppose we have a logical
193 * eraseblock L and it is mapped to the physical eraseblock P. 193 * eraseblock L and it is mapped to the physical eraseblock P.
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index 333c8941552f..1afc61e7455d 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -577,7 +577,7 @@ static int init_volumes(struct ubi_device *ubi, const struct ubi_scan_info *si,
577 if (vtbl[i].flags & UBI_VTBL_AUTORESIZE_FLG) { 577 if (vtbl[i].flags & UBI_VTBL_AUTORESIZE_FLG) {
578 /* Auto re-size flag may be set only for one volume */ 578 /* Auto re-size flag may be set only for one volume */
579 if (ubi->autoresize_vol_id != -1) { 579 if (ubi->autoresize_vol_id != -1) {
580 ubi_err("more then one auto-resize volume (%d " 580 ubi_err("more than one auto-resize volume (%d "
581 "and %d)", ubi->autoresize_vol_id, i); 581 "and %d)", ubi->autoresize_vol_id, i);
582 kfree(vol); 582 kfree(vol);
583 return -EINVAL; 583 return -EINVAL;
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 14901cb82c18..891534f8210d 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -128,7 +128,7 @@
128 * situation when the picked physical eraseblock is constantly erased after the 128 * situation when the picked physical eraseblock is constantly erased after the
129 * data is written to it. So, we have a constant which limits the highest erase 129 * data is written to it. So, we have a constant which limits the highest erase
130 * counter of the free physical eraseblock to pick. Namely, the WL sub-system 130 * counter of the free physical eraseblock to pick. Namely, the WL sub-system
131 * does not pick eraseblocks with erase counter greater then the lowest erase 131 * does not pick eraseblocks with erase counter greater than the lowest erase
132 * counter plus %WL_FREE_MAX_DIFF. 132 * counter plus %WL_FREE_MAX_DIFF.
133 */ 133 */
134#define WL_FREE_MAX_DIFF (2*UBI_WL_THRESHOLD) 134#define WL_FREE_MAX_DIFF (2*UBI_WL_THRESHOLD)
@@ -917,7 +917,7 @@ static int ensure_wear_leveling(struct ubi_device *ubi)
917 /* 917 /*
918 * We schedule wear-leveling only if the difference between the 918 * We schedule wear-leveling only if the difference between the
919 * lowest erase counter of used physical eraseblocks and a high 919 * lowest erase counter of used physical eraseblocks and a high
920 * erase counter of free physical eraseblocks is greater then 920 * erase counter of free physical eraseblocks is greater than
921 * %UBI_WL_THRESHOLD. 921 * %UBI_WL_THRESHOLD.
922 */ 922 */
923 e1 = rb_entry(rb_first(&ubi->used), struct ubi_wl_entry, u.rb); 923 e1 = rb_entry(rb_first(&ubi->used), struct ubi_wl_entry, u.rb);
diff --git a/drivers/net/3c503.c b/drivers/net/3c503.c
index c092c3929224..5b91a85fe107 100644
--- a/drivers/net/3c503.c
+++ b/drivers/net/3c503.c
@@ -177,6 +177,7 @@ static const struct net_device_ops el2_netdev_ops = {
177 .ndo_get_stats = eip_get_stats, 177 .ndo_get_stats = eip_get_stats,
178 .ndo_set_multicast_list = eip_set_multicast_list, 178 .ndo_set_multicast_list = eip_set_multicast_list,
179 .ndo_validate_addr = eth_validate_addr, 179 .ndo_validate_addr = eth_validate_addr,
180 .ndo_set_mac_address = eth_mac_addr,
180 .ndo_change_mtu = eth_change_mtu, 181 .ndo_change_mtu = eth_change_mtu,
181#ifdef CONFIG_NET_POLL_CONTROLLER 182#ifdef CONFIG_NET_POLL_CONTROLLER
182 .ndo_poll_controller = eip_poll, 183 .ndo_poll_controller = eip_poll,
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index 665e7fdf27a1..cdbbb6226fc5 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -3109,6 +3109,8 @@ static void acpi_set_WOL(struct net_device *dev)
3109 struct vortex_private *vp = netdev_priv(dev); 3109 struct vortex_private *vp = netdev_priv(dev);
3110 void __iomem *ioaddr = vp->ioaddr; 3110 void __iomem *ioaddr = vp->ioaddr;
3111 3111
3112 device_set_wakeup_enable(vp->gendev, vp->enable_wol);
3113
3112 if (vp->enable_wol) { 3114 if (vp->enable_wol) {
3113 /* Power up on: 1==Downloaded Filter, 2==Magic Packets, 4==Link Status. */ 3115 /* Power up on: 1==Downloaded Filter, 2==Magic Packets, 4==Link Status. */
3114 EL3WINDOW(7); 3116 EL3WINDOW(7);
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c
index dd7ac8290aec..4e19ae3ce6be 100644
--- a/drivers/net/8139cp.c
+++ b/drivers/net/8139cp.c
@@ -1821,6 +1821,7 @@ static const struct net_device_ops cp_netdev_ops = {
1821 .ndo_open = cp_open, 1821 .ndo_open = cp_open,
1822 .ndo_stop = cp_close, 1822 .ndo_stop = cp_close,
1823 .ndo_validate_addr = eth_validate_addr, 1823 .ndo_validate_addr = eth_validate_addr,
1824 .ndo_set_mac_address = eth_mac_addr,
1824 .ndo_set_multicast_list = cp_set_rx_mode, 1825 .ndo_set_multicast_list = cp_set_rx_mode,
1825 .ndo_get_stats = cp_get_stats, 1826 .ndo_get_stats = cp_get_stats,
1826 .ndo_do_ioctl = cp_ioctl, 1827 .ndo_do_ioctl = cp_ioctl,
@@ -1832,6 +1833,7 @@ static const struct net_device_ops cp_netdev_ops = {
1832#ifdef BROKEN 1833#ifdef BROKEN
1833 .ndo_change_mtu = cp_change_mtu, 1834 .ndo_change_mtu = cp_change_mtu,
1834#endif 1835#endif
1836
1835#ifdef CONFIG_NET_POLL_CONTROLLER 1837#ifdef CONFIG_NET_POLL_CONTROLLER
1836 .ndo_poll_controller = cp_poll_controller, 1838 .ndo_poll_controller = cp_poll_controller,
1837#endif 1839#endif
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index fe370f805793..a5b24202d564 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -917,6 +917,7 @@ static const struct net_device_ops rtl8139_netdev_ops = {
917 .ndo_stop = rtl8139_close, 917 .ndo_stop = rtl8139_close,
918 .ndo_get_stats = rtl8139_get_stats, 918 .ndo_get_stats = rtl8139_get_stats,
919 .ndo_validate_addr = eth_validate_addr, 919 .ndo_validate_addr = eth_validate_addr,
920 .ndo_set_mac_address = eth_mac_addr,
920 .ndo_start_xmit = rtl8139_start_xmit, 921 .ndo_start_xmit = rtl8139_start_xmit,
921 .ndo_set_multicast_list = rtl8139_set_rx_mode, 922 .ndo_set_multicast_list = rtl8139_set_rx_mode,
922 .ndo_do_ioctl = netdev_ioctl, 923 .ndo_do_ioctl = netdev_ioctl,
@@ -924,7 +925,6 @@ static const struct net_device_ops rtl8139_netdev_ops = {
924#ifdef CONFIG_NET_POLL_CONTROLLER 925#ifdef CONFIG_NET_POLL_CONTROLLER
925 .ndo_poll_controller = rtl8139_poll_controller, 926 .ndo_poll_controller = rtl8139_poll_controller,
926#endif 927#endif
927
928}; 928};
929 929
930static int __devinit rtl8139_init_one (struct pci_dev *pdev, 930static int __devinit rtl8139_init_one (struct pci_dev *pdev,
diff --git a/drivers/net/8390.c b/drivers/net/8390.c
index fbe609a51e02..ec3e22e6306f 100644
--- a/drivers/net/8390.c
+++ b/drivers/net/8390.c
@@ -63,6 +63,7 @@ const struct net_device_ops ei_netdev_ops = {
63 .ndo_get_stats = ei_get_stats, 63 .ndo_get_stats = ei_get_stats,
64 .ndo_set_multicast_list = ei_set_multicast_list, 64 .ndo_set_multicast_list = ei_set_multicast_list,
65 .ndo_validate_addr = eth_validate_addr, 65 .ndo_validate_addr = eth_validate_addr,
66 .ndo_set_mac_address = eth_mac_addr,
66 .ndo_change_mtu = eth_change_mtu, 67 .ndo_change_mtu = eth_change_mtu,
67#ifdef CONFIG_NET_POLL_CONTROLLER 68#ifdef CONFIG_NET_POLL_CONTROLLER
68 .ndo_poll_controller = ei_poll, 69 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/8390p.c b/drivers/net/8390p.c
index ee70b358a816..da863c91d1d0 100644
--- a/drivers/net/8390p.c
+++ b/drivers/net/8390p.c
@@ -68,6 +68,7 @@ const struct net_device_ops eip_netdev_ops = {
68 .ndo_get_stats = eip_get_stats, 68 .ndo_get_stats = eip_get_stats,
69 .ndo_set_multicast_list = eip_set_multicast_list, 69 .ndo_set_multicast_list = eip_set_multicast_list,
70 .ndo_validate_addr = eth_validate_addr, 70 .ndo_validate_addr = eth_validate_addr,
71 .ndo_set_mac_address = eth_mac_addr,
71 .ndo_change_mtu = eth_change_mtu, 72 .ndo_change_mtu = eth_change_mtu,
72#ifdef CONFIG_NET_POLL_CONTROLLER 73#ifdef CONFIG_NET_POLL_CONTROLLER
73 .ndo_poll_controller = eip_poll, 74 .ndo_poll_controller = eip_poll,
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 9a18270c1081..9fe8cb7d43ac 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -830,7 +830,7 @@ config ULTRA32
830 830
831config BFIN_MAC 831config BFIN_MAC
832 tristate "Blackfin on-chip MAC support" 832 tristate "Blackfin on-chip MAC support"
833 depends on NET_ETHERNET && (BF526 || BF527 || BF536 || BF537) 833 depends on NET_ETHERNET && (BF516 || BF518 || BF526 || BF527 || BF536 || BF537)
834 select CRC32 834 select CRC32
835 select MII 835 select MII
836 select PHYLIB 836 select PHYLIB
@@ -1600,7 +1600,7 @@ config 8139_OLD_RX_RESET
1600 old RX-reset behavior. If unsure, say N. 1600 old RX-reset behavior. If unsure, say N.
1601 1601
1602config R6040 1602config R6040
1603 tristate "RDC R6040 Fast Ethernet Adapter support (EXPERIMENTAL)" 1603 tristate "RDC R6040 Fast Ethernet Adapter support"
1604 depends on NET_PCI && PCI 1604 depends on NET_PCI && PCI
1605 select CRC32 1605 select CRC32
1606 select MII 1606 select MII
@@ -2614,6 +2614,8 @@ source "drivers/net/tokenring/Kconfig"
2614 2614
2615source "drivers/net/wireless/Kconfig" 2615source "drivers/net/wireless/Kconfig"
2616 2616
2617source "drivers/net/wimax/Kconfig"
2618
2617source "drivers/net/usb/Kconfig" 2619source "drivers/net/usb/Kconfig"
2618 2620
2619source "drivers/net/pcmcia/Kconfig" 2621source "drivers/net/pcmcia/Kconfig"
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index e5c34b464211..a3c5c002f224 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -263,3 +263,4 @@ obj-$(CONFIG_NIU) += niu.o
263obj-$(CONFIG_VIRTIO_NET) += virtio_net.o 263obj-$(CONFIG_VIRTIO_NET) += virtio_net.o
264obj-$(CONFIG_SFC) += sfc/ 264obj-$(CONFIG_SFC) += sfc/
265 265
266obj-$(CONFIG_WIMAX) += wimax/
diff --git a/drivers/net/acenic.c b/drivers/net/acenic.c
index 5b396ff6c83f..9589d620639d 100644
--- a/drivers/net/acenic.c
+++ b/drivers/net/acenic.c
@@ -460,6 +460,7 @@ static const struct net_device_ops ace_netdev_ops = {
460 .ndo_get_stats = ace_get_stats, 460 .ndo_get_stats = ace_get_stats,
461 .ndo_start_xmit = ace_start_xmit, 461 .ndo_start_xmit = ace_start_xmit,
462 .ndo_set_multicast_list = ace_set_multicast_list, 462 .ndo_set_multicast_list = ace_set_multicast_list,
463 .ndo_validate_addr = eth_validate_addr,
463 .ndo_set_mac_address = ace_set_mac_addr, 464 .ndo_set_mac_address = ace_set_mac_addr,
464 .ndo_change_mtu = ace_change_mtu, 465 .ndo_change_mtu = ace_change_mtu,
465#if ACENIC_DO_VLAN 466#if ACENIC_DO_VLAN
diff --git a/drivers/net/acenic_firmware.h b/drivers/net/acenic_firmware.h
deleted file mode 100644
index fd41f7887e27..000000000000
--- a/drivers/net/acenic_firmware.h
+++ /dev/null
@@ -1,9456 +0,0 @@
1/*
2 * Declare these here even if Tigon I support is disabled to avoid
3 * the compiler complaining about undefined symbols.
4 */
5#define tigonFwReleaseMajor 0xc
6#define tigonFwReleaseMinor 0x4
7#define tigonFwReleaseFix 0xb
8#define tigonFwStartAddr 0x00004000
9#define tigonFwTextAddr 0x00004000
10#define tigonFwTextLen 0x11140
11#define tigonFwRodataAddr 0x00015140
12#define tigonFwRodataLen 0xac0
13#define tigonFwDataAddr 0x00015c20
14#define tigonFwDataLen 0x170
15#define tigonFwSbssAddr 0x00015d90
16#define tigonFwSbssLen 0x38
17#define tigonFwBssAddr 0x00015dd0
18#define tigonFwBssLen 0x2080
19#ifdef CONFIG_ACENIC_OMIT_TIGON_I
20#define tigonFwText NULL
21#define tigonFwData NULL
22#define tigonFwRodata NULL
23#else
24/* Generated by genfw.c */
25static u32 tigonFwText[(MAX_TEXT_LEN/4) + 1] __devinitdata = {
260x10000003,
270x0, 0xd, 0xd, 0x3c1d0001,
280x8fbd5c54, 0x3a0f021, 0x3c100000, 0x26104000,
290xc00100c, 0x0, 0xd, 0x27bdffd8,
300x3c1cc000, 0x3c1b0013, 0x377bd800, 0xd021,
310x3c170013, 0x36f75418, 0x2e02021, 0x340583e8,
320xafbf0024, 0xc002488, 0xafb00020, 0xc0023e8,
330x0, 0x3c040001, 0x248451a4, 0x24050001,
340x2e03021, 0x3821, 0x3c100001, 0x26107e50,
350xafb00010, 0xc002403, 0xafbb0014, 0x3c02000f,
360x3442ffff, 0x2021024, 0x362102b, 0x10400009,
370x24050003, 0x3c040001, 0x248451b0, 0x2003021,
380x3603821, 0x3c020010, 0xafa20010, 0xc002403,
390xafa00014, 0x2021, 0x3405c000, 0x3c010001,
400x370821, 0xa02083b0, 0x3c010001, 0x370821,
410xa02083b2, 0x3c010001, 0x370821, 0xa02083b3,
420x3c010001, 0x370821, 0xac2083b4, 0xa2e004d8,
430x418c0, 0x24840001, 0x771021, 0xac40727c,
440x771021, 0xac407280, 0x2e31021, 0xa445727c,
450x2c820020, 0x1440fff7, 0x418c0, 0x2021,
460x3405c000, 0x418c0, 0x24840001, 0x771021,
470xac40737c, 0x771021, 0xac407380, 0x2e31021,
480xa445737c, 0x2c820080, 0x5440fff7, 0x418c0,
490xaf800054, 0xaf80011c, 0x8f820044, 0x34420040,
500xaf820044, 0x8f820044, 0x34420020, 0xaf820044,
510x8f420218, 0x30420002, 0x10400009, 0x0,
520x8f420220, 0x3c030002, 0x34630004, 0x431025,
530xaee204c4, 0x8f42021c, 0x8001074, 0x34420004,
540x8f420220, 0x3c030002, 0x34630006, 0x431025,
550xaee204c4, 0x8f42021c, 0x34420006, 0xaee204cc,
560x8f420218, 0x30420010, 0x1040000a, 0x0,
570x8f42021c, 0x34420004, 0xaee204c8, 0x8f420220,
580x3c03000a, 0x34630004, 0x431025, 0x800108a,
590xaee204c0, 0x8f420220, 0x3c03000a, 0x34630006,
600x431025, 0xaee204c0, 0x8f42021c, 0x34420006,
610xaee204c8, 0x8f420218, 0x30420200, 0x10400003,
620x24020001, 0x8001091, 0xa2e27248, 0xa2e07248,
630x24020001, 0xaf8200a0, 0xaf8200b0, 0x8f830054,
640x8f820054, 0x8001099, 0x24630064, 0x8f820054,
650x621023, 0x2c420065, 0x1440fffc, 0x0,
660xaf800044, 0x8f420208, 0x8f43020c, 0xaee20010,
670xaee30014, 0x8ee40010, 0x8ee50014, 0x26e20030,
680xaee20028, 0x24020490, 0xaee20018, 0xaf840090,
690xaf850094, 0x8ee20028, 0xaf8200b4, 0x96e2001a,
700xaf82009c, 0x8f8200b0, 0x8ee304cc, 0x431025,
710xaf8200b0, 0x8f8200b0, 0x30420004, 0x1440fffd,
720x0, 0x8ee20450, 0x8ee30454, 0xaee304fc,
730x8ee204fc, 0x2442e000, 0x2c422001, 0x1440000d,
740x26e40030, 0x8ee20450, 0x8ee30454, 0x3c040001,
750x248451bc, 0x3c050001, 0xafa00010, 0xafa00014,
760x8ee704fc, 0x34a5f000, 0xc002403, 0x603021,
770x26e40030, 0xc002488, 0x24050400, 0x27440080,
780xc002488, 0x24050080, 0x26e4777c, 0xc002488,
790x24050400, 0x8f42025c, 0x26e40094, 0xaee20060,
800x8f420260, 0x27450200, 0x24060008, 0xaee20068,
810x24020006, 0xc00249a, 0xaee20064, 0x3c023b9a,
820x3442ca00, 0x2021, 0x24030002, 0xaee30074,
830xaee30070, 0xaee2006c, 0x240203e8, 0xaee20104,
840x24020001, 0xaee30100, 0xaee2010c, 0x3c030001,
850x641821, 0x90635c20, 0x2e41021, 0x24840001,
860xa043009c, 0x2c82000f, 0x1440fff8, 0x0,
870x8f820040, 0x2e41821, 0x24840001, 0x21702,
880x24420030, 0xa062009c, 0x2e41021, 0xa040009c,
890x96e2046a, 0x30420003, 0x14400009, 0x0,
900x96e2047a, 0x30420003, 0x50400131, 0x3c030800,
910x96e2046a, 0x30420003, 0x1040002a, 0x3c020700,
920x96e2047a, 0x30420003, 0x10400026, 0x3c020700,
930x96e3047a, 0x96e2046a, 0x14620022, 0x3c020700,
940x8ee204c0, 0x24030001, 0xa2e34e20, 0x34420e00,
950xaee204c0, 0x8f420218, 0x30420100, 0x10400005,
960x0, 0x3c020001, 0x2442e168, 0x800111d,
970x21100, 0x3c020001, 0x2442d35c, 0x21100,
980x21182, 0x3c030800, 0x431025, 0x3c010001,
990xac221238, 0x3c020001, 0x2442f680, 0x21100,
1000x21182, 0x3c030800, 0x431025, 0x3c010001,
1010xac221278, 0x8ee20000, 0x34424000, 0x8001238,
1020xaee20000, 0x34423000, 0xafa20018, 0x8ee20608,
1030x8f430228, 0x24420001, 0x304900ff, 0x512300e2,
1040xafa00010, 0x8ee20608, 0x210c0, 0x571021,
1050x8fa30018, 0x8fa4001c, 0xac43060c, 0xac440610,
1060x8f870120, 0x27623800, 0x24e80020, 0x102102b,
1070x50400001, 0x27683000, 0x8f820128, 0x11020004,
1080x0, 0x8f820124, 0x15020007, 0x1021,
1090x8ee201a4, 0x3021, 0x24420001, 0xaee201a4,
1100x80011a0, 0x8ee201a4, 0x8ee40608, 0x420c0,
1110x801821, 0x8ee40430, 0x8ee50434, 0xa32821,
1120xa3302b, 0x822021, 0x862021, 0xace40000,
1130xace50004, 0x8ee30608, 0x24020008, 0xa4e2000e,
1140x2402000d, 0xace20018, 0xace9001c, 0x318c0,
1150x2463060c, 0x2e31021, 0xace20008, 0x8ee204c4,
1160xace20010, 0xaf880120, 0x92e24e20, 0x14400037,
1170x24060001, 0x8ee24e30, 0x210c0, 0x24425038,
1180x2e22021, 0x8c830000, 0x24020007, 0x1462001f,
1190x0, 0x8ee34e30, 0x8ee24e34, 0x1062001b,
1200x24030040, 0x8c820004, 0x24420001, 0xac820004,
1210x8ee24e34, 0x8ee54e30, 0x24420001, 0x10430007,
1220x0, 0x8ee24e34, 0x24420001, 0x10a20005,
1230x0, 0x800118a, 0x0, 0x14a00005,
1240x0, 0x8f820128, 0x24420020, 0xaf820128,
1250x8f820128, 0x8c820004, 0x2c420011, 0x50400013,
1260xac800000, 0x80011a0, 0x0, 0x8ee24e30,
1270x24030040, 0x24420001, 0x50430003, 0x1021,
1280x8ee24e30, 0x24420001, 0xaee24e30, 0x8ee24e30,
1290x210c0, 0x24425038, 0x2e22021, 0x24020007,
1300xac820000, 0x24020001, 0xac820004, 0x54c0000c,
1310xaee90608, 0x3c040001, 0x248451c8, 0xafa00010,
1320xafa00014, 0x8ee60608, 0x8f470228, 0x3c050009,
1330xc002403, 0x34a5f000, 0x8001223, 0x0,
1340x8f830120, 0x27623800, 0x24660020, 0xc2102b,
1350x50400001, 0x27663000, 0x8f820128, 0x10c20004,
1360x0, 0x8f820124, 0x14c20007, 0x0,
1370x8ee201a4, 0x3021, 0x24420001, 0xaee201a4,
1380x8001207, 0x8ee201a4, 0x8ee20608, 0xac62001c,
1390x8ee404a0, 0x8ee504a4, 0x2462001c, 0xac620008,
1400x24020008, 0xa462000e, 0x24020011, 0xac620018,
1410xac640000, 0xac650004, 0x8ee204c4, 0xac620010,
1420xaf860120, 0x92e24e20, 0x14400037, 0x24060001,
1430x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
1440x8c830000, 0x24020012, 0x1462001f, 0x0,
1450x8ee34e30, 0x8ee24e34, 0x1062001b, 0x24030040,
1460x8c820004, 0x24420001, 0xac820004, 0x8ee24e34,
1470x8ee54e30, 0x24420001, 0x10430007, 0x0,
1480x8ee24e34, 0x24420001, 0x10a20005, 0x0,
1490x80011f1, 0x0, 0x14a00005, 0x0,
1500x8f820128, 0x24420020, 0xaf820128, 0x8f820128,
1510x8c820004, 0x2c420011, 0x50400013, 0xac800000,
1520x8001207, 0x0, 0x8ee24e30, 0x24030040,
1530x24420001, 0x50430003, 0x1021, 0x8ee24e30,
1540x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
1550x24425038, 0x2e22021, 0x24020012, 0xac820000,
1560x24020001, 0xac820004, 0x14c0001b, 0x0,
1570x3c040001, 0x248451d0, 0xafa00010, 0xafa00014,
1580x8ee60608, 0x8f470228, 0x3c050009, 0xc002403,
1590x34a5f001, 0x8ee201b0, 0x24420001, 0xaee201b0,
1600x8001223, 0x8ee201b0, 0x3c040001, 0x248451dc,
1610xafa00014, 0x8ee60608, 0x8f470228, 0x3c050009,
1620xc002403, 0x34a5f005, 0x8ee201ac, 0x24420001,
1630xaee201ac, 0x8ee201ac, 0x8ee20160, 0x3c040001,
1640x248451e8, 0x3405f001, 0x24420001, 0xaee20160,
1650x8ee20160, 0x3021, 0x3821, 0xafa00010,
1660xc002403, 0xafa00014, 0x8001238, 0x0,
1670x3c020001, 0x2442f5a8, 0x21100, 0x21182,
1680x431025, 0x3c010001, 0xac221278, 0x96e2045a,
1690x30420003, 0x10400025, 0x3c050fff, 0x8ee204c8,
1700x34a5ffff, 0x34420a00, 0xaee204c8, 0x8ee304c8,
1710x3c040001, 0x248451f4, 0x24020001, 0xa2e204ec,
1720xa2e204ed, 0x3c020002, 0x621825, 0x3c020001,
1730x2442a390, 0x451024, 0x21082, 0xaee304c8,
1740x3c030800, 0x431025, 0x3c010001, 0xac221220,
1750x3c020001, 0x2442add4, 0x451024, 0x21082,
1760x431025, 0x3c010001, 0xac221280, 0x96e6045a,
1770x3821, 0x24050011, 0xafa00010, 0xc002403,
1780xafa00014, 0x8001268, 0x0, 0x3c020001,
1790x2442a9d4, 0x21100, 0x21182, 0x3c030800,
1800x431025, 0x3c010001, 0xac221280, 0x96e2046a,
1810x30420010, 0x14400009, 0x0, 0x96e2047a,
1820x30420010, 0x10400112, 0x0, 0x96e2046a,
1830x30420010, 0x10400005, 0x3c020700, 0x96e2047a,
1840x30420010, 0x14400102, 0x3c020700, 0x34423000,
1850xafa20018, 0x8ee20608, 0x8f430228, 0x24420001,
1860x304900ff, 0x512300e2, 0xafa00010, 0x8ee20608,
1870x210c0, 0x571021, 0x8fa30018, 0x8fa4001c,
1880xac43060c, 0xac440610, 0x8f870120, 0x27623800,
1890x24e80020, 0x102102b, 0x50400001, 0x27683000,
1900x8f820128, 0x11020004, 0x0, 0x8f820124,
1910x15020007, 0x1021, 0x8ee201a4, 0x3021,
1920x24420001, 0xaee201a4, 0x80012ea, 0x8ee201a4,
1930x8ee40608, 0x420c0, 0x801821, 0x8ee40430,
1940x8ee50434, 0xa32821, 0xa3302b, 0x822021,
1950x862021, 0xace40000, 0xace50004, 0x8ee30608,
1960x24020008, 0xa4e2000e, 0x2402000d, 0xace20018,
1970xace9001c, 0x318c0, 0x2463060c, 0x2e31021,
1980xace20008, 0x8ee204c4, 0xace20010, 0xaf880120,
1990x92e24e20, 0x14400037, 0x24060001, 0x8ee24e30,
2000x210c0, 0x24425038, 0x2e22021, 0x8c830000,
2010x24020007, 0x1462001f, 0x0, 0x8ee34e30,
2020x8ee24e34, 0x1062001b, 0x24030040, 0x8c820004,
2030x24420001, 0xac820004, 0x8ee24e34, 0x8ee54e30,
2040x24420001, 0x10430007, 0x0, 0x8ee24e34,
2050x24420001, 0x10a20005, 0x0, 0x80012d4,
2060x0, 0x14a00005, 0x0, 0x8f820128,
2070x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
2080x2c420011, 0x50400013, 0xac800000, 0x80012ea,
2090x0, 0x8ee24e30, 0x24030040, 0x24420001,
2100x50430003, 0x1021, 0x8ee24e30, 0x24420001,
2110xaee24e30, 0x8ee24e30, 0x210c0, 0x24425038,
2120x2e22021, 0x24020007, 0xac820000, 0x24020001,
2130xac820004, 0x54c0000c, 0xaee90608, 0x3c040001,
2140x248451c8, 0xafa00010, 0xafa00014, 0x8ee60608,
2150x8f470228, 0x3c050009, 0xc002403, 0x34a5f000,
2160x800136d, 0x0, 0x8f830120, 0x27623800,
2170x24660020, 0xc2102b, 0x50400001, 0x27663000,
2180x8f820128, 0x10c20004, 0x0, 0x8f820124,
2190x14c20007, 0x0, 0x8ee201a4, 0x3021,
2200x24420001, 0xaee201a4, 0x8001351, 0x8ee201a4,
2210x8ee20608, 0xac62001c, 0x8ee404a0, 0x8ee504a4,
2220x2462001c, 0xac620008, 0x24020008, 0xa462000e,
2230x24020011, 0xac620018, 0xac640000, 0xac650004,
2240x8ee204c4, 0xac620010, 0xaf860120, 0x92e24e20,
2250x14400037, 0x24060001, 0x8ee24e30, 0x210c0,
2260x24425038, 0x2e22021, 0x8c830000, 0x24020012,
2270x1462001f, 0x0, 0x8ee34e30, 0x8ee24e34,
2280x1062001b, 0x24030040, 0x8c820004, 0x24420001,
2290xac820004, 0x8ee24e34, 0x8ee54e30, 0x24420001,
2300x10430007, 0x0, 0x8ee24e34, 0x24420001,
2310x10a20005, 0x0, 0x800133b, 0x0,
2320x14a00005, 0x0, 0x8f820128, 0x24420020,
2330xaf820128, 0x8f820128, 0x8c820004, 0x2c420011,
2340x50400013, 0xac800000, 0x8001351, 0x0,
2350x8ee24e30, 0x24030040, 0x24420001, 0x50430003,
2360x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
2370x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
2380x24020012, 0xac820000, 0x24020001, 0xac820004,
2390x14c0001b, 0x0, 0x3c040001, 0x248451d0,
2400xafa00010, 0xafa00014, 0x8ee60608, 0x8f470228,
2410x3c050009, 0xc002403, 0x34a5f001, 0x8ee201b0,
2420x24420001, 0xaee201b0, 0x800136d, 0x8ee201b0,
2430x3c040001, 0x248451dc, 0xafa00014, 0x8ee60608,
2440x8f470228, 0x3c050009, 0xc002403, 0x34a5f005,
2450x8ee201ac, 0x24420001, 0xaee201ac, 0x8ee201ac,
2460x8ee20160, 0x3c040001, 0x248451e8, 0x3405f002,
2470x24420001, 0xaee20160, 0x8ee20160, 0x3021,
2480x3821, 0xafa00010, 0xc002403, 0xafa00014,
2490x96e6047a, 0x96e7046a, 0x3c040001, 0x24845200,
2500x24050012, 0xafa00010, 0xc002403, 0xafa00014,
2510xc004500, 0x0, 0xc002318, 0x0,
2520x3c060001, 0x34c63800, 0xaee00608, 0xaf400228,
2530xaf40022c, 0x96e30458, 0x8ee40000, 0x3c0512d8,
2540x34a5c358, 0x27623800, 0xaee27258, 0x27623800,
2550xaee27260, 0x27623800, 0xaee27264, 0x3661021,
2560xaee27270, 0x2402ffff, 0xaee004d4, 0xaee004e0,
2570xaee004e4, 0xaee004f0, 0xa2e004f4, 0xaee00e0c,
2580xaee00e18, 0xaee00e10, 0xaee00e14, 0xaee00e1c,
2590xaee0724c, 0xaee05244, 0xaee05240, 0xaee0523c,
2600xaee07250, 0xaee07254, 0xaee0725c, 0xaee07268,
2610xaee004d0, 0x2463ffff, 0x852025, 0xaee304f8,
2620xaee40000, 0xaf800060, 0xaf820064, 0x3c020100,
2630xafa20018, 0x8ee20608, 0x8f430228, 0x24420001,
2640x304900ff, 0x512300e2, 0xafa00010, 0x8ee20608,
2650x210c0, 0x571021, 0x8fa30018, 0x8fa4001c,
2660xac43060c, 0xac440610, 0x8f870120, 0x27623800,
2670x24e80020, 0x102102b, 0x50400001, 0x27683000,
2680x8f820128, 0x11020004, 0x0, 0x8f820124,
2690x15020007, 0x1021, 0x8ee201a4, 0x3021,
2700x24420001, 0xaee201a4, 0x8001422, 0x8ee201a4,
2710x8ee40608, 0x420c0, 0x801821, 0x8ee40430,
2720x8ee50434, 0xa32821, 0xa3302b, 0x822021,
2730x862021, 0xace40000, 0xace50004, 0x8ee30608,
2740x24020008, 0xa4e2000e, 0x2402000d, 0xace20018,
2750xace9001c, 0x318c0, 0x2463060c, 0x2e31021,
2760xace20008, 0x8ee204c4, 0xace20010, 0xaf880120,
2770x92e24e20, 0x14400037, 0x24060001, 0x8ee24e30,
2780x210c0, 0x24425038, 0x2e22021, 0x8c830000,
2790x24020007, 0x1462001f, 0x0, 0x8ee34e30,
2800x8ee24e34, 0x1062001b, 0x24030040, 0x8c820004,
2810x24420001, 0xac820004, 0x8ee24e34, 0x8ee54e30,
2820x24420001, 0x10430007, 0x0, 0x8ee24e34,
2830x24420001, 0x10a20005, 0x0, 0x800140c,
2840x0, 0x14a00005, 0x0, 0x8f820128,
2850x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
2860x2c420011, 0x50400013, 0xac800000, 0x8001422,
2870x0, 0x8ee24e30, 0x24030040, 0x24420001,
2880x50430003, 0x1021, 0x8ee24e30, 0x24420001,
2890xaee24e30, 0x8ee24e30, 0x210c0, 0x24425038,
2900x2e22021, 0x24020007, 0xac820000, 0x24020001,
2910xac820004, 0x54c0000c, 0xaee90608, 0x3c040001,
2920x248451c8, 0xafa00010, 0xafa00014, 0x8ee60608,
2930x8f470228, 0x3c050009, 0xc002403, 0x34a5f000,
2940x80014a5, 0x0, 0x8f830120, 0x27623800,
2950x24660020, 0xc2102b, 0x50400001, 0x27663000,
2960x8f820128, 0x10c20004, 0x0, 0x8f820124,
2970x14c20007, 0x0, 0x8ee201a4, 0x3021,
2980x24420001, 0xaee201a4, 0x8001489, 0x8ee201a4,
2990x8ee20608, 0xac62001c, 0x8ee404a0, 0x8ee504a4,
3000x2462001c, 0xac620008, 0x24020008, 0xa462000e,
3010x24020011, 0xac620018, 0xac640000, 0xac650004,
3020x8ee204c4, 0xac620010, 0xaf860120, 0x92e24e20,
3030x14400037, 0x24060001, 0x8ee24e30, 0x210c0,
3040x24425038, 0x2e22021, 0x8c830000, 0x24020012,
3050x1462001f, 0x0, 0x8ee34e30, 0x8ee24e34,
3060x1062001b, 0x24030040, 0x8c820004, 0x24420001,
3070xac820004, 0x8ee24e34, 0x8ee54e30, 0x24420001,
3080x10430007, 0x0, 0x8ee24e34, 0x24420001,
3090x10a20005, 0x0, 0x8001473, 0x0,
3100x14a00005, 0x0, 0x8f820128, 0x24420020,
3110xaf820128, 0x8f820128, 0x8c820004, 0x2c420011,
3120x50400013, 0xac800000, 0x8001489, 0x0,
3130x8ee24e30, 0x24030040, 0x24420001, 0x50430003,
3140x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
3150x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
3160x24020012, 0xac820000, 0x24020001, 0xac820004,
3170x14c0001b, 0x0, 0x3c040001, 0x248451d0,
3180xafa00010, 0xafa00014, 0x8ee60608, 0x8f470228,
3190x3c050009, 0xc002403, 0x34a5f001, 0x8ee201b0,
3200x24420001, 0xaee201b0, 0x80014a5, 0x8ee201b0,
3210x3c040001, 0x248451dc, 0xafa00014, 0x8ee60608,
3220x8f470228, 0x3c050009, 0xc002403, 0x34a5f005,
3230x8ee201ac, 0x24420001, 0xaee201ac, 0x8ee201ac,
3240x8ee20154, 0x24420001, 0xaee20154, 0xc0014dc,
3250x8ee20154, 0x8f8200a0, 0x30420004, 0x1440fffd,
3260x0, 0x8f820040, 0x30420001, 0x14400008,
3270x0, 0x8f430104, 0x24020001, 0x10620004,
3280x0, 0x8f420264, 0x10400006, 0x0,
3290x8ee2017c, 0x24420001, 0xaee2017c, 0x80014c5,
3300x8ee2017c, 0x8f820044, 0x34420004, 0xaf820044,
3310x8ee20178, 0x24420001, 0xaee20178, 0x8ee20178,
3320x8f8200d8, 0x8f8300d4, 0x431023, 0xaee2726c,
3330x8ee2726c, 0x1c400003, 0x3c030001, 0x431021,
3340xaee2726c, 0xc004064, 0x0, 0xc004440,
3350xaf800228, 0x8fbf0024, 0x8fb00020, 0x3e00008,
3360x27bd0028, 0x3e00008, 0x0, 0x3e00008,
3370x0, 0x0, 0x0, 0x2402002c,
3380xaf820050, 0xaee07274, 0x8f420238, 0xaee27278,
3390x8f820054, 0x24420067, 0xaf820058, 0xaee07b88,
3400xaee07b8c, 0xaee07b84, 0x3c010001, 0x370821,
3410xac2083bc, 0x3c010001, 0x370821, 0x3e00008,
3420xa02083b9, 0x27bdffd8, 0xafbf0024, 0xafb00020,
3430x8f820054, 0x3c030001, 0x8c635cd8, 0x24420067,
3440x1060000d, 0xaf820058, 0x3c020001, 0x571021,
3450x904283b8, 0x10400005, 0x3c030200, 0x3c010001,
3460x370821, 0x8001503, 0xa02083b8, 0x8ee20000,
3470x431025, 0xaee20000, 0x8f420218, 0x30420100,
3480x104000c6, 0x0, 0x8f8200b0, 0x30420004,
3490x104000c2, 0x0, 0x3c030001, 0x771821,
3500x8c6383d0, 0x8f820104, 0x146200b4, 0x0,
3510x3c030001, 0x771821, 0x8c6383d4, 0x8f8200b4,
3520x146200ae, 0x0, 0x8f8200b0, 0x3c030080,
3530x431024, 0x1040000d, 0x0, 0x8f82011c,
3540x34420002, 0xaf82011c, 0x8f8200b0, 0x2403fffb,
3550x431024, 0xaf8200b0, 0x8f82011c, 0x2403fffd,
3560x431024, 0x80015cc, 0xaf82011c, 0x3c030001,
3570x771821, 0x8c6383d0, 0x8f820104, 0x14620082,
3580x0, 0x3c030001, 0x771821, 0x8c6383d4,
3590x8f8200b4, 0x1462007c, 0x0, 0x3c070001,
3600xf73821, 0x8ce783d0, 0x8f8200b0, 0x3c040001,
3610x24845270, 0xafa00014, 0xafa20010, 0x8f8600b0,
3620x3c050005, 0xc002403, 0x34a50900, 0x8f82011c,
3630x34420002, 0xaf82011c, 0x8f830104, 0x8f8200b0,
3640x34420001, 0xaf8200b0, 0xaf830104, 0x8f830120,
3650x27623800, 0x24660020, 0xc2102b, 0x50400001,
3660x27663000, 0x8f820128, 0x10c20004, 0x0,
3670x8f820124, 0x14c20006, 0x0, 0x8ee201a4,
3680x24420001, 0xaee201a4, 0x80015a0, 0x8ee201a4,
3690x8f440208, 0x8f45020c, 0x26e20030, 0xac620008,
3700x24020400, 0xa462000e, 0x2402000f, 0xac620018,
3710xac60001c, 0xac640000, 0xac650004, 0x8ee204c4,
3720xac620010, 0xaf860120, 0x92e24e20, 0x14400037,
3730x0, 0x8ee24e30, 0x210c0, 0x24425038,
3740x2e22021, 0x8c830000, 0x24020007, 0x1462001f,
3750x0, 0x8ee34e30, 0x8ee24e34, 0x1062001b,
3760x24030040, 0x8c820004, 0x24420001, 0xac820004,
3770x8ee24e34, 0x8ee54e30, 0x24420001, 0x10430007,
3780x0, 0x8ee24e34, 0x24420001, 0x10a20005,
3790x0, 0x800158a, 0x0, 0x14a00005,
3800x0, 0x8f820128, 0x24420020, 0xaf820128,
3810x8f820128, 0x8c820004, 0x2c420011, 0x50400013,
3820xac800000, 0x80015a0, 0x0, 0x8ee24e30,
3830x24030040, 0x24420001, 0x50430003, 0x1021,
3840x8ee24e30, 0x24420001, 0xaee24e30, 0x8ee24e30,
3850x210c0, 0x24425038, 0x2e22021, 0x24020007,
3860xac820000, 0x24020001, 0xac820004, 0x8f82011c,
3870x2403fffd, 0x431024, 0xaf82011c, 0x8ee201e4,
3880x3c070001, 0xf73821, 0x8ce783d0, 0x24420001,
3890xaee201e4, 0x8ee201e4, 0x3c040001, 0x2484527c,
3900x80015bd, 0xafa00010, 0x8f820104, 0x3c010001,
3910x370821, 0xac2283d0, 0x8f8200b4, 0x3c070001,
3920xf73821, 0x8ce783d0, 0x3c040001, 0x24845284,
3930x3c010001, 0x370821, 0xac2283d4, 0xafa00010,
3940xafa00014, 0x8f8600b0, 0x3c050005, 0xc002403,
3950x34a50900, 0x80015cc, 0x0, 0x8f820104,
3960x3c010001, 0x370821, 0xac2283d0, 0x8f8200b4,
3970x3c010001, 0x370821, 0xac2283d4, 0x8ee27274,
3980x92e304f4, 0x24420067, 0x14600006, 0xaee27274,
3990x8ee27274, 0x8f430234, 0x43102b, 0x1440007b,
4000x0, 0x8ee304e4, 0x8ee204f8, 0x14620004,
4010x0, 0x92e204f4, 0x50400074, 0xa2e004f4,
4020x8f830120, 0x27623800, 0x24660020, 0xc2102b,
4030x50400001, 0x27663000, 0x8f820128, 0x10c20004,
4040x0, 0x8f820124, 0x14c20007, 0x0,
4050x8ee201a4, 0x8021, 0x24420001, 0xaee201a4,
4060x8001637, 0x8ee201a4, 0x8ee204e4, 0xac62001c,
4070x8ee404b0, 0x8ee504b4, 0x2462001c, 0xac620008,
4080x24020008, 0xa462000e, 0x24020011, 0xac620018,
4090xac640000, 0xac650004, 0x8ee204c4, 0xac620010,
4100xaf860120, 0x92e24e20, 0x14400037, 0x24100001,
4110x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
4120x8c830000, 0x24020012, 0x1462001f, 0x0,
4130x8ee34e30, 0x8ee24e34, 0x1062001b, 0x24030040,
4140x8c820004, 0x24420001, 0xac820004, 0x8ee24e34,
4150x8ee54e30, 0x24420001, 0x10430007, 0x0,
4160x8ee24e34, 0x24420001, 0x10a20005, 0x0,
4170x8001621, 0x0, 0x14a00005, 0x0,
4180x8f820128, 0x24420020, 0xaf820128, 0x8f820128,
4190x8c820004, 0x2c420011, 0x50400013, 0xac800000,
4200x8001637, 0x0, 0x8ee24e30, 0x24030040,
4210x24420001, 0x50430003, 0x1021, 0x8ee24e30,
4220x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
4230x24425038, 0x2e22021, 0x24020012, 0xac820000,
4240x24020001, 0xac820004, 0x5600000b, 0x24100001,
4250x8ee204e4, 0x3c040001, 0x2484528c, 0xafa00014,
4260xafa20010, 0x8ee60608, 0x8f470228, 0x3c050009,
4270xc002403, 0x34a5f006, 0x16000003, 0x24020001,
4280x8001650, 0xa2e204f4, 0x8ee20170, 0x24420001,
4290xaee20170, 0x8ee20170, 0x8ee204e4, 0xa2e004f4,
4300xaee004f0, 0xaee07274, 0xaee204f8, 0x8ee20e1c,
4310x1040006d, 0x0, 0x8f830120, 0x27623800,
4320x24660020, 0xc2102b, 0x50400001, 0x27663000,
4330x8f820128, 0x10c20004, 0x0, 0x8f820124,
4340x14c20007, 0x0, 0x8ee201a4, 0x8021,
4350x24420001, 0xaee201a4, 0x80016ad, 0x8ee201a4,
4360x8ee2724c, 0xac62001c, 0x8ee404a8, 0x8ee504ac,
4370x2462001c, 0xac620008, 0x24020008, 0xa462000e,
4380x24020011, 0xac620018, 0xac640000, 0xac650004,
4390x8ee204c4, 0xac620010, 0xaf860120, 0x92e24e20,
4400x14400037, 0x24100001, 0x8ee24e30, 0x210c0,
4410x24425038, 0x2e22021, 0x8c830000, 0x24020012,
4420x1462001f, 0x0, 0x8ee34e30, 0x8ee24e34,
4430x1062001b, 0x24030040, 0x8c820004, 0x24420001,
4440xac820004, 0x8ee24e34, 0x8ee54e30, 0x24420001,
4450x10430007, 0x0, 0x8ee24e34, 0x24420001,
4460x10a20005, 0x0, 0x8001697, 0x0,
4470x14a00005, 0x0, 0x8f820128, 0x24420020,
4480xaf820128, 0x8f820128, 0x8c820004, 0x2c420011,
4490x50400013, 0xac800000, 0x80016ad, 0x0,
4500x8ee24e30, 0x24030040, 0x24420001, 0x50430003,
4510x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
4520x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
4530x24020012, 0xac820000, 0x24020001, 0xac820004,
4540x5600000b, 0x24100001, 0x8ee2724c, 0x3c040001,
4550x24845298, 0xafa00014, 0xafa20010, 0x8ee6724c,
4560x8f470280, 0x3c050009, 0xc002403, 0x34a5f008,
4570x56000001, 0xaee00e1c, 0x8ee20174, 0x24420001,
4580xaee20174, 0x8ee20174, 0x8ee24e24, 0x10400019,
4590x0, 0xaee04e24, 0x8f820040, 0x30420001,
4600x14400008, 0x0, 0x8f430104, 0x24020001,
4610x10620004, 0x0, 0x8f420264, 0x10400006,
4620x0, 0x8ee2017c, 0x24420001, 0xaee2017c,
4630x80016da, 0x8ee2017c, 0x8f820044, 0x34420004,
4640xaf820044, 0x8ee20178, 0x24420001, 0xaee20178,
4650x8ee20178, 0x8ee27278, 0x2442ff99, 0xaee27278,
4660x8ee27278, 0x1c4002ad, 0x0, 0x8f420238,
4670x104002aa, 0x0, 0x3c020001, 0x571021,
4680x904283e0, 0x144002a5, 0x0, 0x8f420080,
4690xaee2004c, 0x8f4200c0, 0xaee20048, 0x8f420084,
4700xaee20038, 0x8f420084, 0xaee20244, 0x8f420088,
4710xaee20248, 0x8f42008c, 0xaee2024c, 0x8f420090,
4720xaee20250, 0x8f420094, 0xaee20254, 0x8f420098,
4730xaee20258, 0x8f42009c, 0xaee2025c, 0x8f4200a0,
4740xaee20260, 0x8f4200a4, 0xaee20264, 0x8f4200a8,
4750xaee20268, 0x8f4200ac, 0xaee2026c, 0x8f4200b0,
4760xaee20270, 0x8f4200b4, 0xaee20274, 0x8f4200b8,
4770xaee20278, 0x8f4200bc, 0x24040001, 0xaee2027c,
4780xaee0003c, 0x41080, 0x571021, 0x8ee3003c,
4790x8c420244, 0x24840001, 0x621821, 0x2c82000f,
4800xaee3003c, 0x1440fff8, 0x41080, 0x8f4200cc,
4810xaee20050, 0x8f4200d0, 0xaee20054, 0x8f830120,
4820x27623800, 0x24660020, 0xc2102b, 0x50400001,
4830x27663000, 0x8f820128, 0x10c20004, 0x0,
4840x8f820124, 0x14c20007, 0x0, 0x8ee201a4,
4850x8021, 0x24420001, 0xaee201a4, 0x8001775,
4860x8ee201a4, 0x8f440208, 0x8f45020c, 0x26e20030,
4870xac620008, 0x24020400, 0xa462000e, 0x2402000f,
4880xac620018, 0xac60001c, 0xac640000, 0xac650004,
4890x8ee204c4, 0xac620010, 0xaf860120, 0x92e24e20,
4900x14400037, 0x24100001, 0x8ee24e30, 0x210c0,
4910x24425038, 0x2e22021, 0x8c830000, 0x24020007,
4920x1462001f, 0x0, 0x8ee34e30, 0x8ee24e34,
4930x1062001b, 0x24030040, 0x8c820004, 0x24420001,
4940xac820004, 0x8ee24e34, 0x8ee54e30, 0x24420001,
4950x10430007, 0x0, 0x8ee24e34, 0x24420001,
4960x10a20005, 0x0, 0x800175f, 0x0,
4970x14a00005, 0x0, 0x8f820128, 0x24420020,
4980xaf820128, 0x8f820128, 0x8c820004, 0x2c420011,
4990x50400013, 0xac800000, 0x8001775, 0x0,
5000x8ee24e30, 0x24030040, 0x24420001, 0x50430003,
5010x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
5020x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
5030x24020007, 0xac820000, 0x24020001, 0xac820004,
5040x12000212, 0x3c020400, 0xafa20018, 0x3c020001,
5050x571021, 0x904283b0, 0x1040010b, 0x0,
5060x8ee20608, 0x8f430228, 0x24420001, 0x304a00ff,
5070x514300fd, 0xafa00010, 0x8ee20608, 0x210c0,
5080x571021, 0x8fa30018, 0x8fa4001c, 0xac43060c,
5090xac440610, 0x8f830054, 0x8f820054, 0x24690032,
5100x1221023, 0x2c420033, 0x1040006a, 0x5821,
5110x24180008, 0x240f000d, 0x240d0007, 0x240c0040,
5120x240e0001, 0x8f870120, 0x27623800, 0x24e80020,
5130x102102b, 0x50400001, 0x27683000, 0x8f820128,
5140x11020004, 0x0, 0x8f820124, 0x15020007,
5150x1021, 0x8ee201a4, 0x8021, 0x24420001,
5160xaee201a4, 0x80017f3, 0x8ee201a4, 0x8ee40608,
5170x420c0, 0x801821, 0x8ee40430, 0x8ee50434,
5180xa32821, 0xa3302b, 0x822021, 0x862021,
5190xace40000, 0xace50004, 0x8ee20608, 0xa4f8000e,
5200xacef0018, 0xacea001c, 0x210c0, 0x2442060c,
5210x2e21021, 0xace20008, 0x8ee204c4, 0xace20010,
5220xaf880120, 0x92e24e20, 0x14400033, 0x24100001,
5230x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
5240x8c820000, 0x144d001f, 0x0, 0x8ee34e30,
5250x8ee24e34, 0x1062001b, 0x0, 0x8c820004,
5260x24420001, 0xac820004, 0x8ee24e34, 0x8ee34e30,
5270x24420001, 0x104c0007, 0x0, 0x8ee24e34,
5280x24420001, 0x10620005, 0x0, 0x80017e0,
5290x0, 0x14600005, 0x0, 0x8f820128,
5300x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
5310x2c420011, 0x50400010, 0xac800000, 0x80017f3,
5320x0, 0x8ee24e30, 0x24420001, 0x504c0003,
5330x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
5340x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
5350xac8d0000, 0xac8e0004, 0x56000006, 0x240b0001,
5360x8f820054, 0x1221023, 0x2c420033, 0x1440ff9d,
5370x0, 0x316300ff, 0x24020001, 0x14620077,
5380x3c050009, 0xaeea0608, 0x8f830054, 0x8f820054,
5390x24690032, 0x1221023, 0x2c420033, 0x10400061,
5400x5821, 0x240d0008, 0x240c0011, 0x24080012,
5410x24070040, 0x240a0001, 0x8f830120, 0x27623800,
5420x24660020, 0xc2102b, 0x50400001, 0x27663000,
5430x8f820128, 0x10c20004, 0x0, 0x8f820124,
5440x14c20007, 0x0, 0x8ee201a4, 0x8021,
5450x24420001, 0xaee201a4, 0x800185f, 0x8ee201a4,
5460x8ee20608, 0xac62001c, 0x8ee404a0, 0x8ee504a4,
5470x2462001c, 0xac620008, 0xa46d000e, 0xac6c0018,
5480xac640000, 0xac650004, 0x8ee204c4, 0xac620010,
5490xaf860120, 0x92e24e20, 0x14400033, 0x24100001,
5500x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
5510x8c820000, 0x1448001f, 0x0, 0x8ee34e30,
5520x8ee24e34, 0x1062001b, 0x0, 0x8c820004,
5530x24420001, 0xac820004, 0x8ee24e34, 0x8ee34e30,
5540x24420001, 0x10470007, 0x0, 0x8ee24e34,
5550x24420001, 0x10620005, 0x0, 0x800184c,
5560x0, 0x14600005, 0x0, 0x8f820128,
5570x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
5580x2c420011, 0x50400010, 0xac800000, 0x800185f,
5590x0, 0x8ee24e30, 0x24420001, 0x50470003,
5600x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
5610x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
5620xac880000, 0xac8a0004, 0x56000006, 0x240b0001,
5630x8f820054, 0x1221023, 0x2c420033, 0x1440ffa6,
5640x0, 0x316300ff, 0x24020001, 0x14620003,
5650x3c050009, 0x800197c, 0x24100001, 0x3c040001,
5660x248452a4, 0xafa00010, 0xafa00014, 0x8f860120,
5670x8f870124, 0x800187b, 0x34a5f011, 0x3c040001,
5680x248452b0, 0xafa00010, 0xafa00014, 0x8f860120,
5690x8f870124, 0x34a5f010, 0xc002403, 0x8021,
5700x800197c, 0x0, 0x3c040001, 0x248452bc,
5710xafa00014, 0x8ee60608, 0x8f470228, 0x3c050009,
5720x8001975, 0x34a5f00f, 0x8ee20608, 0x8f430228,
5730x24420001, 0x304900ff, 0x512300e2, 0xafa00010,
5740x8ee20608, 0x210c0, 0x571021, 0x8fa30018,
5750x8fa4001c, 0xac43060c, 0xac440610, 0x8f870120,
5760x27623800, 0x24e80020, 0x102102b, 0x50400001,
5770x27683000, 0x8f820128, 0x11020004, 0x0,
5780x8f820124, 0x15020007, 0x1021, 0x8ee201a4,
5790x8021, 0x24420001, 0xaee201a4, 0x80018f7,
5800x8ee201a4, 0x8ee40608, 0x420c0, 0x801821,
5810x8ee40430, 0x8ee50434, 0xa32821, 0xa3302b,
5820x822021, 0x862021, 0xace40000, 0xace50004,
5830x8ee30608, 0x24020008, 0xa4e2000e, 0x2402000d,
5840xace20018, 0xace9001c, 0x318c0, 0x2463060c,
5850x2e31021, 0xace20008, 0x8ee204c4, 0xace20010,
5860xaf880120, 0x92e24e20, 0x14400037, 0x24100001,
5870x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
5880x8c830000, 0x24020007, 0x1462001f, 0x0,
5890x8ee34e30, 0x8ee24e34, 0x1062001b, 0x24030040,
5900x8c820004, 0x24420001, 0xac820004, 0x8ee24e34,
5910x8ee54e30, 0x24420001, 0x10430007, 0x0,
5920x8ee24e34, 0x24420001, 0x10a20005, 0x0,
5930x80018e1, 0x0, 0x14a00005, 0x0,
5940x8f820128, 0x24420020, 0xaf820128, 0x8f820128,
5950x8c820004, 0x2c420011, 0x50400013, 0xac800000,
5960x80018f7, 0x0, 0x8ee24e30, 0x24030040,
5970x24420001, 0x50430003, 0x1021, 0x8ee24e30,
5980x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
5990x24425038, 0x2e22021, 0x24020007, 0xac820000,
6000x24020001, 0xac820004, 0x5600000c, 0xaee90608,
6010x3c040001, 0x248452c8, 0xafa00010, 0xafa00014,
6020x8ee60608, 0x8f470228, 0x3c050009, 0xc002403,
6030x34a5f000, 0x800197c, 0x0, 0x8f830120,
6040x27623800, 0x24660020, 0xc2102b, 0x50400001,
6050x27663000, 0x8f820128, 0x10c20004, 0x0,
6060x8f820124, 0x14c20007, 0x0, 0x8ee201a4,
6070x8021, 0x24420001, 0xaee201a4, 0x800195e,
6080x8ee201a4, 0x8ee20608, 0xac62001c, 0x8ee404a0,
6090x8ee504a4, 0x2462001c, 0xac620008, 0x24020008,
6100xa462000e, 0x24020011, 0xac620018, 0xac640000,
6110xac650004, 0x8ee204c4, 0xac620010, 0xaf860120,
6120x92e24e20, 0x14400037, 0x24100001, 0x8ee24e30,
6130x210c0, 0x24425038, 0x2e22021, 0x8c830000,
6140x24020012, 0x1462001f, 0x0, 0x8ee34e30,
6150x8ee24e34, 0x1062001b, 0x24030040, 0x8c820004,
6160x24420001, 0xac820004, 0x8ee24e34, 0x8ee54e30,
6170x24420001, 0x10430007, 0x0, 0x8ee24e34,
6180x24420001, 0x10a20005, 0x0, 0x8001948,
6190x0, 0x14a00005, 0x0, 0x8f820128,
6200x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
6210x2c420011, 0x50400013, 0xac800000, 0x800195e,
6220x0, 0x8ee24e30, 0x24030040, 0x24420001,
6230x50430003, 0x1021, 0x8ee24e30, 0x24420001,
6240xaee24e30, 0x8ee24e30, 0x210c0, 0x24425038,
6250x2e22021, 0x24020012, 0xac820000, 0x24020001,
6260xac820004, 0x5600001d, 0x24100001, 0x3c040001,
6270x248452d0, 0xafa00010, 0xafa00014, 0x8ee60608,
6280x8f470228, 0x3c050009, 0xc002403, 0x34a5f001,
6290x8ee201b0, 0x24420001, 0xaee201b0, 0x800197c,
6300x8ee201b0, 0x3c040001, 0x248452dc, 0xafa00014,
6310x8ee60608, 0x8f470228, 0x3c050009, 0x34a5f005,
6320xc002403, 0x0, 0x8ee201ac, 0x8021,
6330x24420001, 0xaee201ac, 0x8ee201ac, 0x1200000c,
6340x24020001, 0x3c010001, 0x370821, 0xa02083b0,
6350x8f420238, 0x8ee30158, 0x24630001, 0xaee30158,
6360x8ee30158, 0x800198c, 0xaee27278, 0x24020001,
6370x3c010001, 0x370821, 0xa02283b0, 0x3c020001,
6380x8c425cd8, 0x10400187, 0x0, 0x8ee27b84,
6390x24430001, 0x284200c9, 0x144001a4, 0xaee37b84,
6400x8ee204d4, 0x30420002, 0x14400119, 0xaee07b84,
6410x8ee204d4, 0x3c030600, 0x34631000, 0x34420002,
6420xaee204d4, 0xafa30018, 0x8ee20608, 0x8f430228,
6430x24420001, 0x304a00ff, 0x514300fd, 0xafa00010,
6440x8ee20608, 0x210c0, 0x571021, 0x8fa30018,
6450x8fa4001c, 0xac43060c, 0xac440610, 0x8f830054,
6460x8f820054, 0x24690032, 0x1221023, 0x2c420033,
6470x1040006a, 0x5821, 0x24180008, 0x240f000d,
6480x240d0007, 0x240c0040, 0x240e0001, 0x8f870120,
6490x27623800, 0x24e80020, 0x102102b, 0x50400001,
6500x27683000, 0x8f820128, 0x11020004, 0x0,
6510x8f820124, 0x15020007, 0x1021, 0x8ee201a4,
6520x8021, 0x24420001, 0xaee201a4, 0x8001a15,
6530x8ee201a4, 0x8ee40608, 0x420c0, 0x801821,
6540x8ee40430, 0x8ee50434, 0xa32821, 0xa3302b,
6550x822021, 0x862021, 0xace40000, 0xace50004,
6560x8ee20608, 0xa4f8000e, 0xacef0018, 0xacea001c,
6570x210c0, 0x2442060c, 0x2e21021, 0xace20008,
6580x8ee204c4, 0xace20010, 0xaf880120, 0x92e24e20,
6590x14400033, 0x24100001, 0x8ee24e30, 0x210c0,
6600x24425038, 0x2e22021, 0x8c820000, 0x144d001f,
6610x0, 0x8ee34e30, 0x8ee24e34, 0x1062001b,
6620x0, 0x8c820004, 0x24420001, 0xac820004,
6630x8ee24e34, 0x8ee34e30, 0x24420001, 0x104c0007,
6640x0, 0x8ee24e34, 0x24420001, 0x10620005,
6650x0, 0x8001a02, 0x0, 0x14600005,
6660x0, 0x8f820128, 0x24420020, 0xaf820128,
6670x8f820128, 0x8c820004, 0x2c420011, 0x50400010,
6680xac800000, 0x8001a15, 0x0, 0x8ee24e30,
6690x24420001, 0x504c0003, 0x1021, 0x8ee24e30,
6700x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
6710x24425038, 0x2e22021, 0xac8d0000, 0xac8e0004,
6720x56000006, 0x240b0001, 0x8f820054, 0x1221023,
6730x2c420033, 0x1440ff9d, 0x0, 0x316300ff,
6740x24020001, 0x54620078, 0xafa00010, 0xaeea0608,
6750x8f830054, 0x8f820054, 0x24690032, 0x1221023,
6760x2c420033, 0x10400061, 0x5821, 0x240d0008,
6770x240c0011, 0x24080012, 0x24070040, 0x240a0001,
6780x8f830120, 0x27623800, 0x24660020, 0xc2102b,
6790x50400001, 0x27663000, 0x8f820128, 0x10c20004,
6800x0, 0x8f820124, 0x14c20007, 0x0,
6810x8ee201a4, 0x8021, 0x24420001, 0xaee201a4,
6820x8001a81, 0x8ee201a4, 0x8ee20608, 0xac62001c,
6830x8ee404a0, 0x8ee504a4, 0x2462001c, 0xac620008,
6840xa46d000e, 0xac6c0018, 0xac640000, 0xac650004,
6850x8ee204c4, 0xac620010, 0xaf860120, 0x92e24e20,
6860x14400033, 0x24100001, 0x8ee24e30, 0x210c0,
6870x24425038, 0x2e22021, 0x8c820000, 0x1448001f,
6880x0, 0x8ee34e30, 0x8ee24e34, 0x1062001b,
6890x0, 0x8c820004, 0x24420001, 0xac820004,
6900x8ee24e34, 0x8ee34e30, 0x24420001, 0x10470007,
6910x0, 0x8ee24e34, 0x24420001, 0x10620005,
6920x0, 0x8001a6e, 0x0, 0x14600005,
6930x0, 0x8f820128, 0x24420020, 0xaf820128,
6940x8f820128, 0x8c820004, 0x2c420011, 0x50400010,
6950xac800000, 0x8001a81, 0x0, 0x8ee24e30,
6960x24420001, 0x50470003, 0x1021, 0x8ee24e30,
6970x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
6980x24425038, 0x2e22021, 0xac880000, 0xac8a0004,
6990x56000006, 0x240b0001, 0x8f820054, 0x1221023,
7000x2c420033, 0x1440ffa6, 0x0, 0x316300ff,
7010x24020001, 0x10620022, 0x0, 0x3c040001,
7020x248452a4, 0xafa00010, 0xafa00014, 0x8f860120,
7030x8f870124, 0x3c050009, 0xc002403, 0x34a5f011,
7040x8001aad, 0x0, 0x3c040001, 0x248452b0,
7050xafa00014, 0x8f860120, 0x8f870124, 0x3c050009,
7060xc002403, 0x34a5f010, 0x8001aad, 0x0,
7070x3c040001, 0x248452bc, 0xafa00014, 0x8ee60608,
7080x8f470228, 0x3c050009, 0xc002403, 0x34a5f00f,
7090x8ee201ac, 0x24420001, 0xaee201ac, 0x8ee201ac,
7100x8ee2015c, 0x24420001, 0xaee2015c, 0x8ee2015c,
7110x8ee204d4, 0x30420001, 0x10400055, 0x0,
7120x8f420218, 0x30420080, 0x10400029, 0x0,
7130x8f820044, 0x34420040, 0xaf820044, 0x8ee27b7c,
7140x402821, 0x8ee200c0, 0x8ee300c4, 0x24060000,
7150x2407ffff, 0x2021, 0x461024, 0x1444000d,
7160x671824, 0x1465000b, 0x0, 0x8ee27b80,
7170x402821, 0x8ee200e0, 0x8ee300e4, 0x2021,
7180x461024, 0x14440003, 0x671824, 0x1065000b,
7190x0, 0x8ee200c0, 0x8ee300c4, 0x8ee400e0,
7200x8ee500e4, 0xaee37b7c, 0xaee57b80, 0x8f820044,
7210x38420020, 0x8001b38, 0xaf820044, 0x8f820044,
7220x2403ffdf, 0x431024, 0x8001b38, 0xaf820044,
7230x8f820044, 0x2403ffdf, 0x431024, 0xaf820044,
7240x8ee27b7c, 0x402821, 0x8ee200c0, 0x8ee300c4,
7250x24060000, 0x2407ffff, 0x2021, 0x461024,
7260x1444000d, 0x671824, 0x1465000b, 0x0,
7270x8ee27b80, 0x402821, 0x8ee200e0, 0x8ee300e4,
7280x2021, 0x461024, 0x14440003, 0x671824,
7290x1065000b, 0x0, 0x8ee200c0, 0x8ee300c4,
7300x8ee400e0, 0x8ee500e4, 0xaee37b7c, 0xaee57b80,
7310x8f820044, 0x38420040, 0x8001b38, 0xaf820044,
7320x8f820044, 0x34420040, 0x8001b38, 0xaf820044,
7330x8f820044, 0x34420040, 0xaf820044, 0x8ee27b8c,
7340x24430001, 0x28420015, 0x14400028, 0xaee37b8c,
7350x8f820044, 0x38420020, 0xaf820044, 0x8001b38,
7360xaee07b8c, 0x8ee204d4, 0x30420001, 0x10400011,
7370x0, 0x8f420218, 0x30420080, 0x10400009,
7380x0, 0x8f820044, 0x34420020, 0xaf820044,
7390x8f820044, 0x2403ffbf, 0x431024, 0x8001b36,
7400xaf820044, 0x8f820044, 0x34420060, 0x8001b36,
7410xaf820044, 0x8f820044, 0x34420040, 0xaf820044,
7420x8ee27b88, 0x24430001, 0x28421389, 0x14400005,
7430xaee37b88, 0x8f820044, 0x38420020, 0xaf820044,
7440xaee07b88, 0xc004603, 0x0, 0x8fbf0024,
7450x8fb00020, 0x3e00008, 0x27bd0028, 0x27bdffb8,
7460xafbf0044, 0xafb60040, 0xafb5003c, 0xafb40038,
7470xafb30034, 0xafb20030, 0xafb1002c, 0xafb00028,
7480x8f960064, 0x32c20004, 0x1040000c, 0x24020004,
7490xaf820064, 0x8f420114, 0xaee204e0, 0x8f820060,
7500x34420008, 0xaf820060, 0x8ee2016c, 0x24420001,
7510xaee2016c, 0x80022f4, 0x8ee2016c, 0x32c20001,
7520x10400004, 0x24020001, 0xaf820064, 0x80022f4,
7530x0, 0x32c20002, 0x1440000c, 0x3c050003,
7540x3c040001, 0x24845354, 0x34a50001, 0x2c03021,
7550x3821, 0xafa00010, 0xc002403, 0xafa00014,
7560x2402fff8, 0x80022f4, 0xaf820064, 0x8f43022c,
7570x8f42010c, 0x5062000c, 0xafa00010, 0x8f42022c,
7580x21080, 0x5a1021, 0x8c420300, 0xafa20020,
7590x8f42022c, 0x24070001, 0x24420001, 0x3042003f,
7600x8001b80, 0xaf42022c, 0x3c040001, 0x24845360,
7610xafa00014, 0x8f46022c, 0x8f47010c, 0x3c050003,
7620xc002403, 0x34a5f01f, 0x3821, 0x14e00003,
7630x0, 0x80022ed, 0xaf960064, 0x93a20020,
7640x2443ffff, 0x2c620011, 0x10400658, 0x31080,
7650x3c010001, 0x220821, 0x8c225418, 0x400008,
7660x0, 0x8fa20020, 0x30420fff, 0xaee20e0c,
7670x8f820060, 0x34420200, 0xaf820060, 0x8ee20118,
7680x24420001, 0xaee20118, 0x80022e8, 0x8ee20118,
7690x8fa20020, 0x24030001, 0x3c010001, 0x370821,
7700xa02383b1, 0x30420fff, 0xaee25238, 0x8f820060,
7710x34420100, 0xaf820060, 0x8ee20144, 0x24420001,
7720xaee20144, 0x80022e8, 0x8ee20144, 0x8fa20020,
7730x21200, 0x22502, 0x24020001, 0x10820005,
7740x24020002, 0x10820009, 0x2402fffe, 0x8001bc9,
7750xafa00010, 0x8ee204d4, 0xaee40070, 0xaee40074,
7760x34420001, 0x8001bbd, 0xaee204d4, 0x8ee304d4,
7770xaee40070, 0xaee40074, 0x621824, 0xaee304d4,
7780x8f840054, 0x41442, 0x41c82, 0x431021,
7790x41cc2, 0x431023, 0x41d02, 0x431021,
7800x41d42, 0x431023, 0x8001bd0, 0xaee20078,
7810x3c040001, 0x2484536c, 0xafa00014, 0x8fa60020,
7820x3c050003, 0xc002403, 0x34a50004, 0x8ee20110,
7830x24420001, 0xaee20110, 0x80022e8, 0x8ee20110,
7840x27440212, 0xc0022fe, 0x24050006, 0x3049001f,
7850x920c0, 0x2e41021, 0x9442727c, 0x30424000,
7860x1040000a, 0x971021, 0x97430212, 0xa443727e,
7870x8f430214, 0x971021, 0xac437280, 0x2e41821,
7880x34028000, 0x8001c79, 0xa462727c, 0x9443727e,
7890x97420212, 0x14620006, 0x2e41021, 0x971021,
7900x8c437280, 0x8f420214, 0x1062009f, 0x2e41021,
7910x9442727c, 0x30428000, 0x1040002a, 0x2406ffff,
7920x2021, 0x410c0, 0x2e21021, 0x9442737c,
7930x30424000, 0x54400005, 0x803021, 0x24840001,
7940x2c820080, 0x1440fff8, 0x410c0, 0x4c10010,
7950x618c0, 0x610c0, 0x571821, 0x8c63737c,
7960x571021, 0xafa30010, 0x8c427380, 0x3c040001,
7970x24845378, 0xafa20014, 0x8f470214, 0x3c050003,
7980xc002403, 0x34a50013, 0x8001c90, 0x3c020800,
7990x97440212, 0x771021, 0xa444737e, 0x8f440214,
8000x771021, 0x2e31821, 0xac447380, 0x34028000,
8010xa462737c, 0x910c0, 0x2e21021, 0x8001c79,
8020xa446727c, 0x2e41021, 0x9445727c, 0x8001c2e,
8030x510c0, 0x9443737e, 0x97420212, 0x14620006,
8040x510c0, 0x971021, 0x8c437380, 0x8f420214,
8050x10620065, 0x510c0, 0x2e21021, 0x9445737c,
8060x510c0, 0x2e21021, 0x9442737c, 0x30428000,
8070x1040fff0, 0x971021, 0x520c0, 0x971021,
8080x9443737e, 0x97420212, 0x14620006, 0x2406ffff,
8090x971021, 0x8c437380, 0x8f420214, 0x10620053,
8100x3c020800, 0x2021, 0x410c0, 0x2e21021,
8110x9442737c, 0x30424000, 0x54400005, 0x803021,
8120x24840001, 0x2c820080, 0x1440fff8, 0x410c0,
8130x4c10023, 0x618c0, 0x910c0, 0x571821,
8140x8c63727c, 0x571021, 0xafa30010, 0x8c427280,
8150x3c040001, 0x24845384, 0xafa20014, 0x8f470214,
8160x3c050003, 0xc002403, 0x34a5f017, 0x8001c90,
8170x3c020800, 0x8f430210, 0xb71021, 0xac43777c,
8180x8f430214, 0xb71021, 0xac437780, 0x3c020001,
8190x571021, 0x8c4283b4, 0x24420001, 0x3c010001,
8200x370821, 0xac2283b4, 0x3c030001, 0x771821,
8210x8c6383b4, 0x2e51021, 0x8001c82, 0xa443777c,
8220x97440212, 0x771021, 0xa444737e, 0x8f440214,
8230x771021, 0x2e31821, 0xac447380, 0x34028000,
8240xa462737c, 0x510c0, 0x2e21021, 0xa446737c,
8250x2021, 0x428c0, 0x2e51021, 0x9442777c,
8260x1040ffdc, 0x24840001, 0x2c820080, 0x5440fffa,
8270x428c0, 0x92e204d8, 0x10400006, 0x24020001,
8280x8ee304dc, 0x1221004, 0x621825, 0x8001c8f,
8290xaee304dc, 0x8f830228, 0x24020001, 0x1221004,
8300x621825, 0xaf830228, 0x3c020800, 0x34421000,
8310xafa20018, 0x8ee20608, 0x8f430228, 0x24420001,
8320x304a00ff, 0x514300fd, 0xafa00010, 0x8ee20608,
8330x210c0, 0x571021, 0x8fa30018, 0x8fa4001c,
8340xac43060c, 0xac440610, 0x8f830054, 0x8f820054,
8350x24690032, 0x1221023, 0x2c420033, 0x1040006a,
8360x5821, 0x24100008, 0x240f000d, 0x240d0007,
8370x240c0040, 0x240e0001, 0x8f870120, 0x27623800,
8380x24e80020, 0x102102b, 0x50400001, 0x27683000,
8390x8f820128, 0x11020004, 0x0, 0x8f820124,
8400x15020007, 0x1021, 0x8ee201a4, 0x3821,
8410x24420001, 0xaee201a4, 0x8001d08, 0x8ee201a4,
8420x8ee40608, 0x420c0, 0x801821, 0x8ee40430,
8430x8ee50434, 0xa32821, 0xa3302b, 0x822021,
8440x862021, 0xace40000, 0xace50004, 0x8ee20608,
8450xa4f0000e, 0xacef0018, 0xacea001c, 0x210c0,
8460x2442060c, 0x2e21021, 0xace20008, 0x8ee204c4,
8470xace20010, 0xaf880120, 0x92e24e20, 0x14400033,
8480x24070001, 0x8ee24e30, 0x210c0, 0x24425038,
8490x2e22021, 0x8c820000, 0x144d001f, 0x0,
8500x8ee34e30, 0x8ee24e34, 0x1062001b, 0x0,
8510x8c820004, 0x24420001, 0xac820004, 0x8ee24e34,
8520x8ee34e30, 0x24420001, 0x104c0007, 0x0,
8530x8ee24e34, 0x24420001, 0x10620005, 0x0,
8540x8001cf5, 0x0, 0x14600005, 0x0,
8550x8f820128, 0x24420020, 0xaf820128, 0x8f820128,
8560x8c820004, 0x2c420011, 0x50400010, 0xac800000,
8570x8001d08, 0x0, 0x8ee24e30, 0x24420001,
8580x504c0003, 0x1021, 0x8ee24e30, 0x24420001,
8590xaee24e30, 0x8ee24e30, 0x210c0, 0x24425038,
8600x2e22021, 0xac8d0000, 0xac8e0004, 0x54e00006,
8610x240b0001, 0x8f820054, 0x1221023, 0x2c420033,
8620x1440ff9d, 0x0, 0x316300ff, 0x24020001,
8630x54620078, 0xafa00010, 0xaeea0608, 0x8f830054,
8640x8f820054, 0x24690032, 0x1221023, 0x2c420033,
8650x10400061, 0x5821, 0x240e0008, 0x240d0011,
8660x240a0012, 0x24080040, 0x240c0001, 0x8f830120,
8670x27623800, 0x24660020, 0xc2102b, 0x50400001,
8680x27663000, 0x8f820128, 0x10c20004, 0x0,
8690x8f820124, 0x14c20007, 0x0, 0x8ee201a4,
8700x3821, 0x24420001, 0xaee201a4, 0x8001d74,
8710x8ee201a4, 0x8ee20608, 0xac62001c, 0x8ee404a0,
8720x8ee504a4, 0x2462001c, 0xac620008, 0xa46e000e,
8730xac6d0018, 0xac640000, 0xac650004, 0x8ee204c4,
8740xac620010, 0xaf860120, 0x92e24e20, 0x14400033,
8750x24070001, 0x8ee24e30, 0x210c0, 0x24425038,
8760x2e22021, 0x8c820000, 0x144a001f, 0x0,
8770x8ee34e30, 0x8ee24e34, 0x1062001b, 0x0,
8780x8c820004, 0x24420001, 0xac820004, 0x8ee24e34,
8790x8ee34e30, 0x24420001, 0x10480007, 0x0,
8800x8ee24e34, 0x24420001, 0x10620005, 0x0,
8810x8001d61, 0x0, 0x14600005, 0x0,
8820x8f820128, 0x24420020, 0xaf820128, 0x8f820128,
8830x8c820004, 0x2c420011, 0x50400010, 0xac800000,
8840x8001d74, 0x0, 0x8ee24e30, 0x24420001,
8850x50480003, 0x1021, 0x8ee24e30, 0x24420001,
8860xaee24e30, 0x8ee24e30, 0x210c0, 0x24425038,
8870x2e22021, 0xac8a0000, 0xac8c0004, 0x54e00006,
8880x240b0001, 0x8f820054, 0x1221023, 0x2c420033,
8890x1440ffa6, 0x0, 0x316300ff, 0x24020001,
8900x10620022, 0x0, 0x3c040001, 0x24845390,
8910xafa00010, 0xafa00014, 0x8f860120, 0x8f870124,
8920x3c050009, 0xc002403, 0x34a5f011, 0x8001da0,
8930x0, 0x3c040001, 0x2484539c, 0xafa00014,
8940x8f860120, 0x8f870124, 0x3c050009, 0xc002403,
8950x34a5f010, 0x8001da0, 0x0, 0x3c040001,
8960x248453a8, 0xafa00014, 0x8ee60608, 0x8f470228,
8970x3c050009, 0xc002403, 0x34a5f00f, 0x8ee201ac,
8980x24420001, 0xaee201ac, 0x8ee201ac, 0x8ee20124,
8990x24420001, 0xaee20124, 0x8001f97, 0x8ee20124,
9000x27440212, 0xc0022fe, 0x24050006, 0x3049001f,
9010x928c0, 0x2e51021, 0x9442727c, 0x30428000,
9020x1040002f, 0x2e51021, 0x9442727c, 0x30424000,
9030x1440001c, 0xb71021, 0x9443727e, 0x97420212,
9040x14620018, 0xb71021, 0x8c437280, 0x8f420214,
9050x54620016, 0xafa20010, 0x92e204d8, 0x10400007,
9060x24020001, 0x8ee304dc, 0x1221004, 0x21027,
9070x621824, 0x8001dc9, 0xaee304dc, 0x8f830228,
9080x1221004, 0x21027, 0x621824, 0xaf830228,
9090x910c0, 0x2e21821, 0x3402c000, 0x8001e4e,
9100xa462727c, 0x8f420214, 0xafa20010, 0x910c0,
9110x571021, 0x8c42727c, 0x3c040001, 0x248453b4,
9120x3c050003, 0xafa20014, 0x8f470210, 0x34a5f01c,
9130xc002403, 0x1203021, 0x8001e83, 0x3c020800,
9140xb71021, 0x9443727e, 0x97420212, 0x14620019,
9150x918c0, 0xb71021, 0x8c437280, 0x8f420214,
9160x14620014, 0x918c0, 0x2e51021, 0x9447727c,
9170x720c0, 0x971021, 0x9443737e, 0xb71021,
9180xa443727e, 0x971021, 0x8c437380, 0xb71021,
9190xac437280, 0x2e41021, 0x9443737c, 0x2e51021,
9200xa443727c, 0x2e41821, 0x3402c000, 0x8001e4e,
9210xa462737c, 0x2e31021, 0x9447727c, 0x3021,
9220x720c0, 0x2e41021, 0x9442737c, 0x4021,
9230x30428000, 0x14400025, 0xe02821, 0x605021,
9240x340bc000, 0x971021, 0x9443737e, 0x97420212,
9250x54620015, 0xe02821, 0x971021, 0x8c437380,
9260x8f420214, 0x54620010, 0xe02821, 0x11000006,
9270x2e41021, 0x9443737c, 0x510c0, 0x2e21021,
9280x8001e1a, 0xa443737c, 0x9443737c, 0x2ea1021,
9290xa443727c, 0x710c0, 0x2e21021, 0xa44b737c,
9300x8001e28, 0x24060001, 0x510c0, 0x2e21021,
9310x9447737c, 0x720c0, 0x2e41021, 0x9442737c,
9320x30428000, 0x1040ffdf, 0x25080001, 0x30c200ff,
9330x14400025, 0x2021, 0x720c0, 0x971021,
9340x9443737e, 0x97420212, 0x1462000f, 0x910c0,
9350x971021, 0x8c437380, 0x8f420214, 0x1462000a,
9360x910c0, 0x2e41821, 0x3402c000, 0x15000015,
9370xa462737c, 0x910c0, 0x2e21821, 0x34028000,
9380x8001e4e, 0xa462727c, 0x571021, 0x8c42727c,
9390x3c040001, 0x248453c0, 0x3c050003, 0xafa20010,
9400x710c0, 0x571021, 0x8c42737c, 0x34a5001e,
9410x1203021, 0xc002403, 0xafa20014, 0x8001e83,
9420x3c020800, 0x2021, 0x428c0, 0xb71021,
9430x9443777e, 0x97420212, 0x5462002b, 0x24840001,
9440xb71021, 0x8c437780, 0x8f420214, 0x54620026,
9450x24840001, 0x3c020001, 0x571021, 0x8c4283b4,
9460x2442ffff, 0x3c010001, 0x370821, 0xac2283b4,
9470x3c020001, 0x571021, 0x8c4283b4, 0x809021,
9480x242102b, 0x1040000e, 0x24b1777c, 0x24b07784,
9490x2f02021, 0x2f12821, 0xc002490, 0x24060008,
9500x26310008, 0x3c020001, 0x571021, 0x8c4283b4,
9510x26520001, 0x242102b, 0x1440fff5, 0x26100008,
9520x3c040001, 0x972021, 0x8c8483b4, 0x24050008,
9530x420c0, 0x2484777c, 0xc002488, 0x2e42021,
9540x8001e83, 0x3c020800, 0x2c820080, 0x1440ffcf,
9550x428c0, 0x3c020800, 0x34422000, 0xafa20018,
9560x8ee20608, 0x8f430228, 0x24420001, 0x304a00ff,
9570x514300fd, 0xafa00010, 0x8ee20608, 0x210c0,
9580x571021, 0x8fa30018, 0x8fa4001c, 0xac43060c,
9590xac440610, 0x8f830054, 0x8f820054, 0x24690032,
9600x1221023, 0x2c420033, 0x1040006a, 0x5821,
9610x24100008, 0x240f000d, 0x240d0007, 0x240c0040,
9620x240e0001, 0x8f870120, 0x27623800, 0x24e80020,
9630x102102b, 0x50400001, 0x27683000, 0x8f820128,
9640x11020004, 0x0, 0x8f820124, 0x15020007,
9650x1021, 0x8ee201a4, 0x3821, 0x24420001,
9660xaee201a4, 0x8001efb, 0x8ee201a4, 0x8ee40608,
9670x420c0, 0x801821, 0x8ee40430, 0x8ee50434,
9680xa32821, 0xa3302b, 0x822021, 0x862021,
9690xace40000, 0xace50004, 0x8ee20608, 0xa4f0000e,
9700xacef0018, 0xacea001c, 0x210c0, 0x2442060c,
9710x2e21021, 0xace20008, 0x8ee204c4, 0xace20010,
9720xaf880120, 0x92e24e20, 0x14400033, 0x24070001,
9730x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
9740x8c820000, 0x144d001f, 0x0, 0x8ee34e30,
9750x8ee24e34, 0x1062001b, 0x0, 0x8c820004,
9760x24420001, 0xac820004, 0x8ee24e34, 0x8ee34e30,
9770x24420001, 0x104c0007, 0x0, 0x8ee24e34,
9780x24420001, 0x10620005, 0x0, 0x8001ee8,
9790x0, 0x14600005, 0x0, 0x8f820128,
9800x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
9810x2c420011, 0x50400010, 0xac800000, 0x8001efb,
9820x0, 0x8ee24e30, 0x24420001, 0x504c0003,
9830x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
9840x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
9850xac8d0000, 0xac8e0004, 0x54e00006, 0x240b0001,
9860x8f820054, 0x1221023, 0x2c420033, 0x1440ff9d,
9870x0, 0x316300ff, 0x24020001, 0x54620078,
9880xafa00010, 0xaeea0608, 0x8f830054, 0x8f820054,
9890x24690032, 0x1221023, 0x2c420033, 0x10400061,
9900x5821, 0x240e0008, 0x240d0011, 0x240a0012,
9910x24080040, 0x240c0001, 0x8f830120, 0x27623800,
9920x24660020, 0xc2102b, 0x50400001, 0x27663000,
9930x8f820128, 0x10c20004, 0x0, 0x8f820124,
9940x14c20007, 0x0, 0x8ee201a4, 0x3821,
9950x24420001, 0xaee201a4, 0x8001f67, 0x8ee201a4,
9960x8ee20608, 0xac62001c, 0x8ee404a0, 0x8ee504a4,
9970x2462001c, 0xac620008, 0xa46e000e, 0xac6d0018,
9980xac640000, 0xac650004, 0x8ee204c4, 0xac620010,
9990xaf860120, 0x92e24e20, 0x14400033, 0x24070001,
10000x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
10010x8c820000, 0x144a001f, 0x0, 0x8ee34e30,
10020x8ee24e34, 0x1062001b, 0x0, 0x8c820004,
10030x24420001, 0xac820004, 0x8ee24e34, 0x8ee34e30,
10040x24420001, 0x10480007, 0x0, 0x8ee24e34,
10050x24420001, 0x10620005, 0x0, 0x8001f54,
10060x0, 0x14600005, 0x0, 0x8f820128,
10070x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
10080x2c420011, 0x50400010, 0xac800000, 0x8001f67,
10090x0, 0x8ee24e30, 0x24420001, 0x50480003,
10100x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
10110x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
10120xac8a0000, 0xac8c0004, 0x54e00006, 0x240b0001,
10130x8f820054, 0x1221023, 0x2c420033, 0x1440ffa6,
10140x0, 0x316300ff, 0x24020001, 0x10620022,
10150x0, 0x3c040001, 0x24845390, 0xafa00010,
10160xafa00014, 0x8f860120, 0x8f870124, 0x3c050009,
10170xc002403, 0x34a5f011, 0x8001f93, 0x0,
10180x3c040001, 0x2484539c, 0xafa00014, 0x8f860120,
10190x8f870124, 0x3c050009, 0xc002403, 0x34a5f010,
10200x8001f93, 0x0, 0x3c040001, 0x248453a8,
10210xafa00014, 0x8ee60608, 0x8f470228, 0x3c050009,
10220xc002403, 0x34a5f00f, 0x8ee201ac, 0x24420001,
10230xaee201ac, 0x8ee201ac, 0x8ee20128, 0x24420001,
10240xaee20128, 0x8ee20128, 0x8ee20164, 0x24420001,
10250xaee20164, 0x80022e8, 0x8ee20164, 0x8fa20020,
10260x21200, 0x21d02, 0x24020001, 0x10620005,
10270x24020002, 0x1062000d, 0x0, 0x8001fb7,
10280xafa00010, 0x92e204d8, 0x14400006, 0x24020001,
10290x8f820228, 0xaee204dc, 0x2402ffff, 0xaf820228,
10300x24020001, 0x8001fbe, 0xa2e204d8, 0x92e204d8,
10310x5040000c, 0xa2e004d8, 0x8ee204dc, 0xaf820228,
10320x8001fbe, 0xa2e004d8, 0x3c040001, 0x248453c8,
10330xafa00014, 0x8fa60020, 0x3c050003, 0xc002403,
10340x34a5f009, 0x8ee2013c, 0x24420001, 0xaee2013c,
10350x80022e8, 0x8ee2013c, 0x8fa20020, 0x21200,
10360x22502, 0x24020001, 0x10820005, 0x24020002,
10370x1082000f, 0x0, 0x8001fe3, 0xafa00010,
10380x8f820220, 0x3c0308ff, 0x3463ffff, 0x431024,
10390x34420008, 0xaf820220, 0x24020001, 0x3c010001,
10400x370821, 0xa02283b2, 0x8001fea, 0xaee40108,
10410x8f820220, 0x3c0308ff, 0x3463fff7, 0x431024,
10420xaf820220, 0x3c010001, 0x370821, 0xa02083b2,
10430x8001fea, 0xaee40108, 0x3c040001, 0x248453d4,
10440xafa00014, 0x8fa60020, 0x3c050003, 0xc002403,
10450x34a5f00a, 0x8ee2012c, 0x24420001, 0xaee2012c,
10460x80022e8, 0x8ee2012c, 0x8fa20020, 0x21200,
10470x21d02, 0x24020001, 0x10620005, 0x24020002,
10480x1062000e, 0x0, 0x8002011, 0xafa00010,
10490x8f820220, 0x3c0308ff, 0x3463ffff, 0x431024,
10500x34420008, 0xaf820220, 0x24020001, 0x3c010001,
10510x370821, 0x8002018, 0xa02283b3, 0x3c020001,
10520x571021, 0x904283b2, 0x3c010001, 0x370821,
10530x1440000e, 0xa02083b3, 0x8f820220, 0x3c0308ff,
10540x3463fff7, 0x431024, 0x8002018, 0xaf820220,
10550x3c040001, 0x248453e0, 0xafa00014, 0x8fa60020,
10560x3c050003, 0xc002403, 0x34a5f00b, 0x8ee20114,
10570x24420001, 0xaee20114, 0x80022e8, 0x8ee20114,
10580x27840208, 0x27450200, 0xc00249a, 0x24060008,
10590x26e40094, 0x27450200, 0xc00249a, 0x24060008,
10600x8ee20134, 0x24420001, 0xaee20134, 0x80022e8,
10610x8ee20134, 0x8f460248, 0x2021, 0xc005108,
10620x24050004, 0x8ee20130, 0x24420001, 0xaee20130,
10630x80022e8, 0x8ee20130, 0x8ef301cc, 0x8ef401d0,
10640x8ef501d8, 0x8ee20140, 0x26e40030, 0x24420001,
10650xaee20140, 0x8ef00140, 0x8ef10074, 0x8ef20070,
10660xc002488, 0x24050400, 0xaef301cc, 0xaef401d0,
10670xaef501d8, 0xaef00140, 0xaef10074, 0xaef20070,
10680x8f42025c, 0x26e40094, 0xaee20060, 0x8f420260,
10690x27450200, 0x24060008, 0xaee20068, 0x24020006,
10700xc00249a, 0xaee20064, 0x3c023b9a, 0x3442ca00,
10710xaee2006c, 0x240203e8, 0x24040002, 0x24030001,
10720xaee20104, 0xaee40100, 0xaee3010c, 0x8f820220,
10730x30420008, 0x10400004, 0x0, 0xaee30108,
10740x8002061, 0x2021, 0xaee40108, 0x2021,
10750x3c030001, 0x641821, 0x90635c30, 0x2e41021,
10760x24840001, 0xa043009c, 0x2c82000f, 0x1440fff8,
10770x0, 0x8f820040, 0x2e41821, 0x24840001,
10780x21702, 0x24420030, 0xa062009c, 0x2e41021,
10790x80022e8, 0xa040009c, 0x24020001, 0x3c010001,
10800x370821, 0xa02283e0, 0x240b0400, 0x24080014,
10810x240a0040, 0x24090001, 0x8f830100, 0x27623000,
10820x24660020, 0xc2102b, 0x50400001, 0x27662800,
10830x8f820108, 0x10c20004, 0x0, 0x8f820104,
10840x14c20007, 0x26e20030, 0x8ee201a8, 0x3821,
10850x24420001, 0xaee201a8, 0x80020a8, 0x8ee201a8,
10860x8ee404b8, 0x8ee504bc, 0xac620008, 0xa46b000e,
10870xac680018, 0xac60001c, 0xac640000, 0xac650004,
10880x8ee204cc, 0xac620010, 0xaf860100, 0x92e204ec,
10890x1440000e, 0x24070001, 0x8ee24e28, 0x24420001,
10900x504a0003, 0x1021, 0x8ee24e28, 0x24420001,
10910xaee24e28, 0x8ee24e28, 0x210c0, 0x24424e38,
10920x2e21021, 0xac480000, 0xac490004, 0x10e0ffd2,
10930x0, 0x80022e8, 0x0, 0x3c020900,
10940xaee05238, 0xaee0523c, 0xaee05240, 0xaee05244,
10950xaee001d0, 0x3c010001, 0x370821, 0xa02083b1,
10960xafa20018, 0x8ee20608, 0x8f430228, 0x24420001,
10970x304a00ff, 0x514300fd, 0xafa00010, 0x8ee20608,
10980x210c0, 0x571021, 0x8fa30018, 0x8fa4001c,
10990xac43060c, 0xac440610, 0x8f830054, 0x8f820054,
11000x24690032, 0x1221023, 0x2c420033, 0x1040006a,
11010x5821, 0x24100008, 0x240f000d, 0x240d0007,
11020x240c0040, 0x240e0001, 0x8f870120, 0x27623800,
11030x24e80020, 0x102102b, 0x50400001, 0x27683000,
11040x8f820128, 0x11020004, 0x0, 0x8f820124,
11050x15020007, 0x1021, 0x8ee201a4, 0x3821,
11060x24420001, 0xaee201a4, 0x800212c, 0x8ee201a4,
11070x8ee40608, 0x420c0, 0x801821, 0x8ee40430,
11080x8ee50434, 0xa32821, 0xa3302b, 0x822021,
11090x862021, 0xace40000, 0xace50004, 0x8ee20608,
11100xa4f0000e, 0xacef0018, 0xacea001c, 0x210c0,
11110x2442060c, 0x2e21021, 0xace20008, 0x8ee204c4,
11120xace20010, 0xaf880120, 0x92e24e20, 0x14400033,
11130x24070001, 0x8ee24e30, 0x210c0, 0x24425038,
11140x2e22021, 0x8c820000, 0x144d001f, 0x0,
11150x8ee34e30, 0x8ee24e34, 0x1062001b, 0x0,
11160x8c820004, 0x24420001, 0xac820004, 0x8ee24e34,
11170x8ee34e30, 0x24420001, 0x104c0007, 0x0,
11180x8ee24e34, 0x24420001, 0x10620005, 0x0,
11190x8002119, 0x0, 0x14600005, 0x0,
11200x8f820128, 0x24420020, 0xaf820128, 0x8f820128,
11210x8c820004, 0x2c420011, 0x50400010, 0xac800000,
11220x800212c, 0x0, 0x8ee24e30, 0x24420001,
11230x504c0003, 0x1021, 0x8ee24e30, 0x24420001,
11240xaee24e30, 0x8ee24e30, 0x210c0, 0x24425038,
11250x2e22021, 0xac8d0000, 0xac8e0004, 0x54e00006,
11260x240b0001, 0x8f820054, 0x1221023, 0x2c420033,
11270x1440ff9d, 0x0, 0x316300ff, 0x24020001,
11280x54620078, 0xafa00010, 0xaeea0608, 0x8f830054,
11290x8f820054, 0x24690032, 0x1221023, 0x2c420033,
11300x10400061, 0x5821, 0x240e0008, 0x240d0011,
11310x240a0012, 0x24080040, 0x240c0001, 0x8f830120,
11320x27623800, 0x24660020, 0xc2102b, 0x50400001,
11330x27663000, 0x8f820128, 0x10c20004, 0x0,
11340x8f820124, 0x14c20007, 0x0, 0x8ee201a4,
11350x3821, 0x24420001, 0xaee201a4, 0x8002198,
11360x8ee201a4, 0x8ee20608, 0xac62001c, 0x8ee404a0,
11370x8ee504a4, 0x2462001c, 0xac620008, 0xa46e000e,
11380xac6d0018, 0xac640000, 0xac650004, 0x8ee204c4,
11390xac620010, 0xaf860120, 0x92e24e20, 0x14400033,
11400x24070001, 0x8ee24e30, 0x210c0, 0x24425038,
11410x2e22021, 0x8c820000, 0x144a001f, 0x0,
11420x8ee34e30, 0x8ee24e34, 0x1062001b, 0x0,
11430x8c820004, 0x24420001, 0xac820004, 0x8ee24e34,
11440x8ee34e30, 0x24420001, 0x10480007, 0x0,
11450x8ee24e34, 0x24420001, 0x10620005, 0x0,
11460x8002185, 0x0, 0x14600005, 0x0,
11470x8f820128, 0x24420020, 0xaf820128, 0x8f820128,
11480x8c820004, 0x2c420011, 0x50400010, 0xac800000,
11490x8002198, 0x0, 0x8ee24e30, 0x24420001,
11500x50480003, 0x1021, 0x8ee24e30, 0x24420001,
11510xaee24e30, 0x8ee24e30, 0x210c0, 0x24425038,
11520x2e22021, 0xac8a0000, 0xac8c0004, 0x54e00006,
11530x240b0001, 0x8f820054, 0x1221023, 0x2c420033,
11540x1440ffa6, 0x0, 0x316300ff, 0x24020001,
11550x10620022, 0x0, 0x3c040001, 0x24845390,
11560xafa00010, 0xafa00014, 0x8f860120, 0x8f870124,
11570x3c050009, 0xc002403, 0x34a5f011, 0x80021c4,
11580x0, 0x3c040001, 0x2484539c, 0xafa00014,
11590x8f860120, 0x8f870124, 0x3c050009, 0xc002403,
11600x34a5f010, 0x80021c4, 0x0, 0x3c040001,
11610x248453a8, 0xafa00014, 0x8ee60608, 0x8f470228,
11620x3c050009, 0xc002403, 0x34a5f00f, 0x8ee201ac,
11630x24420001, 0xaee201ac, 0x8ee201ac, 0x8ee20120,
11640x24420001, 0xaee20120, 0x8ee20120, 0x8ee20168,
11650x24420001, 0xaee20168, 0x80022e8, 0x8ee20168,
11660x8f42025c, 0x26e40094, 0xaee20060, 0x8f420260,
11670x27450200, 0x24060008, 0xc00249a, 0xaee20068,
11680x8f820220, 0x30420008, 0x14400002, 0x24020001,
11690x24020002, 0xaee20108, 0x8ee2011c, 0x24420001,
11700xaee2011c, 0x80022e8, 0x8ee2011c, 0x3c040001,
11710x248453ec, 0xafa00010, 0xafa00014, 0x8fa60020,
11720x3c050003, 0xc002403, 0x34a5f00f, 0x93a20020,
11730x3c030700, 0x34631000, 0x431025, 0xafa20018,
11740x8ee20608, 0x8f430228, 0x24420001, 0x304900ff,
11750x512300e2, 0xafa00010, 0x8ee20608, 0x210c0,
11760x571021, 0x8fa30018, 0x8fa4001c, 0xac43060c,
11770xac440610, 0x8f870120, 0x27623800, 0x24e80020,
11780x102102b, 0x50400001, 0x27683000, 0x8f820128,
11790x11020004, 0x0, 0x8f820124, 0x15020007,
11800x1021, 0x8ee201a4, 0x3821, 0x24420001,
11810xaee201a4, 0x800225d, 0x8ee201a4, 0x8ee40608,
11820x420c0, 0x801821, 0x8ee40430, 0x8ee50434,
11830xa32821, 0xa3302b, 0x822021, 0x862021,
11840xace40000, 0xace50004, 0x8ee30608, 0x24020008,
11850xa4e2000e, 0x2402000d, 0xace20018, 0xace9001c,
11860x318c0, 0x2463060c, 0x2e31021, 0xace20008,
11870x8ee204c4, 0xace20010, 0xaf880120, 0x92e24e20,
11880x14400037, 0x24070001, 0x8ee24e30, 0x210c0,
11890x24425038, 0x2e22021, 0x8c830000, 0x24020007,
11900x1462001f, 0x0, 0x8ee34e30, 0x8ee24e34,
11910x1062001b, 0x24030040, 0x8c820004, 0x24420001,
11920xac820004, 0x8ee24e34, 0x8ee54e30, 0x24420001,
11930x10430007, 0x0, 0x8ee24e34, 0x24420001,
11940x10a20005, 0x0, 0x8002247, 0x0,
11950x14a00005, 0x0, 0x8f820128, 0x24420020,
11960xaf820128, 0x8f820128, 0x8c820004, 0x2c420011,
11970x50400013, 0xac800000, 0x800225d, 0x0,
11980x8ee24e30, 0x24030040, 0x24420001, 0x50430003,
11990x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
12000x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
12010x24020007, 0xac820000, 0x24020001, 0xac820004,
12020x54e0000c, 0xaee90608, 0x3c040001, 0x248453f4,
12030xafa00010, 0xafa00014, 0x8ee60608, 0x8f470228,
12040x3c050009, 0xc002403, 0x34a5f000, 0x80022e0,
12050x0, 0x8f830120, 0x27623800, 0x24660020,
12060xc2102b, 0x50400001, 0x27663000, 0x8f820128,
12070x10c20004, 0x0, 0x8f820124, 0x14c20007,
12080x0, 0x8ee201a4, 0x3821, 0x24420001,
12090xaee201a4, 0x80022c4, 0x8ee201a4, 0x8ee20608,
12100xac62001c, 0x8ee404a0, 0x8ee504a4, 0x2462001c,
12110xac620008, 0x24020008, 0xa462000e, 0x24020011,
12120xac620018, 0xac640000, 0xac650004, 0x8ee204c4,
12130xac620010, 0xaf860120, 0x92e24e20, 0x14400037,
12140x24070001, 0x8ee24e30, 0x210c0, 0x24425038,
12150x2e22021, 0x8c830000, 0x24020012, 0x1462001f,
12160x0, 0x8ee34e30, 0x8ee24e34, 0x1062001b,
12170x24030040, 0x8c820004, 0x24420001, 0xac820004,
12180x8ee24e34, 0x8ee54e30, 0x24420001, 0x10430007,
12190x0, 0x8ee24e34, 0x24420001, 0x10a20005,
12200x0, 0x80022ae, 0x0, 0x14a00005,
12210x0, 0x8f820128, 0x24420020, 0xaf820128,
12220x8f820128, 0x8c820004, 0x2c420011, 0x50400013,
12230xac800000, 0x80022c4, 0x0, 0x8ee24e30,
12240x24030040, 0x24420001, 0x50430003, 0x1021,
12250x8ee24e30, 0x24420001, 0xaee24e30, 0x8ee24e30,
12260x210c0, 0x24425038, 0x2e22021, 0x24020012,
12270xac820000, 0x24020001, 0xac820004, 0x14e0001b,
12280x0, 0x3c040001, 0x248453fc, 0xafa00010,
12290xafa00014, 0x8ee60608, 0x8f470228, 0x3c050009,
12300xc002403, 0x34a5f001, 0x8ee201b0, 0x24420001,
12310xaee201b0, 0x80022e0, 0x8ee201b0, 0x3c040001,
12320x24845408, 0xafa00014, 0x8ee60608, 0x8f470228,
12330x3c050009, 0xc002403, 0x34a5f005, 0x8ee201ac,
12340x24420001, 0xaee201ac, 0x8ee201ac, 0x8ee20150,
12350x24420001, 0xaee20150, 0x8ee20150, 0x8ee20160,
12360x24420001, 0xaee20160, 0x8ee20160, 0x8f43022c,
12370x8f42010c, 0x14620009, 0x24020002, 0xaf820064,
12380x8f820064, 0x14400005, 0x0, 0x8f43022c,
12390x8f42010c, 0x1462f875, 0x0, 0x8fbf0044,
12400x8fb60040, 0x8fb5003c, 0x8fb40038, 0x8fb30034,
12410x8fb20030, 0x8fb1002c, 0x8fb00028, 0x3e00008,
12420x27bd0048, 0x27bdfff8, 0x2408ffff, 0x10a00014,
12430x4821, 0x3c0aedb8, 0x354a8320, 0x90870000,
12440x24840001, 0x3021, 0x1071026, 0x30420001,
12450x10400002, 0x81842, 0x6a1826, 0x604021,
12460x24c60001, 0x2cc20008, 0x1440fff7, 0x73842,
12470x25290001, 0x125102b, 0x1440fff0, 0x0,
12480x1001021, 0x3e00008, 0x27bd0008, 0x27bdffe8,
12490x27642800, 0xafbf0010, 0xc002488, 0x24051000,
12500x24020021, 0xaf800100, 0xaf800104, 0xaf800108,
12510xaf800110, 0xaf800114, 0xaf800118, 0xaf800120,
12520xaf800124, 0xaf800128, 0xaf800130, 0xaf800134,
12530xaf800138, 0xaee04e28, 0xaee04e2c, 0xaee04e30,
12540xaee04e34, 0xaf82011c, 0x8f420218, 0x30420040,
12550x10400004, 0x0, 0x8f82011c, 0x34420004,
12560xaf82011c, 0x8fbf0010, 0x3e00008, 0x27bd0018,
12570x27bdffe0, 0xafbf0018, 0x8f820104, 0xafa20010,
12580x8f820100, 0x3c050002, 0xafa20014, 0x8f8600b0,
12590x8f87011c, 0x3c040001, 0x248454c0, 0xc002403,
12600x34a5f000, 0x8f8300b0, 0x3c027f00, 0x621824,
12610x3c020400, 0x10620029, 0x43102b, 0x14400008,
12620x3c022000, 0x3c020100, 0x10620024, 0x3c020200,
12630x10620011, 0x0, 0x8002374, 0x0,
12640x10620008, 0x3c024000, 0x1462001c, 0x0,
12650x8ee20190, 0x24420001, 0xaee20190, 0x8002374,
12660x8ee20190, 0x8ee2018c, 0x24420001, 0xaee2018c,
12670x8002374, 0x8ee2018c, 0x8f82011c, 0x34420002,
12680xaf82011c, 0x8f830104, 0x8f8200b0, 0x34420001,
12690xaf8200b0, 0xaf830104, 0x8f82011c, 0x2403fffd,
12700x431024, 0xaf82011c, 0x8ee201a0, 0x24420001,
12710xaee201a0, 0x8002377, 0x8ee201a0, 0x8f8200b0,
12720x34420001, 0xaf8200b0, 0x8fbf0018, 0x3e00008,
12730x27bd0020, 0x27bdffe0, 0xafbf001c, 0xafb00018,
12740x8f820120, 0xafa20010, 0x8f820124, 0x3c050001,
12750xafa20014, 0x8f8600a0, 0x8f87011c, 0x3c040001,
12760x248454cc, 0xc002403, 0x34a5f000, 0x8f8300a0,
12770x3c027f00, 0x621824, 0x3c020400, 0x10620053,
12780x8021, 0x43102b, 0x14400008, 0x3c042000,
12790x3c020100, 0x1062004d, 0x3c020200, 0x1062003a,
12800x0, 0x80023e0, 0x0, 0x10640003,
12810x3c024000, 0x14620045, 0x0, 0x8f8200a0,
12820x441024, 0x10400006, 0x0, 0x8ee20194,
12830x24420001, 0xaee20194, 0x80023a9, 0x8ee20194,
12840x8ee20198, 0x24420001, 0xaee20198, 0x8ee20198,
12850x8f82011c, 0x34420002, 0xaf82011c, 0x8f82011c,
12860x30420200, 0x1040001b, 0x0, 0x8f8300a0,
12870x8f840124, 0x8f8200ac, 0x14400007, 0x24020001,
12880x3c020001, 0x3442f000, 0x621024, 0x50400001,
12890x24100001, 0x24020001, 0x1200000d, 0xaf8200a0,
12900x8f820124, 0x2442ffe0, 0xaf820124, 0x8f820124,
12910x8f820124, 0x27633000, 0x43102b, 0x10400005,
12920x276237e0, 0xaf820124, 0x80023ca, 0x0,
12930xaf840124, 0x8f82011c, 0x2403fffd, 0x431024,
12940x80023e3, 0xaf82011c, 0x8f82011c, 0x34420002,
12950xaf82011c, 0x8f830124, 0x8f8200a0, 0x34420001,
12960xaf8200a0, 0xaf830124, 0x8f82011c, 0x2403fffd,
12970x431024, 0xaf82011c, 0x8ee2019c, 0x24420001,
12980xaee2019c, 0x80023e3, 0x8ee2019c, 0x8f8200a0,
12990x34420001, 0xaf8200a0, 0x8fbf001c, 0x8fb00018,
13000x3e00008, 0x27bd0020, 0x0, 0x3c020001,
13010x8c425c58, 0x27bdffe8, 0xafbf0014, 0x14400012,
13020xafb00010, 0x3c100001, 0x26105dd0, 0x2002021,
13030xc002488, 0x24052000, 0x26021fe0, 0x3c010001,
13040xac225d94, 0x3c010001, 0xac225d90, 0xaf420250,
13050x24022000, 0xaf500254, 0xaf420258, 0x24020001,
13060x3c010001, 0xac225c58, 0x8fbf0014, 0x8fb00010,
13070x3e00008, 0x27bd0018, 0x3c030001, 0x8c635d94,
13080x8c820000, 0x8fa80010, 0x8fa90014, 0xac620000,
13090x3c020001, 0x8c425d94, 0x8c830004, 0xac430004,
13100xac450008, 0x8f840054, 0x2443ffe0, 0xac460010,
13110xac470014, 0xac480018, 0xac49001c, 0x3c010001,
13120xac235d94, 0xac44000c, 0x3c020001, 0x24425dd0,
13130x62182b, 0x10600005, 0x0, 0x3c020001,
13140x8c425d90, 0x3c010001, 0xac225d94, 0x3c030001,
13150x8c635d94, 0x3c020001, 0x8c425c40, 0xac620000,
13160x3c030001, 0x8c635d94, 0x3c020001, 0x8c425c40,
13170xac620004, 0x3e00008, 0xaf430250, 0x3c030001,
13180x8c635d94, 0x3c020001, 0x8c425c40, 0x27bdffd0,
13190xafb40020, 0x8fb40040, 0xafb00010, 0x808021,
13200xafb50024, 0x8fb50044, 0x8fa40048, 0xafb10014,
13210xa08821, 0xafbf0028, 0xafb3001c, 0xafb20018,
13220xac620000, 0x3c050001, 0x8ca55d94, 0x3c020001,
13230x8c425c40, 0xc09021, 0xe09821, 0x10800006,
13240xaca20004, 0x24a50008, 0xc002490, 0x24060018,
13250x800244e, 0x0, 0x24a40008, 0xc002488,
13260x24050018, 0x3c020001, 0x8c425d94, 0x3c050001,
13270x24a55dd0, 0x2442ffe0, 0x3c010001, 0xac225d94,
13280x45102b, 0x10400005, 0x0, 0x3c020001,
13290x8c425d90, 0x3c010001, 0xac225d94, 0x3c030001,
13300x8c635d94, 0x8e020000, 0xac620000, 0x3c030001,
13310x8c635d94, 0x8e020004, 0xac620004, 0xac710008,
13320x8f840054, 0x2462ffe0, 0x3c010001, 0xac225d94,
13330x45102b, 0xac720010, 0xac730014, 0xac740018,
13340xac75001c, 0x10400005, 0xac64000c, 0x3c020001,
13350x8c425d90, 0x3c010001, 0xac225d94, 0x3c030001,
13360x8c635d94, 0x3c020001, 0x8c425c40, 0xac620000,
13370x3c030001, 0x8c635d94, 0x3c020001, 0x8c425c40,
13380xac620004, 0xaf430250, 0x8fbf0028, 0x8fb50024,
13390x8fb40020, 0x8fb3001c, 0x8fb20018, 0x8fb10014,
13400x8fb00010, 0x3e00008, 0x27bd0030, 0x10a00005,
13410x0, 0xac800000, 0x24a5fffc, 0x14a0fffd,
13420x24840004, 0x3e00008, 0x0, 0x10c00007,
13430x0, 0x8c820000, 0x24840004, 0x24c6fffc,
13440xaca20000, 0x14c0fffb, 0x24a50004, 0x3e00008,
13450x0, 0x10c00007, 0x0, 0x8ca20000,
13460x24a50004, 0x24c6fffc, 0xac820000, 0x14c0fffb,
13470x24840004, 0x3e00008, 0x0, 0x3e00008,
13480x0, 0x27bdffd8, 0xafbf0020, 0x8ee304e4,
13490x8ee204e0, 0x10620436, 0x0, 0x8ee204e4,
13500x8ee304fc, 0x21100, 0x626021, 0x95870008,
13510x8d8a0000, 0x8d8b0004, 0x958d000a, 0x8ee2725c,
13520x8ee3726c, 0x30e4ffff, 0x441021, 0x62182b,
13530x10600015, 0x31a20004, 0x8f8200d8, 0x8ee37258,
13540x431023, 0xaee2726c, 0x8ee2726c, 0x1c400003,
13550x3c030001, 0x431021, 0xaee2726c, 0x8ee2725c,
13560x8ee3726c, 0x441021, 0x62182b, 0x10600006,
13570x31a20004, 0x8ee201b8, 0x24420001, 0xaee201b8,
13580x80028e1, 0x8ee201b8, 0x10400240, 0x31a20200,
13590x1040014d, 0x4821, 0x96e2045a, 0x30420010,
13600x10400149, 0x0, 0x8f840100, 0x27623000,
13610x24850020, 0xa2102b, 0x50400001, 0x27652800,
13620x8f820108, 0x10a20004, 0x0, 0x8f820104,
13630x14a20006, 0x2402000c, 0x8ee201a8, 0x24420001,
13640xaee201a8, 0x800252c, 0x8ee201a8, 0xac8a0000,
13650xac8b0004, 0x8ee37264, 0x24060005, 0xa482000e,
13660xac860018, 0xac830008, 0x8ee204e4, 0xac82001c,
13670x8ee204c8, 0xac820010, 0xaf850100, 0x92e204ec,
13680x14400036, 0x24090001, 0x8ee24e28, 0x210c0,
13690x24424e38, 0x2e22021, 0x8c820000, 0x1446001f,
13700x0, 0x8ee34e28, 0x8ee24e2c, 0x1062001b,
13710x24030040, 0x8c820004, 0x24420001, 0xac820004,
13720x8ee24e2c, 0x8ee54e28, 0x24420001, 0x10430007,
13730x0, 0x8ee24e2c, 0x24420001, 0x10a20005,
13740x0, 0x8002516, 0x0, 0x14a00005,
13750x0, 0x8f820108, 0x24420020, 0xaf820108,
13760x8f820108, 0x8c820004, 0x2c420011, 0x50400013,
13770xac800000, 0x800252c, 0x0, 0x8ee24e28,
13780x24030040, 0x24420001, 0x50430003, 0x1021,
13790x8ee24e28, 0x24420001, 0xaee24e28, 0x8ee24e28,
13800x210c0, 0x24424e38, 0x2e22021, 0x24020005,
13810xac820000, 0x24020001, 0xac820004, 0x1520000a,
13820x3c040001, 0xafab0010, 0x8ee27264, 0x3c040001,
13830x24845730, 0x3c050004, 0xafa20014, 0x8ee604e4,
13840x80028be, 0x34a5f114, 0x8ee27264, 0x34843800,
13850x3641821, 0x24420010, 0x43102b, 0x14400073,
13860x0, 0x8ee27264, 0x24480010, 0x3641021,
13870x102102b, 0x14400002, 0x3c02ffff, 0x1024021,
13880x8f850100, 0x27623000, 0x24a60020, 0xc2102b,
13890x50400001, 0x27662800, 0x8f820108, 0x10c20004,
13900x0, 0x8f820104, 0x14c20007, 0x2563000c,
13910x8ee201a8, 0x4821, 0x24420001, 0xaee201a8,
13920x80025a0, 0x8ee201a8, 0x2c64000c, 0x1441021,
13930xaca20000, 0xaca30004, 0x24e2fff4, 0xa4a2000e,
13940x24020006, 0xaca80008, 0xaca20018, 0x8ee204e4,
13950xaca2001c, 0x8ee204c8, 0x3c030002, 0x431025,
13960xaca20010, 0xaf860100, 0x92e204ec, 0x14400037,
13970x24090001, 0x8ee24e28, 0x210c0, 0x24424e38,
13980x2e22021, 0x8c830000, 0x24020005, 0x1462001f,
13990x0, 0x8ee34e28, 0x8ee24e2c, 0x1062001b,
14000x24030040, 0x8c820004, 0x24420001, 0xac820004,
14010x8ee24e2c, 0x8ee54e28, 0x24420001, 0x10430007,
14020x0, 0x8ee24e2c, 0x24420001, 0x10a20005,
14030x0, 0x800258a, 0x0, 0x14a00005,
14040x0, 0x8f820108, 0x24420020, 0xaf820108,
14050x8f820108, 0x8c820004, 0x2c420011, 0x50400013,
14060xac800000, 0x80025a0, 0x0, 0x8ee24e28,
14070x24030040, 0x24420001, 0x50430003, 0x1021,
14080x8ee24e28, 0x24420001, 0xaee24e28, 0x8ee24e28,
14090x210c0, 0x24424e38, 0x2e22021, 0x24020005,
14100xac820000, 0x24020001, 0xac820004, 0x1520000a,
14110x2508fffc, 0xafab0010, 0x8ee27264, 0x3c040001,
14120x24845730, 0x3c050004, 0xafa20014, 0x8ee604e4,
14130x80028be, 0x34a5f125, 0x34028100, 0xa5020000,
14140x9582000e, 0x800261d, 0xa5020002, 0x8f850100,
14150x27623000, 0x24a60020, 0xc2102b, 0x50400001,
14160x27662800, 0x8f820108, 0x10c20004, 0x0,
14170x8f820104, 0x14c20007, 0x2563000c, 0x8ee201a8,
14180x4821, 0x24420001, 0xaee201a8, 0x800260d,
14190x8ee201a8, 0x2c64000c, 0x1441021, 0xaca20000,
14200xaca30004, 0x8ee37264, 0x24e2fff4, 0xa4a2000e,
14210x24020006, 0xaca20018, 0x24630010, 0xaca30008,
14220x8ee204e4, 0xaca2001c, 0x8ee204c8, 0x3c030002,
14230x431025, 0xaca20010, 0xaf860100, 0x92e204ec,
14240x14400037, 0x24090001, 0x8ee24e28, 0x210c0,
14250x24424e38, 0x2e22021, 0x8c830000, 0x24020005,
14260x1462001f, 0x0, 0x8ee34e28, 0x8ee24e2c,
14270x1062001b, 0x24030040, 0x8c820004, 0x24420001,
14280xac820004, 0x8ee24e2c, 0x8ee54e28, 0x24420001,
14290x10430007, 0x0, 0x8ee24e2c, 0x24420001,
14300x10a20005, 0x0, 0x80025f7, 0x0,
14310x14a00005, 0x0, 0x8f820108, 0x24420020,
14320xaf820108, 0x8f820108, 0x8c820004, 0x2c420011,
14330x50400013, 0xac800000, 0x800260d, 0x0,
14340x8ee24e28, 0x24030040, 0x24420001, 0x50430003,
14350x1021, 0x8ee24e28, 0x24420001, 0xaee24e28,
14360x8ee24e28, 0x210c0, 0x24424e38, 0x2e22021,
14370x24020005, 0xac820000, 0x24020001, 0xac820004,
14380x1520000a, 0x34028100, 0xafab0010, 0x8ee27264,
14390x3c040001, 0x24845730, 0x3c050004, 0xafa20014,
14400x8ee604e4, 0x80028be, 0x34a5f015, 0x8ee37264,
14410xa462000c, 0x8ee37264, 0x9582000e, 0xa462000e,
14420x8002681, 0x24e70004, 0x8f840100, 0x27623000,
14430x24850020, 0xa2102b, 0x50400001, 0x27652800,
14440x8f820108, 0x10a20004, 0x0, 0x8f820104,
14450x14a20007, 0x24020006, 0x8ee201a8, 0x4821,
14460x24420001, 0xaee201a8, 0x8002677, 0x8ee201a8,
14470xac8a0000, 0xac8b0004, 0x8ee37264, 0xa487000e,
14480xac820018, 0xac830008, 0x8ee204e4, 0xac82001c,
14490x8ee204c8, 0x3c030002, 0x431025, 0xac820010,
14500xaf850100, 0x92e204ec, 0x14400037, 0x24090001,
14510x8ee24e28, 0x210c0, 0x24424e38, 0x2e22021,
14520x8c830000, 0x24020005, 0x1462001f, 0x0,
14530x8ee34e28, 0x8ee24e2c, 0x1062001b, 0x24030040,
14540x8c820004, 0x24420001, 0xac820004, 0x8ee24e2c,
14550x8ee54e28, 0x24420001, 0x10430007, 0x0,
14560x8ee24e2c, 0x24420001, 0x10a20005, 0x0,
14570x8002661, 0x0, 0x14a00005, 0x0,
14580x8f820108, 0x24420020, 0xaf820108, 0x8f820108,
14590x8c820004, 0x2c420011, 0x50400013, 0xac800000,
14600x8002677, 0x0, 0x8ee24e28, 0x24030040,
14610x24420001, 0x50430003, 0x1021, 0x8ee24e28,
14620x24420001, 0xaee24e28, 0x8ee24e28, 0x210c0,
14630x24424e38, 0x2e22021, 0x24020005, 0xac820000,
14640x24020001, 0xac820004, 0x15200009, 0x3c050004,
14650xafab0010, 0x8ee27264, 0x3c040001, 0x24845730,
14660xafa20014, 0x8ee604e4, 0x80028be, 0x34a5f004,
14670x8ee2725c, 0x30e7ffff, 0x471021, 0xaee2725c,
14680x8ee204e4, 0x8ee304fc, 0x8ee47258, 0x21100,
14690x431021, 0xac44000c, 0x8ee27258, 0xafa20018,
14700x8ee3725c, 0xafa3001c, 0x8ee2725c, 0x2c42003c,
14710x10400004, 0x24620001, 0x2403fffe, 0x431024,
14720xafa2001c, 0x8ee27264, 0x3c060001, 0x34c63800,
14730x8ee3725c, 0x2405fff8, 0x471021, 0x24420007,
14740x451024, 0x24630007, 0xaee27258, 0x8ee2726c,
14750x8ee47258, 0x651824, 0x431023, 0xaee2726c,
14760x3661021, 0x82202b, 0x14800004, 0x3c03ffff,
14770x8ee27258, 0x431021, 0xaee27258, 0x8ee27258,
14780xaee27264, 0x8f8200f0, 0x24470008, 0x27621800,
14790xe2102b, 0x50400001, 0x27671000, 0x8f8200f4,
14800x14e20007, 0x0, 0x8ee201b4, 0x4821,
14810x24420001, 0xaee201b4, 0x80026c4, 0x8ee201b4,
14820x8f8200f0, 0x24090001, 0x8fa30018, 0x8fa4001c,
14830xac430000, 0xac440004, 0xaf8700f0, 0x15200012,
14840xd1142, 0x8f8200f0, 0xafa20010, 0x8f8200f4,
14850x3c040001, 0x2484573c, 0xafa20014, 0x8fa60018,
14860x8fa7001c, 0x3c050004, 0xc002403, 0x34a5f005,
14870x8ee20088, 0x24420001, 0xaee20088, 0x8ee20088,
14880x80028d3, 0xaee0725c, 0x30430003, 0x24020002,
14890x10620016, 0x28620003, 0x10400005, 0x24020001,
14900x10620008, 0x0, 0x8002703, 0x0,
14910x24020003, 0x10620017, 0x0, 0x8002703,
14920x0, 0x8ee200e8, 0x8ee300ec, 0x24630001,
14930x2c640001, 0x441021, 0xaee200e8, 0xaee300ec,
14940x8ee200e8, 0x8002703, 0x8ee300ec, 0x8ee200f0,
14950x8ee300f4, 0x24630001, 0x2c640001, 0x441021,
14960xaee200f0, 0xaee300f4, 0x8ee200f0, 0x8002703,
14970x8ee300f4, 0x8ee200f8, 0x8ee300fc, 0x24630001,
14980x2c640001, 0x441021, 0xaee200f8, 0xaee300fc,
14990x8ee200f8, 0x8ee300fc, 0x8ee2725c, 0x8ee400e0,
15000x8ee500e4, 0x401821, 0x1021, 0xa32821,
15010xa3302b, 0x822021, 0x862021, 0xaee400e0,
15020xaee500e4, 0x80028d3, 0xaee0725c, 0x30e2ffff,
15030x104001c1, 0x31a20200, 0x1040014d, 0x4821,
15040x96e2045a, 0x30420010, 0x10400149, 0x0,
15050x8f840100, 0x27623000, 0x24850020, 0xa2102b,
15060x50400001, 0x27652800, 0x8f820108, 0x10a20004,
15070x0, 0x8f820104, 0x14a20006, 0x2402000c,
15080x8ee201a8, 0x24420001, 0xaee201a8, 0x800276e,
15090x8ee201a8, 0xac8a0000, 0xac8b0004, 0x8ee37264,
15100x24060005, 0xa482000e, 0xac860018, 0xac830008,
15110x8ee204e4, 0xac82001c, 0x8ee204c8, 0xac820010,
15120xaf850100, 0x92e204ec, 0x14400036, 0x24090001,
15130x8ee24e28, 0x210c0, 0x24424e38, 0x2e22021,
15140x8c820000, 0x1446001f, 0x0, 0x8ee34e28,
15150x8ee24e2c, 0x1062001b, 0x24030040, 0x8c820004,
15160x24420001, 0xac820004, 0x8ee24e2c, 0x8ee54e28,
15170x24420001, 0x10430007, 0x0, 0x8ee24e2c,
15180x24420001, 0x10a20005, 0x0, 0x8002758,
15190x0, 0x14a00005, 0x0, 0x8f820108,
15200x24420020, 0xaf820108, 0x8f820108, 0x8c820004,
15210x2c420011, 0x50400013, 0xac800000, 0x800276e,
15220x0, 0x8ee24e28, 0x24030040, 0x24420001,
15230x50430003, 0x1021, 0x8ee24e28, 0x24420001,
15240xaee24e28, 0x8ee24e28, 0x210c0, 0x24424e38,
15250x2e22021, 0x24020005, 0xac820000, 0x24020001,
15260xac820004, 0x1520000a, 0x3c040001, 0xafab0010,
15270x8ee27264, 0x3c040001, 0x24845730, 0x3c050004,
15280xafa20014, 0x8ee604e4, 0x80028be, 0x34a5f014,
15290x8ee27264, 0x34843800, 0x3641821, 0x24420010,
15300x43102b, 0x14400073, 0x0, 0x8ee27264,
15310x24480010, 0x3641021, 0x102102b, 0x14400002,
15320x3c02ffff, 0x1024021, 0x8f850100, 0x27623000,
15330x24a60020, 0xc2102b, 0x50400001, 0x27662800,
15340x8f820108, 0x10c20004, 0x0, 0x8f820104,
15350x14c20007, 0x2563000c, 0x8ee201a8, 0x4821,
15360x24420001, 0xaee201a8, 0x80027e2, 0x8ee201a8,
15370x2c64000c, 0x1441021, 0xaca20000, 0xaca30004,
15380x24e2fff4, 0xa4a2000e, 0x24020006, 0xaca80008,
15390xaca20018, 0x8ee204e4, 0xaca2001c, 0x8ee204c8,
15400x3c030002, 0x431025, 0xaca20010, 0xaf860100,
15410x92e204ec, 0x14400037, 0x24090001, 0x8ee24e28,
15420x210c0, 0x24424e38, 0x2e22021, 0x8c830000,
15430x24020005, 0x1462001f, 0x0, 0x8ee34e28,
15440x8ee24e2c, 0x1062001b, 0x24030040, 0x8c820004,
15450x24420001, 0xac820004, 0x8ee24e2c, 0x8ee54e28,
15460x24420001, 0x10430007, 0x0, 0x8ee24e2c,
15470x24420001, 0x10a20005, 0x0, 0x80027cc,
15480x0, 0x14a00005, 0x0, 0x8f820108,
15490x24420020, 0xaf820108, 0x8f820108, 0x8c820004,
15500x2c420011, 0x50400013, 0xac800000, 0x80027e2,
15510x0, 0x8ee24e28, 0x24030040, 0x24420001,
15520x50430003, 0x1021, 0x8ee24e28, 0x24420001,
15530xaee24e28, 0x8ee24e28, 0x210c0, 0x24424e38,
15540x2e22021, 0x24020005, 0xac820000, 0x24020001,
15550xac820004, 0x1520000a, 0x2508fffc, 0xafab0010,
15560x8ee27264, 0x3c040001, 0x24845730, 0x3c050004,
15570xafa20014, 0x8ee604e4, 0x80028be, 0x34a5f015,
15580x34028100, 0xa5020000, 0x9582000e, 0x800285f,
15590xa5020002, 0x8f850100, 0x27623000, 0x24a60020,
15600xc2102b, 0x50400001, 0x27662800, 0x8f820108,
15610x10c20004, 0x0, 0x8f820104, 0x14c20007,
15620x2563000c, 0x8ee201a8, 0x4821, 0x24420001,
15630xaee201a8, 0x800284f, 0x8ee201a8, 0x2c64000c,
15640x1441021, 0xaca20000, 0xaca30004, 0x8ee37264,
15650x24e2fff4, 0xa4a2000e, 0x24020006, 0xaca20018,
15660x24630010, 0xaca30008, 0x8ee204e4, 0xaca2001c,
15670x8ee204c8, 0x3c030002, 0x431025, 0xaca20010,
15680xaf860100, 0x92e204ec, 0x14400037, 0x24090001,
15690x8ee24e28, 0x210c0, 0x24424e38, 0x2e22021,
15700x8c830000, 0x24020005, 0x1462001f, 0x0,
15710x8ee34e28, 0x8ee24e2c, 0x1062001b, 0x24030040,
15720x8c820004, 0x24420001, 0xac820004, 0x8ee24e2c,
15730x8ee54e28, 0x24420001, 0x10430007, 0x0,
15740x8ee24e2c, 0x24420001, 0x10a20005, 0x0,
15750x8002839, 0x0, 0x14a00005, 0x0,
15760x8f820108, 0x24420020, 0xaf820108, 0x8f820108,
15770x8c820004, 0x2c420011, 0x50400013, 0xac800000,
15780x800284f, 0x0, 0x8ee24e28, 0x24030040,
15790x24420001, 0x50430003, 0x1021, 0x8ee24e28,
15800x24420001, 0xaee24e28, 0x8ee24e28, 0x210c0,
15810x24424e38, 0x2e22021, 0x24020005, 0xac820000,
15820x24020001, 0xac820004, 0x1520000a, 0x34028100,
15830xafab0010, 0x8ee27264, 0x3c040001, 0x24845730,
15840x3c050004, 0xafa20014, 0x8ee604e4, 0x80028be,
15850x34a5f016, 0x8ee37264, 0xa462000c, 0x8ee37264,
15860x9582000e, 0xa462000e, 0x80028c2, 0x24e70004,
15870x8f830100, 0x27623000, 0x24640020, 0x82102b,
15880x50400001, 0x27642800, 0x8f820108, 0x10820004,
15890x0, 0x8f820104, 0x14820007, 0x24050005,
15900x8ee201a8, 0x4821, 0x24420001, 0xaee201a8,
15910x80028b6, 0x8ee201a8, 0xac6a0000, 0xac6b0004,
15920x8ee27264, 0xa467000e, 0xac650018, 0xac620008,
15930x8ee204e4, 0xac62001c, 0x8ee204c8, 0xac620010,
15940xaf840100, 0x92e204ec, 0x14400036, 0x24090001,
15950x8ee24e28, 0x210c0, 0x24424e38, 0x2e22021,
15960x8c820000, 0x1445001f, 0x0, 0x8ee34e28,
15970x8ee24e2c, 0x1062001b, 0x24030040, 0x8c820004,
15980x24420001, 0xac820004, 0x8ee24e2c, 0x8ee54e28,
15990x24420001, 0x10430007, 0x0, 0x8ee24e2c,
16000x24420001, 0x10a20005, 0x0, 0x80028a0,
16010x0, 0x14a00005, 0x0, 0x8f820108,
16020x24420020, 0xaf820108, 0x8f820108, 0x8c820004,
16030x2c420011, 0x50400013, 0xac800000, 0x80028b6,
16040x0, 0x8ee24e28, 0x24030040, 0x24420001,
16050x50430003, 0x1021, 0x8ee24e28, 0x24420001,
16060xaee24e28, 0x8ee24e28, 0x210c0, 0x24424e38,
16070x2e22021, 0x24020005, 0xac820000, 0x24020001,
16080xac820004, 0x1520000b, 0x3c050004, 0x3c040001,
16090x24845748, 0xafab0010, 0xafa00014, 0x8ee604e4,
16100x34a5f017, 0xc002403, 0x30e7ffff, 0x80028e1,
16110x0, 0x8ee27264, 0x3c050001, 0x30e4ffff,
16120x441021, 0xaee27264, 0x8ee2725c, 0x8ee37264,
16130x34a53800, 0x441021, 0xaee2725c, 0x3651021,
16140x62182b, 0x14600004, 0x3c03ffff, 0x8ee27264,
16150x431021, 0xaee27264, 0x8ee304e4, 0x96e20458,
16160x24630001, 0x2442ffff, 0x621824, 0xaee304e4,
16170x8ee304e4, 0x8ee204e0, 0x14620005, 0x0,
16180x8f820060, 0x2403fff7, 0x431024, 0xaf820060,
16190x8fbf0020, 0x3e00008, 0x27bd0028, 0x27bdffe0,
16200xafbf0018, 0x8ee304e8, 0x8ee204e0, 0x10620189,
16210x0, 0x8ee204e8, 0x8ee304fc, 0x21100,
16220x621821, 0x94670008, 0x92e204ed, 0x8c680000,
16230x8c690004, 0x10400023, 0x946a000a, 0x8ee204c8,
16240x34460400, 0x31420200, 0x1040001f, 0x0,
16250x96e2045a, 0x30420010, 0x1040001b, 0x3c028000,
16260x3c010001, 0x370821, 0xac2283d8, 0x8ee27264,
16270x9464000e, 0x3c050001, 0x34a53800, 0x24420004,
16280xaee27264, 0x8ee37264, 0x42400, 0x3651021,
16290x3c010001, 0x370821, 0xac2483dc, 0x62182b,
16300x14600005, 0x24e70004, 0x8ee27264, 0x3c03ffff,
16310x431021, 0xaee27264, 0x8ee27264, 0x8002917,
16320xaee27258, 0x8ee604c8, 0x8ee2726c, 0x30e4ffff,
16330x44102a, 0x10400015, 0x0, 0x8f8200d8,
16340x8ee37258, 0x431023, 0xaee2726c, 0x8ee2726c,
16350x1c400007, 0x44102a, 0x8ee2726c, 0x3c030001,
16360x431021, 0xaee2726c, 0x8ee2726c, 0x44102a,
16370x10400006, 0x0, 0x8ee201b8, 0x24420001,
16380xaee201b8, 0x8002a72, 0x8ee201b8, 0x3c020001,
16390x571021, 0x8c4283d8, 0x54400001, 0x24e7fffc,
16400x31420004, 0x104000b9, 0x30e2ffff, 0x3c020001,
16410x571021, 0x8c4283d8, 0x1040002f, 0x5021,
16420x8f840100, 0x27623000, 0x24850020, 0xa2102b,
16430x50400001, 0x27652800, 0x8f820108, 0x10a20032,
16440x0, 0x8f820104, 0x10a2002f, 0x24020015,
16450xac880000, 0xac890004, 0x8ee37264, 0xa487000e,
16460xac820018, 0xac830008, 0x8ee204e8, 0x3c030001,
16470x771821, 0x8c6383dc, 0xac860010, 0x431025,
16480xac82001c, 0xaf850100, 0x92e204ec, 0x14400066,
16490x240a0001, 0x8ee24e28, 0x24030040, 0x24420001,
16500x50430003, 0x1021, 0x8ee24e28, 0x24420001,
16510xaee24e28, 0x8ee24e28, 0x210c0, 0x24424e38,
16520x2e21821, 0x24020015, 0xac620000, 0x24020001,
16530x80029bf, 0xac620004, 0x8f840100, 0x27623000,
16540x24850020, 0xa2102b, 0x50400001, 0x27652800,
16550x8f820108, 0x10a20004, 0x0, 0x8f820104,
16560x14a20006, 0x24020006, 0x8ee201a8, 0x24420001,
16570xaee201a8, 0x80029bf, 0x8ee201a8, 0xac880000,
16580xac890004, 0x8ee37264, 0xa487000e, 0xac820018,
16590xac830008, 0x8ee204e8, 0xac860010, 0xac82001c,
16600xaf850100, 0x92e204ec, 0x14400037, 0x240a0001,
16610x8ee24e28, 0x210c0, 0x24424e38, 0x2e22021,
16620x8c830000, 0x24020005, 0x1462001f, 0x0,
16630x8ee34e28, 0x8ee24e2c, 0x1062001b, 0x24030040,
16640x8c820004, 0x24420001, 0xac820004, 0x8ee24e2c,
16650x8ee54e28, 0x24420001, 0x10430007, 0x0,
16660x8ee24e2c, 0x24420001, 0x10a20005, 0x0,
16670x80029a9, 0x0, 0x14a00005, 0x0,
16680x8f820108, 0x24420020, 0xaf820108, 0x8f820108,
16690x8c820004, 0x2c420011, 0x50400013, 0xac800000,
16700x80029bf, 0x0, 0x8ee24e28, 0x24030040,
16710x24420001, 0x50430003, 0x1021, 0x8ee24e28,
16720x24420001, 0xaee24e28, 0x8ee24e28, 0x210c0,
16730x24424e38, 0x2e22021, 0x24020005, 0xac820000,
16740x24020001, 0xac820004, 0x1540000a, 0x24020001,
16750xafa90010, 0x8ee27264, 0x3c040001, 0x24845730,
16760x3c050004, 0xafa20014, 0x8ee604e4, 0x8002a4f,
16770x34a5f204, 0xa2e204ed, 0x8ee204e8, 0x8ee304fc,
16780x8ee47258, 0x3c060001, 0x34c63800, 0x3c010001,
16790x370821, 0xac2083d8, 0x3c010001, 0x370821,
16800xac2083dc, 0x21100, 0x431021, 0xac44000c,
16810x8ee27264, 0x2405fff8, 0x30e3ffff, 0x431021,
16820x24420007, 0x451024, 0x24630007, 0xaee27258,
16830x8ee2726c, 0x8ee47258, 0x651824, 0x431023,
16840xaee2726c, 0x3661021, 0x82202b, 0x14800004,
16850x3c03ffff, 0x8ee27258, 0x431021, 0xaee27258,
16860x8ee27258, 0x8002a64, 0xaee27264, 0x10400073,
16870x0, 0x8f830100, 0x27623000, 0x24640020,
16880x82102b, 0x14400002, 0x5021, 0x27642800,
16890x8f820108, 0x10820004, 0x0, 0x8f820104,
16900x14820006, 0x24050005, 0x8ee201a8, 0x24420001,
16910xaee201a8, 0x8002a46, 0x8ee201a8, 0xac680000,
16920xac690004, 0x8ee27264, 0xa467000e, 0xac650018,
16930xac620008, 0x8ee204e8, 0xac660010, 0xac62001c,
16940xaf840100, 0x92e204ec, 0x14400036, 0x240a0001,
16950x8ee24e28, 0x210c0, 0x24424e38, 0x2e22021,
16960x8c820000, 0x1445001f, 0x0, 0x8ee34e28,
16970x8ee24e2c, 0x1062001b, 0x24030040, 0x8c820004,
16980x24420001, 0xac820004, 0x8ee24e2c, 0x8ee54e28,
16990x24420001, 0x10430007, 0x0, 0x8ee24e2c,
17000x24420001, 0x10a20005, 0x0, 0x8002a30,
17010x0, 0x14a00005, 0x0, 0x8f820108,
17020x24420020, 0xaf820108, 0x8f820108, 0x8c820004,
17030x2c420011, 0x50400013, 0xac800000, 0x8002a46,
17040x0, 0x8ee24e28, 0x24030040, 0x24420001,
17050x50430003, 0x1021, 0x8ee24e28, 0x24420001,
17060xaee24e28, 0x8ee24e28, 0x210c0, 0x24424e38,
17070x2e22021, 0x24020005, 0xac820000, 0x24020001,
17080xac820004, 0x1540000c, 0x30e5ffff, 0x3c040001,
17090x24845748, 0x3c050004, 0xafa90010, 0xafa00014,
17100x8ee604e4, 0x34a5f237, 0xc002403, 0x30e7ffff,
17110x8002a72, 0x0, 0x8ee27264, 0x451021,
17120xaee27264, 0x8ee2726c, 0x8ee37264, 0x3c040001,
17130x34843800, 0xa2e004ed, 0x451023, 0xaee2726c,
17140x3641021, 0x62182b, 0x14600004, 0x3c03ffff,
17150x8ee27264, 0x431021, 0xaee27264, 0x8ee304e8,
17160x96e20458, 0x24630001, 0x2442ffff, 0x621824,
17170xaee304e8, 0x8ee304e8, 0x8ee204e0, 0x14620005,
17180x0, 0x8f820060, 0x2403fff7, 0x431024,
17190xaf820060, 0x8fbf0018, 0x3e00008, 0x27bd0020,
17200x27bdffe0, 0xafbf001c, 0xafb00018, 0x8f820100,
17210x8ee34e2c, 0x8f820104, 0x8f850108, 0x24020040,
17220x24630001, 0x50620003, 0x1021, 0x8ee24e2c,
17230x24420001, 0xaee24e2c, 0x8ee24e2c, 0x8ee34e2c,
17240x210c0, 0x24424e38, 0x2e22021, 0x8ee24e28,
17250x8c870004, 0x14620007, 0xa03021, 0x8f820108,
17260x24420020, 0xaf820108, 0x8f820108, 0x8002aa2,
17270xac800000, 0x8ee24e2c, 0x24030040, 0x24420001,
17280x50430003, 0x1021, 0x8ee24e2c, 0x24420001,
17290x210c0, 0x24424e38, 0x2e22021, 0x8c820004,
17300x8f830108, 0x21140, 0x621821, 0xaf830108,
17310xac800000, 0x8cc20018, 0x2443fffe, 0x2c620013,
17320x104000c1, 0x31080, 0x3c010001, 0x220821,
17330x8c225770, 0x400008, 0x0, 0x8ee204f0,
17340x471021, 0xaee204f0, 0x8ee204f0, 0x8f43023c,
17350x43102b, 0x144000be, 0x0, 0x8ee304e4,
17360x8ee204f8, 0x506200ba, 0xa2e004f4, 0x8f830120,
17370x27623800, 0x24660020, 0xc2102b, 0x50400001,
17380x27663000, 0x8f820128, 0x10c20004, 0x0,
17390x8f820124, 0x14c20007, 0x0, 0x8ee201a4,
17400x8021, 0x24420001, 0xaee201a4, 0x8002b12,
17410x8ee201a4, 0x8ee204e4, 0xac62001c, 0x8ee404b0,
17420x8ee504b4, 0x2462001c, 0xac620008, 0x24020008,
17430xa462000e, 0x24020011, 0xac620018, 0xac640000,
17440xac650004, 0x8ee204c4, 0xac620010, 0xaf860120,
17450x92e24e20, 0x14400037, 0x24100001, 0x8ee24e30,
17460x210c0, 0x24425038, 0x2e22021, 0x8c830000,
17470x24020012, 0x1462001f, 0x0, 0x8ee34e30,
17480x8ee24e34, 0x1062001b, 0x24030040, 0x8c820004,
17490x24420001, 0xac820004, 0x8ee24e34, 0x8ee54e30,
17500x24420001, 0x10430007, 0x0, 0x8ee24e34,
17510x24420001, 0x10a20005, 0x0, 0x8002afc,
17520x0, 0x14a00005, 0x0, 0x8f820128,
17530x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
17540x2c420011, 0x50400013, 0xac800000, 0x8002b12,
17550x0, 0x8ee24e30, 0x24030040, 0x24420001,
17560x50430003, 0x1021, 0x8ee24e30, 0x24420001,
17570xaee24e30, 0x8ee24e30, 0x210c0, 0x24425038,
17580x2e22021, 0x24020012, 0xac820000, 0x24020001,
17590xac820004, 0x5600000b, 0x24100001, 0x8ee204e4,
17600x3c040001, 0x24845754, 0xafa00014, 0xafa20010,
17610x8ee60608, 0x8f470228, 0x3c050009, 0xc002403,
17620x34a5f006, 0x16000003, 0x24020001, 0x8002b71,
17630xa2e204f4, 0x8ee20170, 0x24420001, 0xaee20170,
17640x8ee20170, 0x8ee204e4, 0xa2e004f4, 0xaee004f0,
17650xaee204f8, 0x8f42023c, 0x50400045, 0xaee07274,
17660x8ee20184, 0x24420001, 0xaee20184, 0x8ee20184,
17670x8002b71, 0xaee07274, 0x8ee20504, 0x24030040,
17680x24420001, 0x50430003, 0x1021, 0x8ee20504,
17690x24420001, 0xaee20504, 0x8ee20504, 0x8cc30018,
17700x21080, 0x571021, 0x8c440508, 0x24020003,
17710x1462000f, 0x0, 0x3c020001, 0x571021,
17720x904283b1, 0x10400014, 0x0, 0x8ee201d0,
17730x8ee35240, 0x441021, 0xaee201d0, 0x8ee201d8,
17740x641821, 0x306300ff, 0x8002b59, 0xaee35240,
17750x8ee201cc, 0x8ee30e10, 0x441021, 0xaee201cc,
17760x8ee201d8, 0x641821, 0x306301ff, 0xaee30e10,
17770x441021, 0xaee201d8, 0x8ee20000, 0x34420040,
17780x8002b71, 0xaee20000, 0x8ee2014c, 0x3c010001,
17790x370821, 0xa02083e0, 0x24420001, 0xaee2014c,
17800x8002b71, 0x8ee2014c, 0x94c7000e, 0x8cc2001c,
17810x3c040001, 0x24845760, 0xafa60014, 0xafa20010,
17820x8cc60018, 0x3c050008, 0xc002403, 0x34a50910,
17830x8fbf001c, 0x8fb00018, 0x3e00008, 0x27bd0020,
17840x27bdff98, 0xafbf0060, 0xafbe005c, 0xafb60058,
17850xafb50054, 0xafb40050, 0xafb3004c, 0xafb20048,
17860xafb10044, 0xafb00040, 0x8f830108, 0x8f820104,
17870xafa00024, 0x106203e7, 0xafa0002c, 0x3c1e0001,
17880x37de3800, 0x3c0bffff, 0x8f930108, 0x8e620018,
17890x8f830104, 0x2443fffe, 0x2c620014, 0x104003cf,
17900x31080, 0x3c010001, 0x220821, 0x8c2257c0,
17910x400008, 0x0, 0x9663000e, 0x8ee2725c,
17920x8ee404f0, 0x431021, 0xaee2725c, 0x8e63001c,
17930x96e20458, 0x24840001, 0xaee404f0, 0x24630001,
17940x2442ffff, 0x621824, 0xaee304e4, 0x8f42023c,
17950x82202b, 0x148003b9, 0x0, 0x8f830120,
17960x27623800, 0x24660020, 0xc2102b, 0x50400001,
17970x27663000, 0x8f820128, 0x10c20004, 0x0,
17980x8f820124, 0x14c20007, 0x0, 0x8ee201a4,
17990x8021, 0x24420001, 0xaee201a4, 0x8002bfe,
18000x8ee201a4, 0x8ee204e4, 0xac62001c, 0x8ee404b0,
18010x8ee504b4, 0x2462001c, 0xac620008, 0x24020008,
18020xa462000e, 0x24020011, 0xac620018, 0xac640000,
18030xac650004, 0x8ee204c4, 0xac620010, 0xaf860120,
18040x92e24e20, 0x14400037, 0x24100001, 0x8ee24e30,
18050x210c0, 0x24425038, 0x2e22021, 0x8c830000,
18060x24020012, 0x1462001f, 0x0, 0x8ee34e30,
18070x8ee24e34, 0x1062001b, 0x240c0040, 0x8c820004,
18080x24420001, 0xac820004, 0x8ee24e34, 0x8ee34e30,
18090x24420001, 0x104c0007, 0x0, 0x8ee24e34,
18100x24420001, 0x10620005, 0x0, 0x8002be8,
18110x0, 0x14600005, 0x0, 0x8f820128,
18120x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
18130x2c420011, 0x50400013, 0xac800000, 0x8002bfe,
18140x0, 0x8ee24e30, 0x240c0040, 0x24420001,
18150x504c0003, 0x1021, 0x8ee24e30, 0x24420001,
18160xaee24e30, 0x8ee24e30, 0x210c0, 0x24425038,
18170x2e22021, 0x24020012, 0x240c0001, 0xac820000,
18180xac8c0004, 0x5600000d, 0x24100001, 0x8ee204e4,
18190x3c040001, 0x24845754, 0xafa00014, 0xafa20010,
18200x8ee60608, 0x8f470228, 0x3c050009, 0x34a5f006,
18210xc002403, 0xafab0038, 0x8fab0038, 0x1200030a,
18220x240c0001, 0x8002f19, 0x0, 0x966c001c,
18230xafac002c, 0x9662001e, 0x3c0c8000, 0xafac0024,
18240xae62001c, 0x8e75001c, 0x8ee204fc, 0x8ee404fc,
18250x151900, 0x621021, 0x8c52000c, 0x92e27b98,
18260x641821, 0x9476000a, 0x14400003, 0x32c20002,
18270xaef27ba4, 0xaef57b9c, 0x1040004b, 0x8021,
18280x96e2045a, 0x30420002, 0x10400047, 0x0,
18290x8e63001c, 0x8ee204fc, 0x32100, 0x821021,
18300x8c42000c, 0x37e1821, 0x24420022, 0x43102b,
18310x1440000a, 0x24050014, 0x8ee204fc, 0x821021,
18320x8c44000c, 0xafab0038, 0xc002f75, 0x2484000e,
18330x8fab0038, 0x8002c52, 0x3050ffff, 0x8ee204fc,
18340x821021, 0x8c42000c, 0x9450000e, 0x94430010,
18350x94440012, 0x94450014, 0x2038021, 0x2048021,
18360x2058021, 0x94430016, 0x94440018, 0x9445001a,
18370x2038021, 0x2048021, 0x2058021, 0x9443001c,
18380x9444001e, 0x94420020, 0x2038021, 0x2048021,
18390x2028021, 0x101c02, 0x3202ffff, 0x628021,
18400x8e63001c, 0x8ee204fc, 0x102402, 0x32900,
18410xa21021, 0x8c43000c, 0x3202ffff, 0x828021,
18420x37e1021, 0x24630018, 0x62182b, 0x14600009,
18430x0, 0x8ee204fc, 0xa21021, 0x8c43000c,
18440x101027, 0x3c01ffff, 0x230821, 0x8002c6f,
18450xa4220018, 0x8ee204fc, 0xa21021, 0x8c43000c,
18460x101027, 0xa4620018, 0x96e2045a, 0x8821,
18470x30420008, 0x14400063, 0xa021, 0x8e63001c,
18480x8ee204fc, 0x33100, 0xc21021, 0x8c42000c,
18490x37e1821, 0x24420022, 0x43102b, 0x14400035,
18500x0, 0x8ee204fc, 0xc21021, 0x8c42000c,
18510x24470010, 0x37e1021, 0xe2102b, 0x50400001,
18520xeb3821, 0x8ee204fc, 0x94f10000, 0xc21021,
18530x8c42000c, 0x24470016, 0x37e1021, 0xe2102b,
18540x14400002, 0x2634ffec, 0xeb3821, 0x8ee204fc,
18550x90e30001, 0xc21021, 0x8c42000c, 0x2447001a,
18560x37e1021, 0xe2102b, 0x14400002, 0x2838821,
18570xeb3821, 0x94e20000, 0x24e70002, 0x2228821,
18580x37e1021, 0xe2102b, 0x50400001, 0xeb3821,
18590x94e20000, 0x24e70002, 0x2228821, 0x37e1021,
18600xe2102b, 0x50400001, 0xeb3821, 0x94e20000,
18610x24e70002, 0x2228821, 0x37e1021, 0xe2102b,
18620x50400001, 0xeb3821, 0x94e20000, 0x8002cd0,
18630x2228821, 0x8ee204fc, 0xc21021, 0x8c43000c,
18640x8ee204fc, 0x94710010, 0x8ee304fc, 0xc21021,
18650x8c44000c, 0xc31821, 0x8c62000c, 0x2634ffec,
18660x90840017, 0x8ee304fc, 0x9442001a, 0x2848821,
18670xc31821, 0x8c65000c, 0x8ee304fc, 0x2228821,
18680x8ee204fc, 0xc31821, 0xc21021, 0x8c44000c,
18690x8c62000c, 0x94a3001c, 0x9484001e, 0x94420020,
18700x2238821, 0x2248821, 0x2228821, 0x111c02,
18710x3222ffff, 0x628821, 0x111c02, 0x3222ffff,
18720x628821, 0x32c20001, 0x104000b2, 0x0,
18730x96e2045a, 0x30420001, 0x104000ae, 0x32c20080,
18740x10400008, 0x0, 0x92e27b98, 0x14400005,
18750x0, 0x240c0001, 0xa2ec7b98, 0xaef57b9c,
18760xaef27ba4, 0x8ee304fc, 0x151100, 0x431021,
18770x8c47000c, 0x37e1821, 0x24e2000e, 0x43102b,
18780x14400008, 0xe02021, 0x2405000e, 0xc002f75,
18790xafab0038, 0x3042ffff, 0x8fab0038, 0x8002d09,
18800x2028021, 0x94e60000, 0x24e70002, 0x94e50000,
18810x24e70002, 0x94e30000, 0x24e70002, 0x94e20000,
18820x24e70002, 0x94e40000, 0x24e70002, 0x2068021,
18830x2058021, 0x2038021, 0x2028021, 0x94e20000,
18840x94e30002, 0x2048021, 0x2028021, 0x2038021,
18850x101c02, 0x3202ffff, 0x628021, 0x101c02,
18860x3202ffff, 0x8ee47b9c, 0x628021, 0x14950004,
18870x3205ffff, 0x96620016, 0x8002d17, 0x512021,
18880x96620016, 0x542021, 0x41402, 0x3083ffff,
18890x432021, 0x852023, 0x41402, 0x822021,
18900x3084ffff, 0x50800001, 0x3404ffff, 0x8ee27ba4,
18910x24430017, 0x37e1021, 0x62102b, 0x50400001,
18920x6b1821, 0x90630000, 0x24020011, 0x14620031,
18930x24020006, 0x8ee27ba4, 0x37e1821, 0x24420028,
18940x43102b, 0x14400018, 0x0, 0x8ee27b9c,
18950x12a2000a, 0x32c20100, 0x8ee27ba4, 0x3c01ffff,
18960x220821, 0x94220028, 0x822021, 0x41c02,
18970x3082ffff, 0x622021, 0x32c20100, 0x14400004,
18980x41027, 0x92e27b98, 0x14400002, 0x41027,
18990x3044ffff, 0x8ee27ba4, 0x3c01ffff, 0x220821,
19000x8002d8a, 0xa4240028, 0x8ee27b9c, 0x12a20008,
19010x32c20100, 0x8ee27ba4, 0x94420028, 0x822021,
19020x41c02, 0x3082ffff, 0x622021, 0x32c20100,
19030x14400004, 0x41027, 0x92e27b98, 0x14400002,
19040x41027, 0x3044ffff, 0x8ee27ba4, 0x8002d8a,
19050xa4440028, 0x1462002f, 0x37e1821, 0x8ee27ba4,
19060x24420032, 0x43102b, 0x14400018, 0x0,
19070x8ee27b9c, 0x12a2000a, 0x32c20100, 0x8ee27ba4,
19080x3c01ffff, 0x220821, 0x94220032, 0x822021,
19090x41c02, 0x3082ffff, 0x622021, 0x32c20100,
19100x14400004, 0x41027, 0x92e27b98, 0x14400002,
19110x41027, 0x3044ffff, 0x8ee27ba4, 0x3c01ffff,
19120x220821, 0x8002d8a, 0xa4240032, 0x8ee27b9c,
19130x12a20008, 0x32c20100, 0x8ee27ba4, 0x94420032,
19140x822021, 0x41c02, 0x3082ffff, 0x622021,
19150x32c20100, 0x14400004, 0x41027, 0x92e27b98,
19160x14400002, 0x41027, 0x3044ffff, 0x8ee27ba4,
19170xa4440032, 0x8fac0024, 0x1180002c, 0x37e1821,
19180x8e420000, 0xae42fffc, 0x2642000a, 0x43102b,
19190x1440001b, 0x34038100, 0x26430004, 0x37e1021,
19200x62102b, 0x14400003, 0x602021, 0x6b1821,
19210x602021, 0x8c620000, 0x24630004, 0xae420000,
19220x37e1021, 0x62102b, 0x50400001, 0x6b1821,
19230x8c620000, 0xac820000, 0x34028100, 0xa4620000,
19240x24630002, 0x37e1021, 0x62102b, 0x50400001,
19250x6b1821, 0x97ac002e, 0x8002db4, 0xa46c0000,
19260x8e420004, 0x8e440008, 0xa6430008, 0x97ac002e,
19270xa64c000a, 0xae420000, 0xae440004, 0x9662000e,
19280x2652fffc, 0x24420004, 0xa662000e, 0x9662000e,
19290x8ee3725c, 0x621821, 0xaee3725c, 0xafb20018,
19300x8ee3725c, 0xafa3001c, 0x8ee2725c, 0x2c42003c,
19310x10400004, 0x24620001, 0x2403fffe, 0x431024,
19320xafa2001c, 0x32c20080, 0x1040000c, 0x32c20100,
19330x8ee27ba8, 0x24430001, 0x210c0, 0x571021,
19340xaee37ba8, 0x8fa30018, 0x8fa4001c, 0xac437bac,
19350xac447bb0, 0x8002ea0, 0xaee0725c, 0x10400072,
19360x0, 0x8ee27ba8, 0x24430001, 0x210c0,
19370x571021, 0xaee37ba8, 0x8fa30018, 0x8fa4001c,
19380xac437bac, 0xac447bb0, 0x8ee27ba8, 0x10400063,
19390x4821, 0x5021, 0x8f8200f0, 0x24480008,
19400x27621800, 0x102102b, 0x50400001, 0x27681000,
19410x8f8200f4, 0x15020007, 0x0, 0x8ee201b4,
19420x8021, 0x24420001, 0xaee201b4, 0x8002dfa,
19430x8ee201b4, 0x8f8300f0, 0x24100001, 0x1571021,
19440x8c447bac, 0x8c457bb0, 0xac640000, 0xac650004,
19450xaf8800f0, 0x16000006, 0x2ea1021, 0x8ee20088,
19460x24420001, 0xaee20088, 0x8002e3f, 0x8ee20088,
19470x8c427bb0, 0x8ee400e0, 0x8ee500e4, 0x8ee67b9c,
19480x401821, 0x1021, 0xa32821, 0xa3382b,
19490x822021, 0x872021, 0x8ee204fc, 0xc93021,
19500x63100, 0xaee400e0, 0xaee500e4, 0xc23021,
19510x94c2000a, 0x240c0002, 0x21142, 0x30430003,
19520x106c0016, 0x28620003, 0x10400005, 0x240c0001,
19530x106c0008, 0x0, 0x8002e3f, 0x0,
19540x240c0003, 0x106c0017, 0x0, 0x8002e3f,
19550x0, 0x8ee200e8, 0x8ee300ec, 0x24630001,
19560x2c640001, 0x441021, 0xaee200e8, 0xaee300ec,
19570x8ee200e8, 0x8002e3f, 0x8ee300ec, 0x8ee200f0,
19580x8ee300f4, 0x24630001, 0x2c640001, 0x441021,
19590xaee200f0, 0xaee300f4, 0x8ee200f0, 0x8002e3f,
19600x8ee300f4, 0x8ee200f8, 0x8ee300fc, 0x24630001,
19610x2c640001, 0x441021, 0xaee200f8, 0xaee300fc,
19620x8ee200f8, 0x8ee300fc, 0x8ee27ba8, 0x25290001,
19630x122102b, 0x1440ffa0, 0x254a0008, 0xa2e07b98,
19640x8002e9f, 0xaee07ba8, 0x8f8200f0, 0x24470008,
19650x27621800, 0xe2102b, 0x50400001, 0x27671000,
19660x8f8200f4, 0x14e20007, 0x0, 0x8ee201b4,
19670x8021, 0x24420001, 0xaee201b4, 0x8002e5d,
19680x8ee201b4, 0x8f8200f0, 0x24100001, 0x8fa30018,
19690x8fa4001c, 0xac430000, 0xac440004, 0xaf8700f0,
19700x16000007, 0x0, 0x8ee20088, 0x24420001,
19710xaee20088, 0x8ee20088, 0x8002ea0, 0xaee0725c,
19720x8ee2725c, 0x8ee400e0, 0x8ee500e4, 0x240c0002,
19730x401821, 0x1021, 0xa32821, 0xa3302b,
19740x822021, 0x862021, 0x161142, 0x30430003,
19750xaee400e0, 0xaee500e4, 0x106c0017, 0x2c620003,
19760x10400005, 0x240c0001, 0x106c0008, 0x0,
19770x8002ea0, 0xaee0725c, 0x240c0003, 0x106c0019,
19780x0, 0x8002ea0, 0xaee0725c, 0x8ee200e8,
19790x8ee300ec, 0x24630001, 0x2c640001, 0x441021,
19800xaee200e8, 0xaee300ec, 0x8ee200e8, 0x8ee300ec,
19810x8002ea0, 0xaee0725c, 0x8ee200f0, 0x8ee300f4,
19820x24630001, 0x2c640001, 0x441021, 0xaee200f0,
19830xaee300f4, 0x8ee200f0, 0x8ee300f4, 0x8002ea0,
19840xaee0725c, 0x8ee200f8, 0x8ee300fc, 0x24630001,
19850x2c640001, 0x441021, 0xaee200f8, 0xaee300fc,
19860x8ee200f8, 0x8ee300fc, 0xaee0725c, 0x8e62001c,
19870x96e30458, 0x8ee404f0, 0x24420001, 0x2463ffff,
19880x431024, 0x24840001, 0xaee204e4, 0xaee404f0,
19890x8f42023c, 0x82202b, 0x148000b0, 0x0,
19900x8f830120, 0x27623800, 0x24660020, 0xc2102b,
19910x50400001, 0x27663000, 0x8f820128, 0x10c20004,
19920x0, 0x8f820124, 0x14c20007, 0x0,
19930x8ee201a4, 0x8021, 0x24420001, 0xaee201a4,
19940x8002f07, 0x8ee201a4, 0x8ee204e4, 0xac62001c,
19950x8ee404b0, 0x8ee504b4, 0x2462001c, 0xac620008,
19960x24020008, 0xa462000e, 0x24020011, 0xac620018,
19970xac640000, 0xac650004, 0x8ee204c4, 0xac620010,
19980xaf860120, 0x92e24e20, 0x14400037, 0x24100001,
19990x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
20000x8c830000, 0x24020012, 0x1462001f, 0x0,
20010x8ee34e30, 0x8ee24e34, 0x1062001b, 0x240c0040,
20020x8c820004, 0x24420001, 0xac820004, 0x8ee24e34,
20030x8ee34e30, 0x24420001, 0x104c0007, 0x0,
20040x8ee24e34, 0x24420001, 0x10620005, 0x0,
20050x8002ef1, 0x0, 0x14600005, 0x0,
20060x8f820128, 0x24420020, 0xaf820128, 0x8f820128,
20070x8c820004, 0x2c420011, 0x50400013, 0xac800000,
20080x8002f07, 0x0, 0x8ee24e30, 0x240c0040,
20090x24420001, 0x504c0003, 0x1021, 0x8ee24e30,
20100x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
20110x24425038, 0x2e22021, 0x24020012, 0x240c0001,
20120xac820000, 0xac8c0004, 0x5600000d, 0x24100001,
20130x8ee204e4, 0x3c040001, 0x24845754, 0xafa00014,
20140xafa20010, 0x8ee60608, 0x8f470228, 0x3c050009,
20150x34a5f006, 0xc002403, 0xafab0038, 0x8fab0038,
20160x16000003, 0x240c0001, 0x8002f5c, 0xa2ec04f4,
20170x8ee20170, 0x24420001, 0xaee20170, 0x8ee20170,
20180x8ee204e4, 0xa2e004f4, 0xaee004f0, 0xaee07274,
20190xaee204f8, 0x8f42023c, 0x10400038, 0x0,
20200x8ee20184, 0x24420001, 0xaee20184, 0x8002f5c,
20210x8ee20184, 0x8ee20504, 0x240c0040, 0x24420001,
20220x504c0003, 0x1021, 0x8ee20504, 0x24420001,
20230xaee20504, 0x8ee20504, 0x8e630018, 0x240c0003,
20240x21080, 0x571021, 0x146c000f, 0x8c440508,
20250x3c020001, 0x571021, 0x904283b1, 0x10400014,
20260x0, 0x8ee201d0, 0x8ee35240, 0x441021,
20270xaee201d0, 0x8ee201d8, 0x641821, 0x306300ff,
20280x8002f4f, 0xaee35240, 0x8ee201cc, 0x8ee30e10,
20290x441021, 0xaee201cc, 0x8ee201d8, 0x641821,
20300x306301ff, 0xaee30e10, 0x441021, 0xaee201d8,
20310x8ee20000, 0x34420040, 0x8002f5c, 0xaee20000,
20320x8ee2014c, 0x3c010001, 0x370821, 0xa02083e0,
20330x24420001, 0xaee2014c, 0x8ee2014c, 0x8f820108,
20340x24420020, 0xaf820108, 0x8f820108, 0x8f820108,
20350x27633000, 0x43102b, 0x14400002, 0x27622800,
20360xaf820108, 0x8f830108, 0x8f820104, 0x1462fc1e,
20370x0, 0x8fbf0060, 0x8fbe005c, 0x8fb60058,
20380x8fb50054, 0x8fb40050, 0x8fb3004c, 0x8fb20048,
20390x8fb10044, 0x8fb00040, 0x3e00008, 0x27bd0068,
20400x52843, 0x10a0000d, 0x3021, 0x3c030001,
20410x34633800, 0x3c07ffff, 0x3631021, 0x82102b,
20420x50400001, 0x872021, 0x94820000, 0x24840002,
20430x24a5ffff, 0x14a0fff8, 0xc23021, 0x61c02,
20440x30c2ffff, 0x623021, 0x61c02, 0x30c2ffff,
20450x623021, 0x3e00008, 0x30c2ffff, 0x27bdff88,
20460x240f0001, 0xafbf0070, 0xafbe006c, 0xafb60068,
20470xafb50064, 0xafb40060, 0xafb3005c, 0xafb20058,
20480xafb10054, 0xafb00050, 0xa3a00027, 0xafaf002c,
20490x8ee204d4, 0x8021, 0x30420001, 0x1440002a,
20500xa3a00037, 0x8f8700e0, 0x8f8800c4, 0x8f8200e8,
20510xe22023, 0x2c821000, 0x50400001, 0x24841000,
20520x420c2, 0x801821, 0x8ee400c8, 0x8ee500cc,
20530x1021, 0xa32821, 0xa3302b, 0x822021,
20540x862021, 0xaee400c8, 0xaee500cc, 0x8f8300c8,
20550x3c02000a, 0x3442efff, 0x1032023, 0x44102b,
20560x10400003, 0x3c02000a, 0x3442f000, 0x822021,
20570x801821, 0x8ee400c0, 0x8ee500c4, 0x1021,
20580xa32821, 0xa3302b, 0x822021, 0x862021,
20590xaee400c0, 0xaee500c4, 0xaf8800c8, 0xaf8700e4,
20600x80034cc, 0xaf8700e8, 0x3c020001, 0x571021,
20610x904283c0, 0x1040000b, 0x0, 0x3c140001,
20620x297a021, 0x8e9483c4, 0x3c130001, 0x2779821,
20630x8e7383c8, 0x3c120001, 0x2579021, 0x8003193,
20640x8e5283cc, 0x8f8300e0, 0x8f8200e4, 0x10430007,
20650x8821, 0x8f8200e4, 0x24110001, 0x8c430000,
20660x8c440004, 0xafa30018, 0xafa4001c, 0x1620000e,
20670x3c02ffff, 0x8f8200c4, 0xafa20010, 0x8f8200c8,
20680x3c040001, 0x24845870, 0xafa20014, 0x8f8600e0,
20690x8f8700e4, 0x3c050006, 0xc002403, 0x34a5f000,
20700x80034cc, 0x0, 0x8fa3001c, 0x8fb20018,
20710x3074ffff, 0x2694fffc, 0x621024, 0x10400058,
20720x2409821, 0x3c020080, 0x621024, 0x1040000a,
20730x3c040040, 0x8ee2007c, 0x24420001, 0xaee2007c,
20740x8ee2007c, 0x8ee201fc, 0x24420001, 0xaee201fc,
20750x80034c6, 0x8ee201fc, 0x3c060004, 0x3c0b0001,
20760x3c0a0002, 0x3c050010, 0x3c090008, 0x8ee20080,
20770x3c080020, 0x34078000, 0x24420001, 0xaee20080,
20780x8ee20080, 0x8fa2001c, 0x441824, 0x10660021,
20790xc3102b, 0x14400007, 0x0, 0x106b0011,
20800x0, 0x106a0015, 0x0, 0x8003049,
20810x42042, 0x10650023, 0xa3102b, 0x14400005,
20820x0, 0x10690019, 0x0, 0x8003049,
20830x42042, 0x10680021, 0x0, 0x8003049,
20840x42042, 0x8ee20034, 0x24420001, 0xaee20034,
20850x8ee20034, 0x8003049, 0x42042, 0x8ee201ec,
20860x24420001, 0xaee201ec, 0x8ee201ec, 0x8003049,
20870x42042, 0x8ee201f0, 0x24420001, 0xaee201f0,
20880x8ee201f0, 0x8003049, 0x42042, 0x8ee201f4,
20890x24420001, 0xaee201f4, 0x8ee201f4, 0x8003049,
20900x42042, 0x8ee20030, 0x24420001, 0xaee20030,
20910x8ee20030, 0x8003049, 0x42042, 0x8ee201f8,
20920x24420001, 0xaee201f8, 0x8ee201f8, 0x42042,
20930x1087047c, 0x0, 0x800300e, 0x0,
20940x3c020001, 0x571021, 0x904283b2, 0x14400084,
20950x24020001, 0x3c030001, 0x771821, 0x906383b3,
20960x1462007f, 0x3c020100, 0x8e430000, 0x621024,
20970x1040006f, 0x2402ffff, 0x14620005, 0x24100001,
20980x96430004, 0x3402ffff, 0x10620075, 0x0,
20990x92e204d8, 0x14400072, 0x0, 0x3c020001,
21000x571021, 0x8c4283b4, 0x28420005, 0x10400020,
21010x3821, 0x3c020001, 0x571021, 0x8c4283b4,
21020x18400016, 0x2821, 0x96660000, 0x520c0,
21030x971021, 0x9442777e, 0x14460009, 0x971021,
21040x94437780, 0x96620002, 0x14620005, 0x971021,
21050x94437782, 0x96620004, 0x50620008, 0x24070001,
21060x3c020001, 0x571021, 0x8c4283b4, 0x24a50001,
21070xa2102a, 0x5440ffee, 0x520c0, 0x30e200ff,
21080x10400440, 0x0, 0x80030d5, 0x0,
21090x2402021, 0xc0022fe, 0x24050006, 0x3044001f,
21100x428c0, 0x2e51021, 0x9442727c, 0x30424000,
21110x14400434, 0xb71021, 0x9443727e, 0x96620000,
21120x1462000b, 0x418c0, 0xb71021, 0x94437280,
21130x96620002, 0x14620006, 0x418c0, 0xb71021,
21140x94437282, 0x96620004, 0x10620035, 0x418c0,
21150x2e31021, 0x9442727c, 0x30428000, 0x14400421,
21160x2e31021, 0x944b727c, 0x96670000, 0xb28c0,
21170xb71021, 0x9442737e, 0x80030b7, 0x3021,
21180x420c0, 0x2e41021, 0x9443737c, 0x2e41021,
21190x944b737c, 0x30638000, 0x14600010, 0xb28c0,
21200xb71021, 0x9442737e, 0x1447fff5, 0x1602021,
21210xb71021, 0x94437380, 0x96620002, 0x5462fff1,
21220x420c0, 0xb71021, 0x94437382, 0x96620004,
21230x5462ffec, 0x420c0, 0x24060001, 0x30c200ff,
21240x10400400, 0x0, 0x80030d5, 0x0,
21250x97430202, 0x96420000, 0x146203fa, 0x0,
21260x97430204, 0x96420002, 0x146203f6, 0x0,
21270x97430206, 0x96420004, 0x146203f2, 0x0,
21280x92420000, 0x3a030001, 0x30420001, 0x431024,
21290x10400074, 0x2402ffff, 0x8e630000, 0x14620004,
21300x3402ffff, 0x96630004, 0x1062006f, 0x240f0002,
21310x3c020001, 0x571021, 0x904283b2, 0x1440006a,
21320x240f0003, 0x92e204d8, 0x54400068, 0xafaf002c,
21330x3c020001, 0x571021, 0x8c4283b4, 0x28420005,
21340x10400020, 0x3821, 0x3c020001, 0x571021,
21350x8c4283b4, 0x18400016, 0x2821, 0x96660000,
21360x520c0, 0x971021, 0x9442777e, 0x14460009,
21370x971021, 0x94437780, 0x96620002, 0x14620005,
21380x971021, 0x94437782, 0x96620004, 0x50620008,
21390x24070001, 0x3c020001, 0x571021, 0x8c4283b4,
21400x24a50001, 0xa2102a, 0x5440ffee, 0x520c0,
21410x30e200ff, 0x14400044, 0x240f0003, 0x80034c6,
21420x0, 0x2402021, 0xc0022fe, 0x24050006,
21430x3044001f, 0x428c0, 0x2e51021, 0x9442727c,
21440x30424000, 0x144003af, 0xb71021, 0x9443727e,
21450x96620000, 0x1462000b, 0x418c0, 0xb71021,
21460x94437280, 0x96620002, 0x14620006, 0x418c0,
21470xb71021, 0x94437282, 0x96620004, 0x10620027,
21480x418c0, 0x2e31021, 0x9442727c, 0x30428000,
21490x1440039c, 0x2e31021, 0x944b727c, 0x96670000,
21500xb28c0, 0xb71021, 0x9442737e, 0x800313c,
21510x3021, 0x420c0, 0x2e41021, 0x9443737c,
21520x2e41021, 0x944b737c, 0x30638000, 0x14600010,
21530xb28c0, 0xb71021, 0x9442737e, 0x1447fff5,
21540x1602021, 0xb71021, 0x94437380, 0x96620002,
21550x5462fff1, 0x420c0, 0xb71021, 0x94437382,
21560x96620004, 0x5462ffec, 0x420c0, 0x24060001,
21570x30c200ff, 0x1040037b, 0x0, 0x800314f,
21580x240f0003, 0x240f0001, 0xafaf002c, 0x8f420260,
21590x54102b, 0x1040003a, 0x0, 0x8f8300e4,
21600x8f8200e0, 0x10620003, 0x24630008, 0xaf8300e4,
21610xaf8300e8, 0x8ee400c0, 0x8ee500c4, 0x2801821,
21620x1021, 0xa32821, 0xa3302b, 0x822021,
21630x862021, 0xaee400c0, 0xaee500c4, 0x8ee20058,
21640x24420001, 0xaee20058, 0x8ee20058, 0x8ee2007c,
21650x24420001, 0xaee2007c, 0x8ee2007c, 0x8f8200e0,
21660xafa20010, 0x8f8200e4, 0x3c040001, 0x24845878,
21670xafa20014, 0x8fa60018, 0x8fa7001c, 0x3c050006,
21680xc002403, 0x34a5f003, 0x80034cc, 0x0,
21690x8ee25240, 0xafa20010, 0x8ee25244, 0x3c040001,
21700x24845884, 0xafa20014, 0x8ee60e10, 0x8ee70e18,
21710x3c050006, 0xc002403, 0x34a5f002, 0x8ee201c0,
21720x24420001, 0xaee201c0, 0x8ee20000, 0x8ee301c0,
21730x2403ffbf, 0x431024, 0x8003470, 0xaee20000,
21740x96e20468, 0x54102b, 0x10400003, 0x0,
21750x240f0001, 0xa3af0027, 0x12800301, 0x24160007,
21760x24150040, 0x241e0001, 0x240e0012, 0x8ee2724c,
21770x8f430280, 0x24420001, 0x304207ff, 0x106202d3,
21780x0, 0x93a20027, 0x10400014, 0x0,
21790x8ee35240, 0x8ee25244, 0x10620009, 0x26ed5244,
21800x8ee65244, 0x8ee35244, 0x21140, 0x24425248,
21810x2e28021, 0x24630001, 0x80031bf, 0x306b00ff,
21820x92e27248, 0x1440ffca, 0x0, 0x8ee201e0,
21830x24420001, 0xaee201e0, 0x8ee201e0, 0x8ee30e10,
21840x8ee20e18, 0x1062ffc2, 0x26ed0e18, 0x8ee60e18,
21850x8ee30e18, 0x21140, 0x24420e20, 0x2e28021,
21860x24630001, 0x306b01ff, 0x96e2046a, 0x30420010,
21870x10400019, 0x0, 0x9642000c, 0x340f8100,
21880x144f0015, 0x0, 0x3c020001, 0x571021,
21890x904283c0, 0x14400010, 0x0, 0x9642000e,
21900xa6020016, 0x8e420008, 0x8e430004, 0x8e440000,
21910x2694fffc, 0xae42000c, 0xae430008, 0xae440004,
21920x9602000e, 0x26730004, 0x240f0001, 0xa3af0037,
21930x34420200, 0xa602000e, 0x8e020000, 0x8e030004,
21940x3c040001, 0x34843800, 0x306a0007, 0x26a9823,
21950x3641021, 0x262102b, 0x10400005, 0x28aa021,
21960x2641023, 0x3621823, 0x3c020020, 0x439823,
21970x26820007, 0x2404fff8, 0x9603000a, 0x446024,
21980x6a1821, 0x6c102b, 0x10400002, 0x1803821,
21990x603821, 0xae130018, 0x8f880120, 0x24e20007,
22000x443824, 0x27623800, 0x25090020, 0x122102b,
22010x50400001, 0x27693000, 0x8f820128, 0x11220004,
22020x0, 0x8f820124, 0x15220007, 0x1401821,
22030x8ee201a4, 0x8821, 0x24420001, 0xaee201a4,
22040x800324c, 0x8ee201a4, 0x8e040000, 0x8e050004,
22050x1021, 0xad130008, 0xa507000e, 0xad160018,
22060xad06001c, 0xa3302b, 0xa32823, 0x822023,
22070x862023, 0xad040000, 0xad050004, 0x8ee204c0,
22080xad020010, 0xaf890120, 0x92e24e20, 0x14400033,
22090x24110001, 0x8ee24e30, 0x210c0, 0x24425038,
22100x2e22021, 0x8c820000, 0x1456001f, 0x0,
22110x8ee34e30, 0x8ee24e34, 0x1062001b, 0x0,
22120x8c820004, 0x24420001, 0xac820004, 0x8ee24e34,
22130x8ee34e30, 0x24420001, 0x10550007, 0x0,
22140x8ee24e34, 0x24420001, 0x10620005, 0x0,
22150x8003239, 0x0, 0x14600005, 0x0,
22160x8f820128, 0x24420020, 0xaf820128, 0x8f820128,
22170x8c820004, 0x2c420011, 0x50400010, 0xac800000,
22180x800324c, 0x0, 0x8ee24e30, 0x24420001,
22190x50550003, 0x1021, 0x8ee24e30, 0x24420001,
22200xaee24e30, 0x8ee24e30, 0x210c0, 0x24425038,
22210x2e22021, 0xac960000, 0xac9e0004, 0x16200018,
22220x3c050006, 0x8e020018, 0x3c040001, 0x24845890,
22230xafa20010, 0x8e020000, 0x8e030004, 0x34a5f009,
22240x2003021, 0xc002403, 0xafa30014, 0x93a20037,
22250x10400216, 0x340f8100, 0x8e420004, 0x8e430008,
22260x8e44000c, 0xa64f000c, 0xae420000, 0xae430004,
22270xae440008, 0x96020016, 0x8003470, 0xa642000e,
22280x14ec0168, 0x28a1823, 0x960c000a, 0x9603000e,
22290x28a1023, 0xa602000a, 0x34620004, 0xa602000e,
22300x8f880120, 0x27623800, 0x25090020, 0x122102b,
22310x14400002, 0x306affff, 0x27693000, 0x8f820128,
22320x11220004, 0x0, 0x8f820124, 0x15220007,
22330x24040020, 0x8ee201a4, 0x8821, 0x24420001,
22340xaee201a4, 0x80032ca, 0x8ee201a4, 0x8ee5724c,
22350x8ee60490, 0x8ee70494, 0xa504000e, 0x24040004,
22360xad100008, 0xad040018, 0x52940, 0xa01821,
22370x1021, 0xe33821, 0xe3202b, 0xc23021,
22380xc43021, 0xad060000, 0xad070004, 0x8ee2724c,
22390xad02001c, 0x8ee204c4, 0xad020010, 0xaf890120,
22400x92e24e20, 0x14400033, 0x24110001, 0x8ee24e30,
22410x210c0, 0x24425038, 0x2e22021, 0x8c820000,
22420x1456001f, 0x0, 0x8ee34e30, 0x8ee24e34,
22430x1062001b, 0x0, 0x8c820004, 0x24420001,
22440xac820004, 0x8ee24e34, 0x8ee34e30, 0x24420001,
22450x10550007, 0x0, 0x8ee24e34, 0x24420001,
22460x10620005, 0x0, 0x80032b7, 0x0,
22470x14600005, 0x0, 0x8f820128, 0x24420020,
22480xaf820128, 0x8f820128, 0x8c820004, 0x2c420011,
22490x50400010, 0xac800000, 0x80032ca, 0x0,
22500x8ee24e30, 0x24420001, 0x50550003, 0x1021,
22510x8ee24e30, 0x24420001, 0xaee24e30, 0x8ee24e30,
22520x210c0, 0x24425038, 0x2e22021, 0xac960000,
22530xac9e0004, 0x1620000d, 0x0, 0xa60c000a,
22540xa60a000e, 0x8f820100, 0xafa20010, 0x8f820104,
22550x3c040001, 0x2484589c, 0x3c050006, 0xafa20014,
22560x8ee6724c, 0x800343b, 0x34a5f00b, 0x3c010001,
22570x370821, 0xa02083c0, 0xadab0000, 0x8ee201d8,
22580x8ee3724c, 0x2442ffff, 0xaee201d8, 0x8ee201d8,
22590x24630001, 0x306307ff, 0x26e25244, 0x15a20006,
22600xaee3724c, 0x8ee201d0, 0x2442ffff, 0xaee201d0,
22610x80032ef, 0x8ee201d0, 0x8ee201cc, 0x2442ffff,
22620xaee201cc, 0x8ee201cc, 0x8f420240, 0x10400073,
22630x0, 0x8ee20e1c, 0x24420001, 0xaee20e1c,
22640x8f430240, 0x43102b, 0x14400176, 0xa021,
22650x8f830120, 0x27623800, 0x24660020, 0xc2102b,
22660x50400001, 0x27663000, 0x8f820128, 0x10c20004,
22670x0, 0x8f820124, 0x14c20007, 0x0,
22680x8ee201a4, 0x8821, 0x24420001, 0xaee201a4,
22690x800334f, 0x8ee201a4, 0x8ee2724c, 0xac62001c,
22700x8ee404a8, 0x8ee504ac, 0x2462001c, 0xac620008,
22710x24020008, 0xa462000e, 0x24020011, 0xac620018,
22720xac640000, 0xac650004, 0x8ee204c4, 0xac620010,
22730xaf860120, 0x92e24e20, 0x14400033, 0x24110001,
22740x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
22750x8c820000, 0x144e001f, 0x0, 0x8ee34e30,
22760x8ee24e34, 0x1062001b, 0x0, 0x8c820004,
22770x24420001, 0xac820004, 0x8ee24e34, 0x8ee34e30,
22780x24420001, 0x10550007, 0x0, 0x8ee24e34,
22790x24420001, 0x10620005, 0x0, 0x800333c,
22800x0, 0x14600005, 0x0, 0x8f820128,
22810x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
22820x2c420011, 0x50400010, 0xac800000, 0x800334f,
22830x0, 0x8ee24e30, 0x24420001, 0x50550003,
22840x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
22850x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
22860xac8e0000, 0xac9e0004, 0x5620000d, 0x24110001,
22870x8ee2724c, 0x3c040001, 0x248458a8, 0xafa00014,
22880xafa20010, 0x8ee6724c, 0x8f470280, 0x3c050009,
22890x34a5f008, 0xc002403, 0xafae0048, 0x8fae0048,
22900x56200001, 0xaee00e1c, 0x8ee20188, 0x24420001,
22910xaee20188, 0x80033c8, 0x8ee20188, 0x8f830120,
22920x27623800, 0x24660020, 0xc2102b, 0x50400001,
22930x27663000, 0x8f820128, 0x10c20004, 0x0,
22940x8f820124, 0x14c20007, 0x0, 0x8ee201a4,
22950x8821, 0x24420001, 0xaee201a4, 0x80033ba,
22960x8ee201a4, 0x8ee2724c, 0xac62001c, 0x8ee404a8,
22970x8ee504ac, 0x2462001c, 0xac620008, 0x24020008,
22980xa462000e, 0x24020011, 0xac620018, 0xac640000,
22990xac650004, 0x8ee204c4, 0xac620010, 0xaf860120,
23000x92e24e20, 0x14400033, 0x24110001, 0x8ee24e30,
23010x210c0, 0x24425038, 0x2e22021, 0x8c820000,
23020x144e001f, 0x0, 0x8ee34e30, 0x8ee24e34,
23030x1062001b, 0x0, 0x8c820004, 0x24420001,
23040xac820004, 0x8ee24e34, 0x8ee34e30, 0x24420001,
23050x10550007, 0x0, 0x8ee24e34, 0x24420001,
23060x10620005, 0x0, 0x80033a7, 0x0,
23070x14600005, 0x0, 0x8f820128, 0x24420020,
23080xaf820128, 0x8f820128, 0x8c820004, 0x2c420011,
23090x50400010, 0xac800000, 0x80033ba, 0x0,
23100x8ee24e30, 0x24420001, 0x50550003, 0x1021,
23110x8ee24e30, 0x24420001, 0xaee24e30, 0x8ee24e30,
23120x210c0, 0x24425038, 0x2e22021, 0xac8e0000,
23130xac9e0004, 0x1620000d, 0x0, 0x8ee2724c,
23140x3c040001, 0x248458a8, 0xafa00014, 0xafa20010,
23150x8ee6724c, 0x8f470280, 0x3c050009, 0x34a5f008,
23160xc002403, 0xafae0048, 0x8fae0048, 0x8ee20174,
23170x24420001, 0xaee20174, 0x8ee20174, 0x800346e,
23180xa021, 0x960c000a, 0x183102b, 0x54400001,
23190x1801821, 0xa603000a, 0x8f880120, 0x27623800,
23200x25090020, 0x122102b, 0x50400001, 0x27693000,
23210x8f820128, 0x11220004, 0x0, 0x8f820124,
23220x15220007, 0x24040020, 0x8ee201a4, 0x8821,
23230x24420001, 0xaee201a4, 0x800342f, 0x8ee201a4,
23240x8ee5724c, 0x8ee60490, 0x8ee70494, 0xa504000e,
23250x24040004, 0xad100008, 0xad040018, 0x52940,
23260xa01821, 0x1021, 0xe33821, 0xe3202b,
23270xc23021, 0xc43021, 0xad060000, 0xad070004,
23280x8ee2724c, 0xad02001c, 0x8ee204c4, 0xad020010,
23290xaf890120, 0x92e24e20, 0x14400033, 0x24110001,
23300x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
23310x8c820000, 0x1456001f, 0x0, 0x8ee34e30,
23320x8ee24e34, 0x1062001b, 0x0, 0x8c820004,
23330x24420001, 0xac820004, 0x8ee24e34, 0x8ee34e30,
23340x24420001, 0x10550007, 0x0, 0x8ee24e34,
23350x24420001, 0x10620005, 0x0, 0x800341c,
23360x0, 0x14600005, 0x0, 0x8f820128,
23370x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
23380x2c420011, 0x50400010, 0xac800000, 0x800342f,
23390x0, 0x8ee24e30, 0x24420001, 0x50550003,
23400x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
23410x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
23420xac960000, 0xac9e0004, 0x1620001d, 0x0,
23430xa60c000a, 0x8f820100, 0xafa20010, 0x8f820104,
23440x3c040001, 0x2484589c, 0x3c050006, 0xafa20014,
23450x8ee6724c, 0x34a5f00d, 0xc002403, 0x2003821,
23460x93a20037, 0x10400031, 0x340f8100, 0x8e420004,
23470x8e430008, 0x8e44000c, 0xa64f000c, 0xae420000,
23480xae430004, 0xae440008, 0x96020016, 0xa642000e,
23490x9602000e, 0x3042fdff, 0x8003470, 0xa602000e,
23500x8ee201d8, 0x2442ffff, 0xaee201d8, 0x8ee201d8,
23510x8ee201cc, 0x3c04001f, 0x3c010001, 0x370821,
23520xa03e83c0, 0x2442ffff, 0xaee201cc, 0x9603000a,
23530x3484ffff, 0x8ee201cc, 0x6a1821, 0x2639821,
23540x93202b, 0x10800003, 0x3c02fff5, 0x34421000,
23550x2629821, 0xadab0000, 0x8ee2724c, 0x24420001,
23560x304207ff, 0xaee2724c, 0x8f420240, 0x10400004,
23570x283a023, 0x8ee20e1c, 0x24420001, 0xaee20e1c,
23580xa3a00027, 0x1680fd29, 0x0, 0x12800024,
23590x0, 0x3c010001, 0x370821, 0xac3483c4,
23600x3c010001, 0x370821, 0xac3383c8, 0x3c010001,
23610x370821, 0xac3283cc, 0x93a20037, 0x10400008,
23620x0, 0x3c020001, 0x571021, 0x8c4283cc,
23630x24420004, 0x3c010001, 0x370821, 0xac2283cc,
23640x8ee2724c, 0x8f430280, 0x24420001, 0x304207ff,
23650x14620006, 0x0, 0x8ee201c4, 0x24420001,
23660xaee201c4, 0x80034cc, 0x8ee201c4, 0x8ee201bc,
23670x24420001, 0xaee201bc, 0x80034cc, 0x8ee201bc,
23680x97a4001e, 0x2484fffc, 0x801821, 0x8ee400c0,
23690x8ee500c4, 0x1021, 0xa32821, 0xa3302b,
23700x822021, 0x862021, 0xaee400c0, 0xaee500c4,
23710x8faf002c, 0x24020002, 0x11e2000f, 0x29e20003,
23720x14400017, 0x24020003, 0x15e20015, 0x0,
23730x8ee200d0, 0x8ee300d4, 0x24630001, 0x2c640001,
23740x441021, 0xaee200d0, 0xaee300d4, 0x8ee200d0,
23750x80034c6, 0x8ee300d4, 0x8ee200d8, 0x8ee300dc,
23760x24630001, 0x2c640001, 0x441021, 0xaee200d8,
23770xaee300dc, 0x8ee200d8, 0x80034c6, 0x8ee300dc,
23780x8ee200c8, 0x8ee300cc, 0x24630001, 0x2c640001,
23790x441021, 0xaee200c8, 0xaee300cc, 0x8ee200c8,
23800x8ee300cc, 0x8f8300e4, 0x8f8200e0, 0x10620003,
23810x24630008, 0xaf8300e4, 0xaf8300e8, 0x8fbf0070,
23820x8fbe006c, 0x8fb60068, 0x8fb50064, 0x8fb40060,
23830x8fb3005c, 0x8fb20058, 0x8fb10054, 0x8fb00050,
23840x3e00008, 0x27bd0078, 0x27bdffb0, 0xafb50044,
23850xa821, 0xafb00030, 0x8021, 0xafbf004c,
23860xafb60048, 0xafb40040, 0xafb3003c, 0xafb20038,
23870xafb10034, 0x8ee204d4, 0x24140001, 0x30420001,
23880x1440002a, 0xb021, 0x8f8700e0, 0x8f8800c4,
23890x8f8200e8, 0xe22023, 0x2c821000, 0x50400001,
23900x24841000, 0x420c2, 0x801821, 0x8ee400c8,
23910x8ee500cc, 0x1021, 0xa32821, 0xa3302b,
23920x822021, 0x862021, 0xaee400c8, 0xaee500cc,
23930x8f8300c8, 0x3c02000a, 0x3442efff, 0x1032023,
23940x44102b, 0x10400003, 0x3c02000a, 0x3442f000,
23950x822021, 0x801821, 0x8ee400c0, 0x8ee500c4,
23960x1021, 0xa32821, 0xa3302b, 0x822021,
23970x862021, 0xaee400c0, 0xaee500c4, 0xaf8800c8,
23980xaf8700e4, 0x8003850, 0xaf8700e8, 0x3c020001,
23990x571021, 0x904283c0, 0x1040000b, 0x0,
24000x3c130001, 0x2779821, 0x8e7383c4, 0x3c110001,
24010x2378821, 0x8e3183c8, 0x3c120001, 0x2579021,
24020x80036e8, 0x8e5283cc, 0x8f8300e0, 0x8f8200e4,
24030x10430007, 0x4821, 0x8f8200e4, 0x24090001,
24040x8c430000, 0x8c440004, 0xafa30018, 0xafa4001c,
24050x1520000e, 0x3c02ffff, 0x8f8200c4, 0xafa20010,
24060x8f8200c8, 0x3c040001, 0x24845870, 0xafa20014,
24070x8f8600e0, 0x8f8700e4, 0x3c050006, 0xc002403,
24080x34a5f000, 0x8003850, 0x0, 0x8fa3001c,
24090x8fb20018, 0x3073ffff, 0x2673fffc, 0x621024,
24100x10400058, 0x2408821, 0x3c020080, 0x621024,
24110x1040000a, 0x3c040040, 0x8ee2007c, 0x24420001,
24120xaee2007c, 0x8ee2007c, 0x8ee201fc, 0x24420001,
24130xaee201fc, 0x800384a, 0x8ee201fc, 0x3c060004,
24140x3c0b0001, 0x3c0a0002, 0x3c050010, 0x3c090008,
24150x8ee20080, 0x3c080020, 0x34078000, 0x24420001,
24160xaee20080, 0x8ee20080, 0x8fa2001c, 0x441824,
24170x10660021, 0xc3102b, 0x14400007, 0x0,
24180x106b0011, 0x0, 0x106a0015, 0x0,
24190x8003592, 0x42042, 0x10650023, 0xa3102b,
24200x14400005, 0x0, 0x10690019, 0x0,
24210x8003592, 0x42042, 0x10680021, 0x0,
24220x8003592, 0x42042, 0x8ee20034, 0x24420001,
24230xaee20034, 0x8ee20034, 0x8003592, 0x42042,
24240x8ee201ec, 0x24420001, 0xaee201ec, 0x8ee201ec,
24250x8003592, 0x42042, 0x8ee201f0, 0x24420001,
24260xaee201f0, 0x8ee201f0, 0x8003592, 0x42042,
24270x8ee201f4, 0x24420001, 0xaee201f4, 0x8ee201f4,
24280x8003592, 0x42042, 0x8ee20030, 0x24420001,
24290xaee20030, 0x8ee20030, 0x8003592, 0x42042,
24300x8ee201f8, 0x24420001, 0xaee201f8, 0x8ee201f8,
24310x42042, 0x108702b7, 0x0, 0x8003557,
24320x0, 0x3c020001, 0x571021, 0x904283b2,
24330x14400084, 0x24020001, 0x3c030001, 0x771821,
24340x906383b3, 0x1462007f, 0x3c020100, 0x8e430000,
24350x621024, 0x1040006f, 0x2402ffff, 0x14620005,
24360x24100001, 0x96430004, 0x3402ffff, 0x10620075,
24370x0, 0x92e204d8, 0x14400072, 0x0,
24380x3c020001, 0x571021, 0x8c4283b4, 0x28420005,
24390x10400020, 0x3821, 0x3c020001, 0x571021,
24400x8c4283b4, 0x18400016, 0x2821, 0x96260000,
24410x520c0, 0x971021, 0x9442777e, 0x14460009,
24420x971021, 0x94437780, 0x96220002, 0x14620005,
24430x971021, 0x94437782, 0x96220004, 0x50620008,
24440x24070001, 0x3c020001, 0x571021, 0x8c4283b4,
24450x24a50001, 0xa2102a, 0x5440ffee, 0x520c0,
24460x30e200ff, 0x1040027b, 0x0, 0x800361e,
24470x0, 0x2402021, 0xc0022fe, 0x24050006,
24480x3044001f, 0x428c0, 0x2e51021, 0x9442727c,
24490x30424000, 0x1440026f, 0xb71021, 0x9443727e,
24500x96220000, 0x1462000b, 0x418c0, 0xb71021,
24510x94437280, 0x96220002, 0x14620006, 0x418c0,
24520xb71021, 0x94437282, 0x96220004, 0x10620035,
24530x418c0, 0x2e31021, 0x9442727c, 0x30428000,
24540x1440025c, 0x2e31021, 0x9448727c, 0x96270000,
24550x828c0, 0xb71021, 0x9442737e, 0x8003600,
24560x3021, 0x420c0, 0x2e41021, 0x9443737c,
24570x2e41021, 0x9448737c, 0x30638000, 0x14600010,
24580x828c0, 0xb71021, 0x9442737e, 0x1447fff5,
24590x1002021, 0xb71021, 0x94437380, 0x96220002,
24600x5462fff1, 0x420c0, 0xb71021, 0x94437382,
24610x96220004, 0x5462ffec, 0x420c0, 0x24060001,
24620x30c200ff, 0x1040023b, 0x0, 0x800361e,
24630x0, 0x97430202, 0x96420000, 0x14620235,
24640x0, 0x97430204, 0x96420002, 0x14620231,
24650x0, 0x97430206, 0x96420004, 0x1462022d,
24660x0, 0x92420000, 0x3a030001, 0x30420001,
24670x431024, 0x10400074, 0x2402ffff, 0x8e230000,
24680x14620004, 0x3402ffff, 0x96230004, 0x1062006f,
24690x24140002, 0x3c020001, 0x571021, 0x904283b2,
24700x1440006a, 0x24140003, 0x92e204d8, 0x14400067,
24710x0, 0x3c020001, 0x571021, 0x8c4283b4,
24720x28420005, 0x10400020, 0x3821, 0x3c020001,
24730x571021, 0x8c4283b4, 0x18400016, 0x2821,
24740x96260000, 0x520c0, 0x971021, 0x9442777e,
24750x14460009, 0x971021, 0x94437780, 0x96220002,
24760x14620005, 0x971021, 0x94437782, 0x96220004,
24770x50620008, 0x24070001, 0x3c020001, 0x571021,
24780x8c4283b4, 0x24a50001, 0xa2102a, 0x5440ffee,
24790x520c0, 0x30e200ff, 0x14400044, 0x24140003,
24800x800384a, 0x0, 0x2402021, 0xc0022fe,
24810x24050006, 0x3044001f, 0x428c0, 0x2e51021,
24820x9442727c, 0x30424000, 0x144001ea, 0xb71021,
24830x9443727e, 0x96220000, 0x1462000b, 0x418c0,
24840xb71021, 0x94437280, 0x96220002, 0x14620006,
24850x418c0, 0xb71021, 0x94437282, 0x96220004,
24860x10620027, 0x418c0, 0x2e31021, 0x9442727c,
24870x30428000, 0x144001d7, 0x2e31021, 0x9448727c,
24880x96270000, 0x828c0, 0xb71021, 0x9442737e,
24890x8003685, 0x3021, 0x420c0, 0x2e41021,
24900x9443737c, 0x2e41021, 0x9448737c, 0x30638000,
24910x14600010, 0x828c0, 0xb71021, 0x9442737e,
24920x1447fff5, 0x1002021, 0xb71021, 0x94437380,
24930x96220002, 0x5462fff1, 0x420c0, 0xb71021,
24940x94437382, 0x96220004, 0x5462ffec, 0x420c0,
24950x24060001, 0x30c200ff, 0x104001b6, 0x0,
24960x8003698, 0x24140003, 0x24140001, 0x8f420260,
24970x53102b, 0x10400049, 0x0, 0x8f8300e4,
24980x8f8200e0, 0x10620003, 0x24630008, 0xaf8300e4,
24990xaf8300e8, 0x8ee400c0, 0x8ee500c4, 0x2601821,
25000x1021, 0xa32821, 0xa3302b, 0x822021,
25010x862021, 0xaee400c0, 0xaee500c4, 0x8ee20058,
25020x24420001, 0xaee20058, 0x8ee20058, 0x8ee2007c,
25030x24420001, 0xaee2007c, 0x8ee2007c, 0x8f8200e0,
25040xafa20010, 0x8f8200e4, 0x3c040001, 0x24845878,
25050xafa20014, 0x8fa60018, 0x8fa7001c, 0x3c050006,
25060xc002403, 0x34a5f003, 0x8003850, 0x0,
25070x8ee25240, 0xafa20010, 0x8ee25244, 0x3c040001,
25080x24845884, 0xafa20014, 0x8ee60e10, 0x8ee70e18,
25090xc002403, 0x34a5f002, 0x8ee201c0, 0x24420001,
25100xaee201c0, 0x8ee20000, 0x8ee301c0, 0x2403ffbf,
25110x431024, 0x80037f8, 0xaee20000, 0x8ee25240,
25120xafa20010, 0x8ee25244, 0x3c040001, 0x24845884,
25130xafa20014, 0x8ee60e10, 0x8ee70e18, 0x3c050006,
25140xc002403, 0x34a5f002, 0x8ee201c0, 0x24420001,
25150xaee201c0, 0x80037f8, 0x8ee201c0, 0x96e20468,
25160x53102b, 0x54400001, 0x3c158000, 0x12600131,
25170x3c0c001f, 0x358cffff, 0x8ee2724c, 0x8f430280,
25180x24420001, 0x304207ff, 0x10620108, 0x0,
25190x12a00014, 0x0, 0x8ee35240, 0x8ee25244,
25200x10620009, 0x26ee5244, 0x8eeb5244, 0x8ee35244,
25210x21140, 0x24425248, 0x2e28021, 0x24630001,
25220x8003712, 0x306800ff, 0x92e27248, 0x1440ffc0,
25230x3c050006, 0x8ee201e0, 0x24420001, 0xaee201e0,
25240x8ee201e0, 0x8ee30e10, 0x8ee20e18, 0x1062ffcb,
25250x26ee0e18, 0x8eeb0e18, 0xa821, 0x8ee30e18,
25260x21140, 0x24420e20, 0x2e28021, 0x24630001,
25270x306801ff, 0x96e2046a, 0x30420010, 0x10400017,
25280x34028100, 0x9643000c, 0x14620014, 0x0,
25290x3c020001, 0x571021, 0x904283c0, 0x1440000f,
25300x0, 0x9642000e, 0xa6020016, 0x8e420008,
25310x8e430004, 0x8e440000, 0x2673fffc, 0xae42000c,
25320xae430008, 0xae440004, 0x9602000e, 0x26310004,
25330x24160001, 0x34420200, 0xa602000e, 0x9603000a,
25340x2605021, 0x73102b, 0x10400002, 0x2606821,
25350x605021, 0x2d42003d, 0x1040002a, 0x3821,
25360x9623000c, 0x24020800, 0x54620027, 0xae110018,
25370x3c020001, 0x571021, 0x904283c0, 0x54400022,
25380xae110018, 0x26220017, 0x182102b, 0x10400013,
25390x0, 0x3c02fff5, 0x511021, 0x90421017,
25400x38430006, 0x2c630001, 0x38420011, 0x2c420001,
25410x621825, 0x10600013, 0x26220010, 0x182102b,
25420x1040000e, 0x0, 0x3c07fff5, 0xf13821,
25430x94e71010, 0x800375e, 0x24e7000e, 0x92220017,
25440x38430006, 0x2c630001, 0x38420011, 0x2c420001,
25450x621825, 0x50600004, 0xae110018, 0x96270010,
25460x24e7000e, 0xae110018, 0x3c020001, 0x571021,
25470x904283c0, 0x2102b, 0x14e00002, 0x24ec0,
25480x1403821, 0x8f830120, 0x27623800, 0x24660020,
25490xc2102b, 0x50400001, 0x27663000, 0x8f820128,
25500x10c20004, 0x0, 0x8f820124, 0x14c20007,
25510x2402000b, 0x8ee201a4, 0x4821, 0x24420001,
25520xaee201a4, 0x80037bf, 0x8ee201a4, 0x8e040000,
25530x8e050004, 0xac620018, 0x1751025, 0x491025,
25540xac710008, 0xa467000e, 0xac62001c, 0xac640000,
25550xac650004, 0x8ee204c0, 0xac620010, 0xaf860120,
25560x92e24e20, 0x14400038, 0x24090001, 0x8ee24e30,
25570x210c0, 0x24425038, 0x2e22021, 0x8c830000,
25580x24020007, 0x14620020, 0x0, 0x8ee34e30,
25590x8ee24e34, 0x1062001c, 0x0, 0x8c820004,
25600x24420001, 0xac820004, 0x8ee34e34, 0x8ee54e30,
25610x24020040, 0x24630001, 0x10620007, 0x0,
25620x8ee24e34, 0x24420001, 0x10a20005, 0x0,
25630x80037a9, 0x0, 0x14a00005, 0x0,
25640x8f820128, 0x24420020, 0xaf820128, 0x8f820128,
25650x8c820004, 0x2c420011, 0x50400013, 0xac800000,
25660x80037bf, 0x0, 0x8ee24e30, 0x24030040,
25670x24420001, 0x50430003, 0x1021, 0x8ee24e30,
25680x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
25690x24425038, 0x2e22021, 0x24020007, 0xac820000,
25700x24020001, 0xac820004, 0x15200018, 0x3c050006,
25710x8e020018, 0x3c040001, 0x24845890, 0xafa20010,
25720x8e020000, 0x8e030004, 0x34a5f009, 0x2003021,
25730xc002403, 0xafa30014, 0x32c200ff, 0x1040002b,
25740x34028100, 0x8e430004, 0x8e440008, 0x8e45000c,
25750xa642000c, 0xae430000, 0xae440004, 0xae450008,
25760x96020016, 0x80037f8, 0xa642000e, 0x154d000a,
25770x0, 0x9602000e, 0xa613000a, 0x34420004,
25780xa602000e, 0x3c010001, 0x370821, 0xa02083c0,
25790x80037f6, 0x9821, 0x9604000a, 0x93102b,
25800x10400002, 0x2601821, 0x801821, 0x24020001,
25810xa603000a, 0x3c010001, 0x370821, 0xa02283c0,
25820x9604000a, 0x2248821, 0x191102b, 0x10400003,
25830x3c02fff5, 0x34421000, 0x2228821, 0x2649823,
25840xa821, 0x1660fef4, 0xadc80000, 0x12600021,
25850x32c200ff, 0x3c010001, 0x370821, 0xac3383c4,
25860x3c010001, 0x370821, 0xac3183c8, 0x3c010001,
25870x370821, 0x10400008, 0xac3283cc, 0x3c020001,
25880x571021, 0x8c4283cc, 0x24420004, 0x3c010001,
25890x370821, 0xac2283cc, 0x8ee2724c, 0x8f430280,
25900x24420001, 0x14620006, 0x0, 0x8ee201c4,
25910x24420001, 0xaee201c4, 0x8003850, 0x8ee201c4,
25920x8ee201bc, 0x24420001, 0xaee201bc, 0x8003850,
25930x8ee201bc, 0x97a4001e, 0x2484fffc, 0x801821,
25940x8ee400c0, 0x8ee500c4, 0x1021, 0xa32821,
25950xa3302b, 0x822021, 0x862021, 0x24020002,
25960xaee400c0, 0xaee500c4, 0x1282000f, 0x2a820003,
25970x14400017, 0x24020003, 0x16820015, 0x0,
25980x8ee200d0, 0x8ee300d4, 0x24630001, 0x2c640001,
25990x441021, 0xaee200d0, 0xaee300d4, 0x8ee200d0,
26000x800384a, 0x8ee300d4, 0x8ee200d8, 0x8ee300dc,
26010x24630001, 0x2c640001, 0x441021, 0xaee200d8,
26020xaee300dc, 0x8ee200d8, 0x800384a, 0x8ee300dc,
26030x8ee200c8, 0x8ee300cc, 0x24630001, 0x2c640001,
26040x441021, 0xaee200c8, 0xaee300cc, 0x8ee200c8,
26050x8ee300cc, 0x8f8300e4, 0x8f8200e0, 0x10620003,
26060x24630008, 0xaf8300e4, 0xaf8300e8, 0x8fbf004c,
26070x8fb60048, 0x8fb50044, 0x8fb40040, 0x8fb3003c,
26080x8fb20038, 0x8fb10034, 0x8fb00030, 0x3e00008,
26090x27bd0050, 0x27bdff90, 0xafb60060, 0xb021,
26100xafbf0068, 0xafbe0064, 0xafb5005c, 0xafb40058,
26110xafb30054, 0xafb20050, 0xafb1004c, 0xafb00048,
26120x8ee204d4, 0x8821, 0x24150001, 0x30420001,
26130x1440002a, 0xa3a0002f, 0x8f8700e0, 0x8f8800c4,
26140x8f8200e8, 0xe22023, 0x2c821000, 0x50400001,
26150x24841000, 0x420c2, 0x801821, 0x8ee400c8,
26160x8ee500cc, 0x1021, 0xa32821, 0xa3302b,
26170x822021, 0x862021, 0xaee400c8, 0xaee500cc,
26180x8f8300c8, 0x3c02000a, 0x3442efff, 0x1032023,
26190x44102b, 0x10400003, 0x3c02000a, 0x3442f000,
26200x822021, 0x801821, 0x8ee400c0, 0x8ee500c4,
26210x1021, 0xa32821, 0xa3302b, 0x822021,
26220x862021, 0xaee400c0, 0xaee500c4, 0xaf8800c8,
26230xaf8700e4, 0x8003c5b, 0xaf8700e8, 0x3c020001,
26240x571021, 0x904283c0, 0x1040000b, 0x0,
26250x3c130001, 0x2779821, 0x8e7383c4, 0x3c100001,
26260x2178021, 0x8e1083c8, 0x3c120001, 0x2579021,
26270x8003a59, 0x8e5283cc, 0x8f8300e0, 0x8f8200e4,
26280x10430007, 0x3821, 0x8f8200e4, 0x24070001,
26290x8c430000, 0x8c440004, 0xafa30018, 0xafa4001c,
26300x14e0000e, 0x3c02ffff, 0x8f8200c4, 0xafa20010,
26310x8f8200c8, 0x3c040001, 0x248458b4, 0xafa20014,
26320x8f8600e0, 0x8f8700e4, 0x3c050006, 0xc002403,
26330x34a5f200, 0x8003c5b, 0x0, 0x8fa3001c,
26340x8fb20018, 0x3073ffff, 0x2673fffc, 0x621024,
26350x10400058, 0x2408021, 0x3c020080, 0x621024,
26360x1040000a, 0x3c040040, 0x8ee2007c, 0x24420001,
26370xaee2007c, 0x8ee2007c, 0x8ee201fc, 0x24420001,
26380xaee201fc, 0x8003c55, 0x8ee201fc, 0x3c060004,
26390x3c0b0001, 0x3c0a0002, 0x3c050010, 0x3c090008,
26400x8ee20080, 0x3c080020, 0x34078000, 0x24420001,
26410xaee20080, 0x8ee20080, 0x8fa2001c, 0x441824,
26420x10660021, 0xc3102b, 0x14400007, 0x0,
26430x106b0011, 0x0, 0x106a0015, 0x0,
26440x8003916, 0x42042, 0x10650023, 0xa3102b,
26450x14400005, 0x0, 0x10690019, 0x0,
26460x8003916, 0x42042, 0x10680021, 0x0,
26470x8003916, 0x42042, 0x8ee20034, 0x24420001,
26480xaee20034, 0x8ee20034, 0x8003916, 0x42042,
26490x8ee201ec, 0x24420001, 0xaee201ec, 0x8ee201ec,
26500x8003916, 0x42042, 0x8ee201f0, 0x24420001,
26510xaee201f0, 0x8ee201f0, 0x8003916, 0x42042,
26520x8ee201f4, 0x24420001, 0xaee201f4, 0x8ee201f4,
26530x8003916, 0x42042, 0x8ee20030, 0x24420001,
26540xaee20030, 0x8ee20030, 0x8003916, 0x42042,
26550x8ee201f8, 0x24420001, 0xaee201f8, 0x8ee201f8,
26560x42042, 0x1087033e, 0x0, 0x80038db,
26570x0, 0x3c020001, 0x571021, 0x904283b2,
26580x14400084, 0x24020001, 0x3c030001, 0x771821,
26590x906383b3, 0x1462007f, 0x3c020100, 0x8e430000,
26600x621024, 0x1040006f, 0x2402ffff, 0x14620005,
26610x24110001, 0x96430004, 0x3402ffff, 0x10620075,
26620x0, 0x92e204d8, 0x14400072, 0x0,
26630x3c020001, 0x571021, 0x8c4283b4, 0x28420005,
26640x10400020, 0x3821, 0x3c020001, 0x571021,
26650x8c4283b4, 0x18400016, 0x2821, 0x96060000,
26660x520c0, 0x971021, 0x9442777e, 0x14460009,
26670x971021, 0x94437780, 0x96020002, 0x14620005,
26680x971021, 0x94437782, 0x96020004, 0x50620008,
26690x24070001, 0x3c020001, 0x571021, 0x8c4283b4,
26700x24a50001, 0xa2102a, 0x5440ffee, 0x520c0,
26710x30e200ff, 0x10400302, 0x0, 0x80039a2,
26720x0, 0x2402021, 0xc0022fe, 0x24050006,
26730x3044001f, 0x428c0, 0x2e51021, 0x9442727c,
26740x30424000, 0x144002f6, 0xb71021, 0x9443727e,
26750x96020000, 0x1462000b, 0x418c0, 0xb71021,
26760x94437280, 0x96020002, 0x14620006, 0x418c0,
26770xb71021, 0x94437282, 0x96020004, 0x10620035,
26780x418c0, 0x2e31021, 0x9442727c, 0x30428000,
26790x144002e3, 0x2e31021, 0x944d727c, 0x96070000,
26800xd28c0, 0xb71021, 0x9442737e, 0x8003984,
26810x3021, 0x420c0, 0x2e41021, 0x9443737c,
26820x2e41021, 0x944d737c, 0x30638000, 0x14600010,
26830xd28c0, 0xb71021, 0x9442737e, 0x1447fff5,
26840x1a02021, 0xb71021, 0x94437380, 0x96020002,
26850x5462fff1, 0x420c0, 0xb71021, 0x94437382,
26860x96020004, 0x5462ffec, 0x420c0, 0x24060001,
26870x30c200ff, 0x104002c2, 0x0, 0x80039a2,
26880x0, 0x97430202, 0x96420000, 0x146202bc,
26890x0, 0x97430204, 0x96420002, 0x146202b8,
26900x0, 0x97430206, 0x96420004, 0x146202b4,
26910x0, 0x92420000, 0x3a230001, 0x30420001,
26920x431024, 0x10400074, 0x2402ffff, 0x8e030000,
26930x14620004, 0x3402ffff, 0x96030004, 0x1062006f,
26940x24150002, 0x3c020001, 0x571021, 0x904283b2,
26950x1440006a, 0x24150003, 0x92e204d8, 0x14400067,
26960x0, 0x3c020001, 0x571021, 0x8c4283b4,
26970x28420005, 0x10400020, 0x3821, 0x3c020001,
26980x571021, 0x8c4283b4, 0x18400016, 0x2821,
26990x96060000, 0x520c0, 0x971021, 0x9442777e,
27000x14460009, 0x971021, 0x94437780, 0x96020002,
27010x14620005, 0x971021, 0x94437782, 0x96020004,
27020x50620008, 0x24070001, 0x3c020001, 0x571021,
27030x8c4283b4, 0x24a50001, 0xa2102a, 0x5440ffee,
27040x520c0, 0x30e200ff, 0x14400044, 0x24150003,
27050x8003c55, 0x0, 0x2402021, 0xc0022fe,
27060x24050006, 0x3044001f, 0x428c0, 0x2e51021,
27070x9442727c, 0x30424000, 0x14400271, 0xb71021,
27080x9443727e, 0x96020000, 0x1462000b, 0x418c0,
27090xb71021, 0x94437280, 0x96020002, 0x14620006,
27100x418c0, 0xb71021, 0x94437282, 0x96020004,
27110x10620027, 0x418c0, 0x2e31021, 0x9442727c,
27120x30428000, 0x1440025e, 0x2e31021, 0x944d727c,
27130x96070000, 0xd28c0, 0xb71021, 0x9442737e,
27140x8003a09, 0x3021, 0x420c0, 0x2e41021,
27150x9443737c, 0x2e41021, 0x944d737c, 0x30638000,
27160x14600010, 0xd28c0, 0xb71021, 0x9442737e,
27170x1447fff5, 0x1a02021, 0xb71021, 0x94437380,
27180x96020002, 0x5462fff1, 0x420c0, 0xb71021,
27190x94437382, 0x96020004, 0x5462ffec, 0x420c0,
27200x24060001, 0x30c200ff, 0x1040023d, 0x0,
27210x8003a1c, 0x24150003, 0x24150001, 0x8f420260,
27220x53102b, 0x10400036, 0x0, 0x8f8300e4,
27230x8f8200e0, 0x10620003, 0x24630008, 0xaf8300e4,
27240xaf8300e8, 0x8ee400c0, 0x8ee500c4, 0x2601821,
27250x1021, 0xa32821, 0xa3302b, 0x822021,
27260x862021, 0xaee400c0, 0xaee500c4, 0x8ee20058,
27270x24420001, 0xaee20058, 0x8ee20058, 0x8ee2007c,
27280x24420001, 0xaee2007c, 0x8ee2007c, 0x8f8200e0,
27290xafa20010, 0x8f8200e4, 0x3c040001, 0x248458c0,
27300xafa20014, 0x8fa60018, 0x8fa7001c, 0x3c050006,
27310xc002403, 0x34a5f203, 0x8003c5b, 0x0,
27320x8ee25240, 0xafa20010, 0x8ee25244, 0x3c040001,
27330x248458cc, 0xafa20014, 0x8ee60e10, 0x8ee70e18,
27340x3c050006, 0xc002403, 0x34a5f202, 0x8ee201c0,
27350x24420001, 0xaee201c0, 0x8003c02, 0x8ee201c0,
27360x96e20468, 0x53102b, 0x54400001, 0x3c168000,
27370x126001cb, 0x3c0e001f, 0x35ceffff, 0x3c0ffff5,
27380x35ef1000, 0x241e0040, 0x8ee2724c, 0x8f430280,
27390x24420001, 0x304207ff, 0x1062019e, 0x0,
27400x12c00012, 0x0, 0x8ee35240, 0x8ee25244,
27410x1062000a, 0x26f85244, 0x8ef45244, 0xafb80024,
27420x8ee35244, 0x21140, 0x24425248, 0x2e28821,
27430x24630001, 0x8003a85, 0x306d00ff, 0x8ee201e0,
27440x24420001, 0xaee201e0, 0x8ee201e0, 0x8ee30e10,
27450x8ee20e18, 0x1062ffca, 0x26f80e18, 0x8ef40e18,
27460xb021, 0xafb80024, 0x8ee30e18, 0x21140,
27470x24420e20, 0x2e28821, 0x24630001, 0x306d01ff,
27480x96e2046a, 0x30420010, 0x10400018, 0x34028100,
27490x9643000c, 0x14620015, 0x0, 0x3c020001,
27500x571021, 0x904283c0, 0x14400010, 0x0,
27510x9642000e, 0xa6220016, 0x8e420008, 0x8e430004,
27520x8e440000, 0x2673fffc, 0xae42000c, 0xae430008,
27530xae440004, 0x9622000e, 0x26100004, 0x24180001,
27540xa3b8002f, 0x34420200, 0xa622000e, 0x8e220000,
27550x8e230004, 0x3c040001, 0x34843800, 0x2003021,
27560x306a0007, 0x20a8023, 0x3641021, 0x202102b,
27570x10400005, 0x26a9821, 0x2041023, 0x3621823,
27580x3c020020, 0x438023, 0x26620007, 0x9623000a,
27590x2418fff8, 0x58c824, 0x6a1821, 0x79102b,
27600x10400002, 0x3206021, 0x606021, 0x1801821,
27610x24620007, 0x2418fff8, 0x586024, 0x26c102b,
27620x14400004, 0x1932823, 0x1832823, 0x8003ac3,
27630xc31021, 0xd31021, 0x4a2023, 0x1c4102b,
27640x54400001, 0x8f2021, 0x25420040, 0x4c102b,
27650x14400035, 0x5821, 0x94c3000c, 0x24020800,
27660x54620032, 0xae260018, 0x3c020001, 0x571021,
27670x904283c0, 0x5440002d, 0xae260018, 0x24c20017,
27680x1c2102b, 0x10400013, 0x0, 0x3c02fff5,
27690x461021, 0x90421017, 0x38430006, 0x2c630001,
27700x38420011, 0x2c420001, 0x621825, 0x10600014,
27710x24c20010, 0x1c2102b, 0x1040000e, 0x0,
27720x3c0bfff5, 0x1665821, 0x956b1010, 0x8003af4,
27730x2562000e, 0x90c20017, 0x38430006, 0x2c630001,
27740x38420011, 0x2c420001, 0x621825, 0x10600005,
27750x1601821, 0x94cb0010, 0x2562000e, 0x4a5821,
27760x1601821, 0x24620007, 0x2418fff8, 0x585824,
27770xc31021, 0x4a2023, 0x1c4102b, 0x10400002,
27780x1632823, 0x8f2021, 0xae260018, 0x3c020001,
27790x571021, 0x904283c0, 0x2102b, 0x216c0,
27800x15600002, 0xafa20044, 0x1805821, 0x30820001,
27810x10400007, 0x4021, 0x90880000, 0x24840001,
27820x1c4102b, 0x10400002, 0x24a5ffff, 0x8f2021,
27830x50a00012, 0x81c02, 0x2ca20002, 0x54400009,
27840x24a5ffff, 0x94820000, 0x24840002, 0x1024021,
27850x1c4102b, 0x10400006, 0x24a5fffe, 0x8003b21,
27860x8f2021, 0x90820000, 0x21200, 0x1024021,
27870x14a0fff2, 0x2ca20002, 0x81c02, 0x3102ffff,
27880x624021, 0x3108ffff, 0x1402821, 0x11400011,
27890x2002021, 0x2ca20002, 0x54400009, 0x24a5ffff,
27900x94820000, 0x24840002, 0x1024021, 0x1c4102b,
27910x10400006, 0x24a5fffe, 0x8003b38, 0x8f2021,
27920x90820000, 0x21200, 0x1024021, 0x14a0fff2,
27930x2ca20002, 0x81c02, 0x3102ffff, 0x624021,
27940x81c02, 0x3102ffff, 0x8f890120, 0x624021,
27950x27623800, 0x25230020, 0x62102b, 0x14400002,
27960x3108ffff, 0x27633000, 0x8f820128, 0x10620004,
27970x0, 0x8f820124, 0x14620007, 0x1402821,
27980x8ee201a4, 0x3821, 0x24420001, 0xaee201a4,
27990x8003bc9, 0x8ee201a4, 0x8e260000, 0x8e270004,
28000x81400, 0x3448000b, 0xad300008, 0xa52b000e,
28010xad280018, 0x8fb80044, 0x2021, 0x2961025,
28020x581025, 0xad22001c, 0xe5102b, 0xe53823,
28030xc43023, 0xc23023, 0xad260000, 0xad270004,
28040x8ee204c0, 0xad220010, 0xaf830120, 0x92e24e20,
28050x1440005f, 0x24070001, 0x2502ffee, 0x2c420002,
28060x14400003, 0x24020011, 0x15020024, 0x0,
28070x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
28080x8c830000, 0x24020012, 0x1462000f, 0x0,
28090x8ee34e30, 0x8ee24e34, 0x1062000b, 0x0,
28100x8c820004, 0x24420001, 0xac820004, 0x8ee24e34,
28110x8ee34e30, 0x24420001, 0x105e002a, 0x0,
28120x8003ba8, 0x0, 0x8ee24e30, 0x24420001,
28130x505e0003, 0x1021, 0x8ee24e30, 0x24420001,
28140xaee24e30, 0x8ee24e30, 0x210c0, 0x24425038,
28150x2e22021, 0x8003bc6, 0x24020012, 0x8ee24e30,
28160x210c0, 0x24425038, 0x2e22021, 0x8c830000,
28170x24020007, 0x1462001f, 0x0, 0x8ee34e30,
28180x8ee24e34, 0x1062001b, 0x0, 0x8c820004,
28190x24420001, 0xac820004, 0x8ee24e34, 0x8ee34e30,
28200x24420001, 0x105e0007, 0x0, 0x8ee24e34,
28210x24420001, 0x10620005, 0x0, 0x8003bb4,
28220x0, 0x14600005, 0x0, 0x8f820128,
28230x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
28240x2c420011, 0x50400012, 0xac800000, 0x8003bc9,
28250x0, 0x8ee24e30, 0x24420001, 0x505e0003,
28260x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
28270x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
28280x24020007, 0xac820000, 0x24020001, 0xac820004,
28290x14e00019, 0x3c050006, 0x3c040001, 0x24845890,
28300x8e220018, 0x34a5f209, 0xafa20010, 0x8e220000,
28310x8e230004, 0x2203021, 0x1603821, 0xc002403,
28320xafa30014, 0x93a2002f, 0x1040002a, 0x34028100,
28330x8e430004, 0x8e440008, 0x8e45000c, 0xa642000c,
28340xae430000, 0xae440004, 0xae450008, 0x96220016,
28350x8003c02, 0xa642000e, 0x1599000a, 0x26a1823,
28360x9622000e, 0xa623000a, 0x34420004, 0xa622000e,
28370x3c010001, 0x370821, 0xa02083c0, 0x8003bff,
28380x9821, 0x9624000a, 0x83102b, 0x54400001,
28390x801821, 0x24020001, 0xa623000a, 0x3c010001,
28400x370821, 0xa02283c0, 0x9622000a, 0x4a1821,
28410x2038021, 0x1d0102b, 0x54400001, 0x20f8021,
28420x2639823, 0xb021, 0x8fb80024, 0x1660fe5e,
28430xaf0d0000, 0x12600022, 0x0, 0x3c010001,
28440x370821, 0xac3383c4, 0x3c010001, 0x370821,
28450xac3083c8, 0x3c010001, 0x370821, 0xac3283cc,
28460x93a2002f, 0x10400008, 0x0, 0x3c020001,
28470x571021, 0x8c4283cc, 0x24420004, 0x3c010001,
28480x370821, 0xac2283cc, 0x8f430280, 0x8ee2724c,
28490x14620006, 0x0, 0x8ee201c4, 0x24420001,
28500xaee201c4, 0x8003c5b, 0x8ee201c4, 0x8ee201bc,
28510x24420001, 0xaee201bc, 0x8003c5b, 0x8ee201bc,
28520x97a4001e, 0x2484fffc, 0x801821, 0x8ee400c0,
28530x8ee500c4, 0x1021, 0xa32821, 0xa3302b,
28540x822021, 0x862021, 0x24020002, 0xaee400c0,
28550xaee500c4, 0x12a2000f, 0x2aa20003, 0x14400017,
28560x24020003, 0x16a20015, 0x0, 0x8ee200d0,
28570x8ee300d4, 0x24630001, 0x2c640001, 0x441021,
28580xaee200d0, 0xaee300d4, 0x8ee200d0, 0x8003c55,
28590x8ee300d4, 0x8ee200d8, 0x8ee300dc, 0x24630001,
28600x2c640001, 0x441021, 0xaee200d8, 0xaee300dc,
28610x8ee200d8, 0x8003c55, 0x8ee300dc, 0x8ee200c8,
28620x8ee300cc, 0x24630001, 0x2c640001, 0x441021,
28630xaee200c8, 0xaee300cc, 0x8ee200c8, 0x8ee300cc,
28640x8f8300e4, 0x8f8200e0, 0x10620003, 0x24630008,
28650xaf8300e4, 0xaf8300e8, 0x8fbf0068, 0x8fbe0064,
28660x8fb60060, 0x8fb5005c, 0x8fb40058, 0x8fb30054,
28670x8fb20050, 0x8fb1004c, 0x8fb00048, 0x3e00008,
28680x27bd0070, 0x27bdffe0, 0xafbf0018, 0x8ee30e14,
28690x8ee20e0c, 0x10620074, 0x0, 0x8ee30e0c,
28700x8ee20e14, 0x622023, 0x4820001, 0x24840200,
28710x8ee30e18, 0x8ee20e14, 0x43102b, 0x14400004,
28720x24020200, 0x8ee30e14, 0x8003c7d, 0x431823,
28730x8ee20e18, 0x8ee30e14, 0x431023, 0x2443ffff,
28740x804821, 0x69102a, 0x54400001, 0x604821,
28750x8f870100, 0x27623000, 0x24e80020, 0x102102b,
28760x50400001, 0x27682800, 0x8f820108, 0x11020004,
28770x0, 0x8f820104, 0x15020007, 0x1021,
28780x8ee201a8, 0x2021, 0x24420001, 0xaee201a8,
28790x8003cbf, 0x8ee201a8, 0x8ee40e14, 0x42140,
28800x801821, 0x8ee40460, 0x8ee50464, 0xa32821,
28810xa3302b, 0x822021, 0x862021, 0xace40000,
28820xace50004, 0x8ee30e14, 0x91140, 0xa4e2000e,
28830x24020002, 0xace20018, 0x31940, 0x24630e20,
28840x2e31021, 0xace20008, 0x8ee20e14, 0xace2001c,
28850x8ee204cc, 0xace20010, 0xaf880100, 0x92e204ec,
28860x14400011, 0x24040001, 0x8ee24e28, 0x24030040,
28870x24420001, 0x50430003, 0x1021, 0x8ee24e28,
28880x24420001, 0xaee24e28, 0x8ee24e28, 0x210c0,
28890x24424e38, 0x2e21821, 0x24020002, 0xac620000,
28900x24020001, 0xac620004, 0x1480000e, 0x24030040,
28910x8ee20e14, 0xafa20010, 0x8ee20e18, 0x3c050007,
28920xafa20014, 0x8ee60e0c, 0x8ee70e10, 0x3c040001,
28930x248458d4, 0xc002403, 0x34a5f001, 0x8003cdd,
28940x0, 0x8ee20500, 0x24420001, 0x50430003,
28950x1021, 0x8ee20500, 0x24420001, 0xaee20500,
28960x8ee20500, 0x21080, 0x571021, 0xac490508,
28970x8ee20e14, 0x491021, 0x304201ff, 0xaee20e14,
28980x8ee30e14, 0x8ee20e0c, 0x14620005, 0x0,
28990x8f820060, 0x2403fdff, 0x431024, 0xaf820060,
29000x8fbf0018, 0x3e00008, 0x27bd0020, 0x27bdffe0,
29010xafbf0018, 0x8ee3523c, 0x8ee25238, 0x10620074,
29020x0, 0x8ee35238, 0x8ee2523c, 0x622023,
29030x4820001, 0x24840100, 0x8ee35244, 0x8ee2523c,
29040x43102b, 0x14400004, 0x24020100, 0x8ee3523c,
29050x8003cff, 0x431823, 0x8ee25244, 0x8ee3523c,
29060x431023, 0x2443ffff, 0x804821, 0x69102a,
29070x54400001, 0x604821, 0x8f870100, 0x27623000,
29080x24e80020, 0x102102b, 0x50400001, 0x27682800,
29090x8f820108, 0x11020004, 0x0, 0x8f820104,
29100x15020007, 0x1021, 0x8ee201a8, 0x2021,
29110x24420001, 0xaee201a8, 0x8003d41, 0x8ee201a8,
29120x8ee4523c, 0x42140, 0x801821, 0x8ee40470,
29130x8ee50474, 0xa32821, 0xa3302b, 0x822021,
29140x862021, 0xace40000, 0xace50004, 0x8ee3523c,
29150x91140, 0xa4e2000e, 0x24020003, 0xace20018,
29160x31940, 0x24635248, 0x2e31021, 0xace20008,
29170x8ee2523c, 0xace2001c, 0x8ee204cc, 0xace20010,
29180xaf880100, 0x92e204ec, 0x14400011, 0x24040001,
29190x8ee24e28, 0x24030040, 0x24420001, 0x50430003,
29200x1021, 0x8ee24e28, 0x24420001, 0xaee24e28,
29210x8ee24e28, 0x210c0, 0x24424e38, 0x2e21821,
29220x24020003, 0xac620000, 0x24020001, 0xac620004,
29230x1480000e, 0x24030040, 0x8ee2523c, 0xafa20010,
29240x8ee25244, 0x3c050007, 0xafa20014, 0x8ee65238,
29250x8ee75240, 0x3c040001, 0x248458e0, 0xc002403,
29260x34a5f010, 0x8003d5f, 0x0, 0x8ee20500,
29270x24420001, 0x50430003, 0x1021, 0x8ee20500,
29280x24420001, 0xaee20500, 0x8ee20500, 0x21080,
29290x571021, 0xac490508, 0x8ee2523c, 0x491021,
29300x304200ff, 0xaee2523c, 0x8ee3523c, 0x8ee25238,
29310x14620005, 0x0, 0x8f820060, 0x2403feff,
29320x431024, 0xaf820060, 0x8fbf0018, 0x3e00008,
29330x27bd0020, 0x8f820120, 0x8ee34e34, 0x8f820124,
29340x8f860128, 0x24020040, 0x24630001, 0x50620003,
29350x1021, 0x8ee24e34, 0x24420001, 0xaee24e34,
29360x8ee24e34, 0x8ee44e34, 0x8ee34e30, 0x210c0,
29370x24425038, 0x14830007, 0x2e22821, 0x8f820128,
29380x24420020, 0xaf820128, 0x8f820128, 0x8003d92,
29390xaca00000, 0x8ee24e34, 0x24030040, 0x24420001,
29400x50430003, 0x1021, 0x8ee24e34, 0x24420001,
29410x210c0, 0x24425038, 0x2e22821, 0x8ca20004,
29420x8f830128, 0x21140, 0x621821, 0xaf830128,
29430xaca00000, 0x8cc20018, 0x2443fffe, 0x2c620012,
29440x10400008, 0x31080, 0x3c010001, 0x220821,
29450x8c2258f0, 0x400008, 0x0, 0x24020001,
29460xaee24e24, 0x3e00008, 0x0, 0x27bdffc8,
29470xafbf0030, 0xafb5002c, 0xafb40028, 0xafb30024,
29480xafb20020, 0xafb1001c, 0xafb00018, 0x8f830128,
29490x8f820124, 0x106202b0, 0x9821, 0x3c11001f,
29500x3631ffff, 0x3c12fff5, 0x36521000, 0x24150012,
29510x24140040, 0x8f8c0128, 0x8f820128, 0x24420020,
29520xaf820128, 0x9182001b, 0x8f830128, 0x2443fffe,
29530x2c620012, 0x1040029c, 0x31080, 0x3c010001,
29540x220821, 0x8c225948, 0x400008, 0x0,
29550x8f420218, 0x30420100, 0x10400007, 0x0,
29560x95830016, 0x95820018, 0x621823, 0x31402,
29570x431021, 0xa5820016, 0x8d82001c, 0x3c038000,
29580x3044ffff, 0x436824, 0x3c030800, 0x431824,
29590x11a00004, 0xad84001c, 0x41140, 0x8003dd8,
29600x24425248, 0x41140, 0x24420e20, 0x2e25821,
29610x9562000e, 0x3042fffc, 0x10600004, 0xa562000e,
29620x95840016, 0x8003ec0, 0x0, 0x8d690018,
29630x4021, 0x952a0000, 0x25290002, 0x95270000,
29640x25290002, 0x95260000, 0x25290002, 0x95250000,
29650x25290002, 0x95240000, 0x25290002, 0x95230000,
29660x25290002, 0x95220000, 0x25290002, 0x1475021,
29670x1465021, 0x1455021, 0x1445021, 0x1435021,
29680x1425021, 0xa1c02, 0x3142ffff, 0x625021,
29690xa1c02, 0x3142ffff, 0x625021, 0x96e2046a,
29700x314effff, 0x30420002, 0x10400044, 0x5021,
29710x25220014, 0x222102b, 0x10400014, 0x1201821,
29720x2405000a, 0x2021, 0x223102b, 0x54400001,
29730x721821, 0x94620000, 0x24630002, 0x24a5ffff,
29740x14a0fff9, 0x822021, 0x41c02, 0x3082ffff,
29750x622021, 0x41402, 0x3083ffff, 0x431021,
29760x3042ffff, 0x8003e33, 0x1425021, 0x952a0000,
29770x25290002, 0x95280000, 0x25290002, 0x95270000,
29780x25290002, 0x95260000, 0x25290002, 0x95250000,
29790x25290002, 0x95230000, 0x25290002, 0x95220000,
29800x25290002, 0x95240000, 0x25290002, 0x1485021,
29810x1475021, 0x1465021, 0x1455021, 0x1435021,
29820x1425021, 0x95220000, 0x95230002, 0x1445021,
29830x1425021, 0x1435021, 0xa1c02, 0x3142ffff,
29840x625021, 0xa1c02, 0x3142ffff, 0x625021,
29850x3148ffff, 0x51000001, 0x3408ffff, 0x8d620018,
29860x9443000c, 0x24020800, 0x54620005, 0xa5680010,
29870x9562000e, 0x34420002, 0xa562000e, 0xa5680010,
29880x96e2046a, 0x2821, 0x30420008, 0x14400056,
29890x3021, 0x8d630018, 0x24620024, 0x222102b,
29900x10400034, 0x24690010, 0x229102b, 0x54400001,
29910x1324821, 0x95250000, 0x24690014, 0x229102b,
29920x10400002, 0x24a5ffec, 0x1324821, 0x95220000,
29930x30420fff, 0x14400003, 0x25290002, 0x8003e60,
29940x24130001, 0x9821, 0xa03021, 0x229102b,
29950x54400001, 0x1324821, 0x91220001, 0x25290002,
29960xa22821, 0x229102b, 0x54400001, 0x1324821,
29970x25290002, 0x229102b, 0x54400001, 0x1324821,
29980x95220000, 0x25290002, 0xa22821, 0x229102b,
29990x54400001, 0x1324821, 0x95220000, 0x25290002,
30000xa22821, 0x229102b, 0x54400001, 0x1324821,
30010x95220000, 0x25290002, 0xa22821, 0x229102b,
30020x54400001, 0x1324821, 0x95220000, 0x8003e99,
30030xa22821, 0x94650010, 0x94620014, 0x24690016,
30040x30420fff, 0x14400003, 0x24a5ffec, 0x8003e8c,
30050x24130001, 0x9821, 0xa03021, 0x91230001,
30060x25290004, 0x95220000, 0x25290002, 0x95240000,
30070x25290002, 0xa32821, 0xa22821, 0x95220000,
30080x95230002, 0xa42821, 0xa22821, 0xa32821,
30090x51c02, 0x30a2ffff, 0x622821, 0x51c02,
30100x30a2ffff, 0x622821, 0x96e2046a, 0x30420001,
30110x1040001e, 0x2021, 0x95820016, 0x4e2023,
30120x41402, 0x822021, 0x326200ff, 0x50400002,
30130x862021, 0x852021, 0x41402, 0x822021,
30140x3084ffff, 0x50800001, 0x3404ffff, 0x8d620018,
30150x24430017, 0x223102b, 0x54400001, 0x721821,
30160x90620000, 0x38430011, 0x2c630001, 0x38420006,
30170x2c420001, 0x621825, 0x10600004, 0x0,
30180x9562000e, 0x34420001, 0xa562000e, 0x9562000e,
30190x240a0002, 0x30420004, 0x10400002, 0xa5640012,
30200x240a0004, 0x8f880120, 0x27623800, 0x25090020,
30210x122102b, 0x50400001, 0x27693000, 0x8f820128,
30220x11220004, 0x0, 0x8f820124, 0x15220007,
30230x24040020, 0x8ee201a4, 0x8021, 0x24420001,
30240xaee201a4, 0x8003f4f, 0x8ee201a4, 0x8ee5724c,
30250x8ee60490, 0x8ee70494, 0xad0b0008, 0xa504000e,
30260xad0a0018, 0x52940, 0xa01821, 0x1021,
30270xe33821, 0xe3202b, 0xc23021, 0xc43021,
30280xad060000, 0xad070004, 0x8ee2724c, 0x4d1025,
30290xad02001c, 0x8ee204c4, 0xad020010, 0xaf890120,
30300x92e24e20, 0x14400060, 0x24100001, 0x2543ffee,
30310x2c630002, 0x39420011, 0x2c420001, 0x621825,
30320x10600024, 0x0, 0x8ee24e30, 0x210c0,
30330x24425038, 0x2e22021, 0x8c820000, 0x1455000f,
30340x0, 0x8ee34e30, 0x8ee24e34, 0x1062000b,
30350x0, 0x8c820004, 0x24420001, 0xac820004,
30360x8ee24e34, 0x8ee34e30, 0x24420001, 0x1054002b,
30370x0, 0x8003f2e, 0x0, 0x8ee24e30,
30380x24420001, 0x50540003, 0x1021, 0x8ee24e30,
30390x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
30400x24425038, 0x2e22021, 0x24020001, 0x8003f4e,
30410xac950000, 0x8ee24e30, 0x210c0, 0x24425038,
30420x2e22021, 0x8c830000, 0x24020007, 0x1462001f,
30430x0, 0x8ee34e30, 0x8ee24e34, 0x1062001b,
30440x0, 0x8c820004, 0x24420001, 0xac820004,
30450x8ee24e34, 0x8ee34e30, 0x24420001, 0x10540007,
30460x0, 0x8ee24e34, 0x24420001, 0x10620005,
30470x0, 0x8003f3a, 0x0, 0x14600005,
30480x0, 0x8f820128, 0x24420020, 0xaf820128,
30490x8f820128, 0x8c820004, 0x2c420011, 0x50400012,
30500xac800000, 0x8003f4f, 0x0, 0x8ee24e30,
30510x24420001, 0x50540003, 0x1021, 0x8ee24e30,
30520x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
30530x24425038, 0x2e22021, 0x24020007, 0xac820000,
30540x24020001, 0xac820004, 0x1600000d, 0x0,
30550x8f820120, 0x3c040001, 0x24845938, 0xafa00014,
30560xafa20010, 0x8d86001c, 0x8f870124, 0x3c050008,
30570xc002403, 0x34a50001, 0x8004057, 0x0,
30580x8ee2724c, 0x24420001, 0x304207ff, 0x11a00006,
30590xaee2724c, 0x8ee201d0, 0x2442ffff, 0xaee201d0,
30600x8003f6b, 0x8ee201d0, 0x8ee201cc, 0x2442ffff,
30610xaee201cc, 0x8ee201cc, 0x8ee201d8, 0x2442ffff,
30620xaee201d8, 0x8004057, 0x8ee201d8, 0x8f420240,
30630x104000e5, 0x0, 0x8ee20e1c, 0x24420001,
30640x8004057, 0xaee20e1c, 0x9582001e, 0xad82001c,
30650x8f420240, 0x10400072, 0x0, 0x8ee20e1c,
30660x24420001, 0xaee20e1c, 0x8f430240, 0x43102b,
30670x144000d5, 0x0, 0x8f830120, 0x27623800,
30680x24660020, 0xc2102b, 0x50400001, 0x27663000,
30690x8f820128, 0x10c20004, 0x0, 0x8f820124,
30700x14c20007, 0x0, 0x8ee201a4, 0x8021,
30710x24420001, 0xaee201a4, 0x8003fda, 0x8ee201a4,
30720x8ee2724c, 0xac62001c, 0x8ee404a8, 0x8ee504ac,
30730x2462001c, 0xac620008, 0x24020008, 0xa462000e,
30740x24020011, 0xac620018, 0xac640000, 0xac650004,
30750x8ee204c4, 0xac620010, 0xaf860120, 0x92e24e20,
30760x14400034, 0x24100001, 0x8ee24e30, 0x210c0,
30770x24425038, 0x2e22021, 0x8c820000, 0x1455001f,
30780x0, 0x8ee34e30, 0x8ee24e34, 0x1062001b,
30790x0, 0x8c820004, 0x24420001, 0xac820004,
30800x8ee24e34, 0x8ee34e30, 0x24420001, 0x10540007,
30810x0, 0x8ee24e34, 0x24420001, 0x10620005,
30820x0, 0x8003fc6, 0x0, 0x14600005,
30830x0, 0x8f820128, 0x24420020, 0xaf820128,
30840x8f820128, 0x8c820004, 0x2c420011, 0x50400011,
30850xac800000, 0x8003fda, 0x0, 0x8ee24e30,
30860x24420001, 0x50540003, 0x1021, 0x8ee24e30,
30870x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
30880x24425038, 0x2e22021, 0x24020001, 0xac950000,
30890xac820004, 0x5600000b, 0x24100001, 0x8ee2724c,
30900x3c040001, 0x248458a8, 0xafa00014, 0xafa20010,
30910x8ee6724c, 0x8f470280, 0x3c050009, 0xc002403,
30920x34a5f008, 0x56000001, 0xaee00e1c, 0x8ee20188,
30930x24420001, 0xaee20188, 0x8004050, 0x8ee20188,
30940x8f830120, 0x27623800, 0x24660020, 0xc2102b,
30950x50400001, 0x27663000, 0x8f820128, 0x10c20004,
30960x0, 0x8f820124, 0x14c20007, 0x0,
30970x8ee201a4, 0x8021, 0x24420001, 0xaee201a4,
30980x8004044, 0x8ee201a4, 0x8ee2724c, 0xac62001c,
30990x8ee404a8, 0x8ee504ac, 0x2462001c, 0xac620008,
31000x24020008, 0xa462000e, 0x24020011, 0xac620018,
31010xac640000, 0xac650004, 0x8ee204c4, 0xac620010,
31020xaf860120, 0x92e24e20, 0x14400034, 0x24100001,
31030x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
31040x8c820000, 0x1455001f, 0x0, 0x8ee34e30,
31050x8ee24e34, 0x1062001b, 0x0, 0x8c820004,
31060x24420001, 0xac820004, 0x8ee24e34, 0x8ee34e30,
31070x24420001, 0x10540007, 0x0, 0x8ee24e34,
31080x24420001, 0x10620005, 0x0, 0x8004030,
31090x0, 0x14600005, 0x0, 0x8f820128,
31100x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
31110x2c420011, 0x50400011, 0xac800000, 0x8004044,
31120x0, 0x8ee24e30, 0x24420001, 0x50540003,
31130x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
31140x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
31150x24020001, 0xac950000, 0xac820004, 0x1600000b,
31160x0, 0x8ee2724c, 0x3c040001, 0x248458a8,
31170xafa00014, 0xafa20010, 0x8ee6724c, 0x8f470280,
31180x3c050009, 0xc002403, 0x34a5f008, 0x8ee20174,
31190x24420001, 0xaee20174, 0x8004057, 0x8ee20174,
31200x24020001, 0xaee24e24, 0x8f830128, 0x8f820124,
31210x1462fd58, 0x0, 0x8fbf0030, 0x8fb5002c,
31220x8fb40028, 0x8fb30024, 0x8fb20020, 0x8fb1001c,
31230x8fb00018, 0x3e00008, 0x27bd0038, 0x27bdffe8,
31240x27840208, 0x27450200, 0x24060008, 0xafbf0014,
31250xc00249a, 0xafb00010, 0x2021, 0x24100001,
31260x2402241f, 0xaf900210, 0xaf900200, 0xaf800204,
31270xaf820214, 0x8f460248, 0x24030004, 0x3c020040,
31280x3c010001, 0xac235cc4, 0x3c010001, 0xac235cc8,
31290x3c010001, 0xac205d9c, 0x3c010001, 0xac225cc0,
31300x3c010001, 0xac235cc8, 0xc005108, 0x24050004,
31310xc004822, 0x0, 0x8ee20000, 0x3c03feff,
31320x3463fffd, 0x431024, 0xaee20000, 0x3c023c00,
31330xaf82021c, 0x3c010001, 0x370821, 0xac3083ac,
31340x8fbf0014, 0x8fb00010, 0x3e00008, 0x27bd0018,
31350x27bdffe0, 0x3c050008, 0x34a50400, 0xafbf0018,
31360xafa00010, 0xafa00014, 0x8f860200, 0x3c040001,
31370x248459f0, 0xc002403, 0x3821, 0x8ee20280,
31380x24420001, 0xaee20280, 0x8ee20280, 0x8f830200,
31390x3c023f00, 0x621824, 0x8fbf0018, 0x3c020400,
31400x3e00008, 0x27bd0020, 0x27bdffd8, 0xafbf0020,
31410xafb1001c, 0xafb00018, 0x8f900220, 0x8ee20214,
31420x3821, 0x24420001, 0xaee20214, 0x8ee20214,
31430x3c020300, 0x2021024, 0x10400027, 0x3c110400,
31440xc00429b, 0x0, 0x3c020100, 0x2021024,
31450x10400007, 0x0, 0x8ee20218, 0x24420001,
31460xaee20218, 0x8ee20218, 0x80040c6, 0x3c03fdff,
31470x8ee2021c, 0x24420001, 0xaee2021c, 0x8ee2021c,
31480x3c03fdff, 0x3463ffff, 0x3c0808ff, 0x3508ffff,
31490x8ee20000, 0x3c040001, 0x248459fc, 0x3c050008,
31500x2003021, 0x431024, 0xaee20000, 0x8f820220,
31510x3821, 0x3c030300, 0x481024, 0x431025,
31520xaf820220, 0xafa00010, 0xc002403, 0xafa00014,
31530x8004296, 0x0, 0x2111024, 0x1040001f,
31540x3c024000, 0x8f830224, 0x24021402, 0x1462000b,
31550x3c03fdff, 0x3c040001, 0x24845a08, 0x3c050008,
31560xafa00010, 0xafa00014, 0x8f860224, 0x34a5ffff,
31570xc002403, 0x3821, 0x3c03fdff, 0x8ee20000,
31580x3463ffff, 0x2002021, 0x431024, 0xc004e54,
31590xaee20000, 0x8ee20220, 0x24420001, 0xaee20220,
31600x8ee20220, 0x8f820220, 0x3c0308ff, 0x3463ffff,
31610x431024, 0x8004295, 0x511025, 0x2021024,
31620x10400142, 0x0, 0x8ee2022c, 0x24420001,
31630xaee2022c, 0x8ee2022c, 0x8f820220, 0x3c0308ff,
31640x3463ffff, 0x431024, 0x34420004, 0xaf820220,
31650x8f830054, 0x8f820054, 0x800410e, 0x24630002,
31660x8f820054, 0x621023, 0x2c420003, 0x1440fffc,
31670x0, 0x8f8600e0, 0x8f8400e4, 0x30c20007,
31680x10400012, 0x0, 0x8f8300e4, 0x2402fff8,
31690xc21024, 0x1043000d, 0x0, 0x8f820054,
31700x8f8300e0, 0x14c30009, 0x24440050, 0x8f820054,
31710x821023, 0x2c420051, 0x10400004, 0x0,
31720x8f8200e0, 0x10c2fff9, 0x0, 0x8f820220,
31730x3c0308ff, 0x3463fffd, 0x431024, 0xaf820220,
31740x8f8600e0, 0x30c20007, 0x10400003, 0x2402fff8,
31750xc23024, 0xaf8600e0, 0x8f8300c4, 0x3c02001f,
31760x3442ffff, 0x24680008, 0x48102b, 0x10400003,
31770x3c02fff5, 0x34421000, 0x1024021, 0x8f8b00c8,
31780x8f850120, 0x8f840124, 0x8004145, 0x6021,
31790x27623800, 0x82102b, 0x50400001, 0x27643000,
31800x10a40010, 0x318200ff, 0x8c820018, 0x38430007,
31810x2c630001, 0x3842000b, 0x2c420001, 0x621825,
31820x5060fff3, 0x24840020, 0x8ee20240, 0x240c0001,
31830x24420001, 0xaee20240, 0x8ee20240, 0x8c8b0008,
31840x318200ff, 0x14400065, 0x0, 0x3c020001,
31850x571021, 0x904283c0, 0x14400060, 0x0,
31860x8f8400e4, 0xc41023, 0x218c3, 0x4620001,
31870x24630200, 0x8f8900c4, 0x10600005, 0x24020001,
31880x10620009, 0x0, 0x8004187, 0x0,
31890x8ee20230, 0x1205821, 0x24420001, 0xaee20230,
31900x80041bc, 0x8ee20230, 0x8ee20234, 0x3c05000a,
31910x24420001, 0xaee20234, 0x8c8b0000, 0x34a5f000,
31920x8ee20234, 0x12b1823, 0xa3102b, 0x54400001,
31930x651821, 0x2c62233f, 0x14400040, 0x0,
31940x8f8200e8, 0x24420008, 0xaf8200e8, 0x8f8200e8,
31950x8f8200e4, 0x1205821, 0x24420008, 0xaf8200e4,
31960x80041bc, 0x8f8200e4, 0x8ee20238, 0x3c03000a,
31970x24420001, 0xaee20238, 0x8c840000, 0x3463f000,
31980x8ee20238, 0x883823, 0x67102b, 0x54400001,
31990xe33821, 0x3c020003, 0x34420d40, 0x47102b,
32000x10400003, 0x0, 0x80041bc, 0x805821,
32010x8f8200e4, 0x24440008, 0xaf8400e4, 0x8f8400e4,
32020x10860018, 0x3c05000a, 0x34a5f000, 0x3c0a0003,
32030x354a0d40, 0x8ee2007c, 0x24420001, 0xaee2007c,
32040x8c830000, 0x8ee2007c, 0x683823, 0xa7102b,
32050x54400001, 0xe53821, 0x147102b, 0x54400007,
32060x605821, 0x8f8200e4, 0x24440008, 0xaf8400e4,
32070x8f8400e4, 0x1486ffef, 0x0, 0x14860005,
32080x0, 0x1205821, 0xaf8600e4, 0x80041bc,
32090xaf8600e8, 0xaf8400e4, 0xaf8400e8, 0x8f8200c8,
32100x3c03000a, 0x3463f000, 0x483823, 0x67102b,
32110x54400001, 0xe33821, 0x3c020003, 0x34420d3f,
32120x47102b, 0x54400007, 0x6021, 0x1683823,
32130x67102b, 0x54400003, 0xe33821, 0x80041cf,
32140x3c020003, 0x3c020003, 0x34420d3f, 0x47102b,
32150x14400016, 0x318200ff, 0x14400006, 0x0,
32160x3c020001, 0x571021, 0x904283c0, 0x1040000f,
32170x0, 0x8ee2023c, 0x3c04fdff, 0x8ee30000,
32180x3484ffff, 0x24420001, 0xaee2023c, 0x8ee2023c,
32190x24020001, 0x641824, 0x3c010001, 0x370821,
32200xa02283b8, 0x800422c, 0xaee30000, 0xaf8b00c8,
32210x8f8300c8, 0x8f8200c4, 0x3c04000a, 0x3484f000,
32220x623823, 0x87102b, 0x54400001, 0xe43821,
32230x3c020003, 0x34420d40, 0x47102b, 0x2ce30001,
32240x431025, 0x10400008, 0x0, 0x8f820220,
32250x3c0308ff, 0x3463ffff, 0x431024, 0x3c034000,
32260x431025, 0xaf820220, 0x8f8600e0, 0x8f8400e4,
32270x10c4002a, 0x0, 0x8ee2007c, 0x24420001,
32280xaee2007c, 0x8ee2007c, 0x24c2fff8, 0xaf8200e0,
32290x3c020001, 0x8c427e30, 0x3c030008, 0x8f8600e0,
32300x431024, 0x1040001d, 0x0, 0x10c4001b,
32310x240dfff8, 0x3c0a000a, 0x354af000, 0x3c0c0080,
32320x24850008, 0x27622800, 0x50a20001, 0x27651800,
32330x8c880004, 0x8c820000, 0x8ca90000, 0x3103ffff,
32340x431021, 0x4d1024, 0x24430010, 0x6b102b,
32350x54400001, 0x6a1821, 0x12b102b, 0x54400001,
32360x12a4821, 0x10690002, 0x10c1025, 0xac820004,
32370xa02021, 0x14c4ffeb, 0x24850008, 0x8f820220,
32380x3c0308ff, 0x3463ffff, 0x431024, 0x34420002,
32390xaf820220, 0x8f830054, 0x8f820054, 0x8004237,
32400x24630001, 0x8f820054, 0x621023, 0x2c420002,
32410x1440fffc, 0x0, 0x8f820220, 0x3c0308ff,
32420x3463fffb, 0x431024, 0xaf820220, 0x6010055,
32430x0, 0x8ee20228, 0x24420001, 0xaee20228,
32440x8ee20228, 0x8f820220, 0x3c0308ff, 0x3463ffff,
32450x431024, 0x34420004, 0xaf820220, 0x8f830054,
32460x8f820054, 0x8004251, 0x24630002, 0x8f820054,
32470x621023, 0x2c420003, 0x1440fffc, 0x0,
32480x8f8600e0, 0x30c20007, 0x10400012, 0x0,
32490x8f8300e4, 0x2402fff8, 0xc21024, 0x1043000d,
32500x0, 0x8f820054, 0x8f8300e0, 0x14c30009,
32510x24440032, 0x8f820054, 0x821023, 0x2c420033,
32520x10400004, 0x0, 0x8f8200e0, 0x10c2fff9,
32530x0, 0x8f820220, 0x3c0308ff, 0x3463fffd,
32540x431024, 0xaf820220, 0x8f8600e0, 0x30c20007,
32550x10400003, 0x2402fff8, 0xc23024, 0xaf8600e0,
32560x240301f5, 0x8f8200e8, 0x673823, 0x718c0,
32570x431021, 0xaf8200e8, 0x8f8200e8, 0xaf8200e4,
32580x8ee2007c, 0x3c0408ff, 0x3484ffff, 0x471021,
32590xaee2007c, 0x8f820220, 0x3c038000, 0x34630002,
32600x441024, 0x431025, 0xaf820220, 0x8f830054,
32610x8f820054, 0x800428d, 0x24630001, 0x8f820054,
32620x621023, 0x2c420002, 0x1440fffc, 0x0,
32630x8f820220, 0x3c0308ff, 0x3463fffb, 0x431024,
32640xaf820220, 0x8fbf0020, 0x8fb1001c, 0x8fb00018,
32650x3e00008, 0x27bd0028, 0x3c020001, 0x8c425cd8,
32660x27bdffd8, 0x10400012, 0xafbf0020, 0x3c040001,
32670x24845a14, 0x3c050008, 0x24020001, 0x3c010001,
32680x370821, 0xac2283ac, 0xafa00010, 0xafa00014,
32690x8f860220, 0x34a50498, 0x3c010001, 0xac205cd8,
32700x3c010001, 0xac225ccc, 0xc002403, 0x3821,
32710x8f420268, 0x3c037fff, 0x3463ffff, 0x431024,
32720xaf420268, 0x8ee204d0, 0x8ee404d4, 0x2403fffe,
32730x431024, 0x30840002, 0x1080011e, 0xaee204d0,
32740x8ee204d4, 0x2403fffd, 0x431024, 0xaee204d4,
32750x8f820044, 0x3c030600, 0x34632000, 0x34420020,
32760xaf820044, 0xafa30018, 0x8ee20608, 0x8f430228,
32770x24420001, 0x304a00ff, 0x514300fe, 0xafa00010,
32780x8ee20608, 0x210c0, 0x571021, 0x8fa30018,
32790x8fa4001c, 0xac43060c, 0xac440610, 0x8f830054,
32800x8f820054, 0x24690032, 0x1221023, 0x2c420033,
32810x1040006a, 0x5821, 0x24180008, 0x240f000d,
32820x240d0007, 0x240c0040, 0x240e0001, 0x8f870120,
32830x27623800, 0x24e80020, 0x102102b, 0x50400001,
32840x27683000, 0x8f820128, 0x11020004, 0x0,
32850x8f820124, 0x15020007, 0x1021, 0x8ee201a4,
32860x2821, 0x24420001, 0xaee201a4, 0x800433d,
32870x8ee201a4, 0x8ee40608, 0x420c0, 0x801821,
32880x8ee40430, 0x8ee50434, 0xa32821, 0xa3302b,
32890x822021, 0x862021, 0xace40000, 0xace50004,
32900x8ee20608, 0xa4f8000e, 0xacef0018, 0xacea001c,
32910x210c0, 0x2442060c, 0x2e21021, 0xace20008,
32920x8ee204c4, 0xace20010, 0xaf880120, 0x92e24e20,
32930x14400033, 0x24050001, 0x8ee24e30, 0x210c0,
32940x24425038, 0x2e22021, 0x8c820000, 0x144d001f,
32950x0, 0x8ee34e30, 0x8ee24e34, 0x1062001b,
32960x0, 0x8c820004, 0x24420001, 0xac820004,
32970x8ee24e34, 0x8ee34e30, 0x24420001, 0x104c0007,
32980x0, 0x8ee24e34, 0x24420001, 0x10620005,
32990x0, 0x800432a, 0x0, 0x14600005,
33000x0, 0x8f820128, 0x24420020, 0xaf820128,
33010x8f820128, 0x8c820004, 0x2c420011, 0x50400010,
33020xac800000, 0x800433d, 0x0, 0x8ee24e30,
33030x24420001, 0x504c0003, 0x1021, 0x8ee24e30,
33040x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
33050x24425038, 0x2e22021, 0xac8d0000, 0xac8e0004,
33060x54a00006, 0x240b0001, 0x8f820054, 0x1221023,
33070x2c420033, 0x1440ff9d, 0x0, 0x316300ff,
33080x24020001, 0x54620079, 0xafa00010, 0xaeea0608,
33090x8f830054, 0x8f820054, 0x24690032, 0x1221023,
33100x2c420033, 0x10400061, 0x5821, 0x240d0008,
33110x240c0011, 0x24080012, 0x24070040, 0x240a0001,
33120x8f830120, 0x27623800, 0x24660020, 0xc2102b,
33130x50400001, 0x27663000, 0x8f820128, 0x10c20004,
33140x0, 0x8f820124, 0x14c20007, 0x0,
33150x8ee201a4, 0x2821, 0x24420001, 0xaee201a4,
33160x80043a9, 0x8ee201a4, 0x8ee20608, 0xac62001c,
33170x8ee404a0, 0x8ee504a4, 0x2462001c, 0xac620008,
33180xa46d000e, 0xac6c0018, 0xac640000, 0xac650004,
33190x8ee204c4, 0xac620010, 0xaf860120, 0x92e24e20,
33200x14400033, 0x24050001, 0x8ee24e30, 0x210c0,
33210x24425038, 0x2e22021, 0x8c820000, 0x1448001f,
33220x0, 0x8ee34e30, 0x8ee24e34, 0x1062001b,
33230x0, 0x8c820004, 0x24420001, 0xac820004,
33240x8ee24e34, 0x8ee34e30, 0x24420001, 0x10470007,
33250x0, 0x8ee24e34, 0x24420001, 0x10620005,
33260x0, 0x8004396, 0x0, 0x14600005,
33270x0, 0x8f820128, 0x24420020, 0xaf820128,
33280x8f820128, 0x8c820004, 0x2c420011, 0x50400010,
33290xac800000, 0x80043a9, 0x0, 0x8ee24e30,
33300x24420001, 0x50470003, 0x1021, 0x8ee24e30,
33310x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
33320x24425038, 0x2e22021, 0xac880000, 0xac8a0004,
33330x54a00006, 0x240b0001, 0x8f820054, 0x1221023,
33340x2c420033, 0x1440ffa6, 0x0, 0x316300ff,
33350x24020001, 0x54620003, 0xafa00010, 0x80043d6,
33360x0, 0x3c040001, 0x24845a20, 0xafa00014,
33370x8f860120, 0x8f870124, 0x3c050009, 0xc002403,
33380x34a5f011, 0x80043d6, 0x0, 0x3c040001,
33390x24845a2c, 0xafa00014, 0x8f860120, 0x8f870124,
33400x3c050009, 0xc002403, 0x34a5f010, 0x80043d6,
33410x0, 0x3c040001, 0x24845a38, 0xafa00014,
33420x8ee60608, 0x8f470228, 0x3c050009, 0xc002403,
33430x34a5f00f, 0x8ee201ac, 0x24420001, 0xaee201ac,
33440x8ee201ac, 0x8ee2015c, 0x24420001, 0xaee2015c,
33450x8ee2015c, 0x8fbf0020, 0x3e00008, 0x27bd0028,
33460x3c020001, 0x8c425cd8, 0x27bdffe0, 0x1440000d,
33470xafbf0018, 0x3c040001, 0x24845a44, 0x3c050008,
33480xafa00010, 0xafa00014, 0x8f860220, 0x34a50499,
33490x24020001, 0x3c010001, 0xac225cd8, 0xc002403,
33500x3821, 0x8ee204d0, 0x3c030001, 0x771821,
33510x946383b2, 0x34420001, 0x10600007, 0xaee204d0,
33520x8f820220, 0x3c0308ff, 0x3463ffff, 0x431024,
33530x34420008, 0xaf820220, 0x2021, 0xc0052a2,
33540x24050004, 0xaf420268, 0x8fbf0018, 0x3e00008,
33550x27bd0020, 0x0, 0x0, 0x0,
33560x0, 0x0, 0x0, 0x0,
33570x0, 0x0, 0x0, 0x0,
33580x0, 0x0, 0x0, 0x0,
33590x0, 0x0, 0x0, 0x0,
33600x0, 0x0, 0x0, 0x0,
33610x0, 0x0, 0x0, 0x0,
33620x0, 0x0, 0x0, 0x0,
33630x0, 0x0, 0x0, 0x0,
33640x0, 0x0, 0x0, 0x0,
33650x0, 0x0, 0x0, 0x0,
33660x0, 0x0, 0x0, 0x0,
33670x0, 0x0, 0x0, 0x0,
33680x0, 0x0, 0x0, 0x0,
33690x0, 0x0, 0x0, 0x0,
33700x0, 0x0, 0x0, 0x3c120001,
33710x26521200, 0x3c140001, 0x8e945c50, 0x3c100001,
33720x26101120, 0x3c15c000, 0x36b50060, 0x8e8a0000,
33730x8eb30000, 0x26a400b, 0x248000a, 0x200f821,
33740x0, 0xd, 0x0, 0x0,
33750x0, 0x0, 0x0, 0x0,
33760x0, 0x0, 0x0, 0x0,
33770x0, 0x0, 0x0, 0x0,
33780x0, 0x0, 0x0, 0x0,
33790x0, 0x0, 0x0, 0x0,
33800x0, 0x0, 0x0, 0x0,
33810x0, 0x0, 0x0, 0x0,
33820x0, 0x0, 0x0, 0x0,
33830x0, 0x0, 0x0, 0x0,
33840x0, 0x0, 0x0, 0x0,
33850x0, 0x0, 0x0, 0x0,
33860x0, 0x0, 0x0, 0x80014d6,
33870x0, 0x80014d8, 0x3c0a0001, 0x80014d8,
33880x3c0a0002, 0x80014d8, 0x0, 0x80024a6,
33890x0, 0x80014d8, 0x3c0a0003, 0x80014d8,
33900x3c0a0004, 0x8002f8c, 0x0, 0x80014d8,
33910x3c0a0005, 0x8003ce8, 0x0, 0x8003c66,
33920x0, 0x80014d8, 0x3c0a0006, 0x80014d8,
33930x3c0a0007, 0x80014d8, 0x0, 0x80014d8,
33940x0, 0x80014d8, 0x0, 0x8002a75,
33950x0, 0x80014d8, 0x3c0a000b, 0x80014d8,
33960x3c0a000c, 0x80014d8, 0x3c0a000d, 0x800237a,
33970x0, 0x8002339, 0x0, 0x80014d8,
33980x3c0a000e, 0x8001b3c, 0x0, 0x80024a4,
33990x0, 0x80014d8, 0x3c0a000f, 0x80040a7,
34000x0, 0x8004091, 0x0, 0x80014d8,
34010x3c0a0010, 0x80014ee, 0x0, 0x80014d8,
34020x3c0a0011, 0x80014d8, 0x3c0a0012, 0x80014d8,
34030x3c0a0013, 0x0, 0x0, 0x0,
34040x0, 0x0, 0x0, 0x0,
34050x0, 0x0, 0x0, 0x0,
34060x0, 0x0, 0x0, 0x0,
34070x0, 0x0, 0x0, 0x0,
34080x0, 0x0, 0x0, 0x0,
34090x0, 0x0, 0x0, 0x0,
34100x0, 0x0, 0x0, 0x0,
34110x0, 0x0, 0x0, 0x0,
34120x0, 0x0, 0x0, 0x0,
34130x0, 0x0, 0x0, 0x0,
34140x0, 0x0, 0x0, 0x0,
34150x0, 0x0, 0x0, 0x0,
34160x0, 0x0, 0x0, 0x0,
34170x0, 0x0, 0x0, 0x0,
34180x0, 0x0, 0x0, 0x3c030001,
34190x34633800, 0x24050080, 0x2404001f, 0x2406ffff,
34200x24020001, 0xaf80021c, 0xaf820200, 0xaf820220,
34210x3631021, 0xaf8200c0, 0x3631021, 0xaf8200c4,
34220x3631021, 0xaf8200c8, 0x27623800, 0xaf8200d0,
34230x27623800, 0xaf8200d4, 0x27623800, 0xaf8200d8,
34240x27621800, 0xaf8200e0, 0x27621800, 0xaf8200e4,
34250x27621800, 0xaf8200e8, 0x27621000, 0xaf8200f0,
34260x27621000, 0xaf8200f4, 0x27621000, 0xaf8200f8,
34270xaca00000, 0x2484ffff, 0x1486fffd, 0x24a50004,
34280x8f830040, 0x3c02f000, 0x621824, 0x3c025000,
34290x1062000c, 0x43102b, 0x14400006, 0x3c026000,
34300x3c024000, 0x10620008, 0x24020800, 0x8004539,
34310x0, 0x10620004, 0x24020800, 0x8004539,
34320x0, 0x24020700, 0x3c010001, 0xac225cdc,
34330x3e00008, 0x0, 0x27bdffd8, 0xafbf0024,
34340xafb00020, 0x8f830054, 0x8f820054, 0x3c010001,
34350xac205cc4, 0x8004545, 0x24630064, 0x8f820054,
34360x621023, 0x2c420065, 0x1440fffc, 0x0,
34370xc004d71, 0x0, 0x24040001, 0x2821,
34380x27a60018, 0x34028000, 0xc00498e, 0xa7a20018,
34390x8f830054, 0x8f820054, 0x8004556, 0x24630064,
34400x8f820054, 0x621023, 0x2c420065, 0x1440fffc,
34410x24040001, 0x24050001, 0xc00494c, 0x27a60018,
34420x8f830054, 0x8f820054, 0x8004562, 0x24630064,
34430x8f820054, 0x621023, 0x2c420065, 0x1440fffc,
34440x24040001, 0x24050001, 0xc00494c, 0x27a60018,
34450x8f830054, 0x8f820054, 0x800456e, 0x24630064,
34460x8f820054, 0x621023, 0x2c420065, 0x1440fffc,
34470x24040001, 0x3c060001, 0x24c65da0, 0xc00494c,
34480x24050002, 0x8f830054, 0x8f820054, 0x800457b,
34490x24630064, 0x8f820054, 0x621023, 0x2c420065,
34500x1440fffc, 0x24040001, 0x24050003, 0x3c100001,
34510x26105da2, 0xc00494c, 0x2003021, 0x97a60018,
34520x3c070001, 0x94e75da0, 0x3c040001, 0x24845ab0,
34530xafa00014, 0x96020000, 0x3c05000d, 0x34a50100,
34540xc002403, 0xafa20010, 0x97a20018, 0x1040004c,
34550x24036040, 0x96020000, 0x3042fff0, 0x1443000a,
34560x24020020, 0x3c030001, 0x94635da0, 0x54620009,
34570x24027830, 0x24020003, 0x3c010001, 0xac225cc4,
34580x80045ac, 0x24020005, 0x3c030001, 0x94635da0,
34590x24027830, 0x1462000f, 0x24030010, 0x3c020001,
34600x94425da2, 0x3042fff0, 0x1443000a, 0x24020003,
34610x3c010001, 0xac225cc4, 0x24020006, 0x3c010001,
34620xac225db0, 0x3c010001, 0xac225dbc, 0x80045e6,
34630x3c09fff0, 0x3c020001, 0x8c425cc4, 0x3c030001,
34640x94635da0, 0x34420001, 0x3c010001, 0xac225cc4,
34650x24020015, 0x1462000f, 0x0, 0x3c020001,
34660x94425da2, 0x3042fff0, 0x3843f420, 0x2c630001,
34670x3842f430, 0x2c420001, 0x621825, 0x10600005,
34680x24020003, 0x3c010001, 0xac225dbc, 0x80045e6,
34690x3c09fff0, 0x3c030001, 0x94635da0, 0x24027810,
34700x1462000b, 0x24020002, 0x3c020001, 0x94425da2,
34710x3042fff0, 0x14400006, 0x24020002, 0x24020004,
34720x3c010001, 0xac225dbc, 0x80045e6, 0x3c09fff0,
34730x3c010001, 0xac225dbc, 0x80045e6, 0x3c09fff0,
34740x3c020001, 0x8c425cc4, 0x24030001, 0x3c010001,
34750xac235dbc, 0x34420004, 0x3c010001, 0xac225cc4,
34760x3c09fff0, 0x3529bdc0, 0x3c060001, 0x8cc65cc4,
34770x3c040001, 0x24845ab0, 0x24020001, 0x3c010001,
34780xac225ccc, 0x8f820054, 0x3c070001, 0x8ce75dbc,
34790x3c030001, 0x94635da0, 0x3c080001, 0x95085da2,
34800x3c05000d, 0x34a50100, 0x3c010001, 0xac205cc8,
34810x491021, 0x3c010001, 0xac225dac, 0xafa30010,
34820xc002403, 0xafa80014, 0x8fbf0024, 0x8fb00020,
34830x3e00008, 0x27bd0028, 0x27bdffe8, 0x3c050001,
34840x8ca55cc8, 0x24060004, 0x24020001, 0x14a20014,
34850xafbf0010, 0x3c020001, 0x8c427e3c, 0x30428000,
34860x10400005, 0x3c04000f, 0x3c030001, 0x8c635dbc,
34870x8004617, 0x34844240, 0x3c040004, 0x3c030001,
34880x8c635dbc, 0x348493e0, 0x24020005, 0x14620016,
34890x0, 0x3c04003d, 0x800462f, 0x34840900,
34900x3c020001, 0x8c427e38, 0x30428000, 0x10400005,
34910x3c04001e, 0x3c030001, 0x8c635dbc, 0x800462a,
34920x34848480, 0x3c04000f, 0x3c030001, 0x8c635dbc,
34930x34844240, 0x24020005, 0x14620003, 0x0,
34940x3c04007a, 0x34841200, 0x3c020001, 0x8c425dac,
34950x8f830054, 0x441021, 0x431023, 0x44102b,
34960x14400037, 0x0, 0x3c020001, 0x8c425cd0,
34970x14400033, 0x0, 0x3c010001, 0x10c00025,
34980xac205ce0, 0x3c090001, 0x8d295cc4, 0x24070001,
34990x3c044000, 0x3c080001, 0x25087e3c, 0x250afffc,
35000x52842, 0x14a00002, 0x24c6ffff, 0x24050008,
35010xa91024, 0x10400010, 0x0, 0x14a70008,
35020x0, 0x8d020000, 0x441024, 0x1040000a,
35030x0, 0x3c010001, 0x800465b, 0xac255ce0,
35040x8d420000, 0x441024, 0x10400003, 0x0,
35050x3c010001, 0xac275ce0, 0x3c020001, 0x8c425ce0,
35060x6182b, 0x2c420001, 0x431024, 0x5440ffe5,
35070x52842, 0x8f820054, 0x3c030001, 0x8c635ce0,
35080x3c010001, 0xac225dac, 0x1060002a, 0x24020001,
35090x3c010001, 0xac255cc8, 0x3c010001, 0xac225ccc,
35100x3c020001, 0x8c425ce0, 0x10400022, 0x0,
35110x3c020001, 0x8c425ccc, 0x1040000a, 0x24020001,
35120x3c010001, 0xac205ccc, 0x3c010001, 0x370821,
35130xac2283ac, 0x3c010001, 0xac205d4c, 0x3c010001,
35140xac225d04, 0x3c030001, 0x771821, 0x8c6383ac,
35150x24020008, 0x10620005, 0x24020001, 0xc004695,
35160x0, 0x8004692, 0x0, 0x3c030001,
35170x8c635cc8, 0x10620007, 0x2402000e, 0x3c030001,
35180x8c637dd0, 0x10620003, 0x0, 0xc004e54,
35190x8f840220, 0x8fbf0010, 0x3e00008, 0x27bd0018,
35200x27bdffe0, 0x3c02fdff, 0xafbf0018, 0x8ee30000,
35210x3c050001, 0x8ca55cc8, 0x3c040001, 0x8c845cf0,
35220x3442ffff, 0x621824, 0x14a40008, 0xaee30000,
35230x3c030001, 0x771821, 0x8c6383ac, 0x3c020001,
35240x8c425cf4, 0x10620008, 0x0, 0x3c020001,
35250x571021, 0x8c4283ac, 0x3c010001, 0xac255cf0,
35260x3c010001, 0xac225cf4, 0x3c030001, 0x8c635cc8,
35270x24020002, 0x10620169, 0x2c620003, 0x10400005,
35280x24020001, 0x10620008, 0x0, 0x800481c,
35290x0, 0x24020004, 0x106200b1, 0x24020001,
35300x800481d, 0x0, 0x3c020001, 0x571021,
35310x8c4283ac, 0x2443ffff, 0x2c620008, 0x1040015a,
35320x31080, 0x3c010001, 0x220821, 0x8c225ac8,
35330x400008, 0x0, 0x3c030001, 0x8c635dbc,
35340x24020005, 0x14620014, 0x0, 0x3c020001,
35350x8c425cd4, 0x1040000a, 0x24020003, 0xc004822,
35360x0, 0x24020002, 0x3c010001, 0x370821,
35370xac2283ac, 0x3c010001, 0x80046e0, 0xac205cd4,
35380x3c010001, 0x370821, 0xac2283ac, 0x3c010001,
35390x800481f, 0xac205c60, 0xc004822, 0x0,
35400x3c020001, 0x8c425cd4, 0x3c010001, 0xac205c60,
35410x104000dd, 0x24020002, 0x3c010001, 0x370821,
35420xac2283ac, 0x3c010001, 0x800481f, 0xac205cd4,
35430x3c030001, 0x8c635dbc, 0x24020005, 0x14620003,
35440x24020001, 0x3c010001, 0xac225d00, 0xc0049cf,
35450x0, 0x3c030001, 0x8c635d00, 0x800478e,
35460x24020011, 0x3c050001, 0x8ca55cc8, 0x3c060001,
35470x8cc67e3c, 0xc005108, 0x2021, 0x24020005,
35480x3c010001, 0xac205cd4, 0x3c010001, 0x370821,
35490x800481f, 0xac2283ac, 0x3c040001, 0x24845abc,
35500x3c05000f, 0x34a50100, 0x3021, 0x3821,
35510xafa00010, 0xc002403, 0xafa00014, 0x800481f,
35520x0, 0x8f820220, 0x3c03f700, 0x431025,
35530x80047b7, 0xaf820220, 0x8f820220, 0x3c030004,
35540x431024, 0x144000a9, 0x24020007, 0x8f830054,
35550x3c020001, 0x8c425da4, 0x2463d8f0, 0x431023,
35560x2c422710, 0x144000f8, 0x24020001, 0x800481d,
35570x0, 0x3c050001, 0x8ca55cc8, 0xc0052a2,
35580x2021, 0xc005386, 0x2021, 0x3c030001,
35590x8c637e34, 0x46100ea, 0x24020001, 0x3c020008,
35600x621024, 0x10400006, 0x0, 0x8f820214,
35610x3c03ffff, 0x431024, 0x8004741, 0x3442251f,
35620x8f820214, 0x3c03ffff, 0x431024, 0x3442241f,
35630xaf820214, 0x8ee20000, 0x3c030200, 0x431025,
35640xaee20000, 0x8f820220, 0x2403fffb, 0x431024,
35650xaf820220, 0x8f820220, 0x34420002, 0xaf820220,
35660x24020008, 0x3c010001, 0x370821, 0xac2283ac,
35670x8f820220, 0x3c030004, 0x431024, 0x14400005,
35680x0, 0x8f820220, 0x3c03f700, 0x431025,
35690xaf820220, 0x3c030001, 0x8c635dbc, 0x24020005,
35700x1462000a, 0x0, 0x3c020001, 0x94425da2,
35710x24429fbc, 0x2c420004, 0x10400004, 0x24040018,
35720x24050002, 0xc004d93, 0x24060020, 0xc0043dd,
35730x0, 0x3c010001, 0x800481f, 0xac205d50,
35740x3c020001, 0x571021, 0x8c4283ac, 0x2443ffff,
35750x2c620008, 0x104000ac, 0x31080, 0x3c010001,
35760x220821, 0x8c225ae8, 0x400008, 0x0,
35770xc00429b, 0x0, 0x3c010001, 0xac205ccc,
35780xaf800204, 0x3c010001, 0xc004822, 0xac207e20,
35790x24020001, 0x3c010001, 0xac225ce4, 0x24020002,
35800x3c010001, 0x370821, 0x800481f, 0xac2283ac,
35810xc00489f, 0x0, 0x3c030001, 0x8c635ce4,
35820x24020009, 0x14620090, 0x24020003, 0x3c010001,
35830x370821, 0x800481f, 0xac2283ac, 0x3c020001,
35840x8c427e38, 0x30424000, 0x10400005, 0x0,
35850x8f820044, 0x3c03ffff, 0x800479f, 0x34637fff,
35860x8f820044, 0x2403ff7f, 0x431024, 0xaf820044,
35870x8f830054, 0x80047b9, 0x24020004, 0x8f830054,
35880x3c020001, 0x8c425da4, 0x2463d8f0, 0x431023,
35890x2c422710, 0x14400074, 0x24020005, 0x3c010001,
35900x370821, 0x800481f, 0xac2283ac, 0x8f820220,
35910x3c03f700, 0x431025, 0xaf820220, 0xaf800204,
35920x3c010001, 0xac207e20, 0x8f830054, 0x24020006,
35930x3c010001, 0x370821, 0xac2283ac, 0x3c010001,
35940x800481f, 0xac235da4, 0x8f830054, 0x3c020001,
35950x8c425da4, 0x2463fff6, 0x431023, 0x2c42000a,
35960x14400059, 0x0, 0x24020007, 0x3c010001,
35970x370821, 0x800481f, 0xac2283ac, 0x8f820220,
35980x3c04f700, 0x441025, 0xaf820220, 0x8f820220,
35990x3c030300, 0x431024, 0x14400005, 0x1821,
36000x8f820220, 0x24030001, 0x441025, 0xaf820220,
36010x10600043, 0x24020001, 0x8f820214, 0x3c03ffff,
36020x3c040001, 0x8c845d98, 0x431024, 0x3442251f,
36030xaf820214, 0x24020008, 0x3c010001, 0x370821,
36040x1080000b, 0xac2283ac, 0x3c020001, 0x8c425d74,
36050x14400007, 0x24020001, 0x3c010001, 0xac227dd0,
36060xc004e54, 0x8f840220, 0x800480c, 0x0,
36070x8f820220, 0x3c030008, 0x431024, 0x14400017,
36080x2402000e, 0x3c010001, 0xac227dd0, 0x8ee20000,
36090x2021, 0x3c030200, 0x431025, 0xc005386,
36100xaee20000, 0x8f820220, 0x2403fffb, 0x431024,
36110xaf820220, 0x8f820220, 0x34420002, 0xc0043dd,
36120xaf820220, 0x3c050001, 0x8ca55cc8, 0xc0052a2,
36130x2021, 0x800481f, 0x0, 0x3c020001,
36140x8c425d74, 0x10400010, 0x0, 0x3c020001,
36150x8c425d70, 0x2442ffff, 0x3c010001, 0xac225d70,
36160x14400009, 0x24020002, 0x3c010001, 0xac205d74,
36170x3c010001, 0x800481f, 0xac225d70, 0x24020001,
36180x3c010001, 0xac225ccc, 0x8fbf0018, 0x3e00008,
36190x27bd0020, 0x8f820200, 0x8f820220, 0x8f820220,
36200x34420004, 0xaf820220, 0x8f820200, 0x3c060001,
36210x8cc65cc8, 0x34420004, 0xaf820200, 0x24020002,
36220x10c2003a, 0x2cc20003, 0x10400005, 0x24020001,
36230x10c20008, 0x0, 0x8004868, 0x0,
36240x24020004, 0x10c20013, 0x24020001, 0x8004868,
36250x0, 0x3c030001, 0x8c635cb8, 0x3c020001,
36260x8c425cc0, 0x3c040001, 0x8c845cdc, 0x3c050001,
36270x8ca55cbc, 0xaf860200, 0xaf860220, 0x34630022,
36280x441025, 0x451025, 0x34420002, 0x8004867,
36290xaf830200, 0x3c030001, 0x8c635d98, 0xaf820200,
36300x10600009, 0xaf820220, 0x3c020001, 0x8c425d74,
36310x14400005, 0x3c033f00, 0x3c020001, 0x8c425cb0,
36320x800485b, 0x346300e0, 0x3c020001, 0x8c425cb0,
36330x3c033f00, 0x346300e2, 0x431025, 0xaf820200,
36340x3c030001, 0x8c635cb4, 0x3c04f700, 0x3c020001,
36350x8c425cc0, 0x3c050001, 0x8ca55cdc, 0x641825,
36360x431025, 0x451025, 0xaf820220, 0x3e00008,
36370x0, 0x8f820220, 0x3c030001, 0x8c635cc8,
36380x34420004, 0xaf820220, 0x24020001, 0x1062000f,
36390x0, 0x8f830054, 0x8f820054, 0x24630002,
36400x621023, 0x2c420003, 0x10400011, 0x0,
36410x8f820054, 0x621023, 0x2c420003, 0x1040000c,
36420x0, 0x8004879, 0x0, 0x8f830054,
36430x8f820054, 0x8004885, 0x24630007, 0x8f820054,
36440x621023, 0x2c420008, 0x1440fffc, 0x0,
36450x8f8400e0, 0x30820007, 0x1040000d, 0x0,
36460x8f820054, 0x8f8300e0, 0x14830009, 0x24450032,
36470x8f820054, 0xa21023, 0x2c420033, 0x10400004,
36480x0, 0x8f8200e0, 0x1082fff9, 0x0,
36490x8f820220, 0x2403fffd, 0x431024, 0xaf820220,
36500x3e00008, 0x0, 0x3c030001, 0x8c635ce4,
36510x3c020001, 0x8c425ce8, 0x50620004, 0x2463ffff,
36520x3c010001, 0xac235ce8, 0x2463ffff, 0x2c620009,
36530x1040009d, 0x31080, 0x3c010001, 0x220821,
36540x8c225b08, 0x400008, 0x0, 0x8f820044,
36550x34428080, 0xaf820044, 0x8f830054, 0x8004938,
36560x24020002, 0x8f830054, 0x3c020001, 0x8c425da8,
36570x2463d8f0, 0x431023, 0x2c422710, 0x1440008a,
36580x24020003, 0x8004945, 0x0, 0x8f820044,
36590x3c03ffff, 0x34637fff, 0x431024, 0xaf820044,
36600x8f830054, 0x8004938, 0x24020004, 0x8f830054,
36610x3c020001, 0x8c425da8, 0x2463fff6, 0x431023,
36620x2c42000a, 0x14400078, 0x24020005, 0x8004945,
36630x0, 0x8f820220, 0x3c03f700, 0x431025,
36640xaf820220, 0x8f820220, 0x2403fffb, 0x431024,
36650xaf820220, 0x8f820220, 0x34420002, 0xaf820220,
36660x3c023f00, 0x344200e0, 0xaf820200, 0x8f820200,
36670x2403fffd, 0x431024, 0xaf820200, 0x24040001,
36680x3405ffff, 0xaf840204, 0x8f830054, 0x8f820054,
36690x80048ec, 0x24630001, 0x8f820054, 0x621023,
36700x2c420002, 0x1440fffc, 0x0, 0x8f820224,
36710x42040, 0xa4102b, 0x1040fff2, 0x0,
36720x8f820220, 0x3c03f700, 0x431025, 0xaf820220,
36730x8f820214, 0x3c03ffff, 0x431024, 0x3442251f,
36740xaf820214, 0x8f820220, 0x2403fffb, 0x431024,
36750xaf820220, 0x8f820220, 0x3c04f700, 0x34840008,
36760x34420002, 0xaf820220, 0x8f820220, 0x3c033f00,
36770x346300e2, 0x441025, 0xaf820220, 0xaf830200,
36780x8f8400f0, 0x276217f8, 0x14820002, 0x24850008,
36790x27651000, 0x8f8200f4, 0x10a20007, 0x3c038000,
36800x34630040, 0x3c020001, 0x24425c70, 0xac820000,
36810xac830004, 0xaf8500f0, 0x8f830054, 0x8004938,
36820x24020006, 0x8f830054, 0x3c020001, 0x8c425da8,
36830x2463fff6, 0x431023, 0x2c42000a, 0x14400022,
36840x24020007, 0x8004945, 0x0, 0x8f8200e0,
36850xaf8200e4, 0x8f8200e0, 0xaf8200e8, 0x8f820220,
36860x34420004, 0xaf820220, 0x8f820220, 0x2403fff7,
36870x431024, 0xaf820220, 0x8f820044, 0x34428080,
36880xaf820044, 0x8f830054, 0x24020008, 0x3c010001,
36890xac225ce4, 0x3c010001, 0x8004947, 0xac235da8,
36900x8f830054, 0x3c020001, 0x8c425da8, 0x2463d8f0,
36910x431023, 0x2c422710, 0x14400003, 0x24020009,
36920x3c010001, 0xac225ce4, 0x3e00008, 0x0,
36930x0, 0x0, 0x0, 0x27bdffd8,
36940xafb20018, 0x809021, 0xafb3001c, 0xa09821,
36950xafb10014, 0xc08821, 0xafb00010, 0x8021,
36960xafbf0020, 0xa6200000, 0xc004d4b, 0x24040001,
36970x26100001, 0x2e020020, 0x1440fffb, 0x0,
36980xc004d4b, 0x2021, 0xc004d4b, 0x24040001,
36990xc004d4b, 0x24040001, 0xc004d4b, 0x2021,
37000x24100010, 0x2501024, 0x10400002, 0x2021,
37010x24040001, 0xc004d4b, 0x108042, 0x1600fffa,
37020x2501024, 0x24100010, 0x2701024, 0x10400002,
37030x2021, 0x24040001, 0xc004d4b, 0x108042,
37040x1600fffa, 0x2701024, 0xc004d71, 0x34108000,
37050xc004d71, 0x0, 0xc004d2b, 0x0,
37060x50400005, 0x108042, 0x96220000, 0x501025,
37070xa6220000, 0x108042, 0x1600fff7, 0x0,
37080xc004d71, 0x0, 0x8fbf0020, 0x8fb3001c,
37090x8fb20018, 0x8fb10014, 0x8fb00010, 0x3e00008,
37100x27bd0028, 0x27bdffd8, 0xafb10014, 0x808821,
37110xafb20018, 0xa09021, 0xafb3001c, 0xc09821,
37120xafb00010, 0x8021, 0xafbf0020, 0xc004d4b,
37130x24040001, 0x26100001, 0x2e020020, 0x1440fffb,
37140x0, 0xc004d4b, 0x2021, 0xc004d4b,
37150x24040001, 0xc004d4b, 0x2021, 0xc004d4b,
37160x24040001, 0x24100010, 0x2301024, 0x10400002,
37170x2021, 0x24040001, 0xc004d4b, 0x108042,
37180x1600fffa, 0x2301024, 0x24100010, 0x2501024,
37190x10400002, 0x2021, 0x24040001, 0xc004d4b,
37200x108042, 0x1600fffa, 0x2501024, 0xc004d4b,
37210x24040001, 0xc004d4b, 0x2021, 0x34108000,
37220x96620000, 0x501024, 0x10400002, 0x2021,
37230x24040001, 0xc004d4b, 0x108042, 0x1600fff8,
37240x0, 0xc004d71, 0x0, 0x8fbf0020,
37250x8fb3001c, 0x8fb20018, 0x8fb10014, 0x8fb00010,
37260x3e00008, 0x27bd0028, 0x3c030001, 0x8c635d00,
37270x3c020001, 0x8c425d48, 0x27bdffd8, 0xafbf0020,
37280xafb1001c, 0x10620003, 0xafb00018, 0x3c010001,
37290xac235d48, 0x2463ffff, 0x2c620013, 0x10400349,
37300x31080, 0x3c010001, 0x220821, 0x8c225b30,
37310x400008, 0x0, 0xc004d71, 0x8021,
37320x34028000, 0xa7a20010, 0x27b10010, 0xc004d4b,
37330x24040001, 0x26100001, 0x2e020020, 0x1440fffb,
37340x0, 0xc004d4b, 0x2021, 0xc004d4b,
37350x24040001, 0xc004d4b, 0x2021, 0xc004d4b,
37360x24040001, 0x24100010, 0x32020001, 0x10400002,
37370x2021, 0x24040001, 0xc004d4b, 0x108042,
37380x1600fffa, 0x32020001, 0x24100010, 0xc004d4b,
37390x2021, 0x108042, 0x1600fffc, 0x0,
37400xc004d4b, 0x24040001, 0xc004d4b, 0x2021,
37410x34108000, 0x96220000, 0x501024, 0x10400002,
37420x2021, 0x24040001, 0xc004d4b, 0x108042,
37430x1600fff8, 0x0, 0xc004d71, 0x0,
37440x8004d24, 0x24020002, 0x27b10010, 0xa7a00010,
37450x8021, 0xc004d4b, 0x24040001, 0x26100001,
37460x2e020020, 0x1440fffb, 0x0, 0xc004d4b,
37470x2021, 0xc004d4b, 0x24040001, 0xc004d4b,
37480x24040001, 0xc004d4b, 0x2021, 0x24100010,
37490x32020001, 0x10400002, 0x2021, 0x24040001,
37500xc004d4b, 0x108042, 0x1600fffa, 0x32020001,
37510x24100010, 0xc004d4b, 0x2021, 0x108042,
37520x1600fffc, 0x0, 0xc004d71, 0x34108000,
37530xc004d71, 0x0, 0xc004d2b, 0x0,
37540x50400005, 0x108042, 0x96220000, 0x501025,
37550xa6220000, 0x108042, 0x1600fff7, 0x0,
37560xc004d71, 0x0, 0x97a20010, 0x30428000,
37570x144002dc, 0x24020003, 0x8004d24, 0x0,
37580x24021200, 0xa7a20010, 0x27b10010, 0x8021,
37590xc004d4b, 0x24040001, 0x26100001, 0x2e020020,
37600x1440fffb, 0x0, 0xc004d4b, 0x2021,
37610xc004d4b, 0x24040001, 0xc004d4b, 0x2021,
37620xc004d4b, 0x24040001, 0x24100010, 0x32020001,
37630x10400002, 0x2021, 0x24040001, 0xc004d4b,
37640x108042, 0x1600fffa, 0x32020001, 0x24100010,
37650xc004d4b, 0x2021, 0x108042, 0x1600fffc,
37660x0, 0xc004d4b, 0x24040001, 0xc004d4b,
37670x2021, 0x34108000, 0x96220000, 0x501024,
37680x10400002, 0x2021, 0x24040001, 0xc004d4b,
37690x108042, 0x1600fff8, 0x0, 0xc004d71,
37700x0, 0x8f830054, 0x8004d16, 0x24020004,
37710x8f830054, 0x3c020001, 0x8c425db8, 0x2463ff9c,
37720x431023, 0x2c420064, 0x1440029e, 0x24020002,
37730x3c030001, 0x8c635dbc, 0x10620297, 0x2c620003,
37740x14400296, 0x24020011, 0x24020003, 0x10620005,
37750x24020004, 0x10620291, 0x2402000f, 0x8004d24,
37760x24020011, 0x8004d24, 0x24020005, 0x24020014,
37770xa7a20010, 0x27b10010, 0x8021, 0xc004d4b,
37780x24040001, 0x26100001, 0x2e020020, 0x1440fffb,
37790x0, 0xc004d4b, 0x2021, 0xc004d4b,
37800x24040001, 0xc004d4b, 0x2021, 0xc004d4b,
37810x24040001, 0x24100010, 0x32020001, 0x10400002,
37820x2021, 0x24040001, 0xc004d4b, 0x108042,
37830x1600fffa, 0x32020001, 0x24100010, 0x32020012,
37840x10400002, 0x2021, 0x24040001, 0xc004d4b,
37850x108042, 0x1600fffa, 0x32020012, 0xc004d4b,
37860x24040001, 0xc004d4b, 0x2021, 0x34108000,
37870x96220000, 0x501024, 0x10400002, 0x2021,
37880x24040001, 0xc004d4b, 0x108042, 0x1600fff8,
37890x0, 0xc004d71, 0x0, 0x8f830054,
37900x8004d16, 0x24020006, 0x8f830054, 0x3c020001,
37910x8c425db8, 0x2463ff9c, 0x431023, 0x2c420064,
37920x14400250, 0x24020007, 0x8004d24, 0x0,
37930x24020006, 0xa7a20010, 0x27b10010, 0x8021,
37940xc004d4b, 0x24040001, 0x26100001, 0x2e020020,
37950x1440fffb, 0x0, 0xc004d4b, 0x2021,
37960xc004d4b, 0x24040001, 0xc004d4b, 0x2021,
37970xc004d4b, 0x24040001, 0x24100010, 0x32020001,
37980x10400002, 0x2021, 0x24040001, 0xc004d4b,
37990x108042, 0x1600fffa, 0x32020001, 0x24100010,
38000x32020013, 0x10400002, 0x2021, 0x24040001,
38010xc004d4b, 0x108042, 0x1600fffa, 0x32020013,
38020xc004d4b, 0x24040001, 0xc004d4b, 0x2021,
38030x34108000, 0x96220000, 0x501024, 0x10400002,
38040x2021, 0x24040001, 0xc004d4b, 0x108042,
38050x1600fff8, 0x0, 0xc004d71, 0x0,
38060x8f830054, 0x8004d16, 0x24020008, 0x8f830054,
38070x3c020001, 0x8c425db8, 0x2463ff9c, 0x431023,
38080x2c420064, 0x1440020f, 0x24020009, 0x8004d24,
38090x0, 0x27b10010, 0xa7a00010, 0x8021,
38100xc004d4b, 0x24040001, 0x26100001, 0x2e020020,
38110x1440fffb, 0x0, 0xc004d4b, 0x2021,
38120xc004d4b, 0x24040001, 0xc004d4b, 0x24040001,
38130xc004d4b, 0x2021, 0x24100010, 0x32020001,
38140x10400002, 0x2021, 0x24040001, 0xc004d4b,
38150x108042, 0x1600fffa, 0x32020001, 0x24100010,
38160x32020018, 0x10400002, 0x2021, 0x24040001,
38170xc004d4b, 0x108042, 0x1600fffa, 0x32020018,
38180xc004d71, 0x34108000, 0xc004d71, 0x0,
38190xc004d2b, 0x0, 0x50400005, 0x108042,
38200x96220000, 0x501025, 0xa6220000, 0x108042,
38210x1600fff7, 0x0, 0xc004d71, 0x8021,
38220x97a20010, 0x27b10010, 0x34420001, 0xa7a20010,
38230xc004d4b, 0x24040001, 0x26100001, 0x2e020020,
38240x1440fffb, 0x0, 0xc004d4b, 0x2021,
38250xc004d4b, 0x24040001, 0xc004d4b, 0x2021,
38260xc004d4b, 0x24040001, 0x24100010, 0x32020001,
38270x10400002, 0x2021, 0x24040001, 0xc004d4b,
38280x108042, 0x1600fffa, 0x32020001, 0x24100010,
38290x32020018, 0x10400002, 0x2021, 0x24040001,
38300xc004d4b, 0x108042, 0x1600fffa, 0x32020018,
38310xc004d4b, 0x24040001, 0xc004d4b, 0x2021,
38320x34108000, 0x96220000, 0x501024, 0x10400002,
38330x2021, 0x24040001, 0xc004d4b, 0x108042,
38340x1600fff8, 0x0, 0xc004d71, 0x0,
38350x8f830054, 0x8004d16, 0x2402000a, 0x8f830054,
38360x3c020001, 0x8c425db8, 0x2463ff9c, 0x431023,
38370x2c420064, 0x1440019b, 0x2402000b, 0x8004d24,
38380x0, 0x27b10010, 0xa7a00010, 0x8021,
38390xc004d4b, 0x24040001, 0x26100001, 0x2e020020,
38400x1440fffb, 0x0, 0xc004d4b, 0x2021,
38410xc004d4b, 0x24040001, 0xc004d4b, 0x24040001,
38420xc004d4b, 0x2021, 0x24100010, 0x32020001,
38430x10400002, 0x2021, 0x24040001, 0xc004d4b,
38440x108042, 0x1600fffa, 0x32020001, 0x24100010,
38450x32020017, 0x10400002, 0x2021, 0x24040001,
38460xc004d4b, 0x108042, 0x1600fffa, 0x32020017,
38470xc004d71, 0x34108000, 0xc004d71, 0x0,
38480xc004d2b, 0x0, 0x50400005, 0x108042,
38490x96220000, 0x501025, 0xa6220000, 0x108042,
38500x1600fff7, 0x0, 0xc004d71, 0x8021,
38510x97a20010, 0x27b10010, 0x34420700, 0xa7a20010,
38520xc004d4b, 0x24040001, 0x26100001, 0x2e020020,
38530x1440fffb, 0x0, 0xc004d4b, 0x2021,
38540xc004d4b, 0x24040001, 0xc004d4b, 0x2021,
38550xc004d4b, 0x24040001, 0x24100010, 0x32020001,
38560x10400002, 0x2021, 0x24040001, 0xc004d4b,
38570x108042, 0x1600fffa, 0x32020001, 0x24100010,
38580x32020017, 0x10400002, 0x2021, 0x24040001,
38590xc004d4b, 0x108042, 0x1600fffa, 0x32020017,
38600xc004d4b, 0x24040001, 0xc004d4b, 0x2021,
38610x34108000, 0x96220000, 0x501024, 0x10400002,
38620x2021, 0x24040001, 0xc004d4b, 0x108042,
38630x1600fff8, 0x0, 0xc004d71, 0x0,
38640x8f830054, 0x8004d16, 0x2402000c, 0x8f830054,
38650x3c020001, 0x8c425db8, 0x2463ff9c, 0x431023,
38660x2c420064, 0x14400127, 0x24020012, 0x8004d24,
38670x0, 0x27b10010, 0xa7a00010, 0x8021,
38680xc004d4b, 0x24040001, 0x26100001, 0x2e020020,
38690x1440fffb, 0x0, 0xc004d4b, 0x2021,
38700xc004d4b, 0x24040001, 0xc004d4b, 0x24040001,
38710xc004d4b, 0x2021, 0x24100010, 0x32020001,
38720x10400002, 0x2021, 0x24040001, 0xc004d4b,
38730x108042, 0x1600fffa, 0x32020001, 0x24100010,
38740x32020014, 0x10400002, 0x2021, 0x24040001,
38750xc004d4b, 0x108042, 0x1600fffa, 0x32020014,
38760xc004d71, 0x34108000, 0xc004d71, 0x0,
38770xc004d2b, 0x0, 0x50400005, 0x108042,
38780x96220000, 0x501025, 0xa6220000, 0x108042,
38790x1600fff7, 0x0, 0xc004d71, 0x8021,
38800x97a20010, 0x27b10010, 0x34420010, 0xa7a20010,
38810xc004d4b, 0x24040001, 0x26100001, 0x2e020020,
38820x1440fffb, 0x0, 0xc004d4b, 0x2021,
38830xc004d4b, 0x24040001, 0xc004d4b, 0x2021,
38840xc004d4b, 0x24040001, 0x24100010, 0x32020001,
38850x10400002, 0x2021, 0x24040001, 0xc004d4b,
38860x108042, 0x1600fffa, 0x32020001, 0x24100010,
38870x32020014, 0x10400002, 0x2021, 0x24040001,
38880xc004d4b, 0x108042, 0x1600fffa, 0x32020014,
38890xc004d4b, 0x24040001, 0xc004d4b, 0x2021,
38900x34108000, 0x96220000, 0x501024, 0x10400002,
38910x2021, 0x24040001, 0xc004d4b, 0x108042,
38920x1600fff8, 0x0, 0xc004d71, 0x0,
38930x8f830054, 0x8004d16, 0x24020013, 0x8f830054,
38940x3c020001, 0x8c425db8, 0x2463ff9c, 0x431023,
38950x2c420064, 0x144000b3, 0x2402000d, 0x8004d24,
38960x0, 0x27b10010, 0xa7a00010, 0x8021,
38970xc004d4b, 0x24040001, 0x26100001, 0x2e020020,
38980x1440fffb, 0x0, 0xc004d4b, 0x2021,
38990xc004d4b, 0x24040001, 0xc004d4b, 0x24040001,
39000xc004d4b, 0x2021, 0x24100010, 0x32020001,
39010x10400002, 0x2021, 0x24040001, 0xc004d4b,
39020x108042, 0x1600fffa, 0x32020001, 0x24100010,
39030x32020018, 0x10400002, 0x2021, 0x24040001,
39040xc004d4b, 0x108042, 0x1600fffa, 0x32020018,
39050xc004d71, 0x34108000, 0xc004d71, 0x0,
39060xc004d2b, 0x0, 0x50400005, 0x108042,
39070x96220000, 0x501025, 0xa6220000, 0x108042,
39080x1600fff7, 0x0, 0xc004d71, 0x8021,
39090x97a20010, 0x27b10010, 0x3042fffe, 0xa7a20010,
39100xc004d4b, 0x24040001, 0x26100001, 0x2e020020,
39110x1440fffb, 0x0, 0xc004d4b, 0x2021,
39120xc004d4b, 0x24040001, 0xc004d4b, 0x2021,
39130xc004d4b, 0x24040001, 0x24100010, 0x32020001,
39140x10400002, 0x2021, 0x24040001, 0xc004d4b,
39150x108042, 0x1600fffa, 0x32020001, 0x24100010,
39160x32020018, 0x10400002, 0x2021, 0x24040001,
39170xc004d4b, 0x108042, 0x1600fffa, 0x32020018,
39180xc004d4b, 0x24040001, 0xc004d4b, 0x2021,
39190x34108000, 0x96220000, 0x501024, 0x10400002,
39200x2021, 0x24040001, 0xc004d4b, 0x108042,
39210x1600fff8, 0x0, 0xc004d71, 0x0,
39220x8f830054, 0x8004d16, 0x2402000e, 0x24020840,
39230xa7a20010, 0x27b10010, 0x8021, 0xc004d4b,
39240x24040001, 0x26100001, 0x2e020020, 0x1440fffb,
39250x0, 0xc004d4b, 0x2021, 0xc004d4b,
39260x24040001, 0xc004d4b, 0x2021, 0xc004d4b,
39270x24040001, 0x24100010, 0x32020001, 0x10400002,
39280x2021, 0x24040001, 0xc004d4b, 0x108042,
39290x1600fffa, 0x32020001, 0x24100010, 0x32020013,
39300x10400002, 0x2021, 0x24040001, 0xc004d4b,
39310x108042, 0x1600fffa, 0x32020013, 0xc004d4b,
39320x24040001, 0xc004d4b, 0x2021, 0x34108000,
39330x96220000, 0x501024, 0x10400002, 0x2021,
39340x24040001, 0xc004d4b, 0x108042, 0x1600fff8,
39350x0, 0xc004d71, 0x0, 0x8f830054,
39360x24020010, 0x3c010001, 0xac225d00, 0x3c010001,
39370x8004d26, 0xac235db8, 0x8f830054, 0x3c020001,
39380x8c425db8, 0x2463ff9c, 0x431023, 0x2c420064,
39390x14400004, 0x0, 0x24020011, 0x3c010001,
39400xac225d00, 0x8fbf0020, 0x8fb1001c, 0x8fb00018,
39410x3e00008, 0x27bd0028, 0x8f850044, 0x8f820044,
39420x3c030001, 0x431025, 0x3c030008, 0xaf820044,
39430x8f840054, 0x8f820054, 0xa32824, 0x8004d37,
39440x24840001, 0x8f820054, 0x821023, 0x2c420002,
39450x1440fffc, 0x0, 0x8f820044, 0x3c03fffe,
39460x3463ffff, 0x431024, 0xaf820044, 0x8f830054,
39470x8f820054, 0x8004d45, 0x24630001, 0x8f820054,
39480x621023, 0x2c420002, 0x1440fffc, 0x0,
39490x3e00008, 0xa01021, 0x8f830044, 0x3c02fff0,
39500x3442ffff, 0x42480, 0x621824, 0x3c020002,
39510x822025, 0x641825, 0xaf830044, 0x8f820044,
39520x3c03fffe, 0x3463ffff, 0x431024, 0xaf820044,
39530x8f830054, 0x8f820054, 0x8004d5e, 0x24630001,
39540x8f820054, 0x621023, 0x2c420002, 0x1440fffc,
39550x0, 0x8f820044, 0x3c030001, 0x431025,
39560xaf820044, 0x8f830054, 0x8f820054, 0x8004d6b,
39570x24630001, 0x8f820054, 0x621023, 0x2c420002,
39580x1440fffc, 0x0, 0x3e00008, 0x0,
39590x8f820044, 0x3c03fff0, 0x3463ffff, 0x431024,
39600xaf820044, 0x8f820044, 0x3c030001, 0x431025,
39610xaf820044, 0x8f830054, 0x8f820054, 0x8004d7f,
39620x24630001, 0x8f820054, 0x621023, 0x2c420002,
39630x1440fffc, 0x0, 0x8f820044, 0x3c03fffe,
39640x3463ffff, 0x431024, 0xaf820044, 0x8f830054,
39650x8f820054, 0x8004d8d, 0x24630001, 0x8f820054,
39660x621023, 0x2c420002, 0x1440fffc, 0x0,
39670x3e00008, 0x0, 0x27bdffc8, 0xafb30024,
39680x809821, 0xafb5002c, 0xa0a821, 0xafb20020,
39690xc09021, 0x32a2ffff, 0xafbf0030, 0xafb40028,
39700xafb1001c, 0xafb00018, 0x14400034, 0xa7b20010,
39710x3271ffff, 0x27b20010, 0x8021, 0xc004d4b,
39720x24040001, 0x26100001, 0x2e020020, 0x1440fffb,
39730x0, 0xc004d4b, 0x2021, 0xc004d4b,
39740x24040001, 0xc004d4b, 0x2021, 0xc004d4b,
39750x24040001, 0x24100010, 0x32020001, 0x10400002,
39760x2021, 0x24040001, 0xc004d4b, 0x108042,
39770x1600fffa, 0x32020001, 0x24100010, 0x2301024,
39780x10400002, 0x2021, 0x24040001, 0xc004d4b,
39790x108042, 0x1600fffa, 0x2301024, 0xc004d4b,
39800x24040001, 0xc004d4b, 0x2021, 0x34108000,
39810x96420000, 0x501024, 0x10400002, 0x2021,
39820x24040001, 0xc004d4b, 0x108042, 0x12000075,
39830x0, 0x8004dc9, 0x0, 0x3274ffff,
39840x27b10010, 0xa7a00010, 0x8021, 0xc004d4b,
39850x24040001, 0x26100001, 0x2e020020, 0x1440fffb,
39860x0, 0xc004d4b, 0x2021, 0xc004d4b,
39870x24040001, 0xc004d4b, 0x24040001, 0xc004d4b,
39880x2021, 0x24100010, 0x32020001, 0x10400002,
39890x2021, 0x24040001, 0xc004d4b, 0x108042,
39900x1600fffa, 0x32020001, 0x24100010, 0x2901024,
39910x10400002, 0x2021, 0x24040001, 0xc004d4b,
39920x108042, 0x1600fffa, 0x2901024, 0xc004d71,
39930x34108000, 0xc004d71, 0x0, 0xc004d2b,
39940x0, 0x50400005, 0x108042, 0x96220000,
39950x501025, 0xa6220000, 0x108042, 0x1600fff7,
39960x0, 0xc004d71, 0x0, 0x32a5ffff,
39970x24020001, 0x54a20004, 0x24020002, 0x97a20010,
39980x8004e14, 0x521025, 0x14a20006, 0x3271ffff,
39990x97a20010, 0x121827, 0x431024, 0xa7a20010,
40000x3271ffff, 0x27b20010, 0x8021, 0xc004d4b,
40010x24040001, 0x26100001, 0x2e020020, 0x1440fffb,
40020x0, 0xc004d4b, 0x2021, 0xc004d4b,
40030x24040001, 0xc004d4b, 0x2021, 0xc004d4b,
40040x24040001, 0x24100010, 0x32020001, 0x10400002,
40050x2021, 0x24040001, 0xc004d4b, 0x108042,
40060x1600fffa, 0x32020001, 0x24100010, 0x2301024,
40070x10400002, 0x2021, 0x24040001, 0xc004d4b,
40080x108042, 0x1600fffa, 0x2301024, 0xc004d4b,
40090x24040001, 0xc004d4b, 0x2021, 0x34108000,
40100x96420000, 0x501024, 0x10400002, 0x2021,
40110x24040001, 0xc004d4b, 0x108042, 0x1600fff8,
40120x0, 0xc004d71, 0x0, 0x8fbf0030,
40130x8fb5002c, 0x8fb40028, 0x8fb30024, 0x8fb20020,
40140x8fb1001c, 0x8fb00018, 0x3e00008, 0x27bd0038,
40150x0, 0x0, 0x0, 0x27bdffe8,
40160xafbf0010, 0x3c030001, 0x771821, 0x8c6383ac,
40170x24020008, 0x1462022c, 0x803021, 0x3c020001,
40180x8c425d98, 0x14400033, 0x0, 0x8f850224,
40190x38a30020, 0x2c630001, 0x38a20010, 0x2c420001,
40200x621825, 0x1460000d, 0x38a30030, 0x2c630001,
40210x38a20400, 0x2c420001, 0x621825, 0x14600007,
40220x38a30402, 0x2c630001, 0x38a20404, 0x2c420001,
40230x621825, 0x10600005, 0x0, 0xc00429b,
40240x0, 0x8004e8d, 0x2402000e, 0xc0043dd,
40250x0, 0x3c050001, 0x8ca55cc8, 0xc0052a2,
40260x2021, 0x3c030001, 0x8c635cc8, 0x24020004,
40270x14620005, 0x2403fffb, 0x3c020001, 0x8c425cc4,
40280x8004e89, 0x2403fff7, 0x3c020001, 0x8c425cc4,
40290x431024, 0x3c010001, 0xac225cc4, 0x2402000e,
40300x3c010001, 0xc00429b, 0xac227dd0, 0x8005087,
40310x0, 0x8f820220, 0x3c030400, 0x431024,
40320x10400027, 0x2403ffbf, 0x8f850224, 0x3c020001,
40330x8c427ddc, 0xa32024, 0x431024, 0x1482000c,
40340x0, 0x3c020001, 0x8c427de0, 0x24420001,
40350x3c010001, 0xac227de0, 0x2c420002, 0x14400008,
40360x24020001, 0x3c010001, 0x8004ead, 0xac227e00,
40370x3c010001, 0xac207de0, 0x3c010001, 0xac207e00,
40380x3c020001, 0x8c427e00, 0x10400006, 0x30a20040,
40390x10400004, 0x24020001, 0x3c010001, 0x8004eb8,
40400xac227e04, 0x3c010001, 0xac207e04, 0x3c010001,
40410xac257ddc, 0x3c010001, 0x8004ec8, 0xac207e10,
40420x24020001, 0x3c010001, 0xac227e10, 0x3c010001,
40430xac207e00, 0x3c010001, 0xac207de0, 0x3c010001,
40440xac207e04, 0x3c010001, 0xac207ddc, 0x3c030001,
40450x8c637dd0, 0x3c020001, 0x8c427dd4, 0x10620003,
40460x3c020200, 0x3c010001, 0xac237dd4, 0xc21024,
40470x10400007, 0x2463ffff, 0x8f820220, 0x24030001,
40480x3c010001, 0xac235ccc, 0x8005085, 0x3c03f700,
40490x2c62000e, 0x104001a8, 0x31080, 0x3c010001,
40500x220821, 0x8c225b80, 0x400008, 0x0,
40510x3c010001, 0xac207e00, 0x3c010001, 0xac207de0,
40520x3c010001, 0xac207ddc, 0x3c010001, 0xac207e04,
40530x3c010001, 0xac207df8, 0x3c010001, 0xac207df0,
40540xc00486a, 0xaf800224, 0x24020002, 0x3c010001,
40550xac227dd0, 0x3c020001, 0x8c427e10, 0x14400056,
40560x3c03fdff, 0x8ee20000, 0x3463ffff, 0x431024,
40570xc00429b, 0xaee20000, 0xaf800204, 0x8f820200,
40580x2403fffd, 0x431024, 0xaf820200, 0x3c010001,
40590xac207e20, 0x8f830054, 0x3c020001, 0x8c427df8,
40600x24040001, 0x3c010001, 0xac247e0c, 0x24420001,
40610x3c010001, 0xac227df8, 0x2c420004, 0x3c010001,
40620xac237df4, 0x14400006, 0x24020003, 0x3c010001,
40630xac245ccc, 0x3c010001, 0x8005083, 0xac207df8,
40640x3c010001, 0x8005083, 0xac227dd0, 0x8f830054,
40650x3c020001, 0x8c427df4, 0x2463d8f0, 0x431023,
40660x2c422710, 0x14400003, 0x24020004, 0x3c010001,
40670xac227dd0, 0x3c020001, 0x8c427e10, 0x14400026,
40680x3c03fdff, 0x8ee20000, 0x3463ffff, 0x431024,
40690x8005083, 0xaee20000, 0x3c040001, 0x8c845d9c,
40700x3c010001, 0xc00508a, 0xac207de8, 0x3c020001,
40710x8c427e1c, 0xaf820204, 0x3c020001, 0x8c427e10,
40720x14400015, 0x3c03fdff, 0x8ee20000, 0x3463ffff,
40730x431024, 0xaee20000, 0x8f820204, 0x30420030,
40740x1440013c, 0x24020002, 0x3c030001, 0x8c637e1c,
40750x24020005, 0x3c010001, 0xac227dd0, 0x3c010001,
40760x8005083, 0xac237e20, 0x3c020001, 0x8c427e10,
40770x10400010, 0x3c03fdff, 0x3c020001, 0x8c425d6c,
40780x24420001, 0x3c010001, 0xac225d6c, 0x2c420002,
40790x14400131, 0x24020001, 0x3c010001, 0xac225d74,
40800x3c010001, 0xac205d6c, 0x3c010001, 0x8005083,
40810xac225ccc, 0x8ee20000, 0x3463ffff, 0x431024,
40820xaee20000, 0x3c020001, 0x8c427e00, 0x10400122,
40830x0, 0x3c020001, 0x8c427ddc, 0x1040011e,
40840x0, 0x3c010001, 0xac227e08, 0x24020003,
40850x3c010001, 0xac227de0, 0x8005024, 0x24020006,
40860x3c010001, 0xac207de8, 0x8f820204, 0x34420040,
40870xaf820204, 0x3c020001, 0x8c427e20, 0x24030007,
40880x3c010001, 0xac237dd0, 0x34420040, 0x3c010001,
40890xac227e20, 0x3c020001, 0x8c427e00, 0x10400005,
40900x0, 0x3c020001, 0x8c427ddc, 0x104000f9,
40910x24020002, 0x3c050001, 0x24a57de0, 0x8ca20000,
40920x2c424e21, 0x104000f3, 0x24020002, 0x3c020001,
40930x8c427e04, 0x104000f8, 0x2404ffbf, 0x3c020001,
40940x8c427ddc, 0x3c030001, 0x8c637e08, 0x441024,
40950x641824, 0x10430004, 0x24020001, 0x3c010001,
40960x8005083, 0xac227dd0, 0x24020003, 0xaca20000,
40970x24020008, 0x3c010001, 0xac227dd0, 0x3c020001,
40980x8c427e0c, 0x1040000c, 0x24020001, 0x3c040001,
40990xc005097, 0x8c847ddc, 0x3c020001, 0x8c427e28,
41000x14400005, 0x24020001, 0x3c020001, 0x8c427e24,
41010x10400006, 0x24020001, 0x3c010001, 0xac225ccc,
41020x3c010001, 0x8005083, 0xac207df8, 0x3c020001,
41030x8c427df0, 0x3c030001, 0x8c637ddc, 0x2c420001,
41040x210c0, 0x30630008, 0x3c010001, 0xac227df0,
41050x3c010001, 0xac237dec, 0x8f830054, 0x24020009,
41060x3c010001, 0xac227dd0, 0x3c010001, 0x8005083,
41070xac237df4, 0x8f830054, 0x3c020001, 0x8c427df4,
41080x2463d8f0, 0x431023, 0x2c422710, 0x144000a8,
41090x0, 0x3c020001, 0x8c427e00, 0x10400005,
41100x0, 0x3c020001, 0x8c427ddc, 0x104000a9,
41110x24020002, 0x3c030001, 0x24637de0, 0x8c620000,
41120x2c424e21, 0x104000a3, 0x24020002, 0x3c020001,
41130x8c427e0c, 0x1040000e, 0x0, 0x3c020001,
41140x8c427ddc, 0x3c010001, 0xac207e0c, 0x30420080,
41150x1040002f, 0x2402000c, 0x8f820204, 0x30420080,
41160x1440000c, 0x24020003, 0x8005011, 0x2402000c,
41170x3c020001, 0x8c427ddc, 0x30420080, 0x14400005,
41180x24020003, 0x8f820204, 0x30420080, 0x1040001f,
41190x24020003, 0xac620000, 0x2402000a, 0x3c010001,
41200xac227dd0, 0x3c040001, 0x24847e18, 0x8c820000,
41210x3c030001, 0x8c637df0, 0x431025, 0xaf820204,
41220x8c830000, 0x3c040001, 0x8c847df0, 0x2402000b,
41230x3c010001, 0xac227dd0, 0x641825, 0x3c010001,
41240xac237e20, 0x3c050001, 0x24a57de0, 0x8ca20000,
41250x2c424e21, 0x1040006f, 0x24020002, 0x3c020001,
41260x8c427e10, 0x10400005, 0x0, 0x2402000c,
41270x3c010001, 0x8005083, 0xac227dd0, 0x3c020001,
41280x8c427e00, 0x1040006c, 0x0, 0x3c040001,
41290x8c847ddc, 0x1080005e, 0x30820008, 0x3c030001,
41300x8c637dec, 0x10620064, 0x24020003, 0x3c010001,
41310xac247e08, 0xaca20000, 0x24020006, 0x3c010001,
41320x8005083, 0xac227dd0, 0x8f820200, 0x34420002,
41330xaf820200, 0x8f830054, 0x2402000d, 0x3c010001,
41340xac227dd0, 0x3c010001, 0xac237df4, 0x8f830054,
41350x3c020001, 0x8c427df4, 0x2463d8f0, 0x431023,
41360x2c422710, 0x1440003a, 0x0, 0x3c020001,
41370x8c427e10, 0x10400029, 0x2402000e, 0x3c030001,
41380x8c637e24, 0x3c010001, 0x14600015, 0xac227dd0,
41390xc0043dd, 0x0, 0x3c050001, 0x8ca55cc8,
41400xc0052a2, 0x2021, 0x3c030001, 0x8c635cc8,
41410x24020004, 0x14620005, 0x2403fffb, 0x3c020001,
41420x8c425cc4, 0x8005052, 0x2403fff7, 0x3c020001,
41430x8c425cc4, 0x431024, 0x3c010001, 0xac225cc4,
41440x8ee20000, 0x3c030200, 0x431025, 0xaee20000,
41450x8f820224, 0x3c010001, 0xac227e2c, 0x8f820220,
41460x2403fffb, 0x431024, 0xaf820220, 0x8f820220,
41470x34420002, 0x8005083, 0xaf820220, 0x3c020001,
41480x8c427e00, 0x10400005, 0x0, 0x3c020001,
41490x8c427ddc, 0x1040000f, 0x24020002, 0x3c020001,
41500x8c427de0, 0x2c424e21, 0x1040000a, 0x24020002,
41510x3c020001, 0x8c427e00, 0x1040000f, 0x0,
41520x3c020001, 0x8c427ddc, 0x1440000b, 0x0,
41530x24020002, 0x3c010001, 0x8005083, 0xac227dd0,
41540x3c020001, 0x8c427e00, 0x10400003, 0x0,
41550xc00429b, 0x0, 0x8f820220, 0x3c03f700,
41560x431025, 0xaf820220, 0x8fbf0010, 0x3e00008,
41570x27bd0018, 0x3c030001, 0x24637e28, 0x8c620000,
41580x10400005, 0x34422000, 0x3c010001, 0xac227e1c,
41590x8005095, 0xac600000, 0x3c010001, 0xac247e1c,
41600x3e00008, 0x0, 0x27bdffe0, 0x30820030,
41610xafbf0018, 0x3c010001, 0xac227e24, 0x14400067,
41620x3c02ffff, 0x34421f0e, 0x821024, 0x14400061,
41630x24020030, 0x30822000, 0x1040005d, 0x30838000,
41640x31a02, 0x30820001, 0x21200, 0x3c040001,
41650x8c845d9c, 0x621825, 0x331c2, 0x3c030001,
41660x24635d78, 0x30828000, 0x21202, 0x30840001,
41670x42200, 0x441025, 0x239c2, 0x61080,
41680x431021, 0x471021, 0x90430000, 0x24020001,
41690x10620025, 0x0, 0x10600007, 0x24020002,
41700x10620013, 0x24020003, 0x1062002c, 0x3c05000f,
41710x80050f9, 0x0, 0x8f820200, 0x2403feff,
41720x431024, 0xaf820200, 0x8f820220, 0x3c03fffe,
41730x3463ffff, 0x431024, 0xaf820220, 0x3c010001,
41740xac207e44, 0x3c010001, 0x8005104, 0xac207e4c,
41750x8f820200, 0x34420100, 0xaf820200, 0x8f820220,
41760x3c03fffe, 0x3463ffff, 0x431024, 0xaf820220,
41770x24020100, 0x3c010001, 0xac227e44, 0x3c010001,
41780x8005104, 0xac207e4c, 0x8f820200, 0x2403feff,
41790x431024, 0xaf820200, 0x8f820220, 0x3c030001,
41800x431025, 0xaf820220, 0x3c010001, 0xac207e44,
41810x3c010001, 0x8005104, 0xac237e4c, 0x8f820200,
41820x34420100, 0xaf820200, 0x8f820220, 0x3c030001,
41830x431025, 0xaf820220, 0x24020100, 0x3c010001,
41840xac227e44, 0x3c010001, 0x8005104, 0xac237e4c,
41850x34a5ffff, 0x3c040001, 0x24845bb8, 0xafa30010,
41860xc002403, 0xafa00014, 0x8005104, 0x0,
41870x24020030, 0x3c010001, 0xac227e28, 0x8fbf0018,
41880x3e00008, 0x27bd0020, 0x0, 0x27bdffc8,
41890xafb20028, 0x809021, 0xafb3002c, 0xa09821,
41900xafb00020, 0xc08021, 0x3c040001, 0x24845bd0,
41910x3c050009, 0x3c020001, 0x8c425cc8, 0x34a59001,
41920x2403021, 0x2603821, 0xafbf0030, 0xafb10024,
41930xa7a0001a, 0xafb00014, 0xc002403, 0xafa20010,
41940x24020002, 0x12620083, 0x2e620003, 0x10400005,
41950x24020001, 0x1262000a, 0x0, 0x800529b,
41960x0, 0x24020004, 0x126200fa, 0x24020008,
41970x126200f9, 0x3c02ffec, 0x800529b, 0x0,
41980x3c020001, 0x8c425cc4, 0x30420002, 0x14400004,
41990x128940, 0x3c02fffb, 0x3442ffff, 0x2028024,
42000x3c010001, 0x310821, 0xac307e3c, 0x3c024000,
42010x2021024, 0x1040004e, 0x1023c2, 0x30840030,
42020x101382, 0x3042001c, 0x3c030001, 0x24635d08,
42030x431021, 0x823821, 0x3c020020, 0x2021024,
42040x10400006, 0x24020100, 0x3c010001, 0x310821,
42050xac227e40, 0x8005150, 0x3c020080, 0x3c010001,
42060x310821, 0xac207e40, 0x3c020080, 0x2021024,
42070x10400006, 0x121940, 0x3c020001, 0x3c010001,
42080x230821, 0x800515c, 0xac227e48, 0x121140,
42090x3c010001, 0x220821, 0xac207e48, 0x94e40000,
42100x3c030001, 0x8c635dbc, 0x24020005, 0x10620010,
42110xa7a40018, 0x32024000, 0x10400002, 0x34824000,
42120xa7a20018, 0x24040001, 0x94e20002, 0x24050004,
42130x24e60002, 0x34420001, 0xc00498e, 0xa4e20002,
42140x24040001, 0x2821, 0xc00498e, 0x27a60018,
42150x3c020001, 0x8c425cc8, 0x24110001, 0x3c010001,
42160xac315cd4, 0x14530004, 0x32028000, 0xc00429b,
42170x0, 0x32028000, 0x1040011f, 0x0,
42180xc00429b, 0x0, 0x3c030001, 0x8c635dbc,
42190x24020005, 0x10620118, 0x24020002, 0x3c010001,
42200xac315ccc, 0x3c010001, 0x800529b, 0xac225cc8,
42210x24040001, 0x24050004, 0x27b0001a, 0xc00498e,
42220x2003021, 0x24040001, 0x2821, 0xc00498e,
42230x2003021, 0x3c020001, 0x511021, 0x8c427e34,
42240x3c040001, 0x8c845cc8, 0x3c03bfff, 0x3463ffff,
42250x3c010001, 0xac335cd4, 0x431024, 0x3c010001,
42260x310821, 0x109300fa, 0xac227e34, 0x800529b,
42270x0, 0x3c022000, 0x2021024, 0x10400005,
42280x24020001, 0x3c010001, 0xac225d98, 0x80051ad,
42290x128940, 0x3c010001, 0xac205d98, 0x128940,
42300x3c010001, 0x310821, 0xac307e38, 0x3c024000,
42310x2021024, 0x14400016, 0x0, 0x3c020001,
42320x8c425d98, 0x10400008, 0x24040004, 0x24050001,
42330xc004d93, 0x24062000, 0x24020001, 0x3c010001,
42340x370821, 0xac2283ac, 0x3c020001, 0x511021,
42350x8c427e30, 0x3c03bfff, 0x3463ffff, 0x431024,
42360x3c010001, 0x310821, 0x8005299, 0xac227e30,
42370x3c020001, 0x8c425d98, 0x10400028, 0x3c0300a0,
42380x2031024, 0x5443000d, 0x3c020020, 0x3c020001,
42390x8c425d9c, 0x24030100, 0x3c010001, 0x310821,
42400xac237e44, 0x3c030001, 0x3c010001, 0x310821,
42410xac237e4c, 0x80051f0, 0x34420400, 0x2021024,
42420x10400008, 0x24030100, 0x3c020001, 0x8c425d9c,
42430x3c010001, 0x310821, 0xac237e44, 0x80051f0,
42440x34420800, 0x3c020080, 0x2021024, 0x1040002e,
42450x3c030001, 0x3c020001, 0x8c425d9c, 0x3c010001,
42460x310821, 0xac237e4c, 0x34420c00, 0x3c010001,
42470xac225d9c, 0x8005218, 0x24040001, 0x3c020020,
42480x2021024, 0x10400006, 0x24020100, 0x3c010001,
42490x310821, 0xac227e44, 0x8005201, 0x3c020080,
42500x3c010001, 0x310821, 0xac207e44, 0x3c020080,
42510x2021024, 0x10400007, 0x121940, 0x3c020001,
42520x3c010001, 0x230821, 0xac227e4c, 0x800520f,
42530x24040001, 0x121140, 0x3c010001, 0x220821,
42540xac207e4c, 0x24040001, 0x2821, 0x27b0001e,
42550xc00494c, 0x2003021, 0x24040001, 0x2821,
42560xc00494c, 0x2003021, 0x24040001, 0x24050001,
42570x27b0001c, 0xc00494c, 0x2003021, 0x24040001,
42580x24050001, 0xc00494c, 0x2003021, 0x8005299,
42590x0, 0x3c02ffec, 0x3442ffff, 0x2028024,
42600x3c020008, 0x2028025, 0x121140, 0x3c010001,
42610x220821, 0xac307e38, 0x3c022000, 0x2021024,
42620x10400009, 0x0, 0x3c020001, 0x8c425d74,
42630x14400005, 0x24020001, 0x3c010001, 0xac225d98,
42640x800523a, 0x3c024000, 0x3c010001, 0xac205d98,
42650x3c024000, 0x2021024, 0x1440001e, 0x0,
42660x3c020001, 0x8c425d98, 0x3c010001, 0xac205ce0,
42670x10400007, 0x24022020, 0x3c010001, 0xac225d9c,
42680x24020001, 0x3c010001, 0x370821, 0xac2283ac,
42690x3c04bfff, 0x121940, 0x3c020001, 0x431021,
42700x8c427e30, 0x3c050001, 0x8ca55cc8, 0x3484ffff,
42710x441024, 0x3c010001, 0x230821, 0xac227e30,
42720x24020001, 0x10a20044, 0x0, 0x8005299,
42730x0, 0x3c020001, 0x8c425d98, 0x1040001c,
42740x24022000, 0x3c010001, 0xac225d9c, 0x3c0300a0,
42750x2031024, 0x14430005, 0x121140, 0x3402a000,
42760x3c010001, 0x8005294, 0xac225d9c, 0x3c030001,
42770x621821, 0x8c637e38, 0x3c020020, 0x621024,
42780x10400004, 0x24022001, 0x3c010001, 0x8005294,
42790xac225d9c, 0x3c020080, 0x621024, 0x1040001f,
42800x3402a001, 0x3c010001, 0x8005294, 0xac225d9c,
42810x3c020020, 0x2021024, 0x10400007, 0x121940,
42820x24020100, 0x3c010001, 0x230821, 0xac227e44,
42830x8005288, 0x3c020080, 0x121140, 0x3c010001,
42840x220821, 0xac207e44, 0x3c020080, 0x2021024,
42850x10400006, 0x121940, 0x3c020001, 0x3c010001,
42860x230821, 0x8005294, 0xac227e4c, 0x121140,
42870x3c010001, 0x220821, 0xac207e4c, 0x3c030001,
42880x8c635cc8, 0x24020001, 0x10620003, 0x0,
42890xc00429b, 0x0, 0x8fbf0030, 0x8fb3002c,
42900x8fb20028, 0x8fb10024, 0x8fb00020, 0x3e00008,
42910x27bd0038, 0x27bdffd8, 0xafb20020, 0x809021,
42920xafb1001c, 0x8821, 0x24020002, 0xafbf0024,
42930xafb00018, 0xa7a00012, 0x10a200d3, 0xa7a00010,
42940x2ca20003, 0x10400005, 0x24020001, 0x10a2000a,
42950x128140, 0x8005380, 0x2201021, 0x24020004,
42960x10a2007d, 0x24020008, 0x10a2007c, 0x122940,
42970x8005380, 0x2201021, 0x3c030001, 0x701821,
42980x8c637e3c, 0x3c024000, 0x621024, 0x14400009,
42990x24040001, 0x3c027fff, 0x3442ffff, 0x628824,
43000x3c010001, 0x300821, 0xac317e34, 0x8005380,
43010x2201021, 0x24050001, 0xc00494c, 0x27a60010,
43020x24040001, 0x24050001, 0xc00494c, 0x27a60010,
43030x97a20010, 0x30420004, 0x10400034, 0x3c114000,
43040x3c020001, 0x8c425dbc, 0x2443ffff, 0x2c620006,
43050x10400034, 0x31080, 0x3c010001, 0x220821,
43060x8c225be0, 0x400008, 0x0, 0x24040001,
43070x24050011, 0x27b00012, 0xc00494c, 0x2003021,
43080x24040001, 0x24050011, 0xc00494c, 0x2003021,
43090x97a50012, 0x30a24000, 0x10400002, 0x3c040010,
43100x3c040008, 0x3c030001, 0x8005301, 0x30a28000,
43110x24040001, 0x24050014, 0x27b00012, 0xc00494c,
43120x2003021, 0x24040001, 0x24050014, 0xc00494c,
43130x2003021, 0x97a50012, 0x30a21000, 0x10400002,
43140x3c040010, 0x3c040008, 0x3c030001, 0x30a20800,
43150x54400001, 0x3c030002, 0x3c028000, 0x2221025,
43160x641825, 0x800530e, 0x438825, 0x3c110001,
43170x2308821, 0x8e317e3c, 0x3c027fff, 0x3442ffff,
43180x2228824, 0x3c020001, 0x8c425cd8, 0x1040001d,
43190x121140, 0x3c020001, 0x8c425d98, 0x10400002,
43200x3c022000, 0x2228825, 0x121140, 0x3c010001,
43210x220821, 0x8c227e40, 0x10400003, 0x3c020020,
43220x8005322, 0x2228825, 0x3c02ffdf, 0x3442ffff,
43230x2228824, 0x121140, 0x3c010001, 0x220821,
43240x8c227e48, 0x10400003, 0x3c020080, 0x800532d,
43250x2228825, 0x3c02ff7f, 0x3442ffff, 0x2228824,
43260x121140, 0x3c010001, 0x220821, 0xac317e34,
43270x8005380, 0x2201021, 0x122940, 0x3c030001,
43280x651821, 0x8c637e38, 0x3c024000, 0x621024,
43290x14400008, 0x3c027fff, 0x3442ffff, 0x628824,
43300x3c010001, 0x250821, 0xac317e30, 0x8005380,
43310x2201021, 0x3c020001, 0x8c425cd8, 0x10400033,
43320x3c11c00c, 0x3c020001, 0x8c425d74, 0x3c04c00c,
43330x34842000, 0x3c030001, 0x8c635d98, 0x2102b,
43340x21023, 0x441024, 0x10600003, 0x518825,
43350x3c022000, 0x2228825, 0x3c020001, 0x451021,
43360x8c427e44, 0x10400003, 0x3c020020, 0x800535d,
43370x2228825, 0x3c02ffdf, 0x3442ffff, 0x2228824,
43380x121140, 0x3c010001, 0x220821, 0x8c227e4c,
43390x10400003, 0x3c020080, 0x8005368, 0x2228825,
43400x3c02ff7f, 0x3442ffff, 0x2228824, 0x3c020001,
43410x8c425d60, 0x10400002, 0x3c020800, 0x2228825,
43420x3c020001, 0x8c425d64, 0x10400002, 0x3c020400,
43430x2228825, 0x3c020001, 0x8c425d68, 0x10400006,
43440x3c020100, 0x800537b, 0x2228825, 0x3c027fff,
43450x3442ffff, 0x628824, 0x121140, 0x3c010001,
43460x220821, 0xac317e30, 0x2201021, 0x8fbf0024,
43470x8fb20020, 0x8fb1001c, 0x8fb00018, 0x3e00008,
43480x27bd0028, 0x27bdffd8, 0xafb40020, 0x80a021,
43490xafbf0024, 0xafb3001c, 0xafb20018, 0xafb10014,
43500xafb00010, 0x8f900200, 0x3c030001, 0x8c635cc8,
43510x8f930220, 0x24020002, 0x10620063, 0x2c620003,
43520x10400005, 0x24020001, 0x1062000a, 0x141940,
43530x8005448, 0x0, 0x24020004, 0x1062005a,
43540x24020008, 0x10620059, 0x149140, 0x8005448,
43550x0, 0x3c040001, 0x832021, 0x8c847e3c,
43560x3c110001, 0x2238821, 0x8e317e34, 0x3c024000,
43570x821024, 0x1040003e, 0x3c020008, 0x2221024,
43580x10400020, 0x36100002, 0x3c020001, 0x431021,
43590x8c427e40, 0x10400005, 0x36100020, 0x36100100,
43600x3c020020, 0x80053bd, 0x2228825, 0x2402feff,
43610x2028024, 0x3c02ffdf, 0x3442ffff, 0x2228824,
43620x141140, 0x3c010001, 0x220821, 0x8c227e48,
43630x10400005, 0x3c020001, 0x2629825, 0x3c020080,
43640x80053dc, 0x2228825, 0x3c02fffe, 0x3442ffff,
43650x2629824, 0x3c02ff7f, 0x3442ffff, 0x80053dc,
43660x2228824, 0x2402fedf, 0x2028024, 0x3c02fffe,
43670x3442ffff, 0x2629824, 0x3c02ff5f, 0x3442ffff,
43680x2228824, 0x3c010001, 0x230821, 0xac207e40,
43690x3c010001, 0x230821, 0xac207e48, 0xc00486a,
43700x0, 0xaf900200, 0xaf930220, 0x8f820220,
43710x2403fffb, 0x431024, 0xaf820220, 0x8f820220,
43720x34420002, 0xaf820220, 0x80053f3, 0x141140,
43730x8f820200, 0x2403fffd, 0x431024, 0xc00486a,
43740xaf820200, 0x3c02bfff, 0x3442ffff, 0xc00429b,
43750x2228824, 0x141140, 0x3c010001, 0x220821,
43760x8005448, 0xac317e34, 0x149140, 0x3c040001,
43770x922021, 0x8c847e38, 0x3c110001, 0x2328821,
43780x8e317e30, 0x3c024000, 0x821024, 0x14400011,
43790x0, 0x3c020001, 0x8c425d98, 0x14400006,
43800x3c02bfff, 0x8f820200, 0x34420002, 0xc00486a,
43810xaf820200, 0x3c02bfff, 0x3442ffff, 0xc00429b,
43820x2228824, 0x3c010001, 0x320821, 0x8005448,
43830xac317e30, 0x3c020001, 0x8c425d98, 0x10400005,
43840x3c020020, 0x3c020001, 0x8c425d74, 0x1040002b,
43850x3c020020, 0x821024, 0x10400007, 0x36100020,
43860x24020100, 0x3c010001, 0x320821, 0xac227e44,
43870x8005428, 0x36100100, 0x3c010001, 0x320821,
43880xac207e44, 0x2402feff, 0x2028024, 0x3c020080,
43890x821024, 0x10400007, 0x141940, 0x3c020001,
43900x3c010001, 0x230821, 0xac227e4c, 0x8005439,
43910x2629825, 0x141140, 0x3c010001, 0x220821,
43920xac207e4c, 0x3c02fffe, 0x3442ffff, 0x2629824,
43930xc00486a, 0x0, 0xaf900200, 0xaf930220,
43940x8f820220, 0x2403fffb, 0x431024, 0xaf820220,
43950x8f820220, 0x34420002, 0xaf820220, 0x141140,
43960x3c010001, 0x220821, 0xac317e30, 0x8fbf0024,
43970x8fb40020, 0x8fb3001c, 0x8fb20018, 0x8fb10014,
43980x8fb00010, 0x3e00008, 0x27bd0028, 0x0 };
4399static u32 tigonFwRodata[(MAX_RODATA_LEN/4) + 1] __devinitdata = {
44000x24486561, 0x6465723a, 0x202f7072,
44010x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
44020x2f2e2f6e, 0x69632f66, 0x772f636f, 0x6d6d6f6e,
44030x2f66776d, 0x61696e2e, 0x632c7620, 0x312e312e,
44040x322e3131, 0x20313939, 0x382f3034, 0x2f323720,
44050x32323a31, 0x333a3432, 0x20736875, 0x616e6720,
44060x45787020, 0x24000000, 0x7468655f, 0x4441574e,
44070x0, 0x53544143, 0x4b5f3120, 0x0,
44080x42616453, 0x6e64526e, 0x67000000, 0x3f456e71,
44090x45767400, 0x3f6e6f51, 0x64457650, 0x0,
44100x6576526e, 0x6746756c, 0x6c000000, 0x496c6c43,
44110x6f6e6652, 0x78000000, 0x53656e64, 0x436b5375,
44120x6d000000, 0x52656376, 0x566c616e, 0x0,
44130x0, 0x24486561, 0x6465723a, 0x202f7072,
44140x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
44150x2f2e2f6e, 0x69632f66, 0x772f636f, 0x6d6d6f6e,
44160x2f74696d, 0x65722e63, 0x2c762031, 0x2e312e32,
44170x2e382031, 0x3939382f, 0x30372f33, 0x31203137,
44180x3a35383a, 0x34352073, 0x6875616e, 0x67204578,
44190x70202400, 0x542d446d, 0x61526431, 0x0,
44200x542d446d, 0x61424200, 0x542d446d, 0x61320000,
44210x3f6e6f51, 0x64547845, 0x0, 0x3f6e6f51,
44220x64527845, 0x0, 0x656e714d, 0x45765046,
44230x61696c00, 0x656e714d, 0x45764661, 0x696c0000,
44240x6661696c, 0x456e454d, 0x0, 0x3f456e71,
44250x45767400, 0x3f6e6f51, 0x64457650, 0x0,
44260x6576526e, 0x6746756c, 0x6c000000, 0x0,
44270x0, 0x24486561, 0x6465723a, 0x202f7072,
44280x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
44290x2f2e2f6e, 0x69632f66, 0x772f636f, 0x6d6d6f6e,
44300x2f636f6d, 0x6d616e64, 0x2e632c76, 0x20312e31,
44310x2e322e31, 0x30203139, 0x39382f31, 0x312f3138,
44320x2031373a, 0x31313a31, 0x38207368, 0x75616e67,
44330x20457870, 0x20240000, 0x3f4d626f, 0x78457674,
44340x0, 0x4e4f636f, 0x6d616e64, 0x0,
44350x68737465, 0x5f455252, 0x0, 0x412d4572,
44360x72427563, 0x0, 0x4552524f, 0x522d4164,
44370x64000000, 0x656e714d, 0x45765046, 0x61696c00,
44380x656e714d, 0x45764661, 0x696c0000, 0x6661696c,
44390x456e454d, 0x0, 0x442d4572, 0x724c6173,
44400x74000000, 0x442d4572, 0x72320000, 0x6d437374,
44410x4d644552, 0x52000000, 0x70726f6d, 0x4d644552,
44420x52000000, 0x46696c74, 0x4d644552, 0x52000000,
44430x636d645f, 0x45525200, 0x3f456e71, 0x45767400,
44440x3f6e6f51, 0x64457650, 0x0, 0x6576526e,
44450x6746756c, 0x6c000000, 0x0, 0x6ea0,
44460x7fbc, 0x6e38, 0x8734, 0x82b0,
44470x8780, 0x8780, 0x6f54, 0x7694,
44480x7f0c, 0x80a8, 0x8074, 0x8780,
44490x7e70, 0x80cc, 0x6e64, 0x81cc,
44500x0, 0x24486561, 0x6465723a, 0x202f7072,
44510x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
44520x2f2e2f6e, 0x69632f66, 0x772f636f, 0x6d6d6f6e,
44530x2f646d61, 0x2e632c76, 0x20312e31, 0x2e322e33,
44540x20313939, 0x382f3034, 0x2f323720, 0x32323a31,
44550x333a3431, 0x20736875, 0x616e6720, 0x45787020,
44560x24000000, 0x646d6172, 0x6441544e, 0x0,
44570x646d6177, 0x7241544e, 0x0, 0x0,
44580x0, 0x24486561, 0x6465723a, 0x202f7072,
44590x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
44600x2f2e2f6e, 0x69632f66, 0x772f636f, 0x6d6d6f6e,
44610x2f747261, 0x63652e63, 0x2c762031, 0x2e312e32,
44620x2e322031, 0x3939382f, 0x30342f32, 0x37203232,
44630x3a31333a, 0x35302073, 0x6875616e, 0x67204578,
44640x70202400, 0x24486561, 0x6465723a, 0x202f7072,
44650x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
44660x2f2e2f6e, 0x69632f66, 0x772f636f, 0x6d6d6f6e,
44670x2f646174, 0x612e632c, 0x7620312e, 0x312e322e,
44680x32203139, 0x39382f30, 0x342f3237, 0x2032323a,
44690x31333a34, 0x30207368, 0x75616e67, 0x20457870,
44700x20240000, 0x46575f56, 0x45525349, 0x4f4e3a20,
44710x23312046, 0x72692041, 0x70722037, 0x2031373a,
44720x35353a34, 0x38205044, 0x54203230, 0x30300000,
44730x46575f43, 0x4f4d5049, 0x4c455f54, 0x494d453a,
44740x2031373a, 0x35353a34, 0x38000000, 0x46575f43,
44750x4f4d5049, 0x4c455f42, 0x593a2064, 0x65767263,
44760x73000000, 0x46575f43, 0x4f4d5049, 0x4c455f48,
44770x4f53543a, 0x20636f6d, 0x70757465, 0x0,
44780x46575f43, 0x4f4d5049, 0x4c455f44, 0x4f4d4149,
44790x4e3a2065, 0x6e672e61, 0x6374656f, 0x6e2e636f,
44800x6d000000, 0x46575f43, 0x4f4d5049, 0x4c45523a,
44810x20676363, 0x20766572, 0x73696f6e, 0x20322e37,
44820x2e320000, 0x0, 0x0, 0x0,
44830x0, 0x24486561, 0x6465723a, 0x202f7072,
44840x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
44850x2f2e2f6e, 0x69632f66, 0x772f636f, 0x6d6d6f6e,
44860x2f6d656d, 0x2e632c76, 0x20312e31, 0x2e322e32,
44870x20313939, 0x382f3034, 0x2f323720, 0x32323a31,
44880x333a3434, 0x20736875, 0x616e6720, 0x45787020,
44890x24000000, 0x24486561, 0x6465723a, 0x202f7072,
44900x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
44910x2f2e2f6e, 0x69632f66, 0x772f636f, 0x6d6d6f6e,
44920x2f73656e, 0x642e632c, 0x7620312e, 0x312e322e,
44930x31312031, 0x3939382f, 0x31322f32, 0x32203137,
44940x3a31373a, 0x35352073, 0x6875616e, 0x67204578,
44950x70202400, 0x736e6464, 0x654e6f51, 0x20000000,
44960x6e6f454e, 0x515f5458, 0x0, 0x736e6464,
44970x744e6f51, 0x20000000, 0x3f6e6f51, 0x64547845,
44980x0, 0x756e6b72, 0x64747970, 0x65000000,
44990x0, 0xaccc, 0xaccc, 0xad9c,
45000xaab0, 0xaab0, 0xad9c, 0xad9c,
45010xad9c, 0xad9c, 0xad9c, 0xad9c,
45020xad9c, 0xad9c, 0xad9c, 0xad9c,
45030xad9c, 0xad9c, 0xad9c, 0xad7c,
45040x0, 0xbca8, 0xbca8, 0xbd70,
45050xae4c, 0xb058, 0xbd70, 0xbd70,
45060xbd70, 0xbd70, 0xbd70, 0xbd70,
45070xbd70, 0xbd70, 0xbd70, 0xbd70,
45080xbd70, 0xbd70, 0xbd70, 0xbd54,
45090xb040, 0x24486561, 0x6465723a, 0x202f7072,
45100x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
45110x2f2e2f6e, 0x69632f66, 0x772f636f, 0x6d6d6f6e,
45120x2f726563, 0x762e632c, 0x7620312e, 0x312e322e,
45130x31392031, 0x3939382f, 0x30372f32, 0x34203231,
45140x3a33303a, 0x30352073, 0x6875616e, 0x67204578,
45150x70202400, 0x706b5278, 0x45525200, 0x66726d32,
45160x4c617267, 0x65000000, 0x72784e6f, 0x52784264,
45170x0, 0x72785144, 0x6d614446, 0x0,
45180x72785144, 0x6d614246, 0x0, 0x3f6e6f51,
45190x64527845, 0x0, 0x706b5278, 0x45525273,
45200x0, 0x66726d32, 0x4c726753, 0x0,
45210x72784e6f, 0x42645300, 0x3f724264, 0x446d6146,
45220x0, 0x3f724a42, 0x64446d46, 0x0,
45230x0, 0xf678, 0xf678, 0xf678,
45240xf678, 0xf678, 0xf678, 0xf678,
45250xf678, 0xf678, 0xf678, 0xf678,
45260xf678, 0xf678, 0xf678, 0xf678,
45270xf670, 0xf670, 0xf670, 0x572d444d,
45280x41456e46, 0x0, 0x0, 0xfdc0,
45290x1015c, 0xfddc, 0x1015c, 0x1015c,
45300x1015c, 0x1015c, 0x1015c, 0x1015c,
45310xf704, 0x1015c, 0x1015c, 0x1015c,
45320x1015c, 0x1015c, 0x10154, 0x10154,
45330x10154, 0x24486561, 0x6465723a, 0x202f7072,
45340x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
45350x2f2e2f6e, 0x69632f66, 0x772f636f, 0x6d6d6f6e,
45360x2f6d6163, 0x2e632c76, 0x20312e31, 0x2e322e31,
45370x32203139, 0x39382f30, 0x342f3237, 0x2032323a,
45380x31333a34, 0x32207368, 0x75616e67, 0x20457870,
45390x20240000, 0x6d616374, 0x7841544e, 0x0,
45400x4e745379, 0x6e264c6b, 0x0, 0x72656d61,
45410x73737274, 0x0, 0x6c696e6b, 0x444f574e,
45420x0, 0x656e714d, 0x45765046, 0x61696c00,
45430x656e714d, 0x45764661, 0x696c0000, 0x6661696c,
45440x456e454d, 0x0, 0x6c696e6b, 0x55500000,
45450x0, 0x24486561, 0x6465723a, 0x202f7072,
45460x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
45470x2f2e2f6e, 0x69632f66, 0x772f636f, 0x6d6d6f6e,
45480x2f636b73, 0x756d2e63, 0x2c762031, 0x2e312e32,
45490x2e322031, 0x3939382f, 0x30342f32, 0x37203232,
45500x3a31333a, 0x33392073, 0x6875616e, 0x67204578,
45510x70202400, 0x50726f62, 0x65506879, 0x0,
45520x6c6e6b41, 0x53535254, 0x0, 0x11b2c,
45530x11bc4, 0x11bf8, 0x11c2c, 0x11c58,
45540x11c6c, 0x11ca8, 0x1207c, 0x11de4,
45550x11e24, 0x11e50, 0x11e90, 0x11ec0,
45560x11efc, 0x11f30, 0x1207c, 0x122c0,
45570x122d8, 0x12300, 0x12320, 0x12348,
45580x12478, 0x124a0, 0x124f4, 0x1251c,
45590x0, 0x1278c, 0x1285c, 0x12934,
45600x12a04, 0x12a60, 0x12b3c, 0x12b64,
45610x12c40, 0x12c68, 0x12e10, 0x12e38,
45620x12fe0, 0x131d8, 0x1346c, 0x13380,
45630x1346c, 0x13498, 0x13008, 0x131b0,
45640x0, 0x13b84, 0x13bc8, 0x13c60,
45650x13cac, 0x13d1c, 0x13db4, 0x13de8,
45660x13e70, 0x13f08, 0x13fd8, 0x14018,
45670x1409c, 0x140c0, 0x141f4, 0x646f4261,
45680x73655067, 0x0, 0x0, 0x0,
45690x0, 0x73746d61, 0x634c4e4b, 0x0,
45700x0, 0x14c38, 0x14c38, 0x14b80,
45710x14bc4, 0x14c38, 0x14c38, 0x0,
45720x0, 0x0 };
4573static u32 tigonFwData[(MAX_DATA_LEN/4) + 1] __devinitdata = {
45740x416c7465,
45750x6f6e2041, 0x63654e49, 0x43205600, 0x416c7465,
45760x6f6e2041, 0x63654e49, 0x43205600, 0x42424242,
45770x0, 0x0, 0x0, 0x135418,
45780x13e7fc, 0x0, 0x0, 0x0,
45790x0, 0x0, 0x0, 0x60cf00,
45800x60, 0xcf000000, 0x0, 0x0,
45810x0, 0x0, 0x0, 0x0,
45820x0, 0x0, 0x0, 0x0,
45830x0, 0x0, 0x0, 0x0,
45840x0, 0x0, 0x0, 0x0,
45850x0, 0x0, 0x3, 0x0,
45860x1, 0x0, 0x0, 0x0,
45870x1, 0x0, 0x1, 0x0,
45880x0, 0x0, 0x0, 0x1,
45890x1, 0x0, 0x0, 0x0,
45900x0, 0x0, 0x1000000, 0x21000000,
45910x12000140, 0x0, 0x0, 0x20000000,
45920x120000a0, 0x0, 0x12000060, 0x12000180,
45930x120001e0, 0x0, 0x0, 0x0,
45940x1, 0x0, 0x0, 0x0,
45950x0, 0x0, 0x0, 0x2,
45960x0, 0x0, 0x30001, 0x1,
45970x30201, 0x0, 0x0, 0x0 };
4598#endif
4599/* Generated by genfw.c */
4600#define tigon2FwReleaseMajor 0xc
4601#define tigon2FwReleaseMinor 0x4
4602#define tigon2FwReleaseFix 0xb
4603#define tigon2FwStartAddr 0x00004000
4604#define tigon2FwTextAddr 0x00004000
4605#define tigon2FwTextLen 0x11bc0
4606#define tigon2FwRodataAddr 0x00015bc0
4607#define tigon2FwRodataLen 0x10d0
4608#define tigon2FwDataAddr 0x00016cc0
4609#define tigon2FwDataLen 0x1c0
4610#define tigon2FwSbssAddr 0x00016e80
4611#define tigon2FwSbssLen 0xcc
4612#define tigon2FwBssAddr 0x00016f50
4613#define tigon2FwBssLen 0x20c0
4614static u32 tigon2FwText[(MAX_TEXT_LEN/4) + 1] __devinitdata = {
46150x0,
46160x10000003, 0x0, 0xd, 0xd,
46170x3c1d0001, 0x8fbd6d20, 0x3a0f021, 0x3c100000,
46180x26104000, 0xc0010c0, 0x0, 0xd,
46190x3c1d0001, 0x8fbd6d24, 0x3a0f021, 0x3c100000,
46200x26104000, 0xc0017e0, 0x0, 0xd,
46210x0, 0x0, 0x0, 0x0,
46220x0, 0x0, 0x0, 0x0,
46230x0, 0x0, 0x0, 0x0,
46240x0, 0x0, 0x0, 0x0,
46250x0, 0x0, 0x0, 0x0,
46260x0, 0x0, 0x0, 0x0,
46270x0, 0x0, 0x0, 0x0,
46280x0, 0x0, 0x0, 0x0,
46290x0, 0x0, 0x0, 0x0,
46300x0, 0x0, 0x0, 0x0,
46310x0, 0x0, 0x0, 0x2000008,
46320x0, 0x800172f, 0x3c0a0001, 0x800172f,
46330x3c0a0002, 0x800172f, 0x0, 0x8002cac,
46340x0, 0x8002c4f, 0x0, 0x800172f,
46350x3c0a0004, 0x800328a, 0x0, 0x8001a52,
46360x0, 0x800394d, 0x0, 0x80038f4,
46370x0, 0x800172f, 0x3c0a0006, 0x80039bb,
46380x3c0a0007, 0x800172f, 0x3c0a0008, 0x800172f,
46390x3c0a0009, 0x8003a13, 0x0, 0x8002ea6,
46400x0, 0x800172f, 0x3c0a000b, 0x800172f,
46410x3c0a000c, 0x800172f, 0x3c0a000d, 0x80028fb,
46420x0, 0x8002890, 0x0, 0x800172f,
46430x3c0a000e, 0x800208c, 0x0, 0x8001964,
46440x0, 0x8001a04, 0x0, 0x8003ca6,
46450x0, 0x8003c94, 0x0, 0x800172f,
46460x0, 0x800191a, 0x0, 0x800172f,
46470x0, 0x800172f, 0x3c0a0013, 0x800172f,
46480x3c0a0014, 0x0, 0x0, 0x0,
46490x0, 0x0, 0x0, 0x0,
46500x0, 0x0, 0x0, 0x0,
46510x0, 0x0, 0x0, 0x0,
46520x0, 0x0, 0x0, 0x0,
46530x0, 0x0, 0x0, 0x0,
46540x0, 0x0, 0x0, 0x0,
46550x0, 0x0, 0x0, 0x0,
46560x0, 0x0, 0x0, 0x0,
46570x0, 0x0, 0x0, 0x0,
46580x0, 0x0, 0x0, 0x0,
46590x0, 0x0, 0x0, 0x0,
46600x0, 0x0, 0x0, 0x0,
46610x0, 0x0, 0x0, 0x0,
46620x0, 0x0, 0x0, 0x0,
46630x0, 0x0, 0x0, 0x27bdffe0,
46640x3c1cc000, 0xafbf001c, 0xafb00018, 0x8f820140,
46650x24030003, 0xaf8300ec, 0x34420004, 0xc002b20,
46660xaf820140, 0x3c0100c0, 0xc001763, 0xac203ffc,
46670x401821, 0x3c020010, 0x3c010001, 0xac236e9c,
46680x10620011, 0x43102b, 0x14400002, 0x3c020020,
46690x3c020008, 0x1062000c, 0x24050100, 0x3c060001,
46700x8cc66e9c, 0x3c040001, 0x24845c74, 0x3821,
46710xafa00010, 0xc002b3b, 0xafa00014, 0x3c020020,
46720x3c010001, 0xac226e9c, 0x24020008, 0x3c010001,
46730xac226eb4, 0x2402001f, 0x3c010001, 0xac226ec4,
46740x24020016, 0x3c010001, 0xac226e98, 0x3c05fffe,
46750x34a56f08, 0x3c020001, 0x8c426e9c, 0x3c030002,
46760x24639010, 0x3c040001, 0x8c846cc4, 0x431023,
46770x14800002, 0x458021, 0x2610fa38, 0x2402f000,
46780x2028024, 0xc001785, 0x2002021, 0x2022823,
46790x3c040020, 0x821823, 0x651823, 0x247bb000,
46800x3c03fffe, 0x3463bf08, 0x363b821, 0x3c0600bf,
46810x34c6f000, 0x3c070001, 0x8ce76cc0, 0x3c0300bf,
46820x3463e000, 0x852023, 0x3c010001, 0xac246ea8,
46830x822023, 0x3c010001, 0xac256e90, 0x52842,
46840x3c010001, 0xac226e84, 0x27620ffc, 0x3c010001,
46850xac226d20, 0x27621ffc, 0xdb3023, 0x7b1823,
46860x3c010001, 0xac246e88, 0x3c010001, 0xac256eac,
46870x3c010001, 0xac226d24, 0xaf860150, 0x10e00011,
46880xaf830250, 0x3c1d0001, 0x8fbd6ccc, 0x3a0f021,
46890xc001749, 0x0, 0x3c020001, 0x8c426cd0,
46900x3c030001, 0x8c636cd4, 0x2442fe00, 0x24630200,
46910x3c010001, 0xac226cd0, 0x3c010001, 0x10000004,
46920xac236cd4, 0x3c1d0001, 0x8fbd6d20, 0x3a0f021,
46930x3c020001, 0x8c426cc4, 0x1040000d, 0x26fafa38,
46940x3c020001, 0x8c426cd0, 0x3c030001, 0x8c636cd4,
46950x3c1a0001, 0x8f5a6cd4, 0x2442fa38, 0x246305c8,
46960x3c010001, 0xac226cd0, 0x3c010001, 0xac236cd4,
46970x3c020001, 0x8c426cc8, 0x14400003, 0x0,
46980x3c010001, 0xac206cd0, 0xc001151, 0x0,
46990x8fbf001c, 0x8fb00018, 0x3e00008, 0x27bd0020,
47000x3c020001, 0x8c426cd0, 0x3c030001, 0x8c636cd4,
47010x27bdff98, 0xafb00048, 0x3c100001, 0x8e1066b8,
47020xafb20050, 0x3c120000, 0x26524100, 0xafbf0060,
47030xafbe005c, 0xafb50058, 0xafb30054, 0xafb1004c,
47040xafa20034, 0xafa30030, 0xafa00010, 0xafa00014,
47050x8f860040, 0x3c040001, 0x24845c80, 0x24050200,
47060x3c010001, 0xac326e80, 0xc002b3b, 0x2003821,
47070x8f830040, 0x3c02f000, 0x621824, 0x3c026000,
47080x1062000b, 0xa3a0003f, 0x240e0001, 0x3c040001,
47090x24845c88, 0xa3ae003f, 0xafa00010, 0xafa00014,
47100x8f860040, 0x24050300, 0xc002b3b, 0x2003821,
47110x8f820240, 0x3c030001, 0x431025, 0xaf820240,
47120xaf800048, 0x8f820048, 0x14400005, 0x0,
47130xaf800048, 0x8f820048, 0x10400004, 0x0,
47140xaf800048, 0x10000003, 0x2e02021, 0xaf80004c,
47150x2e02021, 0x3c050001, 0xc002ba8, 0x34a540f8,
47160x3402021, 0xc002ba8, 0x240505c8, 0x3c020001,
47170x8c426ea8, 0x3c0d0001, 0x8dad6e88, 0x3c030001,
47180x8c636e84, 0x3c080001, 0x8d086e90, 0x3c090001,
47190x8d296eac, 0x3c0a0001, 0x8d4a6eb4, 0x3c0b0001,
47200x8d6b6ec4, 0x3c0c0001, 0x8d8c6e98, 0x3c040001,
47210x24845c94, 0x24050400, 0xaf42013c, 0x8f42013c,
47220x24060001, 0x24070001, 0xaf400000, 0xaf4d0138,
47230xaf430144, 0xaf480148, 0xaf49014c, 0xaf4a0150,
47240xaf4b0154, 0xaf4c0158, 0x2442ff80, 0xaf420140,
47250x24020001, 0xafa20010, 0xc002b3b, 0xafa00014,
47260x8f420138, 0xafa20010, 0x8f42013c, 0xafa20014,
47270x8f460144, 0x8f470148, 0x3c040001, 0x24845ca0,
47280xc002b3b, 0x24050500, 0xafb70010, 0xafba0014,
47290x8f46014c, 0x8f470150, 0x3c040001, 0x24845cac,
47300xc002b3b, 0x24050600, 0x3c020001, 0x8c426e9c,
47310x3603821, 0x3c060002, 0x24c69010, 0x2448ffff,
47320x1061824, 0xe81024, 0x43102b, 0x10400006,
47330x24050900, 0x3c040001, 0x24845cb8, 0xafa80010,
47340xc002b3b, 0xafa00014, 0x8f82000c, 0xafa20010,
47350x8f82003c, 0xafa20014, 0x8f860000, 0x8f870004,
47360x3c040001, 0x24845cc4, 0xc002b3b, 0x24051000,
47370x8c020220, 0x8c030224, 0x8c060218, 0x8c07021c,
47380x3c040001, 0x24845ccc, 0x24051100, 0xafa20010,
47390xc002b3b, 0xafa30014, 0xaf800054, 0xaf80011c,
47400x8c020218, 0x30420002, 0x10400009, 0x0,
47410x8c020220, 0x3c030002, 0x34630004, 0x431025,
47420xaf42000c, 0x8c02021c, 0x10000008, 0x34420004,
47430x8c020220, 0x3c030002, 0x34630006, 0x431025,
47440xaf42000c, 0x8c02021c, 0x34420006, 0xaf420014,
47450x8c020218, 0x30420010, 0x1040000a, 0x0,
47460x8c02021c, 0x34420004, 0xaf420010, 0x8c020220,
47470x3c03000a, 0x34630004, 0x431025, 0x10000009,
47480xaf420008, 0x8c020220, 0x3c03000a, 0x34630006,
47490x431025, 0xaf420008, 0x8c02021c, 0x34420006,
47500xaf420010, 0x24020001, 0xaf8200a0, 0xaf8200b0,
47510x8f830054, 0x8f820054, 0xaf8000d0, 0xaf8000c0,
47520x10000002, 0x24630064, 0x8f820054, 0x621023,
47530x2c420065, 0x1440fffc, 0x0, 0x8c040208,
47540x8c05020c, 0x26e20028, 0xaee20020, 0x24020490,
47550xaee20010, 0xaee40008, 0xaee5000c, 0x26e40008,
47560x8c820000, 0x8c830004, 0xaf820090, 0xaf830094,
47570x8c820018, 0xaf8200b4, 0x9482000a, 0xaf82009c,
47580x8f420014, 0xaf8200b0, 0x8f8200b0, 0x30420004,
47590x1440fffd, 0x0, 0x8f8200b0, 0x3c03ef00,
47600x431024, 0x10400021, 0x0, 0x8f8200b4,
47610xafa20010, 0x8f820090, 0x8f830094, 0x3c040001,
47620x24845cd4, 0xafa30014, 0x8f8600b0, 0x8f87009c,
47630x3c050001, 0xc002b3b, 0x34a5200d, 0x3c040001,
47640x24845ce0, 0x240203c0, 0xafa20010, 0xafa00014,
47650x8f860144, 0x3c070001, 0x24e75ce8, 0xc002b3b,
47660x3405dead, 0x8f82011c, 0x34420002, 0xaf82011c,
47670x8f820220, 0x34420004, 0xaf820220, 0x8f820140,
47680x3c030001, 0x431025, 0xaf820140, 0x96e20472,
47690x96e60452, 0x96e70462, 0xafa20010, 0x96e20482,
47700x3c040001, 0x24845d14, 0x24051200, 0xc002b3b,
47710xafa20014, 0x96f00452, 0x32020001, 0x10400002,
47720xb021, 0x24160001, 0x32020002, 0x54400001,
47730x36d60002, 0x32020008, 0x54400001, 0x36d60004,
47740x32020010, 0x54400001, 0x36d60008, 0x32020020,
47750x54400001, 0x36d60010, 0x32020040, 0x54400001,
47760x36d60020, 0x32020080, 0x54400001, 0x36d60040,
47770x96e60482, 0x30c20200, 0x54400001, 0x36d64000,
47780x96e30472, 0x30620200, 0x10400003, 0x30620100,
47790x10000003, 0x36d62000, 0x54400001, 0x36d61000,
47800x96f00462, 0x32c24000, 0x14400004, 0x3207009b,
47810x30c2009b, 0x14e20007, 0x240e0001, 0x32c22000,
47820x1440000d, 0x32020001, 0x3062009b, 0x10e20009,
47830x240e0001, 0x3c040001, 0x24845d20, 0x24051300,
47840x2003821, 0xa3ae003f, 0xafa30010, 0xc002b3b,
47850xafa00014, 0x32020001, 0x54400001, 0x36d60080,
47860x32020002, 0x54400001, 0x36d60100, 0x32020008,
47870x54400001, 0x36d60200, 0x32020010, 0x54400001,
47880x36d60400, 0x32020080, 0x54400001, 0x36d60800,
47890x8c020218, 0x30420200, 0x10400002, 0x3c020008,
47900x2c2b025, 0x8c020218, 0x30420800, 0x10400002,
47910x3c020080, 0x2c2b025, 0x8c020218, 0x30420400,
47920x10400002, 0x3c020100, 0x2c2b025, 0x8c020218,
47930x30420100, 0x10400002, 0x3c020200, 0x2c2b025,
47940x8c020218, 0x30420080, 0x10400002, 0x3c020400,
47950x2c2b025, 0x8c020218, 0x30422000, 0x10400002,
47960x3c020010, 0x2c2b025, 0x8c020218, 0x30424000,
47970x10400002, 0x3c020020, 0x2c2b025, 0x8c020218,
47980x30421000, 0x10400002, 0x3c020040, 0x2c2b025,
47990x8ee20498, 0x8ee3049c, 0xaf420160, 0xaf430164,
48000x8ee204a0, 0x8ee304a4, 0xaf420168, 0xaf43016c,
48010x8ee204a8, 0x8ee304ac, 0xaf420170, 0xaf430174,
48020x8ee20428, 0x8ee3042c, 0xaf420178, 0xaf43017c,
48030x8ee20448, 0x8ee3044c, 0xaf420180, 0xaf430184,
48040x8ee20458, 0x8ee3045c, 0xaf420188, 0xaf43018c,
48050x8ee20468, 0x8ee3046c, 0xaf420190, 0xaf430194,
48060x8ee20478, 0x8ee3047c, 0xaf420198, 0xaf43019c,
48070x8ee20488, 0x8ee3048c, 0xaf4201a0, 0xaf4301a4,
48080x8ee204b0, 0x8ee304b4, 0x24040080, 0xaf4201a8,
48090xaf4301ac, 0xc002ba8, 0x24050080, 0x8c02025c,
48100x27440224, 0xaf4201f0, 0x8c020260, 0x24050200,
48110x24060008, 0xc002bbf, 0xaf4201f8, 0x3c043b9a,
48120x3484ca00, 0x3821, 0x24020006, 0x24030002,
48130xaf4201f4, 0x240203e8, 0xaf430204, 0xaf430200,
48140xaf4401fc, 0xaf420294, 0x24020001, 0xaf430290,
48150xaf42029c, 0x3c030001, 0x671821, 0x90636cd8,
48160x3471021, 0x24e70001, 0xa043022c, 0x2ce2000f,
48170x1440fff8, 0x3471821, 0x24e70001, 0x3c080001,
48180x350840f8, 0x8f820040, 0x3c040001, 0x24845d2c,
48190x24051400, 0x21702, 0x24420030, 0xa062022c,
48200x3471021, 0xa040022c, 0x8c070218, 0x2c03021,
48210x240205c8, 0xafa20010, 0xc002b3b, 0xafa80014,
48220x3c040001, 0x24845d38, 0x3c050000, 0x24a55c80,
48230x24060010, 0x27b10030, 0x2203821, 0x27b30034,
48240xc0017a3, 0xafb30010, 0x3c030001, 0x8c636cc8,
48250x1060000a, 0x408021, 0x8fa30030, 0x2405ff00,
48260x8fa20034, 0x246400ff, 0x852024, 0x831823,
48270x431023, 0xafa20034, 0xafa40030, 0x3c040001,
48280x24845d44, 0x3c050000, 0x24a54100, 0x24060108,
48290x2203821, 0xc0017a3, 0xafb30010, 0x409021,
48300x32c20003, 0x3c010001, 0xac326e80, 0x10400045,
48310x2203821, 0x8f820050, 0x3c030010, 0x431024,
48320x10400016, 0x0, 0x8c020218, 0x30420040,
48330x1040000f, 0x24020001, 0x8f820050, 0x8c030218,
48340x240e0001, 0x3c040001, 0x24845d50, 0xa3ae003f,
48350xafa20010, 0xafa30014, 0x8f870040, 0x24051500,
48360xc002b3b, 0x2c03021, 0x10000004, 0x0,
48370x3c010001, 0x370821, 0xa02240f4, 0x3c040001,
48380x24845d5c, 0x3c050001, 0x24a55b40, 0x3c060001,
48390x24c65bac, 0xc53023, 0x8f420010, 0x27b30030,
48400x2603821, 0x27b10034, 0x34420a00, 0xaf420010,
48410xc0017a3, 0xafb10010, 0x3c040001, 0x24845d70,
48420x3c050001, 0x24a5b714, 0x3c060001, 0x24c6ba90,
48430xc53023, 0x2603821, 0xaf420108, 0xc0017a3,
48440xafb10010, 0x3c040001, 0x24845d8c, 0x3c050001,
48450x24a5be58, 0x3c060001, 0x24c6c900, 0xc53023,
48460x2603821, 0x3c010001, 0xac226ef4, 0xc0017a3,
48470xafb10010, 0x3c040001, 0x24845da4, 0x10000024,
48480x24051600, 0x3c040001, 0x24845dac, 0x3c050001,
48490x24a5a10c, 0x3c060001, 0x24c6a238, 0xc53023,
48500xc0017a3, 0xafb30010, 0x3c040001, 0x24845dbc,
48510x3c050001, 0x24a5b2b0, 0x3c060001, 0x24c6b70c,
48520xc53023, 0x2203821, 0xaf420108, 0xc0017a3,
48530xafb30010, 0x3c040001, 0x24845dd0, 0x3c050001,
48540x24a5ba98, 0x3c060001, 0x24c6be50, 0xc53023,
48550x2203821, 0x3c010001, 0xac226ef4, 0xc0017a3,
48560xafb30010, 0x3c040001, 0x24845de4, 0x24051650,
48570x2c03021, 0x3821, 0x3c010001, 0xac226ef8,
48580xafa00010, 0xc002b3b, 0xafa00014, 0x32c20020,
48590x10400021, 0x27a70030, 0x3c040001, 0x24845df0,
48600x3c050001, 0x24a5b13c, 0x3c060001, 0x24c6b2a8,
48610xc53023, 0x24022000, 0xaf42001c, 0x27a20034,
48620xc0017a3, 0xafa20010, 0x21900, 0x31982,
48630x3c040800, 0x641825, 0xae430028, 0x24030010,
48640xaf43003c, 0x96e30450, 0xaf430040, 0x8f430040,
48650x3c040001, 0x24845e04, 0xafa00014, 0xafa30010,
48660x8f47001c, 0x24051660, 0x3c010001, 0xac226ef0,
48670x10000025, 0x32c60020, 0x8ee20448, 0x8ee3044c,
48680xaf43001c, 0x8f42001c, 0x2442e000, 0x2c422001,
48690x1440000a, 0x240e0001, 0x3c040001, 0x24845e10,
48700xa3ae003f, 0xafa00010, 0xafa00014, 0x8f46001c,
48710x24051700, 0xc002b3b, 0x3821, 0x3c020000,
48720x24425cbc, 0x21100, 0x21182, 0x3c030800,
48730x431025, 0xae420028, 0x24020008, 0xaf42003c,
48740x96e20450, 0xaf420040, 0x8f420040, 0x3c040001,
48750x24845e1c, 0xafa00014, 0xafa20010, 0x8f47001c,
48760x24051800, 0x32c60020, 0xc002b3b, 0x0,
48770x3c050fff, 0x3c030001, 0x8c636ef4, 0x34a5ffff,
48780x2403021, 0x3c020001, 0x8c426ef8, 0x3c040800,
48790x651824, 0x31882, 0x641825, 0x451024,
48800x21082, 0x441025, 0xacc20080, 0x32c20180,
48810x10400056, 0xacc30020, 0x8f82005c, 0x3c030080,
48820x431024, 0x1040000d, 0x0, 0x8f820050,
48830xafa20010, 0x8f82005c, 0x240e0001, 0x3c040001,
48840x24845e28, 0xa3ae003f, 0xafa20014, 0x8f870040,
48850x24051900, 0xc002b3b, 0x2c03021, 0x8f820050,
48860x3c030010, 0x431024, 0x10400016, 0x0,
48870x8c020218, 0x30420040, 0x1040000f, 0x24020001,
48880x8f820050, 0x8c030218, 0x240e0001, 0x3c040001,
48890x24845d50, 0xa3ae003f, 0xafa20010, 0xafa30014,
48900x8f870040, 0x24052000, 0xc002b3b, 0x2c03021,
48910x10000004, 0x0, 0x3c010001, 0x370821,
48920xa02240f4, 0x3c040001, 0x24845e34, 0x3c050001,
48930x24a55ac0, 0x3c060001, 0x24c65b38, 0xc53023,
48940x8f420008, 0x27b30030, 0x2603821, 0x27b10034,
48950x34420e00, 0xaf420008, 0xc0017a3, 0xafb10010,
48960x3c040001, 0x24845e4c, 0x3c050001, 0x24a5d8b4,
48970x3c060001, 0x24c6e3c8, 0xc53023, 0x2603821,
48980xaf42010c, 0xc0017a3, 0xafb10010, 0x3c040001,
48990x24845e64, 0x3c050001, 0x24a5e9ac, 0x3c060001,
49000x24c6f0f0, 0xc53023, 0x2603821, 0x3c010001,
49010xac226f04, 0xc0017a3, 0xafb10010, 0x3c040001,
49020x24845e7c, 0x10000027, 0x24052100, 0x3c040001,
49030x24845e84, 0x3c050001, 0x24a59fc8, 0x3c060001,
49040x24c6a104, 0xc53023, 0x27b10030, 0x2203821,
49050x27b30034, 0xc0017a3, 0xafb30010, 0x3c040001,
49060x24845e94, 0x3c050001, 0x24a5cad4, 0x3c060001,
49070x24c6d8ac, 0xc53023, 0x2203821, 0xaf42010c,
49080xc0017a3, 0xafb30010, 0x3c040001, 0x24845ea4,
49090x3c050001, 0x24a5e84c, 0x3c060001, 0x24c6e9a4,
49100xc53023, 0x2203821, 0x3c010001, 0xac226f04,
49110xc0017a3, 0xafb30010, 0x3c040001, 0x24845eb8,
49120x24052150, 0x2c03021, 0x3821, 0x3c010001,
49130xac226f10, 0xafa00010, 0xc002b3b, 0xafa00014,
49140x3c110fff, 0x3c030001, 0x8c636f04, 0x3631ffff,
49150x2409821, 0x3c020001, 0x8c426f10, 0x3c0e0800,
49160x711824, 0x31882, 0x6e1825, 0x511024,
49170x21082, 0x4e1025, 0xae630038, 0xae620078,
49180x8c020218, 0x30420040, 0x14400004, 0x24020001,
49190x3c010001, 0x370821, 0xa02240f4, 0x3c040001,
49200x24845ec4, 0x3c050001, 0x24a5e3d0, 0x3c060001,
49210x24c6e52c, 0xc53023, 0x27be0030, 0x3c03821,
49220x27b50034, 0xc0017a3, 0xafb50010, 0x3c010001,
49230xac226efc, 0x511024, 0x21082, 0x3c0e0800,
49240x4e1025, 0xae620050, 0x32c22000, 0x10400006,
49250x3c03821, 0x3c020000, 0x24425cbc, 0x2221024,
49260x1000000f, 0x21082, 0x3c040001, 0x24845ed8,
49270x3c050001, 0x24a5e534, 0x3c060001, 0x24c6e6e4,
49280xc53023, 0xc0017a3, 0xafb50010, 0x3c010001,
49290xac226f14, 0x511024, 0x21082, 0x3c0e0800,
49300x4e1025, 0xae620048, 0x32c24000, 0x10400005,
49310x27a70030, 0x3c020000, 0x24425cbc, 0x1000000e,
49320x21100, 0x3c040001, 0x24845ef0, 0x3c050001,
49330x24a5e6ec, 0x3c060001, 0x24c6e844, 0xc53023,
49340x27a20034, 0xc0017a3, 0xafa20010, 0x3c010001,
49350xac226f08, 0x21100, 0x21182, 0x3c030800,
49360x431025, 0xae420060, 0x3c040001, 0x24845f08,
49370x3c050001, 0x24a58230, 0x3c060001, 0x24c68650,
49380xc53023, 0x27b10030, 0x2203821, 0x27b30034,
49390xc0017a3, 0xafb30010, 0x3c0e0fff, 0x35ceffff,
49400x3c040001, 0x24845f14, 0x3c050000, 0x24a56468,
49410x3c060000, 0x24c66588, 0xc53023, 0x2203821,
49420x240f021, 0x3c010001, 0xac226edc, 0x4e1024,
49430x21082, 0x3c150800, 0x551025, 0xafae0044,
49440xafc200b8, 0xc0017a3, 0xafb30010, 0x3c040001,
49450x24845f20, 0x3c050000, 0x24a56590, 0x3c060000,
49460x24c66808, 0x8fae0044, 0xc53023, 0x2203821,
49470x3c010001, 0xac226ed0, 0x4e1024, 0x21082,
49480x551025, 0xafc200e8, 0xc0017a3, 0xafb30010,
49490x3c040001, 0x24845f38, 0x3c050000, 0x24a56810,
49500x3c060000, 0x24c66940, 0x8fae0044, 0xc53023,
49510x2203821, 0x3c010001, 0xac226ec8, 0x4e1024,
49520x21082, 0x551025, 0xafc200c0, 0xc0017a3,
49530xafb30010, 0x3c040001, 0x24845f50, 0x3c050001,
49540x24a5fad0, 0x3c060001, 0x24c6fba8, 0x8fae0044,
49550xc53023, 0x2203821, 0x3c010001, 0xac226ed4,
49560x4e1024, 0x21082, 0x551025, 0xafc200c8,
49570xc0017a3, 0xafb30010, 0x3c040001, 0x24845f5c,
49580x3c050001, 0x24a5c93c, 0x3c060001, 0x24c6ca20,
49590xc53023, 0x2203821, 0xaf420110, 0xc0017a3,
49600xafb30010, 0x3c040001, 0x24845f6c, 0x3c050001,
49610x24a5c910, 0x3c060001, 0x24c6c934, 0xc53023,
49620x2203821, 0xaf420124, 0xc0017a3, 0xafb30010,
49630x3c040001, 0x24845f7c, 0x3c050001, 0x24a55a80,
49640x3c060001, 0x24c65aac, 0xc53023, 0x2203821,
49650xaf420120, 0xaf420114, 0xc0017a3, 0xafb30010,
49660x3c040001, 0x24845f88, 0x3c050001, 0x24a5f298,
49670x3c060001, 0x24c6f6b4, 0xc53023, 0x2203821,
49680xaf420118, 0xc0017a3, 0xafb30010, 0x8fae0044,
49690x3c010001, 0xac226f18, 0x4e1024, 0x21082,
49700x551025, 0xc003fc3, 0xafc200d0, 0xc003c40,
49710x0, 0xc0027a8, 0x0, 0xac000228,
49720xac00022c, 0x96e20450, 0x2442ffff, 0xaf420038,
49730x96e20460, 0xaf420080, 0x32c24000, 0x14400003,
49740x0, 0x96e20480, 0xaf420084, 0x96e70490,
49750x50e00001, 0x24070800, 0x24e2ffff, 0xaf420088,
49760xaf42007c, 0x24020800, 0x10e2000f, 0x32c24000,
49770x10400003, 0x24020400, 0x10e2000b, 0x0,
49780x240e0001, 0x3c040001, 0x24845f98, 0xa3ae003f,
49790x96e60490, 0x24052170, 0x2c03821, 0xafa00010,
49800xc002b3b, 0xafa00014, 0x8f430138, 0x8f440138,
49810x24020001, 0xa34205c2, 0xaf430094, 0xaf440098,
49820xafa00010, 0xafa00014, 0x8f460080, 0x8f470084,
49830x3c040001, 0x24845fa4, 0xc002b3b, 0x24052200,
49840xc0024a4, 0x3c110800, 0x3c1433d8, 0x3694cb58,
49850x3c020800, 0x34420080, 0x3c040001, 0x24845fb0,
49860x3c050000, 0x24a55d00, 0x3c060000, 0x24c65d1c,
49870xc53023, 0x27a70030, 0xaf820060, 0x2402ffff,
49880xaf820064, 0x27a20034, 0xc0017a3, 0xafa20010,
49890x3c010001, 0xac226eb8, 0x21100, 0x21182,
49900x511025, 0xc0018fc, 0xae420000, 0x8f820240,
49910x3c030001, 0x431025, 0xaf820240, 0x3c020000,
49920x24424034, 0xaf820244, 0xaf800240, 0x8f820060,
49930x511024, 0x14400005, 0x3c030800, 0x8f820060,
49940x431024, 0x1040fffd, 0x0, 0xc003c4d,
49950x8821, 0x3c020100, 0xafa20020, 0x8f530018,
49960x240200ff, 0x56620001, 0x26710001, 0x8c020228,
49970x1622000e, 0x1330c0, 0x8f42033c, 0x24420001,
49980xaf42033c, 0x8f42033c, 0x8c020228, 0x3c040001,
49990x24845c24, 0x3c050009, 0xafa00014, 0xafa20010,
50000x8fa60020, 0x1000003f, 0x34a50100, 0xd71021,
50010x8fa30020, 0x8fa40024, 0xac4304c0, 0xac4404c4,
50020xc01821, 0x8f440178, 0x8f45017c, 0x1021,
50030x24070004, 0xafa70010, 0xafb10014, 0x8f48000c,
50040x24c604c0, 0x2e63021, 0xafa80018, 0x8f48010c,
50050x24070008, 0xa32821, 0xa3482b, 0x822021,
50060x100f809, 0x892021, 0x1440000b, 0x24070008,
50070x8f820120, 0xafa20010, 0x8f820124, 0x3c040001,
50080x24845c2c, 0x3c050009, 0xafa20014, 0x8fa60020,
50090x1000001c, 0x34a50200, 0x8f440160, 0x8f450164,
50100x8f43000c, 0xaf510018, 0x8f860120, 0x24020010,
50110xafa20010, 0xafb10014, 0xafa30018, 0x8f42010c,
50120x40f809, 0x24c6001c, 0x14400010, 0x0,
50130x8f420340, 0x24420001, 0xaf420340, 0x8f420340,
50140x8f820120, 0xafa20010, 0x8f820124, 0x3c040001,
50150x24845c34, 0x3c050009, 0xafa20014, 0x8fa60020,
50160x34a50300, 0xc002b3b, 0x2603821, 0x8f4202e4,
50170x24420001, 0xaf4202e4, 0x8f4202e4, 0x93a2003f,
50180x10400069, 0x3c020700, 0x34423000, 0xafa20028,
50190x8f530018, 0x240200ff, 0x12620002, 0x8821,
50200x26710001, 0x8c020228, 0x1622000e, 0x1330c0,
50210x8f42033c, 0x24420001, 0xaf42033c, 0x8f42033c,
50220x8c020228, 0x3c040001, 0x24845c24, 0x3c050009,
50230xafa00014, 0xafa20010, 0x8fa60028, 0x1000003f,
50240x34a50100, 0xd71021, 0x8fa30028, 0x8fa4002c,
50250xac4304c0, 0xac4404c4, 0xc01821, 0x8f440178,
50260x8f45017c, 0x1021, 0x24070004, 0xafa70010,
50270xafb10014, 0x8f48000c, 0x24c604c0, 0x2e63021,
50280xafa80018, 0x8f48010c, 0x24070008, 0xa32821,
50290xa3482b, 0x822021, 0x100f809, 0x892021,
50300x1440000b, 0x24070008, 0x8f820120, 0xafa20010,
50310x8f820124, 0x3c040001, 0x24845c2c, 0x3c050009,
50320xafa20014, 0x8fa60028, 0x1000001c, 0x34a50200,
50330x8f440160, 0x8f450164, 0x8f43000c, 0xaf510018,
50340x8f860120, 0x24020010, 0xafa20010, 0xafb10014,
50350xafa30018, 0x8f42010c, 0x40f809, 0x24c6001c,
50360x14400010, 0x0, 0x8f420340, 0x24420001,
50370xaf420340, 0x8f420340, 0x8f820120, 0xafa20010,
50380x8f820124, 0x3c040001, 0x24845c34, 0x3c050009,
50390xafa20014, 0x8fa60028, 0x34a50300, 0xc002b3b,
50400x2603821, 0x8f4202f0, 0x24420001, 0xaf4202f0,
50410x8f4202f0, 0x3c040001, 0x24845fc0, 0xafa00010,
50420xafa00014, 0x8fa60028, 0x24052300, 0xc002b3b,
50430x3821, 0x10000004, 0x0, 0x8c020264,
50440x10400005, 0x0, 0x8f8200a0, 0x30420004,
50450x1440fffa, 0x0, 0x8f820044, 0x34420004,
50460xaf820044, 0x8f420308, 0x24420001, 0xaf420308,
50470x8f420308, 0x8f8200d8, 0x8f8300d4, 0x431023,
50480x2442ff80, 0xaf420090, 0x8f420090, 0x2842ff81,
50490x10400006, 0x24020001, 0x8f420090, 0x8f430144,
50500x431021, 0xaf420090, 0x24020001, 0xaf42008c,
50510x32c20008, 0x10400006, 0x0, 0x8f820214,
50520x3c038100, 0x3042ffff, 0x431025, 0xaf820214,
50530x3c030001, 0x8c636d94, 0x30620002, 0x10400009,
50540x30620001, 0x3c040001, 0x24845fcc, 0x3c050000,
50550x24a56d50, 0x3c060000, 0x24c671c8, 0x10000012,
50560xc53023, 0x10400009, 0x0, 0x3c040001,
50570x24845fdc, 0x3c050000, 0x24a571d0, 0x3c060000,
50580x24c67678, 0x10000008, 0xc53023, 0x3c040001,
50590x24845fec, 0x3c050000, 0x24a56948, 0x3c060000,
50600x24c66d48, 0xc53023, 0x27a70030, 0x27a20034,
50610xc0017a3, 0xafa20010, 0x3c010001, 0xac226ecc,
50620x3c020001, 0x8c426ecc, 0x3c030800, 0x21100,
50630x21182, 0x431025, 0xae420040, 0x8f8200a0,
50640xafa20010, 0x8f8200b0, 0xafa20014, 0x8f86005c,
50650x8f87011c, 0x3c040001, 0x24845ffc, 0x3c010001,
50660xac366ea4, 0x3c010001, 0xac206e94, 0x3c010001,
50670xac3c6e8c, 0x3c010001, 0xac3b6ebc, 0x3c010001,
50680xac376ec0, 0x3c010001, 0xac3a6ea0, 0xc002b3b,
50690x24052400, 0x8f820200, 0xafa20010, 0x8f820220,
50700xafa20014, 0x8f860044, 0x8f870050, 0x3c040001,
50710x24846008, 0xc002b3b, 0x24052500, 0x8f830060,
50720x74100b, 0x242000a, 0x200f821, 0x0,
50730xd, 0x8fbf0060, 0x8fbe005c, 0x8fb50058,
50740x8fb30054, 0x8fb20050, 0x8fb1004c, 0x8fb00048,
50750x3e00008, 0x27bd0068, 0x27bdffe0, 0x3c040001,
50760x24846014, 0x24052600, 0x3021, 0x3821,
50770xafbf0018, 0xafa00010, 0xc002b3b, 0xafa00014,
50780x8fbf0018, 0x3e00008, 0x27bd0020, 0x3e00008,
50790x0, 0x3e00008, 0x0, 0x0,
50800x0, 0x0, 0x0, 0x0,
50810x3e00008, 0x0, 0x3e00008, 0x0,
50820x27bdfde0, 0x27a50018, 0x3c04dead, 0x3484beef,
50830xafbf0218, 0x8f820150, 0x3c03001f, 0x3463ffff,
50840xafa40018, 0xa22823, 0xa32824, 0x8ca20000,
50850x1044000a, 0x0, 0xafa50010, 0x8ca20000,
50860xafa20014, 0x8f860150, 0x8f870250, 0x3c040001,
50870x2484601c, 0xc002b3b, 0x24052700, 0x8fbf0218,
50880x3e00008, 0x27bd0220, 0x27bdffe0, 0x3c06abba,
50890x34c6babe, 0xafb00018, 0x3c100004, 0x3c07007f,
50900x34e7ffff, 0xafbf001c, 0x102840, 0x8e040000,
50910x8ca30000, 0xaca00000, 0xae060000, 0x8ca20000,
50920xaca30000, 0x10460005, 0xae040000, 0xa08021,
50930xf0102b, 0x1040fff5, 0x102840, 0x3c040001,
50940x24846028, 0x24052800, 0x2003021, 0x3821,
50950xafa00010, 0xc002b3b, 0xafa00014, 0x2001021,
50960x8fbf001c, 0x8fb00018, 0x3e00008, 0x27bd0020,
50970x8c020224, 0x3047003f, 0x10e00010, 0x803021,
50980x2821, 0x24030020, 0xe31024, 0x10400002,
50990x63042, 0xa62821, 0x31842, 0x1460fffb,
51000xe31024, 0x2402f000, 0xa22824, 0x3402ffff,
51010x45102b, 0x14400003, 0x3c020001, 0x10000008,
51020x3c020001, 0x3442ffff, 0x851823, 0x43102b,
51030x14400003, 0xa01021, 0x3c02fffe, 0x821021,
51040x3e00008, 0x0, 0x27bdffd0, 0xafb50028,
51050x8fb50040, 0xafb20020, 0xa09021, 0xafb1001c,
51060x24c60003, 0xafbf002c, 0xafb30024, 0xafb00018,
51070x8ea20000, 0x2403fffc, 0xc38024, 0x50102b,
51080x1440001b, 0xe08821, 0x8e330000, 0xafb00010,
51090x8ea20000, 0xafa20014, 0x8e270000, 0x24053000,
51100xc002b3b, 0x2403021, 0x8e230000, 0x702021,
51110x64102b, 0x10400007, 0x2402821, 0x8ca20000,
51120xac620000, 0x24630004, 0x64102b, 0x1440fffb,
51130x24a50004, 0x8ea20000, 0x501023, 0xaea20000,
51140x8e220000, 0x501021, 0x1000000b, 0xae220000,
51150x2402002d, 0xa0820000, 0xafb00010, 0x8ea20000,
51160x2409821, 0xafa20014, 0x8e270000, 0x24053100,
51170xc002b3b, 0x2603021, 0x2601021, 0x8fbf002c,
51180x8fb50028, 0x8fb30024, 0x8fb20020, 0x8fb1001c,
51190x8fb00018, 0x3e00008, 0x27bd0030, 0x27bdffe8,
51200x3c1cc000, 0x3c05fffe, 0x3c030001, 0x8c636e84,
51210x3c040001, 0x8c846e90, 0x34a5bf08, 0x24021ffc,
51220x3c010001, 0xac226cd0, 0x3c0200c0, 0x3c010001,
51230xac226cd4, 0x3c020020, 0xafbf0010, 0x3c0100c0,
51240xac201ffc, 0x431023, 0x441023, 0x245bb000,
51250x365b821, 0x3c1d0001, 0x8fbd6ccc, 0x3a0f021,
51260x3c0400c0, 0x34840200, 0x3c1a00c0, 0x3c0300c0,
51270x346307c8, 0x24021dfc, 0x3c010001, 0xac226cd0,
51280x24021834, 0x3c010001, 0xac246cd4, 0x3c010001,
51290xac226cd0, 0x3c010001, 0xac236cd4, 0xc00180d,
51300x375a0200, 0x8fbf0010, 0x3e00008, 0x27bd0018,
51310x27bdffc8, 0x3c040001, 0x24846034, 0x24053200,
51320x3c020001, 0x8c426cd0, 0x3c030001, 0x8c636cd4,
51330x3021, 0x3603821, 0xafbf0030, 0xafb3002c,
51340xafb20028, 0xafb10024, 0xafb00020, 0xafa2001c,
51350xafa30018, 0xafb70010, 0xc002b3b, 0xafba0014,
51360xc001916, 0x0, 0x8f820240, 0x34420004,
51370xaf820240, 0x24020001, 0xaf420000, 0x3c020001,
51380x571021, 0x904240f4, 0x10400092, 0x2403fffc,
51390x3c100001, 0x2610ac73, 0x3c120001, 0x2652a84c,
51400x2121023, 0x438024, 0x8fa3001c, 0x3c040001,
51410x24846040, 0x70102b, 0x1440001a, 0x27b30018,
51420x8fb10018, 0x24053000, 0x2403021, 0xafb00010,
51430xafa30014, 0xc002b3b, 0x2203821, 0x8fa30018,
51440x702021, 0x64102b, 0x10400007, 0x2403021,
51450x8cc20000, 0xac620000, 0x24630004, 0x64102b,
51460x1440fffb, 0x24c60004, 0x8fa2001c, 0x501023,
51470xafa2001c, 0x8e620000, 0x501021, 0x1000000a,
51480xae620000, 0x2408821, 0x24053100, 0xafb00010,
51490xafa30014, 0x8fa70018, 0x2203021, 0x2402002d,
51500xc002b3b, 0xa0820000, 0x24070020, 0x8fa3001c,
51510x3c040001, 0x2484605c, 0x24120020, 0x3c010001,
51520xac316eb0, 0x2c620020, 0x1440001d, 0x27b10018,
51530x8fb00018, 0x24053000, 0x3c060001, 0x24c66f50,
51540xafa70010, 0xafa30014, 0xc002b3b, 0x2003821,
51550x8fa30018, 0x3c040001, 0x24846f50, 0x24650020,
51560x65102b, 0x10400007, 0x0, 0x8c820000,
51570xac620000, 0x24630004, 0x65102b, 0x1440fffb,
51580x24840004, 0x8fa2001c, 0x521023, 0xafa2001c,
51590x8e220000, 0x521021, 0x1000000b, 0xae220000,
51600x3c100001, 0x26106f50, 0x24053100, 0xafa70010,
51610xafa30014, 0x8fa70018, 0x2003021, 0x2402002d,
51620xc002b3b, 0xa0820000, 0x24070020, 0x3c040001,
51630x24846070, 0x8fa3001c, 0x24120020, 0x3c010001,
51640xac306ee4, 0x2c620020, 0x1440001d, 0x27b10018,
51650x8fb00018, 0x24053000, 0x3c060001, 0x24c66f70,
51660xafa70010, 0xafa30014, 0xc002b3b, 0x2003821,
51670x8fa30018, 0x3c040001, 0x24846f70, 0x24650020,
51680x65102b, 0x10400007, 0x0, 0x8c820000,
51690xac620000, 0x24630004, 0x65102b, 0x1440fffb,
51700x24840004, 0x8fa2001c, 0x521023, 0xafa2001c,
51710x8e220000, 0x521021, 0x1000000b, 0xae220000,
51720x3c100001, 0x26106f70, 0x24053100, 0xafa70010,
51730xafa30014, 0x8fa70018, 0x2003021, 0x2402002d,
51740xc002b3b, 0xa0820000, 0x3c010001, 0x10000031,
51750xac306ee0, 0x3c100001, 0x2610821f, 0x3c120001,
51760x2652809c, 0x2121023, 0x438024, 0x8fa3001c,
51770x3c040001, 0x24846084, 0x70102b, 0x1440001a,
51780x27b30018, 0x8fb10018, 0x24053000, 0x2403021,
51790xafb00010, 0xafa30014, 0xc002b3b, 0x2203821,
51800x8fa30018, 0x702021, 0x64102b, 0x10400007,
51810x2403021, 0x8cc20000, 0xac620000, 0x24630004,
51820x64102b, 0x1440fffb, 0x24c60004, 0x8fa2001c,
51830x501023, 0xafa2001c, 0x8e620000, 0x501021,
51840x1000000a, 0xae620000, 0x2408821, 0x24053100,
51850xafb00010, 0xafa30014, 0x8fa70018, 0x2203021,
51860x2402002d, 0xc002b3b, 0xa0820000, 0x3c010001,
51870xac316eb0, 0x3c030001, 0x8c636eb0, 0x24020400,
51880x60f809, 0xaf820070, 0x8fbf0030, 0x8fb3002c,
51890x8fb20028, 0x8fb10024, 0x8fb00020, 0x3e00008,
51900x27bd0038, 0x0, 0x0, 0x8f820040,
51910x3c03f000, 0x431024, 0x3c036000, 0x14430006,
51920x0, 0x8f820050, 0x2403ff80, 0x431024,
51930x34420055, 0xaf820050, 0x8f820054, 0x244203e8,
51940xaf820058, 0x240201f4, 0xaf4200e0, 0x24020004,
51950xaf4200e8, 0x24020002, 0xaf4001b0, 0xaf4000e4,
51960xaf4200dc, 0xaf4000d8, 0xaf4000d4, 0x3e00008,
51970xaf4000d0, 0x8f820054, 0x24420005, 0x3e00008,
51980xaf820078, 0x27bdffe8, 0xafbf0010, 0x8f820054,
51990x244203e8, 0xaf820058, 0x3c020800, 0x2c21024,
52000x10400004, 0x3c02f7ff, 0x3442ffff, 0x2c2b024,
52010x36940040, 0x3c020001, 0x8c426da8, 0x10400017,
52020x3c020200, 0x3c030001, 0x8c636f1c, 0x10600016,
52030x282a025, 0x3c020001, 0x8c426e44, 0x14400012,
52040x3c020200, 0x3c020001, 0x8c426d94, 0x30420003,
52050x1440000d, 0x3c020200, 0x8f830224, 0x3c020002,
52060x8c428fec, 0x10620008, 0x3c020200, 0xc003daf,
52070x0, 0x10000004, 0x3c020200, 0xc004196,
52080x0, 0x3c020200, 0x2c21024, 0x10400003,
52090x0, 0xc001f4b, 0x0, 0x8f4200d8,
52100x8f4300dc, 0x24420001, 0xaf4200d8, 0x43102b,
52110x14400003, 0x0, 0xaf4000d8, 0x36940080,
52120x8c030238, 0x1060000c, 0x0, 0x8f4201b0,
52130x244203e8, 0xaf4201b0, 0x43102b, 0x14400006,
52140x0, 0x934205c5, 0x14400003, 0x0,
52150xc001da0, 0x0, 0x8fbf0010, 0x3e00008,
52160x27bd0018, 0x3e00008, 0x0, 0x27bdffd8,
52170xafbf0020, 0x8f43002c, 0x8f420038, 0x10620059,
52180x0, 0x3c020001, 0x571021, 0x904240f0,
52190x10400026, 0x24070008, 0x8f440170, 0x8f450174,
52200x8f48000c, 0x8f860120, 0x24020020, 0xafa20010,
52210xafa30014, 0xafa80018, 0x8f42010c, 0x40f809,
52220x24c6001c, 0x14400011, 0x24020001, 0x3c010001,
52230x370821, 0xa02240f0, 0x8f820124, 0xafa20010,
52240x8f820128, 0x3c040001, 0x24846128, 0xafa20014,
52250x8f46002c, 0x8f870120, 0x3c050009, 0xc002b3b,
52260x34a50900, 0x1000005c, 0x0, 0x8f420300,
52270x24420001, 0xaf420300, 0x8f420300, 0x8f42002c,
52280xa34005c1, 0x10000027, 0xaf420038, 0x8f440170,
52290x8f450174, 0x8f43002c, 0x8f48000c, 0x8f860120,
52300x24020080, 0xafa20010, 0xafa30014, 0xafa80018,
52310x8f42010c, 0x40f809, 0x24c6001c, 0x14400011,
52320x24020001, 0x3c010001, 0x370821, 0xa02240f1,
52330x8f820124, 0xafa20010, 0x8f820128, 0x3c040001,
52340x24846134, 0xafa20014, 0x8f46002c, 0x8f870120,
52350x3c050009, 0xc002b3b, 0x34a51100, 0x10000036,
52360x0, 0x8f420300, 0x8f43002c, 0x24420001,
52370xaf420300, 0x8f420300, 0x24020001, 0xa34205c1,
52380xaf430038, 0x3c010001, 0x370821, 0xa02040f1,
52390x3c010001, 0x370821, 0xa02040f0, 0x10000026,
52400xaf400034, 0x934205c1, 0x1040001d, 0x0,
52410xa34005c1, 0x8f820040, 0x30420001, 0x14400008,
52420x2021, 0x8c030104, 0x24020001, 0x50620005,
52430x24040001, 0x8c020264, 0x10400003, 0x801021,
52440x24040001, 0x801021, 0x10400006, 0x0,
52450x8f42030c, 0x24420001, 0xaf42030c, 0x10000008,
52460x8f42030c, 0x8f820044, 0x34420004, 0xaf820044,
52470x8f420308, 0x24420001, 0xaf420308, 0x8f420308,
52480x3c010001, 0x370821, 0xa02040f0, 0x3c010001,
52490x370821, 0xa02040f1, 0x8f420000, 0x10400007,
52500x0, 0xaf80004c, 0x8f82004c, 0x1040fffd,
52510x0, 0x10000005, 0x0, 0xaf800048,
52520x8f820048, 0x1040fffd, 0x0, 0x8f820060,
52530x3c03ff7f, 0x3463ffff, 0x431024, 0xaf820060,
52540x8f420000, 0x10400003, 0x0, 0x10000002,
52550xaf80004c, 0xaf800048, 0x8fbf0020, 0x3e00008,
52560x27bd0028, 0x3e00008, 0x0, 0x27bdffd8,
52570xafbf0020, 0x8f430044, 0x8f42007c, 0x10620029,
52580x24070008, 0x8f440168, 0x8f45016c, 0x8f48000c,
52590x8f860120, 0x24020040, 0xafa20010, 0xafa30014,
52600xafa80018, 0x8f42010c, 0x40f809, 0x24c6001c,
52610x14400011, 0x24020001, 0x3c010001, 0x370821,
52620xa02240f2, 0x8f820124, 0xafa20010, 0x8f820128,
52630x3c040001, 0x2484613c, 0xafa20014, 0x8f460044,
52640x8f870120, 0x3c050009, 0xc002b3b, 0x34a51300,
52650x1000000f, 0x0, 0x8f420304, 0x24420001,
52660xaf420304, 0x8f420304, 0x8f420044, 0xaf42007c,
52670x3c010001, 0x370821, 0xa02040f2, 0x10000004,
52680xaf400078, 0x3c010001, 0x370821, 0xa02040f2,
52690x8f420000, 0x10400007, 0x0, 0xaf80004c,
52700x8f82004c, 0x1040fffd, 0x0, 0x10000005,
52710x0, 0xaf800048, 0x8f820048, 0x1040fffd,
52720x0, 0x8f820060, 0x3c03feff, 0x3463ffff,
52730x431024, 0xaf820060, 0x8f420000, 0x10400003,
52740x0, 0x10000002, 0xaf80004c, 0xaf800048,
52750x8fbf0020, 0x3e00008, 0x27bd0028, 0x3e00008,
52760x0, 0x3c020001, 0x8c426da8, 0x27bdffa8,
52770xafbf0050, 0xafbe004c, 0xafb50048, 0xafb30044,
52780xafb20040, 0xafb1003c, 0xafb00038, 0x104000d5,
52790x8f900044, 0x8f4200d0, 0x24430001, 0x2842000b,
52800x144000e4, 0xaf4300d0, 0x8f420004, 0x30420002,
52810x1440009c, 0xaf4000d0, 0x8f420004, 0x3c030001,
52820x8c636d98, 0x34420002, 0xaf420004, 0x24020001,
52830x14620003, 0x3c020600, 0x10000002, 0x34423000,
52840x34421000, 0xafa20020, 0x8f4a0018, 0xafaa0034,
52850x27aa0020, 0xafaa002c, 0x8faa0034, 0x240200ff,
52860x11420002, 0x1821, 0x25430001, 0x8c020228,
52870x609821, 0x1662000e, 0x3c050009, 0x8f42033c,
52880x24420001, 0xaf42033c, 0x8f42033c, 0x8c020228,
52890x8fa70034, 0x3c040001, 0x2484610c, 0xafa00014,
52900xafa20010, 0x8fa60020, 0x10000070, 0x34a50500,
52910x8faa0034, 0xa38c0, 0xf71021, 0x8fa30020,
52920x8fa40024, 0xac4304c0, 0xac4404c4, 0x8f830054,
52930x8f820054, 0x247103e8, 0x2221023, 0x2c4203e9,
52940x1040001b, 0xa821, 0xe09021, 0x265e04c0,
52950x8f440178, 0x8f45017c, 0x2401821, 0x240a0004,
52960xafaa0010, 0xafb30014, 0x8f48000c, 0x1021,
52970x2fe3021, 0xafa80018, 0x8f48010c, 0x24070008,
52980xa32821, 0xa3482b, 0x822021, 0x100f809,
52990x892021, 0x54400006, 0x24150001, 0x8f820054,
53000x2221023, 0x2c4203e9, 0x1440ffe9, 0x0,
53010x32a200ff, 0x54400018, 0xaf530018, 0x8f420378,
53020x24420001, 0xaf420378, 0x8f420378, 0x8f820120,
53030x8faa002c, 0x8fa70034, 0xafa20010, 0x8f820124,
53040x3c040001, 0x24846118, 0xafa20014, 0x8d460000,
53050x3c050009, 0x10000035, 0x34a50600, 0x8f420308,
53060x24150001, 0x24420001, 0xaf420308, 0x8f420308,
53070x1000001e, 0x32a200ff, 0x8f830054, 0x8f820054,
53080x247103e8, 0x2221023, 0x2c4203e9, 0x10400016,
53090xa821, 0x3c1e0020, 0x24120010, 0x8f42000c,
53100x8f440160, 0x8f450164, 0x8f860120, 0xafb20010,
53110xafb30014, 0x5e1025, 0xafa20018, 0x8f42010c,
53120x24070008, 0x40f809, 0x24c6001c, 0x1440ffe3,
53130x0, 0x8f820054, 0x2221023, 0x2c4203e9,
53140x1440ffee, 0x0, 0x32a200ff, 0x14400011,
53150x3c050009, 0x8f420378, 0x24420001, 0xaf420378,
53160x8f420378, 0x8f820120, 0x8faa002c, 0x8fa70034,
53170xafa20010, 0x8f820124, 0x3c040001, 0x24846120,
53180xafa20014, 0x8d460000, 0x34a50700, 0xc002b3b,
53190x0, 0x8f4202ec, 0x24420001, 0xaf4202ec,
53200x8f4202ec, 0x8f420004, 0x30420001, 0x50400029,
53210x36100040, 0x3c020400, 0x2c21024, 0x10400013,
53220x2404ffdf, 0x8f420250, 0x8f430254, 0x8f4401b4,
53230x14640006, 0x36100040, 0x8f420270, 0x8f430274,
53240x8f4401b8, 0x10640007, 0x2402ffdf, 0x8f420250,
53250x8f430254, 0x8f440270, 0x8f450274, 0x10000012,
53260x3a100020, 0x1000002b, 0x2028024, 0x8f420250,
53270x8f430254, 0x8f4501b4, 0x14650006, 0x2048024,
53280x8f420270, 0x8f430274, 0x8f4401b8, 0x50640021,
53290x36100040, 0x8f420250, 0x8f430254, 0x8f440270,
53300x8f450274, 0x3a100040, 0xaf4301b4, 0x10000019,
53310xaf4501b8, 0x8f4200d4, 0x24430001, 0x10000011,
53320x28420033, 0x8f420004, 0x30420001, 0x10400009,
53330x3c020400, 0x2c21024, 0x10400004, 0x2402ffdf,
53340x2028024, 0x1000000b, 0x36100040, 0x10000009,
53350x36100060, 0x8f4200d4, 0x36100040, 0x24430001,
53360x284201f5, 0x14400003, 0xaf4300d4, 0xaf4000d4,
53370x3a100020, 0xaf900044, 0x2402ff7f, 0x282a024,
53380x8fbf0050, 0x8fbe004c, 0x8fb50048, 0x8fb30044,
53390x8fb20040, 0x8fb1003c, 0x8fb00038, 0x3e00008,
53400x27bd0058, 0x3e00008, 0x0, 0x3c020001,
53410x8c426da8, 0x27bdffb0, 0xafbf0048, 0xafbe0044,
53420xafb50040, 0xafb3003c, 0xafb20038, 0xafb10034,
53430x104000c7, 0xafb00030, 0x8f4200d0, 0x24430001,
53440x2842000b, 0x144000da, 0xaf4300d0, 0x8f420004,
53450x30420002, 0x14400097, 0xaf4000d0, 0x8f420004,
53460x3c030001, 0x8c636d98, 0x34420002, 0xaf420004,
53470x24020001, 0x14620003, 0x3c020600, 0x10000002,
53480x34423000, 0x34421000, 0xafa20020, 0x1821,
53490x8f5e0018, 0x27aa0020, 0x240200ff, 0x13c20002,
53500xafaa002c, 0x27c30001, 0x8c020228, 0x609021,
53510x1642000e, 0x1e38c0, 0x8f42033c, 0x24420001,
53520xaf42033c, 0x8f42033c, 0x8c020228, 0x3c040001,
53530x2484610c, 0x3c050009, 0xafa00014, 0xafa20010,
53540x8fa60020, 0x1000006d, 0x34a50500, 0xf71021,
53550x8fa30020, 0x8fa40024, 0xac4304c0, 0xac4404c4,
53560x8f830054, 0x8f820054, 0x247003e8, 0x2021023,
53570x2c4203e9, 0x1040001b, 0x9821, 0xe08821,
53580x263504c0, 0x8f440178, 0x8f45017c, 0x2201821,
53590x240a0004, 0xafaa0010, 0xafb20014, 0x8f48000c,
53600x1021, 0x2f53021, 0xafa80018, 0x8f48010c,
53610x24070008, 0xa32821, 0xa3482b, 0x822021,
53620x100f809, 0x892021, 0x54400006, 0x24130001,
53630x8f820054, 0x2021023, 0x2c4203e9, 0x1440ffe9,
53640x0, 0x326200ff, 0x54400017, 0xaf520018,
53650x8f420378, 0x24420001, 0xaf420378, 0x8f420378,
53660x8f820120, 0x8faa002c, 0xafa20010, 0x8f820124,
53670x3c040001, 0x24846118, 0x3c050009, 0xafa20014,
53680x8d460000, 0x10000035, 0x34a50600, 0x8f420308,
53690x24130001, 0x24420001, 0xaf420308, 0x8f420308,
53700x1000001e, 0x326200ff, 0x8f830054, 0x8f820054,
53710x247003e8, 0x2021023, 0x2c4203e9, 0x10400016,
53720x9821, 0x3c150020, 0x24110010, 0x8f42000c,
53730x8f440160, 0x8f450164, 0x8f860120, 0xafb10010,
53740xafb20014, 0x551025, 0xafa20018, 0x8f42010c,
53750x24070008, 0x40f809, 0x24c6001c, 0x1440ffe3,
53760x0, 0x8f820054, 0x2021023, 0x2c4203e9,
53770x1440ffee, 0x0, 0x326200ff, 0x14400011,
53780x0, 0x8f420378, 0x24420001, 0xaf420378,
53790x8f420378, 0x8f820120, 0x8faa002c, 0xafa20010,
53800x8f820124, 0x3c040001, 0x24846120, 0x3c050009,
53810xafa20014, 0x8d460000, 0x34a50700, 0xc002b3b,
53820x3c03821, 0x8f4202ec, 0x24420001, 0xaf4202ec,
53830x8f4202ec, 0x8f420004, 0x30420001, 0x10400018,
53840x24040001, 0x8f420250, 0x8f430254, 0x8f4501b4,
53850x3c010001, 0x14650006, 0xa0246cf1, 0x8f420270,
53860x8f430274, 0x8f4401b8, 0x10640021, 0x0,
53870x8f420250, 0x8f430254, 0x3c040001, 0x90846cf0,
53880x8f460270, 0x8f470274, 0x38840001, 0xaf4301b4,
53890xaf4701b8, 0x3c010001, 0x10000025, 0xa0246cf0,
53900x8f4200d4, 0x3c010001, 0xa0206cf0, 0x24430001,
53910x28420033, 0x1440001e, 0xaf4300d4, 0x3c020001,
53920x90426cf1, 0xaf4000d4, 0x10000017, 0x38420001,
53930x8f420004, 0x30420001, 0x10400008, 0x0,
53940xc00565a, 0x2021, 0x3c010001, 0xa0206cf1,
53950x3c010001, 0x1000000e, 0xa0206cf0, 0x8f4200d4,
53960x3c010001, 0xa0206cf0, 0x24430001, 0x284201f5,
53970x14400007, 0xaf4300d4, 0x3c020001, 0x90426cf1,
53980xaf4000d4, 0x421026, 0x3c010001, 0xa0226cf1,
53990x3c030001, 0x8c636d98, 0x24020002, 0x1462000c,
54000x3c030002, 0x3c030001, 0x90636cf1, 0x24020001,
54010x5462001f, 0x2021, 0x3c020001, 0x90426cf0,
54020x1443001b, 0x24040005, 0x10000019, 0x24040006,
54030x3c020002, 0x8c428ff4, 0x431024, 0x1040000b,
54040x24020001, 0x3c030001, 0x90636cf1, 0x54620010,
54050x2021, 0x3c020001, 0x90426cf0, 0x1443000c,
54060x24040003, 0x1000000a, 0x24040004, 0x3c030001,
54070x90636cf1, 0x14620006, 0x2021, 0x3c020001,
54080x90426cf0, 0x24040001, 0x50440001, 0x24040002,
54090xc00565a, 0x0, 0x2402ff7f, 0x282a024,
54100x8fbf0048, 0x8fbe0044, 0x8fb50040, 0x8fb3003c,
54110x8fb20038, 0x8fb10034, 0x8fb00030, 0x3e00008,
54120x27bd0050, 0x3e00008, 0x0, 0x3c020001,
54130x8c426da8, 0x27bdffb0, 0xafbf0048, 0xafbe0044,
54140xafb50040, 0xafb3003c, 0xafb20038, 0xafb10034,
54150x104000de, 0xafb00030, 0x8f4200d0, 0x3c040001,
54160x8c846d98, 0x24430001, 0x2842000b, 0xaf4400e8,
54170x144000fe, 0xaf4300d0, 0x8f420004, 0x30420002,
54180x14400095, 0xaf4000d0, 0x8f420004, 0x34420002,
54190xaf420004, 0x24020001, 0x14820003, 0x3c020600,
54200x10000002, 0x34423000, 0x34421000, 0xafa20020,
54210x1821, 0x8f5e0018, 0x27aa0020, 0x240200ff,
54220x13c20002, 0xafaa002c, 0x27c30001, 0x8c020228,
54230x609021, 0x1642000e, 0x1e38c0, 0x8f42033c,
54240x24420001, 0xaf42033c, 0x8f42033c, 0x8c020228,
54250x3c040001, 0x2484610c, 0x3c050009, 0xafa00014,
54260xafa20010, 0x8fa60020, 0x1000006d, 0x34a50500,
54270xf71021, 0x8fa30020, 0x8fa40024, 0xac4304c0,
54280xac4404c4, 0x8f830054, 0x8f820054, 0x247003e8,
54290x2021023, 0x2c4203e9, 0x1040001b, 0x9821,
54300xe08821, 0x263504c0, 0x8f440178, 0x8f45017c,
54310x2201821, 0x240a0004, 0xafaa0010, 0xafb20014,
54320x8f48000c, 0x1021, 0x2f53021, 0xafa80018,
54330x8f48010c, 0x24070008, 0xa32821, 0xa3482b,
54340x822021, 0x100f809, 0x892021, 0x54400006,
54350x24130001, 0x8f820054, 0x2021023, 0x2c4203e9,
54360x1440ffe9, 0x0, 0x326200ff, 0x54400017,
54370xaf520018, 0x8f420378, 0x24420001, 0xaf420378,
54380x8f420378, 0x8f820120, 0x8faa002c, 0xafa20010,
54390x8f820124, 0x3c040001, 0x24846118, 0x3c050009,
54400xafa20014, 0x8d460000, 0x10000035, 0x34a50600,
54410x8f420308, 0x24130001, 0x24420001, 0xaf420308,
54420x8f420308, 0x1000001e, 0x326200ff, 0x8f830054,
54430x8f820054, 0x247003e8, 0x2021023, 0x2c4203e9,
54440x10400016, 0x9821, 0x3c150020, 0x24110010,
54450x8f42000c, 0x8f440160, 0x8f450164, 0x8f860120,
54460xafb10010, 0xafb20014, 0x551025, 0xafa20018,
54470x8f42010c, 0x24070008, 0x40f809, 0x24c6001c,
54480x1440ffe3, 0x0, 0x8f820054, 0x2021023,
54490x2c4203e9, 0x1440ffee, 0x0, 0x326200ff,
54500x14400011, 0x0, 0x8f420378, 0x24420001,
54510xaf420378, 0x8f420378, 0x8f820120, 0x8faa002c,
54520xafa20010, 0x8f820124, 0x3c040001, 0x24846120,
54530x3c050009, 0xafa20014, 0x8d460000, 0x34a50700,
54540xc002b3b, 0x3c03821, 0x8f4202ec, 0x24420001,
54550xaf4202ec, 0x8f4202ec, 0x8f420004, 0x30420001,
54560x10400033, 0x3c020400, 0x2c21024, 0x10400017,
54570x0, 0x934205c0, 0x8f440250, 0x8f450254,
54580x8f4301b4, 0x34420020, 0x14a30006, 0xa34205c0,
54590x8f420270, 0x8f430274, 0x8f4401b8, 0x10640008,
54600x0, 0x8f420250, 0x8f430254, 0x934405c0,
54610x8f460270, 0x8f470274, 0x10000016, 0x38840040,
54620x934205c0, 0x10000048, 0x304200bf, 0x934205c0,
54630x8f440250, 0x8f450254, 0x8f4301b4, 0x304200bf,
54640x14a30006, 0xa34205c0, 0x8f420270, 0x8f430274,
54650x8f4401b8, 0x1064000b, 0x0, 0x8f420250,
54660x8f430254, 0x934405c0, 0x8f460270, 0x8f470274,
54670x38840020, 0xaf4301b4, 0xaf4701b8, 0x10000033,
54680xa34405c0, 0x934205c0, 0x1000002f, 0x34420020,
54690x934205c0, 0x8f4300d4, 0x34420020, 0xa34205c0,
54700x24620001, 0x10000023, 0x28630033, 0x8f4200e4,
54710x8f4300e0, 0x24420001, 0xaf4200e4, 0x43102a,
54720x14400006, 0x24030001, 0x8f4200e8, 0x14430002,
54730xaf4000e4, 0x24030004, 0xaf4300e8, 0x8f420004,
54740x30420001, 0x1040000d, 0x3c020400, 0x2c21024,
54750x10400007, 0x0, 0x934205c0, 0x34420040,
54760xa34205c0, 0x934205c0, 0x1000000f, 0x304200df,
54770x934205c0, 0x1000000c, 0x34420060, 0x934205c0,
54780x8f4300d4, 0x34420020, 0xa34205c0, 0x24620001,
54790x286300fb, 0x14600005, 0xaf4200d4, 0x934205c0,
54800xaf4000d4, 0x38420040, 0xa34205c0, 0x934205c0,
54810x8f4300e8, 0x3042007f, 0xa34205c0, 0x24020001,
54820x14620005, 0x0, 0x934405c0, 0x42102,
54830x10000003, 0x348400f0, 0x934405c0, 0x3484000f,
54840xc005640, 0x0, 0x2402ff7f, 0x282a024,
54850x8fbf0048, 0x8fbe0044, 0x8fb50040, 0x8fb3003c,
54860x8fb20038, 0x8fb10034, 0x8fb00030, 0x3e00008,
54870x27bd0050, 0x3e00008, 0x0, 0x27bdffb0,
54880x274401c0, 0x26e30028, 0x24650400, 0x65102b,
54890xafbf0048, 0xafbe0044, 0xafb50040, 0xafb3003c,
54900xafb20038, 0xafb10034, 0x10400007, 0xafb00030,
54910x8c820000, 0xac620000, 0x24630004, 0x65102b,
54920x1440fffb, 0x24840004, 0x8c020080, 0xaee20044,
54930x8c0200c0, 0xaee20040, 0x8c020084, 0xaee20030,
54940x8c020084, 0xaee2023c, 0x8c020088, 0xaee20240,
54950x8c02008c, 0xaee20244, 0x8c020090, 0xaee20248,
54960x8c020094, 0xaee2024c, 0x8c020098, 0xaee20250,
54970x8c02009c, 0xaee20254, 0x8c0200a0, 0xaee20258,
54980x8c0200a4, 0xaee2025c, 0x8c0200a8, 0xaee20260,
54990x8c0200ac, 0xaee20264, 0x8c0200b0, 0xaee20268,
55000x8c0200b4, 0xaee2026c, 0x8c0200b8, 0xaee20270,
55010x8c0200bc, 0x24040001, 0xaee20274, 0xaee00034,
55020x41080, 0x571021, 0x8ee30034, 0x8c42023c,
55030x24840001, 0x621821, 0x2c82000f, 0xaee30034,
55040x1440fff8, 0x41080, 0x8c0200cc, 0xaee20048,
55050x8c0200d0, 0xaee2004c, 0x8c0200e0, 0xaee201f8,
55060x8c0200e4, 0xaee201fc, 0x8c0200e8, 0xaee20200,
55070x8c0200ec, 0xaee20204, 0x8c0200f0, 0xaee20208,
55080x8ee400c0, 0x8ee500c4, 0x8c0200fc, 0x45102b,
55090x1040000b, 0x0, 0x8ee200c0, 0x8ee300c4,
55100x24040001, 0x24050000, 0x651821, 0x65302b,
55110x441021, 0x461021, 0xaee200c0, 0xaee300c4,
55120x8c0200fc, 0x8ee400c0, 0x8ee500c4, 0x2408ffff,
55130x24090000, 0x401821, 0x1021, 0x882024,
55140xa92824, 0x822025, 0xa32825, 0xaee400c0,
55150xaee500c4, 0x8ee400d0, 0x8ee500d4, 0x8c0200f4,
55160x45102b, 0x1040000b, 0x0, 0x8ee200d0,
55170x8ee300d4, 0x24040001, 0x24050000, 0x651821,
55180x65302b, 0x441021, 0x461021, 0xaee200d0,
55190xaee300d4, 0x8c0200f4, 0x8ee400d0, 0x8ee500d4,
55200x401821, 0x1021, 0x882024, 0xa92824,
55210x822025, 0xa32825, 0xaee400d0, 0xaee500d4,
55220x8ee400c8, 0x8ee500cc, 0x8c0200f8, 0x45102b,
55230x1040000b, 0x0, 0x8ee200c8, 0x8ee300cc,
55240x24040001, 0x24050000, 0x651821, 0x65302b,
55250x441021, 0x461021, 0xaee200c8, 0xaee300cc,
55260x8c0200f8, 0x8ee400c8, 0x8ee500cc, 0x401821,
55270x1021, 0x882024, 0xa92824, 0x822025,
55280xa32825, 0x24020008, 0xaee400c8, 0xaee500cc,
55290xafa20010, 0xafa00014, 0x8f42000c, 0x8c040208,
55300x8c05020c, 0xafa20018, 0x8f42010c, 0x26e60028,
55310x40f809, 0x24070400, 0x104000f0, 0x3c020400,
55320xafa20020, 0x934205c6, 0x10400089, 0x1821,
55330x8f5e0018, 0x27aa0020, 0x240200ff, 0x13c20002,
55340xafaa002c, 0x27c30001, 0x8c020228, 0x609021,
55350x1642000e, 0x1e38c0, 0x8f42033c, 0x24420001,
55360xaf42033c, 0x8f42033c, 0x8c020228, 0x3c040001,
55370x2484610c, 0x3c050009, 0xafa00014, 0xafa20010,
55380x8fa60020, 0x1000006b, 0x34a50500, 0xf71021,
55390x8fa30020, 0x8fa40024, 0xac4304c0, 0xac4404c4,
55400x8f830054, 0x8f820054, 0x247003e8, 0x2021023,
55410x2c4203e9, 0x1040001b, 0x9821, 0xe08821,
55420x263504c0, 0x8f440178, 0x8f45017c, 0x2201821,
55430x240a0004, 0xafaa0010, 0xafb20014, 0x8f48000c,
55440x1021, 0x2f53021, 0xafa80018, 0x8f48010c,
55450x24070008, 0xa32821, 0xa3482b, 0x822021,
55460x100f809, 0x892021, 0x54400006, 0x24130001,
55470x8f820054, 0x2021023, 0x2c4203e9, 0x1440ffe9,
55480x0, 0x326200ff, 0x54400017, 0xaf520018,
55490x8f420378, 0x24420001, 0xaf420378, 0x8f420378,
55500x8f820120, 0x8faa002c, 0xafa20010, 0x8f820124,
55510x3c040001, 0x24846118, 0x3c050009, 0xafa20014,
55520x8d460000, 0x10000033, 0x34a50600, 0x8f420308,
55530x24130001, 0x24420001, 0xaf420308, 0x8f420308,
55540x1000001c, 0x326200ff, 0x8f830054, 0x8f820054,
55550x247003e8, 0x2021023, 0x2c4203e9, 0x10400014,
55560x9821, 0x24110010, 0x8f42000c, 0x8f440160,
55570x8f450164, 0x8f860120, 0xafb10010, 0xafb20014,
55580xafa20018, 0x8f42010c, 0x24070008, 0x40f809,
55590x24c6001c, 0x1440ffe5, 0x0, 0x8f820054,
55600x2021023, 0x2c4203e9, 0x1440ffef, 0x0,
55610x326200ff, 0x54400012, 0x24020001, 0x8f420378,
55620x24420001, 0xaf420378, 0x8f420378, 0x8f820120,
55630x8faa002c, 0xafa20010, 0x8f820124, 0x3c040001,
55640x24846120, 0x3c050009, 0xafa20014, 0x8d460000,
55650x34a50700, 0xc002b3b, 0x3c03821, 0x1021,
55660x1440005b, 0x24020001, 0x10000065, 0x0,
55670x8f510018, 0x240200ff, 0x12220002, 0x8021,
55680x26300001, 0x8c020228, 0x1602000e, 0x1130c0,
55690x8f42033c, 0x24420001, 0xaf42033c, 0x8f42033c,
55700x8c020228, 0x3c040001, 0x248460f4, 0x3c050009,
55710xafa00014, 0xafa20010, 0x8fa60020, 0x1000003f,
55720x34a50100, 0xd71021, 0x8fa30020, 0x8fa40024,
55730xac4304c0, 0xac4404c4, 0xc01821, 0x8f440178,
55740x8f45017c, 0x1021, 0x24070004, 0xafa70010,
55750xafb00014, 0x8f48000c, 0x24c604c0, 0x2e63021,
55760xafa80018, 0x8f48010c, 0x24070008, 0xa32821,
55770xa3482b, 0x822021, 0x100f809, 0x892021,
55780x1440000b, 0x24070008, 0x8f820120, 0xafa20010,
55790x8f820124, 0x3c040001, 0x248460fc, 0x3c050009,
55800xafa20014, 0x8fa60020, 0x1000001c, 0x34a50200,
55810x8f440160, 0x8f450164, 0x8f43000c, 0xaf500018,
55820x8f860120, 0x24020010, 0xafa20010, 0xafb00014,
55830xafa30018, 0x8f42010c, 0x40f809, 0x24c6001c,
55840x54400011, 0x24020001, 0x8f420340, 0x24420001,
55850xaf420340, 0x8f420340, 0x8f820120, 0xafa20010,
55860x8f820124, 0x3c040001, 0x24846104, 0x3c050009,
55870xafa20014, 0x8fa60020, 0x34a50300, 0xc002b3b,
55880x2203821, 0x1021, 0x1040000d, 0x24020001,
55890x8f4202e8, 0xa34005c6, 0xaf4001b0, 0x24420001,
55900xaf4202e8, 0x8f4202e8, 0x8ee20150, 0x24420001,
55910xaee20150, 0x10000003, 0x8ee20150, 0x24020001,
55920xa34205c6, 0x8fbf0048, 0x8fbe0044, 0x8fb50040,
55930x8fb3003c, 0x8fb20038, 0x8fb10034, 0x8fb00030,
55940x3e00008, 0x27bd0050, 0x27bdffd8, 0xafbf0020,
55950x8f8200b0, 0x30420004, 0x10400068, 0x0,
55960x8f430128, 0x8f820104, 0x14620005, 0x0,
55970x8f430130, 0x8f8200b4, 0x10620006, 0x0,
55980x8f820104, 0xaf420128, 0x8f8200b4, 0x1000005b,
55990xaf420130, 0x8f8200b0, 0x3c030080, 0x431024,
56000x1040000d, 0x0, 0x8f82011c, 0x34420002,
56010xaf82011c, 0x8f8200b0, 0x2403fffb, 0x431024,
56020xaf8200b0, 0x8f82011c, 0x2403fffd, 0x431024,
56030x1000004a, 0xaf82011c, 0x8f430128, 0x8f820104,
56040x14620005, 0x0, 0x8f430130, 0x8f8200b4,
56050x10620010, 0x0, 0x8f820104, 0xaf420128,
56060x8f8200b4, 0x8f430128, 0xaf420130, 0xafa30010,
56070x8f420130, 0x3c040001, 0x24846144, 0xafa20014,
56080x8f86011c, 0x8f8700b0, 0x3c050005, 0x10000031,
56090x34a50900, 0x8f420128, 0xafa20010, 0x8f420130,
56100x3c040001, 0x24846150, 0xafa20014, 0x8f86011c,
56110x8f8700b0, 0x3c050005, 0xc002b3b, 0x34a51000,
56120x8f82011c, 0x34420002, 0xaf82011c, 0x8f830104,
56130x8f8200b0, 0x34420001, 0xaf8200b0, 0x24020008,
56140xaf830104, 0xafa20010, 0xafa00014, 0x8f42000c,
56150x8c040208, 0x8c05020c, 0xafa20018, 0x8f42010c,
56160x26e60028, 0x40f809, 0x24070400, 0x8f82011c,
56170x2403fffd, 0x431024, 0xaf82011c, 0x8ee201dc,
56180x24420001, 0xaee201dc, 0x8ee201dc, 0x8f420128,
56190xafa20010, 0x8f420130, 0x3c040001, 0x2484615c,
56200xafa20014, 0x8f86011c, 0x8f8700b0, 0x3c050005,
56210x34a51100, 0xc002b3b, 0x0, 0x8f8200a0,
56220x30420004, 0x10400069, 0x0, 0x8f43012c,
56230x8f820124, 0x14620005, 0x0, 0x8f430134,
56240x8f8200a4, 0x10620006, 0x0, 0x8f820124,
56250xaf42012c, 0x8f8200a4, 0x1000005c, 0xaf420134,
56260x8f8200a0, 0x3c030080, 0x431024, 0x1040000d,
56270x0, 0x8f82011c, 0x34420002, 0xaf82011c,
56280x8f8200a0, 0x2403fffb, 0x431024, 0xaf8200a0,
56290x8f82011c, 0x2403fffd, 0x431024, 0x1000004b,
56300xaf82011c, 0x8f43012c, 0x8f820124, 0x14620005,
56310x0, 0x8f430134, 0x8f8200a4, 0x10620010,
56320x0, 0x8f820124, 0xaf42012c, 0x8f8200a4,
56330x8f43012c, 0xaf420134, 0xafa30010, 0x8f420134,
56340x3c040001, 0x24846168, 0xafa20014, 0x8f86011c,
56350x8f8700a0, 0x3c050005, 0x10000032, 0x34a51200,
56360x8f42012c, 0xafa20010, 0x8f420134, 0x3c040001,
56370x24846174, 0xafa20014, 0x8f86011c, 0x8f8700a0,
56380x3c050005, 0xc002b3b, 0x34a51300, 0x8f82011c,
56390x34420002, 0xaf82011c, 0x8f830124, 0x8f8200a0,
56400x34420001, 0xaf8200a0, 0x24020080, 0xaf830124,
56410xafa20010, 0xafa00014, 0x8f420014, 0x8c040208,
56420x8c05020c, 0xafa20018, 0x8f420108, 0x3c060001,
56430x24c66ed8, 0x40f809, 0x24070004, 0x8f82011c,
56440x2403fffd, 0x431024, 0xaf82011c, 0x8ee201dc,
56450x24420001, 0xaee201dc, 0x8ee201dc, 0x8f42012c,
56460xafa20010, 0x8f420134, 0x3c040001, 0x24846180,
56470xafa20014, 0x8f86011c, 0x8f8700a0, 0x3c050005,
56480x34a51400, 0xc002b3b, 0x0, 0x8fbf0020,
56490x3e00008, 0x27bd0028, 0x3c081000, 0x24070001,
56500x3c060080, 0x3c050100, 0x8f820070, 0x481024,
56510x1040fffd, 0x0, 0x8f820054, 0x24420005,
56520xaf820078, 0x8c040234, 0x10800016, 0x1821,
56530x3c020001, 0x571021, 0x8c4240e8, 0x24420005,
56540x3c010001, 0x370821, 0xac2240e8, 0x3c020001,
56550x571021, 0x8c4240e8, 0x44102b, 0x14400009,
56560x0, 0x3c030080, 0x3c010001, 0x370821,
56570xac2040e8, 0x3c010001, 0x370821, 0x1000000b,
56580xa02740f0, 0x3c020001, 0x571021, 0x904240f0,
56590x54400006, 0x661825, 0x3c020001, 0x571021,
56600x904240f1, 0x54400001, 0x661825, 0x8c040230,
56610x10800013, 0x0, 0x3c020001, 0x571021,
56620x8c4240ec, 0x24420005, 0x3c010001, 0x370821,
56630xac2240ec, 0x3c020001, 0x571021, 0x8c4240ec,
56640x44102b, 0x14400006, 0x0, 0x3c010001,
56650x370821, 0xac2040ec, 0x10000006, 0x651825,
56660x3c020001, 0x571021, 0x904240f2, 0x54400001,
56670x651825, 0x1060ffbc, 0x0, 0x8f420000,
56680x10400007, 0x0, 0xaf80004c, 0x8f82004c,
56690x1040fffd, 0x0, 0x10000005, 0x0,
56700xaf800048, 0x8f820048, 0x1040fffd, 0x0,
56710x8f820060, 0x431025, 0xaf820060, 0x8f420000,
56720x10400003, 0x0, 0x1000ffa7, 0xaf80004c,
56730x1000ffa5, 0xaf800048, 0x3e00008, 0x0,
56740x0, 0x0, 0x0, 0x27bdffe0,
56750xafbf0018, 0x8f860064, 0x30c20004, 0x10400025,
56760x24040004, 0x8c020114, 0xaf420020, 0xaf840064,
56770x8f4202fc, 0x24420001, 0xaf4202fc, 0x8f4202fc,
56780x8f820064, 0x30420004, 0x14400005, 0x0,
56790x8c030114, 0x8f420020, 0x1462fff2, 0x0,
56800x8f420000, 0x10400007, 0x8f43003c, 0xaf80004c,
56810x8f82004c, 0x1040fffd, 0x0, 0x10000005,
56820x0, 0xaf800048, 0x8f820048, 0x1040fffd,
56830x0, 0x8f820060, 0x431025, 0xaf820060,
56840x8f420000, 0x10400073, 0x0, 0x1000006f,
56850x0, 0x30c20008, 0x10400020, 0x24040008,
56860x8c02011c, 0xaf420048, 0xaf840064, 0x8f4202a8,
56870x24420001, 0xaf4202a8, 0x8f4202a8, 0x8f820064,
56880x30420008, 0x14400005, 0x0, 0x8c03011c,
56890x8f420048, 0x1462fff2, 0x0, 0x8f420000,
56900x10400007, 0x0, 0xaf80004c, 0x8f82004c,
56910x1040fffd, 0x0, 0x10000005, 0x0,
56920xaf800048, 0x8f820048, 0x1040fffd, 0x0,
56930x8f820060, 0x1000ffd9, 0x34420200, 0x30c20020,
56940x10400023, 0x24040020, 0x8c02012c, 0xaf420068,
56950xaf840064, 0x8f4202d8, 0x24420001, 0xaf4202d8,
56960x8f4202d8, 0x8f820064, 0x30420020, 0x14400005,
56970x32c24000, 0x8c03012c, 0x8f420068, 0x1462fff2,
56980x32c24000, 0x14400002, 0x3c020001, 0x2c2b025,
56990x8f420000, 0x10400007, 0x0, 0xaf80004c,
57000x8f82004c, 0x1040fffd, 0x0, 0x10000005,
57010x0, 0xaf800048, 0x8f820048, 0x1040fffd,
57020x0, 0x8f820060, 0x1000ffb4, 0x34420800,
57030x30c20010, 0x10400029, 0x24040010, 0x8c020124,
57040xaf420058, 0xaf840064, 0x8f4202d4, 0x24420001,
57050xaf4202d4, 0x8f4202d4, 0x8f820064, 0x30420010,
57060x14400005, 0x32c22000, 0x8c030124, 0x8f420058,
57070x1462fff2, 0x32c22000, 0x50400001, 0x36d68000,
57080x8f420000, 0x10400007, 0x0, 0xaf80004c,
57090x8f82004c, 0x1040fffd, 0x0, 0x10000005,
57100x0, 0xaf800048, 0x8f820048, 0x1040fffd,
57110x0, 0x8f820060, 0x34420100, 0xaf820060,
57120x8f420000, 0x10400003, 0x0, 0x1000006c,
57130xaf80004c, 0x1000006a, 0xaf800048, 0x30c20001,
57140x10400004, 0x24020001, 0xaf820064, 0x10000064,
57150x0, 0x30c20002, 0x1440000b, 0x3c050003,
57160x3c040001, 0x24846244, 0x34a50500, 0x3821,
57170xafa00010, 0xc002b3b, 0xafa00014, 0x2402ffc0,
57180x10000057, 0xaf820064, 0x8c05022c, 0x8c02010c,
57190x10a20048, 0x51080, 0x8c460300, 0x24a20001,
57200x3045003f, 0x24020003, 0xac05022c, 0x61e02,
57210x10620005, 0x24020010, 0x1062001d, 0x30c20fff,
57220x10000039, 0x0, 0x8f4302a8, 0x8f440000,
57230x30c20fff, 0xaf420048, 0x24630001, 0xaf4302a8,
57240x10800007, 0x8f4202a8, 0xaf80004c, 0x8f82004c,
57250x1040fffd, 0x0, 0x10000005, 0x0,
57260xaf800048, 0x8f820048, 0x1040fffd, 0x0,
57270x8f820060, 0x34420200, 0xaf820060, 0x8f420000,
57280x1040001f, 0x0, 0x1000001b, 0x0,
57290xaf420058, 0x32c22000, 0x50400001, 0x36d68000,
57300x8f4202d4, 0x8f430000, 0x24420001, 0xaf4202d4,
57310x10600007, 0x8f4202d4, 0xaf80004c, 0x8f82004c,
57320x1040fffd, 0x0, 0x10000005, 0x0,
57330xaf800048, 0x8f820048, 0x1040fffd, 0x0,
57340x8f820060, 0x34420100, 0xaf820060, 0x8f420000,
57350x10400003, 0x0, 0x10000006, 0xaf80004c,
57360x10000004, 0xaf800048, 0xc002196, 0xc02021,
57370x402821, 0x8c02010c, 0x14a20002, 0x24020002,
57380xaf820064, 0x8f820064, 0x30420002, 0x14400004,
57390x0, 0x8c02010c, 0x14a2ffac, 0x0,
57400x8fbf0018, 0x3e00008, 0x27bd0020, 0x3e00008,
57410x0, 0x27bdffa0, 0xafb00040, 0x808021,
57420x101602, 0x2442ffff, 0x304300ff, 0x2c620013,
57430xafbf0058, 0xafbe0054, 0xafb50050, 0xafb3004c,
57440xafb20048, 0xafb10044, 0x104001f3, 0xafa50034,
57450x31080, 0x3c010001, 0x220821, 0x8c226288,
57460x400008, 0x0, 0x101302, 0x30440fff,
57470x24020001, 0x10820005, 0x24020002, 0x1082000c,
57480x2402fffe, 0x10000024, 0x3c050003, 0x8f430004,
57490x3c020001, 0x8c426f04, 0xaf440200, 0xaf440204,
57500x3c040001, 0x8c846e80, 0x10000009, 0x34630001,
57510x8f430004, 0xaf440200, 0xaf440204, 0x3c040001,
57520x8c846e80, 0x621824, 0x3c020001, 0x2442ca28,
57530x21100, 0x21182, 0xaf430004, 0x3c030800,
57540x431025, 0xac820038, 0x8f840054, 0x41442,
57550x41c82, 0x431021, 0x41cc2, 0x431023,
57560x41d02, 0x431021, 0x41d42, 0x431023,
57570x10000009, 0xaf420208, 0x3c040001, 0x24846250,
57580x34a51000, 0x2003021, 0x3821, 0xafa00010,
57590xc002b3b, 0xafa00014, 0x8f4202a0, 0x24420001,
57600xaf4202a0, 0x1000021f, 0x8f4202a0, 0x27b00028,
57610x2002021, 0x24050210, 0xc002bbf, 0x24060008,
57620xc002518, 0x2002021, 0x10000216, 0x0,
57630x8faa0034, 0x27a40028, 0xa1880, 0x25420001,
57640x3042003f, 0xafa20034, 0x8c650300, 0x8faa0034,
57650x21080, 0x8c430300, 0x25420001, 0x3042003f,
57660xafa20034, 0xac02022c, 0xafa50028, 0xc002518,
57670xafa3002c, 0x10000203, 0x0, 0x27b00028,
57680x2002021, 0x24050210, 0xc002bbf, 0x24060008,
57690xc002657, 0x2002021, 0x100001fa, 0x0,
57700x8faa0034, 0x27a40028, 0xa1880, 0x25420001,
57710x3042003f, 0xafa20034, 0x8c650300, 0x8faa0034,
57720x21080, 0x8c430300, 0x25420001, 0x3042003f,
57730xafa20034, 0xac02022c, 0xafa50028, 0xc002657,
57740xafa3002c, 0x100001e7, 0x0, 0x101302,
57750x30430fff, 0x24020001, 0x10620005, 0x24020002,
57760x1062001e, 0x3c020002, 0x10000033, 0x3c050003,
57770x3c030002, 0x2c31024, 0x54400037, 0x2c3b025,
57780x8f820228, 0x3c010001, 0x370821, 0xac2238d8,
57790x8f82022c, 0x3c010001, 0x370821, 0xac2238dc,
57800x8f820230, 0x3c010001, 0x370821, 0xac2238e0,
57810x8f820234, 0x3c010001, 0x370821, 0xac2238e4,
57820x2402ffff, 0xaf820228, 0xaf82022c, 0xaf820230,
57830xaf820234, 0x10000020, 0x2c3b025, 0x2c21024,
57840x10400012, 0x3c02fffd, 0x3c020001, 0x571021,
57850x8c4238d8, 0xaf820228, 0x3c020001, 0x571021,
57860x8c4238dc, 0xaf82022c, 0x3c020001, 0x571021,
57870x8c4238e0, 0xaf820230, 0x3c020001, 0x571021,
57880x8c4238e4, 0xaf820234, 0x3c02fffd, 0x3442ffff,
57890x10000009, 0x2c2b024, 0x3c040001, 0x2484625c,
57900x34a51100, 0x2003021, 0x3821, 0xafa00010,
57910xc002b3b, 0xafa00014, 0x8f4202cc, 0x24420001,
57920xaf4202cc, 0x1000019f, 0x8f4202cc, 0x101302,
57930x30450fff, 0x24020001, 0x10a20005, 0x24020002,
57940x10a2000d, 0x3c0408ff, 0x10000014, 0x3c050003,
57950x3c0208ff, 0x3442ffff, 0x8f830220, 0x3c040004,
57960x2c4b025, 0x621824, 0x34630008, 0xaf830220,
57970x10000012, 0xaf450298, 0x3484fff7, 0x3c03fffb,
57980x8f820220, 0x3463ffff, 0x2c3b024, 0x441024,
57990xaf820220, 0x10000009, 0xaf450298, 0x3c040001,
58000x24846268, 0x34a51200, 0x2003021, 0x3821,
58010xafa00010, 0xc002b3b, 0xafa00014, 0x8f4202bc,
58020x24420001, 0xaf4202bc, 0x10000176, 0x8f4202bc,
58030x27840208, 0x24050200, 0xc002bbf, 0x24060008,
58040x27440224, 0x24050200, 0xc002bbf, 0x24060008,
58050x8f4202c4, 0x24420001, 0xaf4202c4, 0x10000169,
58060x8f4202c4, 0x101302, 0x30430fff, 0x24020001,
58070x10620011, 0x28620002, 0x50400005, 0x24020002,
58080x10600007, 0x0, 0x10000017, 0x0,
58090x1062000f, 0x0, 0x10000013, 0x0,
58100x8c060248, 0x2021, 0xc005104, 0x24050004,
58110x10000007, 0x0, 0x8c060248, 0x2021,
58120xc005104, 0x24050004, 0x10000010, 0x0,
58130x8c06024c, 0x2021, 0xc005104, 0x24050001,
58140x1000000a, 0x0, 0x3c040001, 0x24846274,
58150x3c050003, 0x34a51300, 0x2003021, 0x3821,
58160xafa00010, 0xc002b3b, 0xafa00014, 0x8f4202c0,
58170x24420001, 0xaf4202c0, 0x1000013a, 0x8f4202c0,
58180xc002426, 0x0, 0x10000136, 0x0,
58190x24020001, 0xa34205c5, 0x24100100, 0x8f4401a8,
58200x8f4501ac, 0xafb00010, 0xafa00014, 0x8f420014,
58210xafa20018, 0x8f420108, 0x26e60028, 0x40f809,
58220x24070400, 0x1040fff5, 0x0, 0x10000125,
58230x0, 0x3c03ffff, 0x34637fff, 0x8f420368,
58240x8f440360, 0x2c3b024, 0x1821, 0xaf400058,
58250xaf40005c, 0xaf400060, 0xaf400064, 0x441023,
58260xaf420368, 0x3c020900, 0xaf400360, 0xafa20020,
58270x8f5e0018, 0x27aa0020, 0x240200ff, 0x13c20002,
58280xafaa003c, 0x27c30001, 0x8c020228, 0x609021,
58290x1642000e, 0x1e38c0, 0x8f42033c, 0x24420001,
58300xaf42033c, 0x8f42033c, 0x8c020228, 0x3c040001,
58310x2484620c, 0x3c050009, 0xafa00014, 0xafa20010,
58320x8fa60020, 0x1000006b, 0x34a50500, 0xf71021,
58330x8fa30020, 0x8fa40024, 0xac4304c0, 0xac4404c4,
58340x8f830054, 0x8f820054, 0x247003e8, 0x2021023,
58350x2c4203e9, 0x1040001b, 0x9821, 0xe08821,
58360x263504c0, 0x8f440178, 0x8f45017c, 0x2201821,
58370x240a0004, 0xafaa0010, 0xafb20014, 0x8f48000c,
58380x1021, 0x2f53021, 0xafa80018, 0x8f48010c,
58390x24070008, 0xa32821, 0xa3482b, 0x822021,
58400x100f809, 0x892021, 0x54400006, 0x24130001,
58410x8f820054, 0x2021023, 0x2c4203e9, 0x1440ffe9,
58420x0, 0x326200ff, 0x54400017, 0xaf520018,
58430x8f420378, 0x24420001, 0xaf420378, 0x8f420378,
58440x8f820120, 0x8faa003c, 0xafa20010, 0x8f820124,
58450x3c040001, 0x24846218, 0x3c050009, 0xafa20014,
58460x8d460000, 0x10000033, 0x34a50600, 0x8f420308,
58470x24130001, 0x24420001, 0xaf420308, 0x8f420308,
58480x1000001c, 0x326200ff, 0x8f830054, 0x8f820054,
58490x247003e8, 0x2021023, 0x2c4203e9, 0x10400014,
58500x9821, 0x24110010, 0x8f42000c, 0x8f440160,
58510x8f450164, 0x8f860120, 0xafb10010, 0xafb20014,
58520xafa20018, 0x8f42010c, 0x24070008, 0x40f809,
58530x24c6001c, 0x1440ffe5, 0x0, 0x8f820054,
58540x2021023, 0x2c4203e9, 0x1440ffef, 0x0,
58550x326200ff, 0x14400011, 0x0, 0x8f420378,
58560x24420001, 0xaf420378, 0x8f420378, 0x8f820120,
58570x8faa003c, 0xafa20010, 0x8f820124, 0x3c040001,
58580x24846220, 0x3c050009, 0xafa20014, 0x8d460000,
58590x34a50700, 0xc002b3b, 0x3c03821, 0x8f4202b0,
58600x24420001, 0xaf4202b0, 0x8f4202b0, 0x8f4202f8,
58610x24420001, 0xaf4202f8, 0x1000008a, 0x8f4202f8,
58620x8c02025c, 0x27440224, 0xaf4201f0, 0x8c020260,
58630x24050200, 0x24060008, 0xc002bbf, 0xaf4201f8,
58640x8f820220, 0x30420008, 0x14400002, 0x24020001,
58650x24020002, 0xaf420298, 0x8f4202ac, 0x24420001,
58660xaf4202ac, 0x10000077, 0x8f4202ac, 0x3c0200ff,
58670x3442ffff, 0x2021824, 0x32c20180, 0x14400006,
58680x3402fffb, 0x43102b, 0x14400003, 0x0,
58690x1000006c, 0xaf4300bc, 0x3c040001, 0x24846280,
58700x3c050003, 0x34a51500, 0x2003021, 0x3821,
58710xafa00010, 0xc002b3b, 0xafa00014, 0x3c020700,
58720x34421000, 0x101e02, 0x621825, 0xafa30020,
58730x8f510018, 0x240200ff, 0x12220002, 0x8021,
58740x26300001, 0x8c020228, 0x1602000e, 0x1130c0,
58750x8f42033c, 0x24420001, 0xaf42033c, 0x8f42033c,
58760x8c020228, 0x3c040001, 0x248461f4, 0x3c050009,
58770xafa00014, 0xafa20010, 0x8fa60020, 0x1000003f,
58780x34a50100, 0xd71021, 0x8fa30020, 0x8fa40024,
58790xac4304c0, 0xac4404c4, 0xc01821, 0x8f440178,
58800x8f45017c, 0x1021, 0x24070004, 0xafa70010,
58810xafb00014, 0x8f48000c, 0x24c604c0, 0x2e63021,
58820xafa80018, 0x8f48010c, 0x24070008, 0xa32821,
58830xa3482b, 0x822021, 0x100f809, 0x892021,
58840x1440000b, 0x24070008, 0x8f820120, 0xafa20010,
58850x8f820124, 0x3c040001, 0x248461fc, 0x3c050009,
58860xafa20014, 0x8fa60020, 0x1000001c, 0x34a50200,
58870x8f440160, 0x8f450164, 0x8f43000c, 0xaf500018,
58880x8f860120, 0x24020010, 0xafa20010, 0xafb00014,
58890xafa30018, 0x8f42010c, 0x40f809, 0x24c6001c,
58900x14400010, 0x0, 0x8f420340, 0x24420001,
58910xaf420340, 0x8f420340, 0x8f820120, 0xafa20010,
58920x8f820124, 0x3c040001, 0x24846204, 0x3c050009,
58930xafa20014, 0x8fa60020, 0x34a50300, 0xc002b3b,
58940x2203821, 0x8f4202e0, 0x24420001, 0xaf4202e0,
58950x8f4202e0, 0x8f4202f0, 0x24420001, 0xaf4202f0,
58960x8f4202f0, 0x8fa20034, 0x8fbf0058, 0x8fbe0054,
58970x8fb50050, 0x8fb3004c, 0x8fb20048, 0x8fb10044,
58980x8fb00040, 0x3e00008, 0x27bd0060, 0x27bdfff8,
58990x2408ffff, 0x10a00014, 0x4821, 0x3c0aedb8,
59000x354a8320, 0x90870000, 0x24840001, 0x3021,
59010x1071026, 0x30420001, 0x10400002, 0x81842,
59020x6a1826, 0x604021, 0x24c60001, 0x2cc20008,
59030x1440fff7, 0x73842, 0x25290001, 0x125102b,
59040x1440fff0, 0x0, 0x1001021, 0x3e00008,
59050x27bd0008, 0x27bdffb0, 0xafbf0048, 0xafbe0044,
59060xafb50040, 0xafb3003c, 0xafb20038, 0xafb10034,
59070xafb00030, 0x8f870220, 0xafa70024, 0x8f870200,
59080xafa7002c, 0x8f820220, 0x3c0308ff, 0x3463ffff,
59090x431024, 0x34420004, 0xaf820220, 0x8f820200,
59100x3c03c0ff, 0x3463ffff, 0x431024, 0x34420004,
59110xaf820200, 0x8f530358, 0x8f55035c, 0x8f5e0360,
59120x8f470364, 0xafa70014, 0x8f470368, 0xafa7001c,
59130x8f4202d0, 0x274401c0, 0x24420001, 0xaf4202d0,
59140x8f5002d0, 0x8f510204, 0x8f520200, 0xc002ba8,
59150x24050400, 0xaf530358, 0xaf55035c, 0xaf5e0360,
59160x8fa70014, 0xaf470364, 0x8fa7001c, 0xaf470368,
59170xaf5002d0, 0xaf510204, 0xaf520200, 0x8c02025c,
59180x27440224, 0xaf4201f0, 0x8c020260, 0x24050200,
59190x24060008, 0xaf4201f8, 0x24020006, 0xc002bbf,
59200xaf4201f4, 0x3c023b9a, 0x3442ca00, 0xaf4201fc,
59210x240203e8, 0x24040002, 0x24030001, 0xaf420294,
59220xaf440290, 0xaf43029c, 0x8f820220, 0x30420008,
59230x10400004, 0x0, 0xaf430298, 0x10000003,
59240x3021, 0xaf440298, 0x3021, 0x3c030001,
59250x661821, 0x90636d00, 0x3461021, 0x24c60001,
59260xa043022c, 0x2cc2000f, 0x1440fff8, 0x3461821,
59270x24c60001, 0x8f820040, 0x24040080, 0x24050080,
59280x21702, 0x24420030, 0xa062022c, 0x3461021,
59290xc002ba8, 0xa040022c, 0x8fa70024, 0x30e20004,
59300x14400006, 0x0, 0x8f820220, 0x3c0308ff,
59310x3463fffb, 0x431024, 0xaf820220, 0x8fa7002c,
59320x30e20004, 0x14400006, 0x0, 0x8f820200,
59330x3c03c0ff, 0x3463fffb, 0x431024, 0xaf820200,
59340x8fbf0048, 0x8fbe0044, 0x8fb50040, 0x8fb3003c,
59350x8fb20038, 0x8fb10034, 0x8fb00030, 0x3e00008,
59360x27bd0050, 0x0, 0x0, 0xaf400104,
59370x24040001, 0x410c0, 0x2e21821, 0x24820001,
59380x3c010001, 0x230821, 0xa42234d0, 0x402021,
59390x2c820080, 0x1440fff8, 0x410c0, 0x24020001,
59400x3c010001, 0x370821, 0xa42038d0, 0xaf420100,
59410xaf800228, 0xaf80022c, 0xaf800230, 0xaf800234,
59420x3e00008, 0x0, 0x27bdffe8, 0xafbf0014,
59430xafb00010, 0x8f420104, 0x28420005, 0x10400026,
59440x808021, 0x3c020001, 0x8f430104, 0x344230d0,
59450x2e22021, 0x318c0, 0x621821, 0x2e31821,
59460x83102b, 0x10400015, 0x1021, 0x96070000,
59470x24840006, 0x24660006, 0x9482fffc, 0x14470009,
59480x2821, 0x9483fffe, 0x96020002, 0x14620006,
59490xa01021, 0x94820000, 0x96030004, 0x431026,
59500x2c450001, 0xa01021, 0x14400009, 0x24840008,
59510x86102b, 0x1440fff0, 0x1021, 0x304200ff,
59520x14400030, 0x24020001, 0x1000002e, 0x1021,
59530x1000fffa, 0x24020001, 0x2002021, 0xc00240c,
59540x24050006, 0x3042007f, 0x218c0, 0x2e31021,
59550x3c010001, 0x220821, 0x942230d0, 0x1040fff2,
59560x2e31021, 0x3c060001, 0xc23021, 0x94c630d0,
59570x10c0ffed, 0x3c080001, 0x350834d2, 0x96070000,
59580x610c0, 0x572021, 0x882021, 0x94820000,
59590x14470009, 0x2821, 0x94830002, 0x96020002,
59600x14620006, 0xa01021, 0x94820004, 0x96030004,
59610x431026, 0x2c450001, 0xa01021, 0x14400007,
59620x610c0, 0x2e21021, 0x3c060001, 0xc23021,
59630x94c634d0, 0x14c0ffeb, 0x610c0, 0x10c0ffd2,
59640x24020001, 0x8fbf0014, 0x8fb00010, 0x3e00008,
59650x27bd0018, 0x3e00008, 0x0, 0x27bdffb0,
59660x801021, 0xafb00030, 0x24500002, 0x2002021,
59670x24050006, 0xafb10034, 0x408821, 0xafbf0048,
59680xafbe0044, 0xafb50040, 0xafb3003c, 0xc00240c,
59690xafb20038, 0x3047007f, 0x710c0, 0x2e21021,
59700x3c050001, 0xa22821, 0x94a530d0, 0x50a0001c,
59710xa03021, 0x3c090001, 0x352934d2, 0x96280002,
59720x510c0, 0x572021, 0x892021, 0x94820000,
59730x14480009, 0x3021, 0x94830002, 0x96020002,
59740x14620006, 0xc01021, 0x94820004, 0x96030004,
59750x431026, 0x2c460001, 0xc01021, 0x14400007,
59760x510c0, 0x2e21021, 0x3c050001, 0xa22821,
59770x94a534d0, 0x14a0ffeb, 0x510c0, 0xa03021,
59780x10c00014, 0x610c0, 0x571821, 0x3c010001,
59790x230821, 0x8c2334d0, 0x571021, 0xafa30010,
59800x3c010001, 0x220821, 0x8c2234d4, 0x3c040001,
59810x24846394, 0xafa20014, 0x8e260000, 0x8e270004,
59820x3c050004, 0xc002b3b, 0x34a50400, 0x10000063,
59830x3c020800, 0x8f450100, 0x10a00006, 0x510c0,
59840x2e21021, 0x3c010001, 0x220821, 0x942234d0,
59850xaf420100, 0xa03021, 0x14c00011, 0x628c0,
59860x710c0, 0x2e21021, 0xafa70010, 0x3c010001,
59870x220821, 0x942230d0, 0x3c040001, 0x248463a0,
59880xafa20014, 0x8e260000, 0x8e270004, 0x3c050004,
59890xc002b3b, 0x34a50500, 0x10000048, 0x3c020800,
59900xb71821, 0x3c020001, 0x96040000, 0x344234d2,
59910x621821, 0xa4640000, 0x8e020002, 0x720c0,
59920xac620002, 0x2e41021, 0x3c030001, 0x621821,
59930x946330d0, 0x2e51021, 0x3c010001, 0x220821,
59940xa42334d0, 0x2e41021, 0x3c010001, 0x220821,
59950xa42630d0, 0x8f420104, 0x24420001, 0x28420080,
59960x1040000f, 0x3c020002, 0x8f420104, 0x3c040001,
59970x348430d2, 0x96030000, 0x210c0, 0x571021,
59980x441021, 0xa4430000, 0x8e030002, 0xac430002,
59990x8f420104, 0x24420001, 0xaf420104, 0x3c020002,
60000x2c21024, 0x10400011, 0x72142, 0x3c030001,
60010x346338d8, 0x24020003, 0x441023, 0x21080,
60020x572021, 0x832021, 0x571021, 0x431021,
60030x30e5001f, 0x8c430000, 0x24020001, 0xa21004,
60040x621825, 0x1000000c, 0xac830000, 0x24020003,
60050x441023, 0x21080, 0x5c2821, 0x5c1021,
60060x30e4001f, 0x8c430228, 0x24020001, 0x821004,
60070x621825, 0xaca30228, 0x3c020800, 0x34421000,
60080x1821, 0xafa20020, 0x8f5e0018, 0x27aa0020,
60090x240200ff, 0x13c20002, 0xafaa002c, 0x27c30001,
60100x8c020228, 0x609021, 0x1642000e, 0x1e38c0,
60110x8f42033c, 0x24420001, 0xaf42033c, 0x8f42033c,
60120x8c020228, 0x3c040001, 0x2484635c, 0x3c050009,
60130xafa00014, 0xafa20010, 0x8fa60020, 0x1000006b,
60140x34a50500, 0xf71021, 0x8fa30020, 0x8fa40024,
60150xac4304c0, 0xac4404c4, 0x8f830054, 0x8f820054,
60160x247003e8, 0x2021023, 0x2c4203e9, 0x1040001b,
60170x9821, 0xe08821, 0x263504c0, 0x8f440178,
60180x8f45017c, 0x2201821, 0x240a0004, 0xafaa0010,
60190xafb20014, 0x8f48000c, 0x1021, 0x2f53021,
60200xafa80018, 0x8f48010c, 0x24070008, 0xa32821,
60210xa3482b, 0x822021, 0x100f809, 0x892021,
60220x54400006, 0x24130001, 0x8f820054, 0x2021023,
60230x2c4203e9, 0x1440ffe9, 0x0, 0x326200ff,
60240x54400017, 0xaf520018, 0x8f420378, 0x24420001,
60250xaf420378, 0x8f420378, 0x8f820120, 0x8faa002c,
60260xafa20010, 0x8f820124, 0x3c040001, 0x24846368,
60270x3c050009, 0xafa20014, 0x8d460000, 0x10000033,
60280x34a50600, 0x8f420308, 0x24130001, 0x24420001,
60290xaf420308, 0x8f420308, 0x1000001c, 0x326200ff,
60300x8f830054, 0x8f820054, 0x247003e8, 0x2021023,
60310x2c4203e9, 0x10400014, 0x9821, 0x24110010,
60320x8f42000c, 0x8f440160, 0x8f450164, 0x8f860120,
60330xafb10010, 0xafb20014, 0xafa20018, 0x8f42010c,
60340x24070008, 0x40f809, 0x24c6001c, 0x1440ffe5,
60350x0, 0x8f820054, 0x2021023, 0x2c4203e9,
60360x1440ffef, 0x0, 0x326200ff, 0x14400011,
60370x0, 0x8f420378, 0x24420001, 0xaf420378,
60380x8f420378, 0x8f820120, 0x8faa002c, 0xafa20010,
60390x8f820124, 0x3c040001, 0x24846370, 0x3c050009,
60400xafa20014, 0x8d460000, 0x34a50700, 0xc002b3b,
60410x3c03821, 0x8f4202b4, 0x24420001, 0xaf4202b4,
60420x8f4202b4, 0x8f4202f4, 0x24420001, 0xaf4202f4,
60430x8f4202f4, 0x8fbf0048, 0x8fbe0044, 0x8fb50040,
60440x8fb3003c, 0x8fb20038, 0x8fb10034, 0x8fb00030,
60450x3e00008, 0x27bd0050, 0x27bdffa0, 0x801021,
60460xafb00040, 0x24500002, 0x2002021, 0x24050006,
60470xafb10044, 0x408821, 0xafbf0058, 0xafbe0054,
60480xafb50050, 0xafb3004c, 0xc00240c, 0xafb20048,
60490x3048007f, 0x810c0, 0x2e21021, 0x3c060001,
60500xc23021, 0x94c630d0, 0x10c0001c, 0x3821,
60510x3c0a0001, 0x354a34d2, 0x96290002, 0x610c0,
60520x572021, 0x8a2021, 0x94820000, 0x14490009,
60530x2821, 0x94830002, 0x96020002, 0x14620006,
60540xa01021, 0x94820004, 0x96030004, 0x431026,
60550x2c450001, 0xa01021, 0x14400008, 0x610c0,
60560xc03821, 0x2e21021, 0x3c060001, 0xc23021,
60570x94c634d0, 0x14c0ffea, 0x610c0, 0x14c00011,
60580xafa70028, 0x810c0, 0x2e21021, 0xafa80010,
60590x3c010001, 0x220821, 0x942230d0, 0x3c040001,
60600x248463ac, 0xafa20014, 0x8e260000, 0x8e270004,
60610x3c050004, 0xc002b3b, 0x34a50900, 0x10000075,
60620x3c020800, 0x10e0000c, 0x610c0, 0x2e21021,
60630x3c030001, 0x621821, 0x946334d0, 0x710c0,
60640x2e21021, 0x3c010001, 0x220821, 0xa42334d0,
60650x1000000b, 0x3c040001, 0x2e21021, 0x3c030001,
60660x621821, 0x946334d0, 0x810c0, 0x2e21021,
60670x3c010001, 0x220821, 0xa42330d0, 0x3c040001,
60680x348430d0, 0x8f430100, 0x610c0, 0x2e21021,
60690x3c010001, 0x220821, 0xa42334d0, 0x8f420104,
60700x2e43821, 0x2821, 0x18400029, 0xaf460100,
60710x24e60006, 0x94c3fffc, 0x96020000, 0x14620009,
60720x2021, 0x94c3fffe, 0x96020002, 0x14620006,
60730x801021, 0x94c20000, 0x96030004, 0x431026,
60740x2c440001, 0x801021, 0x50400014, 0x24a50001,
60750x8f420104, 0x2442ffff, 0xa2102a, 0x1040000b,
60760x24e40004, 0x94820006, 0x8c830008, 0xa482fffe,
60770xac830000, 0x8f420104, 0x24a50001, 0x2442ffff,
60780xa2102a, 0x1440fff7, 0x24840008, 0x8f420104,
60790x2442ffff, 0x10000006, 0xaf420104, 0x8f420104,
60800x24c60008, 0xa2102a, 0x1440ffda, 0x24e70008,
60810x810c0, 0x2e21021, 0x3c010001, 0x220821,
60820x942230d0, 0x14400023, 0x3c020800, 0x3c020002,
60830x2c21024, 0x10400012, 0x82142, 0x3c030001,
60840x346338d8, 0x24020003, 0x441023, 0x21080,
60850x572021, 0x832021, 0x571021, 0x431021,
60860x3105001f, 0x24030001, 0x8c420000, 0xa31804,
60870x31827, 0x431024, 0x1000000d, 0xac820000,
60880x24020003, 0x441023, 0x21080, 0x5c2821,
60890x5c1021, 0x3104001f, 0x24030001, 0x8c420228,
60900x831804, 0x31827, 0x431024, 0xaca20228,
60910x3c020800, 0x34422000, 0x1821, 0xafa20020,
60920x8f5e0018, 0x27ab0020, 0x240200ff, 0x13c20002,
60930xafab0034, 0x27c30001, 0x8c020228, 0x609021,
60940x1642000e, 0x1e38c0, 0x8f42033c, 0x24420001,
60950xaf42033c, 0x8f42033c, 0x8c020228, 0x3c040001,
60960x2484635c, 0x3c050009, 0xafa00014, 0xafa20010,
60970x8fa60020, 0x1000006b, 0x34a50500, 0xf71021,
60980x8fa30020, 0x8fa40024, 0xac4304c0, 0xac4404c4,
60990x8f830054, 0x8f820054, 0x247003e8, 0x2021023,
61000x2c4203e9, 0x1040001b, 0x9821, 0xe08821,
61010x263504c0, 0x8f440178, 0x8f45017c, 0x2201821,
61020x240b0004, 0xafab0010, 0xafb20014, 0x8f48000c,
61030x1021, 0x2f53021, 0xafa80018, 0x8f48010c,
61040x24070008, 0xa32821, 0xa3482b, 0x822021,
61050x100f809, 0x892021, 0x54400006, 0x24130001,
61060x8f820054, 0x2021023, 0x2c4203e9, 0x1440ffe9,
61070x0, 0x326200ff, 0x54400017, 0xaf520018,
61080x8f420378, 0x24420001, 0xaf420378, 0x8f420378,
61090x8f820120, 0x8fab0034, 0xafa20010, 0x8f820124,
61100x3c040001, 0x24846368, 0x3c050009, 0xafa20014,
61110x8d660000, 0x10000033, 0x34a50600, 0x8f420308,
61120x24130001, 0x24420001, 0xaf420308, 0x8f420308,
61130x1000001c, 0x326200ff, 0x8f830054, 0x8f820054,
61140x247003e8, 0x2021023, 0x2c4203e9, 0x10400014,
61150x9821, 0x24110010, 0x8f42000c, 0x8f440160,
61160x8f450164, 0x8f860120, 0xafb10010, 0xafb20014,
61170xafa20018, 0x8f42010c, 0x24070008, 0x40f809,
61180x24c6001c, 0x1440ffe5, 0x0, 0x8f820054,
61190x2021023, 0x2c4203e9, 0x1440ffef, 0x0,
61200x326200ff, 0x14400011, 0x0, 0x8f420378,
61210x24420001, 0xaf420378, 0x8f420378, 0x8f820120,
61220x8fab0034, 0xafa20010, 0x8f820124, 0x3c040001,
61230x24846370, 0x3c050009, 0xafa20014, 0x8d660000,
61240x34a50700, 0xc002b3b, 0x3c03821, 0x8f4202b8,
61250x24420001, 0xaf4202b8, 0x8f4202b8, 0x8f4202f4,
61260x24420001, 0xaf4202f4, 0x8f4202f4, 0x8fbf0058,
61270x8fbe0054, 0x8fb50050, 0x8fb3004c, 0x8fb20048,
61280x8fb10044, 0x8fb00040, 0x3e00008, 0x27bd0060,
61290x0, 0x0, 0x0, 0x27bdffe0,
61300x27644000, 0xafbf0018, 0xc002ba8, 0x24051000,
61310x3c030001, 0x34632cc0, 0x3c040001, 0x34842ec8,
61320x24020020, 0xaf82011c, 0x2e31021, 0xaf800100,
61330xaf800104, 0xaf800108, 0xaf800110, 0xaf800114,
61340xaf800118, 0xaf800120, 0xaf800124, 0xaf800128,
61350xaf800130, 0xaf800134, 0xaf800138, 0xaf4200ec,
61360x2e31021, 0xaf4200f0, 0x2e41021, 0xaf4200f4,
61370x2e41021, 0xaf4200f8, 0x3c020001, 0x571021,
61380x904240f4, 0x1440001c, 0x3c050001, 0x8f82011c,
61390x3c040001, 0x24846470, 0x3c050001, 0x34420001,
61400xaf82011c, 0xafa00010, 0xafa00014, 0x8f86011c,
61410x34a50100, 0xc002b3b, 0x3821, 0x8c020218,
61420x30420040, 0x10400014, 0x0, 0x8f82011c,
61430x3c040001, 0x2484647c, 0x3c050001, 0x34420004,
61440xaf82011c, 0xafa00010, 0xafa00014, 0x8f86011c,
61450x10000007, 0x34a50200, 0x3c040001, 0x24846484,
61460xafa00010, 0xafa00014, 0x8f86011c, 0x34a50300,
61470xc002b3b, 0x3821, 0x8fbf0018, 0x3e00008,
61480x27bd0020, 0x8fa90010, 0x8f83012c, 0x8faa0014,
61490x8fab0018, 0x1060000a, 0x27624fe0, 0x14620002,
61500x24680020, 0x27684800, 0x8f820128, 0x11020004,
61510x0, 0x8f820124, 0x15020007, 0x0,
61520x8f430334, 0x1021, 0x24630001, 0xaf430334,
61530x10000039, 0x8f430334, 0xac640000, 0xac650004,
61540xac660008, 0xa467000e, 0xac690018, 0xac6a001c,
61550xac6b0010, 0xac620014, 0xaf880120, 0x8f4200fc,
61560x8f4400f4, 0x2442ffff, 0xaf4200fc, 0x8c820000,
61570x10490005, 0x3042ff8f, 0x10400019, 0x3122ff8f,
61580x10400018, 0x3c020001, 0x8c830004, 0x2c620010,
61590x10400013, 0x3c020001, 0x24630001, 0xac830004,
61600x8f4300f8, 0x344230c8, 0x2e21021, 0x54620004,
61610x24620008, 0x3c020001, 0x34422ec8, 0x2e21021,
61620x14440015, 0x24020001, 0x8f820128, 0x24420020,
61630xaf820128, 0x8f820128, 0x1000000f, 0x24020001,
61640x3c020001, 0x344230c8, 0x2e21021, 0x54820004,
61650x24820008, 0x3c020001, 0x34422ec8, 0x2e21021,
61660x402021, 0x24020001, 0xaf4400f4, 0xac890000,
61670xac820004, 0x24020001, 0x3e00008, 0x0,
61680x3e00008, 0x0, 0x8fa90010, 0x8f83010c,
61690x8faa0014, 0x8fab0018, 0x1060000a, 0x276247e0,
61700x14620002, 0x24680020, 0x27684000, 0x8f820108,
61710x11020004, 0x0, 0x8f820104, 0x15020007,
61720x0, 0x8f430338, 0x1021, 0x24630001,
61730xaf430338, 0x10000035, 0x8f430338, 0xac640000,
61740xac650004, 0xac660008, 0xa467000e, 0xac690018,
61750xac6a001c, 0xac6b0010, 0xac620014, 0xaf880100,
61760x8f4400ec, 0x8c820000, 0x30420006, 0x10400019,
61770x31220006, 0x10400018, 0x3c020001, 0x8c830004,
61780x2c620010, 0x10400013, 0x3c020001, 0x24630001,
61790xac830004, 0x8f4300f0, 0x34422ec0, 0x2e21021,
61800x54620004, 0x24620008, 0x3c020001, 0x34422cc0,
61810x2e21021, 0x14440015, 0x24020001, 0x8f820108,
61820x24420020, 0xaf820108, 0x8f820108, 0x1000000f,
61830x24020001, 0x3c020001, 0x34422ec0, 0x2e21021,
61840x54820004, 0x24820008, 0x3c020001, 0x34422cc0,
61850x2e21021, 0x402021, 0x24020001, 0xaf4400ec,
61860xac890000, 0xac820004, 0x24020001, 0x3e00008,
61870x0, 0x3e00008, 0x0, 0x27bdffd8,
61880x3c040001, 0x2484648c, 0x3c050001, 0xafbf0024,
61890xafb20020, 0xafb1001c, 0xafb00018, 0x8f900104,
61900x8f9100b0, 0x8f92011c, 0x34a52500, 0x8f820100,
61910x2403021, 0x2203821, 0xafa20010, 0xc002b3b,
61920xafb00014, 0x8e020008, 0xafa20010, 0x8e02000c,
61930x3c040001, 0x24846498, 0xafa20014, 0x8e060000,
61940x8e070004, 0x3c050001, 0xc002b3b, 0x34a52510,
61950x8e020018, 0xafa20010, 0x8e02001c, 0x3c040001,
61960x248464a4, 0xafa20014, 0x8e060010, 0x8e070014,
61970x3c050001, 0xc002b3b, 0x34a52520, 0x3c027f00,
61980x2221024, 0x3c030800, 0x54430016, 0x3c030200,
61990x8f82009c, 0x3042ffff, 0x14400012, 0x3c030200,
62000x3c040001, 0x248464b0, 0x3c050002, 0x34a5f030,
62010x3021, 0x3821, 0x36420002, 0xaf82011c,
62020x36220001, 0xaf8200b0, 0xaf900104, 0xaf92011c,
62030xafa00010, 0xc002b3b, 0xafa00014, 0x10000024,
62040x0, 0x2c31024, 0x1040000d, 0x2231024,
62050x1040000b, 0x36420002, 0xaf82011c, 0x36220001,
62060xaf8200b0, 0xaf900104, 0xaf92011c, 0x8f420330,
62070x24420001, 0xaf420330, 0x10000015, 0x8f420330,
62080x3c040001, 0x248464b8, 0x240202a9, 0xafa20010,
62090xafa00014, 0x8f860144, 0x3c070001, 0x24e764c0,
62100xc002b3b, 0x3405dead, 0x8f82011c, 0x34420002,
62110xaf82011c, 0x8f820220, 0x34420004, 0xaf820220,
62120x8f820140, 0x3c030001, 0x431025, 0xaf820140,
62130x8fbf0024, 0x8fb20020, 0x8fb1001c, 0x8fb00018,
62140x3e00008, 0x27bd0028, 0x27bdffd8, 0x3c040001,
62150x248464e8, 0x3c050001, 0xafbf0024, 0xafb20020,
62160xafb1001c, 0xafb00018, 0x8f900124, 0x8f9100a0,
62170x8f92011c, 0x34a52600, 0x8f820120, 0x2403021,
62180x2203821, 0xafa20010, 0xc002b3b, 0xafb00014,
62190x8e020008, 0xafa20010, 0x8e02000c, 0x3c040001,
62200x248464f4, 0xafa20014, 0x8e060000, 0x8e070004,
62210x3c050001, 0xc002b3b, 0x34a52610, 0x8e020018,
62220xafa20010, 0x8e02001c, 0x3c040001, 0x24846500,
62230xafa20014, 0x8e060010, 0x8e070014, 0x3c050001,
62240xc002b3b, 0x34a52620, 0x3c027f00, 0x2221024,
62250x3c030800, 0x54430016, 0x3c030200, 0x8f8200ac,
62260x3042ffff, 0x14400012, 0x3c030200, 0x3c040001,
62270x2484650c, 0x3c050001, 0x34a5f030, 0x3021,
62280x3821, 0x36420002, 0xaf82011c, 0x36220001,
62290xaf8200a0, 0xaf900124, 0xaf92011c, 0xafa00010,
62300xc002b3b, 0xafa00014, 0x10000024, 0x0,
62310x2c31024, 0x1040000d, 0x2231024, 0x1040000b,
62320x36420002, 0xaf82011c, 0x36220001, 0xaf8200a0,
62330xaf900124, 0xaf92011c, 0x8f42032c, 0x24420001,
62340xaf42032c, 0x10000015, 0x8f42032c, 0x3c040001,
62350x248464b8, 0x240202e2, 0xafa20010, 0xafa00014,
62360x8f860144, 0x3c070001, 0x24e764c0, 0xc002b3b,
62370x3405dead, 0x8f82011c, 0x34420002, 0xaf82011c,
62380x8f820220, 0x34420004, 0xaf820220, 0x8f820140,
62390x3c030001, 0x431025, 0xaf820140, 0x8fbf0024,
62400x8fb20020, 0x8fb1001c, 0x8fb00018, 0x3e00008,
62410x27bd0028, 0x6021, 0x5021, 0x3021,
62420x2821, 0x6821, 0x4821, 0x7821,
62430x7021, 0x8f880124, 0x8f870104, 0x1580002e,
62440x8f8b011c, 0x11a00014, 0x31620800, 0x8f820120,
62450x10460029, 0x0, 0x3c040001, 0x8c846ee4,
62460x8cc20000, 0x8cc30004, 0xac820000, 0xac830004,
62470x8cc20008, 0xac820008, 0x94c2000e, 0xa482000e,
62480x8cc20010, 0x240c0001, 0xac820010, 0x8cc20014,
62490x10000012, 0x24c60020, 0x10400017, 0x0,
62500x3c040001, 0x8c846ee4, 0x8d020000, 0x8d030004,
62510xac820000, 0xac830004, 0x8d020008, 0xac820008,
62520x9502000e, 0xa482000e, 0x8d020010, 0x25060020,
62530xac820010, 0x8d020014, 0x240c0001, 0xc01821,
62540xac820014, 0x27624fe0, 0x43102b, 0x54400001,
62550x27634800, 0x603021, 0x1540002f, 0x31620100,
62560x11200014, 0x31628000, 0x8f820100, 0x1045002a,
62570x31620100, 0x3c040001, 0x8c846ee0, 0x8ca20000,
62580x8ca30004, 0xac820000, 0xac830004, 0x8ca20008,
62590xac820008, 0x94a2000e, 0xa482000e, 0x8ca20010,
62600x240a0001, 0xac820010, 0x8ca20014, 0x10000012,
62610x24a50020, 0x10400018, 0x31620100, 0x3c040001,
62620x8c846ee0, 0x8ce20000, 0x8ce30004, 0xac820000,
62630xac830004, 0x8ce20008, 0xac820008, 0x94e2000e,
62640xa482000e, 0x8ce20010, 0x24e50020, 0xac820010,
62650x8ce20014, 0x240a0001, 0xa01821, 0xac820014,
62660x276247e0, 0x43102b, 0x54400001, 0x27634000,
62670x602821, 0x31620100, 0x5440001d, 0x31621000,
62680x11a00009, 0x31a20800, 0x10400004, 0x25020020,
62690x8f8200a8, 0xa5e20000, 0x25020020, 0xaf820124,
62700x8f880124, 0x6821, 0x11800011, 0x31621000,
62710x3c040001, 0x8c846ee4, 0x8c820000, 0x8c830004,
62720xaf820080, 0xaf830084, 0x8c820008, 0xaf8200a4,
62730x9482000e, 0xaf8200ac, 0x8c820010, 0x6021,
62740xaf8200a0, 0x8c8d0010, 0x8c8f0014, 0x31621000,
62750x1440ff82, 0x0, 0x1120000f, 0x31220800,
62760x10400004, 0x3c020002, 0x8f8200b8, 0xa5c20000,
62770x3c020002, 0x1221024, 0x10400004, 0x24e20020,
62780x8f8200b4, 0xaf8200d4, 0x24e20020, 0xaf820104,
62790x8f870104, 0x4821, 0x1140ff70, 0x0,
62800x3c040001, 0x8c846ee0, 0x8c820000, 0x8c830004,
62810xaf820090, 0xaf830094, 0x8c820008, 0xaf8200b4,
62820x9482000e, 0xaf82009c, 0x8c820010, 0x5021,
62830xaf8200b0, 0x8c890010, 0x1000ff60, 0x8c8e0014,
62840x3e00008, 0x0, 0x6021, 0x5821,
62850x3021, 0x2821, 0x6821, 0x5021,
62860x7821, 0x7021, 0x8f880124, 0x8f870104,
62870x3c180100, 0x1580002e, 0x8f89011c, 0x11a00014,
62880x31220800, 0x8f820120, 0x10460029, 0x0,
62890x3c040001, 0x8c846ee4, 0x8cc20000, 0x8cc30004,
62900xac820000, 0xac830004, 0x8cc20008, 0xac820008,
62910x94c2000e, 0xa482000e, 0x8cc20010, 0x240c0001,
62920xac820010, 0x8cc20014, 0x10000012, 0x24c60020,
62930x10400017, 0x0, 0x3c040001, 0x8c846ee4,
62940x8d020000, 0x8d030004, 0xac820000, 0xac830004,
62950x8d020008, 0xac820008, 0x9502000e, 0xa482000e,
62960x8d020010, 0x25060020, 0xac820010, 0x8d020014,
62970x240c0001, 0xc01821, 0xac820014, 0x27624fe0,
62980x43102b, 0x54400001, 0x27634800, 0x603021,
62990x1560002f, 0x31220100, 0x11400014, 0x31228000,
63000x8f820100, 0x1045002a, 0x31220100, 0x3c040001,
63010x8c846ee0, 0x8ca20000, 0x8ca30004, 0xac820000,
63020xac830004, 0x8ca20008, 0xac820008, 0x94a2000e,
63030xa482000e, 0x8ca20010, 0x240b0001, 0xac820010,
63040x8ca20014, 0x10000012, 0x24a50020, 0x10400018,
63050x31220100, 0x3c040001, 0x8c846ee0, 0x8ce20000,
63060x8ce30004, 0xac820000, 0xac830004, 0x8ce20008,
63070xac820008, 0x94e2000e, 0xa482000e, 0x8ce20010,
63080x24e50020, 0xac820010, 0x8ce20014, 0x240b0001,
63090xa01821, 0xac820014, 0x276247e0, 0x43102b,
63100x54400001, 0x27634000, 0x602821, 0x31220100,
63110x5440001d, 0x31221000, 0x11a00009, 0x31a20800,
63120x10400004, 0x25020020, 0x8f8200a8, 0xa5e20000,
63130x25020020, 0xaf820124, 0x8f880124, 0x6821,
63140x11800011, 0x31221000, 0x3c040001, 0x8c846ee4,
63150x8c820000, 0x8c830004, 0xaf820080, 0xaf830084,
63160x8c820008, 0xaf8200a4, 0x9482000e, 0xaf8200ac,
63170x8c820010, 0x6021, 0xaf8200a0, 0x8c8d0010,
63180x8c8f0014, 0x31221000, 0x14400022, 0x0,
63190x1140000f, 0x31420800, 0x10400004, 0x3c020002,
63200x8f8200b8, 0xa5c20000, 0x3c020002, 0x1421024,
63210x10400004, 0x24e20020, 0x8f8200b4, 0xaf8200d4,
63220x24e20020, 0xaf820104, 0x8f870104, 0x5021,
63230x11600010, 0x0, 0x3c040001, 0x8c846ee0,
63240x8c820000, 0x8c830004, 0xaf820090, 0xaf830094,
63250x8c820008, 0xaf8200b4, 0x9482000e, 0xaf82009c,
63260x8c820010, 0x5821, 0xaf8200b0, 0x8c8a0010,
63270x8c8e0014, 0x8f820070, 0x3c031000, 0x431024,
63280x1040ff5c, 0x0, 0x8f820054, 0x24420005,
63290xaf820078, 0x8c040234, 0x10800016, 0x1821,
63300x3c020001, 0x571021, 0x8c4240e8, 0x24420005,
63310x3c010001, 0x370821, 0xac2240e8, 0x3c020001,
63320x571021, 0x8c4240e8, 0x44102b, 0x14400009,
63330x24020001, 0x3c030080, 0x3c010001, 0x370821,
63340xac2040e8, 0x3c010001, 0x370821, 0x1000000c,
63350xa02240f0, 0x3c020001, 0x571021, 0x904240f0,
63360x14400006, 0x3c020080, 0x3c020001, 0x571021,
63370x904240f1, 0x10400002, 0x3c020080, 0x621825,
63380x8c040230, 0x10800013, 0x0, 0x3c020001,
63390x571021, 0x8c4240ec, 0x24420005, 0x3c010001,
63400x370821, 0xac2240ec, 0x3c020001, 0x571021,
63410x8c4240ec, 0x44102b, 0x14400006, 0x0,
63420x3c010001, 0x370821, 0xac2040ec, 0x10000006,
63430x781825, 0x3c020001, 0x571021, 0x904240f2,
63440x54400001, 0x781825, 0x1060ff1a, 0x0,
63450x8f420000, 0x10400007, 0x0, 0xaf80004c,
63460x8f82004c, 0x1040fffd, 0x0, 0x10000005,
63470x0, 0xaf800048, 0x8f820048, 0x1040fffd,
63480x0, 0x8f820060, 0x431025, 0xaf820060,
63490x8f420000, 0x10400003, 0x0, 0x1000ff05,
63500xaf80004c, 0x1000ff03, 0xaf800048, 0x3e00008,
63510x0, 0x0, 0x0, 0x3c020001,
63520x8c426d28, 0x27bdffe8, 0xafbf0014, 0x14400012,
63530xafb00010, 0x3c100001, 0x26106f90, 0x2002021,
63540xc002ba8, 0x24052000, 0x26021fe0, 0x3c010001,
63550xac226eec, 0x3c010001, 0xac226ee8, 0xac020250,
63560x24022000, 0xac100254, 0xac020258, 0x24020001,
63570x3c010001, 0xac226d28, 0x8fbf0014, 0x8fb00010,
63580x3e00008, 0x27bd0018, 0x3c090001, 0x8d296eec,
63590x8c820000, 0x8fa30010, 0x8fa80014, 0xad220000,
63600x8c820004, 0xad250008, 0xad220004, 0x8f820054,
63610xad260010, 0xad270014, 0xad230018, 0xad28001c,
63620xad22000c, 0x2529ffe0, 0x3c020001, 0x24426f90,
63630x122102b, 0x10400003, 0x0, 0x3c090001,
63640x8d296ee8, 0x3c020001, 0x8c426d10, 0xad220000,
63650x3c020001, 0x8c426d10, 0x3c010001, 0xac296eec,
63660xad220004, 0xac090250, 0x3e00008, 0x0,
63670x27bdffd0, 0xafb00010, 0x3c100001, 0x8e106eec,
63680x3c020001, 0x8c426d10, 0xafb10014, 0x808821,
63690xafbe0024, 0x8fbe0040, 0x8fa40048, 0xafb20018,
63700xa09021, 0xafbf0028, 0xafb50020, 0xafb3001c,
63710xae020000, 0x3c020001, 0x8c426d10, 0xc09821,
63720xe0a821, 0x10800006, 0xae020004, 0x26050008,
63730xc002bb3, 0x24060018, 0x10000005, 0x2610ffe0,
63740x26040008, 0xc002ba8, 0x24050018, 0x2610ffe0,
63750x3c030001, 0x24636f90, 0x203102b, 0x10400003,
63760x0, 0x3c100001, 0x8e106ee8, 0x8e220000,
63770xae020000, 0x8e220004, 0xae120008, 0xae020004,
63780x8f820054, 0xae130010, 0xae150014, 0xae1e0018,
63790x8fa80044, 0xae08001c, 0xae02000c, 0x2610ffe0,
63800x203102b, 0x10400003, 0x0, 0x3c100001,
63810x8e106ee8, 0x3c020001, 0x8c426d10, 0xae020000,
63820x3c020001, 0x8c426d10, 0x3c010001, 0xac306eec,
63830xae020004, 0xac100250, 0x8fbf0028, 0x8fbe0024,
63840x8fb50020, 0x8fb3001c, 0x8fb20018, 0x8fb10014,
63850x8fb00010, 0x3e00008, 0x27bd0030, 0x851821,
63860x83102b, 0x10400006, 0x0, 0xac800000,
63870x24840004, 0x83102b, 0x5440fffd, 0xac800000,
63880x3e00008, 0x0, 0xa61821, 0xa3102b,
63890x10400007, 0x0, 0x8c820000, 0xaca20000,
63900x24a50004, 0xa3102b, 0x1440fffb, 0x24840004,
63910x3e00008, 0x0, 0x861821, 0x83102b,
63920x10400007, 0x0, 0x8ca20000, 0xac820000,
63930x24840004, 0x83102b, 0x1440fffb, 0x24a50004,
63940x3e00008, 0x0, 0x63080, 0x861821,
63950x83102b, 0x10400006, 0x0, 0xac850000,
63960x24840004, 0x83102b, 0x5440fffd, 0xac850000,
63970x3e00008, 0x0, 0x0, 0x26e50028,
63980xa03021, 0x274301c0, 0x8f4d0358, 0x8f47035c,
63990x8f480360, 0x8f490364, 0x8f4a0368, 0x8f4b0204,
64000x8f4c0200, 0x24640400, 0x64102b, 0x10400008,
64010x3c0208ff, 0x8cc20000, 0xac620000, 0x24630004,
64020x64102b, 0x1440fffb, 0x24c60004, 0x3c0208ff,
64030x3442ffff, 0x3c03c0ff, 0xaf4d0358, 0xaf47035c,
64040xaf480360, 0xaf490364, 0xaf4a0368, 0xaf4b0204,
64050xaf4c0200, 0x8f840220, 0x3463ffff, 0x8f860200,
64060x821024, 0x34420004, 0xc31824, 0x34630004,
64070xaf820220, 0xaf830200, 0x8ca20214, 0xac020084,
64080x8ca20218, 0xac020088, 0x8ca2021c, 0xac02008c,
64090x8ca20220, 0xac020090, 0x8ca20224, 0xac020094,
64100x8ca20228, 0xac020098, 0x8ca2022c, 0xac02009c,
64110x8ca20230, 0xac0200a0, 0x8ca20234, 0xac0200a4,
64120x8ca20238, 0xac0200a8, 0x8ca2023c, 0xac0200ac,
64130x8ca20240, 0xac0200b0, 0x8ca20244, 0xac0200b4,
64140x8ca20248, 0xac0200b8, 0x8ca2024c, 0xac0200bc,
64150x8ca2001c, 0xac020080, 0x8ca20018, 0xac0200c0,
64160x8ca20020, 0xac0200cc, 0x8ca20024, 0xac0200d0,
64170x8ca201d0, 0xac0200e0, 0x8ca201d4, 0xac0200e4,
64180x8ca201d8, 0xac0200e8, 0x8ca201dc, 0xac0200ec,
64190x8ca201e0, 0xac0200f0, 0x8ca20098, 0x8ca3009c,
64200xac0300fc, 0x8ca200a8, 0x8ca300ac, 0xac0300f4,
64210x8ca200a0, 0x8ca300a4, 0x30840004, 0xac0300f8,
64220x14800007, 0x30c20004, 0x8f820220, 0x3c0308ff,
64230x3463fffb, 0x431024, 0xaf820220, 0x30c20004,
64240x14400006, 0x0, 0x8f820200, 0x3c03c0ff,
64250x3463fffb, 0x431024, 0xaf820200, 0x8f4202dc,
64260xa34005c5, 0x24420001, 0xaf4202dc, 0x8f4202dc,
64270x3e00008, 0x0, 0x27bdffd8, 0xafbf0024,
64280xafb00020, 0x8f430024, 0x8f420020, 0x10620038,
64290x0, 0x8f430020, 0x8f420024, 0x622023,
64300x4810003, 0x0, 0x8f420040, 0x822021,
64310x8f430030, 0x8f420024, 0x43102b, 0x14400005,
64320x0, 0x8f430040, 0x8f420024, 0x10000005,
64330x621023, 0x8f420030, 0x8f430024, 0x431023,
64340x2442ffff, 0x406021, 0x8c102a, 0x54400001,
64350x806021, 0x8f4a0024, 0x8f490040, 0x8f480024,
64360x8f440180, 0x8f450184, 0x8f460024, 0x8f4b001c,
64370x24070001, 0xafa70010, 0x84100, 0x1001821,
64380x14c5021, 0x2529ffff, 0x1498024, 0xafb00014,
64390x8f470014, 0x1021, 0x63100, 0xafa70018,
64400xa32821, 0xa3382b, 0x822021, 0x872021,
64410x8f420108, 0x1663021, 0x40f809, 0xc3900,
64420x54400001, 0xaf500024, 0x8f430024, 0x8f420020,
64430x14620018, 0x0, 0x8f420000, 0x10400007,
64440x0, 0xaf80004c, 0x8f82004c, 0x1040fffd,
64450x0, 0x10000005, 0x0, 0xaf800048,
64460x8f820048, 0x1040fffd, 0x0, 0x8f820060,
64470x2403ffef, 0x431024, 0xaf820060, 0x8f420000,
64480x10400003, 0x0, 0x10000002, 0xaf80004c,
64490xaf800048, 0x8fbf0024, 0x8fb00020, 0x3e00008,
64500x27bd0028, 0x3e00008, 0x0, 0x27bdffc0,
64510x32c20020, 0xafbf0038, 0xafb30034, 0xafb20030,
64520xafb1002c, 0x10400004, 0xafb00028, 0x8f530028,
64530x10000002, 0x0, 0x8f530020, 0x8f420030,
64540x105300eb, 0x21100, 0x8f43001c, 0x628021,
64550x8e040000, 0x8e050004, 0x96120008, 0x8f420090,
64560x9611000a, 0x3246ffff, 0x46102a, 0x10400017,
64570x0, 0x8f8200d8, 0x8f430098, 0x431023,
64580x2442dcbe, 0xaf420090, 0x8f420090, 0x2842dcbf,
64590x10400005, 0x0, 0x8f420090, 0x8f430144,
64600x431021, 0xaf420090, 0x8f420090, 0x46102a,
64610x10400006, 0x0, 0x8f420348, 0x24420001,
64620xaf420348, 0x100000e1, 0x8f420348, 0x8f8200fc,
64630x14400006, 0x0, 0x8f420344, 0x24420001,
64640xaf420344, 0x100000d9, 0x8f420344, 0x934205c2,
64650x1040000b, 0x32c20008, 0x10400008, 0x32220200,
64660x10400006, 0x3c034000, 0x9602000e, 0xaf4300ac,
64670x21400, 0x10000002, 0xaf4200b0, 0xaf4000ac,
64680x32220004, 0x1040007f, 0x32220800, 0x10400003,
64690x3247ffff, 0x10000002, 0x24020020, 0x24020004,
64700xafa20010, 0x8f420030, 0xafa20014, 0x8f420010,
64710x3c030002, 0x431025, 0xafa20018, 0x8f460098,
64720x8f420108, 0x40f809, 0x0, 0x104000b7,
64730x0, 0x8f42009c, 0x8f430094, 0x2421021,
64740xaf42009c, 0xae03000c, 0x8f4200ac, 0x10400008,
64750x3c034000, 0x8f420094, 0x431025, 0xafa20020,
64760x8f42009c, 0x8f4300b0, 0x10000004, 0x431025,
64770x8f420094, 0xafa20020, 0x8f42009c, 0xafa20024,
64780x8f8200fc, 0x8fa30020, 0x8fa40024, 0xac430000,
64790xac440004, 0x24420008, 0xaf8200f0, 0x8f42009c,
64800x8f440270, 0x8f450274, 0x401821, 0x1021,
64810xa32821, 0xa3302b, 0x822021, 0x862021,
64820x32230060, 0x24020040, 0xaf440270, 0xaf450274,
64830x10620017, 0x2c620041, 0x10400005, 0x24020020,
64840x10620008, 0x24020001, 0x10000026, 0x0,
64850x24020060, 0x10620019, 0x24020001, 0x10000021,
64860x0, 0x8f420278, 0x8f43027c, 0x24630001,
64870x2c640001, 0x441021, 0xaf420278, 0xaf43027c,
64880x8f420278, 0x8f43027c, 0x10000016, 0x24020001,
64890x8f420280, 0x8f430284, 0x24630001, 0x2c640001,
64900x441021, 0xaf420280, 0xaf430284, 0x8f420280,
64910x8f430284, 0x1000000b, 0x24020001, 0x8f420288,
64920x8f43028c, 0x24630001, 0x2c640001, 0x441021,
64930xaf420288, 0xaf43028c, 0x8f420288, 0x8f43028c,
64940x24020001, 0xa34205c2, 0x8f420098, 0x3244ffff,
64950x2406fff8, 0x8f45013c, 0x441021, 0x24420007,
64960x461024, 0x24840007, 0xaf420094, 0x8f420090,
64970x8f430094, 0x862024, 0x441023, 0x65182b,
64980x14600005, 0xaf420090, 0x8f420094, 0x8f430144,
64990x431023, 0xaf420094, 0x8f420094, 0x10000023,
65000xaf40009c, 0x3247ffff, 0x50e00022, 0x32c20020,
65010x14400002, 0x24020010, 0x24020002, 0xafa20010,
65020x8f420030, 0xafa20014, 0x8f420010, 0xafa20018,
65030x8f460098, 0x8f420108, 0x40f809, 0x0,
65040x1040003a, 0x3245ffff, 0x8f420098, 0x8f430090,
65050x8f46013c, 0x451021, 0xaf420098, 0x8f42009c,
65060x8f440098, 0xa34005c2, 0x651823, 0xaf430090,
65070x451021, 0x86202b, 0x14800005, 0xaf42009c,
65080x8f420098, 0x8f430144, 0x431023, 0xaf420098,
65090x32c20020, 0x10400005, 0x0, 0x8f420358,
65100x2442ffff, 0xaf420358, 0x8f420358, 0x8f420030,
65110x8f430040, 0x24420001, 0x2463ffff, 0x431024,
65120xaf420030, 0x8f420030, 0x14530018, 0x0,
65130x8f420000, 0x10400007, 0x0, 0xaf80004c,
65140x8f82004c, 0x1040fffd, 0x0, 0x10000005,
65150x0, 0xaf800048, 0x8f820048, 0x1040fffd,
65160x0, 0x8f820060, 0x2403fff7, 0x431024,
65170xaf820060, 0x8f420000, 0x10400003, 0x0,
65180x10000002, 0xaf80004c, 0xaf800048, 0x8fbf0038,
65190x8fb30034, 0x8fb20030, 0x8fb1002c, 0x8fb00028,
65200x3e00008, 0x27bd0040, 0x3e00008, 0x0,
65210x27bdffd0, 0x32c20020, 0xafbf002c, 0xafb20028,
65220xafb10024, 0x10400004, 0xafb00020, 0x8f520028,
65230x10000002, 0x0, 0x8f520020, 0x8f420030,
65240x105200b5, 0x21100, 0x8f43001c, 0x628021,
65250x8e040000, 0x8e050004, 0x96110008, 0x8f420090,
65260x9607000a, 0x3226ffff, 0x46102a, 0x10400017,
65270x0, 0x8f8200d8, 0x8f430098, 0x431023,
65280x2442dc46, 0xaf420090, 0x8f420090, 0x2842dc47,
65290x10400005, 0x0, 0x8f420090, 0x8f430144,
65300x431021, 0xaf420090, 0x8f420090, 0x46102a,
65310x10400006, 0x0, 0x8f420348, 0x24420001,
65320xaf420348, 0x100000ab, 0x8f420348, 0x8f8600fc,
65330x10c0000c, 0x0, 0x8f8200f4, 0x2403fff8,
65340x431024, 0x461023, 0x218c3, 0x58600001,
65350x24630100, 0x8f42008c, 0x43102b, 0x14400006,
65360x712c2, 0x8f420344, 0x24420001, 0xaf420344,
65370x10000098, 0x8f420344, 0x934305c2, 0x1060000f,
65380x30460001, 0x8f420010, 0x34480400, 0x32c20008,
65390x10400008, 0x30e20200, 0x10400006, 0x3c034000,
65400x9602000e, 0xaf4300ac, 0x21400, 0x10000004,
65410xaf4200b0, 0x10000002, 0xaf4000ac, 0x8f480010,
65420x30e20004, 0x10400045, 0x3227ffff, 0x8f4900ac,
65430x11200005, 0x30c200ff, 0x14400006, 0x24020040,
65440x10000004, 0x24020008, 0x14400002, 0x24020020,
65450x24020004, 0xafa20010, 0x8f430030, 0x11200004,
65460xafa30014, 0x8f4200b0, 0x621025, 0xafa20014,
65470x3c020002, 0x1021025, 0xafa20018, 0x8f460098,
65480x8f420108, 0x40f809, 0x0, 0x10400069,
65490x3224ffff, 0x8f42008c, 0x8f430094, 0x24420001,
65500xaf42008c, 0x24020001, 0xae03000c, 0xa34205c2,
65510x8f420098, 0x2406fff8, 0x8f45013c, 0x441021,
65520x24420007, 0x461024, 0x24840007, 0xaf420094,
65530x8f420090, 0x8f430094, 0x862024, 0x441023,
65540x65182b, 0x14600005, 0xaf420090, 0x8f420094,
65550x8f430144, 0x431023, 0xaf420094, 0x8f430094,
65560x8f420140, 0x43102b, 0x10400009, 0x0,
65570x8f43013c, 0x8f440094, 0x8f420090, 0x8f450138,
65580x641823, 0x431023, 0xaf420090, 0xaf450094,
65590x8f420094, 0x1000001f, 0xaf420098, 0x10e0001d,
65600x30c200ff, 0x14400002, 0x24020010, 0x24020002,
65610xafa20010, 0x8f420030, 0xafa80018, 0xafa20014,
65620x8f460098, 0x8f420108, 0x40f809, 0x0,
65630x10400030, 0x3225ffff, 0x8f420098, 0x8f44013c,
65640x451021, 0xaf420098, 0x8f420090, 0x8f430098,
65650xa34005c2, 0x451023, 0x64182b, 0x14600005,
65660xaf420090, 0x8f420098, 0x8f430144, 0x431023,
65670xaf420098, 0x8f420030, 0x8f430040, 0x24420001,
65680x2463ffff, 0x431024, 0xaf420030, 0x8f420030,
65690x14520018, 0x0, 0x8f420000, 0x10400007,
65700x0, 0xaf80004c, 0x8f82004c, 0x1040fffd,
65710x0, 0x10000005, 0x0, 0xaf800048,
65720x8f820048, 0x1040fffd, 0x0, 0x8f820060,
65730x2403fff7, 0x431024, 0xaf820060, 0x8f420000,
65740x10400003, 0x0, 0x10000002, 0xaf80004c,
65750xaf800048, 0x8fbf002c, 0x8fb20028, 0x8fb10024,
65760x8fb00020, 0x3e00008, 0x27bd0030, 0x3e00008,
65770x0, 0x27bdffd8, 0x3c020001, 0x34422ec0,
65780xafbf0020, 0x8f4300f0, 0x8f840108, 0x2e21021,
65790x54620004, 0x24620008, 0x3c020001, 0x34422cc0,
65800x2e21021, 0x401821, 0xaf4300f0, 0xac600000,
65810x8f4200ec, 0x8c660004, 0x14620004, 0x3c020001,
65820x24820020, 0x1000000f, 0xaf820108, 0x8f4300f0,
65830x34422ec0, 0x2e21021, 0x54620004, 0x24620008,
65840x3c020001, 0x34422cc0, 0x2e21021, 0x401821,
65850x8c620004, 0x21140, 0x821021, 0xaf820108,
65860xac600000, 0x8c850018, 0x30a20036, 0x1040006c,
65870x30a20001, 0x8c82001c, 0x8f430040, 0x8f440034,
65880x24420001, 0x2463ffff, 0x431024, 0x862021,
65890xaf42002c, 0x30a20030, 0x14400006, 0xaf440034,
65900x8f420034, 0x8c03023c, 0x43102b, 0x144000b4,
65910x0, 0x32c20010, 0x10400028, 0x24070008,
65920x8f440170, 0x8f450174, 0x8f43002c, 0x8f48000c,
65930x8f860120, 0x24020080, 0xafa20010, 0xafa30014,
65940xafa80018, 0x8f42010c, 0x40f809, 0x24c6001c,
65950x14400011, 0x24020001, 0x3c010001, 0x370821,
65960xa02240f1, 0x8f820124, 0xafa20010, 0x8f820128,
65970x3c040001, 0x248467c4, 0xafa20014, 0x8f46002c,
65980x8f870120, 0x3c050009, 0xc002b3b, 0x34a51100,
65990x10000036, 0x0, 0x8f420300, 0x8f43002c,
66000x24420001, 0xaf420300, 0x8f420300, 0x24020001,
66010xa34205c1, 0x10000026, 0xaf430038, 0x8f440170,
66020x8f450174, 0x8f43002c, 0x8f48000c, 0x8f860120,
66030x24020020, 0xafa20010, 0xafa30014, 0xafa80018,
66040x8f42010c, 0x40f809, 0x24c6001c, 0x14400011,
66050x24020001, 0x3c010001, 0x370821, 0xa02240f0,
66060x8f820124, 0xafa20010, 0x8f820128, 0x3c040001,
66070x248467b8, 0xafa20014, 0x8f46002c, 0x8f870120,
66080x3c050009, 0xc002b3b, 0x34a50900, 0x1000000f,
66090x0, 0x8f420300, 0x24420001, 0xaf420300,
66100x8f420300, 0x8f42002c, 0xa34005c1, 0xaf420038,
66110x3c010001, 0x370821, 0xa02040f1, 0x3c010001,
66120x370821, 0xa02040f0, 0xaf400034, 0x8f420314,
66130x24420001, 0xaf420314, 0x10000059, 0x8f420314,
66140x10400022, 0x30a27000, 0x8c85001c, 0x8f420028,
66150xa22023, 0x4810003, 0x0, 0x8f420040,
66160x822021, 0x8f420358, 0x8f430000, 0xaf450028,
66170x441021, 0x10600007, 0xaf420358, 0xaf80004c,
66180x8f82004c, 0x1040fffd, 0x0, 0x10000005,
66190x0, 0xaf800048, 0x8f820048, 0x1040fffd,
66200x0, 0x8f820060, 0x34420008, 0xaf820060,
66210x8f420000, 0x10400003, 0x0, 0x10000038,
66220xaf80004c, 0x10000036, 0xaf800048, 0x1040002f,
66230x30a21000, 0x1040000c, 0x30a24000, 0x8c83001c,
66240x8f420050, 0x622023, 0x4820001, 0x24840200,
66250x8f42035c, 0x441021, 0xaf42035c, 0x8f420368,
66260x1000001a, 0xaf430050, 0x1040000c, 0x32c28000,
66270x8c83001c, 0x8f420070, 0x622023, 0x4820001,
66280x24840400, 0x8f420364, 0x441021, 0xaf420364,
66290x8f420368, 0x1000000d, 0xaf430070, 0x1040000e,
66300x3c020800, 0x8c83001c, 0x8f420060, 0x622023,
66310x4820001, 0x24840100, 0x8f420360, 0x441021,
66320xaf420360, 0x8f420368, 0xaf430060, 0x441021,
66330xaf420368, 0x3c020800, 0x2c21024, 0x50400008,
66340x36940040, 0x10000006, 0x0, 0x30a20100,
66350x10400003, 0x0, 0xc002bd8, 0x0,
66360x8fbf0020, 0x3e00008, 0x27bd0028, 0x3e00008,
66370x0, 0x27bdffa8, 0xafbf0050, 0xafbe004c,
66380xafb50048, 0xafb30044, 0xafb20040, 0xafb1003c,
66390xafb00038, 0x8f910108, 0x26220020, 0xaf820108,
66400x8e320018, 0xa821, 0x32420024, 0x104001ba,
66410xf021, 0x8e26001c, 0x8f43001c, 0x61100,
66420x621821, 0x8c70000c, 0x9604000c, 0x962d0016,
66430x9473000a, 0x2c8305dd, 0x38828870, 0x2c420001,
66440x621825, 0x10600015, 0x2821, 0x32c20040,
66450x10400015, 0x24020800, 0x96030014, 0x14620012,
66460x3402aaaa, 0x9603000e, 0x14620007, 0x2021,
66470x96030010, 0x24020300, 0x14620004, 0x801021,
66480x96020012, 0x2c440001, 0x801021, 0x54400006,
66490x24050016, 0x10000004, 0x0, 0x24020800,
66500x50820001, 0x2405000e, 0x934205c3, 0x14400008,
66510x5821, 0x240b0001, 0x32620180, 0xaf4500a8,
66520xaf5000a0, 0x10400002, 0xaf4600a4, 0xa34b05c3,
66530x10a00085, 0x2054021, 0x91020000, 0x3821,
66540x3042000f, 0x25080, 0x32c20002, 0x10400012,
66550x10a1821, 0x32620002, 0x10400010, 0x32c20001,
66560x1002021, 0x94820000, 0x24840002, 0xe23821,
66570x83102b, 0x1440fffb, 0x30e2ffff, 0x71c02,
66580x623821, 0x71c02, 0x30e2ffff, 0x623821,
66590x71027, 0xa502000a, 0x32c20001, 0x1040006a,
66600x32620001, 0x10400068, 0x0, 0x8f4200a8,
66610x10400065, 0x0, 0x8f4200a0, 0x8f4300a8,
66620x431021, 0x904c0009, 0x318900ff, 0x39230006,
66630x3182b, 0x39220011, 0x2102b, 0x621824,
66640x1060000c, 0x3c050006, 0x8f4200a4, 0x3c040001,
66650x248467d4, 0xafa20010, 0x8f4200a0, 0x34a54600,
66660x1203821, 0xc002b3b, 0xafa20014, 0x1000004e,
66670x0, 0x32c20004, 0x14400013, 0x2821,
66680x316200ff, 0x14400004, 0x0, 0x95020002,
66690x1000000d, 0x4a2823, 0x9505000c, 0x9502000e,
66700x95030010, 0xa22821, 0xa32821, 0x95030012,
66710x91040009, 0x95020002, 0xa32821, 0xa42821,
66720x4a1023, 0xa22821, 0x2002021, 0x94820000,
66730x24840002, 0xe23821, 0x88102b, 0x1440fffb,
66740x71c02, 0x30e2ffff, 0x623821, 0x71c02,
66750x30e2ffff, 0x623821, 0x1a52821, 0x51c02,
66760x30a2ffff, 0x622821, 0x51c02, 0x30a2ffff,
66770x622821, 0xa72823, 0x51402, 0xa22821,
66780x30a5ffff, 0x50a00001, 0x3405ffff, 0x316200ff,
66790x14400008, 0x318300ff, 0x8f4300a0, 0x8f4200a8,
66800x624021, 0x91020000, 0x3042000f, 0x25080,
66810x318300ff, 0x24020006, 0x14620003, 0x10a1021,
66820x10000002, 0x24440010, 0x24440006, 0x316200ff,
66830x14400006, 0x0, 0x94820000, 0xa22821,
66840x51c02, 0x30a2ffff, 0x622821, 0x934205c3,
66850x10400003, 0x32620100, 0x50400003, 0xa4850000,
66860x52827, 0xa4850000, 0x9622000e, 0x8f43009c,
66870x621821, 0x32a200ff, 0x10400007, 0xaf43009c,
66880x3c024000, 0x2021025, 0xafa20020, 0x8f42009c,
66890x10000003, 0x5e1025, 0xafb00020, 0x8f42009c,
66900xafa20024, 0x32620080, 0x10400010, 0x32620100,
66910x8f4200b4, 0x24430001, 0x210c0, 0x571021,
66920xaf4300b4, 0x8fa30020, 0x8fa40024, 0x3c010001,
66930x220821, 0xac2338e8, 0x3c010001, 0x220821,
66940xac2438ec, 0x100000a5, 0x32c20020, 0x10400064,
66950x0, 0x8f4200b4, 0x24430001, 0x210c0,
66960x571021, 0xaf4300b4, 0x8fa30020, 0x8fa40024,
66970x3c010001, 0x220821, 0xac2338e8, 0x3c010001,
66980x220821, 0xac2438ec, 0x8f4200b4, 0x10400051,
66990x3821, 0x3c090001, 0x352938e8, 0x3c08001f,
67000x3508ffff, 0x240bffff, 0x340affff, 0x710c0,
67010x571021, 0x491021, 0x8c430000, 0x8c440004,
67020xafa30028, 0xafa4002c, 0x8f8200fc, 0x8fa30028,
67030x8fa4002c, 0xac430000, 0xac440004, 0x24420008,
67040xaf8200f0, 0x8f42008c, 0x2442ffff, 0xaf42008c,
67050x97a2002e, 0x8f440270, 0x8f450274, 0x401821,
67060x1021, 0xa32821, 0xa3302b, 0x822021,
67070x862021, 0xaf440270, 0xaf450274, 0x8fa20028,
67080x481024, 0x90430000, 0x30630001, 0x1460000b,
67090x402021, 0x8f420278, 0x8f43027c, 0x24630001,
67100x2c640001, 0x441021, 0xaf420278, 0xaf43027c,
67110x8f420278, 0x1000001a, 0x8f43027c, 0x8c820000,
67120x144b000e, 0x0, 0x94820004, 0x144a000b,
67130x0, 0x8f420288, 0x8f43028c, 0x24630001,
67140x2c640001, 0x441021, 0xaf420288, 0xaf43028c,
67150x8f420288, 0x1000000a, 0x8f43028c, 0x8f420280,
67160x8f430284, 0x24630001, 0x2c640001, 0x441021,
67170xaf420280, 0xaf430284, 0x8f420280, 0x8f430284,
67180x8f4200b4, 0x24e70001, 0xe2102b, 0x1440ffb8,
67190x710c0, 0xa34005c3, 0x1000003f, 0xaf4000b4,
67200x8f8200fc, 0x8fa30020, 0x8fa40024, 0xac430000,
67210xac440004, 0x24420008, 0xaf8200f0, 0x8f42009c,
67220x8f46008c, 0x8f440270, 0x8f450274, 0x401821,
67230x1021, 0x24c6ffff, 0xaf46008c, 0xa32821,
67240xa3302b, 0x822021, 0x862021, 0xaf440270,
67250xaf450274, 0x92020000, 0x30420001, 0x1440000c,
67260x2402ffff, 0x8f420278, 0x8f43027c, 0x24630001,
67270x2c640001, 0x441021, 0xaf420278, 0xaf43027c,
67280x8f420278, 0x8f43027c, 0x1000001c, 0x32c20020,
67290x8e030000, 0x1462000f, 0x3402ffff, 0x96030004,
67300x1462000c, 0x0, 0x8f420288, 0x8f43028c,
67310x24630001, 0x2c640001, 0x441021, 0xaf420288,
67320xaf43028c, 0x8f420288, 0x8f43028c, 0x1000000b,
67330x32c20020, 0x8f420280, 0x8f430284, 0x24630001,
67340x2c640001, 0x441021, 0xaf420280, 0xaf430284,
67350x8f420280, 0x8f430284, 0x32c20020, 0x10400005,
67360xaf40009c, 0x8f420358, 0x2442ffff, 0xaf420358,
67370x8f420358, 0x8e22001c, 0x8f430040, 0x24420001,
67380x2463ffff, 0x431024, 0xaf42002c, 0x32420060,
67390x14400008, 0x32c20010, 0x8f420034, 0x24420001,
67400xaf420034, 0x8c03023c, 0x43102b, 0x14400102,
67410x32c20010, 0x10400018, 0x24070008, 0x8f440170,
67420x8f450174, 0x8f43002c, 0x8f48000c, 0x8f860120,
67430x24020080, 0xafa20010, 0xafa30014, 0xafa80018,
67440x8f42010c, 0x40f809, 0x24c6001c, 0x10400047,
67450x24020001, 0x8f420300, 0x8f43002c, 0x24420001,
67460xaf420300, 0x8f420300, 0x24020001, 0xa34205c1,
67470x1000007c, 0xaf430038, 0x8f440170, 0x8f450174,
67480x8f43002c, 0x8f48000c, 0x8f860120, 0x24020020,
67490xafa20010, 0xafa30014, 0xafa80018, 0x8f42010c,
67500x40f809, 0x24c6001c, 0x10400057, 0x24020001,
67510x10000065, 0x0, 0x32420012, 0x10400075,
67520x32420001, 0x9622000e, 0x8f43009c, 0x621821,
67530x32c20020, 0x10400005, 0xaf43009c, 0x8f420358,
67540x2442ffff, 0xaf420358, 0x8f420358, 0x8e22001c,
67550x8f430040, 0x24420001, 0x2463ffff, 0x431024,
67560xaf42002c, 0x32420010, 0x14400008, 0x32c20010,
67570x8f420034, 0x24420001, 0xaf420034, 0x8c03023c,
67580x43102b, 0x144000bc, 0x32c20010, 0x10400028,
67590x24070008, 0x8f440170, 0x8f450174, 0x8f43002c,
67600x8f48000c, 0x8f860120, 0x24020080, 0xafa20010,
67610xafa30014, 0xafa80018, 0x8f42010c, 0x40f809,
67620x24c6001c, 0x14400011, 0x24020001, 0x3c010001,
67630x370821, 0xa02240f1, 0x8f820124, 0xafa20010,
67640x8f820128, 0x3c040001, 0x248467c4, 0xafa20014,
67650x8f46002c, 0x8f870120, 0x3c050009, 0xc002b3b,
67660x34a51100, 0x10000036, 0x0, 0x8f420300,
67670x8f43002c, 0x24420001, 0xaf420300, 0x8f420300,
67680x24020001, 0xa34205c1, 0x10000026, 0xaf430038,
67690x8f440170, 0x8f450174, 0x8f43002c, 0x8f48000c,
67700x8f860120, 0x24020020, 0xafa20010, 0xafa30014,
67710xafa80018, 0x8f42010c, 0x40f809, 0x24c6001c,
67720x14400011, 0x24020001, 0x3c010001, 0x370821,
67730xa02240f0, 0x8f820124, 0xafa20010, 0x8f820128,
67740x3c040001, 0x248467b8, 0xafa20014, 0x8f46002c,
67750x8f870120, 0x3c050009, 0xc002b3b, 0x34a50900,
67760x1000000f, 0x0, 0x8f420300, 0x24420001,
67770xaf420300, 0x8f420300, 0x8f42002c, 0xa34005c1,
67780xaf420038, 0x3c010001, 0x370821, 0xa02040f1,
67790x3c010001, 0x370821, 0xa02040f0, 0xaf400034,
67800x8f420314, 0x24420001, 0xaf420314, 0x10000062,
67810x8f420314, 0x10400022, 0x32427000, 0x8e25001c,
67820x8f420028, 0xa22023, 0x4810003, 0x0,
67830x8f420040, 0x822021, 0x8f420358, 0x8f430000,
67840xaf450028, 0x441021, 0x10600007, 0xaf420358,
67850xaf80004c, 0x8f82004c, 0x1040fffd, 0x0,
67860x10000005, 0x0, 0xaf800048, 0x8f820048,
67870x1040fffd, 0x0, 0x8f820060, 0x34420008,
67880xaf820060, 0x8f420000, 0x10400003, 0x0,
67890x10000041, 0xaf80004c, 0x1000003f, 0xaf800048,
67900x1040002f, 0x32421000, 0x1040000c, 0x32424000,
67910x8e23001c, 0x8f420050, 0x622023, 0x4820001,
67920x24840200, 0x8f42035c, 0x441021, 0xaf42035c,
67930x8f420368, 0x1000001a, 0xaf430050, 0x1040000c,
67940x32c28000, 0x8e23001c, 0x8f420070, 0x622023,
67950x4820001, 0x24840400, 0x8f420364, 0x441021,
67960xaf420364, 0x8f420368, 0x1000000d, 0xaf430070,
67970x1040000e, 0x3c020800, 0x8e23001c, 0x8f420060,
67980x622023, 0x4820001, 0x24840100, 0x8f420360,
67990x441021, 0xaf420360, 0x8f420368, 0xaf430060,
68000x441021, 0xaf420368, 0x3c020800, 0x2c21024,
68010x50400011, 0x36940040, 0x1000000f, 0x0,
68020x32420048, 0x10400007, 0x24150001, 0x8e22001c,
68030x3c03ffff, 0x43f024, 0x3042ffff, 0x1000fd75,
68040xae22001c, 0x32420100, 0x10400003, 0x0,
68050xc002bd8, 0x0, 0x8fbf0050, 0x8fbe004c,
68060x8fb50048, 0x8fb30044, 0x8fb20040, 0x8fb1003c,
68070x8fb00038, 0x3e00008, 0x27bd0058, 0x3e00008,
68080x0, 0x0, 0x0, 0x8f8300e4,
68090x8f8200e0, 0x2404fff8, 0x441024, 0x621026,
68100x2102b, 0x21023, 0x3e00008, 0x621024,
68110x3e00008, 0x0, 0x27bdffe0, 0xafbf001c,
68120xafb00018, 0x8f8600c4, 0x8f8400e0, 0x8f8500e4,
68130x2402fff8, 0x821824, 0x10a30009, 0x27623ff8,
68140x14a20002, 0x24a20008, 0x27623000, 0x408021,
68150x16030005, 0x30820004, 0x10400004, 0xc02021,
68160x10000022, 0x1021, 0x8e040000, 0x8f42011c,
68170x14a20003, 0x0, 0x8f420120, 0xaf420114,
68180x8ca30000, 0x8f420148, 0x831823, 0x43102b,
68190x10400003, 0x0, 0x8f420148, 0x621821,
68200x94a20006, 0x24420050, 0x62102b, 0x1440000f,
68210xa01021, 0xafa40010, 0xafa30014, 0x8ca60000,
68220x8ca70004, 0x3c040001, 0xc002b3b, 0x24846894,
68230x8f42020c, 0x24420001, 0xaf42020c, 0x8f42020c,
68240x1021, 0xaf9000e8, 0xaf9000e4, 0x8fbf001c,
68250x8fb00018, 0x3e00008, 0x27bd0020, 0x3e00008,
68260x0, 0x8f8400e0, 0x8f8800c4, 0x8f8300e8,
68270x2402fff8, 0x823824, 0xe32023, 0x2c821000,
68280x50400001, 0x24841000, 0x420c2, 0x801821,
68290x8f440258, 0x8f45025c, 0x1021, 0xa32821,
68300xa3302b, 0x822021, 0x862021, 0xaf440258,
68310xaf45025c, 0x8f8300c8, 0x8f420148, 0x1032023,
68320x82102b, 0x14400004, 0x801821, 0x8f420148,
68330x822021, 0x801821, 0x8f440250, 0x8f450254,
68340x1021, 0xa32821, 0xa3302b, 0x822021,
68350x862021, 0xaf440250, 0xaf450254, 0xaf8800c8,
68360xaf8700e4, 0xaf8700e8, 0x3e00008, 0x0,
68370x27bdff30, 0x240a0001, 0xafbf00c8, 0xafbe00c4,
68380xafb500c0, 0xafb300bc, 0xafb200b8, 0xafb100b4,
68390xafb000b0, 0xa3a00097, 0xafa00044, 0xafaa005c,
68400x934205c4, 0xa7a0008e, 0x1040000a, 0xa7a00086,
68410x8f4b00c4, 0xafab0064, 0x8f4a00c0, 0xafaa006c,
68420x8f4b00cc, 0xafab0074, 0x8f4a00c8, 0x10000129,
68430xafaa007c, 0x8f420114, 0x40f809, 0x0,
68440x403021, 0x10c0034f, 0x0, 0x8cc20000,
68450x8cc30004, 0xafa20020, 0xafa30024, 0x8fab0024,
68460x8faa0020, 0x3162ffff, 0x2442fffc, 0xafa2006c,
68470x3c020006, 0x2c21024, 0xafab007c, 0x14400015,
68480xafaa0064, 0x91420000, 0x30420001, 0x10400011,
68490x2402ffff, 0x8d430000, 0x14620004, 0x3402ffff,
68500x95430004, 0x1062000b, 0x0, 0xc0024bb,
68510x8fa40064, 0x304200ff, 0x14400006, 0x0,
68520x8f420118, 0x40f809, 0x0, 0x1000032d,
68530x0, 0x8fa20024, 0x3c03ffbf, 0x3463ffff,
68540x431024, 0x3c03ffff, 0x431824, 0x14600003,
68550xafa20024, 0x10000040, 0x1821, 0x3c020080,
68560x621024, 0x10400007, 0x0, 0x8f42038c,
68570x24420001, 0xaf42038c, 0x8f42038c, 0x10000036,
68580x24030001, 0x8f420210, 0x24420001, 0xaf420210,
68590x8f420210, 0x3c020001, 0x621024, 0x10400006,
68600x3c020002, 0x8f4201c4, 0x24420001, 0xaf4201c4,
68610x8f4201c4, 0x3c020002, 0x621024, 0x10400006,
68620x3c020004, 0x8f42037c, 0x24420001, 0xaf42037c,
68630x8f42037c, 0x3c020004, 0x621024, 0x10400006,
68640x3c020008, 0x8f420380, 0x24420001, 0xaf420380,
68650x8f420380, 0x3c020008, 0x621024, 0x10400006,
68660x3c020010, 0x8f420384, 0x24420001, 0xaf420384,
68670x8f420384, 0x3c020010, 0x621024, 0x10400006,
68680x3c020020, 0x8f4201c0, 0x24420001, 0xaf4201c0,
68690x8f4201c0, 0x3c020020, 0x621024, 0x10400006,
68700x24030001, 0x8f420388, 0x24420001, 0xaf420388,
68710x8f420388, 0x24030001, 0x8c020260, 0x8fab006c,
68720x4b102b, 0x10400014, 0x307000ff, 0x8f4201e8,
68730x24420001, 0xaf4201e8, 0x8f4201e8, 0x8faa007c,
68740x8f8200e0, 0x354a0100, 0xafaa007c, 0xafa20010,
68750x8f8200e4, 0x24100001, 0x3c040001, 0x248468a0,
68760xafa20014, 0x8fa60020, 0x8fa70024, 0x3c050007,
68770xc002b3b, 0x34a50800, 0x12000010, 0x3c020080,
68780x2c21024, 0x1440000e, 0x32c20400, 0x8fab007c,
68790x3c020080, 0x34420100, 0x1621024, 0x10400005,
68800x0, 0x8f42020c, 0x24420001, 0xaf42020c,
68810x8f42020c, 0x100002b0, 0x8fa3006c, 0x32c20400,
68820x10400015, 0x34028100, 0x8faa0064, 0x9543000c,
68830x14620012, 0x3c020100, 0x240b0200, 0xa7ab008e,
68840x9542000e, 0x8d430008, 0x8d440004, 0x8d450000,
68850x8faa006c, 0x8fab0064, 0x254afffc, 0xafaa006c,
68860xa7a20086, 0xad63000c, 0xad640008, 0xad650004,
68870x256b0004, 0xafab0064, 0x3c020100, 0x2c21024,
68880x10400004, 0x0, 0x8faa006c, 0x254a0004,
68890xafaa006c, 0x8f4200bc, 0x5040000a, 0xafa00074,
68900x8fab006c, 0x4b102b, 0x50400006, 0xafa00074,
68910x8f4200bc, 0x1621023, 0xafa20074, 0x8f4a00bc,
68920xafaa006c, 0x8f420080, 0x8fab006c, 0x4b102b,
68930x10400056, 0x32c28000, 0x1040005e, 0x240a0003,
68940x32c21000, 0x1040005b, 0xafaa005c, 0x10000058,
68950x240b0004, 0x8f420350, 0x2403ffbf, 0x283a024,
68960x24420001, 0xaf420350, 0x1000024f, 0x8f420350,
68970x2c2b025, 0x2402ffbf, 0x282a024, 0x8f830128,
68980x3c040001, 0x248468d0, 0x26620001, 0xafa20014,
68990xafa30010, 0x8f860120, 0x8f870124, 0x3c050007,
69000xc002b3b, 0x34a52250, 0x1000023f, 0x0,
69010x2c2b025, 0x2402ffbf, 0x282a024, 0x8f830128,
69020x3c040001, 0x248468d0, 0x24020002, 0xafa20014,
69030xafa30010, 0x8f860120, 0x8f870124, 0x3c050007,
69040xc002b3b, 0x34a52450, 0x1000022f, 0x0,
69050x8ea20000, 0x8ea30004, 0x3c040001, 0x248468e8,
69060xafb00010, 0xafbe0014, 0x8ea70018, 0x34a52800,
69070xc002b3b, 0x603021, 0x10000223, 0x0,
69080xa6b1000a, 0x8f820124, 0x3c040001, 0x248468f0,
69090xafbe0014, 0xafa20010, 0x8f460044, 0x8f870120,
69100x3c050007, 0xc002b3b, 0x34a53000, 0x10000216,
69110x0, 0xa6b1000a, 0xa6b2000e, 0x8f820124,
69120x3c040001, 0x248468fc, 0xafbe0014, 0xafa20010,
69130x8f460044, 0x8f870120, 0x3c050007, 0xc002b3b,
69140x34a53200, 0x10000208, 0x0, 0x8f420084,
69150x8faa006c, 0x4a102b, 0x14400007, 0x3c020001,
69160x2c21024, 0x10400004, 0x0, 0x240b0002,
69170xafab005c, 0x8faa006c, 0x1140021b, 0x27ab0020,
69180xafab00a4, 0x3c0a001f, 0x354affff, 0xafaa009c,
69190x8fab005c, 0x240a0001, 0x556a0021, 0x240a0002,
69200x8f430054, 0x8f420050, 0x1062000b, 0x274b0054,
69210x8f5e0054, 0x3403ecc0, 0xafab004c, 0x27c20001,
69220x304201ff, 0xafa20054, 0x1e1140, 0x431021,
69230x1000006b, 0x2e2a821, 0x8f420044, 0x8faa006c,
69240x3c040001, 0x248468ac, 0xafaa0014, 0xafa20010,
69250x8f460054, 0x8f470050, 0x3c050007, 0xc002b3b,
69260x34a51300, 0x8f430350, 0x2402ffbf, 0x282a024,
69270x24630001, 0xaf430350, 0x100001d3, 0x8f420350,
69280x156a001d, 0x0, 0x8f430074, 0x8f420070,
69290x1062000a, 0x274b0074, 0x8f5e0074, 0xafab004c,
69300x27c20001, 0x304203ff, 0xafa20054, 0x1e1140,
69310x24426cc0, 0x1000004a, 0x2e2a821, 0x8f420044,
69320x8faa006c, 0x3c040001, 0x248468b8, 0x3c050007,
69330xafaa0014, 0xafa20010, 0x8f460074, 0x8f470070,
69340x34a51500, 0x240b0001, 0xc002b3b, 0xafab005c,
69350x1000ffc3, 0x0, 0x8f430064, 0x8f420060,
69360x1062001a, 0x274a0064, 0x8f5e0064, 0x8fab005c,
69370xafaa004c, 0x27c20001, 0x304200ff, 0xafa20054,
69380x24020004, 0x1562000e, 0x1e1140, 0x1e1180,
69390x24420cc0, 0x2e21021, 0xafa20044, 0x9442002a,
69400x8faa0044, 0x8fab006c, 0x4b102b, 0x10400024,
69410x25550020, 0x240a0001, 0x10000021, 0xa3aa0097,
69420x24424cc0, 0x1000001e, 0x2e2a821, 0x8f420044,
69430x8fab006c, 0x3c040001, 0x248468c4, 0xafab0014,
69440xafa20010, 0x8f460064, 0x8f470060, 0x3c050007,
69450xc002b3b, 0x34a51800, 0x3c020008, 0x2c21024,
69460x1440ff34, 0x0, 0x8f420370, 0x240a0001,
69470xafaa005c, 0x24420001, 0xaf420370, 0x1000ff90,
69480x8f420370, 0x27a30036, 0x131040, 0x621821,
69490x94620000, 0x441021, 0x10000020, 0xa4620000,
69500x8fab0064, 0xaeab0018, 0x93a20097, 0x10400072,
69510x9821, 0x8faa0044, 0x8fa4006c, 0x8fa300a4,
69520x25420020, 0xafa20028, 0x25420008, 0xafa20030,
69530x25420010, 0xafaa002c, 0xafa20034, 0x9542002a,
69540xa7a20038, 0x95420018, 0xa7a2003a, 0x9542001a,
69550xa7a2003c, 0x9542001c, 0xa7a2003e, 0x94620018,
69560x24630002, 0x822023, 0x1880ffde, 0x26730001,
69570x2e620004, 0x1440fff9, 0x0, 0x8f4200fc,
69580x26650001, 0xa2102a, 0x1440002b, 0x24030001,
69590x8f83012c, 0x10600023, 0x0, 0x8f820124,
69600x431023, 0x22143, 0x58800001, 0x24840040,
69610x8f820128, 0x431023, 0x21943, 0x58600001,
69620x24630040, 0x64102a, 0x54400001, 0x602021,
69630xaf4400fc, 0x8f4200fc, 0xa2102a, 0x10400011,
69640x24030001, 0x10000015, 0x306200ff, 0x8fab0064,
69650x96070018, 0xafab0010, 0x8e220008, 0x3c040001,
69660x248468dc, 0x8c430004, 0x8c420000, 0x34a52400,
69670x2403021, 0xc002b3b, 0xafa30014, 0x1000002b,
69680x0, 0x8f420334, 0x1821, 0x24420001,
69690xaf420334, 0x8f420334, 0x306200ff, 0x5040fedc,
69700x3c020800, 0x12600021, 0x9021, 0x8fb100a4,
69710x2208021, 0x8e220008, 0x96070018, 0x8fa60064,
69720x8c440000, 0x8c450004, 0x240a0001, 0xafaa0010,
69730xafbe0014, 0x8f420008, 0xafa20018, 0x8f42010c,
69740x40f809, 0x0, 0x1040ffd8, 0x3c050007,
69750x96020018, 0x8fab0064, 0x8faa009c, 0x1625821,
69760x14b102b, 0x10400004, 0xafab0064, 0x8f420148,
69770x1625823, 0xafab0064, 0x26100002, 0x26520001,
69780x253102b, 0x1440ffe3, 0x26310004, 0x8fb0006c,
69790x10000036, 0x97b10038, 0x8f4200fc, 0x24050002,
69800xa2102a, 0x1440001b, 0x24030001, 0x8f83012c,
69810x10600013, 0x0, 0x8f820124, 0x431023,
69820x22143, 0x58800001, 0x24840040, 0x8f820128,
69830x431023, 0x21943, 0x58600001, 0x24630040,
69840x64102a, 0x54400001, 0x602021, 0xaf4400fc,
69850x8f4200fc, 0xa2102a, 0x14400006, 0x24030001,
69860x8f420334, 0x1821, 0x24420001, 0xaf420334,
69870x8f420334, 0x306200ff, 0x1040fea5, 0x3c020800,
69880x96b1000a, 0x8fb0006c, 0x3223ffff, 0x70102b,
69890x54400001, 0x608021, 0x8ea40000, 0x8ea50004,
69900x240b0001, 0xafab0010, 0xafbe0014, 0x8f420008,
69910x8fa60064, 0xafa20018, 0x8f42010c, 0x40f809,
69920x2003821, 0x1040fea2, 0x3c050007, 0x96a3000e,
69930x97aa008e, 0x11400007, 0x609021, 0x934205c4,
69940x14400004, 0x0, 0x97ab0086, 0x6a1825,
69950xa6ab0016, 0x8faa007c, 0x3c02ffff, 0x1421024,
69960x10400003, 0xa1402, 0x34630400, 0xa6a20014,
69970x8fab006c, 0x560b0072, 0xa6a3000e, 0x34620004,
69980xa6a2000e, 0x8faa0074, 0x16a1021, 0xa6a2000a,
69990x8f430044, 0x8f4401a0, 0x8f4501a4, 0x34028000,
70000xafa20010, 0x8f420044, 0x2a03021, 0x24070020,
70010xafa20014, 0x8f42000c, 0x31940, 0x604821,
70020xafa20018, 0x8f42010c, 0x4021, 0xa92821,
70030xa9182b, 0x882021, 0x40f809, 0x832021,
70040x5040fe7f, 0xa6b2000e, 0x8f420368, 0xafa0006c,
70050xa34005c4, 0x2442ffff, 0xaf420368, 0x8fab005c,
70060x240a0001, 0x8f420368, 0x156a0006, 0x240a0002,
70070x8f42035c, 0x2442ffff, 0xaf42035c, 0x1000000c,
70080x8f42035c, 0x156a0006, 0x0, 0x8f420364,
70090x2442ffff, 0xaf420364, 0x10000005, 0x8f420364,
70100x8f420360, 0x2442ffff, 0xaf420360, 0x8f420360,
70110x8faa0054, 0x8fab004c, 0xad6a0000, 0x8f420044,
70120x8f440088, 0x8f430078, 0x24420001, 0x441024,
70130x24630001, 0xaf420044, 0xaf430078, 0x8c020240,
70140x62182b, 0x14600075, 0x24070008, 0x8f440168,
70150x8f45016c, 0x8f430044, 0x8f48000c, 0x8f860120,
70160x24020040, 0xafa20010, 0xafa30014, 0xafa80018,
70170x8f42010c, 0x40f809, 0x24c6001c, 0x14400011,
70180x240b0001, 0x3c010001, 0x370821, 0xa02b40f2,
70190x8f820124, 0xafa20010, 0x8f820128, 0x3c040001,
70200x2484688c, 0xafa20014, 0x8f460044, 0x8f870120,
70210x3c050009, 0xc002b3b, 0x34a51300, 0x1000000b,
70220x0, 0x8f420304, 0x24420001, 0xaf420304,
70230x8f420304, 0x8f420044, 0xaf42007c, 0x3c010001,
70240x370821, 0xa02040f2, 0xaf400078, 0x8f420318,
70250x24420001, 0xaf420318, 0x10000048, 0x8f420318,
70260xa6b0000a, 0x8f430044, 0x8f4401a0, 0x8f4501a4,
70270x34028000, 0xafa20010, 0x8f420044, 0x2a03021,
70280x24070020, 0xafa20014, 0x8f42000c, 0x31940,
70290x604821, 0xafa20018, 0x8f42010c, 0x4021,
70300xa92821, 0xa9182b, 0x882021, 0x40f809,
70310x832021, 0x1040fe1f, 0x240a0001, 0xa34a05c4,
70320x8fab006c, 0x8faa0064, 0x1705823, 0xafab006c,
70330x8fab009c, 0x1505021, 0x16a102b, 0x10400004,
70340xafaa0064, 0x8f420148, 0x1425023, 0xafaa0064,
70350x8f420368, 0x2442ffff, 0xaf420368, 0x8faa005c,
70360x240b0001, 0x8f420368, 0x154b0006, 0x240b0002,
70370x8f42035c, 0x2442ffff, 0xaf42035c, 0x1000000c,
70380x8f42035c, 0x114b0006, 0x0, 0x8f420360,
70390x2442ffff, 0xaf420360, 0x10000005, 0x8f420360,
70400x8f420364, 0x2442ffff, 0xaf420364, 0x8f420364,
70410x8fab0054, 0x8faa004c, 0xad4b0000, 0x8f420044,
70420x8f440088, 0x8f430078, 0x24420001, 0x441024,
70430x24630001, 0xaf420044, 0xaf430078, 0x8faa006c,
70440x1540fe0b, 0x0, 0x8fab006c, 0x1160001e,
70450x0, 0x934205c4, 0x10400009, 0x0,
70460x8faa0064, 0xaf4a00c4, 0xaf4b00c0, 0x8fab007c,
70470xaf4b00c8, 0x8faa0074, 0x1000000e, 0xaf4a00cc,
70480x97ab008e, 0x1160000b, 0x34038100, 0x8fa20020,
70490x8c46000c, 0xa443000c, 0x97aa0086, 0x8c440004,
70500x8c450008, 0xa44a000e, 0xac440000, 0xac450004,
70510xac460008, 0x8f42034c, 0x24420001, 0xaf42034c,
70520x10000010, 0x8f42034c, 0x8fab007c, 0x3164ffff,
70530x2484fffc, 0x801821, 0x8f440250, 0x8f450254,
70540x8f460118, 0x1021, 0xa32821, 0xa3382b,
70550x822021, 0x872021, 0xaf440250, 0xc0f809,
70560xaf450254, 0x8fbf00c8, 0x8fbe00c4, 0x8fb500c0,
70570x8fb300bc, 0x8fb200b8, 0x8fb100b4, 0x8fb000b0,
70580x3e00008, 0x27bd00d0, 0x3e00008, 0x0,
70590x27bdff38, 0x240b0001, 0xafbf00c0, 0xafbe00bc,
70600xafb500b8, 0xafb300b4, 0xafb200b0, 0xafb100ac,
70610xafb000a8, 0xa3a00087, 0xafa00044, 0xafab005c,
70620x934205c4, 0xa7a00076, 0x10400007, 0xa7a0007e,
70630x8f4c00c0, 0xafac0064, 0x8f4b00c8, 0x8f5e00c4,
70640x10000130, 0xafab006c, 0x8f420114, 0x40f809,
70650x0, 0x403021, 0x10c002a1, 0x0,
70660x8cc20000, 0x8cc30004, 0xafa20020, 0xafa30024,
70670x8fac0024, 0x8fbe0020, 0x3182ffff, 0x2442fffc,
70680xafa20064, 0x3c020006, 0x2c21024, 0x14400015,
70690xafac006c, 0x93c20000, 0x30420001, 0x10400011,
70700x2402ffff, 0x8fc30000, 0x14620004, 0x3402ffff,
70710x97c30004, 0x1062000b, 0x0, 0xc0024bb,
70720x3c02021, 0x304200ff, 0x14400006, 0x0,
70730x8f420118, 0x40f809, 0x0, 0x10000280,
70740x0, 0x8fa20024, 0x3c03ffbf, 0x3463ffff,
70750x431024, 0x3c03ffff, 0x431824, 0x14600003,
70760xafa20024, 0x10000040, 0x8021, 0x3c020080,
70770x621024, 0x10400007, 0x0, 0x8f42038c,
70780x24420001, 0xaf42038c, 0x8f42038c, 0x10000036,
70790x24100001, 0x8f420210, 0x24420001, 0xaf420210,
70800x8f420210, 0x3c020001, 0x621024, 0x10400006,
70810x3c020002, 0x8f4201c4, 0x24420001, 0xaf4201c4,
70820x8f4201c4, 0x3c020002, 0x621024, 0x10400006,
70830x3c020004, 0x8f42037c, 0x24420001, 0xaf42037c,
70840x8f42037c, 0x3c020004, 0x621024, 0x10400006,
70850x3c020008, 0x8f420380, 0x24420001, 0xaf420380,
70860x8f420380, 0x3c020008, 0x621024, 0x10400006,
70870x3c020010, 0x8f420384, 0x24420001, 0xaf420384,
70880x8f420384, 0x3c020010, 0x621024, 0x10400006,
70890x3c020020, 0x8f4201c0, 0x24420001, 0xaf4201c0,
70900x8f4201c0, 0x3c020020, 0x621024, 0x10400006,
70910x24100001, 0x8f420388, 0x24420001, 0xaf420388,
70920x8f420388, 0x24100001, 0x8c020260, 0x8fab0064,
70930x4b102b, 0x10400015, 0x320200ff, 0x8f4201e8,
70940x24420001, 0xaf4201e8, 0x8f4201e8, 0x8fac006c,
70950x8f8200e0, 0x358c0100, 0xafac006c, 0xafa20010,
70960x8f8200e4, 0x24100001, 0x3c040001, 0x248468a0,
70970xafa20014, 0x8fa60020, 0x8fa70024, 0x3c050007,
70980xc002b3b, 0x34a53600, 0x320200ff, 0x10400010,
70990x3c020080, 0x2c21024, 0x1440000e, 0x32c20400,
71000x8fab006c, 0x3c020080, 0x34420100, 0x1621024,
71010x10400005, 0x0, 0x8f42020c, 0x24420001,
71020xaf42020c, 0x8f42020c, 0x10000202, 0x8fa30064,
71030x32c20400, 0x10400012, 0x34028100, 0x97c3000c,
71040x1462000f, 0x0, 0x240c0200, 0xa7ac0076,
71050x97c2000e, 0x8fc30008, 0x8fc40004, 0x8fab0064,
71060x8fc50000, 0x256bfffc, 0xafab0064, 0xa7a2007e,
71070xafc3000c, 0xafc40008, 0xafc50004, 0x27de0004,
71080x8fa70064, 0x320200ff, 0x14400034, 0x3c020100,
71090x97c4000c, 0x2c8305dd, 0x38828870, 0x2c420001,
71100x621825, 0x10600015, 0x2821, 0x32c20800,
71110x10400015, 0x24020800, 0x97c30014, 0x14620012,
71120x3402aaaa, 0x97c3000e, 0x14620007, 0x2021,
71130x97c30010, 0x24020300, 0x14620004, 0x801021,
71140x97c20012, 0x2c440001, 0x801021, 0x54400006,
71150x24050016, 0x10000004, 0x0, 0x24020800,
71160x50820001, 0x2405000e, 0x10a00013, 0x3c52021,
71170x24830009, 0x3c02001f, 0x3442ffff, 0x43102b,
71180x10400003, 0x0, 0x8f420148, 0x621823,
71190x90620000, 0x38430006, 0x2c630001, 0x38420011,
71200x2c420001, 0x621825, 0x10600004, 0x3c020100,
71210x94820002, 0x453821, 0x3c020100, 0x2c21024,
71220x5040000e, 0xafa70064, 0x8fac0064, 0x10ec0008,
71230x3c050007, 0x3c040001, 0x24846908, 0x8fa60064,
71240x34a54000, 0xafa00010, 0xc002b3b, 0xafa00014,
71250x8fab0064, 0x256b0004, 0xafab0064, 0x8f420080,
71260x8fac0064, 0x4c102b, 0x1040002c, 0x32c28000,
71270x10400034, 0x240b0003, 0x32c21000, 0x10400031,
71280xafab005c, 0x1000002e, 0x240c0004, 0x8f420350,
71290x2403ffbf, 0x283a024, 0x24420001, 0xaf420350,
71300x10000173, 0x8f420350, 0x3c020800, 0x2c2b025,
71310x2402ffbf, 0x282a024, 0x8f830128, 0x3c040001,
71320x248468d0, 0x26620001, 0xafa20014, 0xafa30010,
71330x8f860120, 0x8f870124, 0x3c050007, 0xc002b3b,
71340x34a55300, 0x10000162, 0x0, 0x8ea20000,
71350x8ea30004, 0x3c040001, 0x248468e8, 0xafb00010,
71360xafb10014, 0x8ea70018, 0x34a55900, 0xc002b3b,
71370x603021, 0x10000156, 0x0, 0x8f420084,
71380x8fab0064, 0x4b102b, 0x14400007, 0x3c020001,
71390x2c21024, 0x10400004, 0x0, 0x240c0002,
71400xafac005c, 0x8fab0064, 0x11600166, 0x27ac0020,
71410xafac008c, 0x8fab005c, 0x240c0001, 0x556c0021,
71420x240c0002, 0x8f430054, 0x8f420050, 0x1062000b,
71430x274b0054, 0x8f510054, 0x3403ecc0, 0xafab004c,
71440x26220001, 0x304201ff, 0xafa20054, 0x111140,
71450x431021, 0x1000006b, 0x2e2a821, 0x8f420044,
71460x8fac0064, 0x3c040001, 0x248468ac, 0xafac0014,
71470xafa20010, 0x8f460054, 0x8f470050, 0x3c050007,
71480xc002b3b, 0x34a54300, 0x8f430350, 0x2402ffbf,
71490x282a024, 0x24630001, 0xaf430350, 0x10000124,
71500x8f420350, 0x156c001d, 0x0, 0x8f430074,
71510x8f420070, 0x1062000a, 0x274b0074, 0x8f510074,
71520xafab004c, 0x26220001, 0x304203ff, 0xafa20054,
71530x111140, 0x24426cc0, 0x1000004a, 0x2e2a821,
71540x8f420044, 0x8fac0064, 0x3c040001, 0x248468b8,
71550x3c050007, 0xafac0014, 0xafa20010, 0x8f460074,
71560x8f470070, 0x34a54500, 0x240b0001, 0xc002b3b,
71570xafab005c, 0x1000ffc3, 0x0, 0x8f430064,
71580x8f420060, 0x1062001a, 0x274c0064, 0x8f510064,
71590x8fab005c, 0xafac004c, 0x26220001, 0x304200ff,
71600xafa20054, 0x24020004, 0x1562000e, 0x111140,
71610x111180, 0x24420cc0, 0x2e21021, 0xafa20044,
71620x9442002a, 0x8fac0044, 0x8fab0064, 0x4b102b,
71630x10400024, 0x25950020, 0x240c0001, 0x10000021,
71640xa3ac0087, 0x24424cc0, 0x1000001e, 0x2e2a821,
71650x8f420044, 0x8fab0064, 0x3c040001, 0x248468c4,
71660xafab0014, 0xafa20010, 0x8f460064, 0x8f470060,
71670x3c050007, 0xc002b3b, 0x34a54800, 0x3c020008,
71680x2c21024, 0x1440ff61, 0x0, 0x8f420370,
71690x240c0001, 0xafac005c, 0x24420001, 0xaf420370,
71700x1000ff90, 0x8f420370, 0x27a30036, 0x131040,
71710x621821, 0x94620000, 0x441021, 0x1000001f,
71720xa4620000, 0xaebe0018, 0x93a20087, 0x10400084,
71730x9821, 0x8fab0044, 0x8fa40064, 0x8fa3008c,
71740x25620020, 0xafa20028, 0x25620008, 0xafa20030,
71750x25620010, 0xafab002c, 0xafa20034, 0x9562002a,
71760xa7a20038, 0x95620018, 0xa7a2003a, 0x9562001a,
71770xa7a2003c, 0x9562001c, 0xa7a2003e, 0x94620018,
71780x24630002, 0x822023, 0x1880ffdf, 0x26730001,
71790x2e620004, 0x1440fff9, 0x0, 0x8f4200fc,
71800x262102a, 0x14400030, 0x24030001, 0x8f83012c,
71810x10600028, 0x0, 0x8f820124, 0x431023,
71820x22143, 0x58800001, 0x24840040, 0x8f820128,
71830x431023, 0x21943, 0x58600001, 0x24630040,
71840x64102a, 0x54400001, 0x602021, 0xaf4400fc,
71850x8f4200fc, 0x262102a, 0x10400016, 0x24030001,
71860x1000001a, 0x306200ff, 0x8fac008c, 0x101040,
71870x4c1021, 0x94470018, 0x101080, 0x4c1021,
71880xafbe0010, 0x8c420008, 0x3c040001, 0x248468dc,
71890x3c050007, 0x8c430004, 0x8c420000, 0x34a55500,
71900x2003021, 0xc002b3b, 0xafa30014, 0x10000039,
71910x0, 0x8f420334, 0x1821, 0x24420001,
71920xaf420334, 0x8f420334, 0x306200ff, 0x1040ff06,
71930x8021, 0x8f430008, 0x2402fbff, 0x1260002d,
71940x625024, 0x3c0b4000, 0x22b4025, 0x8fb1008c,
71950x2669ffff, 0x2209021, 0x8e420008, 0x96270018,
71960x8c440000, 0x8c450004, 0x56090004, 0x240b0001,
71970x240c0002, 0x10000002, 0xafac0010, 0xafab0010,
71980x16000004, 0xafa80014, 0x8f420008, 0x10000002,
71990xafa20018, 0xafaa0018, 0x8f42010c, 0x3c03021,
72000xafa80098, 0xafa9009c, 0x40f809, 0xafaa00a0,
72010x8fa80098, 0x8fa9009c, 0x8faa00a0, 0x1040ffc2,
72020x3c02001f, 0x96230018, 0x3442ffff, 0x3c3f021,
72030x5e102b, 0x10400003, 0x26310002, 0x8f420148,
72040x3c2f023, 0x26100001, 0x213102b, 0x1440ffda,
72050x26520004, 0x8fb00064, 0x1000001a, 0x0,
72060x96a3000a, 0x8fb00064, 0x70102b, 0x54400001,
72070x608021, 0x8ea40000, 0x8ea50004, 0x8fab005c,
72080x240c0002, 0xafac0010, 0x934305c4, 0xb1700,
72090x10600003, 0x2223025, 0x3c020800, 0xc23025,
72100xafa60014, 0x8f420008, 0xafa20018, 0x8f42010c,
72110x3c03021, 0x40f809, 0x2003821, 0x1040fecb,
72120x3c050007, 0x97ac0076, 0x11800007, 0x96a3000e,
72130x934205c4, 0x14400004, 0x0, 0x97ab007e,
72140x6c1825, 0xa6ab0016, 0x8fac006c, 0x3c02ffff,
72150x1821024, 0x10400003, 0xc1402, 0x34630400,
72160xa6a20014, 0xa6b0000a, 0x8fab0064, 0x560b0006,
72170x3d0f021, 0x34620004, 0xafa00064, 0xa6a2000e,
72180x1000000d, 0xa34005c4, 0x8fac0064, 0x3c02001f,
72190x3442ffff, 0x5e102b, 0x1906023, 0xafac0064,
72200xa6a3000e, 0x240b0001, 0x10400003, 0xa34b05c4,
72210x8f420148, 0x3c2f023, 0x8fab0054, 0x8fac004c,
72220xad8b0000, 0x8fac0064, 0x1580feba, 0x0,
72230x8fab0064, 0x1160001b, 0x0, 0x934205c4,
72240x10400006, 0x0, 0xaf5e00c4, 0xaf4b00c0,
72250x8fac006c, 0x1000000e, 0xaf4c00c8, 0x97ab0076,
72260x1160000b, 0x34038100, 0x8fa20020, 0x8c46000c,
72270xa443000c, 0x97ac007e, 0x8c440004, 0x8c450008,
72280xa44c000e, 0xac440000, 0xac450004, 0xac460008,
72290x8f42034c, 0x24420001, 0xaf42034c, 0x10000010,
72300x8f42034c, 0x8fab006c, 0x3164ffff, 0x2484fffc,
72310x801821, 0x8f440250, 0x8f450254, 0x8f460118,
72320x1021, 0xa32821, 0xa3382b, 0x822021,
72330x872021, 0xaf440250, 0xc0f809, 0xaf450254,
72340x8fbf00c0, 0x8fbe00bc, 0x8fb500b8, 0x8fb300b4,
72350x8fb200b0, 0x8fb100ac, 0x8fb000a8, 0x3e00008,
72360x27bd00c8, 0x3e00008, 0x0, 0x27bdffd8,
72370xafbf0024, 0xafb00020, 0x8f43004c, 0x8f420048,
72380x10620034, 0x0, 0x8f430048, 0x8f42004c,
72390x622023, 0x4820001, 0x24840200, 0x8f430054,
72400x8f42004c, 0x43102b, 0x14400004, 0x24020200,
72410x8f43004c, 0x10000005, 0x431023, 0x8f420054,
72420x8f43004c, 0x431023, 0x2442ffff, 0x405021,
72430x8a102a, 0x54400001, 0x805021, 0x8f49004c,
72440x8f48004c, 0x8f440188, 0x8f45018c, 0x8f46004c,
72450x24071000, 0xafa70010, 0x84140, 0x1001821,
72460x12a4821, 0x313001ff, 0xafb00014, 0x8f470014,
72470x1021, 0x63140, 0xafa70018, 0xa32821,
72480xa3382b, 0x822021, 0x872021, 0x3402ecc0,
72490xc23021, 0x8f420108, 0x2e63021, 0x40f809,
72500xa3940, 0x54400001, 0xaf50004c, 0x8f43004c,
72510x8f420048, 0x14620018, 0x0, 0x8f420000,
72520x10400007, 0x0, 0xaf80004c, 0x8f82004c,
72530x1040fffd, 0x0, 0x10000005, 0x0,
72540xaf800048, 0x8f820048, 0x1040fffd, 0x0,
72550x8f820060, 0x2403fdff, 0x431024, 0xaf820060,
72560x8f420000, 0x10400003, 0x0, 0x10000002,
72570xaf80004c, 0xaf800048, 0x8fbf0024, 0x8fb00020,
72580x3e00008, 0x27bd0028, 0x3e00008, 0x0,
72590x27bdffd8, 0xafbf0024, 0xafb00020, 0x8f43005c,
72600x8f420058, 0x10620049, 0x0, 0x8f430058,
72610x8f42005c, 0x622023, 0x4820001, 0x24840100,
72620x8f430064, 0x8f42005c, 0x43102b, 0x14400004,
72630x24020100, 0x8f43005c, 0x10000005, 0x431023,
72640x8f420064, 0x8f43005c, 0x431023, 0x2442ffff,
72650x403821, 0x87102a, 0x54400001, 0x803821,
72660x8f42005c, 0x471021, 0x305000ff, 0x32c21000,
72670x10400015, 0x24082000, 0x8f49005c, 0x8f440190,
72680x8f450194, 0x8f46005c, 0x73980, 0xafa80010,
72690xafb00014, 0x8f480014, 0x94980, 0x1201821,
72700x1021, 0xa32821, 0xa3482b, 0x822021,
72710x892021, 0x63180, 0xafa80018, 0x8f420108,
72720x10000014, 0x24c60cc0, 0x8f49005c, 0x8f440190,
72730x8f450194, 0x8f46005c, 0x73940, 0xafa80010,
72740xafb00014, 0x8f480014, 0x94940, 0x1201821,
72750x1021, 0xa32821, 0xa3482b, 0x822021,
72760x892021, 0x63140, 0xafa80018, 0x8f420108,
72770x24c64cc0, 0x40f809, 0x2e63021, 0x54400001,
72780xaf50005c, 0x8f43005c, 0x8f420058, 0x14620018,
72790x0, 0x8f420000, 0x10400007, 0x0,
72800xaf80004c, 0x8f82004c, 0x1040fffd, 0x0,
72810x10000005, 0x0, 0xaf800048, 0x8f820048,
72820x1040fffd, 0x0, 0x8f820060, 0x2403feff,
72830x431024, 0xaf820060, 0x8f420000, 0x10400003,
72840x0, 0x10000002, 0xaf80004c, 0xaf800048,
72850x8fbf0024, 0x8fb00020, 0x3e00008, 0x27bd0028,
72860x3e00008, 0x0, 0x27bdffd8, 0xafbf0024,
72870xafb00020, 0x8f43006c, 0x8f420068, 0x10620033,
72880x0, 0x8f430068, 0x8f42006c, 0x622023,
72890x4820001, 0x24840400, 0x8f430074, 0x8f42006c,
72900x43102b, 0x14400004, 0x24020400, 0x8f43006c,
72910x10000005, 0x431023, 0x8f420074, 0x8f43006c,
72920x431023, 0x2442ffff, 0x405021, 0x8a102a,
72930x54400001, 0x805021, 0x8f49006c, 0x8f48006c,
72940x8f440198, 0x8f45019c, 0x8f46006c, 0x24074000,
72950xafa70010, 0x84140, 0x1001821, 0x12a4821,
72960x313003ff, 0xafb00014, 0x8f470014, 0x1021,
72970x63140, 0x24c66cc0, 0xafa70018, 0xa32821,
72980xa3382b, 0x822021, 0x872021, 0x8f420108,
72990x2e63021, 0x40f809, 0xa3940, 0x54400001,
73000xaf50006c, 0x8f43006c, 0x8f420068, 0x14620018,
73010x0, 0x8f420000, 0x10400007, 0x0,
73020xaf80004c, 0x8f82004c, 0x1040fffd, 0x0,
73030x10000005, 0x0, 0xaf800048, 0x8f820048,
73040x1040fffd, 0x0, 0x8f820060, 0x2403f7ff,
73050x431024, 0xaf820060, 0x8f420000, 0x10400003,
73060x0, 0x10000002, 0xaf80004c, 0xaf800048,
73070x8fbf0024, 0x8fb00020, 0x3e00008, 0x27bd0028,
73080x3e00008, 0x0, 0x8f4200fc, 0x3c030001,
73090x8f4400f8, 0x346330c8, 0x24420001, 0xaf4200fc,
73100x8f850128, 0x2e31021, 0x54820004, 0x24820008,
73110x3c020001, 0x34422ec8, 0x2e21021, 0x401821,
73120xaf4300f8, 0xac600000, 0x8f4200f4, 0x14620004,
73130x3c020001, 0x24a20020, 0x1000000f, 0xaf820128,
73140x8f4300f8, 0x344230c8, 0x2e21021, 0x54620004,
73150x24620008, 0x3c020001, 0x34422ec8, 0x2e21021,
73160x401821, 0x8c620004, 0x21140, 0xa21021,
73170xaf820128, 0xac600000, 0x8ca30018, 0x30620070,
73180x1040002d, 0x30620020, 0x10400004, 0x3c020010,
73190x2c21024, 0x1040000d, 0x0, 0x30620040,
73200x10400004, 0x3c020020, 0x2c21024, 0x10400007,
73210x0, 0x30620010, 0x1040001f, 0x3c020040,
73220x2c21024, 0x1440001c, 0x0, 0x8f820040,
73230x30420001, 0x14400008, 0x2021, 0x8c030104,
73240x24020001, 0x50620005, 0x24040001, 0x8c020264,
73250x10400003, 0x801021, 0x24040001, 0x801021,
73260x10400006, 0x0, 0x8f42030c, 0x24420001,
73270xaf42030c, 0x10000008, 0x8f42030c, 0x8f820044,
73280x34420004, 0xaf820044, 0x8f420308, 0x24420001,
73290xaf420308, 0x8f420308, 0x3e00008, 0x0,
73300x3e00008, 0x0, 0x27bdff98, 0xafbf0060,
73310xafbe005c, 0xafb50058, 0xafb30054, 0xafb20050,
73320xafb1004c, 0xafb00048, 0x8f4200fc, 0x24420001,
73330xaf4200fc, 0x8f880128, 0x25020020, 0xaf820128,
73340x8d030018, 0x30620070, 0x1040002e, 0x30620020,
73350x10400004, 0x3c020010, 0x2c21024, 0x1040000d,
73360x0, 0x30620040, 0x10400004, 0x3c020020,
73370x2c21024, 0x10400007, 0x0, 0x30620010,
73380x104001a9, 0x3c020040, 0x2c21024, 0x144001a6,
73390x0, 0x8f820040, 0x30420001, 0x14400008,
73400x2021, 0x8c030104, 0x24020001, 0x50620005,
73410x24040001, 0x8c020264, 0x10400003, 0x801021,
73420x24040001, 0x801021, 0x10400006, 0x0,
73430x8f42030c, 0x24420001, 0xaf42030c, 0x10000192,
73440x8f42030c, 0x8f820044, 0x34420004, 0xaf820044,
73450x8f420308, 0x24420001, 0xaf420308, 0x1000018a,
73460x8f420308, 0x30620002, 0x1040014b, 0x3c020800,
73470x8d1e001c, 0x1e5702, 0xafaa0034, 0x950a0016,
73480x3c22024, 0xafaa0024, 0x8faa0034, 0x24020001,
73490x15420006, 0x33deffff, 0x1e1140, 0x3403ecc0,
73500x431021, 0x10000010, 0x2e2a821, 0x24020002,
73510x15420005, 0x24020003, 0x1e1140, 0x24426cc0,
73520x10000009, 0x2e2a821, 0x15420005, 0x1e1180,
73530x1e1140, 0x24424cc0, 0x10000003, 0x2e2a821,
73540x571021, 0x24550ce0, 0x96a2000e, 0x304afffc,
73550x30420400, 0x10400003, 0xafaa002c, 0x100000e1,
73560x8821, 0x10800004, 0x8821, 0x97b10026,
73570x100000dd, 0xa6b10012, 0x8eb30018, 0x966a000c,
73580xa7aa003e, 0x97a5003e, 0x2ca305dd, 0x38a28870,
73590x2c420001, 0x621825, 0x10600015, 0x2021,
73600x32c20800, 0x10400015, 0x24020800, 0x96630014,
73610x14620012, 0x3402aaaa, 0x9663000e, 0x14620007,
73620x2821, 0x96630010, 0x24020300, 0x14620004,
73630xa01021, 0x96620012, 0x2c450001, 0xa01021,
73640x54400006, 0x24040016, 0x10000004, 0x0,
73650x24020800, 0x50a20001, 0x2404000e, 0x108000b9,
73660x2649021, 0x92420000, 0x3042000f, 0x28080,
73670x32c20100, 0x10400020, 0x2501821, 0x3c020020,
73680x43102b, 0x1440000e, 0x2402021, 0x2821,
73690x94820000, 0x24840002, 0xa22821, 0x83102b,
73700x1440fffb, 0x30a2ffff, 0x51c02, 0x622821,
73710x51c02, 0x30a2ffff, 0x10000009, 0x622821,
73720x8f470148, 0x8f420110, 0x102842, 0x3c060020,
73730x40f809, 0xafa80040, 0x3045ffff, 0x8fa80040,
73740x50a00001, 0x3405ffff, 0x8faa002c, 0x354a0002,
73750x10000002, 0xafaa002c, 0x2821, 0x32c20080,
73760x10400090, 0xa6a50010, 0x26430009, 0x3c02001f,
73770x3442ffff, 0x43102b, 0x10400003, 0x0,
73780x8f420148, 0x621823, 0x90660000, 0x30c200ff,
73790x38430006, 0x2c630001, 0x38420011, 0x2c420001,
73800x621825, 0x1060007f, 0x24020800, 0x8821,
73810x97a3003e, 0x1462000f, 0x2602021, 0x96710000,
73820x96620002, 0x96630004, 0x96640006, 0x2228821,
73830x2238821, 0x2248821, 0x96620008, 0x9663000a,
73840x9664000c, 0x2228821, 0x2238821, 0x10000007,
73850x2248821, 0x94820000, 0x24840002, 0x2228821,
73860x92102b, 0x1440fffb, 0x0, 0x111c02,
73870x3222ffff, 0x628821, 0x111c02, 0x3222ffff,
73880x628821, 0x32c20200, 0x10400003, 0x26440006,
73890x1000003e, 0x8021, 0x3c05001f, 0x34a5ffff,
73900xa4102b, 0x10400003, 0x0, 0x8f420148,
73910x822023, 0x94820000, 0x30421fff, 0x10400004,
73920x2644000c, 0x96420002, 0x10000030, 0x508023,
73930x96420002, 0x26430014, 0x508023, 0x3c020020,
73940x43102b, 0x1440000a, 0xd08021, 0x9642000c,
73950x2028021, 0x9642000e, 0x96430010, 0x96440012,
73960x2028021, 0x2038021, 0x10000020, 0x2048021,
73970xa4102b, 0x10400003, 0x0, 0x8f420148,
73980x822023, 0x94820000, 0x24840002, 0x2028021,
73990xa4102b, 0x10400003, 0x0, 0x8f420148,
74000x822023, 0x94820000, 0x24840002, 0x2028021,
74010xa4102b, 0x10400003, 0x0, 0x8f420148,
74020x822023, 0x94820000, 0x24840002, 0x2028021,
74030xa4102b, 0x10400003, 0x0, 0x8f420148,
74040x822023, 0x94820000, 0x2028021, 0x3c020100,
74050x2c21024, 0x1040000e, 0x0, 0x8faa002c,
74060x31420004, 0x1040000a, 0x0, 0x9504000e,
74070x2642021, 0xc003eec, 0x2484fffc, 0x3042ffff,
74080x2228821, 0x111c02, 0x3222ffff, 0x628821,
74090x8faa0024, 0x1518823, 0x111402, 0x2228821,
74100x2308821, 0x111402, 0x2228821, 0x3231ffff,
74110x52200001, 0x3411ffff, 0x8faa002c, 0x354a0001,
74120xafaa002c, 0xa6b10012, 0x97aa002e, 0xa6aa000e,
74130x8faa002c, 0x31420004, 0x10400002, 0x24091000,
74140x34098000, 0x8f480044, 0x8f4401a0, 0x8f4501a4,
74150xafa90010, 0x8f490044, 0x84140, 0x1001821,
74160xafa90014, 0x8f48000c, 0x2a03021, 0x24070020,
74170xafa80018, 0x8f48010c, 0x1021, 0xa32821,
74180xa3482b, 0x822021, 0x100f809, 0x892021,
74190x1440000b, 0x0, 0x8f820128, 0x3c040001,
74200x24846914, 0xafbe0014, 0xafa20010, 0x8f860124,
74210x8f870120, 0x3c050007, 0xc002b3b, 0x34a59920,
74220x8f420368, 0x2442ffff, 0xaf420368, 0x8f420044,
74230x8f430088, 0x24420001, 0x431024, 0xaf420044,
74240x8faa0034, 0x8f440368, 0x24020001, 0x15420006,
74250x24020002, 0x8f42035c, 0x2442ffff, 0xaf42035c,
74260x10000049, 0x8f42035c, 0x15420006, 0x0,
74270x8f420364, 0x2442ffff, 0xaf420364, 0x10000042,
74280x8f420364, 0x8f420360, 0x2442ffff, 0xaf420360,
74290x1000003d, 0x8f420360, 0x30621000, 0x10400005,
74300x30628000, 0x8f420078, 0x24420001, 0x10000036,
74310xaf420078, 0x10400034, 0x0, 0x8f420078,
74320x24420001, 0xaf420078, 0x8c030240, 0x43102b,
74330x1440002d, 0x24070008, 0x8f440168, 0x8f45016c,
74340x8f430044, 0x8f48000c, 0x8f860120, 0x24020040,
74350xafa20010, 0xafa30014, 0xafa80018, 0x8f42010c,
74360x40f809, 0x24c6001c, 0x14400011, 0x24020001,
74370x3c010001, 0x370821, 0xa02240f2, 0x8f820124,
74380xafa20010, 0x8f820128, 0x3c040001, 0x2484688c,
74390xafa20014, 0x8f460044, 0x8f870120, 0x3c050009,
74400xc002b3b, 0x34a51300, 0x1000000b, 0x0,
74410x8f420304, 0x24420001, 0xaf420304, 0x8f420304,
74420x8f420044, 0xaf42007c, 0x3c010001, 0x370821,
74430xa02040f2, 0xaf400078, 0x8f420318, 0x24420001,
74440xaf420318, 0x8f420318, 0x8fbf0060, 0x8fbe005c,
74450x8fb50058, 0x8fb30054, 0x8fb20050, 0x8fb1004c,
74460x8fb00048, 0x3e00008, 0x27bd0068, 0x3e00008,
74470x0, 0x0, 0x0, 0x8f42013c,
74480xaf8200c0, 0x8f42013c, 0xaf8200c4, 0x8f42013c,
74490xaf8200c8, 0x8f420138, 0xaf8200d0, 0x8f420138,
74500xaf8200d4, 0x8f420138, 0x3e00008, 0xaf8200d8,
74510x27bdffe0, 0x27840208, 0x24050200, 0xafbf0018,
74520xc002bbf, 0x24060008, 0x8c020204, 0xc004012,
74530xaf820210, 0x3c020001, 0x8c426d94, 0x30420002,
74540x1040000e, 0x2021, 0x8c060248, 0x24020002,
74550x3c010001, 0xac226d98, 0xc005104, 0x24050002,
74560x2021, 0x8c060248, 0x24020001, 0x3c010001,
74570xac226d98, 0x10000011, 0x24050001, 0x8c060248,
74580x24020004, 0x3c010001, 0xac226d98, 0xc005104,
74590x24050004, 0x3c020001, 0x8c426d94, 0x30420001,
74600x10400008, 0x24020001, 0x3c010001, 0xac226d98,
74610x2021, 0x24050001, 0x3c06601b, 0xc005104,
74620x0, 0x3c040001, 0x248469d0, 0x8f420150,
74630x8f430154, 0x3c050008, 0x8f460158, 0x21640,
74640x31940, 0x34630403, 0x431025, 0x633c0,
74650x461025, 0xaf82021c, 0xafa00010, 0xafa00014,
74660x8f86021c, 0x34a50200, 0xc002b3b, 0x3821,
74670x3c010001, 0xac206d90, 0x3c010001, 0xac206da8,
74680x8fbf0018, 0x3e00008, 0x27bd0020, 0x27bdffe0,
74690x3c050008, 0x34a50300, 0xafbf0018, 0xafa00010,
74700xafa00014, 0x8f860200, 0x3c040001, 0x248469dc,
74710xc002b3b, 0x3821, 0x8f420410, 0x24420001,
74720xaf420410, 0x8f420410, 0x8fbf0018, 0x3e00008,
74730x27bd0020, 0x27bdffd8, 0xafbf0020, 0xafb1001c,
74740xafb00018, 0x8f4203a4, 0x24420001, 0xaf4203a4,
74750x8f4203a4, 0x8f900220, 0x8f8200e0, 0xafa20010,
74760x8f8200e4, 0xafa20014, 0x8f8600c4, 0x8f8700c8,
74770x3c040001, 0x248469e8, 0xc002b3b, 0x2002821,
74780x3c044000, 0x2041024, 0x504000b4, 0x3c040100,
74790x8f4203bc, 0x24420001, 0xaf4203bc, 0x8f4203bc,
74800x8f8700c4, 0x8f8300c8, 0x8f420148, 0x671823,
74810x43102b, 0x10400003, 0x0, 0x8f420148,
74820x621821, 0x10600005, 0x0, 0x8f42014c,
74830x43102b, 0x1040000b, 0x0, 0x8f8200e0,
74840x8f430124, 0xaf42011c, 0xaf430114, 0x8f820220,
74850x3c0308ff, 0x3463fffb, 0x431024, 0x100000ce,
74860x441025, 0x8f820220, 0x3c0308ff, 0x3463ffff,
74870x431024, 0x34420004, 0xaf820220, 0x8f8200e0,
74880x8f430124, 0xaf42011c, 0xaf430114, 0x8f8600c8,
74890x8f840120, 0x8f830124, 0x10000005, 0x2821,
74900x14620002, 0x24620020, 0x27624800, 0x401821,
74910x1064000c, 0x30a200ff, 0x8c620018, 0x30420003,
74920x1040fff7, 0x27624fe0, 0x8f4203d0, 0x24050001,
74930x24420001, 0xaf4203d0, 0x8f4203d0, 0x8c660008,
74940x30a200ff, 0x14400058, 0x0, 0x934205c4,
74950x14400055, 0x0, 0x8f8700c4, 0x8f8800e0,
74960x8f8400e4, 0x2402fff8, 0x1024024, 0x1041023,
74970x218c3, 0x4620001, 0x24630200, 0x10600005,
74980x24020001, 0x10620009, 0x0, 0x1000001f,
74990x0, 0x8f4203c0, 0xe03021, 0x24420001,
75000xaf4203c0, 0x10000040, 0x8f4203c0, 0x8f4203c4,
75010x24420001, 0xaf4203c4, 0x8c860000, 0x8f420148,
75020x8f4303c4, 0xe61823, 0x43102b, 0x10400004,
75030x2c62233f, 0x8f420148, 0x621821, 0x2c62233f,
75040x14400031, 0x0, 0x8f42020c, 0x24420001,
75050xaf42020c, 0x8f42020c, 0xe03021, 0x24820008,
75060xaf8200e4, 0x10000028, 0xaf8200e8, 0x8f4203c8,
75070x24420001, 0xaf4203c8, 0x8f4203c8, 0x8c850000,
75080x8f420148, 0xa71823, 0x43102b, 0x10400003,
75090x0, 0x8f420148, 0x621821, 0x8f42014c,
75100x43102b, 0x5440000a, 0xa03021, 0x8f42020c,
75110x24420001, 0xaf42020c, 0x8f42020c, 0x24820008,
75120xaf8200e4, 0x8f8400e4, 0x1488ffec, 0xaf8400e8,
75130x1488000d, 0x27623000, 0x14820002, 0x2482fff8,
75140x27623ff8, 0x94430006, 0x3c02001f, 0x3442ffff,
75150xc33021, 0x46102b, 0x10400003, 0x0,
75160x8f420148, 0xc23023, 0xaf8600c8, 0x8f8300c4,
75170x8f420148, 0xc31823, 0x43102b, 0x10400003,
75180x0, 0x8f420148, 0x621821, 0x10600005,
75190x0, 0x8f42014c, 0x43102b, 0x50400008,
75200x3c02fdff, 0x8f820220, 0x3c0308ff, 0x3463fffb,
75210x431024, 0x3c034000, 0x1000003f, 0x431025,
75220x8f4303cc, 0x3442ffff, 0x282a024, 0x24630001,
75230xaf4303cc, 0x10000039, 0x8f4203cc, 0x2041024,
75240x1040000e, 0x3c110200, 0x8f4203a8, 0x24420001,
75250xaf4203a8, 0x8f4203a8, 0x8f820220, 0x3c0308ff,
75260x3463ffff, 0x431024, 0x441025, 0xc003daf,
75270xaf820220, 0x10000029, 0x0, 0x2111024,
75280x50400008, 0x3c110400, 0x8f4203ac, 0x24420001,
75290xaf4203ac, 0xc003daf, 0x8f4203ac, 0x10000019,
75300x0, 0x2111024, 0x1040001c, 0x0,
75310x8f830224, 0x24021402, 0x14620009, 0x3c050008,
75320x3c040001, 0x248469f4, 0xafa00010, 0xafa00014,
75330x8f860224, 0x34a50500, 0xc002b3b, 0x3821,
75340x8f4203b0, 0x24420001, 0xaf4203b0, 0x8f4203b0,
75350x8f820220, 0x2002021, 0x34420002, 0xc004e9c,
75360xaf820220, 0x8f820220, 0x3c0308ff, 0x3463ffff,
75370x431024, 0x511025, 0xaf820220, 0x8fbf0020,
75380x8fb1001c, 0x8fb00018, 0x3e00008, 0x27bd0028,
75390x3e00008, 0x0, 0x3c020001, 0x8c426da8,
75400x27bdffb0, 0xafbf0048, 0xafbe0044, 0xafb50040,
75410xafb3003c, 0xafb20038, 0xafb10034, 0x1040000f,
75420xafb00030, 0x3c040001, 0x24846a00, 0x3c050008,
75430xafa00010, 0xafa00014, 0x8f860220, 0x34a50600,
75440x24020001, 0x3c010001, 0xac206da8, 0x3c010001,
75450xac226d9c, 0xc002b3b, 0x3821, 0x3c037fff,
75460x8c020268, 0x3463ffff, 0x3c04fdff, 0x431024,
75470xac020268, 0x8f420004, 0x3484ffff, 0x30420002,
75480x10400092, 0x284a024, 0x3c040600, 0x34842000,
75490x8f420004, 0x2821, 0x2403fffd, 0x431024,
75500xaf420004, 0xafa40020, 0x8f5e0018, 0x27aa0020,
75510x240200ff, 0x13c20002, 0xafaa002c, 0x27c50001,
75520x8c020228, 0xa09021, 0x1642000e, 0x1e38c0,
75530x8f42033c, 0x24420001, 0xaf42033c, 0x8f42033c,
75540x8c020228, 0x3c040001, 0x24846998, 0x3c050009,
75550xafa00014, 0xafa20010, 0x8fa60020, 0x1000006d,
75560x34a50500, 0xf71021, 0x8fa30020, 0x8fa40024,
75570xac4304c0, 0xac4404c4, 0x8f830054, 0x8f820054,
75580x247003e8, 0x2021023, 0x2c4203e9, 0x1040001b,
75590x9821, 0xe08821, 0x263504c0, 0x8f440178,
75600x8f45017c, 0x2201821, 0x240a0004, 0xafaa0010,
75610xafb20014, 0x8f48000c, 0x1021, 0x2f53021,
75620xafa80018, 0x8f48010c, 0x24070008, 0xa32821,
75630xa3482b, 0x822021, 0x100f809, 0x892021,
75640x54400006, 0x24130001, 0x8f820054, 0x2021023,
75650x2c4203e9, 0x1440ffe9, 0x0, 0x326200ff,
75660x54400017, 0xaf520018, 0x8f420378, 0x24420001,
75670xaf420378, 0x8f420378, 0x8f820120, 0x8faa002c,
75680xafa20010, 0x8f820124, 0x3c040001, 0x248469a4,
75690x3c050009, 0xafa20014, 0x8d460000, 0x10000035,
75700x34a50600, 0x8f420308, 0x24130001, 0x24420001,
75710xaf420308, 0x8f420308, 0x1000001e, 0x326200ff,
75720x8f830054, 0x8f820054, 0x247003e8, 0x2021023,
75730x2c4203e9, 0x10400016, 0x9821, 0x3c150020,
75740x24110010, 0x8f42000c, 0x8f440160, 0x8f450164,
75750x8f860120, 0xafb10010, 0xafb20014, 0x551025,
75760xafa20018, 0x8f42010c, 0x24070008, 0x40f809,
75770x24c6001c, 0x1440ffe3, 0x0, 0x8f820054,
75780x2021023, 0x2c4203e9, 0x1440ffee, 0x0,
75790x326200ff, 0x14400011, 0x0, 0x8f420378,
75800x24420001, 0xaf420378, 0x8f420378, 0x8f820120,
75810x8faa002c, 0xafa20010, 0x8f820124, 0x3c040001,
75820x248469ac, 0x3c050009, 0xafa20014, 0x8d460000,
75830x34a50700, 0xc002b3b, 0x3c03821, 0x8f4202ec,
75840x24420001, 0xaf4202ec, 0x8f4202ec, 0x8fbf0048,
75850x8fbe0044, 0x8fb50040, 0x8fb3003c, 0x8fb20038,
75860x8fb10034, 0x8fb00030, 0x3e00008, 0x27bd0050,
75870x3c020001, 0x8c426da8, 0x27bdffe0, 0x1440000d,
75880xafbf0018, 0x3c040001, 0x24846a0c, 0x3c050008,
75890xafa00010, 0xafa00014, 0x8f860220, 0x34a50700,
75900x24020001, 0x3c010001, 0xac226da8, 0xc002b3b,
75910x3821, 0x3c020004, 0x2c21024, 0x10400007,
75920x0, 0x8f820220, 0x3c0308ff, 0x3463ffff,
75930x431024, 0x34420008, 0xaf820220, 0x3c050001,
75940x8ca56d98, 0x24020001, 0x14a20007, 0x2021,
75950xc00529b, 0x24050001, 0xac02026c, 0x8c03026c,
75960x10000006, 0x3c020007, 0xc00529b, 0x2021,
75970xac020268, 0x8c030268, 0x3c020007, 0x621824,
75980x3c020002, 0x5062000d, 0x3c0205f5, 0x43102b,
75990x14400006, 0x3c020004, 0x3c020001, 0x10620009,
76000x3c020098, 0x1000000b, 0x0, 0x14620009,
76010x3c023b9a, 0x10000004, 0x3442ca00, 0x10000002,
76020x3442e100, 0x34429680, 0xaf4201fc, 0x8f4201fc,
76030xaee20064, 0x8fbf0018, 0x3e00008, 0x27bd0020,
76040x0, 0x0, 0x0, 0x86102b,
76050x50400001, 0x872023, 0xc41023, 0x24843,
76060x125102b, 0x1040001b, 0x91040, 0x824021,
76070x88102b, 0x10400007, 0x1821, 0x94820000,
76080x24840002, 0x621821, 0x88102b, 0x1440fffb,
76090x0, 0x602021, 0xc73023, 0xa91023,
76100x21040, 0xc22821, 0xc5102b, 0x10400007,
76110x1821, 0x94c20000, 0x24c60002, 0x621821,
76120xc5102b, 0x1440fffb, 0x0, 0x1000000d,
76130x832021, 0x51040, 0x822821, 0x85102b,
76140x10400007, 0x1821, 0x94820000, 0x24840002,
76150x621821, 0x85102b, 0x1440fffb, 0x0,
76160x602021, 0x41c02, 0x3082ffff, 0x622021,
76170x41c02, 0x3082ffff, 0x622021, 0x3e00008,
76180x3082ffff, 0x3e00008, 0x0, 0x802821,
76190x30a20001, 0x1040002b, 0x3c03001f, 0x3463ffff,
76200x24a20004, 0x62102b, 0x54400007, 0x65102b,
76210x90a20001, 0x90a40003, 0x90a30000, 0x90a50002,
76220x1000002a, 0x441021, 0x10400003, 0x0,
76230x8f420148, 0xa22823, 0x90a40000, 0x24a50001,
76240x65102b, 0x10400003, 0x0, 0x8f420148,
76250xa22823, 0x90a20000, 0x24a50001, 0x21200,
76260x822021, 0x65102b, 0x10400003, 0x0,
76270x8f420148, 0xa22823, 0x90a20000, 0x24a50001,
76280x822021, 0x65102b, 0x10400003, 0x0,
76290x8f420148, 0xa22823, 0x90a20000, 0x1000002d,
76300x21200, 0x3463ffff, 0x24a20004, 0x62102b,
76310x5440000a, 0x65102b, 0x90a20000, 0x90a40002,
76320x90a30001, 0x90a50003, 0x441021, 0x21200,
76330x651821, 0x10000020, 0x432021, 0x10400003,
76340x0, 0x8f420148, 0xa22823, 0x90a20000,
76350x24a50001, 0x22200, 0x65102b, 0x10400003,
76360x0, 0x8f420148, 0xa22823, 0x90a20000,
76370x24a50001, 0x822021, 0x65102b, 0x10400003,
76380x0, 0x8f420148, 0xa22823, 0x90a20000,
76390x24a50001, 0x21200, 0x822021, 0x65102b,
76400x10400003, 0x0, 0x8f420148, 0xa22823,
76410x90a20000, 0x822021, 0x41c02, 0x3082ffff,
76420x622021, 0x41c02, 0x3082ffff, 0x622021,
76430x3e00008, 0x3082ffff, 0x0, 0x8f820220,
76440x34420002, 0xaf820220, 0x3c020002, 0x8c428ff8,
76450x30424000, 0x10400054, 0x24040001, 0x8f820200,
76460x24067fff, 0x8f830200, 0x30450002, 0x2402fffd,
76470x621824, 0xaf830200, 0xaf840204, 0x8f830054,
76480x8f820054, 0x10000002, 0x24630001, 0x8f820054,
76490x621023, 0x2c420002, 0x1440fffc, 0x0,
76500x8f820224, 0x1444004d, 0x42040, 0xc4102b,
76510x1040fff1, 0x0, 0x8f820200, 0x451025,
76520xaf820200, 0x8f820220, 0x34428000, 0xaf820220,
76530x8f830054, 0x8f820054, 0x10000002, 0x24630001,
76540x8f820054, 0x621023, 0x2c420002, 0x1440fffc,
76550x0, 0x8f820220, 0x3c030004, 0x431024,
76560x1440000f, 0x0, 0x8f820220, 0x3c03ffff,
76570x34637fff, 0x431024, 0xaf820220, 0x8f830054,
76580x8f820054, 0x10000002, 0x24630001, 0x8f820054,
76590x621023, 0x2c420002, 0x1440fffc, 0x0,
76600x8f820220, 0x3c030004, 0x431024, 0x1440000d,
76610x0, 0x8f820220, 0x34428000, 0xaf820220,
76620x8f830054, 0x8f820054, 0x10000002, 0x24630001,
76630x8f820054, 0x621023, 0x2c420002, 0x1440fffc,
76640x0, 0x8f820220, 0x3c030004, 0x431024,
76650x1040001b, 0x1021, 0x8f830220, 0x24020001,
76660x10000015, 0x3c04f700, 0x8f820220, 0x3c04f700,
76670x441025, 0xaf820220, 0x8f820220, 0x2403fffd,
76680x431024, 0xaf820220, 0x8f820220, 0x3c030300,
76690x431024, 0x14400003, 0x0, 0x10000008,
76700x1021, 0x8f820220, 0x34420002, 0xaf820220,
76710x8f830220, 0x24020001, 0x641825, 0xaf830220,
76720x3e00008, 0x0, 0x2021, 0x3c050100,
76730x24020001, 0xaf80021c, 0xaf820200, 0xaf820220,
76740x27625000, 0xaf8200c0, 0x27625000, 0xaf8200c4,
76750x27625000, 0xaf8200c8, 0x27625000, 0xaf8200d0,
76760x27625000, 0xaf8200d4, 0x27625000, 0xaf8200d8,
76770x27623000, 0xaf8200e0, 0x27623000, 0xaf8200e4,
76780x27623000, 0xaf8200e8, 0x27622800, 0xaf8200f0,
76790x27622800, 0xaf8200f4, 0x27622800, 0xaf8200f8,
76800x418c0, 0x24840001, 0x3631021, 0xac453004,
76810x3631021, 0xac403000, 0x28820200, 0x1440fff9,
76820x418c0, 0x2021, 0x418c0, 0x24840001,
76830x3631021, 0xac402804, 0x3631021, 0xac402800,
76840x28820100, 0x1440fff9, 0x418c0, 0xaf80023c,
76850x24030080, 0x24040100, 0xac600000, 0x24630004,
76860x64102b, 0x5440fffd, 0xac600000, 0x8f830040,
76870x3c02f000, 0x621824, 0x3c025000, 0x1062000c,
76880x43102b, 0x14400006, 0x3c026000, 0x3c024000,
76890x10620008, 0x24020800, 0x10000008, 0x0,
76900x10620004, 0x24020800, 0x10000004, 0x0,
76910x24020700, 0x3c010001, 0xac226dac, 0x3e00008,
76920x0, 0x3c020001, 0x8c426dbc, 0x27bdffd0,
76930xafbf002c, 0xafb20028, 0xafb10024, 0xafb00020,
76940x3c010001, 0x10400005, 0xac206d94, 0xc004d9e,
76950x0, 0x3c010001, 0xac206dbc, 0x8f830054,
76960x8f820054, 0x10000002, 0x24630064, 0x8f820054,
76970x621023, 0x2c420065, 0x1440fffc, 0x0,
76980xc004db9, 0x0, 0x24040001, 0x2821,
76990x27a60018, 0x34028000, 0xc0045be, 0xa7a20018,
77000x8f830054, 0x8f820054, 0x10000002, 0x24630064,
77010x8f820054, 0x621023, 0x2c420065, 0x1440fffc,
77020x24040001, 0x24050001, 0xc00457c, 0x27a60018,
77030x8f830054, 0x8f820054, 0x10000002, 0x24630064,
77040x8f820054, 0x621023, 0x2c420065, 0x1440fffc,
77050x24040001, 0x24050001, 0xc00457c, 0x27a60018,
77060x8f830054, 0x8f820054, 0x10000002, 0x24630064,
77070x8f820054, 0x621023, 0x2c420065, 0x1440fffc,
77080x24040001, 0x3c060001, 0x24c66f24, 0xc00457c,
77090x24050002, 0x8f830054, 0x8f820054, 0x10000002,
77100x24630064, 0x8f820054, 0x621023, 0x2c420065,
77110x1440fffc, 0x24040001, 0x24050003, 0x3c100001,
77120x26106f26, 0xc00457c, 0x2003021, 0x97a60018,
77130x3c070001, 0x94e76f24, 0x3c040001, 0x24846ae0,
77140xafa00014, 0x96020000, 0x3c05000d, 0x34a50100,
77150xc002b3b, 0xafa20010, 0x97a20018, 0x1040004d,
77160x24036040, 0x96020000, 0x3042fff0, 0x1443000c,
77170x24020020, 0x3c030001, 0x94636f24, 0x1462000b,
77180x24027830, 0x24020003, 0x3c010001, 0xac226d94,
77190x24020005, 0x3c010001, 0x1000003f, 0xac226f34,
77200x3c030001, 0x94636f24, 0x24027830, 0x1462000c,
77210x24030010, 0x3c020001, 0x94426f26, 0x3042fff0,
77220x14430007, 0x24020003, 0x3c010001, 0xac226d94,
77230x24020006, 0x3c010001, 0x1000002f, 0xac226f34,
77240x3c020001, 0x8c426d94, 0x3c030001, 0x94636f24,
77250x34420001, 0x3c010001, 0xac226d94, 0x24020015,
77260x1462000b, 0x0, 0x3c020001, 0x94426f26,
77270x3042fff0, 0x3843f420, 0x2c630001, 0x3842f430,
77280x2c420001, 0x621825, 0x1460001b, 0x24020003,
77290x3c030001, 0x94636f24, 0x24027810, 0x14620016,
77300x24020002, 0x3c020001, 0x94426f26, 0x3042fff0,
77310x14400011, 0x24020002, 0x1000000f, 0x24020004,
77320x3c020001, 0x8c426d94, 0x34420008, 0x3c010001,
77330xac226d94, 0x1000005e, 0x24020004, 0x3c020001,
77340x8c426d94, 0x34420004, 0x3c010001, 0x100000af,
77350xac226d94, 0x24020001, 0x3c010001, 0xac226f40,
77360x3c020001, 0x8c426d94, 0x30420002, 0x144000b2,
77370x3c09fff0, 0x24020e00, 0xaf820238, 0x8f840054,
77380x8f820054, 0x24030008, 0x3c010001, 0xac236d98,
77390x10000002, 0x248401f4, 0x8f820054, 0x821023,
77400x2c4201f5, 0x1440fffc, 0x3c0200c8, 0x344201fb,
77410xaf820238, 0x8f830054, 0x8f820054, 0x10000002,
77420x246301f4, 0x8f820054, 0x621023, 0x2c4201f5,
77430x1440fffc, 0x8021, 0x24120001, 0x24110009,
77440xc004482, 0x0, 0x3c010001, 0xac326db4,
77450xc004547, 0x0, 0x3c020001, 0x8c426db4,
77460x1451fffb, 0x3c0200c8, 0x344201f6, 0xaf820238,
77470x8f830054, 0x8f820054, 0x10000002, 0x2463000a,
77480x8f820054, 0x621023, 0x2c42000b, 0x1440fffc,
77490x0, 0x8f820220, 0x24040001, 0x34420002,
77500xaf820220, 0x8f830200, 0x24057fff, 0x2402fffd,
77510x621824, 0xaf830200, 0xaf840204, 0x8f830054,
77520x8f820054, 0x10000002, 0x24630001, 0x8f820054,
77530x621023, 0x2c420002, 0x1440fffc, 0x0,
77540x8f820224, 0x14440005, 0x34028000, 0x42040,
77550xa4102b, 0x1040fff0, 0x34028000, 0x1082ffa0,
77560x26100001, 0x2e020014, 0x1440ffcd, 0x24020004,
77570x3c010001, 0xac226d98, 0x8021, 0x24120009,
77580x3c11ffff, 0x36313f7f, 0xc004482, 0x0,
77590x24020001, 0x3c010001, 0xac226db4, 0xc004547,
77600x0, 0x3c020001, 0x8c426db4, 0x1452fffb,
77610x0, 0x8f820044, 0x511024, 0x34425080,
77620xaf820044, 0x8f830054, 0x8f820054, 0x10000002,
77630x2463000a, 0x8f820054, 0x621023, 0x2c42000b,
77640x1440fffc, 0x0, 0x8f820044, 0x511024,
77650x3442f080, 0xaf820044, 0x8f830054, 0x8f820054,
77660x10000002, 0x2463000a, 0x8f820054, 0x621023,
77670x2c42000b, 0x1440fffc, 0x0, 0x8f820220,
77680x3c03f700, 0x431025, 0xaf820220, 0x8f830054,
77690x8f820054, 0x10000002, 0x24630064, 0x8f820054,
77700x621023, 0x2c420065, 0x1440fffc, 0x0,
77710x8f820220, 0x24040001, 0x34420002, 0xaf820220,
77720x8f830200, 0x24057fff, 0x2402fffd, 0x621824,
77730xaf830200, 0xaf840204, 0x8f830054, 0x8f820054,
77740x10000002, 0x24630001, 0x8f820054, 0x621023,
77750x2c420002, 0x1440fffc, 0x0, 0x8f820224,
77760x14440005, 0x34028000, 0x42040, 0xa4102b,
77770x1040fff0, 0x34028000, 0x1082ff50, 0x26100001,
77780x2e020064, 0x1440ffb0, 0x0, 0x3c020001,
77790x8c426d94, 0x30420004, 0x14400007, 0x3c09fff0,
77800x8f820044, 0x3c03ffff, 0x34633f7f, 0x431024,
77810xaf820044, 0x3c09fff0, 0x3529bdc0, 0x3c060001,
77820x8cc66d94, 0x3c040001, 0x24846ae0, 0x24020001,
77830x3c010001, 0xac226d9c, 0x8f820054, 0x3c070001,
77840x8ce76f40, 0x3c030001, 0x94636f24, 0x3c080001,
77850x95086f26, 0x3c05000d, 0x34a50100, 0x3c010001,
77860xac206d98, 0x491021, 0x3c010001, 0xac226f30,
77870xafa30010, 0xc002b3b, 0xafa80014, 0x8fbf002c,
77880x8fb20028, 0x8fb10024, 0x8fb00020, 0x3e00008,
77890x27bd0030, 0x27bdffe8, 0x3c050001, 0x8ca56d98,
77900x24060004, 0x24020001, 0x14a20014, 0xafbf0010,
77910x3c020002, 0x8c428ffc, 0x30428000, 0x10400005,
77920x3c04000f, 0x3c030001, 0x8c636f40, 0x10000005,
77930x34844240, 0x3c040004, 0x3c030001, 0x8c636f40,
77940x348493e0, 0x24020005, 0x14620016, 0x0,
77950x3c04003d, 0x10000013, 0x34840900, 0x3c020002,
77960x8c428ff8, 0x30428000, 0x10400005, 0x3c04001e,
77970x3c030001, 0x8c636f40, 0x10000005, 0x34848480,
77980x3c04000f, 0x3c030001, 0x8c636f40, 0x34844240,
77990x24020005, 0x14620003, 0x0, 0x3c04007a,
78000x34841200, 0x3c020001, 0x8c426f30, 0x8f830054,
78010x441021, 0x431023, 0x44102b, 0x1440004c,
78020x0, 0x3c020001, 0x8c426da0, 0x14400048,
78030x0, 0x3c010001, 0x10c00025, 0xac206db0,
78040x3c090001, 0x8d296d94, 0x24070001, 0x3c044000,
78050x3c080002, 0x25088ffc, 0x250afffc, 0x52842,
78060x14a00002, 0x24c6ffff, 0x24050008, 0xa91024,
78070x10400010, 0x0, 0x14a70008, 0x0,
78080x8d020000, 0x441024, 0x1040000a, 0x0,
78090x3c010001, 0x10000007, 0xac256db0, 0x8d420000,
78100x441024, 0x10400003, 0x0, 0x3c010001,
78110xac276db0, 0x3c020001, 0x8c426db0, 0x6182b,
78120x2c420001, 0x431024, 0x5440ffe5, 0x52842,
78130x8f820054, 0x3c030001, 0x8c636db0, 0x3c010001,
78140xac226f30, 0x1060003b, 0x24020005, 0x3c030001,
78150x8c636f40, 0x3c010001, 0xac256d98, 0x14620012,
78160x24020001, 0x3c020002, 0x8c428ff8, 0x3c032000,
78170x34635000, 0x431024, 0x14400006, 0x24020001,
78180x3c010001, 0xac206f1c, 0x3c010001, 0xac226d98,
78190x24020001, 0x3c010001, 0xac226e24, 0x3c010001,
78200xac226da4, 0x24020001, 0x3c010001, 0xac226d9c,
78210x3c020001, 0x8c426db0, 0x1040001e, 0x0,
78220x3c020001, 0x8c426d9c, 0x10400008, 0x24020001,
78230x3c010001, 0xac206d9c, 0xaee204b8, 0x3c010001,
78240xac206e1c, 0x3c010001, 0xac226dd4, 0x8ee304b8,
78250x24020008, 0x10620005, 0x24020001, 0xc004239,
78260x0, 0x1000000b, 0x0, 0x3c030001,
78270x8c636d98, 0x10620007, 0x2402000e, 0x3c030002,
78280x8c638f90, 0x10620003, 0x0, 0xc004e9c,
78290x8f840220, 0x8fbf0010, 0x3e00008, 0x27bd0018,
78300x27bdffe0, 0x3c03fdff, 0x3c040001, 0x8c846d98,
78310x3c020001, 0x8c426dc0, 0x3463ffff, 0x283a024,
78320x14820006, 0xafbf0018, 0x8ee304b8, 0x3c020001,
78330x8c426dc4, 0x10620006, 0x0, 0x8ee204b8,
78340x3c010001, 0xac246dc0, 0x3c010001, 0xac226dc4,
78350x3c030001, 0x8c636d98, 0x24020002, 0x1062019c,
78360x2c620003, 0x10400005, 0x24020001, 0x1062000a,
78370x0, 0x10000226, 0x0, 0x24020004,
78380x106200b6, 0x24020008, 0x1062010a, 0x24020001,
78390x1000021f, 0x0, 0x8ee204b8, 0x2443ffff,
78400x2c620008, 0x1040021c, 0x31080, 0x3c010001,
78410x220821, 0x8c226af8, 0x400008, 0x0,
78420x3c030001, 0x8c636f40, 0x24020005, 0x14620010,
78430x0, 0x3c020001, 0x8c426da4, 0x10400008,
78440x24020003, 0xc004482, 0x0, 0x24020002,
78450xaee204b8, 0x3c010001, 0x10000002, 0xac206da4,
78460xaee204b8, 0x3c010001, 0x10000203, 0xac206d30,
78470xc004482, 0x0, 0x3c020001, 0x8c426da4,
78480x3c010001, 0xac206d30, 0x1440017a, 0x24020002,
78490x1000019d, 0x24020007, 0x3c030001, 0x8c636f40,
78500x24020005, 0x14620003, 0x24020001, 0x3c010001,
78510xac226dd0, 0xc0045ff, 0x0, 0x3c030001,
78520x8c636dd0, 0x10000174, 0x24020011, 0x3c050001,
78530x8ca56d98, 0x3c060002, 0x8cc68ffc, 0xc005104,
78540x2021, 0x24020005, 0x3c010001, 0xac206da4,
78550x100001e1, 0xaee204b8, 0x3c040001, 0x24846aec,
78560x3c05000f, 0x34a50100, 0x3021, 0x3821,
78570xafa00010, 0xc002b3b, 0xafa00014, 0x100001d6,
78580x0, 0x8f820220, 0x3c030004, 0x431024,
78590x14400175, 0x24020007, 0x8f830054, 0x3c020001,
78600x8c426f28, 0x2463d8f0, 0x431023, 0x2c422710,
78610x14400003, 0x24020001, 0x3c010001, 0xac226d9c,
78620x3c020002, 0x8c428ffc, 0x30425000, 0x104001c2,
78630x0, 0x8f820220, 0x30428000, 0x1040017d,
78640x0, 0x10000175, 0x0, 0x3c050001,
78650x8ca56d98, 0xc00529b, 0x2021, 0xc00551b,
78660x2021, 0x3c030002, 0x8c638ff4, 0x46101b0,
78670x24020001, 0x3c020008, 0x621024, 0x10400006,
78680x0, 0x8f820214, 0x3c03ffff, 0x431024,
78690x10000005, 0x3442251f, 0x8f820214, 0x3c03ffff,
78700x431024, 0x3442241f, 0xaf820214, 0x8f820220,
78710x3c030200, 0x34420002, 0xaf820220, 0x24020008,
78720xaee204b8, 0x8f820220, 0x283a025, 0x3c030004,
78730x431024, 0x14400016, 0x0, 0x3c020002,
78740x8c428ffc, 0x30425000, 0x1040000d, 0x0,
78750x8f820220, 0x30428000, 0x10400006, 0x0,
78760x8f820220, 0x3c03ffff, 0x34637fff, 0x10000003,
78770x431024, 0x8f820220, 0x34428000, 0xaf820220,
78780x8f820220, 0x3c03f700, 0x431025, 0xaf820220,
78790x3c030001, 0x8c636f40, 0x24020005, 0x1462000a,
78800x0, 0x3c020001, 0x94426f26, 0x24429fbc,
78810x2c420004, 0x10400004, 0x24040018, 0x24050002,
78820xc004ddb, 0x24060020, 0xc003e6d, 0x0,
78830x3c010001, 0x10000170, 0xac206e20, 0x8ee204b8,
78840x2443ffff, 0x2c620008, 0x1040016b, 0x31080,
78850x3c010001, 0x220821, 0x8c226b18, 0x400008,
78860x0, 0xc004547, 0x0, 0x3c030001,
78870x8c636db4, 0x100000e8, 0x24020009, 0x3c020002,
78880x8c428ff8, 0x30424000, 0x10400004, 0x0,
78890x8f820044, 0x10000006, 0x3442f080, 0x8f820044,
78900x3c03ffff, 0x34633f7f, 0x431024, 0x3442a080,
78910xaf820044, 0x8f830054, 0x100000ea, 0x24020004,
78920x8f830054, 0x3c020001, 0x8c426f28, 0x2463d8f0,
78930x431023, 0x2c422710, 0x14400147, 0x24020005,
78940x100000d8, 0x0, 0x8f820220, 0x3c03f700,
78950x431025, 0xaf820220, 0xaf800204, 0x3c010002,
78960x100000d6, 0xac208fe0, 0x8f830054, 0x3c020001,
78970x8c426f28, 0x2463fff6, 0x431023, 0x2c42000a,
78980x14400135, 0x24020007, 0x100000d7, 0x0,
78990xc003f50, 0x0, 0x1040012d, 0x24020001,
79000x8f820214, 0x3c03ffff, 0x3c040001, 0x8c846f1c,
79010x431024, 0x3442251f, 0xaf820214, 0x24020008,
79020x10800005, 0xaee204b8, 0x3c020001, 0x8c426e44,
79030x10400064, 0x24020001, 0x8f820220, 0x3c030008,
79040x431024, 0x1040006a, 0x3c020200, 0x10000078,
79050x0, 0x8ee204b8, 0x2443ffff, 0x2c620007,
79060x10400115, 0x31080, 0x3c010001, 0x220821,
79070x8c226b38, 0x400008, 0x0, 0xc003daf,
79080x0, 0x3c010001, 0xac206d9c, 0xaf800204,
79090x3c010002, 0xc004482, 0xac208fe0, 0x24020001,
79100x3c010001, 0xac226db4, 0x24020002, 0x10000102,
79110xaee204b8, 0xc004547, 0x0, 0x3c030001,
79120x8c636db4, 0x10000084, 0x24020009, 0x3c020002,
79130x8c428ff8, 0x30424000, 0x10400003, 0x3c0200c8,
79140x10000002, 0x344201f6, 0x344201fe, 0xaf820238,
79150x8f830054, 0x1000008b, 0x24020004, 0x8f830054,
79160x3c020001, 0x8c426f28, 0x2463d8f0, 0x431023,
79170x2c422710, 0x144000e8, 0x24020005, 0x10000079,
79180x0, 0x8f820220, 0x3c03f700, 0x431025,
79190xaf820220, 0xaf800204, 0x3c010002, 0x10000077,
79200xac208fe0, 0x8f830054, 0x3c020001, 0x8c426f28,
79210x2463fff6, 0x431023, 0x2c42000a, 0x144000d6,
79220x24020007, 0x10000078, 0x0, 0xc003f50,
79230x0, 0x104000ce, 0x24020001, 0x8f820214,
79240x3c03ffff, 0x3c040001, 0x8c846f1c, 0x431024,
79250x3442251f, 0xaf820214, 0x24020008, 0x1080000f,
79260xaee204b8, 0x3c020001, 0x8c426e44, 0x1440000b,
79270x0, 0x8f820220, 0x34420002, 0xaf820220,
79280x24020001, 0x3c010002, 0xac228f90, 0xc004e9c,
79290x8f840220, 0x10000016, 0x0, 0x8f820220,
79300x3c030008, 0x431024, 0x14400011, 0x3c020200,
79310x282a025, 0x2402000e, 0x3c010002, 0xac228f90,
79320xc00551b, 0x2021, 0x8f820220, 0x34420002,
79330xc003e6d, 0xaf820220, 0x3c050001, 0x8ca56d98,
79340xc00529b, 0x2021, 0x100000a3, 0x0,
79350x3c020001, 0x8c426e44, 0x1040009f, 0x0,
79360x3c020001, 0x8c426e40, 0x2442ffff, 0x3c010001,
79370xac226e40, 0x14400098, 0x24020002, 0x3c010001,
79380xac206e44, 0x3c010001, 0x10000093, 0xac226e40,
79390x8ee204b8, 0x2443ffff, 0x2c620007, 0x1040008e,
79400x31080, 0x3c010001, 0x220821, 0x8c226b58,
79410x400008, 0x0, 0x3c020001, 0x8c426da4,
79420x10400018, 0x24020005, 0xc004482, 0x0,
79430x24020002, 0xaee204b8, 0x3c010001, 0x1000007e,
79440xac206da4, 0xc004963, 0x0, 0x3c030001,
79450x8c636dd4, 0x24020006, 0x14620077, 0x24020003,
79460x10000075, 0xaee204b8, 0x3c050001, 0x8ca56d98,
79470x3c060002, 0x8cc68ff8, 0xc005104, 0x2021,
79480x24020005, 0x1000006c, 0xaee204b8, 0x8f820220,
79490x3c03f700, 0x431025, 0xaf820220, 0x8f830054,
79500x24020006, 0xaee204b8, 0x3c010001, 0x10000062,
79510xac236f28, 0x8f820220, 0x3c030004, 0x431024,
79520x10400003, 0x24020007, 0x1000005b, 0xaee204b8,
79530x8f830054, 0x3c020001, 0x8c426f28, 0x2463d8f0,
79540x431023, 0x2c422710, 0x14400003, 0x24020001,
79550x3c010001, 0xac226d9c, 0x3c020002, 0x8c428ff8,
79560x30425000, 0x1040004c, 0x0, 0x8f820220,
79570x30428000, 0x10400007, 0x0, 0x8f820220,
79580x3c03ffff, 0x34637fff, 0x431024, 0x10000042,
79590xaf820220, 0x8f820220, 0x34428000, 0x1000003e,
79600xaf820220, 0x3c050001, 0x8ca56d98, 0xc00529b,
79610x2021, 0xc00551b, 0x2021, 0x3c020002,
79620x8c428ff0, 0x4410032, 0x24020001, 0x8f820214,
79630x3c03ffff, 0x431024, 0x3442251f, 0xaf820214,
79640x24020008, 0xaee204b8, 0x8f820220, 0x34420002,
79650xaf820220, 0x8f820220, 0x3c030004, 0x431024,
79660x14400016, 0x0, 0x3c020002, 0x8c428ff8,
79670x30425000, 0x1040000d, 0x0, 0x8f820220,
79680x30428000, 0x10400006, 0x0, 0x8f820220,
79690x3c03ffff, 0x34637fff, 0x10000003, 0x431024,
79700x8f820220, 0x34428000, 0xaf820220, 0x8f820220,
79710x3c03f700, 0x431025, 0xaf820220, 0x3c020001,
79720x94426f26, 0x24429fbc, 0x2c420004, 0x10400004,
79730x24040018, 0x24050002, 0xc004ddb, 0x24060020,
79740xc003e6d, 0x0, 0x10000003, 0x0,
79750x3c010001, 0xac226d9c, 0x8fbf0018, 0x3e00008,
79760x27bd0020, 0x8f820200, 0x8f820220, 0x8f820220,
79770x34420004, 0xaf820220, 0x8f820200, 0x3c050001,
79780x8ca56d98, 0x34420004, 0xaf820200, 0x24020002,
79790x10a2004b, 0x2ca20003, 0x10400005, 0x24020001,
79800x10a2000a, 0x0, 0x100000b1, 0x0,
79810x24020004, 0x10a20072, 0x24020008, 0x10a20085,
79820x3c02f0ff, 0x100000aa, 0x0, 0x8f830050,
79830x3c02f0ff, 0x3442ffff, 0x3c040001, 0x8c846f40,
79840x621824, 0x3c020700, 0x621825, 0x24020e00,
79850x2484fffb, 0x2c840002, 0xaf830050, 0xaf850200,
79860xaf850220, 0x14800006, 0xaf820238, 0x8f820044,
79870x3c03ffff, 0x34633f7f, 0x431024, 0xaf820044,
79880x3c030001, 0x8c636f40, 0x24020005, 0x14620004,
79890x0, 0x8f820044, 0x34425000, 0xaf820044,
79900x3c020001, 0x8c426d88, 0x3c030001, 0x8c636f40,
79910x34420022, 0x2463fffc, 0x2c630002, 0x1460000c,
79920xaf820200, 0x3c020001, 0x8c426dac, 0x3c030001,
79930x8c636d90, 0x3c040001, 0x8c846d8c, 0x34428000,
79940x621825, 0x641825, 0x1000000a, 0x34620002,
79950x3c020001, 0x8c426d90, 0x3c030001, 0x8c636dac,
79960x3c040001, 0x8c846d8c, 0x431025, 0x441025,
79970x34420002, 0xaf820220, 0x1000002f, 0x24020001,
79980x24020e01, 0xaf820238, 0x8f830050, 0x3c02f0ff,
79990x3442ffff, 0x3c040001, 0x8c846f1c, 0x621824,
80000x3c020d00, 0x621825, 0x24020001, 0xaf830050,
80010xaf820200, 0xaf820220, 0x10800005, 0x3c033f00,
80020x3c020001, 0x8c426d80, 0x10000004, 0x34630070,
80030x3c020001, 0x8c426d80, 0x34630072, 0x431025,
80040xaf820200, 0x3c030001, 0x8c636d84, 0x3c02f700,
80050x621825, 0x3c020001, 0x8c426d90, 0x3c040001,
80060x8c846dac, 0x3c050001, 0x8ca56f40, 0x431025,
80070x441025, 0xaf820220, 0x24020005, 0x14a20006,
80080x24020001, 0x8f820044, 0x2403afff, 0x431024,
80090xaf820044, 0x24020001, 0x1000003d, 0xaf820238,
80100x8f830050, 0x3c02f0ff, 0x3442ffff, 0x3c040001,
80110x8c846f1c, 0x621824, 0x3c020a00, 0x621825,
80120x24020001, 0xaf830050, 0xaf820200, 0x1080001e,
80130xaf820220, 0x3c020001, 0x8c426e44, 0x1440001a,
80140x3c033f00, 0x3c020001, 0x8c426d80, 0x1000001a,
80150x346300e0, 0x8f830050, 0x3c040001, 0x8c846f1c,
80160x3442ffff, 0x621824, 0x1080000f, 0xaf830050,
80170x3c020001, 0x8c426e44, 0x1440000b, 0x3c043f00,
80180x3c030001, 0x8c636d80, 0x348400e0, 0x24020001,
80190xaf820200, 0xaf820220, 0x641825, 0xaf830200,
80200x10000008, 0x3c05f700, 0x3c020001, 0x8c426d80,
80210x3c033f00, 0x346300e2, 0x431025, 0xaf820200,
80220x3c05f700, 0x34a58000, 0x3c030001, 0x8c636d84,
80230x3c020001, 0x8c426d90, 0x3c040001, 0x8c846dac,
80240x651825, 0x431025, 0x441025, 0xaf820220,
80250x3e00008, 0x0, 0x3c030001, 0x8c636db4,
80260x3c020001, 0x8c426db8, 0x10620003, 0x24020002,
80270x3c010001, 0xac236db8, 0x1062001d, 0x2c620003,
80280x10400025, 0x24020001, 0x14620023, 0x24020004,
80290x3c030001, 0x8c636d98, 0x10620006, 0x24020008,
80300x1462000c, 0x3c0200c8, 0x344201fb, 0x10000009,
80310xaf820238, 0x24020e01, 0xaf820238, 0x8f820044,
80320x3c03ffff, 0x34633f7f, 0x431024, 0x34420080,
80330xaf820044, 0x8f830054, 0x24020002, 0x3c010001,
80340xac226db4, 0x3c010001, 0x1000000b, 0xac236f2c,
80350x8f830054, 0x3c020001, 0x8c426f2c, 0x2463d8f0,
80360x431023, 0x2c422710, 0x14400003, 0x24020009,
80370x3c010001, 0xac226db4, 0x3e00008, 0x0,
80380x0, 0x0, 0x0, 0x27bdffd8,
80390xafb20018, 0x809021, 0xafb3001c, 0xa09821,
80400xafb10014, 0xc08821, 0xafb00010, 0x8021,
80410xafbf0020, 0xa6200000, 0xc004d78, 0x24040001,
80420x26100001, 0x2e020020, 0x1440fffb, 0x0,
80430xc004d78, 0x2021, 0xc004d78, 0x24040001,
80440xc004d78, 0x24040001, 0xc004d78, 0x2021,
80450x24100010, 0x2501024, 0x10400002, 0x2021,
80460x24040001, 0xc004d78, 0x108042, 0x1600fffa,
80470x2501024, 0x24100010, 0x2701024, 0x10400002,
80480x2021, 0x24040001, 0xc004d78, 0x108042,
80490x1600fffa, 0x2701024, 0xc004db9, 0x34108000,
80500xc004db9, 0x0, 0xc004d58, 0x0,
80510x50400005, 0x108042, 0x96220000, 0x501025,
80520xa6220000, 0x108042, 0x1600fff7, 0x0,
80530xc004db9, 0x0, 0x8fbf0020, 0x8fb3001c,
80540x8fb20018, 0x8fb10014, 0x8fb00010, 0x3e00008,
80550x27bd0028, 0x27bdffd8, 0xafb10014, 0x808821,
80560xafb20018, 0xa09021, 0xafb3001c, 0xc09821,
80570xafb00010, 0x8021, 0xafbf0020, 0xc004d78,
80580x24040001, 0x26100001, 0x2e020020, 0x1440fffb,
80590x0, 0xc004d78, 0x2021, 0xc004d78,
80600x24040001, 0xc004d78, 0x2021, 0xc004d78,
80610x24040001, 0x24100010, 0x2301024, 0x10400002,
80620x2021, 0x24040001, 0xc004d78, 0x108042,
80630x1600fffa, 0x2301024, 0x24100010, 0x2501024,
80640x10400002, 0x2021, 0x24040001, 0xc004d78,
80650x108042, 0x1600fffa, 0x2501024, 0xc004d78,
80660x24040001, 0xc004d78, 0x2021, 0x34108000,
80670x96620000, 0x501024, 0x10400002, 0x2021,
80680x24040001, 0xc004d78, 0x108042, 0x1600fff8,
80690x0, 0xc004db9, 0x0, 0x8fbf0020,
80700x8fb3001c, 0x8fb20018, 0x8fb10014, 0x8fb00010,
80710x3e00008, 0x27bd0028, 0x3c040001, 0x8c846dd0,
80720x3c020001, 0x8c426e18, 0x27bdffd8, 0xafbf0020,
80730xafb1001c, 0x10820003, 0xafb00018, 0x3c010001,
80740xac246e18, 0x3c030001, 0x8c636f40, 0x24020005,
80750x14620005, 0x2483ffff, 0xc004963, 0x0,
80760x1000034c, 0x0, 0x2c620013, 0x10400349,
80770x31080, 0x3c010001, 0x220821, 0x8c226b80,
80780x400008, 0x0, 0xc004db9, 0x8021,
80790x34028000, 0xa7a20010, 0x27b10010, 0xc004d78,
80800x24040001, 0x26100001, 0x2e020020, 0x1440fffb,
80810x0, 0xc004d78, 0x2021, 0xc004d78,
80820x24040001, 0xc004d78, 0x2021, 0xc004d78,
80830x24040001, 0x24100010, 0x32020001, 0x10400002,
80840x2021, 0x24040001, 0xc004d78, 0x108042,
80850x1600fffa, 0x32020001, 0x24100010, 0xc004d78,
80860x2021, 0x108042, 0x1600fffc, 0x0,
80870xc004d78, 0x24040001, 0xc004d78, 0x2021,
80880x34108000, 0x96220000, 0x501024, 0x10400002,
80890x2021, 0x24040001, 0xc004d78, 0x108042,
80900x1600fff8, 0x0, 0xc004db9, 0x0,
80910x1000030e, 0x24020002, 0x27b10010, 0xa7a00010,
80920x8021, 0xc004d78, 0x24040001, 0x26100001,
80930x2e020020, 0x1440fffb, 0x0, 0xc004d78,
80940x2021, 0xc004d78, 0x24040001, 0xc004d78,
80950x24040001, 0xc004d78, 0x2021, 0x24100010,
80960x32020001, 0x10400002, 0x2021, 0x24040001,
80970xc004d78, 0x108042, 0x1600fffa, 0x32020001,
80980x24100010, 0xc004d78, 0x2021, 0x108042,
80990x1600fffc, 0x0, 0xc004db9, 0x34108000,
81000xc004db9, 0x0, 0xc004d58, 0x0,
81010x50400005, 0x108042, 0x96220000, 0x501025,
81020xa6220000, 0x108042, 0x1600fff7, 0x0,
81030xc004db9, 0x0, 0x97a20010, 0x30428000,
81040x144002dc, 0x24020003, 0x100002d8, 0x0,
81050x24021200, 0xa7a20010, 0x27b10010, 0x8021,
81060xc004d78, 0x24040001, 0x26100001, 0x2e020020,
81070x1440fffb, 0x0, 0xc004d78, 0x2021,
81080xc004d78, 0x24040001, 0xc004d78, 0x2021,
81090xc004d78, 0x24040001, 0x24100010, 0x32020001,
81100x10400002, 0x2021, 0x24040001, 0xc004d78,
81110x108042, 0x1600fffa, 0x32020001, 0x24100010,
81120xc004d78, 0x2021, 0x108042, 0x1600fffc,
81130x0, 0xc004d78, 0x24040001, 0xc004d78,
81140x2021, 0x34108000, 0x96220000, 0x501024,
81150x10400002, 0x2021, 0x24040001, 0xc004d78,
81160x108042, 0x1600fff8, 0x0, 0xc004db9,
81170x0, 0x8f830054, 0x10000296, 0x24020004,
81180x8f830054, 0x3c020001, 0x8c426f3c, 0x2463ff9c,
81190x431023, 0x2c420064, 0x1440029e, 0x24020002,
81200x3c030001, 0x8c636f40, 0x10620297, 0x2c620003,
81210x14400296, 0x24020011, 0x24020003, 0x10620005,
81220x24020004, 0x10620291, 0x2402000f, 0x1000028f,
81230x24020011, 0x1000028d, 0x24020005, 0x24020014,
81240xa7a20010, 0x27b10010, 0x8021, 0xc004d78,
81250x24040001, 0x26100001, 0x2e020020, 0x1440fffb,
81260x0, 0xc004d78, 0x2021, 0xc004d78,
81270x24040001, 0xc004d78, 0x2021, 0xc004d78,
81280x24040001, 0x24100010, 0x32020001, 0x10400002,
81290x2021, 0x24040001, 0xc004d78, 0x108042,
81300x1600fffa, 0x32020001, 0x24100010, 0x32020012,
81310x10400002, 0x2021, 0x24040001, 0xc004d78,
81320x108042, 0x1600fffa, 0x32020012, 0xc004d78,
81330x24040001, 0xc004d78, 0x2021, 0x34108000,
81340x96220000, 0x501024, 0x10400002, 0x2021,
81350x24040001, 0xc004d78, 0x108042, 0x1600fff8,
81360x0, 0xc004db9, 0x0, 0x8f830054,
81370x10000248, 0x24020006, 0x8f830054, 0x3c020001,
81380x8c426f3c, 0x2463ff9c, 0x431023, 0x2c420064,
81390x14400250, 0x24020007, 0x1000024c, 0x0,
81400x24020006, 0xa7a20010, 0x27b10010, 0x8021,
81410xc004d78, 0x24040001, 0x26100001, 0x2e020020,
81420x1440fffb, 0x0, 0xc004d78, 0x2021,
81430xc004d78, 0x24040001, 0xc004d78, 0x2021,
81440xc004d78, 0x24040001, 0x24100010, 0x32020001,
81450x10400002, 0x2021, 0x24040001, 0xc004d78,
81460x108042, 0x1600fffa, 0x32020001, 0x24100010,
81470x32020013, 0x10400002, 0x2021, 0x24040001,
81480xc004d78, 0x108042, 0x1600fffa, 0x32020013,
81490xc004d78, 0x24040001, 0xc004d78, 0x2021,
81500x34108000, 0x96220000, 0x501024, 0x10400002,
81510x2021, 0x24040001, 0xc004d78, 0x108042,
81520x1600fff8, 0x0, 0xc004db9, 0x0,
81530x8f830054, 0x10000207, 0x24020008, 0x8f830054,
81540x3c020001, 0x8c426f3c, 0x2463ff9c, 0x431023,
81550x2c420064, 0x1440020f, 0x24020009, 0x1000020b,
81560x0, 0x27b10010, 0xa7a00010, 0x8021,
81570xc004d78, 0x24040001, 0x26100001, 0x2e020020,
81580x1440fffb, 0x0, 0xc004d78, 0x2021,
81590xc004d78, 0x24040001, 0xc004d78, 0x24040001,
81600xc004d78, 0x2021, 0x24100010, 0x32020001,
81610x10400002, 0x2021, 0x24040001, 0xc004d78,
81620x108042, 0x1600fffa, 0x32020001, 0x24100010,
81630x32020018, 0x10400002, 0x2021, 0x24040001,
81640xc004d78, 0x108042, 0x1600fffa, 0x32020018,
81650xc004db9, 0x34108000, 0xc004db9, 0x0,
81660xc004d58, 0x0, 0x50400005, 0x108042,
81670x96220000, 0x501025, 0xa6220000, 0x108042,
81680x1600fff7, 0x0, 0xc004db9, 0x8021,
81690x97a20010, 0x27b10010, 0x34420001, 0xa7a20010,
81700xc004d78, 0x24040001, 0x26100001, 0x2e020020,
81710x1440fffb, 0x0, 0xc004d78, 0x2021,
81720xc004d78, 0x24040001, 0xc004d78, 0x2021,
81730xc004d78, 0x24040001, 0x24100010, 0x32020001,
81740x10400002, 0x2021, 0x24040001, 0xc004d78,
81750x108042, 0x1600fffa, 0x32020001, 0x24100010,
81760x32020018, 0x10400002, 0x2021, 0x24040001,
81770xc004d78, 0x108042, 0x1600fffa, 0x32020018,
81780xc004d78, 0x24040001, 0xc004d78, 0x2021,
81790x34108000, 0x96220000, 0x501024, 0x10400002,
81800x2021, 0x24040001, 0xc004d78, 0x108042,
81810x1600fff8, 0x0, 0xc004db9, 0x0,
81820x8f830054, 0x10000193, 0x2402000a, 0x8f830054,
81830x3c020001, 0x8c426f3c, 0x2463ff9c, 0x431023,
81840x2c420064, 0x1440019b, 0x2402000b, 0x10000197,
81850x0, 0x27b10010, 0xa7a00010, 0x8021,
81860xc004d78, 0x24040001, 0x26100001, 0x2e020020,
81870x1440fffb, 0x0, 0xc004d78, 0x2021,
81880xc004d78, 0x24040001, 0xc004d78, 0x24040001,
81890xc004d78, 0x2021, 0x24100010, 0x32020001,
81900x10400002, 0x2021, 0x24040001, 0xc004d78,
81910x108042, 0x1600fffa, 0x32020001, 0x24100010,
81920x32020017, 0x10400002, 0x2021, 0x24040001,
81930xc004d78, 0x108042, 0x1600fffa, 0x32020017,
81940xc004db9, 0x34108000, 0xc004db9, 0x0,
81950xc004d58, 0x0, 0x50400005, 0x108042,
81960x96220000, 0x501025, 0xa6220000, 0x108042,
81970x1600fff7, 0x0, 0xc004db9, 0x8021,
81980x97a20010, 0x27b10010, 0x34420700, 0xa7a20010,
81990xc004d78, 0x24040001, 0x26100001, 0x2e020020,
82000x1440fffb, 0x0, 0xc004d78, 0x2021,
82010xc004d78, 0x24040001, 0xc004d78, 0x2021,
82020xc004d78, 0x24040001, 0x24100010, 0x32020001,
82030x10400002, 0x2021, 0x24040001, 0xc004d78,
82040x108042, 0x1600fffa, 0x32020001, 0x24100010,
82050x32020017, 0x10400002, 0x2021, 0x24040001,
82060xc004d78, 0x108042, 0x1600fffa, 0x32020017,
82070xc004d78, 0x24040001, 0xc004d78, 0x2021,
82080x34108000, 0x96220000, 0x501024, 0x10400002,
82090x2021, 0x24040001, 0xc004d78, 0x108042,
82100x1600fff8, 0x0, 0xc004db9, 0x0,
82110x8f830054, 0x1000011f, 0x2402000c, 0x8f830054,
82120x3c020001, 0x8c426f3c, 0x2463ff9c, 0x431023,
82130x2c420064, 0x14400127, 0x24020012, 0x10000123,
82140x0, 0x27b10010, 0xa7a00010, 0x8021,
82150xc004d78, 0x24040001, 0x26100001, 0x2e020020,
82160x1440fffb, 0x0, 0xc004d78, 0x2021,
82170xc004d78, 0x24040001, 0xc004d78, 0x24040001,
82180xc004d78, 0x2021, 0x24100010, 0x32020001,
82190x10400002, 0x2021, 0x24040001, 0xc004d78,
82200x108042, 0x1600fffa, 0x32020001, 0x24100010,
82210x32020014, 0x10400002, 0x2021, 0x24040001,
82220xc004d78, 0x108042, 0x1600fffa, 0x32020014,
82230xc004db9, 0x34108000, 0xc004db9, 0x0,
82240xc004d58, 0x0, 0x50400005, 0x108042,
82250x96220000, 0x501025, 0xa6220000, 0x108042,
82260x1600fff7, 0x0, 0xc004db9, 0x8021,
82270x97a20010, 0x27b10010, 0x34420010, 0xa7a20010,
82280xc004d78, 0x24040001, 0x26100001, 0x2e020020,
82290x1440fffb, 0x0, 0xc004d78, 0x2021,
82300xc004d78, 0x24040001, 0xc004d78, 0x2021,
82310xc004d78, 0x24040001, 0x24100010, 0x32020001,
82320x10400002, 0x2021, 0x24040001, 0xc004d78,
82330x108042, 0x1600fffa, 0x32020001, 0x24100010,
82340x32020014, 0x10400002, 0x2021, 0x24040001,
82350xc004d78, 0x108042, 0x1600fffa, 0x32020014,
82360xc004d78, 0x24040001, 0xc004d78, 0x2021,
82370x34108000, 0x96220000, 0x501024, 0x10400002,
82380x2021, 0x24040001, 0xc004d78, 0x108042,
82390x1600fff8, 0x0, 0xc004db9, 0x0,
82400x8f830054, 0x100000ab, 0x24020013, 0x8f830054,
82410x3c020001, 0x8c426f3c, 0x2463ff9c, 0x431023,
82420x2c420064, 0x144000b3, 0x2402000d, 0x100000af,
82430x0, 0x27b10010, 0xa7a00010, 0x8021,
82440xc004d78, 0x24040001, 0x26100001, 0x2e020020,
82450x1440fffb, 0x0, 0xc004d78, 0x2021,
82460xc004d78, 0x24040001, 0xc004d78, 0x24040001,
82470xc004d78, 0x2021, 0x24100010, 0x32020001,
82480x10400002, 0x2021, 0x24040001, 0xc004d78,
82490x108042, 0x1600fffa, 0x32020001, 0x24100010,
82500x32020018, 0x10400002, 0x2021, 0x24040001,
82510xc004d78, 0x108042, 0x1600fffa, 0x32020018,
82520xc004db9, 0x34108000, 0xc004db9, 0x0,
82530xc004d58, 0x0, 0x50400005, 0x108042,
82540x96220000, 0x501025, 0xa6220000, 0x108042,
82550x1600fff7, 0x0, 0xc004db9, 0x8021,
82560x97a20010, 0x27b10010, 0x3042fffe, 0xa7a20010,
82570xc004d78, 0x24040001, 0x26100001, 0x2e020020,
82580x1440fffb, 0x0, 0xc004d78, 0x2021,
82590xc004d78, 0x24040001, 0xc004d78, 0x2021,
82600xc004d78, 0x24040001, 0x24100010, 0x32020001,
82610x10400002, 0x2021, 0x24040001, 0xc004d78,
82620x108042, 0x1600fffa, 0x32020001, 0x24100010,
82630x32020018, 0x10400002, 0x2021, 0x24040001,
82640xc004d78, 0x108042, 0x1600fffa, 0x32020018,
82650xc004d78, 0x24040001, 0xc004d78, 0x2021,
82660x34108000, 0x96220000, 0x501024, 0x10400002,
82670x2021, 0x24040001, 0xc004d78, 0x108042,
82680x1600fff8, 0x0, 0xc004db9, 0x0,
82690x8f830054, 0x10000037, 0x2402000e, 0x24020840,
82700xa7a20010, 0x27b10010, 0x8021, 0xc004d78,
82710x24040001, 0x26100001, 0x2e020020, 0x1440fffb,
82720x0, 0xc004d78, 0x2021, 0xc004d78,
82730x24040001, 0xc004d78, 0x2021, 0xc004d78,
82740x24040001, 0x24100010, 0x32020001, 0x10400002,
82750x2021, 0x24040001, 0xc004d78, 0x108042,
82760x1600fffa, 0x32020001, 0x24100010, 0x32020013,
82770x10400002, 0x2021, 0x24040001, 0xc004d78,
82780x108042, 0x1600fffa, 0x32020013, 0xc004d78,
82790x24040001, 0xc004d78, 0x2021, 0x34108000,
82800x96220000, 0x501024, 0x10400002, 0x2021,
82810x24040001, 0xc004d78, 0x108042, 0x1600fff8,
82820x0, 0xc004db9, 0x0, 0x8f830054,
82830x24020010, 0x3c010001, 0xac226dd0, 0x3c010001,
82840x1000000c, 0xac236f3c, 0x8f830054, 0x3c020001,
82850x8c426f3c, 0x2463ff9c, 0x431023, 0x2c420064,
82860x14400004, 0x0, 0x24020011, 0x3c010001,
82870xac226dd0, 0x8fbf0020, 0x8fb1001c, 0x8fb00018,
82880x3e00008, 0x27bd0028, 0x3c030001, 0x8c636d98,
82890x27bdffc8, 0x24020002, 0xafbf0034, 0xafb20030,
82900xafb1002c, 0x14620004, 0xafb00028, 0x3c120002,
82910x10000003, 0x8e528ff8, 0x3c120002, 0x8e528ffc,
82920x3c030001, 0x8c636dd4, 0x3c020001, 0x8c426e1c,
82930x50620004, 0x2463ffff, 0x3c010001, 0xac236e1c,
82940x2463ffff, 0x2c620006, 0x10400377, 0x31080,
82950x3c010001, 0x220821, 0x8c226bd8, 0x400008,
82960x0, 0x2021, 0x2821, 0xc004ddb,
82970x34068000, 0x24040010, 0x24050002, 0x24060002,
82980x24020002, 0xc004ddb, 0xa7a20018, 0x24020002,
82990x3c010001, 0x10000364, 0xac226dd4, 0x27b10018,
83000xa7a00018, 0x8021, 0xc004d78, 0x24040001,
83010x26100001, 0x2e020020, 0x1440fffb, 0x0,
83020xc004d78, 0x2021, 0xc004d78, 0x24040001,
83030xc004d78, 0x24040001, 0xc004d78, 0x2021,
83040x24100010, 0x32020001, 0x10400002, 0x2021,
83050x24040001, 0xc004d78, 0x108042, 0x1600fffa,
83060x32020001, 0x24100010, 0xc004d78, 0x2021,
83070x108042, 0x1600fffc, 0x0, 0xc004db9,
83080x34108000, 0xc004db9, 0x0, 0xc004d58,
83090x0, 0x50400005, 0x108042, 0x96220000,
83100x501025, 0xa6220000, 0x108042, 0x1600fff7,
83110x0, 0xc004db9, 0x0, 0x97a20018,
83120x30428000, 0x14400004, 0x24020003, 0x3c010001,
83130xac226dd4, 0x24020003, 0x3c010001, 0x1000032a,
83140xac226dd4, 0x24040010, 0x24050002, 0x24060002,
83150x24020002, 0xc004ddb, 0xa7a20018, 0x3c030001,
83160x8c636e20, 0x24020001, 0x146201e1, 0x8021,
83170x27b10018, 0xa7a00018, 0xc004d78, 0x24040001,
83180x26100001, 0x2e020020, 0x1440fffb, 0x0,
83190xc004d78, 0x2021, 0xc004d78, 0x24040001,
83200xc004d78, 0x24040001, 0xc004d78, 0x2021,
83210x24100010, 0x32020001, 0x10400002, 0x2021,
83220x24040001, 0xc004d78, 0x108042, 0x1600fffa,
83230x32020001, 0x24100010, 0x32020018, 0x10400002,
83240x2021, 0x24040001, 0xc004d78, 0x108042,
83250x1600fffa, 0x32020018, 0xc004db9, 0x34108000,
83260xc004db9, 0x0, 0xc004d58, 0x0,
83270x50400005, 0x108042, 0x96220000, 0x501025,
83280xa6220000, 0x108042, 0x1600fff7, 0x0,
83290xc004db9, 0x8021, 0x27b10018, 0xa7a00018,
83300xc004d78, 0x24040001, 0x26100001, 0x2e020020,
83310x1440fffb, 0x0, 0xc004d78, 0x2021,
83320xc004d78, 0x24040001, 0xc004d78, 0x24040001,
83330xc004d78, 0x2021, 0x24100010, 0x32020001,
83340x10400002, 0x2021, 0x24040001, 0xc004d78,
83350x108042, 0x1600fffa, 0x32020001, 0x24100010,
83360x32020018, 0x10400002, 0x2021, 0x24040001,
83370xc004d78, 0x108042, 0x1600fffa, 0x32020018,
83380xc004db9, 0x34108000, 0xc004db9, 0x0,
83390xc004d58, 0x0, 0x50400005, 0x108042,
83400x96220000, 0x501025, 0xa6220000, 0x108042,
83410x1600fff7, 0x0, 0xc004db9, 0x8021,
83420x24040018, 0x2821, 0xc004ddb, 0x24060404,
83430xa7a0001a, 0xc004d78, 0x24040001, 0x26100001,
83440x2e020020, 0x1440fffb, 0x0, 0xc004d78,
83450x2021, 0xc004d78, 0x24040001, 0xc004d78,
83460x24040001, 0xc004d78, 0x2021, 0x24100010,
83470x32020001, 0x10400002, 0x2021, 0x24040001,
83480xc004d78, 0x108042, 0x1600fffa, 0x32020001,
83490x24100010, 0x32020018, 0x10400002, 0x2021,
83500x24040001, 0xc004d78, 0x108042, 0x1600fffa,
83510x32020018, 0xc004db9, 0x34108000, 0xc004db9,
83520x0, 0xc004d58, 0x0, 0x50400005,
83530x108042, 0x97a2001a, 0x501025, 0xa7a2001a,
83540x108042, 0x1600fff7, 0x0, 0xc004db9,
83550x8021, 0xa7a0001a, 0xc004d78, 0x24040001,
83560x26100001, 0x2e020020, 0x1440fffb, 0x0,
83570xc004d78, 0x2021, 0xc004d78, 0x24040001,
83580xc004d78, 0x24040001, 0xc004d78, 0x2021,
83590x24100010, 0x32020001, 0x10400002, 0x2021,
83600x24040001, 0xc004d78, 0x108042, 0x1600fffa,
83610x32020001, 0x24100010, 0x32020018, 0x10400002,
83620x2021, 0x24040001, 0xc004d78, 0x108042,
83630x1600fffa, 0x32020018, 0xc004db9, 0x34108000,
83640xc004db9, 0x0, 0xc004d58, 0x0,
83650x50400005, 0x108042, 0x97a2001a, 0x501025,
83660xa7a2001a, 0x108042, 0x1600fff7, 0x0,
83670xc004db9, 0x8021, 0xa7a0001c, 0xc004d78,
83680x24040001, 0x26100001, 0x2e020020, 0x1440fffb,
83690x0, 0xc004d78, 0x2021, 0xc004d78,
83700x24040001, 0xc004d78, 0x24040001, 0xc004d78,
83710x2021, 0x24100010, 0xc004d78, 0x2021,
83720x108042, 0x1600fffc, 0x0, 0x24100010,
83730x3202001e, 0x10400002, 0x2021, 0x24040001,
83740xc004d78, 0x108042, 0x1600fffa, 0x3202001e,
83750xc004db9, 0x34108000, 0xc004db9, 0x0,
83760xc004d58, 0x0, 0x50400005, 0x108042,
83770x97a2001c, 0x501025, 0xa7a2001c, 0x108042,
83780x1600fff7, 0x0, 0xc004db9, 0x8021,
83790xa7a0001c, 0xc004d78, 0x24040001, 0x26100001,
83800x2e020020, 0x1440fffb, 0x0, 0xc004d78,
83810x2021, 0xc004d78, 0x24040001, 0xc004d78,
83820x24040001, 0xc004d78, 0x2021, 0x24100010,
83830xc004d78, 0x2021, 0x108042, 0x1600fffc,
83840x0, 0x24100010, 0x3202001e, 0x10400002,
83850x2021, 0x24040001, 0xc004d78, 0x108042,
83860x1600fffa, 0x3202001e, 0xc004db9, 0x34108000,
83870xc004db9, 0x0, 0xc004d58, 0x0,
83880x50400005, 0x108042, 0x97a2001c, 0x501025,
83890xa7a2001c, 0x108042, 0x1600fff7, 0x0,
83900xc004db9, 0x8021, 0x24020002, 0xa7a2001e,
83910xc004d78, 0x24040001, 0x26100001, 0x2e020020,
83920x1440fffb, 0x0, 0xc004d78, 0x2021,
83930xc004d78, 0x24040001, 0xc004d78, 0x2021,
83940xc004d78, 0x24040001, 0x24100010, 0xc004d78,
83950x2021, 0x108042, 0x1600fffc, 0x0,
83960x24100010, 0x3202001e, 0x10400002, 0x2021,
83970x24040001, 0xc004d78, 0x108042, 0x1600fffa,
83980x3202001e, 0xc004d78, 0x24040001, 0xc004d78,
83990x2021, 0x34108000, 0x97a2001e, 0x501024,
84000x10400002, 0x2021, 0x24040001, 0xc004d78,
84010x108042, 0x1600fff8, 0x0, 0xc004db9,
84020x8021, 0xa7a00020, 0xc004d78, 0x24040001,
84030x26100001, 0x2e020020, 0x1440fffb, 0x0,
84040xc004d78, 0x2021, 0xc004d78, 0x24040001,
84050xc004d78, 0x24040001, 0xc004d78, 0x2021,
84060x24100010, 0xc004d78, 0x2021, 0x108042,
84070x1600fffc, 0x0, 0x24100010, 0x3202001e,
84080x10400002, 0x2021, 0x24040001, 0xc004d78,
84090x108042, 0x1600fffa, 0x3202001e, 0xc004db9,
84100x34108000, 0xc004db9, 0x0, 0xc004d58,
84110x0, 0x50400005, 0x108042, 0x97a20020,
84120x501025, 0xa7a20020, 0x108042, 0x1600fff7,
84130x0, 0xc004db9, 0x8021, 0xa7a00020,
84140xc004d78, 0x24040001, 0x26100001, 0x2e020020,
84150x1440fffb, 0x0, 0xc004d78, 0x2021,
84160xc004d78, 0x24040001, 0xc004d78, 0x24040001,
84170xc004d78, 0x2021, 0x24100010, 0xc004d78,
84180x2021, 0x108042, 0x1600fffc, 0x0,
84190x24100010, 0x3202001e, 0x10400002, 0x2021,
84200x24040001, 0xc004d78, 0x108042, 0x1600fffa,
84210x3202001e, 0xc004db9, 0x34108000, 0xc004db9,
84220x0, 0xc004d58, 0x0, 0x50400005,
84230x108042, 0x97a20020, 0x501025, 0xa7a20020,
84240x108042, 0x1600fff7, 0x0, 0xc004db9,
84250x8021, 0xa7a00022, 0xc004d78, 0x24040001,
84260x26100001, 0x2e020020, 0x1440fffb, 0x0,
84270xc004d78, 0x2021, 0xc004d78, 0x24040001,
84280xc004d78, 0x2021, 0xc004d78, 0x24040001,
84290x24100010, 0xc004d78, 0x2021, 0x108042,
84300x1600fffc, 0x0, 0x24100010, 0xc004d78,
84310x2021, 0x108042, 0x1600fffc, 0x0,
84320xc004d78, 0x24040001, 0xc004d78, 0x2021,
84330x34108000, 0x97a20022, 0x501024, 0x10400002,
84340x2021, 0x24040001, 0xc004d78, 0x108042,
84350x1600fff8, 0x0, 0xc004db9, 0x0,
84360x24040018, 0x24050002, 0xc004ddb, 0x24060004,
84370x3c100001, 0x8e106e24, 0x24020001, 0x1602011d,
84380x0, 0x3c020001, 0x94426f26, 0x3c010001,
84390xac206e24, 0x24429fbc, 0x2c420004, 0x1040000c,
84400x24040009, 0x24050001, 0xc004ddb, 0x24060400,
84410x24040018, 0x24050001, 0xc004ddb, 0x24060020,
84420x24040018, 0x24050001, 0xc004ddb, 0x24062000,
84430x3c024000, 0x2421024, 0x10400123, 0x3c022000,
84440x2421024, 0x10400004, 0x0, 0x3c010001,
84450x10000003, 0xac306f1c, 0x3c010001, 0xac206f1c,
84460x3c030001, 0x8c636f34, 0x24020005, 0x146200f9,
84470x0, 0x3c020001, 0x8c426f1c, 0x10400067,
84480x3c020004, 0x2421024, 0x10400011, 0xa7a00018,
84490x3c020008, 0x2421024, 0x10400002, 0x24020200,
84500xa7a20018, 0x3c020010, 0x2421024, 0x10400004,
84510x0, 0x97a20018, 0x34420100, 0xa7a20018,
84520x97a60018, 0x24040009, 0x10000004, 0x2821,
84530x24040009, 0x2821, 0x3021, 0xc004ddb,
84540x0, 0x24020001, 0xa7a2001a, 0x3c020008,
84550x2421024, 0x1040000c, 0x3c020002, 0x2421024,
84560x10400002, 0x24020101, 0xa7a2001a, 0x3c020001,
84570x2421024, 0x10400005, 0x3c020010, 0x97a2001a,
84580x34420040, 0xa7a2001a, 0x3c020010, 0x2421024,
84590x1040000e, 0x3c020002, 0x2421024, 0x10400005,
84600x3c020001, 0x97a2001a, 0x34420080, 0xa7a2001a,
84610x3c020001, 0x2421024, 0x10400005, 0x3c0300a0,
84620x97a2001a, 0x34420020, 0xa7a2001a, 0x3c0300a0,
84630x2431024, 0x54430004, 0x3c020020, 0x97a2001a,
84640x1000000c, 0x34420400, 0x2421024, 0x50400004,
84650x3c020080, 0x97a2001a, 0x10000006, 0x34420800,
84660x2421024, 0x10400004, 0x0, 0x97a2001a,
84670x34420c00, 0xa7a2001a, 0x97a6001a, 0x24040004,
84680xc004ddb, 0x2821, 0x3c020004, 0x2421024,
84690x10400004, 0xa7a0001c, 0x32425000, 0x14400004,
84700x0, 0x32424000, 0x10400005, 0x2021,
84710xc004cf9, 0x2402021, 0x10000096, 0x0,
84720x97a6001c, 0x2821, 0x34c61200, 0xc004ddb,
84730xa7a6001c, 0x1000008f, 0x0, 0x2421024,
84740x10400004, 0xa7a00018, 0x32425000, 0x14400004,
84750x0, 0x32424000, 0x10400005, 0x3c020010,
84760xc004cf9, 0x2402021, 0x10000019, 0xa7a0001a,
84770x2421024, 0x10400004, 0x0, 0x97a20018,
84780x10000004, 0xa7a20018, 0x97a20018, 0x34420100,
84790xa7a20018, 0x3c020001, 0x2421024, 0x10400004,
84800x0, 0x97a20018, 0x10000004, 0xa7a20018,
84810x97a20018, 0x34422000, 0xa7a20018, 0x97a60018,
84820x2021, 0xc004ddb, 0x2821, 0xa7a0001a,
84830x8021, 0xc004d78, 0x24040001, 0x26100001,
84840x2e020020, 0x1440fffb, 0x0, 0xc004d78,
84850x2021, 0xc004d78, 0x24040001, 0xc004d78,
84860x24040001, 0xc004d78, 0x2021, 0x24100010,
84870x32020001, 0x10400002, 0x2021, 0x24040001,
84880xc004d78, 0x108042, 0x1600fffa, 0x32020001,
84890x24100010, 0xc004d78, 0x2021, 0x108042,
84900x1600fffc, 0x0, 0xc004db9, 0x34108000,
84910xc004db9, 0x0, 0xc004d58, 0x0,
84920x50400005, 0x108042, 0x97a2001a, 0x501025,
84930xa7a2001a, 0x108042, 0x1600fff7, 0x0,
84940xc004db9, 0x8021, 0xa7a0001a, 0xc004d78,
84950x24040001, 0x26100001, 0x2e020020, 0x1440fffb,
84960x0, 0xc004d78, 0x2021, 0xc004d78,
84970x24040001, 0xc004d78, 0x24040001, 0xc004d78,
84980x2021, 0x24100010, 0x32020001, 0x10400002,
84990x2021, 0x24040001, 0xc004d78, 0x108042,
85000x1600fffa, 0x32020001, 0x24100010, 0xc004d78,
85010x2021, 0x108042, 0x1600fffc, 0x0,
85020xc004db9, 0x34108000, 0xc004db9, 0x0,
85030xc004d58, 0x0, 0x50400005, 0x108042,
85040x97a2001a, 0x501025, 0xa7a2001a, 0x108042,
85050x1600fff7, 0x0, 0xc004db9, 0x0,
85060x3c040001, 0x24846bcc, 0x97a60018, 0x97a7001a,
85070x3c020001, 0x8c426d98, 0x3c030001, 0x8c636f1c,
85080x3c05000d, 0x34a50205, 0xafa20010, 0xc002b3b,
85090xafa30014, 0x8f830054, 0x24020004, 0x3c010001,
85100xac226dd4, 0x3c010001, 0x10000017, 0xac236f38,
85110x8f830054, 0x3c020001, 0x8c426f38, 0x2463ff9c,
85120x431023, 0x2c420064, 0x1440000f, 0x0,
85130x8f820220, 0x24030005, 0x3c010001, 0xac236dd4,
85140x3c03f700, 0x431025, 0x10000007, 0xaf820220,
85150x24020006, 0x3c010001, 0xac226dd4, 0x24020011,
85160x3c010001, 0xac226dd0, 0x8fbf0034, 0x8fb20030,
85170x8fb1002c, 0x8fb00028, 0x3e00008, 0x27bd0038,
85180x27bdffd8, 0xafb00018, 0x808021, 0xafb1001c,
85190x8821, 0x32024000, 0x10400013, 0xafbf0020,
85200x3c020010, 0x2021024, 0x2c420001, 0x21023,
85210x30434100, 0x3c020001, 0x2021024, 0x14400006,
85220x34714000, 0x3c020002, 0x2021024, 0x14400002,
85230x34716000, 0x34714040, 0x2021, 0x2821,
85240x10000036, 0x2203021, 0x32021000, 0x10400035,
85250x2021, 0x2821, 0xc004ddb, 0x24060040,
85260x24040018, 0x2821, 0xc004ddb, 0x24060c00,
85270x24040017, 0x2821, 0xc004ddb, 0x24060400,
85280x24040016, 0x2821, 0xc004ddb, 0x24060006,
85290x24040017, 0x2821, 0xc004ddb, 0x24062500,
85300x24040016, 0x2821, 0xc004ddb, 0x24060006,
85310x24040017, 0x2821, 0xc004ddb, 0x24064600,
85320x24040016, 0x2821, 0xc004ddb, 0x24060006,
85330x24040017, 0x2821, 0xc004ddb, 0x24066700,
85340x24040016, 0x2821, 0xc004ddb, 0x24060006,
85350x2404001f, 0x2821, 0xc004ddb, 0x24060010,
85360x24040009, 0x2821, 0xc004ddb, 0x24061500,
85370x24040009, 0x2821, 0x24061d00, 0xc004ddb,
85380x0, 0x3c040001, 0x24846bf0, 0x3c05000e,
85390x34a50100, 0x2003021, 0x2203821, 0xafa00010,
85400xc002b3b, 0xafa00014, 0x8fbf0020, 0x8fb1001c,
85410x8fb00018, 0x3e00008, 0x27bd0028, 0x8f850044,
85420x8f820044, 0x3c030001, 0x431025, 0x3c030008,
85430xaf820044, 0x8f840054, 0x8f820054, 0xa32824,
85440x10000002, 0x24840001, 0x8f820054, 0x821023,
85450x2c420002, 0x1440fffc, 0x0, 0x8f820044,
85460x3c03fffe, 0x3463ffff, 0x431024, 0xaf820044,
85470x8f830054, 0x8f820054, 0x10000002, 0x24630001,
85480x8f820054, 0x621023, 0x2c420002, 0x1440fffc,
85490x0, 0x3e00008, 0xa01021, 0x8f830044,
85500x3c02fff0, 0x3442ffff, 0x42480, 0x621824,
85510x3c020002, 0x822025, 0x641825, 0xaf830044,
85520x8f820044, 0x3c03fffe, 0x3463ffff, 0x431024,
85530xaf820044, 0x8f830054, 0x8f820054, 0x10000002,
85540x24630001, 0x8f820054, 0x621023, 0x2c420002,
85550x1440fffc, 0x0, 0x8f820044, 0x3c030001,
85560x431025, 0xaf820044, 0x8f830054, 0x8f820054,
85570x10000002, 0x24630001, 0x8f820054, 0x621023,
85580x2c420002, 0x1440fffc, 0x0, 0x3e00008,
85590x0, 0x8f820044, 0x2403ff7f, 0x431024,
85600xaf820044, 0x8f830054, 0x8f820054, 0x10000002,
85610x24630001, 0x8f820054, 0x621023, 0x2c420002,
85620x1440fffc, 0x0, 0x8f820044, 0x34420080,
85630xaf820044, 0x8f830054, 0x8f820054, 0x10000002,
85640x24630001, 0x8f820054, 0x621023, 0x2c420002,
85650x1440fffc, 0x0, 0x3e00008, 0x0,
85660x8f820044, 0x3c03fff0, 0x3463ffff, 0x431024,
85670xaf820044, 0x8f820044, 0x3c030001, 0x431025,
85680xaf820044, 0x8f830054, 0x8f820054, 0x10000002,
85690x24630001, 0x8f820054, 0x621023, 0x2c420002,
85700x1440fffc, 0x0, 0x8f820044, 0x3c03fffe,
85710x3463ffff, 0x431024, 0xaf820044, 0x8f830054,
85720x8f820054, 0x10000002, 0x24630001, 0x8f820054,
85730x621023, 0x2c420002, 0x1440fffc, 0x0,
85740x3e00008, 0x0, 0x27bdffc8, 0xafb30024,
85750x809821, 0xafbe002c, 0xa0f021, 0xafb20020,
85760xc09021, 0x33c2ffff, 0xafbf0030, 0xafb50028,
85770xafb1001c, 0xafb00018, 0x14400034, 0xa7b20010,
85780x3271ffff, 0x27b20010, 0x8021, 0xc004d78,
85790x24040001, 0x26100001, 0x2e020020, 0x1440fffb,
85800x0, 0xc004d78, 0x2021, 0xc004d78,
85810x24040001, 0xc004d78, 0x2021, 0xc004d78,
85820x24040001, 0x24100010, 0x32020001, 0x10400002,
85830x2021, 0x24040001, 0xc004d78, 0x108042,
85840x1600fffa, 0x32020001, 0x24100010, 0x2301024,
85850x10400002, 0x2021, 0x24040001, 0xc004d78,
85860x108042, 0x1600fffa, 0x2301024, 0xc004d78,
85870x24040001, 0xc004d78, 0x2021, 0x34108000,
85880x96420000, 0x501024, 0x10400002, 0x2021,
85890x24040001, 0xc004d78, 0x108042, 0x12000075,
85900x0, 0x1000fff6, 0x0, 0x3275ffff,
85910x27b10010, 0xa7a00010, 0x8021, 0xc004d78,
85920x24040001, 0x26100001, 0x2e020020, 0x1440fffb,
85930x0, 0xc004d78, 0x2021, 0xc004d78,
85940x24040001, 0xc004d78, 0x24040001, 0xc004d78,
85950x2021, 0x24100010, 0x32020001, 0x10400002,
85960x2021, 0x24040001, 0xc004d78, 0x108042,
85970x1600fffa, 0x32020001, 0x24100010, 0x2b01024,
85980x10400002, 0x2021, 0x24040001, 0xc004d78,
85990x108042, 0x1600fffa, 0x2b01024, 0xc004db9,
86000x34108000, 0xc004db9, 0x0, 0xc004d58,
86010x0, 0x50400005, 0x108042, 0x96220000,
86020x501025, 0xa6220000, 0x108042, 0x1600fff7,
86030x0, 0xc004db9, 0x0, 0x33c5ffff,
86040x24020001, 0x54a20004, 0x24020002, 0x97a20010,
86050x10000006, 0x521025, 0x14a20006, 0x3271ffff,
86060x97a20010, 0x121827, 0x431024, 0xa7a20010,
86070x3271ffff, 0x27b20010, 0x8021, 0xc004d78,
86080x24040001, 0x26100001, 0x2e020020, 0x1440fffb,
86090x0, 0xc004d78, 0x2021, 0xc004d78,
86100x24040001, 0xc004d78, 0x2021, 0xc004d78,
86110x24040001, 0x24100010, 0x32020001, 0x10400002,
86120x2021, 0x24040001, 0xc004d78, 0x108042,
86130x1600fffa, 0x32020001, 0x24100010, 0x2301024,
86140x10400002, 0x2021, 0x24040001, 0xc004d78,
86150x108042, 0x1600fffa, 0x2301024, 0xc004d78,
86160x24040001, 0xc004d78, 0x2021, 0x34108000,
86170x96420000, 0x501024, 0x10400002, 0x2021,
86180x24040001, 0xc004d78, 0x108042, 0x1600fff8,
86190x0, 0xc004db9, 0x0, 0x8fbf0030,
86200x8fbe002c, 0x8fb50028, 0x8fb30024, 0x8fb20020,
86210x8fb1001c, 0x8fb00018, 0x3e00008, 0x27bd0038,
86220x0, 0x0, 0x0, 0x27bdffe8,
86230xafbf0010, 0x8ee304b8, 0x24020008, 0x146201e0,
86240x0, 0x3c020001, 0x8c426f1c, 0x14400005,
86250x0, 0xc003daf, 0x8f840224, 0x100001d8,
86260x0, 0x8f820220, 0x3c030008, 0x431024,
86270x10400026, 0x24020001, 0x8f840224, 0x8f820220,
86280x3c030400, 0x431024, 0x10400006, 0x0,
86290x3c010002, 0xac208fa0, 0x3c010002, 0x1000000b,
86300xac208fc0, 0x3c030002, 0x24638fa0, 0x8c620000,
86310x24420001, 0xac620000, 0x2c420002, 0x14400003,
86320x24020001, 0x3c010002, 0xac228fc0, 0x3c020002,
86330x8c428fc0, 0x10400006, 0x30820040, 0x10400004,
86340x24020001, 0x3c010002, 0x10000003, 0xac228fc4,
86350x3c010002, 0xac208fc4, 0x3c010002, 0xac248f9c,
86360x3c010002, 0x1000000b, 0xac208fd0, 0x3c010002,
86370xac228fd0, 0x3c010002, 0xac208fc0, 0x3c010002,
86380xac208fa0, 0x3c010002, 0xac208fc4, 0x3c010002,
86390xac208f9c, 0x3c030002, 0x8c638f90, 0x3c020002,
86400x8c428f94, 0x50620004, 0x2463ffff, 0x3c010002,
86410xac238f94, 0x2463ffff, 0x2c62000e, 0x10400194,
86420x31080, 0x3c010001, 0x220821, 0x8c226c00,
86430x400008, 0x0, 0x24020002, 0x3c010002,
86440xac208fc0, 0x3c010002, 0xac208fa0, 0x3c010002,
86450xac208f9c, 0x3c010002, 0xac208fc4, 0x3c010002,
86460xac208fb8, 0x3c010002, 0xac208fb0, 0xaf800224,
86470x3c010002, 0xac228f90, 0x3c020002, 0x8c428fd0,
86480x1440004f, 0x3c02fdff, 0x3442ffff, 0xc003daf,
86490x282a024, 0xaf800204, 0x8f820200, 0x2403fffd,
86500x431024, 0xaf820200, 0x3c010002, 0xac208fe0,
86510x8f830054, 0x3c020002, 0x8c428fb8, 0x24040001,
86520x3c010002, 0xac248fcc, 0x24420001, 0x3c010002,
86530xac228fb8, 0x2c420004, 0x3c010002, 0xac238fb4,
86540x14400006, 0x24020003, 0x3c010001, 0xac246d9c,
86550x3c010002, 0x1000015e, 0xac208fb8, 0x3c010002,
86560x1000015b, 0xac228f90, 0x8f830054, 0x3c020002,
86570x8c428fb4, 0x2463d8f0, 0x431023, 0x2c422710,
86580x14400003, 0x24020004, 0x3c010002, 0xac228f90,
86590x3c020002, 0x8c428fd0, 0x14400021, 0x3c02fdff,
86600x3442ffff, 0x1000014a, 0x282a024, 0x3c040001,
86610x8c846f20, 0x3c010002, 0xc005084, 0xac208fa8,
86620x3c020002, 0x8c428fdc, 0xaf820204, 0x3c020002,
86630x8c428fd0, 0x14400012, 0x3c03fdff, 0x8f820204,
86640x3463ffff, 0x30420030, 0x1440012f, 0x283a024,
86650x3c030002, 0x8c638fdc, 0x24020005, 0x3c010002,
86660xac228f90, 0x3c010002, 0x10000131, 0xac238fe0,
86670x3c020002, 0x8c428fd0, 0x10400010, 0x3c02fdff,
86680x3c020001, 0x8c426e3c, 0x24420001, 0x3c010001,
86690xac226e3c, 0x2c420002, 0x14400125, 0x24020001,
86700x3c010001, 0xac226e44, 0x3c010001, 0xac206e3c,
86710x3c010001, 0x1000011e, 0xac226d9c, 0x3c030002,
86720x8c638fc0, 0x3442ffff, 0x10600119, 0x282a024,
86730x3c020002, 0x8c428f9c, 0x10400115, 0x0,
86740x3c010002, 0xac228fc8, 0x24020003, 0x3c010002,
86750xac228fa0, 0x100000b8, 0x24020006, 0x3c010002,
86760xac208fa8, 0x8f820204, 0x34420040, 0xaf820204,
86770x3c020002, 0x8c428fe0, 0x24030007, 0x3c010002,
86780xac238f90, 0x34420040, 0x3c010002, 0xac228fe0,
86790x3c020002, 0x8c428fc0, 0x10400005, 0x0,
86800x3c020002, 0x8c428f9c, 0x104000f0, 0x24020002,
86810x3c050002, 0x24a58fa0, 0x8ca20000, 0x2c424e21,
86820x104000ea, 0x24020002, 0x3c020002, 0x8c428fc4,
86830x104000ef, 0x2404ffbf, 0x3c020002, 0x8c428f9c,
86840x3c030002, 0x8c638fc8, 0x441024, 0x641824,
86850x10430004, 0x24020001, 0x3c010002, 0x100000e4,
86860xac228f90, 0x24020003, 0xaca20000, 0x24020008,
86870x3c010002, 0xac228f90, 0x3c020002, 0x8c428fcc,
86880x1040000c, 0x24020001, 0x3c040002, 0xc005091,
86890x8c848f9c, 0x3c020002, 0x8c428fe8, 0x14400005,
86900x24020001, 0x3c020002, 0x8c428fe4, 0x10400006,
86910x24020001, 0x3c010001, 0xac226d9c, 0x3c010002,
86920x100000cb, 0xac208fb8, 0x3c020002, 0x8c428fb0,
86930x3c030002, 0x8c638f9c, 0x2c420001, 0x210c0,
86940x30630008, 0x3c010002, 0xac228fb0, 0x3c010002,
86950xac238fac, 0x8f830054, 0x24020009, 0x3c010002,
86960xac228f90, 0x3c010002, 0x100000b9, 0xac238fb4,
86970x8f830054, 0x3c020002, 0x8c428fb4, 0x2463d8f0,
86980x431023, 0x2c422710, 0x1440009f, 0x0,
86990x3c020002, 0x8c428fc0, 0x10400005, 0x0,
87000x3c020002, 0x8c428f9c, 0x104000a0, 0x24020002,
87010x3c030002, 0x24638fa0, 0x8c620000, 0x2c424e21,
87020x1040009a, 0x24020002, 0x3c020002, 0x8c428fcc,
87030x1040000e, 0x0, 0x3c020002, 0x8c428f9c,
87040x3c010002, 0xac208fcc, 0x30420080, 0x1040002f,
87050x2402000c, 0x8f820204, 0x30420080, 0x1440000c,
87060x24020003, 0x10000029, 0x2402000c, 0x3c020002,
87070x8c428f9c, 0x30420080, 0x14400005, 0x24020003,
87080x8f820204, 0x30420080, 0x1040001f, 0x24020003,
87090xac620000, 0x2402000a, 0x3c010002, 0xac228f90,
87100x3c040002, 0x24848fd8, 0x8c820000, 0x3c030002,
87110x8c638fb0, 0x431025, 0xaf820204, 0x8c830000,
87120x3c040002, 0x8c848fb0, 0x2402000b, 0x3c010002,
87130xac228f90, 0x641825, 0x3c010002, 0xac238fe0,
87140x3c050002, 0x24a58fa0, 0x8ca20000, 0x2c424e21,
87150x10400066, 0x24020002, 0x3c020002, 0x8c428fd0,
87160x10400005, 0x0, 0x2402000c, 0x3c010002,
87170x10000067, 0xac228f90, 0x3c020002, 0x8c428fc0,
87180x10400063, 0x0, 0x3c040002, 0x8c848f9c,
87190x10800055, 0x30820008, 0x3c030002, 0x8c638fac,
87200x1062005b, 0x24020003, 0x3c010002, 0xac248fc8,
87210xaca20000, 0x24020006, 0x3c010002, 0x10000054,
87220xac228f90, 0x8f820200, 0x34420002, 0xaf820200,
87230x8f830054, 0x2402000d, 0x3c010002, 0xac228f90,
87240x3c010002, 0xac238fb4, 0x8f830054, 0x3c020002,
87250x8c428fb4, 0x2463d8f0, 0x431023, 0x2c422710,
87260x14400031, 0x0, 0x3c020002, 0x8c428fd0,
87270x10400020, 0x2402000e, 0x3c030002, 0x8c638fe4,
87280x3c010002, 0x14600015, 0xac228f90, 0xc003e6d,
87290x0, 0x3c050001, 0x8ca56d98, 0xc00529b,
87300x2021, 0x3c030001, 0x8c636d98, 0x24020004,
87310x14620005, 0x2403fffb, 0x3c020001, 0x8c426d94,
87320x10000003, 0x2403fff7, 0x3c020001, 0x8c426d94,
87330x431024, 0x3c010001, 0xac226d94, 0x8f830224,
87340x3c020200, 0x3c010002, 0xac238fec, 0x10000020,
87350x282a025, 0x3c020002, 0x8c428fc0, 0x10400005,
87360x0, 0x3c020002, 0x8c428f9c, 0x1040000f,
87370x24020002, 0x3c020002, 0x8c428fa0, 0x2c424e21,
87380x1040000a, 0x24020002, 0x3c020002, 0x8c428fc0,
87390x1040000f, 0x0, 0x3c020002, 0x8c428f9c,
87400x1440000b, 0x0, 0x24020002, 0x3c010002,
87410x10000007, 0xac228f90, 0x3c020002, 0x8c428fc0,
87420x10400003, 0x0, 0xc003daf, 0x0,
87430x8f820220, 0x3c03f700, 0x431025, 0xaf820220,
87440x8fbf0010, 0x3e00008, 0x27bd0018, 0x3c030002,
87450x24638fe8, 0x8c620000, 0x10400005, 0x34422000,
87460x3c010002, 0xac228fdc, 0x10000003, 0xac600000,
87470x3c010002, 0xac248fdc, 0x3e00008, 0x0,
87480x27bdffe0, 0x30820030, 0xafbf0018, 0x3c010002,
87490xac228fe4, 0x14400067, 0x3c02ffff, 0x34421f0e,
87500x821024, 0x14400061, 0x24020030, 0x30822000,
87510x1040005d, 0x30838000, 0x31a02, 0x30820001,
87520x21200, 0x3c040001, 0x8c846f20, 0x621825,
87530x331c2, 0x3c030001, 0x24636e48, 0x30828000,
87540x21202, 0x30840001, 0x42200, 0x441025,
87550x239c2, 0x61080, 0x431021, 0x471021,
87560x90430000, 0x24020001, 0x10620025, 0x0,
87570x10600007, 0x24020002, 0x10620013, 0x24020003,
87580x1062002c, 0x3c05000f, 0x10000037, 0x0,
87590x8f820200, 0x2403feff, 0x431024, 0xaf820200,
87600x8f820220, 0x3c03fffe, 0x3463ffff, 0x431024,
87610xaf820220, 0x3c010002, 0xac209004, 0x3c010002,
87620x10000034, 0xac20900c, 0x8f820200, 0x34420100,
87630xaf820200, 0x8f820220, 0x3c03fffe, 0x3463ffff,
87640x431024, 0xaf820220, 0x24020100, 0x3c010002,
87650xac229004, 0x3c010002, 0x10000026, 0xac20900c,
87660x8f820200, 0x2403feff, 0x431024, 0xaf820200,
87670x8f820220, 0x3c030001, 0x431025, 0xaf820220,
87680x3c010002, 0xac209004, 0x3c010002, 0x10000019,
87690xac23900c, 0x8f820200, 0x34420100, 0xaf820200,
87700x8f820220, 0x3c030001, 0x431025, 0xaf820220,
87710x24020100, 0x3c010002, 0xac229004, 0x3c010002,
87720x1000000c, 0xac23900c, 0x34a5ffff, 0x3c040001,
87730x24846c38, 0xafa30010, 0xc002b3b, 0xafa00014,
87740x10000004, 0x0, 0x24020030, 0x3c010002,
87750xac228fe8, 0x8fbf0018, 0x3e00008, 0x27bd0020,
87760x0, 0x0, 0x0, 0x27bdffc8,
87770xafb20028, 0x809021, 0xafb3002c, 0xa09821,
87780xafb00020, 0xc08021, 0x3c040001, 0x24846c50,
87790x3c050009, 0x3c020001, 0x8c426d98, 0x34a59001,
87800x2403021, 0x2603821, 0xafbf0030, 0xafb10024,
87810xa7a0001a, 0xafb00014, 0xc002b3b, 0xafa20010,
87820x24020002, 0x12620083, 0x2e620003, 0x10400005,
87830x24020001, 0x1262000a, 0x0, 0x10000173,
87840x0, 0x24020004, 0x126200f8, 0x24020008,
87850x126200f7, 0x3c02ffec, 0x1000016c, 0x0,
87860x3c020001, 0x8c426d94, 0x30420002, 0x14400004,
87870x128940, 0x3c02fffb, 0x3442ffff, 0x2028024,
87880x3c010002, 0x310821, 0xac308ffc, 0x3c024000,
87890x2021024, 0x1040004e, 0x1023c2, 0x30840030,
87900x101382, 0x3042001c, 0x3c030001, 0x24636dd8,
87910x431021, 0x823821, 0x3c020020, 0x2021024,
87920x10400006, 0x24020100, 0x3c010002, 0x310821,
87930xac229000, 0x10000005, 0x3c020080, 0x3c010002,
87940x310821, 0xac209000, 0x3c020080, 0x2021024,
87950x10400006, 0x121940, 0x3c020001, 0x3c010002,
87960x230821, 0x10000005, 0xac229008, 0x121140,
87970x3c010002, 0x220821, 0xac209008, 0x94e40000,
87980x3c030001, 0x8c636f40, 0x24020005, 0x10620010,
87990xa7a40018, 0x32024000, 0x10400002, 0x34824000,
88000xa7a20018, 0x24040001, 0x94e20002, 0x24050004,
88010x24e60002, 0x34420001, 0xc0045be, 0xa4e20002,
88020x24040001, 0x2821, 0xc0045be, 0x27a60018,
88030x3c020001, 0x8c426d98, 0x24110001, 0x3c010001,
88040xac316da4, 0x14530004, 0x32028000, 0xc003daf,
88050x0, 0x32028000, 0x1040011c, 0x0,
88060xc003daf, 0x0, 0x3c030001, 0x8c636f40,
88070x24020005, 0x10620115, 0x24020002, 0x3c010001,
88080xac316d9c, 0x3c010001, 0x10000110, 0xac226d98,
88090x24040001, 0x24050004, 0x27b0001a, 0xc0045be,
88100x2003021, 0x24040001, 0x2821, 0xc0045be,
88110x2003021, 0x3c020002, 0x511021, 0x8c428ff4,
88120x3c040001, 0x8c846d98, 0x3c03bfff, 0x3463ffff,
88130x3c010001, 0xac336da4, 0x431024, 0x3c010002,
88140x310821, 0x109300f7, 0xac228ff4, 0x100000f7,
88150x0, 0x3c022000, 0x2021024, 0x10400005,
88160x24020001, 0x3c010001, 0xac226f1c, 0x10000004,
88170x128940, 0x3c010001, 0xac206f1c, 0x128940,
88180x3c010002, 0x310821, 0xac308ff8, 0x3c024000,
88190x2021024, 0x14400014, 0x0, 0x3c020001,
88200x8c426f1c, 0x10400006, 0x24040004, 0x24050001,
88210xc004ddb, 0x24062000, 0x24020001, 0xaee204b8,
88220x3c020002, 0x511021, 0x8c428ff0, 0x3c03bfff,
88230x3463ffff, 0x431024, 0x3c010002, 0x310821,
88240x100000d0, 0xac228ff0, 0x3c020001, 0x8c426f1c,
88250x10400028, 0x3c0300a0, 0x2031024, 0x5443000d,
88260x3c020020, 0x3c020001, 0x8c426f20, 0x24030100,
88270x3c010002, 0x310821, 0xac239004, 0x3c030001,
88280x3c010002, 0x310821, 0xac23900c, 0x10000015,
88290x34420400, 0x2021024, 0x10400008, 0x24030100,
88300x3c020001, 0x8c426f20, 0x3c010002, 0x310821,
88310xac239004, 0x1000000b, 0x34420800, 0x3c020080,
88320x2021024, 0x1040002e, 0x3c030001, 0x3c020001,
88330x8c426f20, 0x3c010002, 0x310821, 0xac23900c,
88340x34420c00, 0x3c010001, 0xac226f20, 0x10000025,
88350x24040001, 0x3c020020, 0x2021024, 0x10400006,
88360x24020100, 0x3c010002, 0x310821, 0xac229004,
88370x10000005, 0x3c020080, 0x3c010002, 0x310821,
88380xac209004, 0x3c020080, 0x2021024, 0x10400007,
88390x121940, 0x3c020001, 0x3c010002, 0x230821,
88400xac22900c, 0x10000006, 0x24040001, 0x121140,
88410x3c010002, 0x220821, 0xac20900c, 0x24040001,
88420x2821, 0x27b0001e, 0xc00457c, 0x2003021,
88430x24040001, 0x2821, 0xc00457c, 0x2003021,
88440x24040001, 0x24050001, 0x27b0001c, 0xc00457c,
88450x2003021, 0x24040001, 0x24050001, 0xc00457c,
88460x2003021, 0x10000077, 0x0, 0x3c02ffec,
88470x3442ffff, 0x2028024, 0x3c020008, 0x2028025,
88480x121140, 0x3c010002, 0x220821, 0xac308ff8,
88490x3c022000, 0x2021024, 0x10400009, 0x0,
88500x3c020001, 0x8c426e44, 0x14400005, 0x24020001,
88510x3c010001, 0xac226f1c, 0x10000004, 0x3c024000,
88520x3c010001, 0xac206f1c, 0x3c024000, 0x2021024,
88530x1440001d, 0x24020e01, 0x3c030001, 0x8c636f1c,
88540xaf820238, 0x3c010001, 0xac206db0, 0x10600005,
88550x24022020, 0x3c010001, 0xac226f20, 0x24020001,
88560xaee204b8, 0x3c04bfff, 0x121940, 0x3c020002,
88570x431021, 0x8c428ff0, 0x3c050001, 0x8ca56d98,
88580x3484ffff, 0x441024, 0x3c010002, 0x230821,
88590xac228ff0, 0x24020001, 0x10a20044, 0x0,
88600x10000040, 0x0, 0x3c020001, 0x8c426f1c,
88610x1040001c, 0x24022000, 0x3c010001, 0xac226f20,
88620x3c0300a0, 0x2031024, 0x14430005, 0x121140,
88630x3402a000, 0x3c010001, 0x1000002d, 0xac226f20,
88640x3c030002, 0x621821, 0x8c638ff8, 0x3c020020,
88650x621024, 0x10400004, 0x24022001, 0x3c010001,
88660x10000023, 0xac226f20, 0x3c020080, 0x621024,
88670x1040001f, 0x3402a001, 0x3c010001, 0x1000001c,
88680xac226f20, 0x3c020020, 0x2021024, 0x10400007,
88690x121940, 0x24020100, 0x3c010002, 0x230821,
88700xac229004, 0x10000006, 0x3c020080, 0x121140,
88710x3c010002, 0x220821, 0xac209004, 0x3c020080,
88720x2021024, 0x10400006, 0x121940, 0x3c020001,
88730x3c010002, 0x230821, 0x10000005, 0xac22900c,
88740x121140, 0x3c010002, 0x220821, 0xac20900c,
88750x3c030001, 0x8c636d98, 0x24020001, 0x10620003,
88760x0, 0xc003daf, 0x0, 0x8fbf0030,
88770x8fb3002c, 0x8fb20028, 0x8fb10024, 0x8fb00020,
88780x3e00008, 0x27bd0038, 0x27bdffb0, 0xafb3003c,
88790x9821, 0xafb50040, 0xa821, 0xafb10034,
88800x8821, 0x24020002, 0xafbf0048, 0xafbe0044,
88810xafb20038, 0xafb00030, 0xafa4002c, 0xa7a0001a,
88820xa7a00018, 0xa7a00020, 0xa7a0001e, 0xa7a00022,
88830x10a20130, 0xa7a0001c, 0x2ca20003, 0x10400005,
88840x24020001, 0x10a2000a, 0x3c024000, 0x1000025d,
88850x2201021, 0x24020004, 0x10a2020a, 0x24020008,
88860x10a20208, 0x2201021, 0x10000256, 0x0,
88870x8fa8002c, 0x88140, 0x3c030002, 0x701821,
88880x8c638ffc, 0x621024, 0x14400009, 0x24040001,
88890x3c027fff, 0x3442ffff, 0x628824, 0x3c010002,
88900x300821, 0xac318ff4, 0x10000246, 0x2201021,
88910x24050001, 0xc00457c, 0x27a60018, 0x24040001,
88920x24050001, 0xc00457c, 0x27a60018, 0x97a20018,
88930x30420004, 0x104000d9, 0x3c114000, 0x3c020001,
88940x8c426f40, 0x2443ffff, 0x2c620006, 0x104000d9,
88950x31080, 0x3c010001, 0x220821, 0x8c226c68,
88960x400008, 0x0, 0x24040001, 0x24050011,
88970x27b0001a, 0xc00457c, 0x2003021, 0x24040001,
88980x24050011, 0xc00457c, 0x2003021, 0x97a3001a,
88990x30624000, 0x10400002, 0x3c150010, 0x3c150008,
89000x30628000, 0x104000aa, 0x3c130001, 0x100000a8,
89010x3c130002, 0x24040001, 0x24050014, 0x27b0001a,
89020xc00457c, 0x2003021, 0x24040001, 0x24050014,
89030xc00457c, 0x2003021, 0x97a3001a, 0x30621000,
89040x10400002, 0x3c150010, 0x3c150008, 0x30620800,
89050x10400097, 0x3c130001, 0x10000095, 0x3c130002,
89060x24040001, 0x24050019, 0x27b0001c, 0xc00457c,
89070x2003021, 0x24040001, 0x24050019, 0xc00457c,
89080x2003021, 0x97a2001c, 0x30430700, 0x24020400,
89090x10620027, 0x28620401, 0x1040000e, 0x24020200,
89100x1062001f, 0x28620201, 0x10400005, 0x24020100,
89110x5062001e, 0x3c130001, 0x1000001e, 0x24040001,
89120x24020300, 0x50620019, 0x3c130002, 0x10000019,
89130x24040001, 0x24020600, 0x1062000d, 0x28620601,
89140x10400005, 0x24020500, 0x5062000b, 0x3c130002,
89150x10000010, 0x24040001, 0x24020700, 0x1462000d,
89160x24040001, 0x3c130004, 0x1000000a, 0x3c150008,
89170x10000006, 0x3c130004, 0x10000005, 0x3c150008,
89180x3c130001, 0x10000002, 0x3c150008, 0x3c150010,
89190x24040001, 0x24050018, 0x27b0001e, 0xc00457c,
89200x2003021, 0x24040001, 0x24050018, 0xc00457c,
89210x2003021, 0x8fa8002c, 0x97a7001e, 0x81140,
89220x3c060002, 0xc23021, 0x8cc68ff4, 0x97a20022,
89230x3c100001, 0x26106c5c, 0x2002021, 0xafa20010,
89240x97a2001c, 0x3c05000c, 0x34a50303, 0xc002b3b,
89250xafa20014, 0x3c020004, 0x16620010, 0x3c020001,
89260x8f840054, 0x24030001, 0x24020002, 0x3c010001,
89270xac236d9c, 0x3c010001, 0xac226d98, 0x3c010001,
89280xac236da4, 0x3c010001, 0xac236e24, 0x3c010001,
89290xac246f30, 0x1000004f, 0x2b38825, 0x16620039,
89300x3c028000, 0x3c020001, 0x8c426e20, 0x1440001e,
89310x24040018, 0x2021, 0x2821, 0xc004ddb,
89320x34068000, 0x8f830054, 0x8f820054, 0x2b38825,
89330x10000002, 0x24630032, 0x8f820054, 0x621023,
89340x2c420033, 0x1440fffc, 0x0, 0x8f830054,
89350x24020001, 0x3c010001, 0xac226e20, 0x3c010001,
89360xac226d9c, 0x3c010001, 0xac226d98, 0x3c010001,
89370xac226da4, 0x3c010001, 0xac226e24, 0x3c010001,
89380x1000002c, 0xac236f30, 0x2821, 0xc004ddb,
89390x24060404, 0x2021, 0x2405001e, 0x27a60018,
89400x24020002, 0xc0045be, 0xa7a20018, 0x2021,
89410x2821, 0x27a60018, 0xc0045be, 0xa7a00018,
89420x24040018, 0x24050002, 0xc004ddb, 0x24060004,
89430x3c028000, 0x2221025, 0x2b31825, 0x10000015,
89440x438825, 0x2221025, 0x2751825, 0x438825,
89450x2002021, 0x97a6001c, 0x3c070001, 0x8ce76d98,
89460x3c05000c, 0x34a50326, 0xafb30010, 0xc002b3b,
89470xafb10014, 0x10000007, 0x0, 0x3c110002,
89480x2308821, 0x8e318ffc, 0x3c027fff, 0x3442ffff,
89490x2228824, 0x3c020001, 0x8c426da8, 0x1040001e,
89500x0, 0x3c020001, 0x8c426f1c, 0x10400002,
89510x3c022000, 0x2228825, 0x8fa8002c, 0x81140,
89520x3c010002, 0x220821, 0x8c229000, 0x10400003,
89530x3c020020, 0x10000005, 0x2228825, 0x3c02ffdf,
89540x3442ffff, 0x2228824, 0x8fa8002c, 0x81140,
89550x3c010002, 0x220821, 0x8c229008, 0x10400003,
89560x3c020080, 0x10000004, 0x2228825, 0x3c02ff7f,
89570x3442ffff, 0x2228824, 0x8fa8002c, 0x81140,
89580x3c010002, 0x220821, 0xac318ff4, 0x10000135,
89590x2201021, 0x8fa8002c, 0x8f140, 0x3c030002,
89600x7e1821, 0x8c638ff8, 0x3c024000, 0x621024,
89610x14400009, 0x24040001, 0x3c027fff, 0x3442ffff,
89620x628824, 0x3c010002, 0x3e0821, 0xac318ff0,
89630x10000124, 0x2201021, 0x2821, 0xc00457c,
89640x27a60018, 0x24040001, 0x2821, 0xc00457c,
89650x27a60018, 0x24040001, 0x24050001, 0x27b20020,
89660xc00457c, 0x2403021, 0x24040001, 0x24050001,
89670xc00457c, 0x2403021, 0x24040001, 0x24050004,
89680x27b1001e, 0xc00457c, 0x2203021, 0x24040001,
89690x24050004, 0xc00457c, 0x2203021, 0x24040001,
89700x24050005, 0x27b00022, 0xc00457c, 0x2003021,
89710x24040001, 0x24050005, 0xc00457c, 0x2003021,
89720x24040001, 0x24050010, 0xc00457c, 0x27a60018,
89730x24040001, 0x24050010, 0xc00457c, 0x27a60018,
89740x24040001, 0x2405000a, 0xc00457c, 0x2403021,
89750x24040001, 0x2405000a, 0xc00457c, 0x2403021,
89760x24040001, 0x24050018, 0xc00457c, 0x2203021,
89770x24040001, 0x24050018, 0xc00457c, 0x2203021,
89780x24040001, 0x24050001, 0xc00457c, 0x27a60018,
89790x24040001, 0x24050001, 0xc00457c, 0x27a60018,
89800x97a20018, 0x30420004, 0x10400066, 0x3c114000,
89810x3c030001, 0x8c636f34, 0x24020005, 0x14620067,
89820x24040001, 0x24050019, 0x27b0001c, 0xc00457c,
89830x2003021, 0x24040001, 0x24050019, 0xc00457c,
89840x2003021, 0x97a2001c, 0x30430700, 0x24020400,
89850x10620027, 0x28620401, 0x1040000e, 0x24020200,
89860x1062001f, 0x28620201, 0x10400005, 0x24020100,
89870x5062001e, 0x3c130001, 0x1000001e, 0x3c020004,
89880x24020300, 0x50620019, 0x3c130002, 0x10000019,
89890x3c020004, 0x24020600, 0x1062000d, 0x28620601,
89900x10400005, 0x24020500, 0x5062000b, 0x3c130002,
89910x10000010, 0x3c020004, 0x24020700, 0x1462000d,
89920x3c020004, 0x3c130004, 0x1000000a, 0x3c150008,
89930x10000006, 0x3c130004, 0x10000005, 0x3c150008,
89940x3c130001, 0x10000002, 0x3c150008, 0x3c150010,
89950x3c020004, 0x12620017, 0x3c028000, 0x8f820054,
89960x24100001, 0x3c010001, 0xac306d9c, 0x3c010001,
89970xac306d98, 0x3c010001, 0xac306da4, 0x3c010001,
89980xac306e24, 0x3c010001, 0xac226f30, 0x3c020001,
89990x16620022, 0x2758825, 0x2021, 0x2821,
90000xc004ddb, 0x34068000, 0x3c010001, 0x1000001b,
90010xac306e20, 0x2221025, 0x2b31825, 0x438825,
90020x97a6001c, 0x3c020001, 0x8c426f1c, 0x3c070001,
90030x8ce76d98, 0x3c040001, 0x24846c5c, 0xafa20010,
90040x97a2001e, 0x3c05000c, 0x34a50323, 0x3c010001,
90050xac206e20, 0xc002b3b, 0xafa20014, 0x10000007,
90060x0, 0x3c110002, 0x23e8821, 0x8e318ff0,
90070x3c027fff, 0x3442ffff, 0x2228824, 0x3c020001,
90080x8c426da8, 0x10400069, 0x0, 0x3c020001,
90090x8c426f1c, 0x10400002, 0x3c022000, 0x2228825,
90100x8fa8002c, 0x81140, 0x3c010002, 0x220821,
90110x8c229004, 0x10400003, 0x3c020020, 0x10000005,
90120x2228825, 0x3c02ffdf, 0x3442ffff, 0x2228824,
90130x8fa8002c, 0x81140, 0x3c010002, 0x220821,
90140x8c22900c, 0x10400003, 0x3c020080, 0x1000004f,
90150x2228825, 0x3c02ff7f, 0x3442ffff, 0x1000004b,
90160x2228824, 0x8fa8002c, 0x82940, 0x3c030002,
90170x651821, 0x8c638ff8, 0x3c024000, 0x621024,
90180x14400008, 0x3c027fff, 0x3442ffff, 0x628824,
90190x3c010002, 0x250821, 0xac318ff0, 0x10000041,
90200x2201021, 0x3c020001, 0x8c426da8, 0x10400034,
90210x3c11c00c, 0x3c020001, 0x8c426e44, 0x3c04c00c,
90220x34842000, 0x3c030001, 0x8c636f1c, 0x2102b,
90230x21023, 0x441024, 0x10600003, 0x518825,
90240x3c022000, 0x2228825, 0x3c020002, 0x451021,
90250x8c429004, 0x10400003, 0x3c020020, 0x10000004,
90260x2228825, 0x3c02ffdf, 0x3442ffff, 0x2228824,
90270x8fa8002c, 0x81140, 0x3c010002, 0x220821,
90280x8c22900c, 0x10400003, 0x3c020080, 0x10000004,
90290x2228825, 0x3c02ff7f, 0x3442ffff, 0x2228824,
90300x3c020001, 0x8c426e30, 0x10400002, 0x3c020800,
90310x2228825, 0x3c020001, 0x8c426e34, 0x10400002,
90320x3c020400, 0x2228825, 0x3c020001, 0x8c426e38,
90330x10400006, 0x3c020100, 0x10000004, 0x2228825,
90340x3c027fff, 0x3442ffff, 0x628824, 0x8fa8002c,
90350x81140, 0x3c010002, 0x220821, 0xac318ff0,
90360x2201021, 0x8fbf0048, 0x8fbe0044, 0x8fb50040,
90370x8fb3003c, 0x8fb20038, 0x8fb10034, 0x8fb00030,
90380x3e00008, 0x27bd0050, 0x27bdffd0, 0xafb20028,
90390x809021, 0xafbf002c, 0xafb10024, 0xafb00020,
90400x8f840200, 0x3c100001, 0x8e106d98, 0x8f860220,
90410x24020002, 0x1202005c, 0x2e020003, 0x10400005,
90420x24020001, 0x1202000a, 0x121940, 0x1000010c,
90430x0, 0x24020004, 0x120200bf, 0x24020008,
90440x120200be, 0x128940, 0x10000105, 0x0,
90450x3c050002, 0xa32821, 0x8ca58ffc, 0x3c100002,
90460x2038021, 0x8e108ff4, 0x3c024000, 0xa21024,
90470x10400038, 0x3c020008, 0x2021024, 0x10400020,
90480x34840002, 0x3c020002, 0x431021, 0x8c429000,
90490x10400005, 0x34840020, 0x34840100, 0x3c020020,
90500x10000006, 0x2028025, 0x2402feff, 0x822024,
90510x3c02ffdf, 0x3442ffff, 0x2028024, 0x121140,
90520x3c010002, 0x220821, 0x8c229008, 0x10400005,
90530x3c020001, 0xc23025, 0x3c020080, 0x10000016,
90540x2028025, 0x3c02fffe, 0x3442ffff, 0xc23024,
90550x3c02ff7f, 0x3442ffff, 0x1000000f, 0x2028024,
90560x2402fedf, 0x822024, 0x3c02fffe, 0x3442ffff,
90570xc23024, 0x3c02ff5f, 0x3442ffff, 0x2028024,
90580x3c010002, 0x230821, 0xac209000, 0x3c010002,
90590x230821, 0xac209008, 0xaf840200, 0xaf860220,
90600x8f820220, 0x34420002, 0xaf820220, 0x1000000a,
90610x121140, 0x3c02bfff, 0x3442ffff, 0x8f830200,
90620x2028024, 0x2402fffd, 0x621824, 0xc003daf,
90630xaf830200, 0x121140, 0x3c010002, 0x220821,
90640x100000b7, 0xac308ff4, 0x3c020001, 0x8c426f1c,
90650x10400069, 0x24050004, 0x24040001, 0xc00457c,
90660x27a60018, 0x24040001, 0x24050005, 0xc00457c,
90670x27a6001a, 0x97a30018, 0x97a2001a, 0x3c040001,
90680x24846e48, 0x30630c00, 0x31a82, 0x30420c00,
90690x21282, 0xa7a2001a, 0x21080, 0x441021,
90700x431021, 0xa7a30018, 0x90480000, 0x24020001,
90710x3103ffff, 0x10620029, 0x28620002, 0x10400005,
90720x0, 0x10600009, 0x0, 0x1000003d,
90730x0, 0x10700013, 0x24020003, 0x1062002c,
90740x0, 0x10000037, 0x0, 0x8f820200,
90750x2403feff, 0x431024, 0xaf820200, 0x8f820220,
90760x3c03fffe, 0x3463ffff, 0x431024, 0xaf820220,
90770x3c010002, 0xac209004, 0x3c010002, 0x10000032,
90780xac20900c, 0x8f820200, 0x34420100, 0xaf820200,
90790x8f820220, 0x3c03fffe, 0x3463ffff, 0x431024,
90800xaf820220, 0x24020100, 0x3c010002, 0xac229004,
90810x3c010002, 0x10000024, 0xac20900c, 0x8f820200,
90820x2403feff, 0x431024, 0xaf820200, 0x8f820220,
90830x3c030001, 0x431025, 0xaf820220, 0x3c010002,
90840xac209004, 0x3c010002, 0x10000017, 0xac23900c,
90850x8f820200, 0x34420100, 0xaf820200, 0x8f820220,
90860x3c030001, 0x431025, 0xaf820220, 0x24020100,
90870x3c010002, 0xac229004, 0x3c010002, 0x1000000a,
90880xac23900c, 0x3c040001, 0x24846c80, 0x97a6001a,
90890x97a70018, 0x3c050001, 0x34a5ffff, 0xafa80010,
90900xc002b3b, 0xafa00014, 0x8f820200, 0x34420002,
90910x1000004b, 0xaf820200, 0x128940, 0x3c050002,
90920xb12821, 0x8ca58ff8, 0x3c100002, 0x2118021,
90930x8e108ff0, 0x3c024000, 0xa21024, 0x14400010,
90940x0, 0x3c020001, 0x8c426f1c, 0x14400005,
90950x3c02bfff, 0x8f820200, 0x34420002, 0xaf820200,
90960x3c02bfff, 0x3442ffff, 0xc003daf, 0x2028024,
90970x3c010002, 0x310821, 0x10000031, 0xac308ff0,
90980x3c020001, 0x8c426f1c, 0x10400005, 0x3c020020,
90990x3c020001, 0x8c426e44, 0x10400025, 0x3c020020,
91000xa21024, 0x10400007, 0x34840020, 0x24020100,
91010x3c010002, 0x310821, 0xac229004, 0x10000006,
91020x34840100, 0x3c010002, 0x310821, 0xac209004,
91030x2402feff, 0x822024, 0x3c020080, 0xa21024,
91040x10400007, 0x121940, 0x3c020001, 0x3c010002,
91050x230821, 0xac22900c, 0x10000008, 0xc23025,
91060x121140, 0x3c010002, 0x220821, 0xac20900c,
91070x3c02fffe, 0x3442ffff, 0xc23024, 0xaf840200,
91080xaf860220, 0x8f820220, 0x34420002, 0xaf820220,
91090x121140, 0x3c010002, 0x220821, 0xac308ff0,
91100x8fbf002c, 0x8fb20028, 0x8fb10024, 0x8fb00020,
91110x3e00008, 0x27bd0030, 0x0, 0x1821,
91120x308400ff, 0x2405ffdf, 0x2406ffbf, 0x641007,
91130x30420001, 0x10400004, 0x0, 0x8f820044,
91140x10000003, 0x34420040, 0x8f820044, 0x461024,
91150xaf820044, 0x8f820044, 0x34420020, 0xaf820044,
91160x8f820044, 0x451024, 0xaf820044, 0x24630001,
91170x28620008, 0x5440ffee, 0x641007, 0x3e00008,
91180x0, 0x2c820008, 0x1040001b, 0x0,
91190x2405ffdf, 0x2406ffbf, 0x41880, 0x3c020001,
91200x24426e60, 0x621821, 0x24640004, 0x90620000,
91210x10400004, 0x0, 0x8f820044, 0x10000003,
91220x34420040, 0x8f820044, 0x461024, 0xaf820044,
91230x8f820044, 0x34420020, 0xaf820044, 0x8f820044,
91240x451024, 0xaf820044, 0x24630001, 0x64102b,
91250x1440ffee, 0x0, 0x3e00008, 0x0,
91260x0, 0x0, 0x0, 0x8f8400c4,
91270x8f8600e0, 0x8f8700e4, 0x2402fff8, 0xc22824,
91280x10e5001a, 0x27623ff8, 0x14e20002, 0x24e80008,
91290x27683000, 0x55050004, 0x8d0a0000, 0x30c20004,
91300x14400012, 0x805021, 0x8ce90000, 0x8f42013c,
91310x1494823, 0x49182b, 0x94eb0006, 0x10600002,
91320x25630050, 0x494821, 0x123182b, 0x50400003,
91330x8f4201fc, 0x3e00008, 0xe01021, 0xaf8800e8,
91340x24420001, 0xaf4201fc, 0xaf8800e4, 0x3e00008,
91350x1021, 0x3e00008, 0x0, 0x8f8300e4,
91360x27623ff8, 0x10620004, 0x24620008, 0xaf8200e8,
91370x3e00008, 0xaf8200e4, 0x27623000, 0xaf8200e8,
91380x3e00008, 0xaf8200e4, 0x3e00008, 0x0,
91390x0, 0x0, 0x0, 0x8f880120,
91400x27624fe0, 0x8f830128, 0x15020002, 0x25090020,
91410x27694800, 0x11230012, 0x8fa20010, 0xad040000,
91420xad050004, 0xad060008, 0xa507000e, 0x8fa30014,
91430xad020018, 0x8fa20018, 0xad03001c, 0x25030016,
91440xad020010, 0xad030014, 0xaf890120, 0x8f4300fc,
91450x24020001, 0x2463ffff, 0x3e00008, 0xaf4300fc,
91460x8f430324, 0x1021, 0x24630001, 0x3e00008,
91470xaf430324, 0x3e00008, 0x0, 0x8f880100,
91480x276247e0, 0x8f830108, 0x15020002, 0x25090020,
91490x27694000, 0x1123000f, 0x8fa20010, 0xad040000,
91500xad050004, 0xad060008, 0xa507000e, 0x8fa30014,
91510xad020018, 0x8fa20018, 0xad03001c, 0x25030016,
91520xad020010, 0xad030014, 0xaf890100, 0x3e00008,
91530x24020001, 0x8f430328, 0x1021, 0x24630001,
91540x3e00008, 0xaf430328, 0x3e00008, 0x0,
91550x0, 0x0, 0x0, 0x0 };
9156static u32 tigon2FwRodata[(MAX_RODATA_LEN/4) + 1] __devinitdata = {
91570x24486561, 0x6465723a, 0x202f7072,
91580x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
91590x2f2e2f6e, 0x69632f66, 0x77322f63, 0x6f6d6d6f,
91600x6e2f6677, 0x6d61696e, 0x2e632c76, 0x20312e31,
91610x2e322e34, 0x35203139, 0x39392f30, 0x312f3234,
91620x2030303a, 0x31303a35, 0x35207368, 0x75616e67,
91630x20457870, 0x20240000, 0x65767452, 0x6e674600,
91640x51657674, 0x46000000, 0x51657674, 0x505f4600,
91650x4d657674, 0x526e6746, 0x0, 0x4d516576,
91660x74460000, 0x4d516576, 0x505f4600, 0x5173436f,
91670x6e495f46, 0x0, 0x5173436f, 0x6e734600,
91680x51725072, 0x6f644600, 0x6261644d, 0x656d537a,
91690x0, 0x68775665, 0x72000000, 0x62616448,
91700x77566572, 0x0, 0x2a2a4441, 0x574e5f41,
91710x0, 0x74785278, 0x4266537a, 0x0,
91720x62664174, 0x6e4d726b, 0x0, 0x7265645a,
91730x6f6e6531, 0x0, 0x70636943, 0x6f6e6600,
91740x67656e43, 0x6f6e6600, 0x2a646d61, 0x5244666c,
91750x0, 0x2a50414e, 0x49432a00, 0x2e2e2f2e,
91760x2e2f2e2e, 0x2f2e2e2f, 0x2e2e2f73, 0x72632f6e,
91770x69632f66, 0x77322f63, 0x6f6d6d6f, 0x6e2f6677,
91780x6d61696e, 0x2e630000, 0x72636246, 0x6c616773,
91790x0, 0x62616452, 0x78526362, 0x0,
91800x676c6f62, 0x466c6773, 0x0, 0x2b5f6469,
91810x73705f6c, 0x6f6f7000, 0x2b65765f, 0x68616e64,
91820x6c657200, 0x63616e74, 0x31446d61, 0x0,
91830x2b715f64, 0x6d615f74, 0x6f5f6e69, 0x635f636b,
91840x73756d00, 0x2b685f73, 0x656e645f, 0x64617461,
91850x5f726561, 0x64795f63, 0x6b73756d, 0x0,
91860x2b685f64, 0x6d615f72, 0x645f6173, 0x73697374,
91870x5f636b73, 0x756d0000, 0x74436b73, 0x6d4f6e00,
91880x2b715f64, 0x6d615f74, 0x6f5f6e69, 0x63000000,
91890x2b685f73, 0x656e645f, 0x64617461, 0x5f726561,
91900x64790000, 0x2b685f64, 0x6d615f72, 0x645f6173,
91910x73697374, 0x0, 0x74436b73, 0x6d4f6666,
91920x0, 0x2b685f73, 0x656e645f, 0x62645f72,
91930x65616479, 0x0, 0x68737453, 0x52696e67,
91940x0, 0x62616453, 0x52696e67, 0x0,
91950x6e696353, 0x52696e67, 0x0, 0x77446d61,
91960x416c6c41, 0x0, 0x2b715f64, 0x6d615f74,
91970x6f5f686f, 0x73745f63, 0x6b73756d, 0x0,
91980x2b685f6d, 0x61635f72, 0x785f636f, 0x6d705f63,
91990x6b73756d, 0x0, 0x2b685f64, 0x6d615f77,
92000x725f6173, 0x73697374, 0x5f636b73, 0x756d0000,
92010x72436b73, 0x6d4f6e00, 0x2b715f64, 0x6d615f74,
92020x6f5f686f, 0x73740000, 0x2b685f6d, 0x61635f72,
92030x785f636f, 0x6d700000, 0x2b685f64, 0x6d615f77,
92040x725f6173, 0x73697374, 0x0, 0x72436b73,
92050x6d4f6666, 0x0, 0x2b685f72, 0x6563765f,
92060x62645f72, 0x65616479, 0x0, 0x2b685f72,
92070x6563765f, 0x6a756d62, 0x6f5f6264, 0x5f726561,
92080x64790000, 0x2b685f72, 0x6563765f, 0x6d696e69,
92090x5f62645f, 0x72656164, 0x79000000, 0x2b6d685f,
92100x636f6d6d, 0x616e6400, 0x2b685f74, 0x696d6572,
92110x0, 0x2b685f64, 0x6f5f7570, 0x64617465,
92120x5f74785f, 0x636f6e73, 0x0, 0x2b685f64,
92130x6f5f7570, 0x64617465, 0x5f72785f, 0x70726f64,
92140x0, 0x2b636b73, 0x756d3136, 0x0,
92150x2b706565, 0x6b5f6d61, 0x635f7278, 0x5f776100,
92160x2b706565, 0x6b5f6d61, 0x635f7278, 0x0,
92170x2b646571, 0x5f6d6163, 0x5f727800, 0x2b685f6d,
92180x61635f72, 0x785f6174, 0x746e0000, 0x62616452,
92190x6574537a, 0x0, 0x72784264, 0x4266537a,
92200x0, 0x2b6e756c, 0x6c5f6861, 0x6e646c65,
92210x72000000, 0x66774f70, 0x4661696c, 0x0,
92220x2b685f75, 0x70646174, 0x655f6c65, 0x64340000,
92230x2b685f75, 0x70646174, 0x655f6c65, 0x64360000,
92240x2b685f75, 0x70646174, 0x655f6c65, 0x64320000,
92250x696e7453, 0x74617465, 0x0, 0x2a2a696e,
92260x69744370, 0x0, 0x23736372, 0x65616d00,
92270x69537461, 0x636b4572, 0x0, 0x70726f62,
92280x654d656d, 0x0, 0x2a2a4441, 0x574e5f42,
92290x0, 0x2b73775f, 0x646d615f, 0x61737369,
92300x73745f70, 0x6c75735f, 0x74696d65, 0x72000000,
92310x2b267072, 0x656c6f61, 0x645f7772, 0x5f646573,
92320x63720000, 0x2b267072, 0x656c6f61, 0x645f7264,
92330x5f646573, 0x63720000, 0x2b685f68, 0x665f7469,
92340x6d657200, 0x24486561, 0x6465723a, 0x202f7072,
92350x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
92360x2f2e2f6e, 0x69632f66, 0x77322f63, 0x6f6d6d6f,
92370x6e2f7469, 0x6d65722e, 0x632c7620, 0x312e312e,
92380x322e3335, 0x20313939, 0x392f3031, 0x2f323720,
92390x31393a30, 0x393a3530, 0x20686179, 0x65732045,
92400x78702024, 0x0, 0x65767452, 0x6e674600,
92410x51657674, 0x46000000, 0x51657674, 0x505f4600,
92420x4d657674, 0x526e6746, 0x0, 0x4d516576,
92430x74460000, 0x4d516576, 0x505f4600, 0x5173436f,
92440x6e495f46, 0x0, 0x5173436f, 0x6e734600,
92450x51725072, 0x6f644600, 0x542d446d, 0x61526432,
92460x0, 0x542d446d, 0x61526431, 0x0,
92470x542d446d, 0x61526442, 0x0, 0x542d446d,
92480x61577232, 0x0, 0x542d446d, 0x61577231,
92490x0, 0x542d446d, 0x61577242, 0x0,
92500x0, 0x24486561, 0x6465723a, 0x202f7072,
92510x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
92520x2f2e2f6e, 0x69632f66, 0x77322f63, 0x6f6d6d6f,
92530x6e2f636f, 0x6d6d616e, 0x642e632c, 0x7620312e,
92540x312e322e, 0x32382031, 0x3939392f, 0x30312f32,
92550x30203139, 0x3a34393a, 0x34392073, 0x6875616e,
92560x67204578, 0x70202400, 0x65767452, 0x6e674600,
92570x51657674, 0x46000000, 0x51657674, 0x505f4600,
92580x4d657674, 0x526e6746, 0x0, 0x4d516576,
92590x74460000, 0x4d516576, 0x505f4600, 0x5173436f,
92600x6e495f46, 0x0, 0x5173436f, 0x6e734600,
92610x51725072, 0x6f644600, 0x3f48636d, 0x644d6278,
92620x0, 0x3f636d64, 0x48737453, 0x0,
92630x3f636d64, 0x4d634d64, 0x0, 0x3f636d64,
92640x50726f6d, 0x0, 0x3f636d64, 0x4c696e6b,
92650x0, 0x3f636d64, 0x45727200, 0x86ac,
92660x8e5c, 0x8e5c, 0x8de4, 0x8b78,
92670x8e30, 0x8e5c, 0x8790, 0x8800,
92680x8990, 0x8a68, 0x8a34, 0x8e5c,
92690x8870, 0x8b24, 0x8e5c, 0x8b34,
92700x87b4, 0x8824, 0x0, 0x0,
92710x0, 0x24486561, 0x6465723a, 0x202f7072,
92720x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
92730x2f2e2f6e, 0x69632f66, 0x77322f63, 0x6f6d6d6f,
92740x6e2f6d63, 0x6173742e, 0x632c7620, 0x312e312e,
92750x322e3820, 0x31393938, 0x2f31322f, 0x30382030,
92760x323a3336, 0x3a333620, 0x73687561, 0x6e672045,
92770x78702024, 0x0, 0x65767452, 0x6e674600,
92780x51657674, 0x46000000, 0x51657674, 0x505f4600,
92790x4d657674, 0x526e6746, 0x0, 0x4d516576,
92800x74460000, 0x4d516576, 0x505f4600, 0x5173436f,
92810x6e495f46, 0x0, 0x5173436f, 0x6e734600,
92820x51725072, 0x6f644600, 0x6164644d, 0x63447570,
92830x0, 0x6164644d, 0x6346756c, 0x0,
92840x64656c4d, 0x634e6f45, 0x0, 0x0,
92850x0, 0x24486561, 0x6465723a, 0x202f7072,
92860x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
92870x2f2e2f6e, 0x69632f66, 0x77322f63, 0x6f6d6d6f,
92880x6e2f646d, 0x612e632c, 0x7620312e, 0x312e322e,
92890x32342031, 0x3939382f, 0x31322f32, 0x31203030,
92900x3a33333a, 0x30392073, 0x6875616e, 0x67204578,
92910x70202400, 0x65767452, 0x6e674600, 0x51657674,
92920x46000000, 0x51657674, 0x505f4600, 0x4d657674,
92930x526e6746, 0x0, 0x4d516576, 0x74460000,
92940x4d516576, 0x505f4600, 0x5173436f, 0x6e495f46,
92950x0, 0x5173436f, 0x6e734600, 0x51725072,
92960x6f644600, 0x7377446d, 0x614f6666, 0x0,
92970x31446d61, 0x4f6e0000, 0x7377446d, 0x614f6e00,
92980x2372446d, 0x6141544e, 0x0, 0x72446d61,
92990x41544e30, 0x0, 0x72446d61, 0x41544e31,
93000x0, 0x72446d61, 0x34476200, 0x2a50414e,
93010x49432a00, 0x2e2e2f2e, 0x2e2f2e2e, 0x2f2e2e2f,
93020x2e2e2f73, 0x72632f6e, 0x69632f66, 0x77322f63,
93030x6f6d6d6f, 0x6e2f646d, 0x612e6300, 0x2377446d,
93040x6141544e, 0x0, 0x77446d61, 0x41544e30,
93050x0, 0x77446d61, 0x41544e31, 0x0,
93060x77446d61, 0x34476200, 0x0, 0x0,
93070x0, 0x24486561, 0x6465723a, 0x202f7072,
93080x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
93090x2f2e2f6e, 0x69632f66, 0x77322f63, 0x6f6d6d6f,
93100x6e2f7472, 0x6163652e, 0x632c7620, 0x312e312e,
93110x322e3520, 0x31393938, 0x2f30392f, 0x33302031,
93120x383a3530, 0x3a323820, 0x73687561, 0x6e672045,
93130x78702024, 0x0, 0x0, 0x0,
93140x0, 0x24486561, 0x6465723a, 0x202f7072,
93150x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
93160x2f2e2f6e, 0x69632f66, 0x77322f63, 0x6f6d6d6f,
93170x6e2f6461, 0x74612e63, 0x2c762031, 0x2e312e32,
93180x2e313220, 0x31393939, 0x2f30312f, 0x32302031,
93190x393a3439, 0x3a353120, 0x73687561, 0x6e672045,
93200x78702024, 0x0, 0x46575f56, 0x45525349,
93210x4f4e3a20, 0x23312046, 0x72692041, 0x70722037,
93220x2031373a, 0x35373a35, 0x32205044, 0x54203230,
93230x30300000, 0x46575f43, 0x4f4d5049, 0x4c455f54,
93240x494d453a, 0x2031373a, 0x35373a35, 0x32000000,
93250x46575f43, 0x4f4d5049, 0x4c455f42, 0x593a2064,
93260x65767263, 0x73000000, 0x46575f43, 0x4f4d5049,
93270x4c455f48, 0x4f53543a, 0x20636f6d, 0x70757465,
93280x0, 0x46575f43, 0x4f4d5049, 0x4c455f44,
93290x4f4d4149, 0x4e3a2065, 0x6e672e61, 0x6374656f,
93300x6e2e636f, 0x6d000000, 0x46575f43, 0x4f4d5049,
93310x4c45523a, 0x20676363, 0x20766572, 0x73696f6e,
93320x20322e37, 0x2e320000, 0x0, 0x12041100,
93330x0, 0x24486561, 0x6465723a, 0x202f7072,
93340x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
93350x2f2e2f6e, 0x69632f66, 0x77322f63, 0x6f6d6d6f,
93360x6e2f6d65, 0x6d2e632c, 0x7620312e, 0x312e322e,
93370x35203139, 0x39382f30, 0x392f3330, 0x2031383a,
93380x35303a30, 0x38207368, 0x75616e67, 0x20457870,
93390x20240000, 0x24486561, 0x6465723a, 0x202f7072,
93400x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
93410x2f2e2f6e, 0x69632f66, 0x77322f63, 0x6f6d6d6f,
93420x6e2f7365, 0x6e642e63, 0x2c762031, 0x2e312e32,
93430x2e343420, 0x31393938, 0x2f31322f, 0x32312030,
93440x303a3333, 0x3a313820, 0x73687561, 0x6e672045,
93450x78702024, 0x0, 0x65767452, 0x6e674600,
93460x51657674, 0x46000000, 0x51657674, 0x505f4600,
93470x4d657674, 0x526e6746, 0x0, 0x4d516576,
93480x74460000, 0x4d516576, 0x505f4600, 0x5173436f,
93490x6e495f46, 0x0, 0x5173436f, 0x6e734600,
93500x51725072, 0x6f644600, 0x69736e74, 0x54637055,
93510x0, 0x24486561, 0x6465723a, 0x202f7072,
93520x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
93530x2f2e2f6e, 0x69632f66, 0x77322f63, 0x6f6d6d6f,
93540x6e2f7265, 0x63762e63, 0x2c762031, 0x2e312e32,
93550x2e353320, 0x31393939, 0x2f30312f, 0x31362030,
93560x323a3535, 0x3a343320, 0x73687561, 0x6e672045,
93570x78702024, 0x0, 0x65767452, 0x6e674600,
93580x51657674, 0x46000000, 0x51657674, 0x505f4600,
93590x4d657674, 0x526e6746, 0x0, 0x4d516576,
93600x74460000, 0x4d516576, 0x505f4600, 0x5173436f,
93610x6e495f46, 0x0, 0x5173436f, 0x6e734600,
93620x51725072, 0x6f644600, 0x724d6163, 0x43686b30,
93630x0, 0x72784672, 0x6d324c67, 0x0,
93640x72784e6f, 0x53744264, 0x0, 0x72784e6f,
93650x4d694264, 0x0, 0x72784e6f, 0x4a6d4264,
93660x0, 0x7278436b, 0x446d6146, 0x0,
93670x72785144, 0x6d457846, 0x0, 0x72785144,
93680x6d614600, 0x72785144, 0x4c426446, 0x0,
93690x72785144, 0x6d426446, 0x0, 0x72784372,
93700x63506164, 0x0, 0x72536d51, 0x446d6146,
93710x0, 0x24486561, 0x6465723a, 0x202f7072,
93720x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
93730x2f2e2f6e, 0x69632f66, 0x77322f63, 0x6f6d6d6f,
93740x6e2f6d61, 0x632e632c, 0x7620312e, 0x312e322e,
93750x32322031, 0x3939382f, 0x31322f30, 0x38203032,
93760x3a33363a, 0x33302073, 0x6875616e, 0x67204578,
93770x70202400, 0x65767452, 0x6e674600, 0x51657674,
93780x46000000, 0x51657674, 0x505f4600, 0x4d657674,
93790x526e6746, 0x0, 0x4d516576, 0x74460000,
93800x4d516576, 0x505f4600, 0x5173436f, 0x6e495f46,
93810x0, 0x5173436f, 0x6e734600, 0x51725072,
93820x6f644600, 0x6d616354, 0x68726573, 0x0,
93830x23744d61, 0x6341544e, 0x0, 0x23724d61,
93840x6341544e, 0x0, 0x72656d41, 0x73737274,
93850x0, 0x6c696e6b, 0x444f574e, 0x0,
93860x6c696e6b, 0x55500000, 0x0, 0x0,
93870x0, 0x24486561, 0x6465723a, 0x202f7072,
93880x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
93890x2f2e2f6e, 0x69632f66, 0x77322f63, 0x6f6d6d6f,
93900x6e2f636b, 0x73756d2e, 0x632c7620, 0x312e312e,
93910x322e3920, 0x31393939, 0x2f30312f, 0x31342030,
93920x303a3033, 0x3a343820, 0x73687561, 0x6e672045,
93930x78702024, 0x0, 0x65767452, 0x6e674600,
93940x51657674, 0x46000000, 0x51657674, 0x505f4600,
93950x4d657674, 0x526e6746, 0x0, 0x4d516576,
93960x74460000, 0x4d516576, 0x505f4600, 0x5173436f,
93970x6e495f46, 0x0, 0x5173436f, 0x6e734600,
93980x51725072, 0x6f644600, 0x0, 0x0,
93990x0, 0x50726f62, 0x65506879, 0x0,
94000x6c6e6b41, 0x53535254, 0x0, 0x109a4,
94010x10a1c, 0x10a50, 0x10a7c, 0x11050,
94020x10aa8, 0x10b10, 0x111fc, 0x10dc0,
94030x10c68, 0x10c80, 0x10cc4, 0x10cec,
94040x10d0c, 0x10d34, 0x111fc, 0x10dc0,
94050x10df8, 0x10e10, 0x10e40, 0x10e68,
94060x10e88, 0x10eb0, 0x0, 0x10fdc,
94070x11008, 0x1102c, 0x111fc, 0x11050,
94080x11078, 0x11108, 0x0, 0x0,
94090x0, 0x1186c, 0x1193c, 0x11a14,
94100x11ae4, 0x11b40, 0x11c1c, 0x11c44,
94110x11d20, 0x11d48, 0x11ef0, 0x11f18,
94120x120c0, 0x122b8, 0x1254c, 0x12460,
94130x1254c, 0x12578, 0x120e8, 0x12290,
94140x7273745f, 0x676d6969, 0x0, 0x12608,
94150x12640, 0x12728, 0x13374, 0x133b4,
94160x133cc, 0x7365746c, 0x6f6f7000, 0x0,
94170x0, 0x13bbc, 0x13bfc, 0x13c8c,
94180x13cd0, 0x13d34, 0x13dc0, 0x13df4,
94190x13e7c, 0x13f14, 0x13fe4, 0x14024,
94200x140a8, 0x140cc, 0x141dc, 0x646f4261,
94210x73655067, 0x0, 0x0, 0x0,
94220x0, 0x73746d61, 0x634c4e4b, 0x0,
94230x6765746d, 0x636c6e6b, 0x0, 0x14ed8,
94240x14ed8, 0x14b8c, 0x14bd8, 0x14c24,
94250x14ed8, 0x7365746d, 0x61636163, 0x74000000,
94260x0, 0x0 };
9427static u32 tigon2FwData[(MAX_DATA_LEN/4) + 1] __devinitdata = {
94280x1,
94290x1, 0x1, 0xc001fc, 0x3ffc,
94300xc00000, 0x416c7465, 0x6f6e2041, 0x63654e49,
94310x43205600, 0x0, 0x0, 0x0,
94320x0, 0x0, 0x0, 0x416c7465,
94330x6f6e2041, 0x63654e49, 0x43205600, 0x42424242,
94340x0, 0x0, 0x0, 0x1ffffc,
94350x1fff7c, 0x0, 0x0, 0x0,
94360x0, 0x0, 0x0, 0x60cf00,
94370x60, 0xcf000000, 0x0, 0x0,
94380x0, 0x0, 0x0, 0x0,
94390x0, 0x0, 0x0, 0x0,
94400x0, 0x0, 0x0, 0x0,
94410x0, 0x0, 0x0, 0x0,
94420x0, 0x0, 0x3, 0x0,
94430x1, 0x0, 0x0, 0x0,
94440x1, 0x0, 0x1, 0x0,
94450x0, 0x0, 0x0, 0x1,
94460x1, 0x0, 0x0, 0x0,
94470x0, 0x0, 0x1000000, 0x21000000,
94480x12000140, 0x0, 0x0, 0x20000000,
94490x120000a0, 0x0, 0x12000060, 0x12000180,
94500x120001e0, 0x0, 0x0, 0x0,
94510x1, 0x0, 0x0, 0x0,
94520x0, 0x0, 0x0, 0x2,
94530x0, 0x0, 0x30001, 0x1,
94540x30201, 0x0, 0x0, 0x1010101,
94550x1010100, 0x10100, 0x1010001, 0x10001,
94560x1000101, 0x101, 0x0, 0x0 };
diff --git a/drivers/net/amd8111e.c b/drivers/net/amd8111e.c
index 187ac6eb6e94..7709992bb6bf 100644
--- a/drivers/net/amd8111e.c
+++ b/drivers/net/amd8111e.c
@@ -1813,6 +1813,25 @@ static void __devinit amd8111e_probe_ext_phy(struct net_device* dev)
1813 lp->ext_phy_addr = 1; 1813 lp->ext_phy_addr = 1;
1814} 1814}
1815 1815
1816static const struct net_device_ops amd8111e_netdev_ops = {
1817 .ndo_open = amd8111e_open,
1818 .ndo_stop = amd8111e_close,
1819 .ndo_start_xmit = amd8111e_start_xmit,
1820 .ndo_tx_timeout = amd8111e_tx_timeout,
1821 .ndo_get_stats = amd8111e_get_stats,
1822 .ndo_set_multicast_list = amd8111e_set_multicast_list,
1823 .ndo_validate_addr = eth_validate_addr,
1824 .ndo_set_mac_address = amd8111e_set_mac_address,
1825 .ndo_do_ioctl = amd8111e_ioctl,
1826 .ndo_change_mtu = amd8111e_change_mtu,
1827#if AMD8111E_VLAN_TAG_USED
1828 .ndo_vlan_rx_register = amd8111e_vlan_rx_register,
1829#endif
1830#ifdef CONFIG_NET_POLL_CONTROLLER
1831 .ndo_poll_controller = amd8111e_poll,
1832#endif
1833};
1834
1816static int __devinit amd8111e_probe_one(struct pci_dev *pdev, 1835static int __devinit amd8111e_probe_one(struct pci_dev *pdev,
1817 const struct pci_device_id *ent) 1836 const struct pci_device_id *ent)
1818{ 1837{
@@ -1872,7 +1891,6 @@ static int __devinit amd8111e_probe_one(struct pci_dev *pdev,
1872 1891
1873#if AMD8111E_VLAN_TAG_USED 1892#if AMD8111E_VLAN_TAG_USED
1874 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX ; 1893 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX ;
1875 dev->vlan_rx_register =amd8111e_vlan_rx_register;
1876#endif 1894#endif
1877 1895
1878 lp = netdev_priv(dev); 1896 lp = netdev_priv(dev);
@@ -1901,27 +1919,16 @@ static int __devinit amd8111e_probe_one(struct pci_dev *pdev,
1901 if(dynamic_ipg[card_idx++]) 1919 if(dynamic_ipg[card_idx++])
1902 lp->options |= OPTION_DYN_IPG_ENABLE; 1920 lp->options |= OPTION_DYN_IPG_ENABLE;
1903 1921
1922
1904 /* Initialize driver entry points */ 1923 /* Initialize driver entry points */
1905 dev->open = amd8111e_open; 1924 dev->netdev_ops = &amd8111e_netdev_ops;
1906 dev->hard_start_xmit = amd8111e_start_xmit;
1907 dev->stop = amd8111e_close;
1908 dev->get_stats = amd8111e_get_stats;
1909 dev->set_multicast_list = amd8111e_set_multicast_list;
1910 dev->set_mac_address = amd8111e_set_mac_address;
1911 dev->do_ioctl = amd8111e_ioctl;
1912 dev->change_mtu = amd8111e_change_mtu;
1913 SET_ETHTOOL_OPS(dev, &ops); 1925 SET_ETHTOOL_OPS(dev, &ops);
1914 dev->irq =pdev->irq; 1926 dev->irq =pdev->irq;
1915 dev->tx_timeout = amd8111e_tx_timeout;
1916 dev->watchdog_timeo = AMD8111E_TX_TIMEOUT; 1927 dev->watchdog_timeo = AMD8111E_TX_TIMEOUT;
1917 netif_napi_add(dev, &lp->napi, amd8111e_rx_poll, 32); 1928 netif_napi_add(dev, &lp->napi, amd8111e_rx_poll, 32);
1918#ifdef CONFIG_NET_POLL_CONTROLLER
1919 dev->poll_controller = amd8111e_poll;
1920#endif
1921 1929
1922#if AMD8111E_VLAN_TAG_USED 1930#if AMD8111E_VLAN_TAG_USED
1923 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; 1931 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
1924 dev->vlan_rx_register =amd8111e_vlan_rx_register;
1925#endif 1932#endif
1926 /* Probe the external PHY */ 1933 /* Probe the external PHY */
1927 amd8111e_probe_ext_phy(dev); 1934 amd8111e_probe_ext_phy(dev);
diff --git a/drivers/net/appletalk/ipddp.c b/drivers/net/appletalk/ipddp.c
index 9a0be9b2eaad..da64ba88d7f8 100644
--- a/drivers/net/appletalk/ipddp.c
+++ b/drivers/net/appletalk/ipddp.c
@@ -48,12 +48,18 @@ static int ipddp_mode = IPDDP_DECAP;
48 48
49/* Index to functions, as function prototypes. */ 49/* Index to functions, as function prototypes. */
50static int ipddp_xmit(struct sk_buff *skb, struct net_device *dev); 50static int ipddp_xmit(struct sk_buff *skb, struct net_device *dev);
51static struct net_device_stats *ipddp_get_stats(struct net_device *dev);
52static int ipddp_create(struct ipddp_route *new_rt); 51static int ipddp_create(struct ipddp_route *new_rt);
53static int ipddp_delete(struct ipddp_route *rt); 52static int ipddp_delete(struct ipddp_route *rt);
54static struct ipddp_route* ipddp_find_route(struct ipddp_route *rt); 53static struct ipddp_route* ipddp_find_route(struct ipddp_route *rt);
55static int ipddp_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); 54static int ipddp_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
56 55
56static const struct net_device_ops ipddp_netdev_ops = {
57 .ndo_start_xmit = ipddp_xmit,
58 .ndo_do_ioctl = ipddp_ioctl,
59 .ndo_change_mtu = eth_change_mtu,
60 .ndo_set_mac_address = eth_mac_addr,
61 .ndo_validate_addr = eth_validate_addr,
62};
57 63
58static struct net_device * __init ipddp_init(void) 64static struct net_device * __init ipddp_init(void)
59{ 65{
@@ -61,7 +67,7 @@ static struct net_device * __init ipddp_init(void)
61 struct net_device *dev; 67 struct net_device *dev;
62 int err; 68 int err;
63 69
64 dev = alloc_etherdev(sizeof(struct net_device_stats)); 70 dev = alloc_etherdev(0);
65 if (!dev) 71 if (!dev)
66 return ERR_PTR(-ENOMEM); 72 return ERR_PTR(-ENOMEM);
67 73
@@ -71,9 +77,7 @@ static struct net_device * __init ipddp_init(void)
71 printk(version); 77 printk(version);
72 78
73 /* Initalize the device structure. */ 79 /* Initalize the device structure. */
74 dev->hard_start_xmit = ipddp_xmit; 80 dev->netdev_ops = &ipddp_netdev_ops;
75 dev->get_stats = ipddp_get_stats;
76 dev->do_ioctl = ipddp_ioctl;
77 81
78 dev->type = ARPHRD_IPDDP; /* IP over DDP tunnel */ 82 dev->type = ARPHRD_IPDDP; /* IP over DDP tunnel */
79 dev->mtu = 585; 83 dev->mtu = 585;
@@ -103,13 +107,6 @@ static struct net_device * __init ipddp_init(void)
103 return dev; 107 return dev;
104} 108}
105 109
106/*
107 * Get the current statistics. This may be called with the card open or closed.
108 */
109static struct net_device_stats *ipddp_get_stats(struct net_device *dev)
110{
111 return netdev_priv(dev);
112}
113 110
114/* 111/*
115 * Transmit LLAP/ELAP frame using aarp_send_ddp. 112 * Transmit LLAP/ELAP frame using aarp_send_ddp.
@@ -170,8 +167,8 @@ static int ipddp_xmit(struct sk_buff *skb, struct net_device *dev)
170 167
171 skb->protocol = htons(ETH_P_ATALK); /* Protocol has changed */ 168 skb->protocol = htons(ETH_P_ATALK); /* Protocol has changed */
172 169
173 ((struct net_device_stats *) netdev_priv(dev))->tx_packets++; 170 dev->stats.tx_packets++;
174 ((struct net_device_stats *) netdev_priv(dev))->tx_bytes += skb->len; 171 dev->stats.tx_bytes += skb->len;
175 172
176 if(aarp_send_ddp(rt->dev, skb, &rt->at, NULL) < 0) 173 if(aarp_send_ddp(rt->dev, skb, &rt->at, NULL) < 0)
177 dev_kfree_skb(skb); 174 dev_kfree_skb(skb);
diff --git a/drivers/net/arm/etherh.c b/drivers/net/arm/etherh.c
index 6278606d1049..d15d8b79d8e5 100644
--- a/drivers/net/arm/etherh.c
+++ b/drivers/net/arm/etherh.c
@@ -646,6 +646,7 @@ static const struct net_device_ops etherh_netdev_ops = {
646 .ndo_get_stats = ei_get_stats, 646 .ndo_get_stats = ei_get_stats,
647 .ndo_set_multicast_list = ei_set_multicast_list, 647 .ndo_set_multicast_list = ei_set_multicast_list,
648 .ndo_validate_addr = eth_validate_addr, 648 .ndo_validate_addr = eth_validate_addr,
649 .ndo_set_mac_address = eth_set_mac_addr,
649 .ndo_change_mtu = eth_change_mtu, 650 .ndo_change_mtu = eth_change_mtu,
650#ifdef CONFIG_NET_POLL_CONTROLLER 651#ifdef CONFIG_NET_POLL_CONTROLLER
651 .ndo_poll_controller = ei_poll, 652 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/arm/ks8695net.c b/drivers/net/arm/ks8695net.c
index 9ad22d1b00fd..1cf2f949c0b4 100644
--- a/drivers/net/arm/ks8695net.c
+++ b/drivers/net/arm/ks8695net.c
@@ -1357,6 +1357,7 @@ static const struct net_device_ops ks8695_netdev_ops = {
1357 .ndo_start_xmit = ks8695_start_xmit, 1357 .ndo_start_xmit = ks8695_start_xmit,
1358 .ndo_tx_timeout = ks8695_timeout, 1358 .ndo_tx_timeout = ks8695_timeout,
1359 .ndo_set_mac_address = ks8695_set_mac, 1359 .ndo_set_mac_address = ks8695_set_mac,
1360 .ndo_validate_addr = eth_validate_addr,
1360 .ndo_set_multicast_list = ks8695_set_multicast, 1361 .ndo_set_multicast_list = ks8695_set_multicast,
1361}; 1362};
1362 1363
diff --git a/drivers/net/atp.c b/drivers/net/atp.c
index ea493ce23982..4317b3edb3d7 100644
--- a/drivers/net/atp.c
+++ b/drivers/net/atp.c
@@ -204,8 +204,7 @@ static irqreturn_t atp_interrupt(int irq, void *dev_id);
204static void net_rx(struct net_device *dev); 204static void net_rx(struct net_device *dev);
205static void read_block(long ioaddr, int length, unsigned char *buffer, int data_mode); 205static void read_block(long ioaddr, int length, unsigned char *buffer, int data_mode);
206static int net_close(struct net_device *dev); 206static int net_close(struct net_device *dev);
207static void set_rx_mode_8002(struct net_device *dev); 207static void set_rx_mode(struct net_device *dev);
208static void set_rx_mode_8012(struct net_device *dev);
209static void tx_timeout(struct net_device *dev); 208static void tx_timeout(struct net_device *dev);
210 209
211 210
@@ -242,6 +241,17 @@ static int __init atp_init(void)
242 return -ENODEV; 241 return -ENODEV;
243} 242}
244 243
244static const struct net_device_ops atp_netdev_ops = {
245 .ndo_open = net_open,
246 .ndo_stop = net_close,
247 .ndo_start_xmit = atp_send_packet,
248 .ndo_set_multicast_list = set_rx_mode,
249 .ndo_tx_timeout = tx_timeout,
250 .ndo_change_mtu = eth_change_mtu,
251 .ndo_set_mac_address = eth_mac_addr,
252 .ndo_validate_addr = eth_validate_addr,
253};
254
245static int __init atp_probe1(long ioaddr) 255static int __init atp_probe1(long ioaddr)
246{ 256{
247 struct net_device *dev = NULL; 257 struct net_device *dev = NULL;
@@ -342,12 +352,7 @@ static int __init atp_probe1(long ioaddr)
342 if (dev->mem_end & 0xf) 352 if (dev->mem_end & 0xf)
343 net_debug = dev->mem_end & 7; 353 net_debug = dev->mem_end & 7;
344 354
345 dev->open = net_open; 355 dev->netdev_ops = &atp_netdev_ops;
346 dev->stop = net_close;
347 dev->hard_start_xmit = atp_send_packet;
348 dev->set_multicast_list =
349 lp->chip_type == RTL8002 ? &set_rx_mode_8002 : &set_rx_mode_8012;
350 dev->tx_timeout = tx_timeout;
351 dev->watchdog_timeo = TX_TIMEOUT; 356 dev->watchdog_timeo = TX_TIMEOUT;
352 357
353 res = register_netdev(dev); 358 res = register_netdev(dev);
@@ -903,6 +908,17 @@ static void set_rx_mode_8012(struct net_device *dev)
903 write_reg(ioaddr, CMR2, CMR2_IRQOUT); /* Switch back to page 0 */ 908 write_reg(ioaddr, CMR2, CMR2_IRQOUT); /* Switch back to page 0 */
904} 909}
905 910
911static void set_rx_mode(struct net_device *dev)
912{
913 struct net_local *lp = netdev_priv(dev);
914
915 if (lp->chip_type == RTL8002)
916 return set_rx_mode_8002(dev);
917 else
918 return set_rx_mode_8012(dev);
919}
920
921
906static int __init atp_init_module(void) { 922static int __init atp_init_module(void) {
907 if (debug) /* Emit version even if no cards detected. */ 923 if (debug) /* Emit version even if no cards detected. */
908 printk(KERN_INFO "%s", version); 924 printk(KERN_INFO "%s", version);
diff --git a/drivers/net/ax88796.c b/drivers/net/ax88796.c
index 337488ec707c..a4eb6c40678c 100644
--- a/drivers/net/ax88796.c
+++ b/drivers/net/ax88796.c
@@ -37,7 +37,10 @@ static int phy_debug = 0;
37#define __ei_open ax_ei_open 37#define __ei_open ax_ei_open
38#define __ei_close ax_ei_close 38#define __ei_close ax_ei_close
39#define __ei_poll ax_ei_poll 39#define __ei_poll ax_ei_poll
40#define __ei_start_xmit ax_ei_start_xmit
40#define __ei_tx_timeout ax_ei_tx_timeout 41#define __ei_tx_timeout ax_ei_tx_timeout
42#define __ei_get_stats ax_ei_get_stats
43#define __ei_set_multicast_list ax_ei_set_multicast_list
41#define __ei_interrupt ax_ei_interrupt 44#define __ei_interrupt ax_ei_interrupt
42#define ____alloc_ei_netdev ax__alloc_ei_netdev 45#define ____alloc_ei_netdev ax__alloc_ei_netdev
43#define __NS8390_init ax_NS8390_init 46#define __NS8390_init ax_NS8390_init
@@ -623,6 +626,23 @@ static void ax_eeprom_register_write(struct eeprom_93cx6 *eeprom)
623} 626}
624#endif 627#endif
625 628
629static const struct net_device_ops ax_netdev_ops = {
630 .ndo_open = ax_open,
631 .ndo_stop = ax_close,
632 .ndo_do_ioctl = ax_ioctl,
633
634 .ndo_start_xmit = ax_ei_start_xmit,
635 .ndo_tx_timeout = ax_ei_tx_timeout,
636 .ndo_get_stats = ax_ei_get_stats,
637 .ndo_set_multicast_list = ax_ei_set_multicast_list,
638 .ndo_validate_addr = eth_validate_addr,
639 .ndo_set_mac_address = eth_mac_addr,
640 .ndo_change_mtu = eth_change_mtu,
641#ifdef CONFIG_NET_POLL_CONTROLLER
642 .ndo_poll_controller = ax_ei_poll,
643#endif
644};
645
626/* setup code */ 646/* setup code */
627 647
628static void ax_initial_setup(struct net_device *dev, struct ei_device *ei_local) 648static void ax_initial_setup(struct net_device *dev, struct ei_device *ei_local)
@@ -738,9 +758,7 @@ static int ax_init_dev(struct net_device *dev, int first_init)
738 ei_status.get_8390_hdr = &ax_get_8390_hdr; 758 ei_status.get_8390_hdr = &ax_get_8390_hdr;
739 ei_status.priv = 0; 759 ei_status.priv = 0;
740 760
741 dev->open = ax_open; 761 dev->netdev_ops = &ax_netdev_ops;
742 dev->stop = ax_close;
743 dev->do_ioctl = ax_ioctl;
744 dev->ethtool_ops = &ax_ethtool_ops; 762 dev->ethtool_ops = &ax_ethtool_ops;
745 763
746 ax->msg_enable = NETIF_MSG_LINK; 764 ax->msg_enable = NETIF_MSG_LINK;
@@ -753,9 +771,6 @@ static int ax_init_dev(struct net_device *dev, int first_init)
753 ax->mii.mdio_write = ax_phy_write; 771 ax->mii.mdio_write = ax_phy_write;
754 ax->mii.dev = dev; 772 ax->mii.dev = dev;
755 773
756#ifdef CONFIG_NET_POLL_CONTROLLER
757 dev->poll_controller = ax_ei_poll;
758#endif
759 ax_NS8390_init(dev, 0); 774 ax_NS8390_init(dev, 0);
760 775
761 if (first_init) 776 if (first_init)
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index 0e7470a201f0..c38512ebcea6 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -73,8 +73,8 @@
73 (BP)->tx_cons - (BP)->tx_prod - TX_RING_GAP(BP)) 73 (BP)->tx_cons - (BP)->tx_prod - TX_RING_GAP(BP))
74#define NEXT_TX(N) (((N) + 1) & (B44_TX_RING_SIZE - 1)) 74#define NEXT_TX(N) (((N) + 1) & (B44_TX_RING_SIZE - 1))
75 75
76#define RX_PKT_OFFSET 30 76#define RX_PKT_OFFSET (RX_HEADER_LEN + 2)
77#define RX_PKT_BUF_SZ (1536 + RX_PKT_OFFSET + 64) 77#define RX_PKT_BUF_SZ (1536 + RX_PKT_OFFSET)
78 78
79/* minimum number of free TX descriptors required to wake up TX process */ 79/* minimum number of free TX descriptors required to wake up TX process */
80#define B44_TX_WAKEUP_THRESH (B44_TX_RING_SIZE / 4) 80#define B44_TX_WAKEUP_THRESH (B44_TX_RING_SIZE / 4)
@@ -679,10 +679,10 @@ static int b44_alloc_rx_skb(struct b44 *bp, int src_idx, u32 dest_idx_unmasked)
679 dev_kfree_skb_any(skb); 679 dev_kfree_skb_any(skb);
680 return -ENOMEM; 680 return -ENOMEM;
681 } 681 }
682 bp->force_copybreak = 1;
682 } 683 }
683 684
684 rh = (struct rx_header *) skb->data; 685 rh = (struct rx_header *) skb->data;
685 skb_reserve(skb, RX_PKT_OFFSET);
686 686
687 rh->len = 0; 687 rh->len = 0;
688 rh->flags = 0; 688 rh->flags = 0;
@@ -693,13 +693,13 @@ static int b44_alloc_rx_skb(struct b44 *bp, int src_idx, u32 dest_idx_unmasked)
693 if (src_map != NULL) 693 if (src_map != NULL)
694 src_map->skb = NULL; 694 src_map->skb = NULL;
695 695
696 ctrl = (DESC_CTRL_LEN & (RX_PKT_BUF_SZ - RX_PKT_OFFSET)); 696 ctrl = (DESC_CTRL_LEN & RX_PKT_BUF_SZ);
697 if (dest_idx == (B44_RX_RING_SIZE - 1)) 697 if (dest_idx == (B44_RX_RING_SIZE - 1))
698 ctrl |= DESC_CTRL_EOT; 698 ctrl |= DESC_CTRL_EOT;
699 699
700 dp = &bp->rx_ring[dest_idx]; 700 dp = &bp->rx_ring[dest_idx];
701 dp->ctrl = cpu_to_le32(ctrl); 701 dp->ctrl = cpu_to_le32(ctrl);
702 dp->addr = cpu_to_le32((u32) mapping + RX_PKT_OFFSET + bp->dma_offset); 702 dp->addr = cpu_to_le32((u32) mapping + bp->dma_offset);
703 703
704 if (bp->flags & B44_FLAG_RX_RING_HACK) 704 if (bp->flags & B44_FLAG_RX_RING_HACK)
705 b44_sync_dma_desc_for_device(bp->sdev, bp->rx_ring_dma, 705 b44_sync_dma_desc_for_device(bp->sdev, bp->rx_ring_dma,
@@ -801,7 +801,7 @@ static int b44_rx(struct b44 *bp, int budget)
801 /* Omit CRC. */ 801 /* Omit CRC. */
802 len -= 4; 802 len -= 4;
803 803
804 if (len > RX_COPY_THRESHOLD) { 804 if (!bp->force_copybreak && len > RX_COPY_THRESHOLD) {
805 int skb_size; 805 int skb_size;
806 skb_size = b44_alloc_rx_skb(bp, cons, bp->rx_prod); 806 skb_size = b44_alloc_rx_skb(bp, cons, bp->rx_prod);
807 if (skb_size < 0) 807 if (skb_size < 0)
@@ -809,8 +809,8 @@ static int b44_rx(struct b44 *bp, int budget)
809 ssb_dma_unmap_single(bp->sdev, map, 809 ssb_dma_unmap_single(bp->sdev, map,
810 skb_size, DMA_FROM_DEVICE); 810 skb_size, DMA_FROM_DEVICE);
811 /* Leave out rx_header */ 811 /* Leave out rx_header */
812 skb_put(skb, len + RX_PKT_OFFSET); 812 skb_put(skb, len + RX_PKT_OFFSET);
813 skb_pull(skb, RX_PKT_OFFSET); 813 skb_pull(skb, RX_PKT_OFFSET);
814 } else { 814 } else {
815 struct sk_buff *copy_skb; 815 struct sk_buff *copy_skb;
816 816
@@ -2108,6 +2108,22 @@ static int __devinit b44_get_invariants(struct b44 *bp)
2108 return err; 2108 return err;
2109} 2109}
2110 2110
2111static const struct net_device_ops b44_netdev_ops = {
2112 .ndo_open = b44_open,
2113 .ndo_stop = b44_close,
2114 .ndo_start_xmit = b44_start_xmit,
2115 .ndo_get_stats = b44_get_stats,
2116 .ndo_set_multicast_list = b44_set_rx_mode,
2117 .ndo_set_mac_address = b44_set_mac_addr,
2118 .ndo_validate_addr = eth_validate_addr,
2119 .ndo_do_ioctl = b44_ioctl,
2120 .ndo_tx_timeout = b44_tx_timeout,
2121 .ndo_change_mtu = b44_change_mtu,
2122#ifdef CONFIG_NET_POLL_CONTROLLER
2123 .ndo_poll_controller = b44_poll_controller,
2124#endif
2125};
2126
2111static int __devinit b44_init_one(struct ssb_device *sdev, 2127static int __devinit b44_init_one(struct ssb_device *sdev,
2112 const struct ssb_device_id *ent) 2128 const struct ssb_device_id *ent)
2113{ 2129{
@@ -2137,6 +2153,7 @@ static int __devinit b44_init_one(struct ssb_device *sdev,
2137 bp = netdev_priv(dev); 2153 bp = netdev_priv(dev);
2138 bp->sdev = sdev; 2154 bp->sdev = sdev;
2139 bp->dev = dev; 2155 bp->dev = dev;
2156 bp->force_copybreak = 0;
2140 2157
2141 bp->msg_enable = netif_msg_init(b44_debug, B44_DEF_MSG_ENABLE); 2158 bp->msg_enable = netif_msg_init(b44_debug, B44_DEF_MSG_ENABLE);
2142 2159
@@ -2145,20 +2162,9 @@ static int __devinit b44_init_one(struct ssb_device *sdev,
2145 bp->rx_pending = B44_DEF_RX_RING_PENDING; 2162 bp->rx_pending = B44_DEF_RX_RING_PENDING;
2146 bp->tx_pending = B44_DEF_TX_RING_PENDING; 2163 bp->tx_pending = B44_DEF_TX_RING_PENDING;
2147 2164
2148 dev->open = b44_open; 2165 dev->netdev_ops = &b44_netdev_ops;
2149 dev->stop = b44_close;
2150 dev->hard_start_xmit = b44_start_xmit;
2151 dev->get_stats = b44_get_stats;
2152 dev->set_multicast_list = b44_set_rx_mode;
2153 dev->set_mac_address = b44_set_mac_addr;
2154 dev->do_ioctl = b44_ioctl;
2155 dev->tx_timeout = b44_tx_timeout;
2156 netif_napi_add(dev, &bp->napi, b44_poll, 64); 2166 netif_napi_add(dev, &bp->napi, b44_poll, 64);
2157 dev->watchdog_timeo = B44_TX_TIMEOUT; 2167 dev->watchdog_timeo = B44_TX_TIMEOUT;
2158#ifdef CONFIG_NET_POLL_CONTROLLER
2159 dev->poll_controller = b44_poll_controller;
2160#endif
2161 dev->change_mtu = b44_change_mtu;
2162 dev->irq = sdev->irq; 2168 dev->irq = sdev->irq;
2163 SET_ETHTOOL_OPS(dev, &b44_ethtool_ops); 2169 SET_ETHTOOL_OPS(dev, &b44_ethtool_ops);
2164 2170
diff --git a/drivers/net/b44.h b/drivers/net/b44.h
index 7db0c84a7950..e678498de6db 100644
--- a/drivers/net/b44.h
+++ b/drivers/net/b44.h
@@ -395,7 +395,7 @@ struct b44 {
395 u32 rx_pending; 395 u32 rx_pending;
396 u32 tx_pending; 396 u32 tx_pending;
397 u8 phy_addr; 397 u8 phy_addr;
398 398 u8 force_copybreak;
399 struct mii_if_info mii_if; 399 struct mii_if_info mii_if;
400}; 400};
401 401
diff --git a/drivers/net/bnx2x.h b/drivers/net/bnx2x.h
index fd705d1295a7..6fcccef4cf3d 100644
--- a/drivers/net/bnx2x.h
+++ b/drivers/net/bnx2x.h
@@ -20,6 +20,11 @@
20 * (you will need to reboot afterwards) */ 20 * (you will need to reboot afterwards) */
21/* #define BNX2X_STOP_ON_ERROR */ 21/* #define BNX2X_STOP_ON_ERROR */
22 22
23#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
24#define BCM_VLAN 1
25#endif
26
27
23/* error/debug prints */ 28/* error/debug prints */
24 29
25#define DRV_MODULE_NAME "bnx2x" 30#define DRV_MODULE_NAME "bnx2x"
@@ -78,11 +83,6 @@
78#endif 83#endif
79 84
80 85
81#ifdef NETIF_F_HW_VLAN_TX
82#define BCM_VLAN 1
83#endif
84
85
86#define U64_LO(x) (u32)(((u64)(x)) & 0xffffffff) 86#define U64_LO(x) (u32)(((u64)(x)) & 0xffffffff)
87#define U64_HI(x) (u32)(((u64)(x)) >> 32) 87#define U64_HI(x) (u32)(((u64)(x)) >> 32)
88#define HILO_U64(hi, lo) ((((u64)(hi)) << 32) + (lo)) 88#define HILO_U64(hi, lo) ((((u64)(hi)) << 32) + (lo))
@@ -150,6 +150,9 @@ struct sw_rx_page {
150 150
151#define PAGES_PER_SGE_SHIFT 0 151#define PAGES_PER_SGE_SHIFT 0
152#define PAGES_PER_SGE (1 << PAGES_PER_SGE_SHIFT) 152#define PAGES_PER_SGE (1 << PAGES_PER_SGE_SHIFT)
153#define SGE_PAGE_SIZE PAGE_SIZE
154#define SGE_PAGE_SHIFT PAGE_SHIFT
155#define SGE_PAGE_ALIGN(addr) PAGE_ALIGN(addr)
153 156
154#define BCM_RX_ETH_PAYLOAD_ALIGN 64 157#define BCM_RX_ETH_PAYLOAD_ALIGN 64
155 158
@@ -736,7 +739,7 @@ struct bnx2x {
736 struct bnx2x_fastpath fp[MAX_CONTEXT]; 739 struct bnx2x_fastpath fp[MAX_CONTEXT];
737 void __iomem *regview; 740 void __iomem *regview;
738 void __iomem *doorbells; 741 void __iomem *doorbells;
739#define BNX2X_DB_SIZE (16*2048) 742#define BNX2X_DB_SIZE (16*BCM_PAGE_SIZE)
740 743
741 struct net_device *dev; 744 struct net_device *dev;
742 struct pci_dev *pdev; 745 struct pci_dev *pdev;
@@ -801,6 +804,8 @@ struct bnx2x {
801#define TPA_ENABLE_FLAG 0x80 804#define TPA_ENABLE_FLAG 0x80
802#define NO_MCP_FLAG 0x100 805#define NO_MCP_FLAG 0x100
803#define BP_NOMCP(bp) (bp->flags & NO_MCP_FLAG) 806#define BP_NOMCP(bp) (bp->flags & NO_MCP_FLAG)
807#define HW_VLAN_TX_FLAG 0x400
808#define HW_VLAN_RX_FLAG 0x800
804 809
805 int func; 810 int func;
806#define BP_PORT(bp) (bp->func % PORT_MAX) 811#define BP_PORT(bp) (bp->func % PORT_MAX)
@@ -811,7 +816,7 @@ struct bnx2x {
811 int pm_cap; 816 int pm_cap;
812 int pcie_cap; 817 int pcie_cap;
813 818
814 struct work_struct sp_task; 819 struct delayed_work sp_task;
815 struct work_struct reset_task; 820 struct work_struct reset_task;
816 821
817 struct timer_list timer; 822 struct timer_list timer;
diff --git a/drivers/net/bnx2x_link.c b/drivers/net/bnx2x_link.c
index 67de94f1f30e..fefa6ab13064 100644
--- a/drivers/net/bnx2x_link.c
+++ b/drivers/net/bnx2x_link.c
@@ -3359,7 +3359,7 @@ static u8 bnx2x_format_ver(u32 num, u8 *str, u16 len)
3359 u8 shift = 8*4; 3359 u8 shift = 8*4;
3360 u8 digit; 3360 u8 digit;
3361 if (len < 10) { 3361 if (len < 10) {
3362 /* Need more then 10chars for this format */ 3362 /* Need more than 10chars for this format */
3363 *str_ptr = '\0'; 3363 *str_ptr = '\0';
3364 return -EINVAL; 3364 return -EINVAL;
3365 } 3365 }
diff --git a/drivers/net/bnx2x_main.c b/drivers/net/bnx2x_main.c
index ef8103b3523e..7c533797c064 100644
--- a/drivers/net/bnx2x_main.c
+++ b/drivers/net/bnx2x_main.c
@@ -38,9 +38,7 @@
38#include <linux/time.h> 38#include <linux/time.h>
39#include <linux/ethtool.h> 39#include <linux/ethtool.h>
40#include <linux/mii.h> 40#include <linux/mii.h>
41#ifdef NETIF_F_HW_VLAN_TX 41#include <linux/if_vlan.h>
42 #include <linux/if_vlan.h>
43#endif
44#include <net/ip.h> 42#include <net/ip.h>
45#include <net/tcp.h> 43#include <net/tcp.h>
46#include <net/checksum.h> 44#include <net/checksum.h>
@@ -95,6 +93,7 @@ MODULE_PARM_DESC(debug, "default debug msglevel");
95module_param(use_multi, int, 0); 93module_param(use_multi, int, 0);
96MODULE_PARM_DESC(use_multi, "use per-CPU queues"); 94MODULE_PARM_DESC(use_multi, "use per-CPU queues");
97#endif 95#endif
96static struct workqueue_struct *bnx2x_wq;
98 97
99enum bnx2x_board_type { 98enum bnx2x_board_type {
100 BCM57710 = 0, 99 BCM57710 = 0,
@@ -671,7 +670,8 @@ static void bnx2x_int_disable_sync(struct bnx2x *bp, int disable_hw)
671 synchronize_irq(bp->pdev->irq); 670 synchronize_irq(bp->pdev->irq);
672 671
673 /* make sure sp_task is not running */ 672 /* make sure sp_task is not running */
674 cancel_work_sync(&bp->sp_task); 673 cancel_delayed_work(&bp->sp_task);
674 flush_workqueue(bnx2x_wq);
675} 675}
676 676
677/* fast path */ 677/* fast path */
@@ -972,7 +972,7 @@ static inline void bnx2x_free_rx_sge(struct bnx2x *bp,
972 return; 972 return;
973 973
974 pci_unmap_page(bp->pdev, pci_unmap_addr(sw_buf, mapping), 974 pci_unmap_page(bp->pdev, pci_unmap_addr(sw_buf, mapping),
975 BCM_PAGE_SIZE*PAGES_PER_SGE, PCI_DMA_FROMDEVICE); 975 SGE_PAGE_SIZE*PAGES_PER_SGE, PCI_DMA_FROMDEVICE);
976 __free_pages(page, PAGES_PER_SGE_SHIFT); 976 __free_pages(page, PAGES_PER_SGE_SHIFT);
977 977
978 sw_buf->page = NULL; 978 sw_buf->page = NULL;
@@ -1000,7 +1000,7 @@ static inline int bnx2x_alloc_rx_sge(struct bnx2x *bp,
1000 if (unlikely(page == NULL)) 1000 if (unlikely(page == NULL))
1001 return -ENOMEM; 1001 return -ENOMEM;
1002 1002
1003 mapping = pci_map_page(bp->pdev, page, 0, BCM_PAGE_SIZE*PAGES_PER_SGE, 1003 mapping = pci_map_page(bp->pdev, page, 0, SGE_PAGE_SIZE*PAGES_PER_SGE,
1004 PCI_DMA_FROMDEVICE); 1004 PCI_DMA_FROMDEVICE);
1005 if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) { 1005 if (unlikely(dma_mapping_error(&bp->pdev->dev, mapping))) {
1006 __free_pages(page, PAGES_PER_SGE_SHIFT); 1006 __free_pages(page, PAGES_PER_SGE_SHIFT);
@@ -1096,9 +1096,9 @@ static void bnx2x_update_sge_prod(struct bnx2x_fastpath *fp,
1096 struct eth_fast_path_rx_cqe *fp_cqe) 1096 struct eth_fast_path_rx_cqe *fp_cqe)
1097{ 1097{
1098 struct bnx2x *bp = fp->bp; 1098 struct bnx2x *bp = fp->bp;
1099 u16 sge_len = BCM_PAGE_ALIGN(le16_to_cpu(fp_cqe->pkt_len) - 1099 u16 sge_len = SGE_PAGE_ALIGN(le16_to_cpu(fp_cqe->pkt_len) -
1100 le16_to_cpu(fp_cqe->len_on_bd)) >> 1100 le16_to_cpu(fp_cqe->len_on_bd)) >>
1101 BCM_PAGE_SHIFT; 1101 SGE_PAGE_SHIFT;
1102 u16 last_max, last_elem, first_elem; 1102 u16 last_max, last_elem, first_elem;
1103 u16 delta = 0; 1103 u16 delta = 0;
1104 u16 i; 1104 u16 i;
@@ -1203,22 +1203,22 @@ static int bnx2x_fill_frag_skb(struct bnx2x *bp, struct bnx2x_fastpath *fp,
1203 u16 cqe_idx) 1203 u16 cqe_idx)
1204{ 1204{
1205 struct sw_rx_page *rx_pg, old_rx_pg; 1205 struct sw_rx_page *rx_pg, old_rx_pg;
1206 struct page *sge;
1207 u16 len_on_bd = le16_to_cpu(fp_cqe->len_on_bd); 1206 u16 len_on_bd = le16_to_cpu(fp_cqe->len_on_bd);
1208 u32 i, frag_len, frag_size, pages; 1207 u32 i, frag_len, frag_size, pages;
1209 int err; 1208 int err;
1210 int j; 1209 int j;
1211 1210
1212 frag_size = le16_to_cpu(fp_cqe->pkt_len) - len_on_bd; 1211 frag_size = le16_to_cpu(fp_cqe->pkt_len) - len_on_bd;
1213 pages = BCM_PAGE_ALIGN(frag_size) >> BCM_PAGE_SHIFT; 1212 pages = SGE_PAGE_ALIGN(frag_size) >> SGE_PAGE_SHIFT;
1214 1213
1215 /* This is needed in order to enable forwarding support */ 1214 /* This is needed in order to enable forwarding support */
1216 if (frag_size) 1215 if (frag_size)
1217 skb_shinfo(skb)->gso_size = min((u32)BCM_PAGE_SIZE, 1216 skb_shinfo(skb)->gso_size = min((u32)SGE_PAGE_SIZE,
1218 max(frag_size, (u32)len_on_bd)); 1217 max(frag_size, (u32)len_on_bd));
1219 1218
1220#ifdef BNX2X_STOP_ON_ERROR 1219#ifdef BNX2X_STOP_ON_ERROR
1221 if (pages > 8*PAGES_PER_SGE) { 1220 if (pages >
1221 min((u32)8, (u32)MAX_SKB_FRAGS) * SGE_PAGE_SIZE * PAGES_PER_SGE) {
1222 BNX2X_ERR("SGL length is too long: %d. CQE index is %d\n", 1222 BNX2X_ERR("SGL length is too long: %d. CQE index is %d\n",
1223 pages, cqe_idx); 1223 pages, cqe_idx);
1224 BNX2X_ERR("fp_cqe->pkt_len = %d fp_cqe->len_on_bd = %d\n", 1224 BNX2X_ERR("fp_cqe->pkt_len = %d fp_cqe->len_on_bd = %d\n",
@@ -1234,9 +1234,8 @@ static int bnx2x_fill_frag_skb(struct bnx2x *bp, struct bnx2x_fastpath *fp,
1234 1234
1235 /* FW gives the indices of the SGE as if the ring is an array 1235 /* FW gives the indices of the SGE as if the ring is an array
1236 (meaning that "next" element will consume 2 indices) */ 1236 (meaning that "next" element will consume 2 indices) */
1237 frag_len = min(frag_size, (u32)(BCM_PAGE_SIZE*PAGES_PER_SGE)); 1237 frag_len = min(frag_size, (u32)(SGE_PAGE_SIZE*PAGES_PER_SGE));
1238 rx_pg = &fp->rx_page_ring[sge_idx]; 1238 rx_pg = &fp->rx_page_ring[sge_idx];
1239 sge = rx_pg->page;
1240 old_rx_pg = *rx_pg; 1239 old_rx_pg = *rx_pg;
1241 1240
1242 /* If we fail to allocate a substitute page, we simply stop 1241 /* If we fail to allocate a substitute page, we simply stop
@@ -1249,7 +1248,7 @@ static int bnx2x_fill_frag_skb(struct bnx2x *bp, struct bnx2x_fastpath *fp,
1249 1248
1250 /* Unmap the page as we r going to pass it to the stack */ 1249 /* Unmap the page as we r going to pass it to the stack */
1251 pci_unmap_page(bp->pdev, pci_unmap_addr(&old_rx_pg, mapping), 1250 pci_unmap_page(bp->pdev, pci_unmap_addr(&old_rx_pg, mapping),
1252 BCM_PAGE_SIZE*PAGES_PER_SGE, PCI_DMA_FROMDEVICE); 1251 SGE_PAGE_SIZE*PAGES_PER_SGE, PCI_DMA_FROMDEVICE);
1253 1252
1254 /* Add one frag and update the appropriate fields in the skb */ 1253 /* Add one frag and update the appropriate fields in the skb */
1255 skb_fill_page_desc(skb, j, old_rx_pg.page, 0, frag_len); 1254 skb_fill_page_desc(skb, j, old_rx_pg.page, 0, frag_len);
@@ -1282,6 +1281,13 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp,
1282 if (likely(new_skb)) { 1281 if (likely(new_skb)) {
1283 /* fix ip xsum and give it to the stack */ 1282 /* fix ip xsum and give it to the stack */
1284 /* (no need to map the new skb) */ 1283 /* (no need to map the new skb) */
1284#ifdef BCM_VLAN
1285 int is_vlan_cqe =
1286 (le16_to_cpu(cqe->fast_path_cqe.pars_flags.flags) &
1287 PARSING_FLAGS_VLAN);
1288 int is_not_hwaccel_vlan_cqe =
1289 (is_vlan_cqe && (!(bp->flags & HW_VLAN_RX_FLAG)));
1290#endif
1285 1291
1286 prefetch(skb); 1292 prefetch(skb);
1287 prefetch(((char *)(skb)) + 128); 1293 prefetch(((char *)(skb)) + 128);
@@ -1306,6 +1312,12 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp,
1306 struct iphdr *iph; 1312 struct iphdr *iph;
1307 1313
1308 iph = (struct iphdr *)skb->data; 1314 iph = (struct iphdr *)skb->data;
1315#ifdef BCM_VLAN
1316 /* If there is no Rx VLAN offloading -
1317 take VLAN tag into an account */
1318 if (unlikely(is_not_hwaccel_vlan_cqe))
1319 iph = (struct iphdr *)((u8 *)iph + VLAN_HLEN);
1320#endif
1309 iph->check = 0; 1321 iph->check = 0;
1310 iph->check = ip_fast_csum((u8 *)iph, iph->ihl); 1322 iph->check = ip_fast_csum((u8 *)iph, iph->ihl);
1311 } 1323 }
@@ -1313,9 +1325,8 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp,
1313 if (!bnx2x_fill_frag_skb(bp, fp, skb, 1325 if (!bnx2x_fill_frag_skb(bp, fp, skb,
1314 &cqe->fast_path_cqe, cqe_idx)) { 1326 &cqe->fast_path_cqe, cqe_idx)) {
1315#ifdef BCM_VLAN 1327#ifdef BCM_VLAN
1316 if ((bp->vlgrp != NULL) && 1328 if ((bp->vlgrp != NULL) && is_vlan_cqe &&
1317 (le16_to_cpu(cqe->fast_path_cqe.pars_flags.flags) & 1329 (!is_not_hwaccel_vlan_cqe))
1318 PARSING_FLAGS_VLAN))
1319 vlan_hwaccel_receive_skb(skb, bp->vlgrp, 1330 vlan_hwaccel_receive_skb(skb, bp->vlgrp,
1320 le16_to_cpu(cqe->fast_path_cqe. 1331 le16_to_cpu(cqe->fast_path_cqe.
1321 vlan_tag)); 1332 vlan_tag));
@@ -1355,11 +1366,23 @@ static inline void bnx2x_update_rx_prod(struct bnx2x *bp,
1355 rx_prods.cqe_prod = rx_comp_prod; 1366 rx_prods.cqe_prod = rx_comp_prod;
1356 rx_prods.sge_prod = rx_sge_prod; 1367 rx_prods.sge_prod = rx_sge_prod;
1357 1368
1369 /*
1370 * Make sure that the BD and SGE data is updated before updating the
1371 * producers since FW might read the BD/SGE right after the producer
1372 * is updated.
1373 * This is only applicable for weak-ordered memory model archs such
1374 * as IA-64. The following barrier is also mandatory since FW will
1375 * assumes BDs must have buffers.
1376 */
1377 wmb();
1378
1358 for (i = 0; i < sizeof(struct tstorm_eth_rx_producers)/4; i++) 1379 for (i = 0; i < sizeof(struct tstorm_eth_rx_producers)/4; i++)
1359 REG_WR(bp, BAR_TSTRORM_INTMEM + 1380 REG_WR(bp, BAR_TSTRORM_INTMEM +
1360 TSTORM_RX_PRODS_OFFSET(BP_PORT(bp), FP_CL_ID(fp)) + i*4, 1381 TSTORM_RX_PRODS_OFFSET(BP_PORT(bp), FP_CL_ID(fp)) + i*4,
1361 ((u32 *)&rx_prods)[i]); 1382 ((u32 *)&rx_prods)[i]);
1362 1383
1384 mmiowb(); /* keep prod updates ordered */
1385
1363 DP(NETIF_MSG_RX_STATUS, 1386 DP(NETIF_MSG_RX_STATUS,
1364 "Wrote: bd_prod %u cqe_prod %u sge_prod %u\n", 1387 "Wrote: bd_prod %u cqe_prod %u sge_prod %u\n",
1365 bd_prod, rx_comp_prod, rx_sge_prod); 1388 bd_prod, rx_comp_prod, rx_sge_prod);
@@ -1415,7 +1438,7 @@ static int bnx2x_rx_int(struct bnx2x_fastpath *fp, int budget)
1415 DP(NETIF_MSG_RX_STATUS, "CQE type %x err %x status %x" 1438 DP(NETIF_MSG_RX_STATUS, "CQE type %x err %x status %x"
1416 " queue %x vlan %x len %u\n", CQE_TYPE(cqe_fp_flags), 1439 " queue %x vlan %x len %u\n", CQE_TYPE(cqe_fp_flags),
1417 cqe_fp_flags, cqe->fast_path_cqe.status_flags, 1440 cqe_fp_flags, cqe->fast_path_cqe.status_flags,
1418 cqe->fast_path_cqe.rss_hash_result, 1441 le32_to_cpu(cqe->fast_path_cqe.rss_hash_result),
1419 le16_to_cpu(cqe->fast_path_cqe.vlan_tag), 1442 le16_to_cpu(cqe->fast_path_cqe.vlan_tag),
1420 le16_to_cpu(cqe->fast_path_cqe.pkt_len)); 1443 le16_to_cpu(cqe->fast_path_cqe.pkt_len));
1421 1444
@@ -1547,7 +1570,7 @@ reuse_rx:
1547 } 1570 }
1548 1571
1549#ifdef BCM_VLAN 1572#ifdef BCM_VLAN
1550 if ((bp->vlgrp != NULL) && 1573 if ((bp->vlgrp != NULL) && (bp->flags & HW_VLAN_RX_FLAG) &&
1551 (le16_to_cpu(cqe->fast_path_cqe.pars_flags.flags) & 1574 (le16_to_cpu(cqe->fast_path_cqe.pars_flags.flags) &
1552 PARSING_FLAGS_VLAN)) 1575 PARSING_FLAGS_VLAN))
1553 vlan_hwaccel_receive_skb(skb, bp->vlgrp, 1576 vlan_hwaccel_receive_skb(skb, bp->vlgrp,
@@ -1580,7 +1603,6 @@ next_cqe:
1580 /* Update producers */ 1603 /* Update producers */
1581 bnx2x_update_rx_prod(bp, fp, bd_prod_fw, sw_comp_prod, 1604 bnx2x_update_rx_prod(bp, fp, bd_prod_fw, sw_comp_prod,
1582 fp->rx_sge_prod); 1605 fp->rx_sge_prod);
1583 mmiowb(); /* keep prod updates ordered */
1584 1606
1585 fp->rx_pkt += rx_pkt; 1607 fp->rx_pkt += rx_pkt;
1586 fp->rx_calls++; 1608 fp->rx_calls++;
@@ -1660,7 +1682,7 @@ static irqreturn_t bnx2x_interrupt(int irq, void *dev_instance)
1660 1682
1661 1683
1662 if (unlikely(status & 0x1)) { 1684 if (unlikely(status & 0x1)) {
1663 schedule_work(&bp->sp_task); 1685 queue_delayed_work(bnx2x_wq, &bp->sp_task, 0);
1664 1686
1665 status &= ~0x1; 1687 status &= ~0x1;
1666 if (!status) 1688 if (!status)
@@ -1887,7 +1909,8 @@ static int bnx2x_set_spio(struct bnx2x *bp, int spio_num, u32 mode)
1887 1909
1888static void bnx2x_calc_fc_adv(struct bnx2x *bp) 1910static void bnx2x_calc_fc_adv(struct bnx2x *bp)
1889{ 1911{
1890 switch (bp->link_vars.ieee_fc) { 1912 switch (bp->link_vars.ieee_fc &
1913 MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_MASK) {
1891 case MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_NONE: 1914 case MDIO_COMBO_IEEE0_AUTO_NEG_ADV_PAUSE_NONE:
1892 bp->port.advertising &= ~(ADVERTISED_Asym_Pause | 1915 bp->port.advertising &= ~(ADVERTISED_Asym_Pause |
1893 ADVERTISED_Pause); 1916 ADVERTISED_Pause);
@@ -1957,10 +1980,11 @@ static u8 bnx2x_initial_phy_init(struct bnx2x *bp)
1957 rc = bnx2x_phy_init(&bp->link_params, &bp->link_vars); 1980 rc = bnx2x_phy_init(&bp->link_params, &bp->link_vars);
1958 bnx2x_release_phy_lock(bp); 1981 bnx2x_release_phy_lock(bp);
1959 1982
1983 bnx2x_calc_fc_adv(bp);
1984
1960 if (bp->link_vars.link_up) 1985 if (bp->link_vars.link_up)
1961 bnx2x_link_report(bp); 1986 bnx2x_link_report(bp);
1962 1987
1963 bnx2x_calc_fc_adv(bp);
1964 1988
1965 return rc; 1989 return rc;
1966 } 1990 }
@@ -2220,9 +2244,7 @@ static void bnx2x_link_attn(struct bnx2x *bp)
2220 /* Make sure that we are synced with the current statistics */ 2244 /* Make sure that we are synced with the current statistics */
2221 bnx2x_stats_handle(bp, STATS_EVENT_STOP); 2245 bnx2x_stats_handle(bp, STATS_EVENT_STOP);
2222 2246
2223 bnx2x_acquire_phy_lock(bp);
2224 bnx2x_link_update(&bp->link_params, &bp->link_vars); 2247 bnx2x_link_update(&bp->link_params, &bp->link_vars);
2225 bnx2x_release_phy_lock(bp);
2226 2248
2227 if (bp->link_vars.link_up) { 2249 if (bp->link_vars.link_up) {
2228 2250
@@ -2471,6 +2493,8 @@ static void bnx2x_attn_int_asserted(struct bnx2x *bp, u32 asserted)
2471 if (asserted & ATTN_HARD_WIRED_MASK) { 2493 if (asserted & ATTN_HARD_WIRED_MASK) {
2472 if (asserted & ATTN_NIG_FOR_FUNC) { 2494 if (asserted & ATTN_NIG_FOR_FUNC) {
2473 2495
2496 bnx2x_acquire_phy_lock(bp);
2497
2474 /* save nig interrupt mask */ 2498 /* save nig interrupt mask */
2475 bp->nig_mask = REG_RD(bp, nig_int_mask_addr); 2499 bp->nig_mask = REG_RD(bp, nig_int_mask_addr);
2476 REG_WR(bp, nig_int_mask_addr, 0); 2500 REG_WR(bp, nig_int_mask_addr, 0);
@@ -2526,8 +2550,10 @@ static void bnx2x_attn_int_asserted(struct bnx2x *bp, u32 asserted)
2526 REG_WR(bp, hc_addr, asserted); 2550 REG_WR(bp, hc_addr, asserted);
2527 2551
2528 /* now set back the mask */ 2552 /* now set back the mask */
2529 if (asserted & ATTN_NIG_FOR_FUNC) 2553 if (asserted & ATTN_NIG_FOR_FUNC) {
2530 REG_WR(bp, nig_int_mask_addr, bp->nig_mask); 2554 REG_WR(bp, nig_int_mask_addr, bp->nig_mask);
2555 bnx2x_release_phy_lock(bp);
2556 }
2531} 2557}
2532 2558
2533static inline void bnx2x_attn_int_deasserted0(struct bnx2x *bp, u32 attn) 2559static inline void bnx2x_attn_int_deasserted0(struct bnx2x *bp, u32 attn)
@@ -2795,8 +2821,10 @@ static void bnx2x_attn_int_deasserted(struct bnx2x *bp, u32 deasserted)
2795static void bnx2x_attn_int(struct bnx2x *bp) 2821static void bnx2x_attn_int(struct bnx2x *bp)
2796{ 2822{
2797 /* read local copy of bits */ 2823 /* read local copy of bits */
2798 u32 attn_bits = bp->def_status_blk->atten_status_block.attn_bits; 2824 u32 attn_bits = le32_to_cpu(bp->def_status_blk->atten_status_block.
2799 u32 attn_ack = bp->def_status_blk->atten_status_block.attn_bits_ack; 2825 attn_bits);
2826 u32 attn_ack = le32_to_cpu(bp->def_status_blk->atten_status_block.
2827 attn_bits_ack);
2800 u32 attn_state = bp->attn_state; 2828 u32 attn_state = bp->attn_state;
2801 2829
2802 /* look for changed bits */ 2830 /* look for changed bits */
@@ -2820,7 +2848,7 @@ static void bnx2x_attn_int(struct bnx2x *bp)
2820 2848
2821static void bnx2x_sp_task(struct work_struct *work) 2849static void bnx2x_sp_task(struct work_struct *work)
2822{ 2850{
2823 struct bnx2x *bp = container_of(work, struct bnx2x, sp_task); 2851 struct bnx2x *bp = container_of(work, struct bnx2x, sp_task.work);
2824 u16 status; 2852 u16 status;
2825 2853
2826 2854
@@ -2844,7 +2872,7 @@ static void bnx2x_sp_task(struct work_struct *work)
2844 if (status & 0x2) 2872 if (status & 0x2)
2845 bp->stats_pending = 0; 2873 bp->stats_pending = 0;
2846 2874
2847 bnx2x_ack_sb(bp, DEF_SB_ID, ATTENTION_ID, bp->def_att_idx, 2875 bnx2x_ack_sb(bp, DEF_SB_ID, ATTENTION_ID, le16_to_cpu(bp->def_att_idx),
2848 IGU_INT_NOP, 1); 2876 IGU_INT_NOP, 1);
2849 bnx2x_ack_sb(bp, DEF_SB_ID, USTORM_ID, le16_to_cpu(bp->def_u_idx), 2877 bnx2x_ack_sb(bp, DEF_SB_ID, USTORM_ID, le16_to_cpu(bp->def_u_idx),
2850 IGU_INT_NOP, 1); 2878 IGU_INT_NOP, 1);
@@ -2875,7 +2903,7 @@ static irqreturn_t bnx2x_msix_sp_int(int irq, void *dev_instance)
2875 return IRQ_HANDLED; 2903 return IRQ_HANDLED;
2876#endif 2904#endif
2877 2905
2878 schedule_work(&bp->sp_task); 2906 queue_delayed_work(bnx2x_wq, &bp->sp_task, 0);
2879 2907
2880 return IRQ_HANDLED; 2908 return IRQ_HANDLED;
2881} 2909}
@@ -2892,7 +2920,7 @@ static irqreturn_t bnx2x_msix_sp_int(int irq, void *dev_instance)
2892#define ADD_64(s_hi, a_hi, s_lo, a_lo) \ 2920#define ADD_64(s_hi, a_hi, s_lo, a_lo) \
2893 do { \ 2921 do { \
2894 s_lo += a_lo; \ 2922 s_lo += a_lo; \
2895 s_hi += a_hi + (s_lo < a_lo) ? 1 : 0; \ 2923 s_hi += a_hi + ((s_lo < a_lo) ? 1 : 0); \
2896 } while (0) 2924 } while (0)
2897 2925
2898/* difference = minuend - subtrahend */ 2926/* difference = minuend - subtrahend */
@@ -4496,7 +4524,7 @@ static void bnx2x_init_context(struct bnx2x *bp)
4496 4524
4497static void bnx2x_init_ind_table(struct bnx2x *bp) 4525static void bnx2x_init_ind_table(struct bnx2x *bp)
4498{ 4526{
4499 int port = BP_PORT(bp); 4527 int func = BP_FUNC(bp);
4500 int i; 4528 int i;
4501 4529
4502 if (!is_multi(bp)) 4530 if (!is_multi(bp))
@@ -4505,10 +4533,8 @@ static void bnx2x_init_ind_table(struct bnx2x *bp)
4505 DP(NETIF_MSG_IFUP, "Initializing indirection table\n"); 4533 DP(NETIF_MSG_IFUP, "Initializing indirection table\n");
4506 for (i = 0; i < TSTORM_INDIRECTION_TABLE_SIZE; i++) 4534 for (i = 0; i < TSTORM_INDIRECTION_TABLE_SIZE; i++)
4507 REG_WR8(bp, BAR_TSTRORM_INTMEM + 4535 REG_WR8(bp, BAR_TSTRORM_INTMEM +
4508 TSTORM_INDIRECTION_TABLE_OFFSET(port) + i, 4536 TSTORM_INDIRECTION_TABLE_OFFSET(func) + i,
4509 i % bp->num_queues); 4537 BP_CL_ID(bp) + (i % bp->num_queues));
4510
4511 REG_WR(bp, PRS_REG_A_PRSU_20, 0xf);
4512} 4538}
4513 4539
4514static void bnx2x_set_client_config(struct bnx2x *bp) 4540static void bnx2x_set_client_config(struct bnx2x *bp)
@@ -4517,12 +4543,12 @@ static void bnx2x_set_client_config(struct bnx2x *bp)
4517 int port = BP_PORT(bp); 4543 int port = BP_PORT(bp);
4518 int i; 4544 int i;
4519 4545
4520 tstorm_client.mtu = bp->dev->mtu + ETH_OVREHEAD; 4546 tstorm_client.mtu = bp->dev->mtu;
4521 tstorm_client.statistics_counter_id = BP_CL_ID(bp); 4547 tstorm_client.statistics_counter_id = BP_CL_ID(bp);
4522 tstorm_client.config_flags = 4548 tstorm_client.config_flags =
4523 TSTORM_ETH_CLIENT_CONFIG_STATSITICS_ENABLE; 4549 TSTORM_ETH_CLIENT_CONFIG_STATSITICS_ENABLE;
4524#ifdef BCM_VLAN 4550#ifdef BCM_VLAN
4525 if (bp->rx_mode && bp->vlgrp) { 4551 if (bp->rx_mode && bp->vlgrp && (bp->flags & HW_VLAN_RX_FLAG)) {
4526 tstorm_client.config_flags |= 4552 tstorm_client.config_flags |=
4527 TSTORM_ETH_CLIENT_CONFIG_VLAN_REMOVAL_ENABLE; 4553 TSTORM_ETH_CLIENT_CONFIG_VLAN_REMOVAL_ENABLE;
4528 DP(NETIF_MSG_IFUP, "vlan removal enabled\n"); 4554 DP(NETIF_MSG_IFUP, "vlan removal enabled\n");
@@ -4531,7 +4557,7 @@ static void bnx2x_set_client_config(struct bnx2x *bp)
4531 4557
4532 if (bp->flags & TPA_ENABLE_FLAG) { 4558 if (bp->flags & TPA_ENABLE_FLAG) {
4533 tstorm_client.max_sges_for_packet = 4559 tstorm_client.max_sges_for_packet =
4534 BCM_PAGE_ALIGN(tstorm_client.mtu) >> BCM_PAGE_SHIFT; 4560 SGE_PAGE_ALIGN(tstorm_client.mtu) >> SGE_PAGE_SHIFT;
4535 tstorm_client.max_sges_for_packet = 4561 tstorm_client.max_sges_for_packet =
4536 ((tstorm_client.max_sges_for_packet + 4562 ((tstorm_client.max_sges_for_packet +
4537 PAGES_PER_SGE - 1) & (~(PAGES_PER_SGE - 1))) >> 4563 PAGES_PER_SGE - 1) & (~(PAGES_PER_SGE - 1))) >>
@@ -4714,10 +4740,11 @@ static void bnx2x_init_internal_func(struct bnx2x *bp)
4714 bp->e1hov); 4740 bp->e1hov);
4715 } 4741 }
4716 4742
4717 /* Init CQ ring mapping and aggregation size */ 4743 /* Init CQ ring mapping and aggregation size, the FW limit is 8 frags */
4718 max_agg_size = min((u32)(bp->rx_buf_size + 4744 max_agg_size =
4719 8*BCM_PAGE_SIZE*PAGES_PER_SGE), 4745 min((u32)(min((u32)8, (u32)MAX_SKB_FRAGS) *
4720 (u32)0xffff); 4746 SGE_PAGE_SIZE * PAGES_PER_SGE),
4747 (u32)0xffff);
4721 for_each_queue(bp, i) { 4748 for_each_queue(bp, i) {
4722 struct bnx2x_fastpath *fp = &bp->fp[i]; 4749 struct bnx2x_fastpath *fp = &bp->fp[i];
4723 4750
@@ -4785,6 +4812,15 @@ static void bnx2x_nic_init(struct bnx2x *bp, u32 load_code)
4785 bnx2x_init_context(bp); 4812 bnx2x_init_context(bp);
4786 bnx2x_init_internal(bp, load_code); 4813 bnx2x_init_internal(bp, load_code);
4787 bnx2x_init_ind_table(bp); 4814 bnx2x_init_ind_table(bp);
4815 bnx2x_stats_init(bp);
4816
4817 /* At this point, we are ready for interrupts */
4818 atomic_set(&bp->intr_sem, 0);
4819
4820 /* flush all before enabling interrupts */
4821 mb();
4822 mmiowb();
4823
4788 bnx2x_int_enable(bp); 4824 bnx2x_int_enable(bp);
4789} 4825}
4790 4826
@@ -5134,7 +5170,6 @@ static int bnx2x_init_common(struct bnx2x *bp)
5134 REG_WR(bp, PXP2_REG_RQ_SRC_ENDIAN_M, 1); 5170 REG_WR(bp, PXP2_REG_RQ_SRC_ENDIAN_M, 1);
5135 REG_WR(bp, PXP2_REG_RQ_CDU_ENDIAN_M, 1); 5171 REG_WR(bp, PXP2_REG_RQ_CDU_ENDIAN_M, 1);
5136 REG_WR(bp, PXP2_REG_RQ_DBG_ENDIAN_M, 1); 5172 REG_WR(bp, PXP2_REG_RQ_DBG_ENDIAN_M, 1);
5137 REG_WR(bp, PXP2_REG_RQ_HC_ENDIAN_M, 1);
5138 5173
5139/* REG_WR(bp, PXP2_REG_RD_PBF_SWAP_MODE, 1); */ 5174/* REG_WR(bp, PXP2_REG_RD_PBF_SWAP_MODE, 1); */
5140 REG_WR(bp, PXP2_REG_RD_QM_SWAP_MODE, 1); 5175 REG_WR(bp, PXP2_REG_RD_QM_SWAP_MODE, 1);
@@ -5212,6 +5247,7 @@ static int bnx2x_init_common(struct bnx2x *bp)
5212 } 5247 }
5213 5248
5214 bnx2x_init_block(bp, PRS_COMMON_START, PRS_COMMON_END); 5249 bnx2x_init_block(bp, PRS_COMMON_START, PRS_COMMON_END);
5250 REG_WR(bp, PRS_REG_A_PRSU_20, 0xf);
5215 /* set NIC mode */ 5251 /* set NIC mode */
5216 REG_WR(bp, PRS_REG_NIC_MODE, 1); 5252 REG_WR(bp, PRS_REG_NIC_MODE, 1);
5217 if (CHIP_IS_E1H(bp)) 5253 if (CHIP_IS_E1H(bp))
@@ -6393,17 +6429,8 @@ static int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
6393 } 6429 }
6394 } 6430 }
6395 6431
6396 bnx2x_stats_init(bp);
6397
6398 bp->state = BNX2X_STATE_OPENING_WAIT4_PORT; 6432 bp->state = BNX2X_STATE_OPENING_WAIT4_PORT;
6399 6433
6400 /* Enable Rx interrupt handling before sending the ramrod
6401 as it's completed on Rx FP queue */
6402 bnx2x_napi_enable(bp);
6403
6404 /* Enable interrupt handling */
6405 atomic_set(&bp->intr_sem, 0);
6406
6407 rc = bnx2x_setup_leading(bp); 6434 rc = bnx2x_setup_leading(bp);
6408 if (rc) { 6435 if (rc) {
6409 BNX2X_ERR("Setup leading failed!\n"); 6436 BNX2X_ERR("Setup leading failed!\n");
@@ -7501,7 +7528,7 @@ static int __devinit bnx2x_init_bp(struct bnx2x *bp)
7501 7528
7502 mutex_init(&bp->port.phy_mutex); 7529 mutex_init(&bp->port.phy_mutex);
7503 7530
7504 INIT_WORK(&bp->sp_task, bnx2x_sp_task); 7531 INIT_DELAYED_WORK(&bp->sp_task, bnx2x_sp_task);
7505 INIT_WORK(&bp->reset_task, bnx2x_reset_task); 7532 INIT_WORK(&bp->reset_task, bnx2x_reset_task);
7506 7533
7507 rc = bnx2x_get_hwinfo(bp); 7534 rc = bnx2x_get_hwinfo(bp);
@@ -8243,6 +8270,9 @@ static int bnx2x_set_eeprom(struct net_device *dev,
8243 struct bnx2x *bp = netdev_priv(dev); 8270 struct bnx2x *bp = netdev_priv(dev);
8244 int rc; 8271 int rc;
8245 8272
8273 if (!netif_running(dev))
8274 return -EAGAIN;
8275
8246 DP(BNX2X_MSG_NVM, "ethtool_eeprom: cmd %d\n" 8276 DP(BNX2X_MSG_NVM, "ethtool_eeprom: cmd %d\n"
8247 DP_LEVEL " magic 0x%x offset 0x%x (%d) len 0x%x (%d)\n", 8277 DP_LEVEL " magic 0x%x offset 0x%x (%d) len 0x%x (%d)\n",
8248 eeprom->cmd, eeprom->magic, eeprom->offset, eeprom->offset, 8278 eeprom->cmd, eeprom->magic, eeprom->offset, eeprom->offset,
@@ -8724,6 +8754,8 @@ static int bnx2x_run_loopback(struct bnx2x *bp, int loopback_mode, u8 link_up)
8724 tx_bd->general_data = ((UNICAST_ADDRESS << 8754 tx_bd->general_data = ((UNICAST_ADDRESS <<
8725 ETH_TX_BD_ETH_ADDR_TYPE_SHIFT) | 1); 8755 ETH_TX_BD_ETH_ADDR_TYPE_SHIFT) | 1);
8726 8756
8757 wmb();
8758
8727 fp->hw_tx_prods->bds_prod = 8759 fp->hw_tx_prods->bds_prod =
8728 cpu_to_le16(le16_to_cpu(fp->hw_tx_prods->bds_prod) + 1); 8760 cpu_to_le16(le16_to_cpu(fp->hw_tx_prods->bds_prod) + 1);
8729 mb(); /* FW restriction: must not reorder writing nbd and packets */ 8761 mb(); /* FW restriction: must not reorder writing nbd and packets */
@@ -8775,7 +8807,6 @@ test_loopback_rx_exit:
8775 /* Update producers */ 8807 /* Update producers */
8776 bnx2x_update_rx_prod(bp, fp, fp->rx_bd_prod, fp->rx_comp_prod, 8808 bnx2x_update_rx_prod(bp, fp, fp->rx_bd_prod, fp->rx_comp_prod,
8777 fp->rx_sge_prod); 8809 fp->rx_sge_prod);
8778 mmiowb(); /* keep prod updates ordered */
8779 8810
8780test_loopback_exit: 8811test_loopback_exit:
8781 bp->link_params.loopback_mode = LOOPBACK_NONE; 8812 bp->link_params.loopback_mode = LOOPBACK_NONE;
@@ -9546,11 +9577,14 @@ static int bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
9546 "sending pkt %u @%p next_idx %u bd %u @%p\n", 9577 "sending pkt %u @%p next_idx %u bd %u @%p\n",
9547 pkt_prod, tx_buf, fp->tx_pkt_prod, bd_prod, tx_bd); 9578 pkt_prod, tx_buf, fp->tx_pkt_prod, bd_prod, tx_bd);
9548 9579
9549 if ((bp->vlgrp != NULL) && vlan_tx_tag_present(skb)) { 9580#ifdef BCM_VLAN
9581 if ((bp->vlgrp != NULL) && vlan_tx_tag_present(skb) &&
9582 (bp->flags & HW_VLAN_TX_FLAG)) {
9550 tx_bd->vlan = cpu_to_le16(vlan_tx_tag_get(skb)); 9583 tx_bd->vlan = cpu_to_le16(vlan_tx_tag_get(skb));
9551 tx_bd->bd_flags.as_bitfield |= ETH_TX_BD_FLAGS_VLAN_TAG; 9584 tx_bd->bd_flags.as_bitfield |= ETH_TX_BD_FLAGS_VLAN_TAG;
9552 vlan_off += 4; 9585 vlan_off += 4;
9553 } else 9586 } else
9587#endif
9554 tx_bd->vlan = cpu_to_le16(pkt_prod); 9588 tx_bd->vlan = cpu_to_le16(pkt_prod);
9555 9589
9556 if (xmit_type) { 9590 if (xmit_type) {
@@ -9702,6 +9736,15 @@ static int bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
9702 9736
9703 DP(NETIF_MSG_TX_QUEUED, "doorbell: nbd %d bd %u\n", nbd, bd_prod); 9737 DP(NETIF_MSG_TX_QUEUED, "doorbell: nbd %d bd %u\n", nbd, bd_prod);
9704 9738
9739 /*
9740 * Make sure that the BD data is updated before updating the producer
9741 * since FW might read the BD right after the producer is updated.
9742 * This is only applicable for weak-ordered memory model archs such
9743 * as IA-64. The following barrier is also mandatory since FW will
9744 * assumes packets must have BDs.
9745 */
9746 wmb();
9747
9705 fp->hw_tx_prods->bds_prod = 9748 fp->hw_tx_prods->bds_prod =
9706 cpu_to_le16(le16_to_cpu(fp->hw_tx_prods->bds_prod) + nbd); 9749 cpu_to_le16(le16_to_cpu(fp->hw_tx_prods->bds_prod) + nbd);
9707 mb(); /* FW restriction: must not reorder writing nbd and packets */ 9750 mb(); /* FW restriction: must not reorder writing nbd and packets */
@@ -9715,6 +9758,9 @@ static int bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
9715 dev->trans_start = jiffies; 9758 dev->trans_start = jiffies;
9716 9759
9717 if (unlikely(bnx2x_tx_avail(fp) < MAX_SKB_FRAGS + 3)) { 9760 if (unlikely(bnx2x_tx_avail(fp) < MAX_SKB_FRAGS + 3)) {
9761 /* We want bnx2x_tx_int to "see" the updated tx_bd_prod
9762 if we put Tx into XOFF state. */
9763 smp_mb();
9718 netif_stop_queue(dev); 9764 netif_stop_queue(dev);
9719 bp->eth_stats.driver_xoff++; 9765 bp->eth_stats.driver_xoff++;
9720 if (bnx2x_tx_avail(fp) >= MAX_SKB_FRAGS + 3) 9766 if (bnx2x_tx_avail(fp) >= MAX_SKB_FRAGS + 3)
@@ -9984,6 +10030,16 @@ static void bnx2x_vlan_rx_register(struct net_device *dev,
9984 struct bnx2x *bp = netdev_priv(dev); 10030 struct bnx2x *bp = netdev_priv(dev);
9985 10031
9986 bp->vlgrp = vlgrp; 10032 bp->vlgrp = vlgrp;
10033
10034 /* Set flags according to the required capabilities */
10035 bp->flags &= ~(HW_VLAN_RX_FLAG | HW_VLAN_TX_FLAG);
10036
10037 if (dev->features & NETIF_F_HW_VLAN_TX)
10038 bp->flags |= HW_VLAN_TX_FLAG;
10039
10040 if (dev->features & NETIF_F_HW_VLAN_RX)
10041 bp->flags |= HW_VLAN_RX_FLAG;
10042
9987 if (netif_running(dev)) 10043 if (netif_running(dev))
9988 bnx2x_set_client_config(bp); 10044 bnx2x_set_client_config(bp);
9989} 10045}
@@ -10140,6 +10196,7 @@ static int __devinit bnx2x_init_dev(struct pci_dev *pdev,
10140 dev->features |= NETIF_F_HIGHDMA; 10196 dev->features |= NETIF_F_HIGHDMA;
10141#ifdef BCM_VLAN 10197#ifdef BCM_VLAN
10142 dev->features |= (NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX); 10198 dev->features |= (NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX);
10199 bp->flags |= (HW_VLAN_RX_FLAG | HW_VLAN_TX_FLAG);
10143#endif 10200#endif
10144 dev->features |= (NETIF_F_TSO | NETIF_F_TSO_ECN); 10201 dev->features |= (NETIF_F_TSO | NETIF_F_TSO_ECN);
10145 dev->features |= NETIF_F_TSO6; 10202 dev->features |= NETIF_F_TSO6;
@@ -10516,12 +10573,20 @@ static struct pci_driver bnx2x_pci_driver = {
10516 10573
10517static int __init bnx2x_init(void) 10574static int __init bnx2x_init(void)
10518{ 10575{
10576 bnx2x_wq = create_singlethread_workqueue("bnx2x");
10577 if (bnx2x_wq == NULL) {
10578 printk(KERN_ERR PFX "Cannot create workqueue\n");
10579 return -ENOMEM;
10580 }
10581
10519 return pci_register_driver(&bnx2x_pci_driver); 10582 return pci_register_driver(&bnx2x_pci_driver);
10520} 10583}
10521 10584
10522static void __exit bnx2x_cleanup(void) 10585static void __exit bnx2x_cleanup(void)
10523{ 10586{
10524 pci_unregister_driver(&bnx2x_pci_driver); 10587 pci_unregister_driver(&bnx2x_pci_driver);
10588
10589 destroy_workqueue(bnx2x_wq);
10525} 10590}
10526 10591
10527module_init(bnx2x_init); 10592module_init(bnx2x_init);
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 460c2cad2755..9fb388388fb7 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4148,7 +4148,7 @@ static int bond_change_mtu(struct net_device *bond_dev, int new_mtu)
4148 4148
4149 bond_for_each_slave(bond, slave, i) { 4149 bond_for_each_slave(bond, slave, i) {
4150 pr_debug("s %p s->p %p c_m %p\n", slave, 4150 pr_debug("s %p s->p %p c_m %p\n", slave,
4151 slave->prev, slave->dev->change_mtu); 4151 slave->prev, slave->dev->netdev_ops->ndo_change_mtu);
4152 4152
4153 res = dev_set_mtu(slave->dev, new_mtu); 4153 res = dev_set_mtu(slave->dev, new_mtu);
4154 4154
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c
index 321f43d9f0e2..840b3d1a22f5 100644
--- a/drivers/net/cassini.c
+++ b/drivers/net/cassini.c
@@ -4977,6 +4977,22 @@ static void __devinit cas_program_bridge(struct pci_dev *cas_pdev)
4977 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0xff); 4977 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0xff);
4978} 4978}
4979 4979
4980static const struct net_device_ops cas_netdev_ops = {
4981 .ndo_open = cas_open,
4982 .ndo_stop = cas_close,
4983 .ndo_start_xmit = cas_start_xmit,
4984 .ndo_get_stats = cas_get_stats,
4985 .ndo_set_multicast_list = cas_set_multicast,
4986 .ndo_do_ioctl = cas_ioctl,
4987 .ndo_tx_timeout = cas_tx_timeout,
4988 .ndo_change_mtu = cas_change_mtu,
4989 .ndo_set_mac_address = eth_mac_addr,
4990 .ndo_validate_addr = eth_validate_addr,
4991#ifdef CONFIG_NET_POLL_CONTROLLER
4992 .ndo_poll_controller = cas_netpoll,
4993#endif
4994};
4995
4980static int __devinit cas_init_one(struct pci_dev *pdev, 4996static int __devinit cas_init_one(struct pci_dev *pdev,
4981 const struct pci_device_id *ent) 4997 const struct pci_device_id *ent)
4982{ 4998{
@@ -5166,22 +5182,13 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
5166 for (i = 0; i < N_RX_FLOWS; i++) 5182 for (i = 0; i < N_RX_FLOWS; i++)
5167 skb_queue_head_init(&cp->rx_flows[i]); 5183 skb_queue_head_init(&cp->rx_flows[i]);
5168 5184
5169 dev->open = cas_open; 5185 dev->netdev_ops = &cas_netdev_ops;
5170 dev->stop = cas_close;
5171 dev->hard_start_xmit = cas_start_xmit;
5172 dev->get_stats = cas_get_stats;
5173 dev->set_multicast_list = cas_set_multicast;
5174 dev->do_ioctl = cas_ioctl;
5175 dev->ethtool_ops = &cas_ethtool_ops; 5186 dev->ethtool_ops = &cas_ethtool_ops;
5176 dev->tx_timeout = cas_tx_timeout;
5177 dev->watchdog_timeo = CAS_TX_TIMEOUT; 5187 dev->watchdog_timeo = CAS_TX_TIMEOUT;
5178 dev->change_mtu = cas_change_mtu; 5188
5179#ifdef USE_NAPI 5189#ifdef USE_NAPI
5180 netif_napi_add(dev, &cp->napi, cas_poll, 64); 5190 netif_napi_add(dev, &cp->napi, cas_poll, 64);
5181#endif 5191#endif
5182#ifdef CONFIG_NET_POLL_CONTROLLER
5183 dev->poll_controller = cas_netpoll;
5184#endif
5185 dev->irq = pdev->irq; 5192 dev->irq = pdev->irq;
5186 dev->dma = 0; 5193 dev->dma = 0;
5187 5194
diff --git a/drivers/net/cxgb3/adapter.h b/drivers/net/cxgb3/adapter.h
index 5b346f9eaa8b..a89d8cc51205 100644
--- a/drivers/net/cxgb3/adapter.h
+++ b/drivers/net/cxgb3/adapter.h
@@ -50,12 +50,17 @@ struct vlan_group;
50struct adapter; 50struct adapter;
51struct sge_qset; 51struct sge_qset;
52 52
53enum { /* rx_offload flags */
54 T3_RX_CSUM = 1 << 0,
55 T3_LRO = 1 << 1,
56};
57
53struct port_info { 58struct port_info {
54 struct adapter *adapter; 59 struct adapter *adapter;
55 struct vlan_group *vlan_grp; 60 struct vlan_group *vlan_grp;
56 struct sge_qset *qs; 61 struct sge_qset *qs;
57 u8 port_id; 62 u8 port_id;
58 u8 rx_csum_offload; 63 u8 rx_offload;
59 u8 nqsets; 64 u8 nqsets;
60 u8 first_qset; 65 u8 first_qset;
61 struct cphy phy; 66 struct cphy phy;
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index 2847f947499d..0089746b8d02 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -546,7 +546,7 @@ static int setup_sge_qsets(struct adapter *adap)
546 pi->qs = &adap->sge.qs[pi->first_qset]; 546 pi->qs = &adap->sge.qs[pi->first_qset];
547 for (j = pi->first_qset; j < pi->first_qset + pi->nqsets; 547 for (j = pi->first_qset; j < pi->first_qset + pi->nqsets;
548 ++j, ++qset_idx) { 548 ++j, ++qset_idx) {
549 set_qset_lro(dev, qset_idx, pi->rx_csum_offload); 549 set_qset_lro(dev, qset_idx, pi->rx_offload & T3_LRO);
550 err = t3_sge_alloc_qset(adap, qset_idx, 1, 550 err = t3_sge_alloc_qset(adap, qset_idx, 1,
551 (adap->flags & USING_MSIX) ? qset_idx + 1 : 551 (adap->flags & USING_MSIX) ? qset_idx + 1 :
552 irq_idx, 552 irq_idx,
@@ -1657,17 +1657,19 @@ static u32 get_rx_csum(struct net_device *dev)
1657{ 1657{
1658 struct port_info *p = netdev_priv(dev); 1658 struct port_info *p = netdev_priv(dev);
1659 1659
1660 return p->rx_csum_offload; 1660 return p->rx_offload & T3_RX_CSUM;
1661} 1661}
1662 1662
1663static int set_rx_csum(struct net_device *dev, u32 data) 1663static int set_rx_csum(struct net_device *dev, u32 data)
1664{ 1664{
1665 struct port_info *p = netdev_priv(dev); 1665 struct port_info *p = netdev_priv(dev);
1666 1666
1667 p->rx_csum_offload = data; 1667 if (data) {
1668 if (!data) { 1668 p->rx_offload |= T3_RX_CSUM;
1669 } else {
1669 int i; 1670 int i;
1670 1671
1672 p->rx_offload &= ~(T3_RX_CSUM | T3_LRO);
1671 for (i = p->first_qset; i < p->first_qset + p->nqsets; i++) 1673 for (i = p->first_qset; i < p->first_qset + p->nqsets; i++)
1672 set_qset_lro(dev, i, 0); 1674 set_qset_lro(dev, i, 0);
1673 } 1675 }
@@ -1830,15 +1832,18 @@ static int cxgb3_set_flags(struct net_device *dev, u32 data)
1830 int i; 1832 int i;
1831 1833
1832 if (data & ETH_FLAG_LRO) { 1834 if (data & ETH_FLAG_LRO) {
1833 if (!pi->rx_csum_offload) 1835 if (!(pi->rx_offload & T3_RX_CSUM))
1834 return -EINVAL; 1836 return -EINVAL;
1835 1837
1838 pi->rx_offload |= T3_LRO;
1836 for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; i++) 1839 for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; i++)
1837 set_qset_lro(dev, i, 1); 1840 set_qset_lro(dev, i, 1);
1838 1841
1839 } else 1842 } else {
1843 pi->rx_offload &= ~T3_LRO;
1840 for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; i++) 1844 for (i = pi->first_qset; i < pi->first_qset + pi->nqsets; i++)
1841 set_qset_lro(dev, i, 0); 1845 set_qset_lro(dev, i, 0);
1846 }
1842 1847
1843 return 0; 1848 return 0;
1844} 1849}
@@ -1926,7 +1931,7 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr)
1926 pi = adap2pinfo(adapter, i); 1931 pi = adap2pinfo(adapter, i);
1927 if (t.qset_idx >= pi->first_qset && 1932 if (t.qset_idx >= pi->first_qset &&
1928 t.qset_idx < pi->first_qset + pi->nqsets && 1933 t.qset_idx < pi->first_qset + pi->nqsets &&
1929 !pi->rx_csum_offload) 1934 !(pi->rx_offload & T3_RX_CSUM))
1930 return -EINVAL; 1935 return -EINVAL;
1931 } 1936 }
1932 1937
@@ -2946,7 +2951,7 @@ static int __devinit init_one(struct pci_dev *pdev,
2946 adapter->port[i] = netdev; 2951 adapter->port[i] = netdev;
2947 pi = netdev_priv(netdev); 2952 pi = netdev_priv(netdev);
2948 pi->adapter = adapter; 2953 pi->adapter = adapter;
2949 pi->rx_csum_offload = 1; 2954 pi->rx_offload = T3_RX_CSUM | T3_LRO;
2950 pi->port_id = i; 2955 pi->port_id = i;
2951 netif_carrier_off(netdev); 2956 netif_carrier_off(netdev);
2952 netif_tx_stop_all_queues(netdev); 2957 netif_tx_stop_all_queues(netdev);
@@ -2955,6 +2960,7 @@ static int __devinit init_one(struct pci_dev *pdev,
2955 netdev->mem_end = mmio_start + mmio_len - 1; 2960 netdev->mem_end = mmio_start + mmio_len - 1;
2956 netdev->features |= NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO; 2961 netdev->features |= NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO;
2957 netdev->features |= NETIF_F_LLTX; 2962 netdev->features |= NETIF_F_LLTX;
2963 netdev->features |= NETIF_F_LRO;
2958 if (pci_using_dac) 2964 if (pci_using_dac)
2959 netdev->features |= NETIF_F_HIGHDMA; 2965 netdev->features |= NETIF_F_HIGHDMA;
2960 2966
diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c
index 6c641a889471..14f9fb3e8795 100644
--- a/drivers/net/cxgb3/sge.c
+++ b/drivers/net/cxgb3/sge.c
@@ -1932,7 +1932,7 @@ static void rx_eth(struct adapter *adap, struct sge_rspq *rq,
1932 skb_pull(skb, sizeof(*p) + pad); 1932 skb_pull(skb, sizeof(*p) + pad);
1933 skb->protocol = eth_type_trans(skb, adap->port[p->iff]); 1933 skb->protocol = eth_type_trans(skb, adap->port[p->iff]);
1934 pi = netdev_priv(skb->dev); 1934 pi = netdev_priv(skb->dev);
1935 if (pi->rx_csum_offload && p->csum_valid && p->csum == htons(0xffff) && 1935 if ((pi->rx_offload & T3_RX_CSUM) && p->csum_valid && p->csum == htons(0xffff) &&
1936 !p->fragment) { 1936 !p->fragment) {
1937 qs->port_stats[SGE_PSTAT_RX_CSUM_GOOD]++; 1937 qs->port_stats[SGE_PSTAT_RX_CSUM_GOOD]++;
1938 skb->ip_summed = CHECKSUM_UNNECESSARY; 1938 skb->ip_summed = CHECKSUM_UNNECESSARY;
diff --git a/drivers/net/de600.c b/drivers/net/de600.c
index 970f820ba814..de63f1d41d32 100644
--- a/drivers/net/de600.c
+++ b/drivers/net/de600.c
@@ -378,6 +378,16 @@ static void de600_rx_intr(struct net_device *dev)
378 */ 378 */
379} 379}
380 380
381static const struct net_device_ops de600_netdev_ops = {
382 .ndo_open = de600_open,
383 .ndo_stop = de600_close,
384 .ndo_start_xmit = de600_start_xmit,
385 .ndo_change_mtu = eth_change_mtu,
386 .ndo_set_mac_address = eth_mac_addr,
387 .ndo_validate_addr = eth_validate_addr,
388};
389
390
381static struct net_device * __init de600_probe(void) 391static struct net_device * __init de600_probe(void)
382{ 392{
383 int i; 393 int i;
@@ -439,9 +449,7 @@ static struct net_device * __init de600_probe(void)
439 449
440 printk(", Ethernet Address: %pM\n", dev->dev_addr); 450 printk(", Ethernet Address: %pM\n", dev->dev_addr);
441 451
442 dev->open = de600_open; 452 dev->netdev_ops = &de600_netdev_ops;
443 dev->stop = de600_close;
444 dev->hard_start_xmit = &de600_start_xmit;
445 453
446 dev->flags&=~IFF_MULTICAST; 454 dev->flags&=~IFF_MULTICAST;
447 455
diff --git a/drivers/net/de620.c b/drivers/net/de620.c
index bdfa89403389..d52f34cc9526 100644
--- a/drivers/net/de620.c
+++ b/drivers/net/de620.c
@@ -784,6 +784,17 @@ static int adapter_init(struct net_device *dev)
784 return 0; /* all ok */ 784 return 0; /* all ok */
785} 785}
786 786
787static const struct net_device_ops de620_netdev_ops = {
788 .ndo_open = de620_open,
789 .ndo_stop = de620_close,
790 .ndo_start_xmit = de620_start_xmit,
791 .ndo_tx_timeout = de620_timeout,
792 .ndo_set_multicast_list = de620_set_multicast_list,
793 .ndo_change_mtu = eth_change_mtu,
794 .ndo_set_mac_address = eth_mac_addr,
795 .ndo_validate_addr = eth_validate_addr,
796};
797
787/****************************************************************************** 798/******************************************************************************
788 * 799 *
789 * Only start-up code below 800 * Only start-up code below
@@ -861,12 +872,8 @@ struct net_device * __init de620_probe(int unit)
861 else 872 else
862 printk(" UTP)\n"); 873 printk(" UTP)\n");
863 874
864 dev->open = de620_open; 875 dev->netdev_ops = &de620_netdev_ops;
865 dev->stop = de620_close;
866 dev->hard_start_xmit = de620_start_xmit;
867 dev->tx_timeout = de620_timeout;
868 dev->watchdog_timeo = HZ*2; 876 dev->watchdog_timeo = HZ*2;
869 dev->set_multicast_list = de620_set_multicast_list;
870 877
871 /* base_addr and irq are already set, see above! */ 878 /* base_addr and irq are already set, see above! */
872 879
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 134b2d60b479..86bb876fb123 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -161,6 +161,7 @@
161#include <linux/skbuff.h> 161#include <linux/skbuff.h>
162#include <linux/ethtool.h> 162#include <linux/ethtool.h>
163#include <linux/string.h> 163#include <linux/string.h>
164#include <linux/firmware.h>
164#include <asm/unaligned.h> 165#include <asm/unaligned.h>
165 166
166 167
@@ -174,10 +175,17 @@
174#define E100_WATCHDOG_PERIOD (2 * HZ) 175#define E100_WATCHDOG_PERIOD (2 * HZ)
175#define E100_NAPI_WEIGHT 16 176#define E100_NAPI_WEIGHT 16
176 177
178#define FIRMWARE_D101M "e100/d101m_ucode.bin"
179#define FIRMWARE_D101S "e100/d101s_ucode.bin"
180#define FIRMWARE_D102E "e100/d102e_ucode.bin"
181
177MODULE_DESCRIPTION(DRV_DESCRIPTION); 182MODULE_DESCRIPTION(DRV_DESCRIPTION);
178MODULE_AUTHOR(DRV_COPYRIGHT); 183MODULE_AUTHOR(DRV_COPYRIGHT);
179MODULE_LICENSE("GPL"); 184MODULE_LICENSE("GPL");
180MODULE_VERSION(DRV_VERSION); 185MODULE_VERSION(DRV_VERSION);
186MODULE_FIRMWARE(FIRMWARE_D101M);
187MODULE_FIRMWARE(FIRMWARE_D101S);
188MODULE_FIRMWARE(FIRMWARE_D102E);
181 189
182static int debug = 3; 190static int debug = 3;
183static int eeprom_bad_csum_allow = 0; 191static int eeprom_bad_csum_allow = 0;
@@ -1049,178 +1057,6 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
1049 c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23]); 1057 c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23]);
1050} 1058}
1051 1059
1052/********************************************************/
1053/* Micro code for 8086:1229 Rev 8 */
1054/********************************************************/
1055
1056/* Parameter values for the D101M B-step */
1057#define D101M_CPUSAVER_TIMER_DWORD 78
1058#define D101M_CPUSAVER_BUNDLE_DWORD 65
1059#define D101M_CPUSAVER_MIN_SIZE_DWORD 126
1060
1061#define D101M_B_RCVBUNDLE_UCODE \
1062{\
10630x00550215, 0xFFFF0437, 0xFFFFFFFF, 0x06A70789, 0xFFFFFFFF, 0x0558FFFF, \
10640x000C0001, 0x00101312, 0x000C0008, 0x00380216, \
10650x0010009C, 0x00204056, 0x002380CC, 0x00380056, \
10660x0010009C, 0x00244C0B, 0x00000800, 0x00124818, \
10670x00380438, 0x00000000, 0x00140000, 0x00380555, \
10680x00308000, 0x00100662, 0x00100561, 0x000E0408, \
10690x00134861, 0x000C0002, 0x00103093, 0x00308000, \
10700x00100624, 0x00100561, 0x000E0408, 0x00100861, \
10710x000C007E, 0x00222C21, 0x000C0002, 0x00103093, \
10720x00380C7A, 0x00080000, 0x00103090, 0x00380C7A, \
10730x00000000, 0x00000000, 0x00000000, 0x00000000, \
10740x0010009C, 0x00244C2D, 0x00010004, 0x00041000, \
10750x003A0437, 0x00044010, 0x0038078A, 0x00000000, \
10760x00100099, 0x00206C7A, 0x0010009C, 0x00244C48, \
10770x00130824, 0x000C0001, 0x00101213, 0x00260C75, \
10780x00041000, 0x00010004, 0x00130826, 0x000C0006, \
10790x002206A8, 0x0013C926, 0x00101313, 0x003806A8, \
10800x00000000, 0x00000000, 0x00000000, 0x00000000, \
10810x00000000, 0x00000000, 0x00000000, 0x00000000, \
10820x00080600, 0x00101B10, 0x00050004, 0x00100826, \
10830x00101210, 0x00380C34, 0x00000000, 0x00000000, \
10840x0021155B, 0x00100099, 0x00206559, 0x0010009C, \
10850x00244559, 0x00130836, 0x000C0000, 0x00220C62, \
10860x000C0001, 0x00101B13, 0x00229C0E, 0x00210C0E, \
10870x00226C0E, 0x00216C0E, 0x0022FC0E, 0x00215C0E, \
10880x00214C0E, 0x00380555, 0x00010004, 0x00041000, \
10890x00278C67, 0x00040800, 0x00018100, 0x003A0437, \
10900x00130826, 0x000C0001, 0x00220559, 0x00101313, \
10910x00380559, 0x00000000, 0x00000000, 0x00000000, \
10920x00000000, 0x00000000, 0x00000000, 0x00000000, \
10930x00000000, 0x00130831, 0x0010090B, 0x00124813, \
10940x000CFF80, 0x002606AB, 0x00041000, 0x00010004, \
10950x003806A8, 0x00000000, 0x00000000, 0x00000000, \
1096}
1097
1098/********************************************************/
1099/* Micro code for 8086:1229 Rev 9 */
1100/********************************************************/
1101
1102/* Parameter values for the D101S */
1103#define D101S_CPUSAVER_TIMER_DWORD 78
1104#define D101S_CPUSAVER_BUNDLE_DWORD 67
1105#define D101S_CPUSAVER_MIN_SIZE_DWORD 128
1106
1107#define D101S_RCVBUNDLE_UCODE \
1108{\
11090x00550242, 0xFFFF047E, 0xFFFFFFFF, 0x06FF0818, 0xFFFFFFFF, 0x05A6FFFF, \
11100x000C0001, 0x00101312, 0x000C0008, 0x00380243, \
11110x0010009C, 0x00204056, 0x002380D0, 0x00380056, \
11120x0010009C, 0x00244F8B, 0x00000800, 0x00124818, \
11130x0038047F, 0x00000000, 0x00140000, 0x003805A3, \
11140x00308000, 0x00100610, 0x00100561, 0x000E0408, \
11150x00134861, 0x000C0002, 0x00103093, 0x00308000, \
11160x00100624, 0x00100561, 0x000E0408, 0x00100861, \
11170x000C007E, 0x00222FA1, 0x000C0002, 0x00103093, \
11180x00380F90, 0x00080000, 0x00103090, 0x00380F90, \
11190x00000000, 0x00000000, 0x00000000, 0x00000000, \
11200x0010009C, 0x00244FAD, 0x00010004, 0x00041000, \
11210x003A047E, 0x00044010, 0x00380819, 0x00000000, \
11220x00100099, 0x00206FFD, 0x0010009A, 0x0020AFFD, \
11230x0010009C, 0x00244FC8, 0x00130824, 0x000C0001, \
11240x00101213, 0x00260FF7, 0x00041000, 0x00010004, \
11250x00130826, 0x000C0006, 0x00220700, 0x0013C926, \
11260x00101313, 0x00380700, 0x00000000, 0x00000000, \
11270x00000000, 0x00000000, 0x00000000, 0x00000000, \
11280x00080600, 0x00101B10, 0x00050004, 0x00100826, \
11290x00101210, 0x00380FB6, 0x00000000, 0x00000000, \
11300x002115A9, 0x00100099, 0x002065A7, 0x0010009A, \
11310x0020A5A7, 0x0010009C, 0x002445A7, 0x00130836, \
11320x000C0000, 0x00220FE4, 0x000C0001, 0x00101B13, \
11330x00229F8E, 0x00210F8E, 0x00226F8E, 0x00216F8E, \
11340x0022FF8E, 0x00215F8E, 0x00214F8E, 0x003805A3, \
11350x00010004, 0x00041000, 0x00278FE9, 0x00040800, \
11360x00018100, 0x003A047E, 0x00130826, 0x000C0001, \
11370x002205A7, 0x00101313, 0x003805A7, 0x00000000, \
11380x00000000, 0x00000000, 0x00000000, 0x00000000, \
11390x00000000, 0x00000000, 0x00000000, 0x00130831, \
11400x0010090B, 0x00124813, 0x000CFF80, 0x00260703, \
11410x00041000, 0x00010004, 0x00380700 \
1142}
1143
1144/********************************************************/
1145/* Micro code for the 8086:1229 Rev F/10 */
1146/********************************************************/
1147
1148/* Parameter values for the D102 E-step */
1149#define D102_E_CPUSAVER_TIMER_DWORD 42
1150#define D102_E_CPUSAVER_BUNDLE_DWORD 54
1151#define D102_E_CPUSAVER_MIN_SIZE_DWORD 46
1152
1153#define D102_E_RCVBUNDLE_UCODE \
1154{\
11550x007D028F, 0x0E4204F9, 0x14ED0C85, 0x14FA14E9, 0x0EF70E36, 0x1FFF1FFF, \
11560x00E014B9, 0x00000000, 0x00000000, 0x00000000, \
11570x00E014BD, 0x00000000, 0x00000000, 0x00000000, \
11580x00E014D5, 0x00000000, 0x00000000, 0x00000000, \
11590x00000000, 0x00000000, 0x00000000, 0x00000000, \
11600x00E014C1, 0x00000000, 0x00000000, 0x00000000, \
11610x00000000, 0x00000000, 0x00000000, 0x00000000, \
11620x00000000, 0x00000000, 0x00000000, 0x00000000, \
11630x00000000, 0x00000000, 0x00000000, 0x00000000, \
11640x00E014C8, 0x00000000, 0x00000000, 0x00000000, \
11650x00200600, 0x00E014EE, 0x00000000, 0x00000000, \
11660x0030FF80, 0x00940E46, 0x00038200, 0x00102000, \
11670x00E00E43, 0x00000000, 0x00000000, 0x00000000, \
11680x00300006, 0x00E014FB, 0x00000000, 0x00000000, \
11690x00000000, 0x00000000, 0x00000000, 0x00000000, \
11700x00000000, 0x00000000, 0x00000000, 0x00000000, \
11710x00000000, 0x00000000, 0x00000000, 0x00000000, \
11720x00906E41, 0x00800E3C, 0x00E00E39, 0x00000000, \
11730x00906EFD, 0x00900EFD, 0x00E00EF8, 0x00000000, \
11740x00000000, 0x00000000, 0x00000000, 0x00000000, \
11750x00000000, 0x00000000, 0x00000000, 0x00000000, \
11760x00000000, 0x00000000, 0x00000000, 0x00000000, \
11770x00000000, 0x00000000, 0x00000000, 0x00000000, \
11780x00000000, 0x00000000, 0x00000000, 0x00000000, \
11790x00000000, 0x00000000, 0x00000000, 0x00000000, \
11800x00000000, 0x00000000, 0x00000000, 0x00000000, \
11810x00000000, 0x00000000, 0x00000000, 0x00000000, \
11820x00000000, 0x00000000, 0x00000000, 0x00000000, \
11830x00000000, 0x00000000, 0x00000000, 0x00000000, \
11840x00000000, 0x00000000, 0x00000000, 0x00000000, \
11850x00000000, 0x00000000, 0x00000000, 0x00000000, \
11860x00000000, 0x00000000, 0x00000000, 0x00000000, \
11870x00000000, 0x00000000, 0x00000000, 0x00000000, \
1188}
1189
1190static void e100_setup_ucode(struct nic *nic, struct cb *cb, struct sk_buff *skb)
1191{
1192/* *INDENT-OFF* */
1193 static struct {
1194 u32 ucode[UCODE_SIZE + 1];
1195 u8 mac;
1196 u8 timer_dword;
1197 u8 bundle_dword;
1198 u8 min_size_dword;
1199 } ucode_opts[] = {
1200 { D101M_B_RCVBUNDLE_UCODE,
1201 mac_82559_D101M,
1202 D101M_CPUSAVER_TIMER_DWORD,
1203 D101M_CPUSAVER_BUNDLE_DWORD,
1204 D101M_CPUSAVER_MIN_SIZE_DWORD },
1205 { D101S_RCVBUNDLE_UCODE,
1206 mac_82559_D101S,
1207 D101S_CPUSAVER_TIMER_DWORD,
1208 D101S_CPUSAVER_BUNDLE_DWORD,
1209 D101S_CPUSAVER_MIN_SIZE_DWORD },
1210 { D102_E_RCVBUNDLE_UCODE,
1211 mac_82551_F,
1212 D102_E_CPUSAVER_TIMER_DWORD,
1213 D102_E_CPUSAVER_BUNDLE_DWORD,
1214 D102_E_CPUSAVER_MIN_SIZE_DWORD },
1215 { D102_E_RCVBUNDLE_UCODE,
1216 mac_82551_10,
1217 D102_E_CPUSAVER_TIMER_DWORD,
1218 D102_E_CPUSAVER_BUNDLE_DWORD,
1219 D102_E_CPUSAVER_MIN_SIZE_DWORD },
1220 { {0}, 0, 0, 0, 0}
1221 }, *opts;
1222/* *INDENT-ON* */
1223
1224/************************************************************************* 1060/*************************************************************************
1225* CPUSaver parameters 1061* CPUSaver parameters
1226* 1062*
@@ -1280,42 +1116,101 @@ static void e100_setup_ucode(struct nic *nic, struct cb *cb, struct sk_buff *skb
1280#define BUNDLEMAX (u16)6 1116#define BUNDLEMAX (u16)6
1281#define INTDELAY (u16)1536 /* 0x600 */ 1117#define INTDELAY (u16)1536 /* 0x600 */
1282 1118
1119/* Initialize firmware */
1120static const struct firmware *e100_request_firmware(struct nic *nic)
1121{
1122 const char *fw_name;
1123 const struct firmware *fw;
1124 u8 timer, bundle, min_size;
1125 int err;
1126
1283 /* do not load u-code for ICH devices */ 1127 /* do not load u-code for ICH devices */
1284 if (nic->flags & ich) 1128 if (nic->flags & ich)
1285 goto noloaducode; 1129 return NULL;
1286 1130
1287 /* Search for ucode match against h/w revision */ 1131 /* Search for ucode match against h/w revision */
1288 for (opts = ucode_opts; opts->mac; opts++) { 1132 if (nic->mac == mac_82559_D101M)
1289 int i; 1133 fw_name = FIRMWARE_D101M;
1290 u32 *ucode = opts->ucode; 1134 else if (nic->mac == mac_82559_D101S)
1291 if (nic->mac != opts->mac) 1135 fw_name = FIRMWARE_D101S;
1292 continue; 1136 else if (nic->mac == mac_82551_F || nic->mac == mac_82551_10)
1293 1137 fw_name = FIRMWARE_D102E;
1294 /* Insert user-tunable settings */ 1138 else /* No ucode on other devices */
1295 ucode[opts->timer_dword] &= 0xFFFF0000; 1139 return NULL;
1296 ucode[opts->timer_dword] |= INTDELAY; 1140
1297 ucode[opts->bundle_dword] &= 0xFFFF0000; 1141 err = request_firmware(&fw, fw_name, &nic->pdev->dev);
1298 ucode[opts->bundle_dword] |= BUNDLEMAX; 1142 if (err) {
1299 ucode[opts->min_size_dword] &= 0xFFFF0000; 1143 DPRINTK(PROBE, ERR, "Failed to load firmware \"%s\": %d\n",
1300 ucode[opts->min_size_dword] |= (BUNDLESMALL) ? 0xFFFF : 0xFF80; 1144 fw_name, err);
1301 1145 return ERR_PTR(err);
1302 for (i = 0; i < UCODE_SIZE; i++) 1146 }
1303 cb->u.ucode[i] = cpu_to_le32(ucode[i]); 1147 /* Firmware should be precisely UCODE_SIZE (words) plus three bytes
1304 cb->command = cpu_to_le16(cb_ucode | cb_el); 1148 indicating the offsets for BUNDLESMALL, BUNDLEMAX, INTDELAY */
1305 return; 1149 if (fw->size != UCODE_SIZE * 4 + 3) {
1306 } 1150 DPRINTK(PROBE, ERR, "Firmware \"%s\" has wrong size %zu\n",
1307 1151 fw_name, fw->size);
1308noloaducode: 1152 release_firmware(fw);
1309 cb->command = cpu_to_le16(cb_nop | cb_el); 1153 return ERR_PTR(-EINVAL);
1310} 1154 }
1311 1155
1312static inline int e100_exec_cb_wait(struct nic *nic, struct sk_buff *skb, 1156 /* Read timer, bundle and min_size from end of firmware blob */
1313 void (*cb_prepare)(struct nic *, struct cb *, struct sk_buff *)) 1157 timer = fw->data[UCODE_SIZE * 4];
1314{ 1158 bundle = fw->data[UCODE_SIZE * 4 + 1];
1159 min_size = fw->data[UCODE_SIZE * 4 + 2];
1160
1161 if (timer >= UCODE_SIZE || bundle >= UCODE_SIZE ||
1162 min_size >= UCODE_SIZE) {
1163 DPRINTK(PROBE, ERR,
1164 "\"%s\" has bogus offset values (0x%x,0x%x,0x%x)\n",
1165 fw_name, timer, bundle, min_size);
1166 release_firmware(fw);
1167 return ERR_PTR(-EINVAL);
1168 }
1169 /* OK, firmware is validated and ready to use... */
1170 return fw;
1171}
1172
1173static void e100_setup_ucode(struct nic *nic, struct cb *cb,
1174 struct sk_buff *skb)
1175{
1176 const struct firmware *fw = (void *)skb;
1177 u8 timer, bundle, min_size;
1178
1179 /* It's not a real skb; we just abused the fact that e100_exec_cb
1180 will pass it through to here... */
1181 cb->skb = NULL;
1182
1183 /* firmware is stored as little endian already */
1184 memcpy(cb->u.ucode, fw->data, UCODE_SIZE * 4);
1185
1186 /* Read timer, bundle and min_size from end of firmware blob */
1187 timer = fw->data[UCODE_SIZE * 4];
1188 bundle = fw->data[UCODE_SIZE * 4 + 1];
1189 min_size = fw->data[UCODE_SIZE * 4 + 2];
1190
1191 /* Insert user-tunable settings in cb->u.ucode */
1192 cb->u.ucode[timer] &= cpu_to_le32(0xFFFF0000);
1193 cb->u.ucode[timer] |= cpu_to_le32(INTDELAY);
1194 cb->u.ucode[bundle] &= cpu_to_le32(0xFFFF0000);
1195 cb->u.ucode[bundle] |= cpu_to_le32(BUNDLEMAX);
1196 cb->u.ucode[min_size] &= cpu_to_le32(0xFFFF0000);
1197 cb->u.ucode[min_size] |= cpu_to_le32((BUNDLESMALL) ? 0xFFFF : 0xFF80);
1198
1199 cb->command = cpu_to_le16(cb_ucode | cb_el);
1200}
1201
1202static inline int e100_load_ucode_wait(struct nic *nic)
1203{
1204 const struct firmware *fw;
1315 int err = 0, counter = 50; 1205 int err = 0, counter = 50;
1316 struct cb *cb = nic->cb_to_clean; 1206 struct cb *cb = nic->cb_to_clean;
1317 1207
1318 if ((err = e100_exec_cb(nic, NULL, e100_setup_ucode))) 1208 fw = e100_request_firmware(nic);
1209 /* If it's NULL, then no ucode is required */
1210 if (!fw || IS_ERR(fw))
1211 return PTR_ERR(fw);
1212
1213 if ((err = e100_exec_cb(nic, (void *)fw, e100_setup_ucode)))
1319 DPRINTK(PROBE,ERR, "ucode cmd failed with error %d\n", err); 1214 DPRINTK(PROBE,ERR, "ucode cmd failed with error %d\n", err);
1320 1215
1321 /* must restart cuc */ 1216 /* must restart cuc */
@@ -1435,7 +1330,7 @@ static int e100_hw_init(struct nic *nic)
1435 return err; 1330 return err;
1436 if ((err = e100_exec_cmd(nic, ruc_load_base, 0))) 1331 if ((err = e100_exec_cmd(nic, ruc_load_base, 0)))
1437 return err; 1332 return err;
1438 if ((err = e100_exec_cb_wait(nic, NULL, e100_setup_ucode))) 1333 if ((err = e100_load_ucode_wait(nic)))
1439 return err; 1334 return err;
1440 if ((err = e100_exec_cb(nic, NULL, e100_configure))) 1335 if ((err = e100_exec_cb(nic, NULL, e100_configure)))
1441 return err; 1336 return err;
diff --git a/drivers/net/e1000/e1000_hw.c b/drivers/net/e1000/e1000_hw.c
index d04eef53571e..e1a3fc1303ee 100644
--- a/drivers/net/e1000/e1000_hw.c
+++ b/drivers/net/e1000/e1000_hw.c
@@ -6758,7 +6758,7 @@ static s32 e1000_get_cable_length(struct e1000_hw *hw, u16 *min_length,
6758 * returns: - E1000_ERR_XXX 6758 * returns: - E1000_ERR_XXX
6759 * E1000_SUCCESS 6759 * E1000_SUCCESS
6760 * 6760 *
6761 * For phy's older then IGP, this function simply reads the polarity bit in the 6761 * For phy's older than IGP, this function simply reads the polarity bit in the
6762 * Phy Status register. For IGP phy's, this bit is valid only if link speed is 6762 * Phy Status register. For IGP phy's, this bit is valid only if link speed is
6763 * 10 Mbps. If the link speed is 100 Mbps there is no polarity so this bit will 6763 * 10 Mbps. If the link speed is 100 Mbps there is no polarity so this bit will
6764 * return 0. If the link speed is 1000 Mbps the polarity status is in the 6764 * return 0. If the link speed is 1000 Mbps the polarity status is in the
@@ -6834,7 +6834,7 @@ static s32 e1000_check_polarity(struct e1000_hw *hw,
6834 * returns: - E1000_ERR_XXX 6834 * returns: - E1000_ERR_XXX
6835 * E1000_SUCCESS 6835 * E1000_SUCCESS
6836 * 6836 *
6837 * For phy's older then IGP, this function reads the Downshift bit in the Phy 6837 * For phy's older than IGP, this function reads the Downshift bit in the Phy
6838 * Specific Status register. For IGP phy's, it reads the Downgrade bit in the 6838 * Specific Status register. For IGP phy's, it reads the Downgrade bit in the
6839 * Link Health register. In IGP this bit is latched high, so the driver must 6839 * Link Health register. In IGP this bit is latched high, so the driver must
6840 * read it immediately after link is established. 6840 * read it immediately after link is established.
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index f2a5963b5a95..e415e81ecd3e 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -390,7 +390,8 @@ static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
390} 390}
391 391
392static DEFINE_MUTEX(nvm_mutex); 392static DEFINE_MUTEX(nvm_mutex);
393static pid_t nvm_owner = -1; 393static pid_t nvm_owner_pid = -1;
394static char nvm_owner_name[TASK_COMM_LEN] = "";
394 395
395/** 396/**
396 * e1000_acquire_swflag_ich8lan - Acquire software control flag 397 * e1000_acquire_swflag_ich8lan - Acquire software control flag
@@ -408,11 +409,15 @@ static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
408 might_sleep(); 409 might_sleep();
409 410
410 if (!mutex_trylock(&nvm_mutex)) { 411 if (!mutex_trylock(&nvm_mutex)) {
411 WARN(1, KERN_ERR "e1000e mutex contention. Owned by pid %d\n", 412 WARN(1, KERN_ERR "e1000e mutex contention. Owned by process "
412 nvm_owner); 413 "%s (pid %d), required by process %s (pid %d)\n",
414 nvm_owner_name, nvm_owner_pid,
415 current->comm, current->pid);
416
413 mutex_lock(&nvm_mutex); 417 mutex_lock(&nvm_mutex);
414 } 418 }
415 nvm_owner = current->pid; 419 nvm_owner_pid = current->pid;
420 strncpy(nvm_owner_name, current->comm, TASK_COMM_LEN);
416 421
417 while (timeout) { 422 while (timeout) {
418 extcnf_ctrl = er32(EXTCNF_CTRL); 423 extcnf_ctrl = er32(EXTCNF_CTRL);
@@ -430,7 +435,8 @@ static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
430 hw_dbg(hw, "FW or HW has locked the resource for too long.\n"); 435 hw_dbg(hw, "FW or HW has locked the resource for too long.\n");
431 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; 436 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
432 ew32(EXTCNF_CTRL, extcnf_ctrl); 437 ew32(EXTCNF_CTRL, extcnf_ctrl);
433 nvm_owner = -1; 438 nvm_owner_pid = -1;
439 strcpy(nvm_owner_name, "");
434 mutex_unlock(&nvm_mutex); 440 mutex_unlock(&nvm_mutex);
435 return -E1000_ERR_CONFIG; 441 return -E1000_ERR_CONFIG;
436 } 442 }
@@ -454,7 +460,8 @@ static void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
454 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; 460 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
455 ew32(EXTCNF_CTRL, extcnf_ctrl); 461 ew32(EXTCNF_CTRL, extcnf_ctrl);
456 462
457 nvm_owner = -1; 463 nvm_owner_pid = -1;
464 strcpy(nvm_owner_name, "");
458 mutex_unlock(&nvm_mutex); 465 mutex_unlock(&nvm_mutex);
459} 466}
460 467
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index d4639facd1bd..91817d0afcaf 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -4807,7 +4807,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
4807 } 4807 }
4808 } 4808 }
4809 4809
4810 err = pci_request_selected_regions(pdev, 4810 err = pci_request_selected_regions_exclusive(pdev,
4811 pci_select_bars(pdev, IORESOURCE_MEM), 4811 pci_select_bars(pdev, IORESOURCE_MEM),
4812 e1000e_driver_name); 4812 e1000e_driver_name);
4813 if (err) 4813 if (err)
diff --git a/drivers/net/e2100.c b/drivers/net/e2100.c
index 20eb05cddb83..b07ba1924de0 100644
--- a/drivers/net/e2100.c
+++ b/drivers/net/e2100.c
@@ -169,6 +169,7 @@ static const struct net_device_ops e21_netdev_ops = {
169 .ndo_get_stats = ei_get_stats, 169 .ndo_get_stats = ei_get_stats,
170 .ndo_set_multicast_list = ei_set_multicast_list, 170 .ndo_set_multicast_list = ei_set_multicast_list,
171 .ndo_validate_addr = eth_validate_addr, 171 .ndo_validate_addr = eth_validate_addr,
172 .ndo_set_mac_address = eth_mac_addr,
172 .ndo_change_mtu = eth_change_mtu, 173 .ndo_change_mtu = eth_change_mtu,
173#ifdef CONFIG_NET_POLL_CONTROLLER 174#ifdef CONFIG_NET_POLL_CONTROLLER
174 .ndo_poll_controller = ei_poll, 175 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index e3131ea629cd..dfe92264e825 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -132,7 +132,7 @@ void ehea_dump(void *adr, int len, char *msg)
132 int x; 132 int x;
133 unsigned char *deb = adr; 133 unsigned char *deb = adr;
134 for (x = 0; x < len; x += 16) { 134 for (x = 0; x < len; x += 16) {
135 printk(DRV_NAME " %s adr=%p ofs=%04x %016lx %016lx\n", msg, 135 printk(DRV_NAME " %s adr=%p ofs=%04x %016llx %016llx\n", msg,
136 deb, x, *((u64 *)&deb[0]), *((u64 *)&deb[8])); 136 deb, x, *((u64 *)&deb[0]), *((u64 *)&deb[8]));
137 deb += 16; 137 deb += 16;
138 } 138 }
@@ -883,7 +883,7 @@ static irqreturn_t ehea_qp_aff_irq_handler(int irq, void *param)
883 883
884 while (eqe) { 884 while (eqe) {
885 qp_token = EHEA_BMASK_GET(EHEA_EQE_QP_TOKEN, eqe->entry); 885 qp_token = EHEA_BMASK_GET(EHEA_EQE_QP_TOKEN, eqe->entry);
886 ehea_error("QP aff_err: entry=0x%lx, token=0x%x", 886 ehea_error("QP aff_err: entry=0x%llx, token=0x%x",
887 eqe->entry, qp_token); 887 eqe->entry, qp_token);
888 888
889 qp = port->port_res[qp_token].qp; 889 qp = port->port_res[qp_token].qp;
@@ -1159,7 +1159,7 @@ static void ehea_parse_eqe(struct ehea_adapter *adapter, u64 eqe)
1159 netif_stop_queue(port->netdev); 1159 netif_stop_queue(port->netdev);
1160 break; 1160 break;
1161 default: 1161 default:
1162 ehea_error("unknown event code %x, eqe=0x%lX", ec, eqe); 1162 ehea_error("unknown event code %x, eqe=0x%llX", ec, eqe);
1163 break; 1163 break;
1164 } 1164 }
1165} 1165}
@@ -1971,7 +1971,7 @@ static void ehea_set_multicast_list(struct net_device *dev)
1971 } 1971 }
1972 1972
1973 if (dev->mc_count > port->adapter->max_mc_mac) { 1973 if (dev->mc_count > port->adapter->max_mc_mac) {
1974 ehea_info("Mcast registration limit reached (0x%lx). " 1974 ehea_info("Mcast registration limit reached (0x%llx). "
1975 "Use ALLMULTI!", 1975 "Use ALLMULTI!",
1976 port->adapter->max_mc_mac); 1976 port->adapter->max_mc_mac);
1977 goto out; 1977 goto out;
diff --git a/drivers/net/ehea/ehea_phyp.c b/drivers/net/ehea/ehea_phyp.c
index 2a33a613d9e6..8fe9dcaa7538 100644
--- a/drivers/net/ehea/ehea_phyp.c
+++ b/drivers/net/ehea/ehea_phyp.c
@@ -214,7 +214,7 @@ u64 ehea_h_alloc_resource_qp(const u64 adapter_handle,
214 u64 *qp_handle, struct h_epas *h_epas) 214 u64 *qp_handle, struct h_epas *h_epas)
215{ 215{
216 u64 hret; 216 u64 hret;
217 u64 outs[PLPAR_HCALL9_BUFSIZE]; 217 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
218 218
219 u64 allocate_controls = 219 u64 allocate_controls =
220 EHEA_BMASK_SET(H_ALL_RES_QP_EQPO, init_attr->low_lat_rq1 ? 1 : 0) 220 EHEA_BMASK_SET(H_ALL_RES_QP_EQPO, init_attr->low_lat_rq1 ? 1 : 0)
@@ -312,7 +312,7 @@ u64 ehea_h_alloc_resource_cq(const u64 adapter_handle,
312 u64 *cq_handle, struct h_epas *epas) 312 u64 *cq_handle, struct h_epas *epas)
313{ 313{
314 u64 hret; 314 u64 hret;
315 u64 outs[PLPAR_HCALL9_BUFSIZE]; 315 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
316 316
317 hret = ehea_plpar_hcall9(H_ALLOC_HEA_RESOURCE, 317 hret = ehea_plpar_hcall9(H_ALLOC_HEA_RESOURCE,
318 outs, 318 outs,
@@ -374,7 +374,7 @@ u64 ehea_h_alloc_resource_eq(const u64 adapter_handle,
374 struct ehea_eq_attr *eq_attr, u64 *eq_handle) 374 struct ehea_eq_attr *eq_attr, u64 *eq_handle)
375{ 375{
376 u64 hret, allocate_controls; 376 u64 hret, allocate_controls;
377 u64 outs[PLPAR_HCALL9_BUFSIZE]; 377 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
378 378
379 /* resource type */ 379 /* resource type */
380 allocate_controls = 380 allocate_controls =
@@ -407,7 +407,7 @@ u64 ehea_h_modify_ehea_qp(const u64 adapter_handle, const u8 cat,
407 u16 *out_swr, u16 *out_rwr) 407 u16 *out_swr, u16 *out_rwr)
408{ 408{
409 u64 hret; 409 u64 hret;
410 u64 outs[PLPAR_HCALL9_BUFSIZE]; 410 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
411 411
412 hret = ehea_plpar_hcall9(H_MODIFY_HEA_QP, 412 hret = ehea_plpar_hcall9(H_MODIFY_HEA_QP,
413 outs, 413 outs,
@@ -449,7 +449,7 @@ u64 ehea_h_register_smr(const u64 adapter_handle, const u64 orig_mr_handle,
449 struct ehea_mr *mr) 449 struct ehea_mr *mr)
450{ 450{
451 u64 hret; 451 u64 hret;
452 u64 outs[PLPAR_HCALL9_BUFSIZE]; 452 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
453 453
454 hret = ehea_plpar_hcall9(H_REGISTER_SMR, 454 hret = ehea_plpar_hcall9(H_REGISTER_SMR,
455 outs, 455 outs,
@@ -468,7 +468,7 @@ u64 ehea_h_register_smr(const u64 adapter_handle, const u64 orig_mr_handle,
468 468
469u64 ehea_h_disable_and_get_hea(const u64 adapter_handle, const u64 qp_handle) 469u64 ehea_h_disable_and_get_hea(const u64 adapter_handle, const u64 qp_handle)
470{ 470{
471 u64 outs[PLPAR_HCALL9_BUFSIZE]; 471 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
472 472
473 return ehea_plpar_hcall9(H_DISABLE_AND_GET_HEA, 473 return ehea_plpar_hcall9(H_DISABLE_AND_GET_HEA,
474 outs, 474 outs,
@@ -493,7 +493,7 @@ u64 ehea_h_alloc_resource_mr(const u64 adapter_handle, const u64 vaddr,
493 const u32 pd, u64 *mr_handle, u32 *lkey) 493 const u32 pd, u64 *mr_handle, u32 *lkey)
494{ 494{
495 u64 hret; 495 u64 hret;
496 u64 outs[PLPAR_HCALL9_BUFSIZE]; 496 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
497 497
498 hret = ehea_plpar_hcall9(H_ALLOC_HEA_RESOURCE, 498 hret = ehea_plpar_hcall9(H_ALLOC_HEA_RESOURCE,
499 outs, 499 outs,
@@ -564,7 +564,7 @@ u64 ehea_h_modify_ehea_port(const u64 adapter_handle, const u16 port_num,
564 const u8 cb_cat, const u64 select_mask, 564 const u8 cb_cat, const u64 select_mask,
565 void *cb_addr) 565 void *cb_addr)
566{ 566{
567 u64 outs[PLPAR_HCALL9_BUFSIZE]; 567 unsigned long outs[PLPAR_HCALL9_BUFSIZE];
568 u64 port_info; 568 u64 port_info;
569 u64 arr_index = 0; 569 u64 arr_index = 0;
570 u64 cb_logaddr = virt_to_abs(cb_addr); 570 u64 cb_logaddr = virt_to_abs(cb_addr);
diff --git a/drivers/net/ehea/ehea_qmr.c b/drivers/net/ehea/ehea_qmr.c
index 225c692b5d99..49d766ebbcf4 100644
--- a/drivers/net/ehea/ehea_qmr.c
+++ b/drivers/net/ehea/ehea_qmr.c
@@ -168,7 +168,7 @@ struct ehea_cq *ehea_create_cq(struct ehea_adapter *adapter,
168 cq->fw_handle, rpage, 1); 168 cq->fw_handle, rpage, 1);
169 if (hret < H_SUCCESS) { 169 if (hret < H_SUCCESS) {
170 ehea_error("register_rpage_cq failed ehea_cq=%p " 170 ehea_error("register_rpage_cq failed ehea_cq=%p "
171 "hret=%lx counter=%i act_pages=%i", 171 "hret=%llx counter=%i act_pages=%i",
172 cq, hret, counter, cq->attr.nr_pages); 172 cq, hret, counter, cq->attr.nr_pages);
173 goto out_kill_hwq; 173 goto out_kill_hwq;
174 } 174 }
@@ -178,13 +178,13 @@ struct ehea_cq *ehea_create_cq(struct ehea_adapter *adapter,
178 178
179 if ((hret != H_SUCCESS) || (vpage)) { 179 if ((hret != H_SUCCESS) || (vpage)) {
180 ehea_error("registration of pages not " 180 ehea_error("registration of pages not "
181 "complete hret=%lx\n", hret); 181 "complete hret=%llx\n", hret);
182 goto out_kill_hwq; 182 goto out_kill_hwq;
183 } 183 }
184 } else { 184 } else {
185 if (hret != H_PAGE_REGISTERED) { 185 if (hret != H_PAGE_REGISTERED) {
186 ehea_error("CQ: registration of page failed " 186 ehea_error("CQ: registration of page failed "
187 "hret=%lx\n", hret); 187 "hret=%llx\n", hret);
188 goto out_kill_hwq; 188 goto out_kill_hwq;
189 } 189 }
190 } 190 }
@@ -986,15 +986,15 @@ void print_error_data(u64 *data)
986 length = EHEA_PAGESIZE; 986 length = EHEA_PAGESIZE;
987 987
988 if (type == 0x8) /* Queue Pair */ 988 if (type == 0x8) /* Queue Pair */
989 ehea_error("QP (resource=%lX) state: AER=0x%lX, AERR=0x%lX, " 989 ehea_error("QP (resource=%llX) state: AER=0x%llX, AERR=0x%llX, "
990 "port=%lX", resource, data[6], data[12], data[22]); 990 "port=%llX", resource, data[6], data[12], data[22]);
991 991
992 if (type == 0x4) /* Completion Queue */ 992 if (type == 0x4) /* Completion Queue */
993 ehea_error("CQ (resource=%lX) state: AER=0x%lX", resource, 993 ehea_error("CQ (resource=%llX) state: AER=0x%llX", resource,
994 data[6]); 994 data[6]);
995 995
996 if (type == 0x3) /* Event Queue */ 996 if (type == 0x3) /* Event Queue */
997 ehea_error("EQ (resource=%lX) state: AER=0x%lX", resource, 997 ehea_error("EQ (resource=%llX) state: AER=0x%llX", resource,
998 data[6]); 998 data[6]);
999 999
1000 ehea_dump(data, length, "error data"); 1000 ehea_dump(data, length, "error data");
@@ -1016,11 +1016,11 @@ void ehea_error_data(struct ehea_adapter *adapter, u64 res_handle)
1016 rblock); 1016 rblock);
1017 1017
1018 if (ret == H_R_STATE) 1018 if (ret == H_R_STATE)
1019 ehea_error("No error data is available: %lX.", res_handle); 1019 ehea_error("No error data is available: %llX.", res_handle);
1020 else if (ret == H_SUCCESS) 1020 else if (ret == H_SUCCESS)
1021 print_error_data(rblock); 1021 print_error_data(rblock);
1022 else 1022 else
1023 ehea_error("Error data could not be fetched: %lX", res_handle); 1023 ehea_error("Error data could not be fetched: %llX", res_handle);
1024 1024
1025 kfree(rblock); 1025 kfree(rblock);
1026} 1026}
diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c
index cefe1d98f93e..fc6cc038c7b8 100644
--- a/drivers/net/enc28j60.c
+++ b/drivers/net/enc28j60.c
@@ -1531,6 +1531,17 @@ static int enc28j60_chipset_init(struct net_device *dev)
1531 return enc28j60_hw_init(priv); 1531 return enc28j60_hw_init(priv);
1532} 1532}
1533 1533
1534static const struct net_device_ops enc28j60_netdev_ops = {
1535 .ndo_open = enc28j60_net_open,
1536 .ndo_stop = enc28j60_net_close,
1537 .ndo_start_xmit = enc28j60_send_packet,
1538 .ndo_set_multicast_list = enc28j60_set_multicast_list,
1539 .ndo_set_mac_address = enc28j60_set_mac_address,
1540 .ndo_tx_timeout = enc28j60_tx_timeout,
1541 .ndo_change_mtu = eth_change_mtu,
1542 .ndo_validate_addr = eth_validate_addr,
1543};
1544
1534static int __devinit enc28j60_probe(struct spi_device *spi) 1545static int __devinit enc28j60_probe(struct spi_device *spi)
1535{ 1546{
1536 struct net_device *dev; 1547 struct net_device *dev;
@@ -1585,12 +1596,7 @@ static int __devinit enc28j60_probe(struct spi_device *spi)
1585 1596
1586 dev->if_port = IF_PORT_10BASET; 1597 dev->if_port = IF_PORT_10BASET;
1587 dev->irq = spi->irq; 1598 dev->irq = spi->irq;
1588 dev->open = enc28j60_net_open; 1599 dev->netdev_ops = &enc28j60_netdev_ops;
1589 dev->stop = enc28j60_net_close;
1590 dev->hard_start_xmit = enc28j60_send_packet;
1591 dev->set_multicast_list = &enc28j60_set_multicast_list;
1592 dev->set_mac_address = enc28j60_set_mac_address;
1593 dev->tx_timeout = &enc28j60_tx_timeout;
1594 dev->watchdog_timeo = TX_TIMEOUT; 1600 dev->watchdog_timeo = TX_TIMEOUT;
1595 SET_ETHTOOL_OPS(dev, &enc28j60_ethtool_ops); 1601 SET_ETHTOOL_OPS(dev, &enc28j60_ethtool_ops);
1596 1602
diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c
index d039e16f2763..7d60551d538f 100644
--- a/drivers/net/enic/enic_main.c
+++ b/drivers/net/enic/enic_main.c
@@ -1599,6 +1599,7 @@ static const struct net_device_ops enic_netdev_ops = {
1599 .ndo_start_xmit = enic_hard_start_xmit, 1599 .ndo_start_xmit = enic_hard_start_xmit,
1600 .ndo_get_stats = enic_get_stats, 1600 .ndo_get_stats = enic_get_stats,
1601 .ndo_validate_addr = eth_validate_addr, 1601 .ndo_validate_addr = eth_validate_addr,
1602 .ndo_set_mac_address = eth_mac_addr,
1602 .ndo_set_multicast_list = enic_set_multicast_list, 1603 .ndo_set_multicast_list = enic_set_multicast_list,
1603 .ndo_change_mtu = enic_change_mtu, 1604 .ndo_change_mtu = enic_change_mtu,
1604 .ndo_vlan_rx_register = enic_vlan_rx_register, 1605 .ndo_vlan_rx_register = enic_vlan_rx_register,
diff --git a/drivers/net/epic100.c b/drivers/net/epic100.c
index f9b37c80dda6..a539bc3163cf 100644
--- a/drivers/net/epic100.c
+++ b/drivers/net/epic100.c
@@ -308,7 +308,18 @@ static int epic_close(struct net_device *dev);
308static struct net_device_stats *epic_get_stats(struct net_device *dev); 308static struct net_device_stats *epic_get_stats(struct net_device *dev);
309static void set_rx_mode(struct net_device *dev); 309static void set_rx_mode(struct net_device *dev);
310 310
311 311static const struct net_device_ops epic_netdev_ops = {
312 .ndo_open = epic_open,
313 .ndo_stop = epic_close,
314 .ndo_start_xmit = epic_start_xmit,
315 .ndo_tx_timeout = epic_tx_timeout,
316 .ndo_get_stats = epic_get_stats,
317 .ndo_set_multicast_list = set_rx_mode,
318 .ndo_do_ioctl = netdev_ioctl,
319 .ndo_change_mtu = eth_change_mtu,
320 .ndo_set_mac_address = eth_mac_addr,
321 .ndo_validate_addr = eth_validate_addr,
322};
312 323
313static int __devinit epic_init_one (struct pci_dev *pdev, 324static int __devinit epic_init_one (struct pci_dev *pdev,
314 const struct pci_device_id *ent) 325 const struct pci_device_id *ent)
@@ -483,15 +494,9 @@ static int __devinit epic_init_one (struct pci_dev *pdev,
483 dev->if_port = ep->default_port = option; 494 dev->if_port = ep->default_port = option;
484 495
485 /* The Epic-specific entries in the device structure. */ 496 /* The Epic-specific entries in the device structure. */
486 dev->open = &epic_open; 497 dev->netdev_ops = &epic_netdev_ops;
487 dev->hard_start_xmit = &epic_start_xmit;
488 dev->stop = &epic_close;
489 dev->get_stats = &epic_get_stats;
490 dev->set_multicast_list = &set_rx_mode;
491 dev->do_ioctl = &netdev_ioctl;
492 dev->ethtool_ops = &netdev_ethtool_ops; 498 dev->ethtool_ops = &netdev_ethtool_ops;
493 dev->watchdog_timeo = TX_TIMEOUT; 499 dev->watchdog_timeo = TX_TIMEOUT;
494 dev->tx_timeout = &epic_tx_timeout;
495 netif_napi_add(dev, &ep->napi, epic_poll, 64); 500 netif_napi_add(dev, &ep->napi, epic_poll, 64);
496 501
497 ret = register_netdev(dev); 502 ret = register_netdev(dev);
diff --git a/drivers/net/fealnx.c b/drivers/net/fealnx.c
index 31ab1ff623fc..daf7272c3352 100644
--- a/drivers/net/fealnx.c
+++ b/drivers/net/fealnx.c
@@ -467,6 +467,18 @@ static void stop_nic_rxtx(void __iomem *ioaddr, long crvalue)
467 } 467 }
468} 468}
469 469
470static const struct net_device_ops netdev_ops = {
471 .ndo_open = netdev_open,
472 .ndo_stop = netdev_close,
473 .ndo_start_xmit = start_tx,
474 .ndo_get_stats = get_stats,
475 .ndo_set_multicast_list = set_rx_mode,
476 .ndo_do_ioctl = mii_ioctl,
477 .ndo_tx_timeout = fealnx_tx_timeout,
478 .ndo_change_mtu = eth_change_mtu,
479 .ndo_set_mac_address = eth_mac_addr,
480 .ndo_validate_addr = eth_validate_addr,
481};
470 482
471static int __devinit fealnx_init_one(struct pci_dev *pdev, 483static int __devinit fealnx_init_one(struct pci_dev *pdev,
472 const struct pci_device_id *ent) 484 const struct pci_device_id *ent)
@@ -649,15 +661,8 @@ static int __devinit fealnx_init_one(struct pci_dev *pdev,
649 np->mii.force_media = 1; 661 np->mii.force_media = 1;
650 } 662 }
651 663
652 /* The chip-specific entries in the device structure. */ 664 dev->netdev_ops = &netdev_ops;
653 dev->open = &netdev_open;
654 dev->hard_start_xmit = &start_tx;
655 dev->stop = &netdev_close;
656 dev->get_stats = &get_stats;
657 dev->set_multicast_list = &set_rx_mode;
658 dev->do_ioctl = &mii_ioctl;
659 dev->ethtool_ops = &netdev_ethtool_ops; 665 dev->ethtool_ops = &netdev_ethtool_ops;
660 dev->tx_timeout = &fealnx_tx_timeout;
661 dev->watchdog_timeo = TX_TIMEOUT; 666 dev->watchdog_timeo = TX_TIMEOUT;
662 667
663 err = register_netdev(dev); 668 err = register_netdev(dev);
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index 5b68dc20168d..5b910cf63740 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -13,7 +13,7 @@
13 * Copyright (C) 2004 Andrew de Quincey (wol support) 13 * Copyright (C) 2004 Andrew de Quincey (wol support)
14 * Copyright (C) 2004 Carl-Daniel Hailfinger (invalid MAC handling, insane 14 * Copyright (C) 2004 Carl-Daniel Hailfinger (invalid MAC handling, insane
15 * IRQ rate fixes, bigendian fixes, cleanups, verification) 15 * IRQ rate fixes, bigendian fixes, cleanups, verification)
16 * Copyright (c) 2004,2005,2006,2007,2008 NVIDIA Corporation 16 * Copyright (c) 2004,2005,2006,2007,2008,2009 NVIDIA Corporation
17 * 17 *
18 * This program is free software; you can redistribute it and/or modify 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 19 * it under the terms of the GNU General Public License as published by
@@ -39,7 +39,7 @@
39 * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few 39 * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few
40 * superfluous timer interrupts from the nic. 40 * superfluous timer interrupts from the nic.
41 */ 41 */
42#define FORCEDETH_VERSION "0.61" 42#define FORCEDETH_VERSION "0.62"
43#define DRV_NAME "forcedeth" 43#define DRV_NAME "forcedeth"
44 44
45#include <linux/module.h> 45#include <linux/module.h>
@@ -2096,14 +2096,15 @@ static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev)
2096 ((skb_shinfo(skb)->frags[i].size & (NV_TX2_TSO_MAX_SIZE-1)) ? 1 : 0); 2096 ((skb_shinfo(skb)->frags[i].size & (NV_TX2_TSO_MAX_SIZE-1)) ? 1 : 0);
2097 } 2097 }
2098 2098
2099 spin_lock_irqsave(&np->lock, flags);
2099 empty_slots = nv_get_empty_tx_slots(np); 2100 empty_slots = nv_get_empty_tx_slots(np);
2100 if (unlikely(empty_slots <= entries)) { 2101 if (unlikely(empty_slots <= entries)) {
2101 spin_lock_irqsave(&np->lock, flags);
2102 netif_stop_queue(dev); 2102 netif_stop_queue(dev);
2103 np->tx_stop = 1; 2103 np->tx_stop = 1;
2104 spin_unlock_irqrestore(&np->lock, flags); 2104 spin_unlock_irqrestore(&np->lock, flags);
2105 return NETDEV_TX_BUSY; 2105 return NETDEV_TX_BUSY;
2106 } 2106 }
2107 spin_unlock_irqrestore(&np->lock, flags);
2107 2108
2108 start_tx = put_tx = np->put_tx.orig; 2109 start_tx = put_tx = np->put_tx.orig;
2109 2110
@@ -2214,14 +2215,15 @@ static int nv_start_xmit_optimized(struct sk_buff *skb, struct net_device *dev)
2214 ((skb_shinfo(skb)->frags[i].size & (NV_TX2_TSO_MAX_SIZE-1)) ? 1 : 0); 2215 ((skb_shinfo(skb)->frags[i].size & (NV_TX2_TSO_MAX_SIZE-1)) ? 1 : 0);
2215 } 2216 }
2216 2217
2218 spin_lock_irqsave(&np->lock, flags);
2217 empty_slots = nv_get_empty_tx_slots(np); 2219 empty_slots = nv_get_empty_tx_slots(np);
2218 if (unlikely(empty_slots <= entries)) { 2220 if (unlikely(empty_slots <= entries)) {
2219 spin_lock_irqsave(&np->lock, flags);
2220 netif_stop_queue(dev); 2221 netif_stop_queue(dev);
2221 np->tx_stop = 1; 2222 np->tx_stop = 1;
2222 spin_unlock_irqrestore(&np->lock, flags); 2223 spin_unlock_irqrestore(&np->lock, flags);
2223 return NETDEV_TX_BUSY; 2224 return NETDEV_TX_BUSY;
2224 } 2225 }
2226 spin_unlock_irqrestore(&np->lock, flags);
2225 2227
2226 start_tx = put_tx = np->put_tx.ex; 2228 start_tx = put_tx = np->put_tx.ex;
2227 start_tx_ctx = np->put_tx_ctx; 2229 start_tx_ctx = np->put_tx_ctx;
@@ -3403,10 +3405,10 @@ static irqreturn_t nv_nic_irq(int foo, void *data)
3403 3405
3404#ifdef CONFIG_FORCEDETH_NAPI 3406#ifdef CONFIG_FORCEDETH_NAPI
3405 if (events & NVREG_IRQ_RX_ALL) { 3407 if (events & NVREG_IRQ_RX_ALL) {
3408 spin_lock(&np->lock);
3406 netif_rx_schedule(&np->napi); 3409 netif_rx_schedule(&np->napi);
3407 3410
3408 /* Disable furthur receive irq's */ 3411 /* Disable furthur receive irq's */
3409 spin_lock(&np->lock);
3410 np->irqmask &= ~NVREG_IRQ_RX_ALL; 3412 np->irqmask &= ~NVREG_IRQ_RX_ALL;
3411 3413
3412 if (np->msi_flags & NV_MSI_X_ENABLED) 3414 if (np->msi_flags & NV_MSI_X_ENABLED)
@@ -3520,10 +3522,10 @@ static irqreturn_t nv_nic_irq_optimized(int foo, void *data)
3520 3522
3521#ifdef CONFIG_FORCEDETH_NAPI 3523#ifdef CONFIG_FORCEDETH_NAPI
3522 if (events & NVREG_IRQ_RX_ALL) { 3524 if (events & NVREG_IRQ_RX_ALL) {
3525 spin_lock(&np->lock);
3523 netif_rx_schedule(&np->napi); 3526 netif_rx_schedule(&np->napi);
3524 3527
3525 /* Disable furthur receive irq's */ 3528 /* Disable furthur receive irq's */
3526 spin_lock(&np->lock);
3527 np->irqmask &= ~NVREG_IRQ_RX_ALL; 3529 np->irqmask &= ~NVREG_IRQ_RX_ALL;
3528 3530
3529 if (np->msi_flags & NV_MSI_X_ENABLED) 3531 if (np->msi_flags & NV_MSI_X_ENABLED)
@@ -6167,19 +6169,19 @@ static struct pci_device_id pci_tbl[] = {
6167 }, 6169 },
6168 { /* MCP79 Ethernet Controller */ 6170 { /* MCP79 Ethernet Controller */
6169 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_36), 6171 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_36),
6170 .driver_data = DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE, 6172 .driver_data = DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE,
6171 }, 6173 },
6172 { /* MCP79 Ethernet Controller */ 6174 { /* MCP79 Ethernet Controller */
6173 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_37), 6175 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_37),
6174 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE, 6176 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE,
6175 }, 6177 },
6176 { /* MCP79 Ethernet Controller */ 6178 { /* MCP79 Ethernet Controller */
6177 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_38), 6179 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_38),
6178 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE, 6180 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE,
6179 }, 6181 },
6180 { /* MCP79 Ethernet Controller */ 6182 { /* MCP79 Ethernet Controller */
6181 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_39), 6183 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_39),
6182 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE, 6184 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT|DEV_HAS_GEAR_MODE,
6183 }, 6185 },
6184 {0,}, 6186 {0,},
6185}; 6187};
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index 4e6a9195fe5f..ce900e54d8d1 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -795,6 +795,7 @@ static int fs_enet_open(struct net_device *dev)
795 795
796 err = fs_init_phy(dev); 796 err = fs_init_phy(dev);
797 if (err) { 797 if (err) {
798 free_irq(fep->interrupt, dev);
798 if (fep->fpi->use_napi) 799 if (fep->fpi->use_napi)
799 napi_disable(&fep->napi); 800 napi_disable(&fep->napi);
800 return err; 801 return err;
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index c672ecfc9595..ea530673236e 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -238,8 +238,8 @@ static int gfar_of_init(struct net_device *dev)
238 goto err_out; 238 goto err_out;
239 } 239 }
240 240
241 snprintf(priv->phy_bus_id, BUS_ID_SIZE, PHY_ID_FMT, "0", 241 snprintf(priv->phy_bus_id, sizeof(priv->phy_bus_id),
242 fixed_link[0]); 242 PHY_ID_FMT, "0", fixed_link[0]);
243 } else { 243 } else {
244 phy = of_find_node_by_phandle(*ph); 244 phy = of_find_node_by_phandle(*ph);
245 245
@@ -256,7 +256,7 @@ static int gfar_of_init(struct net_device *dev)
256 of_node_put(mdio); 256 of_node_put(mdio);
257 257
258 gfar_mdio_bus_name(bus_name, mdio); 258 gfar_mdio_bus_name(bus_name, mdio);
259 snprintf(priv->phy_bus_id, BUS_ID_SIZE, "%s:%02x", 259 snprintf(priv->phy_bus_id, sizeof(priv->phy_bus_id), "%s:%02x",
260 bus_name, *id); 260 bus_name, *id);
261 } 261 }
262 262
@@ -296,6 +296,20 @@ err_out:
296 return err; 296 return err;
297} 297}
298 298
299/* Ioctl MII Interface */
300static int gfar_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
301{
302 struct gfar_private *priv = netdev_priv(dev);
303
304 if (!netif_running(dev))
305 return -EINVAL;
306
307 if (!priv->phydev)
308 return -ENODEV;
309
310 return phy_mii_ioctl(priv->phydev, if_mii(rq), cmd);
311}
312
299/* Set up the ethernet device structure, private data, 313/* Set up the ethernet device structure, private data,
300 * and anything else we need before we start */ 314 * and anything else we need before we start */
301static int gfar_probe(struct of_device *ofdev, 315static int gfar_probe(struct of_device *ofdev,
@@ -366,6 +380,7 @@ static int gfar_probe(struct of_device *ofdev,
366 dev->set_multicast_list = gfar_set_multi; 380 dev->set_multicast_list = gfar_set_multi;
367 381
368 dev->ethtool_ops = &gfar_ethtool_ops; 382 dev->ethtool_ops = &gfar_ethtool_ops;
383 dev->do_ioctl = gfar_ioctl;
369 384
370 if (priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM) { 385 if (priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM) {
371 priv->rx_csum_enable = 1; 386 priv->rx_csum_enable = 1;
@@ -1607,10 +1622,18 @@ static int gfar_clean_tx_ring(struct net_device *dev)
1607static void gfar_schedule_cleanup(struct net_device *dev) 1622static void gfar_schedule_cleanup(struct net_device *dev)
1608{ 1623{
1609 struct gfar_private *priv = netdev_priv(dev); 1624 struct gfar_private *priv = netdev_priv(dev);
1625 unsigned long flags;
1626
1627 spin_lock_irqsave(&priv->txlock, flags);
1628 spin_lock(&priv->rxlock);
1629
1610 if (netif_rx_schedule_prep(&priv->napi)) { 1630 if (netif_rx_schedule_prep(&priv->napi)) {
1611 gfar_write(&priv->regs->imask, IMASK_RTX_DISABLED); 1631 gfar_write(&priv->regs->imask, IMASK_RTX_DISABLED);
1612 __netif_rx_schedule(&priv->napi); 1632 __netif_rx_schedule(&priv->napi);
1613 } 1633 }
1634
1635 spin_unlock(&priv->rxlock);
1636 spin_unlock_irqrestore(&priv->txlock, flags);
1614} 1637}
1615 1638
1616/* Interrupt Handler for Transmit complete */ 1639/* Interrupt Handler for Transmit complete */
@@ -1973,6 +1996,8 @@ static void adjust_link(struct net_device *dev)
1973 case 1000: 1996 case 1000:
1974 tempval = 1997 tempval =
1975 ((tempval & ~(MACCFG2_IF)) | MACCFG2_GMII); 1998 ((tempval & ~(MACCFG2_IF)) | MACCFG2_GMII);
1999
2000 ecntrl &= ~(ECNTRL_R100);
1976 break; 2001 break;
1977 case 100: 2002 case 100:
1978 case 10: 2003 case 10:
diff --git a/drivers/net/hamachi.c b/drivers/net/hamachi.c
index 32200227c923..7e8b3c59a7d6 100644
--- a/drivers/net/hamachi.c
+++ b/drivers/net/hamachi.c
@@ -576,6 +576,7 @@ static const struct net_device_ops hamachi_netdev_ops = {
576 .ndo_set_multicast_list = set_rx_mode, 576 .ndo_set_multicast_list = set_rx_mode,
577 .ndo_change_mtu = eth_change_mtu, 577 .ndo_change_mtu = eth_change_mtu,
578 .ndo_validate_addr = eth_validate_addr, 578 .ndo_validate_addr = eth_validate_addr,
579 .ndo_set_mac_address = eth_mac_addr,
579 .ndo_tx_timeout = hamachi_tx_timeout, 580 .ndo_tx_timeout = hamachi_tx_timeout,
580 .ndo_do_ioctl = netdev_ioctl, 581 .ndo_do_ioctl = netdev_ioctl,
581}; 582};
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 50f1e172ee8f..2d4089894ec7 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -717,11 +717,12 @@ static int sixpack_ioctl(struct tty_struct *tty, struct file *file,
717 unsigned int cmd, unsigned long arg) 717 unsigned int cmd, unsigned long arg)
718{ 718{
719 struct sixpack *sp = sp_get(tty); 719 struct sixpack *sp = sp_get(tty);
720 struct net_device *dev = sp->dev; 720 struct net_device *dev;
721 unsigned int tmp, err; 721 unsigned int tmp, err;
722 722
723 if (!sp) 723 if (!sp)
724 return -ENXIO; 724 return -ENXIO;
725 dev = sp->dev;
725 726
726 switch(cmd) { 727 switch(cmd) {
727 case SIOCGIFNAME: 728 case SIOCGIFNAME:
diff --git a/drivers/net/hp-plus.c b/drivers/net/hp-plus.c
index b507dbc16e62..5e070f446635 100644
--- a/drivers/net/hp-plus.c
+++ b/drivers/net/hp-plus.c
@@ -166,6 +166,7 @@ static const struct net_device_ops hpp_netdev_ops = {
166 .ndo_get_stats = eip_get_stats, 166 .ndo_get_stats = eip_get_stats,
167 .ndo_set_multicast_list = eip_set_multicast_list, 167 .ndo_set_multicast_list = eip_set_multicast_list,
168 .ndo_validate_addr = eth_validate_addr, 168 .ndo_validate_addr = eth_validate_addr,
169 .ndo_set_mac_address = eth_mac_addr,
169 .ndo_change_mtu = eth_change_mtu, 170 .ndo_change_mtu = eth_change_mtu,
170#ifdef CONFIG_NET_POLL_CONTROLLER 171#ifdef CONFIG_NET_POLL_CONTROLLER
171 .ndo_poll_controller = eip_poll, 172 .ndo_poll_controller = eip_poll,
diff --git a/drivers/net/hp100.c b/drivers/net/hp100.c
index ebe7651fcb86..ad8be7e78290 100644
--- a/drivers/net/hp100.c
+++ b/drivers/net/hp100.c
@@ -425,6 +425,28 @@ struct net_device * __init hp100_probe(int unit)
425} 425}
426#endif /* !MODULE && CONFIG_ISA */ 426#endif /* !MODULE && CONFIG_ISA */
427 427
428static const struct net_device_ops hp100_bm_netdev_ops = {
429 .ndo_open = hp100_open,
430 .ndo_stop = hp100_close,
431 .ndo_start_xmit = hp100_start_xmit_bm,
432 .ndo_get_stats = hp100_get_stats,
433 .ndo_set_multicast_list = hp100_set_multicast_list,
434 .ndo_change_mtu = eth_change_mtu,
435 .ndo_set_mac_address = eth_mac_addr,
436 .ndo_validate_addr = eth_validate_addr,
437};
438
439static const struct net_device_ops hp100_netdev_ops = {
440 .ndo_open = hp100_open,
441 .ndo_stop = hp100_close,
442 .ndo_start_xmit = hp100_start_xmit,
443 .ndo_get_stats = hp100_get_stats,
444 .ndo_set_multicast_list = hp100_set_multicast_list,
445 .ndo_change_mtu = eth_change_mtu,
446 .ndo_set_mac_address = eth_mac_addr,
447 .ndo_validate_addr = eth_validate_addr,
448};
449
428static int __devinit hp100_probe1(struct net_device *dev, int ioaddr, 450static int __devinit hp100_probe1(struct net_device *dev, int ioaddr,
429 u_char bus, struct pci_dev *pci_dev) 451 u_char bus, struct pci_dev *pci_dev)
430{ 452{
@@ -657,16 +679,10 @@ static int __devinit hp100_probe1(struct net_device *dev, int ioaddr,
657 lp->virt_memory_size = virt_memory_size; 679 lp->virt_memory_size = virt_memory_size;
658 lp->rx_ratio = hp100_rx_ratio; /* can be conf'd with insmod */ 680 lp->rx_ratio = hp100_rx_ratio; /* can be conf'd with insmod */
659 681
660 dev->open = hp100_open;
661 dev->stop = hp100_close;
662
663 if (lp->mode == 1) /* busmaster */ 682 if (lp->mode == 1) /* busmaster */
664 dev->hard_start_xmit = hp100_start_xmit_bm; 683 dev->netdev_ops = &hp100_bm_netdev_ops;
665 else 684 else
666 dev->hard_start_xmit = hp100_start_xmit; 685 dev->netdev_ops = &hp100_netdev_ops;
667
668 dev->get_stats = hp100_get_stats;
669 dev->set_multicast_list = &hp100_set_multicast_list;
670 686
671 /* Ask the card for which IRQ line it is configured */ 687 /* Ask the card for which IRQ line it is configured */
672 if (bus == HP100_BUS_PCI) { 688 if (bus == HP100_BUS_PCI) {
diff --git a/drivers/net/hydra.c b/drivers/net/hydra.c
index 9cb38a8d4387..8ac0930c183c 100644
--- a/drivers/net/hydra.c
+++ b/drivers/net/hydra.c
@@ -103,6 +103,7 @@ static const struct net_device_ops hydra_netdev_ops = {
103 .ndo_get_stats = ei_get_stats, 103 .ndo_get_stats = ei_get_stats,
104 .ndo_set_multicast_list = ei_set_multicast_list, 104 .ndo_set_multicast_list = ei_set_multicast_list,
105 .ndo_validate_addr = eth_validate_addr, 105 .ndo_validate_addr = eth_validate_addr,
106 .ndo_set_mac_address = eth_mac_addr,
106 .ndo_change_mtu = eth_change_mtu, 107 .ndo_change_mtu = eth_change_mtu,
107#ifdef CONFIG_NET_POLL_CONTROLLER 108#ifdef CONFIG_NET_POLL_CONTROLLER
108 .ndo_poll_controller = ei_poll, 109 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/ibm_newemac/mal.c b/drivers/net/ibm_newemac/mal.c
index ecf9798987fa..2a2fc17b2878 100644
--- a/drivers/net/ibm_newemac/mal.c
+++ b/drivers/net/ibm_newemac/mal.c
@@ -613,7 +613,9 @@ static int __devinit mal_probe(struct of_device *ofdev,
613 INIT_LIST_HEAD(&mal->list); 613 INIT_LIST_HEAD(&mal->list);
614 spin_lock_init(&mal->lock); 614 spin_lock_init(&mal->lock);
615 615
616 netif_napi_add(NULL, &mal->napi, mal_poll, 616 init_dummy_netdev(&mal->dummy_dev);
617
618 netif_napi_add(&mal->dummy_dev, &mal->napi, mal_poll,
617 CONFIG_IBM_NEW_EMAC_POLL_WEIGHT); 619 CONFIG_IBM_NEW_EMAC_POLL_WEIGHT);
618 620
619 /* Load power-on reset defaults */ 621 /* Load power-on reset defaults */
diff --git a/drivers/net/ibm_newemac/mal.h b/drivers/net/ibm_newemac/mal.h
index 2f0a87360844..9ededfbf0726 100644
--- a/drivers/net/ibm_newemac/mal.h
+++ b/drivers/net/ibm_newemac/mal.h
@@ -214,6 +214,8 @@ struct mal_instance {
214 int index; 214 int index;
215 spinlock_t lock; 215 spinlock_t lock;
216 216
217 struct net_device dummy_dev;
218
217 unsigned int features; 219 unsigned int features;
218}; 220};
219 221
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index 9bc0f178f24b..dfa6348ac1dc 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -602,7 +602,7 @@ static int ibmveth_open(struct net_device *netdev)
602 602
603 if(lpar_rc != H_SUCCESS) { 603 if(lpar_rc != H_SUCCESS) {
604 ibmveth_error_printk("h_register_logical_lan failed with %ld\n", lpar_rc); 604 ibmveth_error_printk("h_register_logical_lan failed with %ld\n", lpar_rc);
605 ibmveth_error_printk("buffer TCE:0x%lx filter TCE:0x%lx rxq desc:0x%lx MAC:0x%lx\n", 605 ibmveth_error_printk("buffer TCE:0x%llx filter TCE:0x%llx rxq desc:0x%llx MAC:0x%llx\n",
606 adapter->buffer_list_dma, 606 adapter->buffer_list_dma,
607 adapter->filter_list_dma, 607 adapter->filter_list_dma,
608 rxq_desc.desc, 608 rxq_desc.desc,
@@ -754,7 +754,7 @@ static int ibmveth_set_csum_offload(struct net_device *dev, u32 data,
754 void (*done) (struct net_device *, u32)) 754 void (*done) (struct net_device *, u32))
755{ 755{
756 struct ibmveth_adapter *adapter = netdev_priv(dev); 756 struct ibmveth_adapter *adapter = netdev_priv(dev);
757 u64 set_attr, clr_attr, ret_attr; 757 unsigned long set_attr, clr_attr, ret_attr;
758 long ret; 758 long ret;
759 int rc1 = 0, rc2 = 0; 759 int rc1 = 0, rc2 = 0;
760 int restart = 0; 760 int restart = 0;
@@ -1209,7 +1209,7 @@ static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_
1209 long ret; 1209 long ret;
1210 struct net_device *netdev; 1210 struct net_device *netdev;
1211 struct ibmveth_adapter *adapter; 1211 struct ibmveth_adapter *adapter;
1212 u64 set_attr, ret_attr; 1212 unsigned long set_attr, ret_attr;
1213 1213
1214 unsigned char *mac_addr_p; 1214 unsigned char *mac_addr_p;
1215 unsigned int *mcastFilterSize_p; 1215 unsigned int *mcastFilterSize_p;
@@ -1378,13 +1378,13 @@ static int ibmveth_show(struct seq_file *seq, void *v)
1378 seq_printf(seq, "Firmware MAC: %pM\n", firmware_mac); 1378 seq_printf(seq, "Firmware MAC: %pM\n", firmware_mac);
1379 1379
1380 seq_printf(seq, "\nAdapter Statistics:\n"); 1380 seq_printf(seq, "\nAdapter Statistics:\n");
1381 seq_printf(seq, " TX: vio_map_single failres: %ld\n", adapter->tx_map_failed); 1381 seq_printf(seq, " TX: vio_map_single failres: %lld\n", adapter->tx_map_failed);
1382 seq_printf(seq, " send failures: %ld\n", adapter->tx_send_failed); 1382 seq_printf(seq, " send failures: %lld\n", adapter->tx_send_failed);
1383 seq_printf(seq, " RX: replenish task cycles: %ld\n", adapter->replenish_task_cycles); 1383 seq_printf(seq, " RX: replenish task cycles: %lld\n", adapter->replenish_task_cycles);
1384 seq_printf(seq, " alloc_skb_failures: %ld\n", adapter->replenish_no_mem); 1384 seq_printf(seq, " alloc_skb_failures: %lld\n", adapter->replenish_no_mem);
1385 seq_printf(seq, " add buffer failures: %ld\n", adapter->replenish_add_buff_failure); 1385 seq_printf(seq, " add buffer failures: %lld\n", adapter->replenish_add_buff_failure);
1386 seq_printf(seq, " invalid buffers: %ld\n", adapter->rx_invalid_buffer); 1386 seq_printf(seq, " invalid buffers: %lld\n", adapter->rx_invalid_buffer);
1387 seq_printf(seq, " no buffers: %ld\n", adapter->rx_no_buffer); 1387 seq_printf(seq, " no buffers: %lld\n", adapter->rx_no_buffer);
1388 1388
1389 return 0; 1389 return 0;
1390} 1390}
diff --git a/drivers/net/ibmveth.h b/drivers/net/ibmveth.h
index d28186948752..ec76ace66c6b 100644
--- a/drivers/net/ibmveth.h
+++ b/drivers/net/ibmveth.h
@@ -39,11 +39,11 @@
39#define IbmVethMcastRemoveFilter 0x2UL 39#define IbmVethMcastRemoveFilter 0x2UL
40#define IbmVethMcastClearFilterTable 0x3UL 40#define IbmVethMcastClearFilterTable 0x3UL
41 41
42#define IBMVETH_ILLAN_PADDED_PKT_CSUM 0x0000000000002000ULL 42#define IBMVETH_ILLAN_PADDED_PKT_CSUM 0x0000000000002000UL
43#define IBMVETH_ILLAN_TRUNK_PRI_MASK 0x0000000000000F00ULL 43#define IBMVETH_ILLAN_TRUNK_PRI_MASK 0x0000000000000F00UL
44#define IBMVETH_ILLAN_IPV6_TCP_CSUM 0x0000000000000004ULL 44#define IBMVETH_ILLAN_IPV6_TCP_CSUM 0x0000000000000004UL
45#define IBMVETH_ILLAN_IPV4_TCP_CSUM 0x0000000000000002ULL 45#define IBMVETH_ILLAN_IPV4_TCP_CSUM 0x0000000000000002UL
46#define IBMVETH_ILLAN_ACTIVE_TRUNK 0x0000000000000001ULL 46#define IBMVETH_ILLAN_ACTIVE_TRUNK 0x0000000000000001UL
47 47
48/* hcall macros */ 48/* hcall macros */
49#define h_register_logical_lan(ua, buflst, rxq, fltlst, mac) \ 49#define h_register_logical_lan(ua, buflst, rxq, fltlst, mac) \
diff --git a/drivers/net/ipg.c b/drivers/net/ipg.c
index 7b6d435a8468..360aa5e35fda 100644
--- a/drivers/net/ipg.c
+++ b/drivers/net/ipg.c
@@ -2210,6 +2210,19 @@ static void __devexit ipg_remove(struct pci_dev *pdev)
2210 pci_set_drvdata(pdev, NULL); 2210 pci_set_drvdata(pdev, NULL);
2211} 2211}
2212 2212
2213static const struct net_device_ops ipg_netdev_ops = {
2214 .ndo_open = ipg_nic_open,
2215 .ndo_stop = ipg_nic_stop,
2216 .ndo_start_xmit = ipg_nic_hard_start_xmit,
2217 .ndo_get_stats = ipg_nic_get_stats,
2218 .ndo_set_multicast_list = ipg_nic_set_multicast_list,
2219 .ndo_do_ioctl = ipg_ioctl,
2220 .ndo_tx_timeout = ipg_tx_timeout,
2221 .ndo_change_mtu = ipg_nic_change_mtu,
2222 .ndo_set_mac_address = eth_mac_addr,
2223 .ndo_validate_addr = eth_validate_addr,
2224};
2225
2213static int __devinit ipg_probe(struct pci_dev *pdev, 2226static int __devinit ipg_probe(struct pci_dev *pdev,
2214 const struct pci_device_id *id) 2227 const struct pci_device_id *id)
2215{ 2228{
@@ -2258,15 +2271,7 @@ static int __devinit ipg_probe(struct pci_dev *pdev,
2258 2271
2259 /* Declare IPG NIC functions for Ethernet device methods. 2272 /* Declare IPG NIC functions for Ethernet device methods.
2260 */ 2273 */
2261 dev->open = &ipg_nic_open; 2274 dev->netdev_ops = &ipg_netdev_ops;
2262 dev->stop = &ipg_nic_stop;
2263 dev->hard_start_xmit = &ipg_nic_hard_start_xmit;
2264 dev->get_stats = &ipg_nic_get_stats;
2265 dev->set_multicast_list = &ipg_nic_set_multicast_list;
2266 dev->do_ioctl = ipg_ioctl;
2267 dev->tx_timeout = ipg_tx_timeout;
2268 dev->change_mtu = &ipg_nic_change_mtu;
2269
2270 SET_NETDEV_DEV(dev, &pdev->dev); 2275 SET_NETDEV_DEV(dev, &pdev->dev);
2271 SET_ETHTOOL_OPS(dev, &ipg_ethtool_ops); 2276 SET_ETHTOOL_OPS(dev, &ipg_ethtool_ops);
2272 2277
diff --git a/drivers/net/irda/ali-ircc.c b/drivers/net/irda/ali-ircc.c
index 3c58e67ef1e4..17779f9bffc4 100644
--- a/drivers/net/irda/ali-ircc.c
+++ b/drivers/net/irda/ali-ircc.c
@@ -109,7 +109,6 @@ static int ali_ircc_net_open(struct net_device *dev);
109static int ali_ircc_net_close(struct net_device *dev); 109static int ali_ircc_net_close(struct net_device *dev);
110static int ali_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 110static int ali_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
111static void ali_ircc_change_speed(struct ali_ircc_cb *self, __u32 baud); 111static void ali_ircc_change_speed(struct ali_ircc_cb *self, __u32 baud);
112static struct net_device_stats *ali_ircc_net_get_stats(struct net_device *dev);
113 112
114/* SIR function */ 113/* SIR function */
115static int ali_ircc_sir_hard_xmit(struct sk_buff *skb, struct net_device *dev); 114static int ali_ircc_sir_hard_xmit(struct sk_buff *skb, struct net_device *dev);
@@ -366,7 +365,6 @@ static int ali_ircc_open(int i, chipio_t *info)
366 dev->open = ali_ircc_net_open; 365 dev->open = ali_ircc_net_open;
367 dev->stop = ali_ircc_net_close; 366 dev->stop = ali_ircc_net_close;
368 dev->do_ioctl = ali_ircc_net_ioctl; 367 dev->do_ioctl = ali_ircc_net_ioctl;
369 dev->get_stats = ali_ircc_net_get_stats;
370 368
371 err = register_netdev(dev); 369 err = register_netdev(dev);
372 if (err) { 370 if (err) {
@@ -876,7 +874,7 @@ static void ali_ircc_sir_receive(struct ali_ircc_cb *self)
876 * async_unwrap_char will deliver all found frames 874 * async_unwrap_char will deliver all found frames
877 */ 875 */
878 do { 876 do {
879 async_unwrap_char(self->netdev, &self->stats, &self->rx_buff, 877 async_unwrap_char(self->netdev, &self->netdev->stats, &self->rx_buff,
880 inb(iobase+UART_RX)); 878 inb(iobase+UART_RX));
881 879
882 /* Make sure we don't stay here too long */ 880 /* Make sure we don't stay here too long */
@@ -943,7 +941,7 @@ static void ali_ircc_sir_write_wakeup(struct ali_ircc_cb *self)
943 netif_wake_queue(self->netdev); 941 netif_wake_queue(self->netdev);
944 } 942 }
945 943
946 self->stats.tx_packets++; 944 self->netdev->stats.tx_packets++;
947 945
948 /* Turn on receive interrupts */ 946 /* Turn on receive interrupts */
949 outb(UART_IER_RDI, iobase+UART_IER); 947 outb(UART_IER_RDI, iobase+UART_IER);
@@ -1467,7 +1465,7 @@ static int ali_ircc_fir_hard_xmit(struct sk_buff *skb, struct net_device *dev)
1467 self->tx_fifo.queue[self->tx_fifo.free].len = skb->len; 1465 self->tx_fifo.queue[self->tx_fifo.free].len = skb->len;
1468 self->tx_fifo.tail += skb->len; 1466 self->tx_fifo.tail += skb->len;
1469 1467
1470 self->stats.tx_bytes += skb->len; 1468 dev->stats.tx_bytes += skb->len;
1471 1469
1472 skb_copy_from_linear_data(skb, self->tx_fifo.queue[self->tx_fifo.free].start, 1470 skb_copy_from_linear_data(skb, self->tx_fifo.queue[self->tx_fifo.free].start,
1473 skb->len); 1471 skb->len);
@@ -1661,12 +1659,12 @@ static int ali_ircc_dma_xmit_complete(struct ali_ircc_cb *self)
1661 1659
1662 { 1660 {
1663 IRDA_ERROR("%s(), ********* LSR_FRAME_ABORT *********\n", __func__); 1661 IRDA_ERROR("%s(), ********* LSR_FRAME_ABORT *********\n", __func__);
1664 self->stats.tx_errors++; 1662 self->netdev->stats.tx_errors++;
1665 self->stats.tx_fifo_errors++; 1663 self->netdev->stats.tx_fifo_errors++;
1666 } 1664 }
1667 else 1665 else
1668 { 1666 {
1669 self->stats.tx_packets++; 1667 self->netdev->stats.tx_packets++;
1670 } 1668 }
1671 1669
1672 /* Check if we need to change the speed */ 1670 /* Check if we need to change the speed */
@@ -1831,35 +1829,35 @@ static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self)
1831 IRDA_DEBUG(0,"%s(), ************* RX Errors ************ \n", __func__ ); 1829 IRDA_DEBUG(0,"%s(), ************* RX Errors ************ \n", __func__ );
1832 1830
1833 /* Skip frame */ 1831 /* Skip frame */
1834 self->stats.rx_errors++; 1832 self->netdev->stats.rx_errors++;
1835 1833
1836 self->rx_buff.data += len; 1834 self->rx_buff.data += len;
1837 1835
1838 if (status & LSR_FIFO_UR) 1836 if (status & LSR_FIFO_UR)
1839 { 1837 {
1840 self->stats.rx_frame_errors++; 1838 self->netdev->stats.rx_frame_errors++;
1841 IRDA_DEBUG(0,"%s(), ************* FIFO Errors ************ \n", __func__ ); 1839 IRDA_DEBUG(0,"%s(), ************* FIFO Errors ************ \n", __func__ );
1842 } 1840 }
1843 if (status & LSR_FRAME_ERROR) 1841 if (status & LSR_FRAME_ERROR)
1844 { 1842 {
1845 self->stats.rx_frame_errors++; 1843 self->netdev->stats.rx_frame_errors++;
1846 IRDA_DEBUG(0,"%s(), ************* FRAME Errors ************ \n", __func__ ); 1844 IRDA_DEBUG(0,"%s(), ************* FRAME Errors ************ \n", __func__ );
1847 } 1845 }
1848 1846
1849 if (status & LSR_CRC_ERROR) 1847 if (status & LSR_CRC_ERROR)
1850 { 1848 {
1851 self->stats.rx_crc_errors++; 1849 self->netdev->stats.rx_crc_errors++;
1852 IRDA_DEBUG(0,"%s(), ************* CRC Errors ************ \n", __func__ ); 1850 IRDA_DEBUG(0,"%s(), ************* CRC Errors ************ \n", __func__ );
1853 } 1851 }
1854 1852
1855 if(self->rcvFramesOverflow) 1853 if(self->rcvFramesOverflow)
1856 { 1854 {
1857 self->stats.rx_frame_errors++; 1855 self->netdev->stats.rx_frame_errors++;
1858 IRDA_DEBUG(0,"%s(), ************* Overran DMA buffer ************ \n", __func__ ); 1856 IRDA_DEBUG(0,"%s(), ************* Overran DMA buffer ************ \n", __func__ );
1859 } 1857 }
1860 if(len == 0) 1858 if(len == 0)
1861 { 1859 {
1862 self->stats.rx_frame_errors++; 1860 self->netdev->stats.rx_frame_errors++;
1863 IRDA_DEBUG(0,"%s(), ********** Receive Frame Size = 0 ********* \n", __func__ ); 1861 IRDA_DEBUG(0,"%s(), ********** Receive Frame Size = 0 ********* \n", __func__ );
1864 } 1862 }
1865 } 1863 }
@@ -1910,7 +1908,7 @@ static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self)
1910 IRDA_WARNING("%s(), memory squeeze, " 1908 IRDA_WARNING("%s(), memory squeeze, "
1911 "dropping frame.\n", 1909 "dropping frame.\n",
1912 __func__); 1910 __func__);
1913 self->stats.rx_dropped++; 1911 self->netdev->stats.rx_dropped++;
1914 1912
1915 return FALSE; 1913 return FALSE;
1916 } 1914 }
@@ -1924,8 +1922,8 @@ static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self)
1924 1922
1925 /* Move to next frame */ 1923 /* Move to next frame */
1926 self->rx_buff.data += len; 1924 self->rx_buff.data += len;
1927 self->stats.rx_bytes += len; 1925 self->netdev->stats.rx_bytes += len;
1928 self->stats.rx_packets++; 1926 self->netdev->stats.rx_packets++;
1929 1927
1930 skb->dev = self->netdev; 1928 skb->dev = self->netdev;
1931 skb_reset_mac_header(skb); 1929 skb_reset_mac_header(skb);
@@ -1994,7 +1992,7 @@ static int ali_ircc_sir_hard_xmit(struct sk_buff *skb, struct net_device *dev)
1994 self->tx_buff.len = async_wrap_skb(skb, self->tx_buff.data, 1992 self->tx_buff.len = async_wrap_skb(skb, self->tx_buff.data,
1995 self->tx_buff.truesize); 1993 self->tx_buff.truesize);
1996 1994
1997 self->stats.tx_bytes += self->tx_buff.len; 1995 self->netdev->stats.tx_bytes += self->tx_buff.len;
1998 1996
1999 /* Turn on transmit finished interrupt. Will fire immediately! */ 1997 /* Turn on transmit finished interrupt. Will fire immediately! */
2000 outb(UART_IER_THRI, iobase+UART_IER); 1998 outb(UART_IER_THRI, iobase+UART_IER);
@@ -2111,17 +2109,6 @@ static int ali_ircc_is_receiving(struct ali_ircc_cb *self)
2111 return status; 2109 return status;
2112} 2110}
2113 2111
2114static struct net_device_stats *ali_ircc_net_get_stats(struct net_device *dev)
2115{
2116 struct ali_ircc_cb *self = netdev_priv(dev);
2117
2118 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__ );
2119
2120 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ );
2121
2122 return &self->stats;
2123}
2124
2125static int ali_ircc_suspend(struct platform_device *dev, pm_message_t state) 2112static int ali_ircc_suspend(struct platform_device *dev, pm_message_t state)
2126{ 2113{
2127 struct ali_ircc_cb *self = platform_get_drvdata(dev); 2114 struct ali_ircc_cb *self = platform_get_drvdata(dev);
diff --git a/drivers/net/irda/ali-ircc.h b/drivers/net/irda/ali-ircc.h
index ed35d99763d5..0c8edb41bd0a 100644
--- a/drivers/net/irda/ali-ircc.h
+++ b/drivers/net/irda/ali-ircc.h
@@ -191,7 +191,6 @@ struct ali_ircc_cb {
191 struct tx_fifo tx_fifo; /* Info about frames to be transmitted */ 191 struct tx_fifo tx_fifo; /* Info about frames to be transmitted */
192 192
193 struct net_device *netdev; /* Yes! we are some kind of netdevice */ 193 struct net_device *netdev; /* Yes! we are some kind of netdevice */
194 struct net_device_stats stats;
195 194
196 struct irlap_cb *irlap; /* The link layer we are binded to */ 195 struct irlap_cb *irlap; /* The link layer we are binded to */
197 struct qos_info qos; /* QoS capabilities for this device */ 196 struct qos_info qos; /* QoS capabilities for this device */
diff --git a/drivers/net/irda/au1000_ircc.h b/drivers/net/irda/au1000_ircc.h
index b4763f24dded..c072c09a8d91 100644
--- a/drivers/net/irda/au1000_ircc.h
+++ b/drivers/net/irda/au1000_ircc.h
@@ -107,7 +107,6 @@ struct au1k_private {
107 iobuff_t rx_buff; 107 iobuff_t rx_buff;
108 108
109 struct net_device *netdev; 109 struct net_device *netdev;
110 struct net_device_stats stats;
111 110
112 struct timeval stamp; 111 struct timeval stamp;
113 struct timeval now; 112 struct timeval now;
diff --git a/drivers/net/irda/au1k_ir.c b/drivers/net/irda/au1k_ir.c
index 6c4b53ffbcac..941164076a2b 100644
--- a/drivers/net/irda/au1k_ir.c
+++ b/drivers/net/irda/au1k_ir.c
@@ -53,7 +53,6 @@ static int au1k_irda_hard_xmit(struct sk_buff *, struct net_device *);
53static int au1k_irda_rx(struct net_device *); 53static int au1k_irda_rx(struct net_device *);
54static void au1k_irda_interrupt(int, void *); 54static void au1k_irda_interrupt(int, void *);
55static void au1k_tx_timeout(struct net_device *); 55static void au1k_tx_timeout(struct net_device *);
56static struct net_device_stats *au1k_irda_stats(struct net_device *);
57static int au1k_irda_ioctl(struct net_device *, struct ifreq *, int); 56static int au1k_irda_ioctl(struct net_device *, struct ifreq *, int);
58static int au1k_irda_set_speed(struct net_device *dev, int speed); 57static int au1k_irda_set_speed(struct net_device *dev, int speed);
59 58
@@ -213,7 +212,6 @@ static int au1k_irda_net_init(struct net_device *dev)
213 dev->open = au1k_irda_start; 212 dev->open = au1k_irda_start;
214 dev->hard_start_xmit = au1k_irda_hard_xmit; 213 dev->hard_start_xmit = au1k_irda_hard_xmit;
215 dev->stop = au1k_irda_stop; 214 dev->stop = au1k_irda_stop;
216 dev->get_stats = au1k_irda_stats;
217 dev->do_ioctl = au1k_irda_ioctl; 215 dev->do_ioctl = au1k_irda_ioctl;
218 dev->tx_timeout = au1k_tx_timeout; 216 dev->tx_timeout = au1k_tx_timeout;
219 217
@@ -596,7 +594,7 @@ static int au1k_irda_rx(struct net_device *dev)
596 update_rx_stats(dev, flags, count); 594 update_rx_stats(dev, flags, count);
597 skb=alloc_skb(count+1,GFP_ATOMIC); 595 skb=alloc_skb(count+1,GFP_ATOMIC);
598 if (skb == NULL) { 596 if (skb == NULL) {
599 aup->stats.rx_dropped++; 597 aup->netdev->stats.rx_dropped++;
600 continue; 598 continue;
601 } 599 }
602 skb_reserve(skb, 1); 600 skb_reserve(skb, 1);
@@ -832,13 +830,6 @@ au1k_irda_ioctl(struct net_device *dev, struct ifreq *ifreq, int cmd)
832 return ret; 830 return ret;
833} 831}
834 832
835
836static struct net_device_stats *au1k_irda_stats(struct net_device *dev)
837{
838 struct au1k_private *aup = netdev_priv(dev);
839 return &aup->stats;
840}
841
842MODULE_AUTHOR("Pete Popov <ppopov@mvista.com>"); 833MODULE_AUTHOR("Pete Popov <ppopov@mvista.com>");
843MODULE_DESCRIPTION("Au1000 IrDA Device Driver"); 834MODULE_DESCRIPTION("Au1000 IrDA Device Driver");
844 835
diff --git a/drivers/net/irda/donauboe.c b/drivers/net/irda/donauboe.c
index 687c2d53d4d2..6f3e7f71658d 100644
--- a/drivers/net/irda/donauboe.c
+++ b/drivers/net/irda/donauboe.c
@@ -1194,13 +1194,13 @@ toshoboe_interrupt (int irq, void *dev_id)
1194 txp = txpc; 1194 txp = txpc;
1195 txpc++; 1195 txpc++;
1196 txpc %= TX_SLOTS; 1196 txpc %= TX_SLOTS;
1197 self->stats.tx_packets++; 1197 self->netdev->stats.tx_packets++;
1198 if (self->ring->tx[txpc].control & OBOE_CTL_TX_HW_OWNS) 1198 if (self->ring->tx[txpc].control & OBOE_CTL_TX_HW_OWNS)
1199 self->ring->tx[txp].control &= ~OBOE_CTL_TX_RTCENTX; 1199 self->ring->tx[txp].control &= ~OBOE_CTL_TX_RTCENTX;
1200 } 1200 }
1201 self->stats.tx_packets--; 1201 self->netdev->stats.tx_packets--;
1202#else 1202#else
1203 self->stats.tx_packets++; 1203 self->netdev->stats.tx_packets++;
1204#endif 1204#endif
1205 toshoboe_start_DMA(self, OBOE_CONFIG0H_ENTX); 1205 toshoboe_start_DMA(self, OBOE_CONFIG0H_ENTX);
1206 } 1206 }
@@ -1280,7 +1280,7 @@ dumpbufs(self->rx_bufs[self->rxs],len,'<');
1280 skb_put (skb, len); 1280 skb_put (skb, len);
1281 skb_copy_to_linear_data(skb, self->rx_bufs[self->rxs], 1281 skb_copy_to_linear_data(skb, self->rx_bufs[self->rxs],
1282 len); 1282 len);
1283 self->stats.rx_packets++; 1283 self->netdev->stats.rx_packets++;
1284 skb->dev = self->netdev; 1284 skb->dev = self->netdev;
1285 skb_reset_mac_header(skb); 1285 skb_reset_mac_header(skb);
1286 skb->protocol = htons (ETH_P_IRDA); 1286 skb->protocol = htons (ETH_P_IRDA);
diff --git a/drivers/net/irda/donauboe.h b/drivers/net/irda/donauboe.h
index 1e67720f1066..0dbd1932b72f 100644
--- a/drivers/net/irda/donauboe.h
+++ b/drivers/net/irda/donauboe.h
@@ -308,7 +308,6 @@ struct OboeRing
308struct toshoboe_cb 308struct toshoboe_cb
309{ 309{
310 struct net_device *netdev; /* Yes! we are some kind of netdevice */ 310 struct net_device *netdev; /* Yes! we are some kind of netdevice */
311 struct net_device_stats stats;
312 struct tty_driver ttydev; 311 struct tty_driver ttydev;
313 312
314 struct irlap_cb *irlap; /* The link layer we are binded to */ 313 struct irlap_cb *irlap; /* The link layer we are binded to */
diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c
index 205e4e825a97..3a22dc41b656 100644
--- a/drivers/net/irda/irda-usb.c
+++ b/drivers/net/irda/irda-usb.c
@@ -122,7 +122,6 @@ static int irda_usb_net_open(struct net_device *dev);
122static int irda_usb_net_close(struct net_device *dev); 122static int irda_usb_net_close(struct net_device *dev);
123static int irda_usb_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 123static int irda_usb_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
124static void irda_usb_net_timeout(struct net_device *dev); 124static void irda_usb_net_timeout(struct net_device *dev);
125static struct net_device_stats *irda_usb_net_get_stats(struct net_device *dev);
126 125
127/************************ TRANSMIT ROUTINES ************************/ 126/************************ TRANSMIT ROUTINES ************************/
128/* 127/*
@@ -525,13 +524,13 @@ static int irda_usb_hard_xmit(struct sk_buff *skb, struct net_device *netdev)
525 /* Ask USB to send the packet - Irq disabled -> GFP_ATOMIC */ 524 /* Ask USB to send the packet - Irq disabled -> GFP_ATOMIC */
526 if ((res = usb_submit_urb(urb, GFP_ATOMIC))) { 525 if ((res = usb_submit_urb(urb, GFP_ATOMIC))) {
527 IRDA_WARNING("%s(), failed Tx URB\n", __func__); 526 IRDA_WARNING("%s(), failed Tx URB\n", __func__);
528 self->stats.tx_errors++; 527 netdev->stats.tx_errors++;
529 /* Let USB recover : We will catch that in the watchdog */ 528 /* Let USB recover : We will catch that in the watchdog */
530 /*netif_start_queue(netdev);*/ 529 /*netif_start_queue(netdev);*/
531 } else { 530 } else {
532 /* Increment packet stats */ 531 /* Increment packet stats */
533 self->stats.tx_packets++; 532 netdev->stats.tx_packets++;
534 self->stats.tx_bytes += skb->len; 533 netdev->stats.tx_bytes += skb->len;
535 534
536 netdev->trans_start = jiffies; 535 netdev->trans_start = jiffies;
537 } 536 }
@@ -677,7 +676,7 @@ static void irda_usb_net_timeout(struct net_device *netdev)
677 IRDA_DEBUG(0, "%s: Tx timed out, urb->status=%d, urb->transfer_flags=0x%04X\n", netdev->name, urb->status, urb->transfer_flags); 676 IRDA_DEBUG(0, "%s: Tx timed out, urb->status=%d, urb->transfer_flags=0x%04X\n", netdev->name, urb->status, urb->transfer_flags);
678 677
679 /* Increase error count */ 678 /* Increase error count */
680 self->stats.tx_errors++; 679 netdev->stats.tx_errors++;
681 680
682#ifdef IU_BUG_KICK_TIMEOUT 681#ifdef IU_BUG_KICK_TIMEOUT
683 /* Can't be a bad idea to reset the speed ;-) - Jean II */ 682 /* Can't be a bad idea to reset the speed ;-) - Jean II */
@@ -826,7 +825,7 @@ static void irda_usb_receive(struct urb *urb)
826 if (urb->status != 0) { 825 if (urb->status != 0) {
827 switch (urb->status) { 826 switch (urb->status) {
828 case -EILSEQ: 827 case -EILSEQ:
829 self->stats.rx_crc_errors++; 828 self->netdev->stats.rx_crc_errors++;
830 /* Also precursor to a hot-unplug on UHCI. */ 829 /* Also precursor to a hot-unplug on UHCI. */
831 /* Fallthrough... */ 830 /* Fallthrough... */
832 case -ECONNRESET: 831 case -ECONNRESET:
@@ -839,7 +838,7 @@ static void irda_usb_receive(struct urb *urb)
839 case -ETIME: 838 case -ETIME:
840 /* Usually precursor to a hot-unplug on OHCI. */ 839 /* Usually precursor to a hot-unplug on OHCI. */
841 default: 840 default:
842 self->stats.rx_errors++; 841 self->netdev->stats.rx_errors++;
843 IRDA_DEBUG(0, "%s(), RX status %d, transfer_flags 0x%04X \n", __func__, urb->status, urb->transfer_flags); 842 IRDA_DEBUG(0, "%s(), RX status %d, transfer_flags 0x%04X \n", __func__, urb->status, urb->transfer_flags);
844 break; 843 break;
845 } 844 }
@@ -890,7 +889,7 @@ static void irda_usb_receive(struct urb *urb)
890 IRDA_SKB_MAX_MTU); 889 IRDA_SKB_MAX_MTU);
891 890
892 if (!newskb) { 891 if (!newskb) {
893 self->stats.rx_dropped++; 892 self->netdev->stats.rx_dropped++;
894 /* We could deliver the current skb, but this would stall 893 /* We could deliver the current skb, but this would stall
895 * the Rx path. Better drop the packet... Jean II */ 894 * the Rx path. Better drop the packet... Jean II */
896 goto done; 895 goto done;
@@ -927,8 +926,8 @@ static void irda_usb_receive(struct urb *urb)
927 netif_rx(dataskb); 926 netif_rx(dataskb);
928 927
929 /* Keep stats up to date */ 928 /* Keep stats up to date */
930 self->stats.rx_bytes += len; 929 self->netdev->stats.rx_bytes += len;
931 self->stats.rx_packets++; 930 self->netdev->stats.rx_packets++;
932 931
933done: 932done:
934 /* Note : at this point, the URB we've just received (urb) 933 /* Note : at this point, the URB we've just received (urb)
@@ -1074,7 +1073,7 @@ static int stir421x_patch_device(struct irda_usb_cb *self)
1074{ 1073{
1075 unsigned int i; 1074 unsigned int i;
1076 int ret; 1075 int ret;
1077 char stir421x_fw_name[11]; 1076 char stir421x_fw_name[12];
1078 const struct firmware *fw; 1077 const struct firmware *fw;
1079 const unsigned char *fw_version_ptr; /* pointer to version string */ 1078 const unsigned char *fw_version_ptr; /* pointer to version string */
1080 unsigned long fw_version = 0; 1079 unsigned long fw_version = 0;
@@ -1342,14 +1341,6 @@ static int irda_usb_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1342} 1341}
1343 1342
1344/*------------------------------------------------------------------*/ 1343/*------------------------------------------------------------------*/
1345/*
1346 * Get device stats (for /proc/net/dev and ifconfig)
1347 */
1348static struct net_device_stats *irda_usb_net_get_stats(struct net_device *dev)
1349{
1350 struct irda_usb_cb *self = netdev_priv(dev);
1351 return &self->stats;
1352}
1353 1344
1354/********************* IRDA CONFIG SUBROUTINES *********************/ 1345/********************* IRDA CONFIG SUBROUTINES *********************/
1355/* 1346/*
@@ -1428,7 +1419,6 @@ static inline int irda_usb_open(struct irda_usb_cb *self)
1428 netdev->watchdog_timeo = 250*HZ/1000; /* 250 ms > USB timeout */ 1419 netdev->watchdog_timeo = 250*HZ/1000; /* 250 ms > USB timeout */
1429 netdev->open = irda_usb_net_open; 1420 netdev->open = irda_usb_net_open;
1430 netdev->stop = irda_usb_net_close; 1421 netdev->stop = irda_usb_net_close;
1431 netdev->get_stats = irda_usb_net_get_stats;
1432 netdev->do_ioctl = irda_usb_net_ioctl; 1422 netdev->do_ioctl = irda_usb_net_ioctl;
1433 1423
1434 return register_netdev(netdev); 1424 return register_netdev(netdev);
diff --git a/drivers/net/irda/irda-usb.h b/drivers/net/irda/irda-usb.h
index a0ca9c1fe196..ac0443d52e50 100644
--- a/drivers/net/irda/irda-usb.h
+++ b/drivers/net/irda/irda-usb.h
@@ -152,7 +152,6 @@ struct irda_usb_cb {
152 struct urb *speed_urb; /* URB used to send speed commands */ 152 struct urb *speed_urb; /* URB used to send speed commands */
153 153
154 struct net_device *netdev; /* Yes! we are some kind of netdev. */ 154 struct net_device *netdev; /* Yes! we are some kind of netdev. */
155 struct net_device_stats stats;
156 struct irlap_cb *irlap; /* The link layer we are binded to */ 155 struct irlap_cb *irlap; /* The link layer we are binded to */
157 struct qos_info qos; 156 struct qos_info qos;
158 char *speed_buff; /* Buffer for speed changes */ 157 char *speed_buff; /* Buffer for speed changes */
diff --git a/drivers/net/irda/kingsun-sir.c b/drivers/net/irda/kingsun-sir.c
index c747c874d44d..b4a61717254a 100644
--- a/drivers/net/irda/kingsun-sir.c
+++ b/drivers/net/irda/kingsun-sir.c
@@ -105,7 +105,7 @@ struct kingsun_cb {
105 struct usb_device *usbdev; /* init: probe_irda */ 105 struct usb_device *usbdev; /* init: probe_irda */
106 struct net_device *netdev; /* network layer */ 106 struct net_device *netdev; /* network layer */
107 struct irlap_cb *irlap; /* The link layer we are binded to */ 107 struct irlap_cb *irlap; /* The link layer we are binded to */
108 struct net_device_stats stats; /* network statistics */ 108
109 struct qos_info qos; 109 struct qos_info qos;
110 110
111 __u8 *in_buf; /* receive buffer */ 111 __u8 *in_buf; /* receive buffer */
@@ -186,12 +186,12 @@ static int kingsun_hard_xmit(struct sk_buff *skb, struct net_device *netdev)
186 case -EPIPE: 186 case -EPIPE:
187 break; 187 break;
188 default: 188 default:
189 kingsun->stats.tx_errors++; 189 netdev->stats.tx_errors++;
190 netif_start_queue(netdev); 190 netif_start_queue(netdev);
191 } 191 }
192 } else { 192 } else {
193 kingsun->stats.tx_packets++; 193 netdev->stats.tx_packets++;
194 kingsun->stats.tx_bytes += skb->len; 194 netdev->stats.tx_bytes += skb->len;
195 } 195 }
196 196
197 dev_kfree_skb(skb); 197 dev_kfree_skb(skb);
@@ -232,7 +232,7 @@ static void kingsun_rcv_irq(struct urb *urb)
232 if (bytes[0] >= 1 && bytes[0] < kingsun->max_rx) { 232 if (bytes[0] >= 1 && bytes[0] < kingsun->max_rx) {
233 for (i = 1; i <= bytes[0]; i++) { 233 for (i = 1; i <= bytes[0]; i++) {
234 async_unwrap_char(kingsun->netdev, 234 async_unwrap_char(kingsun->netdev,
235 &kingsun->stats, 235 &kingsun->netdev->stats,
236 &kingsun->rx_buff, bytes[i]); 236 &kingsun->rx_buff, bytes[i]);
237 } 237 }
238 do_gettimeofday(&kingsun->rx_time); 238 do_gettimeofday(&kingsun->rx_time);
@@ -418,15 +418,6 @@ static int kingsun_net_ioctl(struct net_device *netdev, struct ifreq *rq,
418 return ret; 418 return ret;
419} 419}
420 420
421/*
422 * Get device stats (for /proc/net/dev and ifconfig)
423 */
424static struct net_device_stats *
425kingsun_net_get_stats(struct net_device *netdev)
426{
427 struct kingsun_cb *kingsun = netdev_priv(netdev);
428 return &kingsun->stats;
429}
430 421
431/* 422/*
432 * This routine is called by the USB subsystem for each new device 423 * This routine is called by the USB subsystem for each new device
@@ -532,7 +523,6 @@ static int kingsun_probe(struct usb_interface *intf,
532 net->hard_start_xmit = kingsun_hard_xmit; 523 net->hard_start_xmit = kingsun_hard_xmit;
533 net->open = kingsun_net_open; 524 net->open = kingsun_net_open;
534 net->stop = kingsun_net_close; 525 net->stop = kingsun_net_close;
535 net->get_stats = kingsun_net_get_stats;
536 net->do_ioctl = kingsun_net_ioctl; 526 net->do_ioctl = kingsun_net_ioctl;
537 527
538 ret = register_netdev(net); 528 ret = register_netdev(net);
diff --git a/drivers/net/irda/ks959-sir.c b/drivers/net/irda/ks959-sir.c
index 600d96f9cdb7..55322fb92cf1 100644
--- a/drivers/net/irda/ks959-sir.c
+++ b/drivers/net/irda/ks959-sir.c
@@ -174,7 +174,7 @@ struct ks959_cb {
174 struct usb_device *usbdev; /* init: probe_irda */ 174 struct usb_device *usbdev; /* init: probe_irda */
175 struct net_device *netdev; /* network layer */ 175 struct net_device *netdev; /* network layer */
176 struct irlap_cb *irlap; /* The link layer we are binded to */ 176 struct irlap_cb *irlap; /* The link layer we are binded to */
177 struct net_device_stats stats; /* network statistics */ 177
178 struct qos_info qos; 178 struct qos_info qos;
179 179
180 struct usb_ctrlrequest *tx_setuprequest; 180 struct usb_ctrlrequest *tx_setuprequest;
@@ -366,7 +366,7 @@ static void ks959_send_irq(struct urb *urb)
366 case -EPIPE: 366 case -EPIPE:
367 break; 367 break;
368 default: 368 default:
369 kingsun->stats.tx_errors++; 369 netdev->stats.tx_errors++;
370 netif_start_queue(netdev); 370 netif_start_queue(netdev);
371 } 371 }
372 } 372 }
@@ -416,12 +416,12 @@ static int ks959_hard_xmit(struct sk_buff *skb, struct net_device *netdev)
416 case -EPIPE: 416 case -EPIPE:
417 break; 417 break;
418 default: 418 default:
419 kingsun->stats.tx_errors++; 419 netdev->stats.tx_errors++;
420 netif_start_queue(netdev); 420 netif_start_queue(netdev);
421 } 421 }
422 } else { 422 } else {
423 kingsun->stats.tx_packets++; 423 netdev->stats.tx_packets++;
424 kingsun->stats.tx_bytes += skb->len; 424 netdev->stats.tx_bytes += skb->len;
425 425
426 } 426 }
427 427
@@ -469,7 +469,7 @@ static void ks959_rcv_irq(struct urb *urb)
469 */ 469 */
470 if (kingsun->rx_variable_xormask != 0) { 470 if (kingsun->rx_variable_xormask != 0) {
471 async_unwrap_char(kingsun->netdev, 471 async_unwrap_char(kingsun->netdev,
472 &kingsun->stats, 472 &kingsun->netdev->stats,
473 &kingsun->rx_unwrap_buff, 473 &kingsun->rx_unwrap_buff,
474 bytes[i]); 474 bytes[i]);
475 } 475 }
@@ -669,15 +669,6 @@ static int ks959_net_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
669} 669}
670 670
671/* 671/*
672 * Get device stats (for /proc/net/dev and ifconfig)
673 */
674static struct net_device_stats *ks959_net_get_stats(struct net_device *netdev)
675{
676 struct ks959_cb *kingsun = netdev_priv(netdev);
677 return &kingsun->stats;
678}
679
680/*
681 * This routine is called by the USB subsystem for each new device 672 * This routine is called by the USB subsystem for each new device
682 * in the system. We need to check if the device is ours, and in 673 * in the system. We need to check if the device is ours, and in
683 * this case start handling it. 674 * this case start handling it.
@@ -792,7 +783,6 @@ static int ks959_probe(struct usb_interface *intf,
792 net->hard_start_xmit = ks959_hard_xmit; 783 net->hard_start_xmit = ks959_hard_xmit;
793 net->open = ks959_net_open; 784 net->open = ks959_net_open;
794 net->stop = ks959_net_close; 785 net->stop = ks959_net_close;
795 net->get_stats = ks959_net_get_stats;
796 net->do_ioctl = ks959_net_ioctl; 786 net->do_ioctl = ks959_net_ioctl;
797 787
798 ret = register_netdev(net); 788 ret = register_netdev(net);
diff --git a/drivers/net/irda/ksdazzle-sir.c b/drivers/net/irda/ksdazzle-sir.c
index 0e7f89337b25..5b327b09acd8 100644
--- a/drivers/net/irda/ksdazzle-sir.c
+++ b/drivers/net/irda/ksdazzle-sir.c
@@ -140,7 +140,7 @@ struct ksdazzle_cb {
140 struct usb_device *usbdev; /* init: probe_irda */ 140 struct usb_device *usbdev; /* init: probe_irda */
141 struct net_device *netdev; /* network layer */ 141 struct net_device *netdev; /* network layer */
142 struct irlap_cb *irlap; /* The link layer we are binded to */ 142 struct irlap_cb *irlap; /* The link layer we are binded to */
143 struct net_device_stats stats; /* network statistics */ 143
144 struct qos_info qos; 144 struct qos_info qos;
145 145
146 struct urb *tx_urb; 146 struct urb *tx_urb;
@@ -278,7 +278,7 @@ static void ksdazzle_send_irq(struct urb *urb)
278 case -EPIPE: 278 case -EPIPE:
279 break; 279 break;
280 default: 280 default:
281 kingsun->stats.tx_errors++; 281 netdev->stats.tx_errors++;
282 netif_start_queue(netdev); 282 netif_start_queue(netdev);
283 } 283 }
284 } 284 }
@@ -329,12 +329,12 @@ static int ksdazzle_hard_xmit(struct sk_buff *skb, struct net_device *netdev)
329 case -EPIPE: 329 case -EPIPE:
330 break; 330 break;
331 default: 331 default:
332 kingsun->stats.tx_errors++; 332 netdev->stats.tx_errors++;
333 netif_start_queue(netdev); 333 netif_start_queue(netdev);
334 } 334 }
335 } else { 335 } else {
336 kingsun->stats.tx_packets++; 336 netdev->stats.tx_packets++;
337 kingsun->stats.tx_bytes += skb->len; 337 netdev->stats.tx_bytes += skb->len;
338 338
339 } 339 }
340 340
@@ -348,9 +348,10 @@ static int ksdazzle_hard_xmit(struct sk_buff *skb, struct net_device *netdev)
348static void ksdazzle_rcv_irq(struct urb *urb) 348static void ksdazzle_rcv_irq(struct urb *urb)
349{ 349{
350 struct ksdazzle_cb *kingsun = urb->context; 350 struct ksdazzle_cb *kingsun = urb->context;
351 struct net_device *netdev = kingsun->netdev;
351 352
352 /* in process of stopping, just drop data */ 353 /* in process of stopping, just drop data */
353 if (!netif_running(kingsun->netdev)) { 354 if (!netif_running(netdev)) {
354 kingsun->receiving = 0; 355 kingsun->receiving = 0;
355 return; 356 return;
356 } 357 }
@@ -368,7 +369,7 @@ static void ksdazzle_rcv_irq(struct urb *urb)
368 unsigned int i; 369 unsigned int i;
369 370
370 for (i = 0; i < urb->actual_length; i++) { 371 for (i = 0; i < urb->actual_length; i++) {
371 async_unwrap_char(kingsun->netdev, &kingsun->stats, 372 async_unwrap_char(netdev, &netdev->stats,
372 &kingsun->rx_unwrap_buff, bytes[i]); 373 &kingsun->rx_unwrap_buff, bytes[i]);
373 } 374 }
374 kingsun->receiving = 375 kingsun->receiving =
@@ -562,16 +563,6 @@ static int ksdazzle_net_ioctl(struct net_device *netdev, struct ifreq *rq,
562} 563}
563 564
564/* 565/*
565 * Get device stats (for /proc/net/dev and ifconfig)
566 */
567static struct net_device_stats *ksdazzle_net_get_stats(struct net_device
568 *netdev)
569{
570 struct ksdazzle_cb *kingsun = netdev_priv(netdev);
571 return &kingsun->stats;
572}
573
574/*
575 * This routine is called by the USB subsystem for each new device 566 * This routine is called by the USB subsystem for each new device
576 * in the system. We need to check if the device is ours, and in 567 * in the system. We need to check if the device is ours, and in
577 * this case start handling it. 568 * this case start handling it.
@@ -696,7 +687,6 @@ static int ksdazzle_probe(struct usb_interface *intf,
696 net->hard_start_xmit = ksdazzle_hard_xmit; 687 net->hard_start_xmit = ksdazzle_hard_xmit;
697 net->open = ksdazzle_net_open; 688 net->open = ksdazzle_net_open;
698 net->stop = ksdazzle_net_close; 689 net->stop = ksdazzle_net_close;
699 net->get_stats = ksdazzle_net_get_stats;
700 net->do_ioctl = ksdazzle_net_ioctl; 690 net->do_ioctl = ksdazzle_net_ioctl;
701 691
702 ret = register_netdev(net); 692 ret = register_netdev(net);
diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c
index 904c9610c0dd..7eafdca19f34 100644
--- a/drivers/net/irda/mcs7780.c
+++ b/drivers/net/irda/mcs7780.c
@@ -403,8 +403,8 @@ static void mcs_unwrap_mir(struct mcs_cb *mcs, __u8 *buf, int len)
403 if(unlikely(new_len <= 0)) { 403 if(unlikely(new_len <= 0)) {
404 IRDA_ERROR("%s short frame length %d\n", 404 IRDA_ERROR("%s short frame length %d\n",
405 mcs->netdev->name, new_len); 405 mcs->netdev->name, new_len);
406 ++mcs->stats.rx_errors; 406 ++mcs->netdev->stats.rx_errors;
407 ++mcs->stats.rx_length_errors; 407 ++mcs->netdev->stats.rx_length_errors;
408 return; 408 return;
409 } 409 }
410 fcs = 0; 410 fcs = 0;
@@ -413,14 +413,14 @@ static void mcs_unwrap_mir(struct mcs_cb *mcs, __u8 *buf, int len)
413 if(fcs != GOOD_FCS) { 413 if(fcs != GOOD_FCS) {
414 IRDA_ERROR("crc error calc 0x%x len %d\n", 414 IRDA_ERROR("crc error calc 0x%x len %d\n",
415 fcs, new_len); 415 fcs, new_len);
416 mcs->stats.rx_errors++; 416 mcs->netdev->stats.rx_errors++;
417 mcs->stats.rx_crc_errors++; 417 mcs->netdev->stats.rx_crc_errors++;
418 return; 418 return;
419 } 419 }
420 420
421 skb = dev_alloc_skb(new_len + 1); 421 skb = dev_alloc_skb(new_len + 1);
422 if(unlikely(!skb)) { 422 if(unlikely(!skb)) {
423 ++mcs->stats.rx_dropped; 423 ++mcs->netdev->stats.rx_dropped;
424 return; 424 return;
425 } 425 }
426 426
@@ -433,8 +433,8 @@ static void mcs_unwrap_mir(struct mcs_cb *mcs, __u8 *buf, int len)
433 433
434 netif_rx(skb); 434 netif_rx(skb);
435 435
436 mcs->stats.rx_packets++; 436 mcs->netdev->stats.rx_packets++;
437 mcs->stats.rx_bytes += new_len; 437 mcs->netdev->stats.rx_bytes += new_len;
438 438
439 return; 439 return;
440} 440}
@@ -458,22 +458,22 @@ static void mcs_unwrap_fir(struct mcs_cb *mcs, __u8 *buf, int len)
458 if(unlikely(new_len <= 0)) { 458 if(unlikely(new_len <= 0)) {
459 IRDA_ERROR("%s short frame length %d\n", 459 IRDA_ERROR("%s short frame length %d\n",
460 mcs->netdev->name, new_len); 460 mcs->netdev->name, new_len);
461 ++mcs->stats.rx_errors; 461 ++mcs->netdev->stats.rx_errors;
462 ++mcs->stats.rx_length_errors; 462 ++mcs->netdev->stats.rx_length_errors;
463 return; 463 return;
464 } 464 }
465 465
466 fcs = ~(crc32_le(~0, buf, new_len)); 466 fcs = ~(crc32_le(~0, buf, new_len));
467 if(fcs != get_unaligned_le32(buf + new_len)) { 467 if(fcs != get_unaligned_le32(buf + new_len)) {
468 IRDA_ERROR("crc error calc 0x%x len %d\n", fcs, new_len); 468 IRDA_ERROR("crc error calc 0x%x len %d\n", fcs, new_len);
469 mcs->stats.rx_errors++; 469 mcs->netdev->stats.rx_errors++;
470 mcs->stats.rx_crc_errors++; 470 mcs->netdev->stats.rx_crc_errors++;
471 return; 471 return;
472 } 472 }
473 473
474 skb = dev_alloc_skb(new_len + 1); 474 skb = dev_alloc_skb(new_len + 1);
475 if(unlikely(!skb)) { 475 if(unlikely(!skb)) {
476 ++mcs->stats.rx_dropped; 476 ++mcs->netdev->stats.rx_dropped;
477 return; 477 return;
478 } 478 }
479 479
@@ -486,8 +486,8 @@ static void mcs_unwrap_fir(struct mcs_cb *mcs, __u8 *buf, int len)
486 486
487 netif_rx(skb); 487 netif_rx(skb);
488 488
489 mcs->stats.rx_packets++; 489 mcs->netdev->stats.rx_packets++;
490 mcs->stats.rx_bytes += new_len; 490 mcs->netdev->stats.rx_bytes += new_len;
491 491
492 return; 492 return;
493} 493}
@@ -756,14 +756,6 @@ static int mcs_net_open(struct net_device *netdev)
756 return ret; 756 return ret;
757} 757}
758 758
759
760/* Get device stats for /proc/net/dev and ifconfig */
761static struct net_device_stats *mcs_net_get_stats(struct net_device *netdev)
762{
763 struct mcs_cb *mcs = netdev_priv(netdev);
764 return &mcs->stats;
765}
766
767/* Receive callback function. */ 759/* Receive callback function. */
768static void mcs_receive_irq(struct urb *urb) 760static void mcs_receive_irq(struct urb *urb)
769{ 761{
@@ -786,14 +778,14 @@ static void mcs_receive_irq(struct urb *urb)
786 */ 778 */
787 /* SIR speed */ 779 /* SIR speed */
788 if(mcs->speed < 576000) { 780 if(mcs->speed < 576000) {
789 async_unwrap_char(mcs->netdev, &mcs->stats, 781 async_unwrap_char(mcs->netdev, &mcs->netdev->stats,
790 &mcs->rx_buff, 0xc0); 782 &mcs->rx_buff, 0xc0);
791 783
792 for (i = 0; i < urb->actual_length; i++) 784 for (i = 0; i < urb->actual_length; i++)
793 async_unwrap_char(mcs->netdev, &mcs->stats, 785 async_unwrap_char(mcs->netdev, &mcs->netdev->stats,
794 &mcs->rx_buff, bytes[i]); 786 &mcs->rx_buff, bytes[i]);
795 787
796 async_unwrap_char(mcs->netdev, &mcs->stats, 788 async_unwrap_char(mcs->netdev, &mcs->netdev->stats,
797 &mcs->rx_buff, 0xc1); 789 &mcs->rx_buff, 0xc1);
798 } 790 }
799 /* MIR speed */ 791 /* MIR speed */
@@ -868,12 +860,12 @@ static int mcs_hard_xmit(struct sk_buff *skb, struct net_device *ndev)
868 case -EPIPE: 860 case -EPIPE:
869 break; 861 break;
870 default: 862 default:
871 mcs->stats.tx_errors++; 863 mcs->netdev->stats.tx_errors++;
872 netif_start_queue(ndev); 864 netif_start_queue(ndev);
873 } 865 }
874 } else { 866 } else {
875 mcs->stats.tx_packets++; 867 mcs->netdev->stats.tx_packets++;
876 mcs->stats.tx_bytes += skb->len; 868 mcs->netdev->stats.tx_bytes += skb->len;
877 } 869 }
878 870
879 dev_kfree_skb(skb); 871 dev_kfree_skb(skb);
@@ -931,7 +923,6 @@ static int mcs_probe(struct usb_interface *intf,
931 ndev->hard_start_xmit = mcs_hard_xmit; 923 ndev->hard_start_xmit = mcs_hard_xmit;
932 ndev->open = mcs_net_open; 924 ndev->open = mcs_net_open;
933 ndev->stop = mcs_net_close; 925 ndev->stop = mcs_net_close;
934 ndev->get_stats = mcs_net_get_stats;
935 ndev->do_ioctl = mcs_net_ioctl; 926 ndev->do_ioctl = mcs_net_ioctl;
936 927
937 if (!intf->cur_altsetting) 928 if (!intf->cur_altsetting)
diff --git a/drivers/net/irda/mcs7780.h b/drivers/net/irda/mcs7780.h
index b18148cee638..6bdc621e67c6 100644
--- a/drivers/net/irda/mcs7780.h
+++ b/drivers/net/irda/mcs7780.h
@@ -104,7 +104,6 @@ struct mcs_cb {
104 struct usb_device *usbdev; /* init: probe_irda */ 104 struct usb_device *usbdev; /* init: probe_irda */
105 struct net_device *netdev; /* network layer */ 105 struct net_device *netdev; /* network layer */
106 struct irlap_cb *irlap; /* The link layer we are binded to */ 106 struct irlap_cb *irlap; /* The link layer we are binded to */
107 struct net_device_stats stats; /* network statistics */
108 struct qos_info qos; 107 struct qos_info qos;
109 unsigned int speed; /* Current speed */ 108 unsigned int speed; /* Current speed */
110 unsigned int new_speed; /* new speed */ 109 unsigned int new_speed; /* new speed */
@@ -154,7 +153,6 @@ static int mcs_speed_change(struct mcs_cb *mcs);
154static int mcs_net_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd); 153static int mcs_net_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd);
155static int mcs_net_close(struct net_device *netdev); 154static int mcs_net_close(struct net_device *netdev);
156static int mcs_net_open(struct net_device *netdev); 155static int mcs_net_open(struct net_device *netdev);
157static struct net_device_stats *mcs_net_get_stats(struct net_device *netdev);
158 156
159static void mcs_receive_irq(struct urb *urb); 157static void mcs_receive_irq(struct urb *urb);
160static void mcs_send_irq(struct urb *urb); 158static void mcs_send_irq(struct urb *urb);
diff --git a/drivers/net/irda/nsc-ircc.c b/drivers/net/irda/nsc-ircc.c
index 2c6bf2d11bb1..61e509cb712a 100644
--- a/drivers/net/irda/nsc-ircc.c
+++ b/drivers/net/irda/nsc-ircc.c
@@ -185,7 +185,6 @@ static void nsc_ircc_init_dongle_interface (int iobase, int dongle_id);
185static int nsc_ircc_net_open(struct net_device *dev); 185static int nsc_ircc_net_open(struct net_device *dev);
186static int nsc_ircc_net_close(struct net_device *dev); 186static int nsc_ircc_net_close(struct net_device *dev);
187static int nsc_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 187static int nsc_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
188static struct net_device_stats *nsc_ircc_net_get_stats(struct net_device *dev);
189 188
190/* Globals */ 189/* Globals */
191static int pnp_registered; 190static int pnp_registered;
@@ -446,7 +445,6 @@ static int __init nsc_ircc_open(chipio_t *info)
446 dev->open = nsc_ircc_net_open; 445 dev->open = nsc_ircc_net_open;
447 dev->stop = nsc_ircc_net_close; 446 dev->stop = nsc_ircc_net_close;
448 dev->do_ioctl = nsc_ircc_net_ioctl; 447 dev->do_ioctl = nsc_ircc_net_ioctl;
449 dev->get_stats = nsc_ircc_net_get_stats;
450 448
451 err = register_netdev(dev); 449 err = register_netdev(dev);
452 if (err) { 450 if (err) {
@@ -1401,7 +1399,7 @@ static int nsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev)
1401 self->tx_buff.len = async_wrap_skb(skb, self->tx_buff.data, 1399 self->tx_buff.len = async_wrap_skb(skb, self->tx_buff.data,
1402 self->tx_buff.truesize); 1400 self->tx_buff.truesize);
1403 1401
1404 self->stats.tx_bytes += self->tx_buff.len; 1402 dev->stats.tx_bytes += self->tx_buff.len;
1405 1403
1406 /* Add interrupt on tx low level (will fire immediately) */ 1404 /* Add interrupt on tx low level (will fire immediately) */
1407 switch_bank(iobase, BANK0); 1405 switch_bank(iobase, BANK0);
@@ -1473,7 +1471,7 @@ static int nsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev)
1473 self->tx_fifo.queue[self->tx_fifo.free].len = skb->len; 1471 self->tx_fifo.queue[self->tx_fifo.free].len = skb->len;
1474 self->tx_fifo.tail += skb->len; 1472 self->tx_fifo.tail += skb->len;
1475 1473
1476 self->stats.tx_bytes += skb->len; 1474 dev->stats.tx_bytes += skb->len;
1477 1475
1478 skb_copy_from_linear_data(skb, self->tx_fifo.queue[self->tx_fifo.free].start, 1476 skb_copy_from_linear_data(skb, self->tx_fifo.queue[self->tx_fifo.free].start,
1479 skb->len); 1477 skb->len);
@@ -1652,13 +1650,13 @@ static int nsc_ircc_dma_xmit_complete(struct nsc_ircc_cb *self)
1652 1650
1653 /* Check for underrrun! */ 1651 /* Check for underrrun! */
1654 if (inb(iobase+ASCR) & ASCR_TXUR) { 1652 if (inb(iobase+ASCR) & ASCR_TXUR) {
1655 self->stats.tx_errors++; 1653 self->netdev->stats.tx_errors++;
1656 self->stats.tx_fifo_errors++; 1654 self->netdev->stats.tx_fifo_errors++;
1657 1655
1658 /* Clear bit, by writing 1 into it */ 1656 /* Clear bit, by writing 1 into it */
1659 outb(ASCR_TXUR, iobase+ASCR); 1657 outb(ASCR_TXUR, iobase+ASCR);
1660 } else { 1658 } else {
1661 self->stats.tx_packets++; 1659 self->netdev->stats.tx_packets++;
1662 } 1660 }
1663 1661
1664 /* Finished with this frame, so prepare for next */ 1662 /* Finished with this frame, so prepare for next */
@@ -1793,28 +1791,28 @@ static int nsc_ircc_dma_receive_complete(struct nsc_ircc_cb *self, int iobase)
1793 if (status & FRM_ST_ERR_MSK) { 1791 if (status & FRM_ST_ERR_MSK) {
1794 if (status & FRM_ST_LOST_FR) { 1792 if (status & FRM_ST_LOST_FR) {
1795 /* Add number of lost frames to stats */ 1793 /* Add number of lost frames to stats */
1796 self->stats.rx_errors += len; 1794 self->netdev->stats.rx_errors += len;
1797 } else { 1795 } else {
1798 /* Skip frame */ 1796 /* Skip frame */
1799 self->stats.rx_errors++; 1797 self->netdev->stats.rx_errors++;
1800 1798
1801 self->rx_buff.data += len; 1799 self->rx_buff.data += len;
1802 1800
1803 if (status & FRM_ST_MAX_LEN) 1801 if (status & FRM_ST_MAX_LEN)
1804 self->stats.rx_length_errors++; 1802 self->netdev->stats.rx_length_errors++;
1805 1803
1806 if (status & FRM_ST_PHY_ERR) 1804 if (status & FRM_ST_PHY_ERR)
1807 self->stats.rx_frame_errors++; 1805 self->netdev->stats.rx_frame_errors++;
1808 1806
1809 if (status & FRM_ST_BAD_CRC) 1807 if (status & FRM_ST_BAD_CRC)
1810 self->stats.rx_crc_errors++; 1808 self->netdev->stats.rx_crc_errors++;
1811 } 1809 }
1812 /* The errors below can be reported in both cases */ 1810 /* The errors below can be reported in both cases */
1813 if (status & FRM_ST_OVR1) 1811 if (status & FRM_ST_OVR1)
1814 self->stats.rx_fifo_errors++; 1812 self->netdev->stats.rx_fifo_errors++;
1815 1813
1816 if (status & FRM_ST_OVR2) 1814 if (status & FRM_ST_OVR2)
1817 self->stats.rx_fifo_errors++; 1815 self->netdev->stats.rx_fifo_errors++;
1818 } else { 1816 } else {
1819 /* 1817 /*
1820 * First we must make sure that the frame we 1818 * First we must make sure that the frame we
@@ -1863,7 +1861,7 @@ static int nsc_ircc_dma_receive_complete(struct nsc_ircc_cb *self, int iobase)
1863 IRDA_WARNING("%s(), memory squeeze, " 1861 IRDA_WARNING("%s(), memory squeeze, "
1864 "dropping frame.\n", 1862 "dropping frame.\n",
1865 __func__); 1863 __func__);
1866 self->stats.rx_dropped++; 1864 self->netdev->stats.rx_dropped++;
1867 1865
1868 /* Restore bank register */ 1866 /* Restore bank register */
1869 outb(bank, iobase+BSR); 1867 outb(bank, iobase+BSR);
@@ -1889,8 +1887,8 @@ static int nsc_ircc_dma_receive_complete(struct nsc_ircc_cb *self, int iobase)
1889 1887
1890 /* Move to next frame */ 1888 /* Move to next frame */
1891 self->rx_buff.data += len; 1889 self->rx_buff.data += len;
1892 self->stats.rx_bytes += len; 1890 self->netdev->stats.rx_bytes += len;
1893 self->stats.rx_packets++; 1891 self->netdev->stats.rx_packets++;
1894 1892
1895 skb->dev = self->netdev; 1893 skb->dev = self->netdev;
1896 skb_reset_mac_header(skb); 1894 skb_reset_mac_header(skb);
@@ -1920,8 +1918,8 @@ static void nsc_ircc_pio_receive(struct nsc_ircc_cb *self)
1920 /* Receive all characters in Rx FIFO */ 1918 /* Receive all characters in Rx FIFO */
1921 do { 1919 do {
1922 byte = inb(iobase+RXD); 1920 byte = inb(iobase+RXD);
1923 async_unwrap_char(self->netdev, &self->stats, &self->rx_buff, 1921 async_unwrap_char(self->netdev, &self->netdev->stats,
1924 byte); 1922 &self->rx_buff, byte);
1925 } while (inb(iobase+LSR) & LSR_RXDA); /* Data available */ 1923 } while (inb(iobase+LSR) & LSR_RXDA); /* Data available */
1926} 1924}
1927 1925
@@ -1952,7 +1950,7 @@ static void nsc_ircc_sir_interrupt(struct nsc_ircc_cb *self, int eir)
1952 self->ier = IER_TXLDL_IE; 1950 self->ier = IER_TXLDL_IE;
1953 else { 1951 else {
1954 1952
1955 self->stats.tx_packets++; 1953 self->netdev->stats.tx_packets++;
1956 netif_wake_queue(self->netdev); 1954 netif_wake_queue(self->netdev);
1957 self->ier = IER_TXEMP_IE; 1955 self->ier = IER_TXEMP_IE;
1958 } 1956 }
@@ -2307,13 +2305,6 @@ static int nsc_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2307 return ret; 2305 return ret;
2308} 2306}
2309 2307
2310static struct net_device_stats *nsc_ircc_net_get_stats(struct net_device *dev)
2311{
2312 struct nsc_ircc_cb *self = netdev_priv(dev);
2313
2314 return &self->stats;
2315}
2316
2317static int nsc_ircc_suspend(struct platform_device *dev, pm_message_t state) 2308static int nsc_ircc_suspend(struct platform_device *dev, pm_message_t state)
2318{ 2309{
2319 struct nsc_ircc_cb *self = platform_get_drvdata(dev); 2310 struct nsc_ircc_cb *self = platform_get_drvdata(dev);
diff --git a/drivers/net/irda/nsc-ircc.h b/drivers/net/irda/nsc-ircc.h
index 71cd3c5a0762..7ba7738759b9 100644
--- a/drivers/net/irda/nsc-ircc.h
+++ b/drivers/net/irda/nsc-ircc.h
@@ -251,7 +251,6 @@ struct nsc_ircc_cb {
251 struct tx_fifo tx_fifo; /* Info about frames to be transmitted */ 251 struct tx_fifo tx_fifo; /* Info about frames to be transmitted */
252 252
253 struct net_device *netdev; /* Yes! we are some kind of netdevice */ 253 struct net_device *netdev; /* Yes! we are some kind of netdevice */
254 struct net_device_stats stats;
255 254
256 struct irlap_cb *irlap; /* The link layer we are binded to */ 255 struct irlap_cb *irlap; /* The link layer we are binded to */
257 struct qos_info qos; /* QoS capabilities for this device */ 256 struct qos_info qos; /* QoS capabilities for this device */
diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c
index 004a9aab3a50..31794c2363ec 100644
--- a/drivers/net/irda/pxaficp_ir.c
+++ b/drivers/net/irda/pxaficp_ir.c
@@ -108,7 +108,6 @@ struct pxa_irda {
108 int txdma; 108 int txdma;
109 int rxdma; 109 int rxdma;
110 110
111 struct net_device_stats stats;
112 struct irlap_cb *irlap; 111 struct irlap_cb *irlap;
113 struct qos_info qos; 112 struct qos_info qos;
114 113
@@ -258,14 +257,15 @@ static irqreturn_t pxa_irda_sir_irq(int irq, void *dev_id)
258 data = STRBR; 257 data = STRBR;
259 if (lsr & (LSR_OE | LSR_PE | LSR_FE | LSR_BI)) { 258 if (lsr & (LSR_OE | LSR_PE | LSR_FE | LSR_BI)) {
260 printk(KERN_DEBUG "pxa_ir: sir receiving error\n"); 259 printk(KERN_DEBUG "pxa_ir: sir receiving error\n");
261 si->stats.rx_errors++; 260 dev->stats.rx_errors++;
262 if (lsr & LSR_FE) 261 if (lsr & LSR_FE)
263 si->stats.rx_frame_errors++; 262 dev->stats.rx_frame_errors++;
264 if (lsr & LSR_OE) 263 if (lsr & LSR_OE)
265 si->stats.rx_fifo_errors++; 264 dev->stats.rx_fifo_errors++;
266 } else { 265 } else {
267 si->stats.rx_bytes++; 266 dev->stats.rx_bytes++;
268 async_unwrap_char(dev, &si->stats, &si->rx_buff, data); 267 async_unwrap_char(dev, &dev->stats,
268 &si->rx_buff, data);
269 } 269 }
270 lsr = STLSR; 270 lsr = STLSR;
271 } 271 }
@@ -277,8 +277,8 @@ static irqreturn_t pxa_irda_sir_irq(int irq, void *dev_id)
277 277
278 case 0x0C: /* Character Timeout Indication */ 278 case 0x0C: /* Character Timeout Indication */
279 do { 279 do {
280 si->stats.rx_bytes++; 280 dev->stats.rx_bytes++;
281 async_unwrap_char(dev, &si->stats, &si->rx_buff, STRBR); 281 async_unwrap_char(dev, &dev->stats, &si->rx_buff, STRBR);
282 } while (STLSR & LSR_DR); 282 } while (STLSR & LSR_DR);
283 si->last_oscr = OSCR; 283 si->last_oscr = OSCR;
284 break; 284 break;
@@ -290,9 +290,8 @@ static irqreturn_t pxa_irda_sir_irq(int irq, void *dev_id)
290 } 290 }
291 291
292 if (si->tx_buff.len == 0) { 292 if (si->tx_buff.len == 0) {
293 si->stats.tx_packets++; 293 dev->stats.tx_packets++;
294 si->stats.tx_bytes += si->tx_buff.data - 294 dev->stats.tx_bytes += si->tx_buff.data - si->tx_buff.head;
295 si->tx_buff.head;
296 295
297 /* We need to ensure that the transmitter has finished. */ 296 /* We need to ensure that the transmitter has finished. */
298 while ((STLSR & LSR_TEMT) == 0) 297 while ((STLSR & LSR_TEMT) == 0)
@@ -343,10 +342,10 @@ static void pxa_irda_fir_dma_tx_irq(int channel, void *data)
343 DCSR(channel) = dcsr & ~DCSR_RUN; 342 DCSR(channel) = dcsr & ~DCSR_RUN;
344 343
345 if (dcsr & DCSR_ENDINTR) { 344 if (dcsr & DCSR_ENDINTR) {
346 si->stats.tx_packets++; 345 dev->stats.tx_packets++;
347 si->stats.tx_bytes += si->dma_tx_buff_len; 346 dev->stats.tx_bytes += si->dma_tx_buff_len;
348 } else { 347 } else {
349 si->stats.tx_errors++; 348 dev->stats.tx_errors++;
350 } 349 }
351 350
352 while (ICSR1 & ICSR1_TBY) 351 while (ICSR1 & ICSR1_TBY)
@@ -392,14 +391,14 @@ static void pxa_irda_fir_irq_eif(struct pxa_irda *si, struct net_device *dev, in
392 data = ICDR; 391 data = ICDR;
393 392
394 if (stat & (ICSR1_CRE | ICSR1_ROR)) { 393 if (stat & (ICSR1_CRE | ICSR1_ROR)) {
395 si->stats.rx_errors++; 394 dev->stats.rx_errors++;
396 if (stat & ICSR1_CRE) { 395 if (stat & ICSR1_CRE) {
397 printk(KERN_DEBUG "pxa_ir: fir receive CRC error\n"); 396 printk(KERN_DEBUG "pxa_ir: fir receive CRC error\n");
398 si->stats.rx_crc_errors++; 397 dev->stats.rx_crc_errors++;
399 } 398 }
400 if (stat & ICSR1_ROR) { 399 if (stat & ICSR1_ROR) {
401 printk(KERN_DEBUG "pxa_ir: fir receive overrun\n"); 400 printk(KERN_DEBUG "pxa_ir: fir receive overrun\n");
402 si->stats.rx_over_errors++; 401 dev->stats.rx_over_errors++;
403 } 402 }
404 } else { 403 } else {
405 si->dma_rx_buff[len++] = data; 404 si->dma_rx_buff[len++] = data;
@@ -415,14 +414,14 @@ static void pxa_irda_fir_irq_eif(struct pxa_irda *si, struct net_device *dev, in
415 414
416 if (icsr0 & ICSR0_FRE) { 415 if (icsr0 & ICSR0_FRE) {
417 printk(KERN_ERR "pxa_ir: dropping erroneous frame\n"); 416 printk(KERN_ERR "pxa_ir: dropping erroneous frame\n");
418 si->stats.rx_dropped++; 417 dev->stats.rx_dropped++;
419 return; 418 return;
420 } 419 }
421 420
422 skb = alloc_skb(len+1,GFP_ATOMIC); 421 skb = alloc_skb(len+1,GFP_ATOMIC);
423 if (!skb) { 422 if (!skb) {
424 printk(KERN_ERR "pxa_ir: fir out of memory for receive skb\n"); 423 printk(KERN_ERR "pxa_ir: fir out of memory for receive skb\n");
425 si->stats.rx_dropped++; 424 dev->stats.rx_dropped++;
426 return; 425 return;
427 } 426 }
428 427
@@ -437,8 +436,8 @@ static void pxa_irda_fir_irq_eif(struct pxa_irda *si, struct net_device *dev, in
437 skb->protocol = htons(ETH_P_IRDA); 436 skb->protocol = htons(ETH_P_IRDA);
438 netif_rx(skb); 437 netif_rx(skb);
439 438
440 si->stats.rx_packets++; 439 dev->stats.rx_packets++;
441 si->stats.rx_bytes += len; 440 dev->stats.rx_bytes += len;
442 } 441 }
443} 442}
444 443
@@ -457,10 +456,10 @@ static irqreturn_t pxa_irda_fir_irq(int irq, void *dev_id)
457 if (icsr0 & (ICSR0_FRE | ICSR0_RAB)) { 456 if (icsr0 & (ICSR0_FRE | ICSR0_RAB)) {
458 if (icsr0 & ICSR0_FRE) { 457 if (icsr0 & ICSR0_FRE) {
459 printk(KERN_DEBUG "pxa_ir: fir receive frame error\n"); 458 printk(KERN_DEBUG "pxa_ir: fir receive frame error\n");
460 si->stats.rx_frame_errors++; 459 dev->stats.rx_frame_errors++;
461 } else { 460 } else {
462 printk(KERN_DEBUG "pxa_ir: fir receive abort\n"); 461 printk(KERN_DEBUG "pxa_ir: fir receive abort\n");
463 si->stats.rx_errors++; 462 dev->stats.rx_errors++;
464 } 463 }
465 ICSR0 = icsr0 & (ICSR0_FRE | ICSR0_RAB); 464 ICSR0 = icsr0 & (ICSR0_FRE | ICSR0_RAB);
466 } 465 }
@@ -589,12 +588,6 @@ static int pxa_irda_ioctl(struct net_device *dev, struct ifreq *ifreq, int cmd)
589 return ret; 588 return ret;
590} 589}
591 590
592static struct net_device_stats *pxa_irda_stats(struct net_device *dev)
593{
594 struct pxa_irda *si = netdev_priv(dev);
595 return &si->stats;
596}
597
598static void pxa_irda_startup(struct pxa_irda *si) 591static void pxa_irda_startup(struct pxa_irda *si)
599{ 592{
600 /* Disable STUART interrupts */ 593 /* Disable STUART interrupts */
@@ -857,7 +850,6 @@ static int pxa_irda_probe(struct platform_device *pdev)
857 dev->open = pxa_irda_start; 850 dev->open = pxa_irda_start;
858 dev->stop = pxa_irda_stop; 851 dev->stop = pxa_irda_stop;
859 dev->do_ioctl = pxa_irda_ioctl; 852 dev->do_ioctl = pxa_irda_ioctl;
860 dev->get_stats = pxa_irda_stats;
861 853
862 irda_init_max_qos_capabilies(&si->qos); 854 irda_init_max_qos_capabilies(&si->qos);
863 855
diff --git a/drivers/net/irda/sa1100_ir.c b/drivers/net/irda/sa1100_ir.c
index d302bcf4c148..7a2b003954ca 100644
--- a/drivers/net/irda/sa1100_ir.c
+++ b/drivers/net/irda/sa1100_ir.c
@@ -60,7 +60,6 @@ struct sa1100_irda {
60 dma_regs_t *txdma; 60 dma_regs_t *txdma;
61 dma_regs_t *rxdma; 61 dma_regs_t *rxdma;
62 62
63 struct net_device_stats stats;
64 struct device *dev; 63 struct device *dev;
65 struct irda_platform_data *pdata; 64 struct irda_platform_data *pdata;
66 struct irlap_cb *irlap; 65 struct irlap_cb *irlap;
@@ -375,13 +374,13 @@ static void sa1100_irda_hpsir_irq(struct net_device *dev)
375 data = Ser2UTDR; 374 data = Ser2UTDR;
376 375
377 if (stat & (UTSR1_FRE | UTSR1_ROR)) { 376 if (stat & (UTSR1_FRE | UTSR1_ROR)) {
378 si->stats.rx_errors++; 377 dev->stats.rx_errors++;
379 if (stat & UTSR1_FRE) 378 if (stat & UTSR1_FRE)
380 si->stats.rx_frame_errors++; 379 dev->stats.rx_frame_errors++;
381 if (stat & UTSR1_ROR) 380 if (stat & UTSR1_ROR)
382 si->stats.rx_fifo_errors++; 381 dev->stats.rx_fifo_errors++;
383 } else 382 } else
384 async_unwrap_char(dev, &si->stats, &si->rx_buff, data); 383 async_unwrap_char(dev, &dev->stats, &si->rx_buff, data);
385 384
386 status = Ser2UTSR0; 385 status = Ser2UTSR0;
387 } 386 }
@@ -396,9 +395,9 @@ static void sa1100_irda_hpsir_irq(struct net_device *dev)
396 * There are at least 4 bytes in the FIFO. Read 3 bytes 395 * There are at least 4 bytes in the FIFO. Read 3 bytes
397 * and leave the rest to the block below. 396 * and leave the rest to the block below.
398 */ 397 */
399 async_unwrap_char(dev, &si->stats, &si->rx_buff, Ser2UTDR); 398 async_unwrap_char(dev, &dev->stats, &si->rx_buff, Ser2UTDR);
400 async_unwrap_char(dev, &si->stats, &si->rx_buff, Ser2UTDR); 399 async_unwrap_char(dev, &dev->stats, &si->rx_buff, Ser2UTDR);
401 async_unwrap_char(dev, &si->stats, &si->rx_buff, Ser2UTDR); 400 async_unwrap_char(dev, &dev->stats, &si->rx_buff, Ser2UTDR);
402 } 401 }
403 402
404 if (status & (UTSR0_RFS | UTSR0_RID)) { 403 if (status & (UTSR0_RFS | UTSR0_RID)) {
@@ -406,7 +405,7 @@ static void sa1100_irda_hpsir_irq(struct net_device *dev)
406 * Fifo contains more than 1 character. 405 * Fifo contains more than 1 character.
407 */ 406 */
408 do { 407 do {
409 async_unwrap_char(dev, &si->stats, &si->rx_buff, 408 async_unwrap_char(dev, &dev->stats, &si->rx_buff,
410 Ser2UTDR); 409 Ser2UTDR);
411 } while (Ser2UTSR1 & UTSR1_RNE); 410 } while (Ser2UTSR1 & UTSR1_RNE);
412 411
@@ -422,8 +421,8 @@ static void sa1100_irda_hpsir_irq(struct net_device *dev)
422 } while (Ser2UTSR1 & UTSR1_TNF && si->tx_buff.len); 421 } while (Ser2UTSR1 & UTSR1_TNF && si->tx_buff.len);
423 422
424 if (si->tx_buff.len == 0) { 423 if (si->tx_buff.len == 0) {
425 si->stats.tx_packets++; 424 dev->stats.tx_packets++;
426 si->stats.tx_bytes += si->tx_buff.data - 425 dev->stats.tx_bytes += si->tx_buff.data -
427 si->tx_buff.head; 426 si->tx_buff.head;
428 427
429 /* 428 /*
@@ -482,11 +481,11 @@ static void sa1100_irda_fir_error(struct sa1100_irda *si, struct net_device *dev
482 data = Ser2HSDR; 481 data = Ser2HSDR;
483 482
484 if (stat & (HSSR1_CRE | HSSR1_ROR)) { 483 if (stat & (HSSR1_CRE | HSSR1_ROR)) {
485 si->stats.rx_errors++; 484 dev->stats.rx_errors++;
486 if (stat & HSSR1_CRE) 485 if (stat & HSSR1_CRE)
487 si->stats.rx_crc_errors++; 486 dev->stats.rx_crc_errors++;
488 if (stat & HSSR1_ROR) 487 if (stat & HSSR1_ROR)
489 si->stats.rx_frame_errors++; 488 dev->stats.rx_frame_errors++;
490 } else 489 } else
491 skb->data[len++] = data; 490 skb->data[len++] = data;
492 491
@@ -505,8 +504,8 @@ static void sa1100_irda_fir_error(struct sa1100_irda *si, struct net_device *dev
505 skb->dev = dev; 504 skb->dev = dev;
506 skb_reset_mac_header(skb); 505 skb_reset_mac_header(skb);
507 skb->protocol = htons(ETH_P_IRDA); 506 skb->protocol = htons(ETH_P_IRDA);
508 si->stats.rx_packets++; 507 dev->stats.rx_packets++;
509 si->stats.rx_bytes += len; 508 dev->stats.rx_bytes += len;
510 509
511 /* 510 /*
512 * Before we pass the buffer up, allocate a new one. 511 * Before we pass the buffer up, allocate a new one.
@@ -545,10 +544,10 @@ static void sa1100_irda_fir_irq(struct net_device *dev)
545 * from the fifo. 544 * from the fifo.
546 */ 545 */
547 if (Ser2HSSR0 & (HSSR0_FRE | HSSR0_RAB)) { 546 if (Ser2HSSR0 & (HSSR0_FRE | HSSR0_RAB)) {
548 si->stats.rx_errors++; 547 dev->stats.rx_errors++;
549 548
550 if (Ser2HSSR0 & HSSR0_FRE) 549 if (Ser2HSSR0 & HSSR0_FRE)
551 si->stats.rx_frame_errors++; 550 dev->stats.rx_frame_errors++;
552 551
553 /* 552 /*
554 * Clear out the DMA... 553 * Clear out the DMA...
@@ -633,8 +632,8 @@ static void sa1100_irda_txdma_irq(void *id)
633 */ 632 */
634 if (skb) { 633 if (skb) {
635 dma_unmap_single(si->dev, si->txbuf_dma, skb->len, DMA_TO_DEVICE); 634 dma_unmap_single(si->dev, si->txbuf_dma, skb->len, DMA_TO_DEVICE);
636 si->stats.tx_packets ++; 635 dev->stats.tx_packets ++;
637 si->stats.tx_bytes += skb->len; 636 dev->stats.tx_bytes += skb->len;
638 dev_kfree_skb_irq(skb); 637 dev_kfree_skb_irq(skb);
639 } 638 }
640 639
@@ -762,12 +761,6 @@ sa1100_irda_ioctl(struct net_device *dev, struct ifreq *ifreq, int cmd)
762 return ret; 761 return ret;
763} 762}
764 763
765static struct net_device_stats *sa1100_irda_stats(struct net_device *dev)
766{
767 struct sa1100_irda *si = netdev_priv(dev);
768 return &si->stats;
769}
770
771static int sa1100_irda_start(struct net_device *dev) 764static int sa1100_irda_start(struct net_device *dev)
772{ 765{
773 struct sa1100_irda *si = netdev_priv(dev); 766 struct sa1100_irda *si = netdev_priv(dev);
@@ -924,7 +917,6 @@ static int sa1100_irda_probe(struct platform_device *pdev)
924 dev->open = sa1100_irda_start; 917 dev->open = sa1100_irda_start;
925 dev->stop = sa1100_irda_stop; 918 dev->stop = sa1100_irda_stop;
926 dev->do_ioctl = sa1100_irda_ioctl; 919 dev->do_ioctl = sa1100_irda_ioctl;
927 dev->get_stats = sa1100_irda_stats;
928 dev->irq = IRQ_Ser2ICP; 920 dev->irq = IRQ_Ser2ICP;
929 921
930 irda_init_max_qos_capabilies(&si->qos); 922 irda_init_max_qos_capabilies(&si->qos);
diff --git a/drivers/net/irda/sir-dev.h b/drivers/net/irda/sir-dev.h
index 2a57bc67ce35..6d5b1e2b1289 100644
--- a/drivers/net/irda/sir-dev.h
+++ b/drivers/net/irda/sir-dev.h
@@ -160,7 +160,6 @@ static inline int sirdev_schedule_mode(struct sir_dev *dev, int mode)
160 160
161struct sir_dev { 161struct sir_dev {
162 struct net_device *netdev; 162 struct net_device *netdev;
163 struct net_device_stats stats;
164 163
165 struct irlap_cb *irlap; 164 struct irlap_cb *irlap;
166 165
diff --git a/drivers/net/irda/sir_dev.c b/drivers/net/irda/sir_dev.c
index ceef040aa76d..5b5862499def 100644
--- a/drivers/net/irda/sir_dev.c
+++ b/drivers/net/irda/sir_dev.c
@@ -455,8 +455,8 @@ void sirdev_write_complete(struct sir_dev *dev)
455 if ((skb=dev->tx_skb) != NULL) { 455 if ((skb=dev->tx_skb) != NULL) {
456 dev->tx_skb = NULL; 456 dev->tx_skb = NULL;
457 dev_kfree_skb_any(skb); 457 dev_kfree_skb_any(skb);
458 dev->stats.tx_errors++; 458 dev->netdev->stats.tx_errors++;
459 dev->stats.tx_dropped++; 459 dev->netdev->stats.tx_dropped++;
460 } 460 }
461 dev->tx_buff.len = 0; 461 dev->tx_buff.len = 0;
462 } 462 }
@@ -493,8 +493,8 @@ void sirdev_write_complete(struct sir_dev *dev)
493 493
494 if ((skb=dev->tx_skb) != NULL) { 494 if ((skb=dev->tx_skb) != NULL) {
495 dev->tx_skb = NULL; 495 dev->tx_skb = NULL;
496 dev->stats.tx_packets++; 496 dev->netdev->stats.tx_packets++;
497 dev->stats.tx_bytes += skb->len; 497 dev->netdev->stats.tx_bytes += skb->len;
498 dev_kfree_skb_any(skb); 498 dev_kfree_skb_any(skb);
499 } 499 }
500 500
@@ -548,7 +548,7 @@ int sirdev_receive(struct sir_dev *dev, const unsigned char *cp, size_t count)
548 * just update stats and set media busy 548 * just update stats and set media busy
549 */ 549 */
550 irda_device_set_media_busy(dev->netdev, TRUE); 550 irda_device_set_media_busy(dev->netdev, TRUE);
551 dev->stats.rx_dropped++; 551 dev->netdev->stats.rx_dropped++;
552 IRDA_DEBUG(0, "%s; rx-drop: %zd\n", __func__, count); 552 IRDA_DEBUG(0, "%s; rx-drop: %zd\n", __func__, count);
553 return 0; 553 return 0;
554 } 554 }
@@ -557,7 +557,7 @@ int sirdev_receive(struct sir_dev *dev, const unsigned char *cp, size_t count)
557 if (likely(atomic_read(&dev->enable_rx))) { 557 if (likely(atomic_read(&dev->enable_rx))) {
558 while (count--) 558 while (count--)
559 /* Unwrap and destuff one byte */ 559 /* Unwrap and destuff one byte */
560 async_unwrap_char(dev->netdev, &dev->stats, 560 async_unwrap_char(dev->netdev, &dev->netdev->stats,
561 &dev->rx_buff, *cp++); 561 &dev->rx_buff, *cp++);
562 } else { 562 } else {
563 while (count--) { 563 while (count--) {
@@ -582,13 +582,6 @@ EXPORT_SYMBOL(sirdev_receive);
582 582
583/* callbacks from network layer */ 583/* callbacks from network layer */
584 584
585static struct net_device_stats *sirdev_get_stats(struct net_device *ndev)
586{
587 struct sir_dev *dev = netdev_priv(ndev);
588
589 return (dev) ? &dev->stats : NULL;
590}
591
592static int sirdev_hard_xmit(struct sk_buff *skb, struct net_device *ndev) 585static int sirdev_hard_xmit(struct sk_buff *skb, struct net_device *ndev)
593{ 586{
594 struct sir_dev *dev = netdev_priv(ndev); 587 struct sir_dev *dev = netdev_priv(ndev);
@@ -654,7 +647,7 @@ static int sirdev_hard_xmit(struct sk_buff *skb, struct net_device *ndev)
654 */ 647 */
655 atomic_set(&dev->enable_rx, 0); 648 atomic_set(&dev->enable_rx, 0);
656 if (unlikely(sirdev_is_receiving(dev))) 649 if (unlikely(sirdev_is_receiving(dev)))
657 dev->stats.collisions++; 650 dev->netdev->stats.collisions++;
658 651
659 actual = dev->drv->do_write(dev, dev->tx_buff.data, dev->tx_buff.len); 652 actual = dev->drv->do_write(dev, dev->tx_buff.data, dev->tx_buff.len);
660 653
@@ -669,8 +662,8 @@ static int sirdev_hard_xmit(struct sk_buff *skb, struct net_device *ndev)
669 IRDA_ERROR("%s: drv->do_write failed (%d)\n", 662 IRDA_ERROR("%s: drv->do_write failed (%d)\n",
670 __func__, actual); 663 __func__, actual);
671 dev_kfree_skb_any(skb); 664 dev_kfree_skb_any(skb);
672 dev->stats.tx_errors++; 665 dev->netdev->stats.tx_errors++;
673 dev->stats.tx_dropped++; 666 dev->netdev->stats.tx_dropped++;
674 netif_wake_queue(ndev); 667 netif_wake_queue(ndev);
675 } 668 }
676 spin_unlock_irqrestore(&dev->tx_lock, flags); 669 spin_unlock_irqrestore(&dev->tx_lock, flags);
@@ -918,7 +911,6 @@ struct sir_dev * sirdev_get_instance(const struct sir_driver *drv, const char *n
918 ndev->hard_start_xmit = sirdev_hard_xmit; 911 ndev->hard_start_xmit = sirdev_hard_xmit;
919 ndev->open = sirdev_open; 912 ndev->open = sirdev_open;
920 ndev->stop = sirdev_close; 913 ndev->stop = sirdev_close;
921 ndev->get_stats = sirdev_get_stats;
922 ndev->do_ioctl = sirdev_ioctl; 914 ndev->do_ioctl = sirdev_ioctl;
923 915
924 if (register_netdev(ndev)) { 916 if (register_netdev(ndev)) {
diff --git a/drivers/net/irda/smsc-ircc2.c b/drivers/net/irda/smsc-ircc2.c
index 5d09e157e15b..dd73cce10991 100644
--- a/drivers/net/irda/smsc-ircc2.c
+++ b/drivers/net/irda/smsc-ircc2.c
@@ -150,7 +150,6 @@ struct smsc_chip_address {
150/* Private data for each instance */ 150/* Private data for each instance */
151struct smsc_ircc_cb { 151struct smsc_ircc_cb {
152 struct net_device *netdev; /* Yes! we are some kind of netdevice */ 152 struct net_device *netdev; /* Yes! we are some kind of netdevice */
153 struct net_device_stats stats;
154 struct irlap_cb *irlap; /* The link layer we are binded to */ 153 struct irlap_cb *irlap; /* The link layer we are binded to */
155 154
156 chipio_t io; /* IrDA controller information */ 155 chipio_t io; /* IrDA controller information */
@@ -215,7 +214,6 @@ static int smsc_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cm
215#if SMSC_IRCC2_C_NET_TIMEOUT 214#if SMSC_IRCC2_C_NET_TIMEOUT
216static void smsc_ircc_timeout(struct net_device *dev); 215static void smsc_ircc_timeout(struct net_device *dev);
217#endif 216#endif
218static struct net_device_stats *smsc_ircc_net_get_stats(struct net_device *dev);
219static int smsc_ircc_is_receiving(struct smsc_ircc_cb *self); 217static int smsc_ircc_is_receiving(struct smsc_ircc_cb *self);
220static void smsc_ircc_probe_transceiver(struct smsc_ircc_cb *self); 218static void smsc_ircc_probe_transceiver(struct smsc_ircc_cb *self);
221static void smsc_ircc_set_transceiver_for_speed(struct smsc_ircc_cb *self, u32 speed); 219static void smsc_ircc_set_transceiver_for_speed(struct smsc_ircc_cb *self, u32 speed);
@@ -529,7 +527,6 @@ static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u
529 dev->open = smsc_ircc_net_open; 527 dev->open = smsc_ircc_net_open;
530 dev->stop = smsc_ircc_net_close; 528 dev->stop = smsc_ircc_net_close;
531 dev->do_ioctl = smsc_ircc_net_ioctl; 529 dev->do_ioctl = smsc_ircc_net_ioctl;
532 dev->get_stats = smsc_ircc_net_get_stats;
533 530
534 self = netdev_priv(dev); 531 self = netdev_priv(dev);
535 self->netdev = dev; 532 self->netdev = dev;
@@ -834,13 +831,6 @@ static int smsc_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd
834 return ret; 831 return ret;
835} 832}
836 833
837static struct net_device_stats *smsc_ircc_net_get_stats(struct net_device *dev)
838{
839 struct smsc_ircc_cb *self = netdev_priv(dev);
840
841 return &self->stats;
842}
843
844#if SMSC_IRCC2_C_NET_TIMEOUT 834#if SMSC_IRCC2_C_NET_TIMEOUT
845/* 835/*
846 * Function smsc_ircc_timeout (struct net_device *dev) 836 * Function smsc_ircc_timeout (struct net_device *dev)
@@ -920,7 +910,7 @@ static int smsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev)
920 self->tx_buff.len = async_wrap_skb(skb, self->tx_buff.data, 910 self->tx_buff.len = async_wrap_skb(skb, self->tx_buff.data,
921 self->tx_buff.truesize); 911 self->tx_buff.truesize);
922 912
923 self->stats.tx_bytes += self->tx_buff.len; 913 dev->stats.tx_bytes += self->tx_buff.len;
924 914
925 /* Turn on transmit finished interrupt. Will fire immediately! */ 915 /* Turn on transmit finished interrupt. Will fire immediately! */
926 outb(UART_IER_THRI, self->io.sir_base + UART_IER); 916 outb(UART_IER_THRI, self->io.sir_base + UART_IER);
@@ -1320,16 +1310,16 @@ static void smsc_ircc_dma_xmit_complete(struct smsc_ircc_cb *self)
1320 /* Check for underrun! */ 1310 /* Check for underrun! */
1321 register_bank(iobase, 0); 1311 register_bank(iobase, 0);
1322 if (inb(iobase + IRCC_LSR) & IRCC_LSR_UNDERRUN) { 1312 if (inb(iobase + IRCC_LSR) & IRCC_LSR_UNDERRUN) {
1323 self->stats.tx_errors++; 1313 self->netdev->stats.tx_errors++;
1324 self->stats.tx_fifo_errors++; 1314 self->netdev->stats.tx_fifo_errors++;
1325 1315
1326 /* Reset error condition */ 1316 /* Reset error condition */
1327 register_bank(iobase, 0); 1317 register_bank(iobase, 0);
1328 outb(IRCC_MASTER_ERROR_RESET, iobase + IRCC_MASTER); 1318 outb(IRCC_MASTER_ERROR_RESET, iobase + IRCC_MASTER);
1329 outb(0x00, iobase + IRCC_MASTER); 1319 outb(0x00, iobase + IRCC_MASTER);
1330 } else { 1320 } else {
1331 self->stats.tx_packets++; 1321 self->netdev->stats.tx_packets++;
1332 self->stats.tx_bytes += self->tx_buff.len; 1322 self->netdev->stats.tx_bytes += self->tx_buff.len;
1333 } 1323 }
1334 1324
1335 /* Check if it's time to change the speed */ 1325 /* Check if it's time to change the speed */
@@ -1429,15 +1419,15 @@ static void smsc_ircc_dma_receive_complete(struct smsc_ircc_cb *self)
1429 1419
1430 /* Look for errors */ 1420 /* Look for errors */
1431 if (lsr & (IRCC_LSR_FRAME_ERROR | IRCC_LSR_CRC_ERROR | IRCC_LSR_SIZE_ERROR)) { 1421 if (lsr & (IRCC_LSR_FRAME_ERROR | IRCC_LSR_CRC_ERROR | IRCC_LSR_SIZE_ERROR)) {
1432 self->stats.rx_errors++; 1422 self->netdev->stats.rx_errors++;
1433 if (lsr & IRCC_LSR_FRAME_ERROR) 1423 if (lsr & IRCC_LSR_FRAME_ERROR)
1434 self->stats.rx_frame_errors++; 1424 self->netdev->stats.rx_frame_errors++;
1435 if (lsr & IRCC_LSR_CRC_ERROR) 1425 if (lsr & IRCC_LSR_CRC_ERROR)
1436 self->stats.rx_crc_errors++; 1426 self->netdev->stats.rx_crc_errors++;
1437 if (lsr & IRCC_LSR_SIZE_ERROR) 1427 if (lsr & IRCC_LSR_SIZE_ERROR)
1438 self->stats.rx_length_errors++; 1428 self->netdev->stats.rx_length_errors++;
1439 if (lsr & (IRCC_LSR_UNDERRUN | IRCC_LSR_OVERRUN)) 1429 if (lsr & (IRCC_LSR_UNDERRUN | IRCC_LSR_OVERRUN))
1440 self->stats.rx_length_errors++; 1430 self->netdev->stats.rx_length_errors++;
1441 return; 1431 return;
1442 } 1432 }
1443 1433
@@ -1460,8 +1450,8 @@ static void smsc_ircc_dma_receive_complete(struct smsc_ircc_cb *self)
1460 skb_reserve(skb, 1); 1450 skb_reserve(skb, 1);
1461 1451
1462 memcpy(skb_put(skb, len), self->rx_buff.data, len); 1452 memcpy(skb_put(skb, len), self->rx_buff.data, len);
1463 self->stats.rx_packets++; 1453 self->netdev->stats.rx_packets++;
1464 self->stats.rx_bytes += len; 1454 self->netdev->stats.rx_bytes += len;
1465 1455
1466 skb->dev = self->netdev; 1456 skb->dev = self->netdev;
1467 skb_reset_mac_header(skb); 1457 skb_reset_mac_header(skb);
@@ -1489,7 +1479,7 @@ static void smsc_ircc_sir_receive(struct smsc_ircc_cb *self)
1489 * async_unwrap_char will deliver all found frames 1479 * async_unwrap_char will deliver all found frames
1490 */ 1480 */
1491 do { 1481 do {
1492 async_unwrap_char(self->netdev, &self->stats, &self->rx_buff, 1482 async_unwrap_char(self->netdev, &self->netdev->stats, &self->rx_buff,
1493 inb(iobase + UART_RX)); 1483 inb(iobase + UART_RX));
1494 1484
1495 /* Make sure we don't stay here to long */ 1485 /* Make sure we don't stay here to long */
@@ -1992,7 +1982,7 @@ static void smsc_ircc_sir_write_wakeup(struct smsc_ircc_cb *self)
1992 /* Tell network layer that we want more frames */ 1982 /* Tell network layer that we want more frames */
1993 netif_wake_queue(self->netdev); 1983 netif_wake_queue(self->netdev);
1994 } 1984 }
1995 self->stats.tx_packets++; 1985 self->netdev->stats.tx_packets++;
1996 1986
1997 if (self->io.speed <= 115200) { 1987 if (self->io.speed <= 115200) {
1998 /* 1988 /*
diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c
index ca4cd9266e55..8b1658c6c925 100644
--- a/drivers/net/irda/stir4200.c
+++ b/drivers/net/irda/stir4200.c
@@ -164,7 +164,7 @@ struct stir_cb {
164 struct usb_device *usbdev; /* init: probe_irda */ 164 struct usb_device *usbdev; /* init: probe_irda */
165 struct net_device *netdev; /* network layer */ 165 struct net_device *netdev; /* network layer */
166 struct irlap_cb *irlap; /* The link layer we are binded to */ 166 struct irlap_cb *irlap; /* The link layer we are binded to */
167 struct net_device_stats stats; /* network statistics */ 167
168 struct qos_info qos; 168 struct qos_info qos;
169 unsigned speed; /* Current speed */ 169 unsigned speed; /* Current speed */
170 170
@@ -323,16 +323,16 @@ static void fir_eof(struct stir_cb *stir)
323 pr_debug("%s: short frame len %d\n", 323 pr_debug("%s: short frame len %d\n",
324 stir->netdev->name, len); 324 stir->netdev->name, len);
325 325
326 ++stir->stats.rx_errors; 326 ++stir->netdev->stats.rx_errors;
327 ++stir->stats.rx_length_errors; 327 ++stir->netdev->stats.rx_length_errors;
328 return; 328 return;
329 } 329 }
330 330
331 fcs = ~(crc32_le(~0, rx_buff->data, len)); 331 fcs = ~(crc32_le(~0, rx_buff->data, len));
332 if (fcs != get_unaligned_le32(rx_buff->data + len)) { 332 if (fcs != get_unaligned_le32(rx_buff->data + len)) {
333 pr_debug("crc error calc 0x%x len %d\n", fcs, len); 333 pr_debug("crc error calc 0x%x len %d\n", fcs, len);
334 stir->stats.rx_errors++; 334 stir->netdev->stats.rx_errors++;
335 stir->stats.rx_crc_errors++; 335 stir->netdev->stats.rx_crc_errors++;
336 return; 336 return;
337 } 337 }
338 338
@@ -340,7 +340,7 @@ static void fir_eof(struct stir_cb *stir)
340 if (len < IRDA_RX_COPY_THRESHOLD) { 340 if (len < IRDA_RX_COPY_THRESHOLD) {
341 nskb = dev_alloc_skb(len + 1); 341 nskb = dev_alloc_skb(len + 1);
342 if (unlikely(!nskb)) { 342 if (unlikely(!nskb)) {
343 ++stir->stats.rx_dropped; 343 ++stir->netdev->stats.rx_dropped;
344 return; 344 return;
345 } 345 }
346 skb_reserve(nskb, 1); 346 skb_reserve(nskb, 1);
@@ -349,7 +349,7 @@ static void fir_eof(struct stir_cb *stir)
349 } else { 349 } else {
350 nskb = dev_alloc_skb(rx_buff->truesize); 350 nskb = dev_alloc_skb(rx_buff->truesize);
351 if (unlikely(!nskb)) { 351 if (unlikely(!nskb)) {
352 ++stir->stats.rx_dropped; 352 ++stir->netdev->stats.rx_dropped;
353 return; 353 return;
354 } 354 }
355 skb_reserve(nskb, 1); 355 skb_reserve(nskb, 1);
@@ -366,8 +366,8 @@ static void fir_eof(struct stir_cb *stir)
366 366
367 netif_rx(skb); 367 netif_rx(skb);
368 368
369 stir->stats.rx_packets++; 369 stir->netdev->stats.rx_packets++;
370 stir->stats.rx_bytes += len; 370 stir->netdev->stats.rx_bytes += len;
371 371
372 rx_buff->data = rx_buff->head; 372 rx_buff->data = rx_buff->head;
373 rx_buff->len = 0; 373 rx_buff->len = 0;
@@ -437,7 +437,7 @@ static void stir_fir_chars(struct stir_cb *stir,
437 if (unlikely(rx_buff->len >= rx_buff->truesize)) { 437 if (unlikely(rx_buff->len >= rx_buff->truesize)) {
438 pr_debug("%s: fir frame exceeds %d\n", 438 pr_debug("%s: fir frame exceeds %d\n",
439 stir->netdev->name, rx_buff->truesize); 439 stir->netdev->name, rx_buff->truesize);
440 ++stir->stats.rx_over_errors; 440 ++stir->netdev->stats.rx_over_errors;
441 goto error_recovery; 441 goto error_recovery;
442 } 442 }
443 443
@@ -445,10 +445,10 @@ static void stir_fir_chars(struct stir_cb *stir,
445 continue; 445 continue;
446 446
447 frame_error: 447 frame_error:
448 ++stir->stats.rx_frame_errors; 448 ++stir->netdev->stats.rx_frame_errors;
449 449
450 error_recovery: 450 error_recovery:
451 ++stir->stats.rx_errors; 451 ++stir->netdev->stats.rx_errors;
452 rx_buff->state = OUTSIDE_FRAME; 452 rx_buff->state = OUTSIDE_FRAME;
453 rx_buff->in_frame = FALSE; 453 rx_buff->in_frame = FALSE;
454 } 454 }
@@ -461,7 +461,7 @@ static void stir_sir_chars(struct stir_cb *stir,
461 int i; 461 int i;
462 462
463 for (i = 0; i < len; i++) 463 for (i = 0; i < len; i++)
464 async_unwrap_char(stir->netdev, &stir->stats, 464 async_unwrap_char(stir->netdev, &stir->netdev->stats,
465 &stir->rx_buff, bytes[i]); 465 &stir->rx_buff, bytes[i]);
466} 466}
467 467
@@ -692,7 +692,7 @@ static void receive_stop(struct stir_cb *stir)
692 usb_kill_urb(stir->rx_urb); 692 usb_kill_urb(stir->rx_urb);
693 693
694 if (stir->rx_buff.in_frame) 694 if (stir->rx_buff.in_frame)
695 stir->stats.collisions++; 695 stir->netdev->stats.collisions++;
696} 696}
697/* 697/*
698 * Wrap data in socket buffer and send it. 698 * Wrap data in socket buffer and send it.
@@ -718,15 +718,15 @@ static void stir_send(struct stir_cb *stir, struct sk_buff *skb)
718 if (!first_frame) 718 if (!first_frame)
719 fifo_txwait(stir, wraplen); 719 fifo_txwait(stir, wraplen);
720 720
721 stir->stats.tx_packets++; 721 stir->netdev->stats.tx_packets++;
722 stir->stats.tx_bytes += skb->len; 722 stir->netdev->stats.tx_bytes += skb->len;
723 stir->netdev->trans_start = jiffies; 723 stir->netdev->trans_start = jiffies;
724 pr_debug("send %d (%d)\n", skb->len, wraplen); 724 pr_debug("send %d (%d)\n", skb->len, wraplen);
725 725
726 if (usb_bulk_msg(stir->usbdev, usb_sndbulkpipe(stir->usbdev, 1), 726 if (usb_bulk_msg(stir->usbdev, usb_sndbulkpipe(stir->usbdev, 1),
727 stir->io_buf, wraplen, 727 stir->io_buf, wraplen,
728 NULL, TRANSMIT_TIMEOUT)) 728 NULL, TRANSMIT_TIMEOUT))
729 stir->stats.tx_errors++; 729 stir->netdev->stats.tx_errors++;
730} 730}
731 731
732/* 732/*
@@ -1008,15 +1008,6 @@ static int stir_net_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
1008} 1008}
1009 1009
1010/* 1010/*
1011 * Get device stats (for /proc/net/dev and ifconfig)
1012 */
1013static struct net_device_stats *stir_net_get_stats(struct net_device *netdev)
1014{
1015 struct stir_cb *stir = netdev_priv(netdev);
1016 return &stir->stats;
1017}
1018
1019/*
1020 * This routine is called by the USB subsystem for each new device 1011 * This routine is called by the USB subsystem for each new device
1021 * in the system. We need to check if the device is ours, and in 1012 * in the system. We need to check if the device is ours, and in
1022 * this case start handling it. 1013 * this case start handling it.
@@ -1066,7 +1057,6 @@ static int stir_probe(struct usb_interface *intf,
1066 net->hard_start_xmit = stir_hard_xmit; 1057 net->hard_start_xmit = stir_hard_xmit;
1067 net->open = stir_net_open; 1058 net->open = stir_net_open;
1068 net->stop = stir_net_close; 1059 net->stop = stir_net_close;
1069 net->get_stats = stir_net_get_stats;
1070 net->do_ioctl = stir_net_ioctl; 1060 net->do_ioctl = stir_net_ioctl;
1071 1061
1072 ret = register_netdev(net); 1062 ret = register_netdev(net);
diff --git a/drivers/net/irda/via-ircc.c b/drivers/net/irda/via-ircc.c
index 74c78cf7a333..8b3e545924cc 100644
--- a/drivers/net/irda/via-ircc.c
+++ b/drivers/net/irda/via-ircc.c
@@ -101,8 +101,6 @@ static int via_ircc_net_open(struct net_device *dev);
101static int via_ircc_net_close(struct net_device *dev); 101static int via_ircc_net_close(struct net_device *dev);
102static int via_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, 102static int via_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq,
103 int cmd); 103 int cmd);
104static struct net_device_stats *via_ircc_net_get_stats(struct net_device
105 *dev);
106static void via_ircc_change_dongle_speed(int iobase, int speed, 104static void via_ircc_change_dongle_speed(int iobase, int speed,
107 int dongle_id); 105 int dongle_id);
108static int RxTimerHandler(struct via_ircc_cb *self, int iobase); 106static int RxTimerHandler(struct via_ircc_cb *self, int iobase);
@@ -434,7 +432,6 @@ static __devinit int via_ircc_open(int i, chipio_t * info, unsigned int id)
434 dev->open = via_ircc_net_open; 432 dev->open = via_ircc_net_open;
435 dev->stop = via_ircc_net_close; 433 dev->stop = via_ircc_net_close;
436 dev->do_ioctl = via_ircc_net_ioctl; 434 dev->do_ioctl = via_ircc_net_ioctl;
437 dev->get_stats = via_ircc_net_get_stats;
438 435
439 err = register_netdev(dev); 436 err = register_netdev(dev);
440 if (err) 437 if (err)
@@ -855,7 +852,7 @@ static int via_ircc_hard_xmit_sir(struct sk_buff *skb,
855 async_wrap_skb(skb, self->tx_buff.data, 852 async_wrap_skb(skb, self->tx_buff.data,
856 self->tx_buff.truesize); 853 self->tx_buff.truesize);
857 854
858 self->stats.tx_bytes += self->tx_buff.len; 855 dev->stats.tx_bytes += self->tx_buff.len;
859 /* Send this frame with old speed */ 856 /* Send this frame with old speed */
860 SetBaudRate(iobase, self->io.speed); 857 SetBaudRate(iobase, self->io.speed);
861 SetPulseWidth(iobase, 12); 858 SetPulseWidth(iobase, 12);
@@ -921,7 +918,7 @@ static int via_ircc_hard_xmit_fir(struct sk_buff *skb,
921 self->tx_fifo.queue[self->tx_fifo.free].len = skb->len; 918 self->tx_fifo.queue[self->tx_fifo.free].len = skb->len;
922 919
923 self->tx_fifo.tail += skb->len; 920 self->tx_fifo.tail += skb->len;
924 self->stats.tx_bytes += skb->len; 921 dev->stats.tx_bytes += skb->len;
925 skb_copy_from_linear_data(skb, 922 skb_copy_from_linear_data(skb,
926 self->tx_fifo.queue[self->tx_fifo.free].start, skb->len); 923 self->tx_fifo.queue[self->tx_fifo.free].start, skb->len);
927 self->tx_fifo.len++; 924 self->tx_fifo.len++;
@@ -990,12 +987,12 @@ static int via_ircc_dma_xmit_complete(struct via_ircc_cb *self)
990 /* Clear bit, by writing 1 into it */ 987 /* Clear bit, by writing 1 into it */
991 Tx_status = GetTXStatus(iobase); 988 Tx_status = GetTXStatus(iobase);
992 if (Tx_status & 0x08) { 989 if (Tx_status & 0x08) {
993 self->stats.tx_errors++; 990 self->netdev->stats.tx_errors++;
994 self->stats.tx_fifo_errors++; 991 self->netdev->stats.tx_fifo_errors++;
995 hwreset(self); 992 hwreset(self);
996// how to clear underrrun ? 993// how to clear underrrun ?
997 } else { 994 } else {
998 self->stats.tx_packets++; 995 self->netdev->stats.tx_packets++;
999 ResetChip(iobase, 3); 996 ResetChip(iobase, 3);
1000 ResetChip(iobase, 4); 997 ResetChip(iobase, 4);
1001 } 998 }
@@ -1119,8 +1116,8 @@ static int via_ircc_dma_receive_complete(struct via_ircc_cb *self,
1119 } 1116 }
1120 // Move to next frame 1117 // Move to next frame
1121 self->rx_buff.data += len; 1118 self->rx_buff.data += len;
1122 self->stats.rx_bytes += len; 1119 self->netdev->stats.rx_bytes += len;
1123 self->stats.rx_packets++; 1120 self->netdev->stats.rx_packets++;
1124 skb->dev = self->netdev; 1121 skb->dev = self->netdev;
1125 skb_reset_mac_header(skb); 1122 skb_reset_mac_header(skb);
1126 skb->protocol = htons(ETH_P_IRDA); 1123 skb->protocol = htons(ETH_P_IRDA);
@@ -1180,7 +1177,7 @@ F01_E */
1180 */ 1177 */
1181 if ((skb == NULL) || (skb->data == NULL) 1178 if ((skb == NULL) || (skb->data == NULL)
1182 || (self->rx_buff.data == NULL) || (len < 6)) { 1179 || (self->rx_buff.data == NULL) || (len < 6)) {
1183 self->stats.rx_dropped++; 1180 self->netdev->stats.rx_dropped++;
1184 return TRUE; 1181 return TRUE;
1185 } 1182 }
1186 skb_reserve(skb, 1); 1183 skb_reserve(skb, 1);
@@ -1192,8 +1189,8 @@ F01_E */
1192 1189
1193 // Move to next frame 1190 // Move to next frame
1194 self->rx_buff.data += len; 1191 self->rx_buff.data += len;
1195 self->stats.rx_bytes += len; 1192 self->netdev->stats.rx_bytes += len;
1196 self->stats.rx_packets++; 1193 self->netdev->stats.rx_packets++;
1197 skb->dev = self->netdev; 1194 skb->dev = self->netdev;
1198 skb_reset_mac_header(skb); 1195 skb_reset_mac_header(skb);
1199 skb->protocol = htons(ETH_P_IRDA); 1196 skb->protocol = htons(ETH_P_IRDA);
@@ -1220,13 +1217,13 @@ static int upload_rxdata(struct via_ircc_cb *self, int iobase)
1220 IRDA_DEBUG(2, "%s(): len=%x\n", __func__, len); 1217 IRDA_DEBUG(2, "%s(): len=%x\n", __func__, len);
1221 1218
1222 if ((len - 4) < 2) { 1219 if ((len - 4) < 2) {
1223 self->stats.rx_dropped++; 1220 self->netdev->stats.rx_dropped++;
1224 return FALSE; 1221 return FALSE;
1225 } 1222 }
1226 1223
1227 skb = dev_alloc_skb(len + 1); 1224 skb = dev_alloc_skb(len + 1);
1228 if (skb == NULL) { 1225 if (skb == NULL) {
1229 self->stats.rx_dropped++; 1226 self->netdev->stats.rx_dropped++;
1230 return FALSE; 1227 return FALSE;
1231 } 1228 }
1232 skb_reserve(skb, 1); 1229 skb_reserve(skb, 1);
@@ -1238,8 +1235,8 @@ static int upload_rxdata(struct via_ircc_cb *self, int iobase)
1238 st_fifo->tail = 0; 1235 st_fifo->tail = 0;
1239 // Move to next frame 1236 // Move to next frame
1240 self->rx_buff.data += len; 1237 self->rx_buff.data += len;
1241 self->stats.rx_bytes += len; 1238 self->netdev->stats.rx_bytes += len;
1242 self->stats.rx_packets++; 1239 self->netdev->stats.rx_packets++;
1243 skb->dev = self->netdev; 1240 skb->dev = self->netdev;
1244 skb_reset_mac_header(skb); 1241 skb_reset_mac_header(skb);
1245 skb->protocol = htons(ETH_P_IRDA); 1242 skb->protocol = htons(ETH_P_IRDA);
@@ -1295,7 +1292,7 @@ static int RxTimerHandler(struct via_ircc_cb *self, int iobase)
1295 */ 1292 */
1296 if ((skb == NULL) || (skb->data == NULL) 1293 if ((skb == NULL) || (skb->data == NULL)
1297 || (self->rx_buff.data == NULL) || (len < 6)) { 1294 || (self->rx_buff.data == NULL) || (len < 6)) {
1298 self->stats.rx_dropped++; 1295 self->netdev->stats.rx_dropped++;
1299 continue; 1296 continue;
1300 } 1297 }
1301 skb_reserve(skb, 1); 1298 skb_reserve(skb, 1);
@@ -1307,8 +1304,8 @@ static int RxTimerHandler(struct via_ircc_cb *self, int iobase)
1307 1304
1308 // Move to next frame 1305 // Move to next frame
1309 self->rx_buff.data += len; 1306 self->rx_buff.data += len;
1310 self->stats.rx_bytes += len; 1307 self->netdev->stats.rx_bytes += len;
1311 self->stats.rx_packets++; 1308 self->netdev->stats.rx_packets++;
1312 skb->dev = self->netdev; 1309 skb->dev = self->netdev;
1313 skb_reset_mac_header(skb); 1310 skb_reset_mac_header(skb);
1314 skb->protocol = htons(ETH_P_IRDA); 1311 skb->protocol = htons(ETH_P_IRDA);
@@ -1523,7 +1520,7 @@ static int via_ircc_net_open(struct net_device *dev)
1523 1520
1524 IRDA_ASSERT(dev != NULL, return -1;); 1521 IRDA_ASSERT(dev != NULL, return -1;);
1525 self = netdev_priv(dev); 1522 self = netdev_priv(dev);
1526 self->stats.rx_packets = 0; 1523 dev->stats.rx_packets = 0;
1527 IRDA_ASSERT(self != NULL, return 0;); 1524 IRDA_ASSERT(self != NULL, return 0;);
1528 iobase = self->io.fir_base; 1525 iobase = self->io.fir_base;
1529 if (request_irq(self->io.irq, via_ircc_interrupt, 0, dev->name, dev)) { 1526 if (request_irq(self->io.irq, via_ircc_interrupt, 0, dev->name, dev)) {
@@ -1660,14 +1657,6 @@ static int via_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq,
1660 return ret; 1657 return ret;
1661} 1658}
1662 1659
1663static struct net_device_stats *via_ircc_net_get_stats(struct net_device
1664 *dev)
1665{
1666 struct via_ircc_cb *self = netdev_priv(dev);
1667
1668 return &self->stats;
1669}
1670
1671MODULE_AUTHOR("VIA Technologies,inc"); 1660MODULE_AUTHOR("VIA Technologies,inc");
1672MODULE_DESCRIPTION("VIA IrDA Device Driver"); 1661MODULE_DESCRIPTION("VIA IrDA Device Driver");
1673MODULE_LICENSE("GPL"); 1662MODULE_LICENSE("GPL");
diff --git a/drivers/net/irda/via-ircc.h b/drivers/net/irda/via-ircc.h
index 403c3f77634c..d9d1db03fa2d 100644
--- a/drivers/net/irda/via-ircc.h
+++ b/drivers/net/irda/via-ircc.h
@@ -95,7 +95,6 @@ struct via_ircc_cb {
95 struct tx_fifo tx_fifo; /* Info about frames to be transmitted */ 95 struct tx_fifo tx_fifo; /* Info about frames to be transmitted */
96 96
97 struct net_device *netdev; /* Yes! we are some kind of netdevice */ 97 struct net_device *netdev; /* Yes! we are some kind of netdevice */
98 struct net_device_stats stats;
99 98
100 struct irlap_cb *irlap; /* The link layer we are binded to */ 99 struct irlap_cb *irlap; /* The link layer we are binded to */
101 struct qos_info qos; /* QoS capabilities for this device */ 100 struct qos_info qos; /* QoS capabilities for this device */
diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
index 0d30f8d659a1..723c4588c803 100644
--- a/drivers/net/irda/vlsi_ir.c
+++ b/drivers/net/irda/vlsi_ir.c
@@ -291,14 +291,14 @@ static void vlsi_proc_ndev(struct seq_file *seq, struct net_device *ndev)
291 now.tv_sec - idev->last_rx.tv_sec - delta1, delta2); 291 now.tv_sec - idev->last_rx.tv_sec - delta1, delta2);
292 292
293 seq_printf(seq, "RX: packets=%lu / bytes=%lu / errors=%lu / dropped=%lu", 293 seq_printf(seq, "RX: packets=%lu / bytes=%lu / errors=%lu / dropped=%lu",
294 idev->stats.rx_packets, idev->stats.rx_bytes, idev->stats.rx_errors, 294 ndev->stats.rx_packets, ndev->stats.rx_bytes, ndev->stats.rx_errors,
295 idev->stats.rx_dropped); 295 ndev->stats.rx_dropped);
296 seq_printf(seq, " / overrun=%lu / length=%lu / frame=%lu / crc=%lu\n", 296 seq_printf(seq, " / overrun=%lu / length=%lu / frame=%lu / crc=%lu\n",
297 idev->stats.rx_over_errors, idev->stats.rx_length_errors, 297 ndev->stats.rx_over_errors, ndev->stats.rx_length_errors,
298 idev->stats.rx_frame_errors, idev->stats.rx_crc_errors); 298 ndev->stats.rx_frame_errors, ndev->stats.rx_crc_errors);
299 seq_printf(seq, "TX: packets=%lu / bytes=%lu / errors=%lu / dropped=%lu / fifo=%lu\n", 299 seq_printf(seq, "TX: packets=%lu / bytes=%lu / errors=%lu / dropped=%lu / fifo=%lu\n",
300 idev->stats.tx_packets, idev->stats.tx_bytes, idev->stats.tx_errors, 300 ndev->stats.tx_packets, ndev->stats.tx_bytes, ndev->stats.tx_errors,
301 idev->stats.tx_dropped, idev->stats.tx_fifo_errors); 301 ndev->stats.tx_dropped, ndev->stats.tx_fifo_errors);
302 302
303} 303}
304 304
@@ -651,21 +651,21 @@ static void vlsi_rx_interrupt(struct net_device *ndev)
651 651
652 if (ret < 0) { 652 if (ret < 0) {
653 ret = -ret; 653 ret = -ret;
654 idev->stats.rx_errors++; 654 ndev->stats.rx_errors++;
655 if (ret & VLSI_RX_DROP) 655 if (ret & VLSI_RX_DROP)
656 idev->stats.rx_dropped++; 656 ndev->stats.rx_dropped++;
657 if (ret & VLSI_RX_OVER) 657 if (ret & VLSI_RX_OVER)
658 idev->stats.rx_over_errors++; 658 ndev->stats.rx_over_errors++;
659 if (ret & VLSI_RX_LENGTH) 659 if (ret & VLSI_RX_LENGTH)
660 idev->stats.rx_length_errors++; 660 ndev->stats.rx_length_errors++;
661 if (ret & VLSI_RX_FRAME) 661 if (ret & VLSI_RX_FRAME)
662 idev->stats.rx_frame_errors++; 662 ndev->stats.rx_frame_errors++;
663 if (ret & VLSI_RX_CRC) 663 if (ret & VLSI_RX_CRC)
664 idev->stats.rx_crc_errors++; 664 ndev->stats.rx_crc_errors++;
665 } 665 }
666 else if (ret > 0) { 666 else if (ret > 0) {
667 idev->stats.rx_packets++; 667 ndev->stats.rx_packets++;
668 idev->stats.rx_bytes += ret; 668 ndev->stats.rx_bytes += ret;
669 } 669 }
670 } 670 }
671 671
@@ -686,6 +686,7 @@ static void vlsi_rx_interrupt(struct net_device *ndev)
686 686
687static void vlsi_unarm_rx(vlsi_irda_dev_t *idev) 687static void vlsi_unarm_rx(vlsi_irda_dev_t *idev)
688{ 688{
689 struct net_device *ndev = pci_get_drvdata(idev->pdev);
689 struct vlsi_ring *r = idev->rx_ring; 690 struct vlsi_ring *r = idev->rx_ring;
690 struct ring_descr *rd; 691 struct ring_descr *rd;
691 int ret; 692 int ret;
@@ -711,21 +712,21 @@ static void vlsi_unarm_rx(vlsi_irda_dev_t *idev)
711 712
712 if (ret < 0) { 713 if (ret < 0) {
713 ret = -ret; 714 ret = -ret;
714 idev->stats.rx_errors++; 715 ndev->stats.rx_errors++;
715 if (ret & VLSI_RX_DROP) 716 if (ret & VLSI_RX_DROP)
716 idev->stats.rx_dropped++; 717 ndev->stats.rx_dropped++;
717 if (ret & VLSI_RX_OVER) 718 if (ret & VLSI_RX_OVER)
718 idev->stats.rx_over_errors++; 719 ndev->stats.rx_over_errors++;
719 if (ret & VLSI_RX_LENGTH) 720 if (ret & VLSI_RX_LENGTH)
720 idev->stats.rx_length_errors++; 721 ndev->stats.rx_length_errors++;
721 if (ret & VLSI_RX_FRAME) 722 if (ret & VLSI_RX_FRAME)
722 idev->stats.rx_frame_errors++; 723 ndev->stats.rx_frame_errors++;
723 if (ret & VLSI_RX_CRC) 724 if (ret & VLSI_RX_CRC)
724 idev->stats.rx_crc_errors++; 725 ndev->stats.rx_crc_errors++;
725 } 726 }
726 else if (ret > 0) { 727 else if (ret > 0) {
727 idev->stats.rx_packets++; 728 ndev->stats.rx_packets++;
728 idev->stats.rx_bytes += ret; 729 ndev->stats.rx_bytes += ret;
729 } 730 }
730 } 731 }
731} 732}
@@ -1050,8 +1051,8 @@ drop_unlock:
1050drop: 1051drop:
1051 IRDA_WARNING("%s: dropping packet - %s\n", __func__, msg); 1052 IRDA_WARNING("%s: dropping packet - %s\n", __func__, msg);
1052 dev_kfree_skb_any(skb); 1053 dev_kfree_skb_any(skb);
1053 idev->stats.tx_errors++; 1054 ndev->stats.tx_errors++;
1054 idev->stats.tx_dropped++; 1055 ndev->stats.tx_dropped++;
1055 /* Don't even think about returning NET_XMIT_DROP (=1) here! 1056 /* Don't even think about returning NET_XMIT_DROP (=1) here!
1056 * In fact any retval!=0 causes the packet scheduler to requeue the 1057 * In fact any retval!=0 causes the packet scheduler to requeue the
1057 * packet for later retry of transmission - which isn't exactly 1058 * packet for later retry of transmission - which isn't exactly
@@ -1078,15 +1079,15 @@ static void vlsi_tx_interrupt(struct net_device *ndev)
1078 1079
1079 if (ret < 0) { 1080 if (ret < 0) {
1080 ret = -ret; 1081 ret = -ret;
1081 idev->stats.tx_errors++; 1082 ndev->stats.tx_errors++;
1082 if (ret & VLSI_TX_DROP) 1083 if (ret & VLSI_TX_DROP)
1083 idev->stats.tx_dropped++; 1084 ndev->stats.tx_dropped++;
1084 if (ret & VLSI_TX_FIFO) 1085 if (ret & VLSI_TX_FIFO)
1085 idev->stats.tx_fifo_errors++; 1086 ndev->stats.tx_fifo_errors++;
1086 } 1087 }
1087 else if (ret > 0){ 1088 else if (ret > 0){
1088 idev->stats.tx_packets++; 1089 ndev->stats.tx_packets++;
1089 idev->stats.tx_bytes += ret; 1090 ndev->stats.tx_bytes += ret;
1090 } 1091 }
1091 } 1092 }
1092 1093
@@ -1122,6 +1123,7 @@ static void vlsi_tx_interrupt(struct net_device *ndev)
1122 1123
1123static void vlsi_unarm_tx(vlsi_irda_dev_t *idev) 1124static void vlsi_unarm_tx(vlsi_irda_dev_t *idev)
1124{ 1125{
1126 struct net_device *ndev = pci_get_drvdata(idev->pdev);
1125 struct vlsi_ring *r = idev->tx_ring; 1127 struct vlsi_ring *r = idev->tx_ring;
1126 struct ring_descr *rd; 1128 struct ring_descr *rd;
1127 int ret; 1129 int ret;
@@ -1145,15 +1147,15 @@ static void vlsi_unarm_tx(vlsi_irda_dev_t *idev)
1145 1147
1146 if (ret < 0) { 1148 if (ret < 0) {
1147 ret = -ret; 1149 ret = -ret;
1148 idev->stats.tx_errors++; 1150 ndev->stats.tx_errors++;
1149 if (ret & VLSI_TX_DROP) 1151 if (ret & VLSI_TX_DROP)
1150 idev->stats.tx_dropped++; 1152 ndev->stats.tx_dropped++;
1151 if (ret & VLSI_TX_FIFO) 1153 if (ret & VLSI_TX_FIFO)
1152 idev->stats.tx_fifo_errors++; 1154 ndev->stats.tx_fifo_errors++;
1153 } 1155 }
1154 else if (ret > 0){ 1156 else if (ret > 0){
1155 idev->stats.tx_packets++; 1157 ndev->stats.tx_packets++;
1156 idev->stats.tx_bytes += ret; 1158 ndev->stats.tx_bytes += ret;
1157 } 1159 }
1158 } 1160 }
1159 1161
@@ -1373,13 +1375,6 @@ static int vlsi_stop_hw(vlsi_irda_dev_t *idev)
1373 1375
1374/**************************************************************/ 1376/**************************************************************/
1375 1377
1376static struct net_device_stats * vlsi_get_stats(struct net_device *ndev)
1377{
1378 vlsi_irda_dev_t *idev = netdev_priv(ndev);
1379
1380 return &idev->stats;
1381}
1382
1383static void vlsi_tx_timeout(struct net_device *ndev) 1378static void vlsi_tx_timeout(struct net_device *ndev)
1384{ 1379{
1385 vlsi_irda_dev_t *idev = netdev_priv(ndev); 1380 vlsi_irda_dev_t *idev = netdev_priv(ndev);
@@ -1615,7 +1610,6 @@ static int vlsi_irda_init(struct net_device *ndev)
1615 1610
1616 ndev->open = vlsi_open; 1611 ndev->open = vlsi_open;
1617 ndev->stop = vlsi_close; 1612 ndev->stop = vlsi_close;
1618 ndev->get_stats = vlsi_get_stats;
1619 ndev->hard_start_xmit = vlsi_hard_start_xmit; 1613 ndev->hard_start_xmit = vlsi_hard_start_xmit;
1620 ndev->do_ioctl = vlsi_ioctl; 1614 ndev->do_ioctl = vlsi_ioctl;
1621 ndev->tx_timeout = vlsi_tx_timeout; 1615 ndev->tx_timeout = vlsi_tx_timeout;
diff --git a/drivers/net/irda/vlsi_ir.h b/drivers/net/irda/vlsi_ir.h
index 9b1884329fba..3050d1a0cccf 100644
--- a/drivers/net/irda/vlsi_ir.h
+++ b/drivers/net/irda/vlsi_ir.h
@@ -712,7 +712,6 @@ static inline struct ring_descr *ring_get(struct vlsi_ring *r)
712 712
713typedef struct vlsi_irda_dev { 713typedef struct vlsi_irda_dev {
714 struct pci_dev *pdev; 714 struct pci_dev *pdev;
715 struct net_device_stats stats;
716 715
717 struct irlap_cb *irlap; 716 struct irlap_cb *irlap;
718 717
diff --git a/drivers/net/irda/w83977af_ir.c b/drivers/net/irda/w83977af_ir.c
index 30ec9131c5ce..dc0a2e4d830f 100644
--- a/drivers/net/irda/w83977af_ir.c
+++ b/drivers/net/irda/w83977af_ir.c
@@ -102,7 +102,6 @@ static int w83977af_is_receiving(struct w83977af_ir *self);
102static int w83977af_net_open(struct net_device *dev); 102static int w83977af_net_open(struct net_device *dev);
103static int w83977af_net_close(struct net_device *dev); 103static int w83977af_net_close(struct net_device *dev);
104static int w83977af_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 104static int w83977af_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
105static struct net_device_stats *w83977af_net_get_stats(struct net_device *dev);
106 105
107/* 106/*
108 * Function w83977af_init () 107 * Function w83977af_init ()
@@ -237,7 +236,6 @@ static int w83977af_open(int i, unsigned int iobase, unsigned int irq,
237 dev->open = w83977af_net_open; 236 dev->open = w83977af_net_open;
238 dev->stop = w83977af_net_close; 237 dev->stop = w83977af_net_close;
239 dev->do_ioctl = w83977af_net_ioctl; 238 dev->do_ioctl = w83977af_net_ioctl;
240 dev->get_stats = w83977af_net_get_stats;
241 239
242 err = register_netdev(dev); 240 err = register_netdev(dev);
243 if (err) { 241 if (err) {
@@ -702,13 +700,13 @@ static void w83977af_dma_xmit_complete(struct w83977af_ir *self)
702 if (inb(iobase+AUDR) & AUDR_UNDR) { 700 if (inb(iobase+AUDR) & AUDR_UNDR) {
703 IRDA_DEBUG(0, "%s(), Transmit underrun!\n", __func__ ); 701 IRDA_DEBUG(0, "%s(), Transmit underrun!\n", __func__ );
704 702
705 self->stats.tx_errors++; 703 self->netdev->stats.tx_errors++;
706 self->stats.tx_fifo_errors++; 704 self->netdev->stats.tx_fifo_errors++;
707 705
708 /* Clear bit, by writing 1 to it */ 706 /* Clear bit, by writing 1 to it */
709 outb(AUDR_UNDR, iobase+AUDR); 707 outb(AUDR_UNDR, iobase+AUDR);
710 } else 708 } else
711 self->stats.tx_packets++; 709 self->netdev->stats.tx_packets++;
712 710
713 711
714 if (self->new_speed) { 712 if (self->new_speed) {
@@ -846,28 +844,28 @@ static int w83977af_dma_receive_complete(struct w83977af_ir *self)
846 if (status & FS_FO_ERR_MSK) { 844 if (status & FS_FO_ERR_MSK) {
847 if (status & FS_FO_LST_FR) { 845 if (status & FS_FO_LST_FR) {
848 /* Add number of lost frames to stats */ 846 /* Add number of lost frames to stats */
849 self->stats.rx_errors += len; 847 self->netdev->stats.rx_errors += len;
850 } else { 848 } else {
851 /* Skip frame */ 849 /* Skip frame */
852 self->stats.rx_errors++; 850 self->netdev->stats.rx_errors++;
853 851
854 self->rx_buff.data += len; 852 self->rx_buff.data += len;
855 853
856 if (status & FS_FO_MX_LEX) 854 if (status & FS_FO_MX_LEX)
857 self->stats.rx_length_errors++; 855 self->netdev->stats.rx_length_errors++;
858 856
859 if (status & FS_FO_PHY_ERR) 857 if (status & FS_FO_PHY_ERR)
860 self->stats.rx_frame_errors++; 858 self->netdev->stats.rx_frame_errors++;
861 859
862 if (status & FS_FO_CRC_ERR) 860 if (status & FS_FO_CRC_ERR)
863 self->stats.rx_crc_errors++; 861 self->netdev->stats.rx_crc_errors++;
864 } 862 }
865 /* The errors below can be reported in both cases */ 863 /* The errors below can be reported in both cases */
866 if (status & FS_FO_RX_OV) 864 if (status & FS_FO_RX_OV)
867 self->stats.rx_fifo_errors++; 865 self->netdev->stats.rx_fifo_errors++;
868 866
869 if (status & FS_FO_FSF_OV) 867 if (status & FS_FO_FSF_OV)
870 self->stats.rx_fifo_errors++; 868 self->netdev->stats.rx_fifo_errors++;
871 869
872 } else { 870 } else {
873 /* Check if we have transferred all data to memory */ 871 /* Check if we have transferred all data to memory */
@@ -917,7 +915,7 @@ static int w83977af_dma_receive_complete(struct w83977af_ir *self)
917 915
918 /* Move to next frame */ 916 /* Move to next frame */
919 self->rx_buff.data += len; 917 self->rx_buff.data += len;
920 self->stats.rx_packets++; 918 self->netdev->stats.rx_packets++;
921 919
922 skb->dev = self->netdev; 920 skb->dev = self->netdev;
923 skb_reset_mac_header(skb); 921 skb_reset_mac_header(skb);
@@ -951,7 +949,7 @@ static void w83977af_pio_receive(struct w83977af_ir *self)
951 /* Receive all characters in Rx FIFO */ 949 /* Receive all characters in Rx FIFO */
952 do { 950 do {
953 byte = inb(iobase+RBR); 951 byte = inb(iobase+RBR);
954 async_unwrap_char(self->netdev, &self->stats, &self->rx_buff, 952 async_unwrap_char(self->netdev, &self->netdev->stats, &self->rx_buff,
955 byte); 953 byte);
956 } while (inb(iobase+USR) & USR_RDR); /* Data available */ 954 } while (inb(iobase+USR) & USR_RDR); /* Data available */
957} 955}
@@ -994,7 +992,7 @@ static __u8 w83977af_sir_interrupt(struct w83977af_ir *self, int isr)
994 outb(AUDR_SFEND, iobase+AUDR); 992 outb(AUDR_SFEND, iobase+AUDR);
995 outb(set, iobase+SSR); 993 outb(set, iobase+SSR);
996 994
997 self->stats.tx_packets++; 995 self->netdev->stats.tx_packets++;
998 996
999 /* Feed me more packets */ 997 /* Feed me more packets */
1000 netif_wake_queue(self->netdev); 998 netif_wake_queue(self->netdev);
@@ -1336,13 +1334,6 @@ out:
1336 return ret; 1334 return ret;
1337} 1335}
1338 1336
1339static struct net_device_stats *w83977af_net_get_stats(struct net_device *dev)
1340{
1341 struct w83977af_ir *self = netdev_priv(dev);
1342
1343 return &self->stats;
1344}
1345
1346MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>"); 1337MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>");
1347MODULE_DESCRIPTION("Winbond W83977AF IrDA Device Driver"); 1338MODULE_DESCRIPTION("Winbond W83977AF IrDA Device Driver");
1348MODULE_LICENSE("GPL"); 1339MODULE_LICENSE("GPL");
diff --git a/drivers/net/irda/w83977af_ir.h b/drivers/net/irda/w83977af_ir.h
index 87c3975baf62..fefe9b11e200 100644
--- a/drivers/net/irda/w83977af_ir.h
+++ b/drivers/net/irda/w83977af_ir.h
@@ -172,7 +172,6 @@ struct w83977af_ir {
172 int tx_len; /* Number of frames in tx_buff */ 172 int tx_len; /* Number of frames in tx_buff */
173 173
174 struct net_device *netdev; /* Yes! we are some kind of netdevice */ 174 struct net_device *netdev; /* Yes! we are some kind of netdevice */
175 struct net_device_stats stats;
176 175
177 struct irlap_cb *irlap; /* The link layer we are binded to */ 176 struct irlap_cb *irlap; /* The link layer we are binded to */
178 struct qos_info qos; /* QoS capabilities for this device */ 177 struct qos_info qos; /* QoS capabilities for this device */
diff --git a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c
index c7457f97259d..cb793c2bade2 100644
--- a/drivers/net/iseries_veth.c
+++ b/drivers/net/iseries_veth.c
@@ -429,7 +429,7 @@ SIMPLE_PORT_ATTR(promiscuous);
429SIMPLE_PORT_ATTR(num_mcast); 429SIMPLE_PORT_ATTR(num_mcast);
430CUSTOM_PORT_ATTR(lpar_map, "0x%X\n", port->lpar_map); 430CUSTOM_PORT_ATTR(lpar_map, "0x%X\n", port->lpar_map);
431CUSTOM_PORT_ATTR(stopped_map, "0x%X\n", port->stopped_map); 431CUSTOM_PORT_ATTR(stopped_map, "0x%X\n", port->stopped_map);
432CUSTOM_PORT_ATTR(mac_addr, "0x%lX\n", port->mac_addr); 432CUSTOM_PORT_ATTR(mac_addr, "0x%llX\n", port->mac_addr);
433 433
434#define GET_PORT_ATTR(_name) (&veth_port_attr_##_name.attr) 434#define GET_PORT_ATTR(_name) (&veth_port_attr_##_name.attr)
435static struct attribute *veth_port_default_attrs[] = { 435static struct attribute *veth_port_default_attrs[] = {
diff --git a/drivers/net/korina.c b/drivers/net/korina.c
index 4a5580c1126a..1d6e48e13366 100644
--- a/drivers/net/korina.c
+++ b/drivers/net/korina.c
@@ -84,7 +84,10 @@
84#define KORINA_NUM_RDS 64 /* number of receive descriptors */ 84#define KORINA_NUM_RDS 64 /* number of receive descriptors */
85#define KORINA_NUM_TDS 64 /* number of transmit descriptors */ 85#define KORINA_NUM_TDS 64 /* number of transmit descriptors */
86 86
87#define KORINA_RBSIZE 536 /* size of one resource buffer = Ether MTU */ 87/* KORINA_RBSIZE is the hardware's default maximum receive
88 * frame size in bytes. Having this hardcoded means that there
89 * is no support for MTU sizes greater than 1500. */
90#define KORINA_RBSIZE 1536 /* size of one resource buffer = Ether MTU */
88#define KORINA_RDS_MASK (KORINA_NUM_RDS - 1) 91#define KORINA_RDS_MASK (KORINA_NUM_RDS - 1)
89#define KORINA_TDS_MASK (KORINA_NUM_TDS - 1) 92#define KORINA_TDS_MASK (KORINA_NUM_TDS - 1)
90#define RD_RING_SIZE (KORINA_NUM_RDS * sizeof(struct dma_desc)) 93#define RD_RING_SIZE (KORINA_NUM_RDS * sizeof(struct dma_desc))
@@ -196,7 +199,7 @@ static int korina_send_packet(struct sk_buff *skb, struct net_device *dev)
196 struct korina_private *lp = netdev_priv(dev); 199 struct korina_private *lp = netdev_priv(dev);
197 unsigned long flags; 200 unsigned long flags;
198 u32 length; 201 u32 length;
199 u32 chain_index; 202 u32 chain_prev, chain_next;
200 struct dma_desc *td; 203 struct dma_desc *td;
201 204
202 spin_lock_irqsave(&lp->lock, flags); 205 spin_lock_irqsave(&lp->lock, flags);
@@ -228,8 +231,8 @@ static int korina_send_packet(struct sk_buff *skb, struct net_device *dev)
228 /* Setup the transmit descriptor. */ 231 /* Setup the transmit descriptor. */
229 dma_cache_inv((u32) td, sizeof(*td)); 232 dma_cache_inv((u32) td, sizeof(*td));
230 td->ca = CPHYSADDR(skb->data); 233 td->ca = CPHYSADDR(skb->data);
231 chain_index = (lp->tx_chain_tail - 1) & 234 chain_prev = (lp->tx_chain_tail - 1) & KORINA_TDS_MASK;
232 KORINA_TDS_MASK; 235 chain_next = (lp->tx_chain_tail + 1) & KORINA_TDS_MASK;
233 236
234 if (readl(&(lp->tx_dma_regs->dmandptr)) == 0) { 237 if (readl(&(lp->tx_dma_regs->dmandptr)) == 0) {
235 if (lp->tx_chain_status == desc_empty) { 238 if (lp->tx_chain_status == desc_empty) {
@@ -237,7 +240,7 @@ static int korina_send_packet(struct sk_buff *skb, struct net_device *dev)
237 td->control = DMA_COUNT(length) | 240 td->control = DMA_COUNT(length) |
238 DMA_DESC_COF | DMA_DESC_IOF; 241 DMA_DESC_COF | DMA_DESC_IOF;
239 /* Move tail */ 242 /* Move tail */
240 lp->tx_chain_tail = chain_index; 243 lp->tx_chain_tail = chain_next;
241 /* Write to NDPTR */ 244 /* Write to NDPTR */
242 writel(CPHYSADDR(&lp->td_ring[lp->tx_chain_head]), 245 writel(CPHYSADDR(&lp->td_ring[lp->tx_chain_head]),
243 &lp->tx_dma_regs->dmandptr); 246 &lp->tx_dma_regs->dmandptr);
@@ -248,12 +251,12 @@ static int korina_send_packet(struct sk_buff *skb, struct net_device *dev)
248 td->control = DMA_COUNT(length) | 251 td->control = DMA_COUNT(length) |
249 DMA_DESC_COF | DMA_DESC_IOF; 252 DMA_DESC_COF | DMA_DESC_IOF;
250 /* Link to prev */ 253 /* Link to prev */
251 lp->td_ring[chain_index].control &= 254 lp->td_ring[chain_prev].control &=
252 ~DMA_DESC_COF; 255 ~DMA_DESC_COF;
253 /* Link to prev */ 256 /* Link to prev */
254 lp->td_ring[chain_index].link = CPHYSADDR(td); 257 lp->td_ring[chain_prev].link = CPHYSADDR(td);
255 /* Move tail */ 258 /* Move tail */
256 lp->tx_chain_tail = chain_index; 259 lp->tx_chain_tail = chain_next;
257 /* Write to NDPTR */ 260 /* Write to NDPTR */
258 writel(CPHYSADDR(&lp->td_ring[lp->tx_chain_head]), 261 writel(CPHYSADDR(&lp->td_ring[lp->tx_chain_head]),
259 &(lp->tx_dma_regs->dmandptr)); 262 &(lp->tx_dma_regs->dmandptr));
@@ -267,17 +270,16 @@ static int korina_send_packet(struct sk_buff *skb, struct net_device *dev)
267 td->control = DMA_COUNT(length) | 270 td->control = DMA_COUNT(length) |
268 DMA_DESC_COF | DMA_DESC_IOF; 271 DMA_DESC_COF | DMA_DESC_IOF;
269 /* Move tail */ 272 /* Move tail */
270 lp->tx_chain_tail = chain_index; 273 lp->tx_chain_tail = chain_next;
271 lp->tx_chain_status = desc_filled; 274 lp->tx_chain_status = desc_filled;
272 netif_stop_queue(dev);
273 } else { 275 } else {
274 /* Update tail */ 276 /* Update tail */
275 td->control = DMA_COUNT(length) | 277 td->control = DMA_COUNT(length) |
276 DMA_DESC_COF | DMA_DESC_IOF; 278 DMA_DESC_COF | DMA_DESC_IOF;
277 lp->td_ring[chain_index].control &= 279 lp->td_ring[chain_prev].control &=
278 ~DMA_DESC_COF; 280 ~DMA_DESC_COF;
279 lp->td_ring[chain_index].link = CPHYSADDR(td); 281 lp->td_ring[chain_prev].link = CPHYSADDR(td);
280 lp->tx_chain_tail = chain_index; 282 lp->tx_chain_tail = chain_next;
281 } 283 }
282 } 284 }
283 dma_cache_wback((u32) td, sizeof(*td)); 285 dma_cache_wback((u32) td, sizeof(*td));
@@ -327,13 +329,13 @@ static irqreturn_t korina_rx_dma_interrupt(int irq, void *dev_id)
327 329
328 dmas = readl(&lp->rx_dma_regs->dmas); 330 dmas = readl(&lp->rx_dma_regs->dmas);
329 if (dmas & (DMA_STAT_DONE | DMA_STAT_HALT | DMA_STAT_ERR)) { 331 if (dmas & (DMA_STAT_DONE | DMA_STAT_HALT | DMA_STAT_ERR)) {
330 netif_rx_schedule_prep(&lp->napi);
331
332 dmasm = readl(&lp->rx_dma_regs->dmasm); 332 dmasm = readl(&lp->rx_dma_regs->dmasm);
333 writel(dmasm | (DMA_STAT_DONE | 333 writel(dmasm | (DMA_STAT_DONE |
334 DMA_STAT_HALT | DMA_STAT_ERR), 334 DMA_STAT_HALT | DMA_STAT_ERR),
335 &lp->rx_dma_regs->dmasm); 335 &lp->rx_dma_regs->dmasm);
336 336
337 netif_rx_schedule(&lp->napi);
338
337 if (dmas & DMA_STAT_ERR) 339 if (dmas & DMA_STAT_ERR)
338 printk(KERN_ERR DRV_NAME "%s: DMA error\n", dev->name); 340 printk(KERN_ERR DRV_NAME "%s: DMA error\n", dev->name);
339 341
@@ -350,15 +352,20 @@ static int korina_rx(struct net_device *dev, int limit)
350 struct dma_desc *rd = &lp->rd_ring[lp->rx_next_done]; 352 struct dma_desc *rd = &lp->rd_ring[lp->rx_next_done];
351 struct sk_buff *skb, *skb_new; 353 struct sk_buff *skb, *skb_new;
352 u8 *pkt_buf; 354 u8 *pkt_buf;
353 u32 devcs, pkt_len, dmas, rx_free_desc; 355 u32 devcs, pkt_len, dmas;
354 int count; 356 int count;
355 357
356 dma_cache_inv((u32)rd, sizeof(*rd)); 358 dma_cache_inv((u32)rd, sizeof(*rd));
357 359
358 for (count = 0; count < limit; count++) { 360 for (count = 0; count < limit; count++) {
361 skb = lp->rx_skb[lp->rx_next_done];
362 skb_new = NULL;
359 363
360 devcs = rd->devcs; 364 devcs = rd->devcs;
361 365
366 if ((KORINA_RBSIZE - (u32)DMA_COUNT(rd->control)) == 0)
367 break;
368
362 /* Update statistics counters */ 369 /* Update statistics counters */
363 if (devcs & ETH_RX_CRC) 370 if (devcs & ETH_RX_CRC)
364 dev->stats.rx_crc_errors++; 371 dev->stats.rx_crc_errors++;
@@ -381,63 +388,55 @@ static int korina_rx(struct net_device *dev, int limit)
381 * in Rc32434 (errata ref #077) */ 388 * in Rc32434 (errata ref #077) */
382 dev->stats.rx_errors++; 389 dev->stats.rx_errors++;
383 dev->stats.rx_dropped++; 390 dev->stats.rx_dropped++;
384 } 391 } else if ((devcs & ETH_RX_ROK)) {
385
386 while ((rx_free_desc = KORINA_RBSIZE - (u32)DMA_COUNT(rd->control)) != 0) {
387 /* init the var. used for the later
388 * operations within the while loop */
389 skb_new = NULL;
390 pkt_len = RCVPKT_LENGTH(devcs); 392 pkt_len = RCVPKT_LENGTH(devcs);
391 skb = lp->rx_skb[lp->rx_next_done]; 393
392 394 /* must be the (first and) last
393 if ((devcs & ETH_RX_ROK)) { 395 * descriptor then */
394 /* must be the (first and) last 396 pkt_buf = (u8 *)lp->rx_skb[lp->rx_next_done]->data;
395 * descriptor then */ 397
396 pkt_buf = (u8 *)lp->rx_skb[lp->rx_next_done]->data; 398 /* invalidate the cache */
397 399 dma_cache_inv((unsigned long)pkt_buf, pkt_len - 4);
398 /* invalidate the cache */ 400
399 dma_cache_inv((unsigned long)pkt_buf, pkt_len - 4); 401 /* Malloc up new buffer. */
400 402 skb_new = netdev_alloc_skb(dev, KORINA_RBSIZE + 2);
401 /* Malloc up new buffer. */ 403
402 skb_new = netdev_alloc_skb(dev, KORINA_RBSIZE + 2); 404 if (!skb_new)
403 405 break;
404 if (!skb_new) 406 /* Do not count the CRC */
405 break; 407 skb_put(skb, pkt_len - 4);
406 /* Do not count the CRC */ 408 skb->protocol = eth_type_trans(skb, dev);
407 skb_put(skb, pkt_len - 4); 409
408 skb->protocol = eth_type_trans(skb, dev); 410 /* Pass the packet to upper layers */
409 411 netif_receive_skb(skb);
410 /* Pass the packet to upper layers */ 412 dev->stats.rx_packets++;
411 netif_receive_skb(skb); 413 dev->stats.rx_bytes += pkt_len;
412 dev->stats.rx_packets++; 414
413 dev->stats.rx_bytes += pkt_len; 415 /* Update the mcast stats */
414 416 if (devcs & ETH_RX_MP)
415 /* Update the mcast stats */ 417 dev->stats.multicast++;
416 if (devcs & ETH_RX_MP) 418
417 dev->stats.multicast++; 419 lp->rx_skb[lp->rx_next_done] = skb_new;
418
419 lp->rx_skb[lp->rx_next_done] = skb_new;
420 }
421
422 rd->devcs = 0;
423
424 /* Restore descriptor's curr_addr */
425 if (skb_new)
426 rd->ca = CPHYSADDR(skb_new->data);
427 else
428 rd->ca = CPHYSADDR(skb->data);
429
430 rd->control = DMA_COUNT(KORINA_RBSIZE) |
431 DMA_DESC_COD | DMA_DESC_IOD;
432 lp->rd_ring[(lp->rx_next_done - 1) &
433 KORINA_RDS_MASK].control &=
434 ~DMA_DESC_COD;
435
436 lp->rx_next_done = (lp->rx_next_done + 1) & KORINA_RDS_MASK;
437 dma_cache_wback((u32)rd, sizeof(*rd));
438 rd = &lp->rd_ring[lp->rx_next_done];
439 writel(~DMA_STAT_DONE, &lp->rx_dma_regs->dmas);
440 } 420 }
421
422 rd->devcs = 0;
423
424 /* Restore descriptor's curr_addr */
425 if (skb_new)
426 rd->ca = CPHYSADDR(skb_new->data);
427 else
428 rd->ca = CPHYSADDR(skb->data);
429
430 rd->control = DMA_COUNT(KORINA_RBSIZE) |
431 DMA_DESC_COD | DMA_DESC_IOD;
432 lp->rd_ring[(lp->rx_next_done - 1) &
433 KORINA_RDS_MASK].control &=
434 ~DMA_DESC_COD;
435
436 lp->rx_next_done = (lp->rx_next_done + 1) & KORINA_RDS_MASK;
437 dma_cache_wback((u32)rd, sizeof(*rd));
438 rd = &lp->rd_ring[lp->rx_next_done];
439 writel(~DMA_STAT_DONE, &lp->rx_dma_regs->dmas);
441 } 440 }
442 441
443 dmas = readl(&lp->rx_dma_regs->dmas); 442 dmas = readl(&lp->rx_dma_regs->dmas);
@@ -623,12 +622,12 @@ korina_tx_dma_interrupt(int irq, void *dev_id)
623 dmas = readl(&lp->tx_dma_regs->dmas); 622 dmas = readl(&lp->tx_dma_regs->dmas);
624 623
625 if (dmas & (DMA_STAT_FINI | DMA_STAT_ERR)) { 624 if (dmas & (DMA_STAT_FINI | DMA_STAT_ERR)) {
626 korina_tx(dev);
627
628 dmasm = readl(&lp->tx_dma_regs->dmasm); 625 dmasm = readl(&lp->tx_dma_regs->dmasm);
629 writel(dmasm | (DMA_STAT_FINI | DMA_STAT_ERR), 626 writel(dmasm | (DMA_STAT_FINI | DMA_STAT_ERR),
630 &lp->tx_dma_regs->dmasm); 627 &lp->tx_dma_regs->dmasm);
631 628
629 korina_tx(dev);
630
632 if (lp->tx_chain_status == desc_filled && 631 if (lp->tx_chain_status == desc_filled &&
633 (readl(&(lp->tx_dma_regs->dmandptr)) == 0)) { 632 (readl(&(lp->tx_dma_regs->dmandptr)) == 0)) {
634 writel(CPHYSADDR(&lp->td_ring[lp->tx_chain_head]), 633 writel(CPHYSADDR(&lp->td_ring[lp->tx_chain_head]),
@@ -901,6 +900,8 @@ static int korina_restart(struct net_device *dev)
901 900
902 korina_free_ring(dev); 901 korina_free_ring(dev);
903 902
903 napi_disable(&lp->napi);
904
904 ret = korina_init(dev); 905 ret = korina_init(dev);
905 if (ret < 0) { 906 if (ret < 0) {
906 printk(KERN_ERR DRV_NAME "%s: cannot restart device\n", 907 printk(KERN_ERR DRV_NAME "%s: cannot restart device\n",
@@ -999,14 +1000,14 @@ static int korina_open(struct net_device *dev)
999 * that handles the Done Finished 1000 * that handles the Done Finished
1000 * Ovr and Und Events */ 1001 * Ovr and Und Events */
1001 ret = request_irq(lp->rx_irq, &korina_rx_dma_interrupt, 1002 ret = request_irq(lp->rx_irq, &korina_rx_dma_interrupt,
1002 IRQF_SHARED | IRQF_DISABLED, "Korina ethernet Rx", dev); 1003 IRQF_DISABLED, "Korina ethernet Rx", dev);
1003 if (ret < 0) { 1004 if (ret < 0) {
1004 printk(KERN_ERR DRV_NAME "%s: unable to get Rx DMA IRQ %d\n", 1005 printk(KERN_ERR DRV_NAME "%s: unable to get Rx DMA IRQ %d\n",
1005 dev->name, lp->rx_irq); 1006 dev->name, lp->rx_irq);
1006 goto err_release; 1007 goto err_release;
1007 } 1008 }
1008 ret = request_irq(lp->tx_irq, &korina_tx_dma_interrupt, 1009 ret = request_irq(lp->tx_irq, &korina_tx_dma_interrupt,
1009 IRQF_SHARED | IRQF_DISABLED, "Korina ethernet Tx", dev); 1010 IRQF_DISABLED, "Korina ethernet Tx", dev);
1010 if (ret < 0) { 1011 if (ret < 0) {
1011 printk(KERN_ERR DRV_NAME "%s: unable to get Tx DMA IRQ %d\n", 1012 printk(KERN_ERR DRV_NAME "%s: unable to get Tx DMA IRQ %d\n",
1012 dev->name, lp->tx_irq); 1013 dev->name, lp->tx_irq);
@@ -1015,7 +1016,7 @@ static int korina_open(struct net_device *dev)
1015 1016
1016 /* Install handler for overrun error. */ 1017 /* Install handler for overrun error. */
1017 ret = request_irq(lp->ovr_irq, &korina_ovr_interrupt, 1018 ret = request_irq(lp->ovr_irq, &korina_ovr_interrupt,
1018 IRQF_SHARED | IRQF_DISABLED, "Ethernet Overflow", dev); 1019 IRQF_DISABLED, "Ethernet Overflow", dev);
1019 if (ret < 0) { 1020 if (ret < 0) {
1020 printk(KERN_ERR DRV_NAME"%s: unable to get OVR IRQ %d\n", 1021 printk(KERN_ERR DRV_NAME"%s: unable to get OVR IRQ %d\n",
1021 dev->name, lp->ovr_irq); 1022 dev->name, lp->ovr_irq);
@@ -1024,7 +1025,7 @@ static int korina_open(struct net_device *dev)
1024 1025
1025 /* Install handler for underflow error. */ 1026 /* Install handler for underflow error. */
1026 ret = request_irq(lp->und_irq, &korina_und_interrupt, 1027 ret = request_irq(lp->und_irq, &korina_und_interrupt,
1027 IRQF_SHARED | IRQF_DISABLED, "Ethernet Underflow", dev); 1028 IRQF_DISABLED, "Ethernet Underflow", dev);
1028 if (ret < 0) { 1029 if (ret < 0) {
1029 printk(KERN_ERR DRV_NAME "%s: unable to get UND IRQ %d\n", 1030 printk(KERN_ERR DRV_NAME "%s: unable to get UND IRQ %d\n",
1030 dev->name, lp->und_irq); 1031 dev->name, lp->und_irq);
@@ -1067,6 +1068,8 @@ static int korina_close(struct net_device *dev)
1067 1068
1068 korina_free_ring(dev); 1069 korina_free_ring(dev);
1069 1070
1071 napi_disable(&lp->napi);
1072
1070 free_irq(lp->rx_irq, dev); 1073 free_irq(lp->rx_irq, dev);
1071 free_irq(lp->tx_irq, dev); 1074 free_irq(lp->tx_irq, dev);
1072 free_irq(lp->ovr_irq, dev); 1075 free_irq(lp->ovr_irq, dev);
@@ -1089,7 +1092,6 @@ static int korina_probe(struct platform_device *pdev)
1089 return -ENOMEM; 1092 return -ENOMEM;
1090 } 1093 }
1091 SET_NETDEV_DEV(dev, &pdev->dev); 1094 SET_NETDEV_DEV(dev, &pdev->dev);
1092 platform_set_drvdata(pdev, dev);
1093 lp = netdev_priv(dev); 1095 lp = netdev_priv(dev);
1094 1096
1095 bif->dev = dev; 1097 bif->dev = dev;
diff --git a/drivers/net/mac8390.c b/drivers/net/mac8390.c
index 57716e22660c..8e884869a05b 100644
--- a/drivers/net/mac8390.c
+++ b/drivers/net/mac8390.c
@@ -486,6 +486,7 @@ static const struct net_device_ops mac8390_netdev_ops = {
486 .ndo_get_stats = ei_get_stats, 486 .ndo_get_stats = ei_get_stats,
487 .ndo_set_multicast_list = ei_set_multicast_list, 487 .ndo_set_multicast_list = ei_set_multicast_list,
488 .ndo_validate_addr = eth_validate_addr, 488 .ndo_validate_addr = eth_validate_addr,
489 .ndo_set_mac_address = eth_mac_addr,
489 .ndo_change_mtu = eth_change_mtu, 490 .ndo_change_mtu = eth_change_mtu,
490#ifdef CONFIG_NET_POLL_CONTROLLER 491#ifdef CONFIG_NET_POLL_CONTROLLER
491 .ndo_poll_controller = ei_poll, 492 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/mlx4/en_netdev.c b/drivers/net/mlx4/en_netdev.c
index 15bb38d99304..9f6644a44030 100644
--- a/drivers/net/mlx4/en_netdev.c
+++ b/drivers/net/mlx4/en_netdev.c
@@ -952,6 +952,7 @@ static const struct net_device_ops mlx4_netdev_ops = {
952 .ndo_get_stats = mlx4_en_get_stats, 952 .ndo_get_stats = mlx4_en_get_stats,
953 .ndo_set_multicast_list = mlx4_en_set_multicast, 953 .ndo_set_multicast_list = mlx4_en_set_multicast,
954 .ndo_set_mac_address = mlx4_en_set_mac, 954 .ndo_set_mac_address = mlx4_en_set_mac,
955 .ndo_validate_addr = eth_validate_addr,
955 .ndo_change_mtu = mlx4_en_change_mtu, 956 .ndo_change_mtu = mlx4_en_change_mtu,
956 .ndo_tx_timeout = mlx4_en_tx_timeout, 957 .ndo_tx_timeout = mlx4_en_tx_timeout,
957 .ndo_vlan_rx_register = mlx4_en_vlan_rx_register, 958 .ndo_vlan_rx_register = mlx4_en_vlan_rx_register,
diff --git a/drivers/net/mlx4/en_params.c b/drivers/net/mlx4/en_params.c
index cfeef0f1bacc..c1bd040b9e05 100644
--- a/drivers/net/mlx4/en_params.c
+++ b/drivers/net/mlx4/en_params.c
@@ -399,8 +399,10 @@ static int mlx4_en_set_ringparam(struct net_device *dev,
399 399
400 rx_size = roundup_pow_of_two(param->rx_pending); 400 rx_size = roundup_pow_of_two(param->rx_pending);
401 rx_size = max_t(u32, rx_size, MLX4_EN_MIN_RX_SIZE); 401 rx_size = max_t(u32, rx_size, MLX4_EN_MIN_RX_SIZE);
402 rx_size = min_t(u32, rx_size, MLX4_EN_MAX_RX_SIZE);
402 tx_size = roundup_pow_of_two(param->tx_pending); 403 tx_size = roundup_pow_of_two(param->tx_pending);
403 tx_size = max_t(u32, tx_size, MLX4_EN_MIN_TX_SIZE); 404 tx_size = max_t(u32, tx_size, MLX4_EN_MIN_TX_SIZE);
405 tx_size = min_t(u32, tx_size, MLX4_EN_MAX_TX_SIZE);
404 406
405 if (rx_size == priv->prof->rx_ring_size && 407 if (rx_size == priv->prof->rx_ring_size &&
406 tx_size == priv->prof->tx_ring_size) 408 tx_size == priv->prof->tx_ring_size)
@@ -440,8 +442,8 @@ static void mlx4_en_get_ringparam(struct net_device *dev,
440 struct mlx4_en_dev *mdev = priv->mdev; 442 struct mlx4_en_dev *mdev = priv->mdev;
441 443
442 memset(param, 0, sizeof(*param)); 444 memset(param, 0, sizeof(*param));
443 param->rx_max_pending = mdev->dev->caps.max_rq_sg; 445 param->rx_max_pending = MLX4_EN_MAX_RX_SIZE;
444 param->tx_max_pending = mdev->dev->caps.max_sq_sg; 446 param->tx_max_pending = MLX4_EN_MAX_TX_SIZE;
445 param->rx_pending = mdev->profile.prof[priv->port].rx_ring_size; 447 param->rx_pending = mdev->profile.prof[priv->port].rx_ring_size;
446 param->tx_pending = mdev->profile.prof[priv->port].tx_ring_size; 448 param->tx_pending = mdev->profile.prof[priv->port].tx_ring_size;
447} 449}
diff --git a/drivers/net/mlx4/en_tx.c b/drivers/net/mlx4/en_tx.c
index ff4d75205c25..4afd5993e31c 100644
--- a/drivers/net/mlx4/en_tx.c
+++ b/drivers/net/mlx4/en_tx.c
@@ -203,19 +203,21 @@ static u32 mlx4_en_free_tx_desc(struct mlx4_en_priv *priv,
203 203
204 /* Optimize the common case when there are no wraparounds */ 204 /* Optimize the common case when there are no wraparounds */
205 if (likely((void *) tx_desc + tx_info->nr_txbb * TXBB_SIZE <= end)) { 205 if (likely((void *) tx_desc + tx_info->nr_txbb * TXBB_SIZE <= end)) {
206 if (tx_info->linear) { 206 if (!tx_info->inl) {
207 pci_unmap_single(mdev->pdev, 207 if (tx_info->linear) {
208 (dma_addr_t) be64_to_cpu(data->addr), 208 pci_unmap_single(mdev->pdev,
209 (dma_addr_t) be64_to_cpu(data->addr),
209 be32_to_cpu(data->byte_count), 210 be32_to_cpu(data->byte_count),
210 PCI_DMA_TODEVICE); 211 PCI_DMA_TODEVICE);
211 ++data; 212 ++data;
212 } 213 }
213 214
214 for (i = 0; i < frags; i++) { 215 for (i = 0; i < frags; i++) {
215 frag = &skb_shinfo(skb)->frags[i]; 216 frag = &skb_shinfo(skb)->frags[i];
216 pci_unmap_page(mdev->pdev, 217 pci_unmap_page(mdev->pdev,
217 (dma_addr_t) be64_to_cpu(data[i].addr), 218 (dma_addr_t) be64_to_cpu(data[i].addr),
218 frag->size, PCI_DMA_TODEVICE); 219 frag->size, PCI_DMA_TODEVICE);
220 }
219 } 221 }
220 /* Stamp the freed descriptor */ 222 /* Stamp the freed descriptor */
221 for (i = 0; i < tx_info->nr_txbb * TXBB_SIZE; i += STAMP_STRIDE) { 223 for (i = 0; i < tx_info->nr_txbb * TXBB_SIZE; i += STAMP_STRIDE) {
@@ -224,27 +226,29 @@ static u32 mlx4_en_free_tx_desc(struct mlx4_en_priv *priv,
224 } 226 }
225 227
226 } else { 228 } else {
227 if ((void *) data >= end) { 229 if (!tx_info->inl) {
228 data = (struct mlx4_wqe_data_seg *) 230 if ((void *) data >= end) {
229 (ring->buf + ((void *) data - end)); 231 data = (struct mlx4_wqe_data_seg *)
230 } 232 (ring->buf + ((void *) data - end));
233 }
231 234
232 if (tx_info->linear) { 235 if (tx_info->linear) {
233 pci_unmap_single(mdev->pdev, 236 pci_unmap_single(mdev->pdev,
234 (dma_addr_t) be64_to_cpu(data->addr), 237 (dma_addr_t) be64_to_cpu(data->addr),
235 be32_to_cpu(data->byte_count), 238 be32_to_cpu(data->byte_count),
236 PCI_DMA_TODEVICE); 239 PCI_DMA_TODEVICE);
237 ++data; 240 ++data;
238 } 241 }
239 242
240 for (i = 0; i < frags; i++) { 243 for (i = 0; i < frags; i++) {
241 /* Check for wraparound before unmapping */ 244 /* Check for wraparound before unmapping */
242 if ((void *) data >= end) 245 if ((void *) data >= end)
243 data = (struct mlx4_wqe_data_seg *) ring->buf; 246 data = (struct mlx4_wqe_data_seg *) ring->buf;
244 frag = &skb_shinfo(skb)->frags[i]; 247 frag = &skb_shinfo(skb)->frags[i];
245 pci_unmap_page(mdev->pdev, 248 pci_unmap_page(mdev->pdev,
246 (dma_addr_t) be64_to_cpu(data->addr), 249 (dma_addr_t) be64_to_cpu(data->addr),
247 frag->size, PCI_DMA_TODEVICE); 250 frag->size, PCI_DMA_TODEVICE);
251 }
248 } 252 }
249 /* Stamp the freed descriptor */ 253 /* Stamp the freed descriptor */
250 for (i = 0; i < tx_info->nr_txbb * TXBB_SIZE; i += STAMP_STRIDE) { 254 for (i = 0; i < tx_info->nr_txbb * TXBB_SIZE; i += STAMP_STRIDE) {
@@ -790,8 +794,11 @@ int mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
790 wmb(); 794 wmb();
791 data->byte_count = cpu_to_be32(skb_headlen(skb) - lso_header_size); 795 data->byte_count = cpu_to_be32(skb_headlen(skb) - lso_header_size);
792 } 796 }
793 } else 797 tx_info->inl = 0;
798 } else {
794 build_inline_wqe(tx_desc, skb, real_size, &vlan_tag, tx_ind, fragptr); 799 build_inline_wqe(tx_desc, skb, real_size, &vlan_tag, tx_ind, fragptr);
800 tx_info->inl = 1;
801 }
795 802
796 ring->prod += nr_txbb; 803 ring->prod += nr_txbb;
797 804
diff --git a/drivers/net/mlx4/main.c b/drivers/net/mlx4/main.c
index 710c79e7a2db..6ef2490d5c3e 100644
--- a/drivers/net/mlx4/main.c
+++ b/drivers/net/mlx4/main.c
@@ -912,8 +912,8 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev)
912 int i; 912 int i;
913 913
914 if (msi_x) { 914 if (msi_x) {
915 nreq = min(dev->caps.num_eqs - dev->caps.reserved_eqs, 915 nreq = min_t(int, dev->caps.num_eqs - dev->caps.reserved_eqs,
916 num_possible_cpus() + 1); 916 num_possible_cpus() + 1);
917 entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL); 917 entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL);
918 if (!entries) 918 if (!entries)
919 goto no_msi; 919 goto no_msi;
diff --git a/drivers/net/mlx4/mlx4_en.h b/drivers/net/mlx4/mlx4_en.h
index 2e96c7b2180a..e9af32d41ca4 100644
--- a/drivers/net/mlx4/mlx4_en.h
+++ b/drivers/net/mlx4/mlx4_en.h
@@ -115,6 +115,10 @@ enum {
115}; 115};
116#define MLX4_EN_MAX_RX_FRAGS 4 116#define MLX4_EN_MAX_RX_FRAGS 4
117 117
118/* Maximum ring sizes */
119#define MLX4_EN_MAX_TX_SIZE 8192
120#define MLX4_EN_MAX_RX_SIZE 8192
121
118/* Minimum ring size for our page-allocation sceme to work */ 122/* Minimum ring size for our page-allocation sceme to work */
119#define MLX4_EN_MIN_RX_SIZE (MLX4_EN_ALLOC_SIZE / SMP_CACHE_BYTES) 123#define MLX4_EN_MIN_RX_SIZE (MLX4_EN_ALLOC_SIZE / SMP_CACHE_BYTES)
120#define MLX4_EN_MIN_TX_SIZE (4096 / TXBB_SIZE) 124#define MLX4_EN_MIN_TX_SIZE (4096 / TXBB_SIZE)
@@ -202,6 +206,7 @@ struct mlx4_en_tx_info {
202 u32 nr_txbb; 206 u32 nr_txbb;
203 u8 linear; 207 u8 linear;
204 u8 data_offset; 208 u8 data_offset;
209 u8 inl;
205}; 210};
206 211
207 212
diff --git a/drivers/net/mlx4/profile.c b/drivers/net/mlx4/profile.c
index 919fb9eb1b62..cebdf3243ca1 100644
--- a/drivers/net/mlx4/profile.c
+++ b/drivers/net/mlx4/profile.c
@@ -107,9 +107,9 @@ u64 mlx4_make_profile(struct mlx4_dev *dev,
107 profile[MLX4_RES_AUXC].num = request->num_qp; 107 profile[MLX4_RES_AUXC].num = request->num_qp;
108 profile[MLX4_RES_SRQ].num = request->num_srq; 108 profile[MLX4_RES_SRQ].num = request->num_srq;
109 profile[MLX4_RES_CQ].num = request->num_cq; 109 profile[MLX4_RES_CQ].num = request->num_cq;
110 profile[MLX4_RES_EQ].num = min(dev_cap->max_eqs, 110 profile[MLX4_RES_EQ].num = min_t(unsigned, dev_cap->max_eqs,
111 dev_cap->reserved_eqs + 111 dev_cap->reserved_eqs +
112 num_possible_cpus() + 1); 112 num_possible_cpus() + 1);
113 profile[MLX4_RES_DMPT].num = request->num_mpt; 113 profile[MLX4_RES_DMPT].num = request->num_mpt;
114 profile[MLX4_RES_CMPT].num = MLX4_NUM_CMPTS; 114 profile[MLX4_RES_CMPT].num = MLX4_NUM_CMPTS;
115 profile[MLX4_RES_MTT].num = request->num_mtt; 115 profile[MLX4_RES_MTT].num = request->num_mtt;
diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c
index 478edb92bca3..c5dec54251bf 100644
--- a/drivers/net/natsemi.c
+++ b/drivers/net/natsemi.c
@@ -779,6 +779,22 @@ static void __devinit natsemi_init_media (struct net_device *dev)
779 779
780} 780}
781 781
782static const struct net_device_ops natsemi_netdev_ops = {
783 .ndo_open = netdev_open,
784 .ndo_stop = netdev_close,
785 .ndo_start_xmit = start_tx,
786 .ndo_get_stats = get_stats,
787 .ndo_set_multicast_list = set_rx_mode,
788 .ndo_change_mtu = natsemi_change_mtu,
789 .ndo_do_ioctl = netdev_ioctl,
790 .ndo_tx_timeout = ns_tx_timeout,
791 .ndo_set_mac_address = eth_mac_addr,
792 .ndo_validate_addr = eth_validate_addr,
793#ifdef CONFIG_NET_POLL_CONTROLLER
794 .ndo_poll_controller = natsemi_poll_controller,
795#endif
796};
797
782static int __devinit natsemi_probe1 (struct pci_dev *pdev, 798static int __devinit natsemi_probe1 (struct pci_dev *pdev,
783 const struct pci_device_id *ent) 799 const struct pci_device_id *ent)
784{ 800{
@@ -911,20 +927,9 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
911 if (find_cnt < MAX_UNITS && full_duplex[find_cnt]) 927 if (find_cnt < MAX_UNITS && full_duplex[find_cnt])
912 np->full_duplex = 1; 928 np->full_duplex = 1;
913 929
914 /* The chip-specific entries in the device structure. */ 930 dev->netdev_ops = &natsemi_netdev_ops;
915 dev->open = &netdev_open;
916 dev->hard_start_xmit = &start_tx;
917 dev->stop = &netdev_close;
918 dev->get_stats = &get_stats;
919 dev->set_multicast_list = &set_rx_mode;
920 dev->change_mtu = &natsemi_change_mtu;
921 dev->do_ioctl = &netdev_ioctl;
922 dev->tx_timeout = &ns_tx_timeout;
923 dev->watchdog_timeo = TX_TIMEOUT; 931 dev->watchdog_timeo = TX_TIMEOUT;
924 932
925#ifdef CONFIG_NET_POLL_CONTROLLER
926 dev->poll_controller = &natsemi_poll_controller;
927#endif
928 SET_ETHTOOL_OPS(dev, &ethtool_ops); 933 SET_ETHTOOL_OPS(dev, &ethtool_ops);
929 934
930 if (mtu) 935 if (mtu)
diff --git a/drivers/net/ne-h8300.c b/drivers/net/ne-h8300.c
index b57239171046..7bd6662d5b04 100644
--- a/drivers/net/ne-h8300.c
+++ b/drivers/net/ne-h8300.c
@@ -202,6 +202,7 @@ static const struct net_device_ops ne_netdev_ops = {
202 .ndo_get_stats = ei_get_stats, 202 .ndo_get_stats = ei_get_stats,
203 .ndo_set_multicast_list = ei_set_multicast_list, 203 .ndo_set_multicast_list = ei_set_multicast_list,
204 .ndo_validate_addr = eth_validate_addr, 204 .ndo_validate_addr = eth_validate_addr,
205 .ndo_set_mac_address = eth_mac_addr,
205 .ndo_change_mtu = eth_change_mtu, 206 .ndo_change_mtu = eth_change_mtu,
206#ifdef CONFIG_NET_POLL_CONTROLLER 207#ifdef CONFIG_NET_POLL_CONTROLLER
207 .ndo_poll_controller = ei_poll, 208 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/ne2k-pci.c b/drivers/net/ne2k-pci.c
index 62f20ba211cb..f090d3b9ec94 100644
--- a/drivers/net/ne2k-pci.c
+++ b/drivers/net/ne2k-pci.c
@@ -208,6 +208,7 @@ static const struct net_device_ops ne2k_netdev_ops = {
208 .ndo_get_stats = ei_get_stats, 208 .ndo_get_stats = ei_get_stats,
209 .ndo_set_multicast_list = ei_set_multicast_list, 209 .ndo_set_multicast_list = ei_set_multicast_list,
210 .ndo_validate_addr = eth_validate_addr, 210 .ndo_validate_addr = eth_validate_addr,
211 .ndo_set_mac_address = eth_mac_addr,
211 .ndo_change_mtu = eth_change_mtu, 212 .ndo_change_mtu = eth_change_mtu,
212#ifdef CONFIG_NET_POLL_CONTROLLER 213#ifdef CONFIG_NET_POLL_CONTROLLER
213 .ndo_poll_controller = ei_poll, 214 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index f8e601c51da7..c11c568fd7db 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -308,27 +308,16 @@ struct netxen_ring_ctx {
308#define netxen_set_cmd_desc_ctxid(cmd_desc, var) \ 308#define netxen_set_cmd_desc_ctxid(cmd_desc, var) \
309 ((cmd_desc)->port_ctxid |= ((var) << 4 & 0xF0)) 309 ((cmd_desc)->port_ctxid |= ((var) << 4 & 0xF0))
310 310
311#define netxen_set_cmd_desc_flags(cmd_desc, val) \ 311#define netxen_set_tx_port(_desc, _port) \
312 (cmd_desc)->flags_opcode = ((cmd_desc)->flags_opcode & \ 312 (_desc)->port_ctxid = ((_port) & 0xf) | (((_port) << 4) & 0xf0)
313 ~cpu_to_le16(0x7f)) | cpu_to_le16((val) & 0x7f) 313
314#define netxen_set_cmd_desc_opcode(cmd_desc, val) \ 314#define netxen_set_tx_flags_opcode(_desc, _flags, _opcode) \
315 (cmd_desc)->flags_opcode = ((cmd_desc)->flags_opcode & \ 315 (_desc)->flags_opcode = \
316 ~cpu_to_le16((u16)0x3f << 7)) | cpu_to_le16(((val) & 0x3f) << 7) 316 cpu_to_le16(((_flags) & 0x7f) | (((_opcode) & 0x3f) << 7))
317 317
318#define netxen_set_cmd_desc_num_of_buff(cmd_desc, val) \ 318#define netxen_set_tx_frags_len(_desc, _frags, _len) \
319 (cmd_desc)->num_of_buffers_total_length = \ 319 (_desc)->num_of_buffers_total_length = \
320 ((cmd_desc)->num_of_buffers_total_length & \ 320 cpu_to_le32(((_frags) & 0xff) | (((_len) & 0xffffff) << 8))
321 ~cpu_to_le32(0xff)) | cpu_to_le32((val) & 0xff)
322#define netxen_set_cmd_desc_totallength(cmd_desc, val) \
323 (cmd_desc)->num_of_buffers_total_length = \
324 ((cmd_desc)->num_of_buffers_total_length & \
325 ~cpu_to_le32((u32)0xffffff << 8)) | \
326 cpu_to_le32(((val) & 0xffffff) << 8)
327
328#define netxen_get_cmd_desc_opcode(cmd_desc) \
329 ((le16_to_cpu((cmd_desc)->flags_opcode) >> 7) & 0x003f)
330#define netxen_get_cmd_desc_totallength(cmd_desc) \
331 ((le32_to_cpu((cmd_desc)->num_of_buffers_total_length) >> 8) & 0xffffff)
332 321
333struct cmd_desc_type0 { 322struct cmd_desc_type0 {
334 u8 tcp_hdr_offset; /* For LSO only */ 323 u8 tcp_hdr_offset; /* For LSO only */
@@ -510,7 +499,8 @@ typedef enum {
510 NETXEN_BRDTYPE_P3_10G_SFP_CT = 0x002a, 499 NETXEN_BRDTYPE_P3_10G_SFP_CT = 0x002a,
511 NETXEN_BRDTYPE_P3_10G_SFP_QT = 0x002b, 500 NETXEN_BRDTYPE_P3_10G_SFP_QT = 0x002b,
512 NETXEN_BRDTYPE_P3_10G_CX4 = 0x0031, 501 NETXEN_BRDTYPE_P3_10G_CX4 = 0x0031,
513 NETXEN_BRDTYPE_P3_10G_XFP = 0x0032 502 NETXEN_BRDTYPE_P3_10G_XFP = 0x0032,
503 NETXEN_BRDTYPE_P3_10G_TP = 0x0080
514 504
515} netxen_brdtype_t; 505} netxen_brdtype_t;
516 506
@@ -757,7 +747,7 @@ extern char netxen_nic_driver_name[];
757 */ 747 */
758struct netxen_skb_frag { 748struct netxen_skb_frag {
759 u64 dma; 749 u64 dma;
760 u32 length; 750 ulong length;
761}; 751};
762 752
763#define _netxen_set_bits(config_word, start, bits, val) {\ 753#define _netxen_set_bits(config_word, start, bits, val) {\
@@ -783,13 +773,7 @@ struct netxen_skb_frag {
783struct netxen_cmd_buffer { 773struct netxen_cmd_buffer {
784 struct sk_buff *skb; 774 struct sk_buff *skb;
785 struct netxen_skb_frag frag_array[MAX_BUFFERS_PER_CMD + 1]; 775 struct netxen_skb_frag frag_array[MAX_BUFFERS_PER_CMD + 1];
786 u32 total_length; 776 u32 frag_count;
787 u32 mss;
788 u16 port;
789 u8 cmd;
790 u8 frag_count;
791 unsigned long time_stamp;
792 u32 state;
793}; 777};
794 778
795/* In rx_buffer, we do not need multiple fragments as is a single buffer */ 779/* In rx_buffer, we do not need multiple fragments as is a single buffer */
@@ -876,7 +860,6 @@ struct nx_host_rds_ring {
876 u32 skb_size; 860 u32 skb_size;
877 struct netxen_rx_buffer *rx_buf_arr; /* rx buffers for receive */ 861 struct netxen_rx_buffer *rx_buf_arr; /* rx buffers for receive */
878 struct list_head free_list; 862 struct list_head free_list;
879 int begin_alloc;
880}; 863};
881 864
882/* 865/*
@@ -995,31 +978,31 @@ struct netxen_recv_context {
995 */ 978 */
996 979
997typedef struct { 980typedef struct {
998 u64 host_phys_addr; /* Ring base addr */ 981 __le64 host_phys_addr; /* Ring base addr */
999 u32 ring_size; /* Ring entries */ 982 __le32 ring_size; /* Ring entries */
1000 u16 msi_index; 983 __le16 msi_index;
1001 u16 rsvd; /* Padding */ 984 __le16 rsvd; /* Padding */
1002} nx_hostrq_sds_ring_t; 985} nx_hostrq_sds_ring_t;
1003 986
1004typedef struct { 987typedef struct {
1005 u64 host_phys_addr; /* Ring base addr */ 988 __le64 host_phys_addr; /* Ring base addr */
1006 u64 buff_size; /* Packet buffer size */ 989 __le64 buff_size; /* Packet buffer size */
1007 u32 ring_size; /* Ring entries */ 990 __le32 ring_size; /* Ring entries */
1008 u32 ring_kind; /* Class of ring */ 991 __le32 ring_kind; /* Class of ring */
1009} nx_hostrq_rds_ring_t; 992} nx_hostrq_rds_ring_t;
1010 993
1011typedef struct { 994typedef struct {
1012 u64 host_rsp_dma_addr; /* Response dma'd here */ 995 __le64 host_rsp_dma_addr; /* Response dma'd here */
1013 u32 capabilities[4]; /* Flag bit vector */ 996 __le32 capabilities[4]; /* Flag bit vector */
1014 u32 host_int_crb_mode; /* Interrupt crb usage */ 997 __le32 host_int_crb_mode; /* Interrupt crb usage */
1015 u32 host_rds_crb_mode; /* RDS crb usage */ 998 __le32 host_rds_crb_mode; /* RDS crb usage */
1016 /* These ring offsets are relative to data[0] below */ 999 /* These ring offsets are relative to data[0] below */
1017 u32 rds_ring_offset; /* Offset to RDS config */ 1000 __le32 rds_ring_offset; /* Offset to RDS config */
1018 u32 sds_ring_offset; /* Offset to SDS config */ 1001 __le32 sds_ring_offset; /* Offset to SDS config */
1019 u16 num_rds_rings; /* Count of RDS rings */ 1002 __le16 num_rds_rings; /* Count of RDS rings */
1020 u16 num_sds_rings; /* Count of SDS rings */ 1003 __le16 num_sds_rings; /* Count of SDS rings */
1021 u16 rsvd1; /* Padding */ 1004 __le16 rsvd1; /* Padding */
1022 u16 rsvd2; /* Padding */ 1005 __le16 rsvd2; /* Padding */
1023 u8 reserved[128]; /* reserve space for future expansion*/ 1006 u8 reserved[128]; /* reserve space for future expansion*/
1024 /* MUST BE 64-bit aligned. 1007 /* MUST BE 64-bit aligned.
1025 The following is packed: 1008 The following is packed:
@@ -1029,24 +1012,24 @@ typedef struct {
1029} nx_hostrq_rx_ctx_t; 1012} nx_hostrq_rx_ctx_t;
1030 1013
1031typedef struct { 1014typedef struct {
1032 u32 host_producer_crb; /* Crb to use */ 1015 __le32 host_producer_crb; /* Crb to use */
1033 u32 rsvd1; /* Padding */ 1016 __le32 rsvd1; /* Padding */
1034} nx_cardrsp_rds_ring_t; 1017} nx_cardrsp_rds_ring_t;
1035 1018
1036typedef struct { 1019typedef struct {
1037 u32 host_consumer_crb; /* Crb to use */ 1020 __le32 host_consumer_crb; /* Crb to use */
1038 u32 interrupt_crb; /* Crb to use */ 1021 __le32 interrupt_crb; /* Crb to use */
1039} nx_cardrsp_sds_ring_t; 1022} nx_cardrsp_sds_ring_t;
1040 1023
1041typedef struct { 1024typedef struct {
1042 /* These ring offsets are relative to data[0] below */ 1025 /* These ring offsets are relative to data[0] below */
1043 u32 rds_ring_offset; /* Offset to RDS config */ 1026 __le32 rds_ring_offset; /* Offset to RDS config */
1044 u32 sds_ring_offset; /* Offset to SDS config */ 1027 __le32 sds_ring_offset; /* Offset to SDS config */
1045 u32 host_ctx_state; /* Starting State */ 1028 __le32 host_ctx_state; /* Starting State */
1046 u32 num_fn_per_port; /* How many PCI fn share the port */ 1029 __le32 num_fn_per_port; /* How many PCI fn share the port */
1047 u16 num_rds_rings; /* Count of RDS rings */ 1030 __le16 num_rds_rings; /* Count of RDS rings */
1048 u16 num_sds_rings; /* Count of SDS rings */ 1031 __le16 num_sds_rings; /* Count of SDS rings */
1049 u16 context_id; /* Handle for context */ 1032 __le16 context_id; /* Handle for context */
1050 u8 phys_port; /* Physical id of port */ 1033 u8 phys_port; /* Physical id of port */
1051 u8 virt_port; /* Virtual/Logical id of port */ 1034 u8 virt_port; /* Virtual/Logical id of port */
1052 u8 reserved[128]; /* save space for future expansion */ 1035 u8 reserved[128]; /* save space for future expansion */
@@ -1072,34 +1055,34 @@ typedef struct {
1072 */ 1055 */
1073 1056
1074typedef struct { 1057typedef struct {
1075 u64 host_phys_addr; /* Ring base addr */ 1058 __le64 host_phys_addr; /* Ring base addr */
1076 u32 ring_size; /* Ring entries */ 1059 __le32 ring_size; /* Ring entries */
1077 u32 rsvd; /* Padding */ 1060 __le32 rsvd; /* Padding */
1078} nx_hostrq_cds_ring_t; 1061} nx_hostrq_cds_ring_t;
1079 1062
1080typedef struct { 1063typedef struct {
1081 u64 host_rsp_dma_addr; /* Response dma'd here */ 1064 __le64 host_rsp_dma_addr; /* Response dma'd here */
1082 u64 cmd_cons_dma_addr; /* */ 1065 __le64 cmd_cons_dma_addr; /* */
1083 u64 dummy_dma_addr; /* */ 1066 __le64 dummy_dma_addr; /* */
1084 u32 capabilities[4]; /* Flag bit vector */ 1067 __le32 capabilities[4]; /* Flag bit vector */
1085 u32 host_int_crb_mode; /* Interrupt crb usage */ 1068 __le32 host_int_crb_mode; /* Interrupt crb usage */
1086 u32 rsvd1; /* Padding */ 1069 __le32 rsvd1; /* Padding */
1087 u16 rsvd2; /* Padding */ 1070 __le16 rsvd2; /* Padding */
1088 u16 interrupt_ctl; 1071 __le16 interrupt_ctl;
1089 u16 msi_index; 1072 __le16 msi_index;
1090 u16 rsvd3; /* Padding */ 1073 __le16 rsvd3; /* Padding */
1091 nx_hostrq_cds_ring_t cds_ring; /* Desc of cds ring */ 1074 nx_hostrq_cds_ring_t cds_ring; /* Desc of cds ring */
1092 u8 reserved[128]; /* future expansion */ 1075 u8 reserved[128]; /* future expansion */
1093} nx_hostrq_tx_ctx_t; 1076} nx_hostrq_tx_ctx_t;
1094 1077
1095typedef struct { 1078typedef struct {
1096 u32 host_producer_crb; /* Crb to use */ 1079 __le32 host_producer_crb; /* Crb to use */
1097 u32 interrupt_crb; /* Crb to use */ 1080 __le32 interrupt_crb; /* Crb to use */
1098} nx_cardrsp_cds_ring_t; 1081} nx_cardrsp_cds_ring_t;
1099 1082
1100typedef struct { 1083typedef struct {
1101 u32 host_ctx_state; /* Starting state */ 1084 __le32 host_ctx_state; /* Starting state */
1102 u16 context_id; /* Handle for context */ 1085 __le16 context_id; /* Handle for context */
1103 u8 phys_port; /* Physical id of port */ 1086 u8 phys_port; /* Physical id of port */
1104 u8 virt_port; /* Virtual/Logical id of port */ 1087 u8 virt_port; /* Virtual/Logical id of port */
1105 nx_cardrsp_cds_ring_t cds_ring; /* Card cds settings */ 1088 nx_cardrsp_cds_ring_t cds_ring; /* Card cds settings */
@@ -1202,9 +1185,9 @@ enum {
1202#define VPORT_MISS_MODE_ACCEPT_MULTI 2 /* accept unmatched multicast */ 1185#define VPORT_MISS_MODE_ACCEPT_MULTI 2 /* accept unmatched multicast */
1203 1186
1204typedef struct { 1187typedef struct {
1205 u64 qhdr; 1188 __le64 qhdr;
1206 u64 req_hdr; 1189 __le64 req_hdr;
1207 u64 words[6]; 1190 __le64 words[6];
1208} nx_nic_req_t; 1191} nx_nic_req_t;
1209 1192
1210typedef struct { 1193typedef struct {
@@ -1486,8 +1469,6 @@ void netxen_release_tx_buffers(struct netxen_adapter *adapter);
1486 1469
1487void netxen_initialize_adapter_ops(struct netxen_adapter *adapter); 1470void netxen_initialize_adapter_ops(struct netxen_adapter *adapter);
1488int netxen_init_firmware(struct netxen_adapter *adapter); 1471int netxen_init_firmware(struct netxen_adapter *adapter);
1489void netxen_tso_check(struct netxen_adapter *adapter,
1490 struct cmd_desc_type0 *desc, struct sk_buff *skb);
1491void netxen_nic_clear_stats(struct netxen_adapter *adapter); 1472void netxen_nic_clear_stats(struct netxen_adapter *adapter);
1492void netxen_watchdog_task(struct work_struct *work); 1473void netxen_watchdog_task(struct work_struct *work);
1493void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, 1474void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx,
@@ -1496,6 +1477,7 @@ int netxen_process_cmd_ring(struct netxen_adapter *adapter);
1496u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max); 1477u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max);
1497void netxen_p2_nic_set_multi(struct net_device *netdev); 1478void netxen_p2_nic_set_multi(struct net_device *netdev);
1498void netxen_p3_nic_set_multi(struct net_device *netdev); 1479void netxen_p3_nic_set_multi(struct net_device *netdev);
1480void netxen_p3_free_mac_list(struct netxen_adapter *adapter);
1499int netxen_p3_nic_set_promisc(struct netxen_adapter *adapter, u32); 1481int netxen_p3_nic_set_promisc(struct netxen_adapter *adapter, u32);
1500int netxen_config_intr_coalesce(struct netxen_adapter *adapter); 1482int netxen_config_intr_coalesce(struct netxen_adapter *adapter);
1501 1483
diff --git a/drivers/net/netxen/netxen_nic_ctx.c b/drivers/net/netxen/netxen_nic_ctx.c
index 64b51643c626..746bdb470418 100644
--- a/drivers/net/netxen/netxen_nic_ctx.c
+++ b/drivers/net/netxen/netxen_nic_ctx.c
@@ -76,7 +76,7 @@ netxen_api_unlock(struct netxen_adapter *adapter)
76static u32 76static u32
77netxen_poll_rsp(struct netxen_adapter *adapter) 77netxen_poll_rsp(struct netxen_adapter *adapter)
78{ 78{
79 u32 raw_rsp, rsp = NX_CDRP_RSP_OK; 79 u32 rsp = NX_CDRP_RSP_OK;
80 int timeout = 0; 80 int timeout = 0;
81 81
82 do { 82 do {
@@ -86,10 +86,7 @@ netxen_poll_rsp(struct netxen_adapter *adapter)
86 if (++timeout > NX_OS_CRB_RETRY_COUNT) 86 if (++timeout > NX_OS_CRB_RETRY_COUNT)
87 return NX_CDRP_RSP_TIMEOUT; 87 return NX_CDRP_RSP_TIMEOUT;
88 88
89 netxen_nic_read_w1(adapter, NX_CDRP_CRB_OFFSET, 89 netxen_nic_read_w1(adapter, NX_CDRP_CRB_OFFSET, &rsp);
90 &raw_rsp);
91
92 rsp = le32_to_cpu(raw_rsp);
93 } while (!NX_CDRP_IS_RSP(rsp)); 90 } while (!NX_CDRP_IS_RSP(rsp));
94 91
95 return rsp; 92 return rsp;
@@ -109,20 +106,16 @@ netxen_issue_cmd(struct netxen_adapter *adapter,
109 if (netxen_api_lock(adapter)) 106 if (netxen_api_lock(adapter))
110 return NX_RCODE_TIMEOUT; 107 return NX_RCODE_TIMEOUT;
111 108
112 netxen_nic_write_w1(adapter, NX_SIGN_CRB_OFFSET, 109 netxen_nic_write_w1(adapter, NX_SIGN_CRB_OFFSET, signature);
113 cpu_to_le32(signature));
114 110
115 netxen_nic_write_w1(adapter, NX_ARG1_CRB_OFFSET, 111 netxen_nic_write_w1(adapter, NX_ARG1_CRB_OFFSET, arg1);
116 cpu_to_le32(arg1));
117 112
118 netxen_nic_write_w1(adapter, NX_ARG2_CRB_OFFSET, 113 netxen_nic_write_w1(adapter, NX_ARG2_CRB_OFFSET, arg2);
119 cpu_to_le32(arg2));
120 114
121 netxen_nic_write_w1(adapter, NX_ARG3_CRB_OFFSET, 115 netxen_nic_write_w1(adapter, NX_ARG3_CRB_OFFSET, arg3);
122 cpu_to_le32(arg3));
123 116
124 netxen_nic_write_w1(adapter, NX_CDRP_CRB_OFFSET, 117 netxen_nic_write_w1(adapter, NX_CDRP_CRB_OFFSET,
125 cpu_to_le32(NX_CDRP_FORM_CMD(cmd))); 118 NX_CDRP_FORM_CMD(cmd));
126 119
127 rsp = netxen_poll_rsp(adapter); 120 rsp = netxen_poll_rsp(adapter);
128 121
@@ -133,7 +126,6 @@ netxen_issue_cmd(struct netxen_adapter *adapter,
133 rcode = NX_RCODE_TIMEOUT; 126 rcode = NX_RCODE_TIMEOUT;
134 } else if (rsp == NX_CDRP_RSP_FAIL) { 127 } else if (rsp == NX_CDRP_RSP_FAIL) {
135 netxen_nic_read_w1(adapter, NX_ARG1_CRB_OFFSET, &rcode); 128 netxen_nic_read_w1(adapter, NX_ARG1_CRB_OFFSET, &rcode);
136 rcode = le32_to_cpu(rcode);
137 129
138 printk(KERN_ERR "%s: failed card response code:0x%x\n", 130 printk(KERN_ERR "%s: failed card response code:0x%x\n",
139 netxen_nic_driver_name, rcode); 131 netxen_nic_driver_name, rcode);
@@ -183,7 +175,7 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
183 175
184 int i, nrds_rings, nsds_rings; 176 int i, nrds_rings, nsds_rings;
185 size_t rq_size, rsp_size; 177 size_t rq_size, rsp_size;
186 u32 cap, reg; 178 u32 cap, reg, val;
187 179
188 int err; 180 int err;
189 181
@@ -225,11 +217,14 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
225 217
226 prq->num_rds_rings = cpu_to_le16(nrds_rings); 218 prq->num_rds_rings = cpu_to_le16(nrds_rings);
227 prq->num_sds_rings = cpu_to_le16(nsds_rings); 219 prq->num_sds_rings = cpu_to_le16(nsds_rings);
228 prq->rds_ring_offset = 0; 220 prq->rds_ring_offset = cpu_to_le32(0);
229 prq->sds_ring_offset = prq->rds_ring_offset + 221
222 val = le32_to_cpu(prq->rds_ring_offset) +
230 (sizeof(nx_hostrq_rds_ring_t) * nrds_rings); 223 (sizeof(nx_hostrq_rds_ring_t) * nrds_rings);
224 prq->sds_ring_offset = cpu_to_le32(val);
231 225
232 prq_rds = (nx_hostrq_rds_ring_t *)(prq->data + prq->rds_ring_offset); 226 prq_rds = (nx_hostrq_rds_ring_t *)(prq->data +
227 le32_to_cpu(prq->rds_ring_offset));
233 228
234 for (i = 0; i < nrds_rings; i++) { 229 for (i = 0; i < nrds_rings; i++) {
235 230
@@ -241,17 +236,14 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
241 prq_rds[i].buff_size = cpu_to_le64(rds_ring->dma_size); 236 prq_rds[i].buff_size = cpu_to_le64(rds_ring->dma_size);
242 } 237 }
243 238
244 prq_sds = (nx_hostrq_sds_ring_t *)(prq->data + prq->sds_ring_offset); 239 prq_sds = (nx_hostrq_sds_ring_t *)(prq->data +
240 le32_to_cpu(prq->sds_ring_offset));
245 241
246 prq_sds[0].host_phys_addr = 242 prq_sds[0].host_phys_addr =
247 cpu_to_le64(recv_ctx->rcv_status_desc_phys_addr); 243 cpu_to_le64(recv_ctx->rcv_status_desc_phys_addr);
248 prq_sds[0].ring_size = cpu_to_le32(adapter->max_rx_desc_count); 244 prq_sds[0].ring_size = cpu_to_le32(adapter->max_rx_desc_count);
249 /* only one msix vector for now */ 245 /* only one msix vector for now */
250 prq_sds[0].msi_index = cpu_to_le32(0); 246 prq_sds[0].msi_index = cpu_to_le16(0);
251
252 /* now byteswap offsets */
253 prq->rds_ring_offset = cpu_to_le32(prq->rds_ring_offset);
254 prq->sds_ring_offset = cpu_to_le32(prq->sds_ring_offset);
255 247
256 phys_addr = hostrq_phys_addr; 248 phys_addr = hostrq_phys_addr;
257 err = netxen_issue_cmd(adapter, 249 err = netxen_issue_cmd(adapter,
@@ -269,9 +261,9 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
269 261
270 262
271 prsp_rds = ((nx_cardrsp_rds_ring_t *) 263 prsp_rds = ((nx_cardrsp_rds_ring_t *)
272 &prsp->data[prsp->rds_ring_offset]); 264 &prsp->data[le32_to_cpu(prsp->rds_ring_offset)]);
273 265
274 for (i = 0; i < le32_to_cpu(prsp->num_rds_rings); i++) { 266 for (i = 0; i < le16_to_cpu(prsp->num_rds_rings); i++) {
275 rds_ring = &recv_ctx->rds_rings[i]; 267 rds_ring = &recv_ctx->rds_rings[i];
276 268
277 reg = le32_to_cpu(prsp_rds[i].host_producer_crb); 269 reg = le32_to_cpu(prsp_rds[i].host_producer_crb);
@@ -279,7 +271,7 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
279 } 271 }
280 272
281 prsp_sds = ((nx_cardrsp_sds_ring_t *) 273 prsp_sds = ((nx_cardrsp_sds_ring_t *)
282 &prsp->data[prsp->sds_ring_offset]); 274 &prsp->data[le32_to_cpu(prsp->sds_ring_offset)]);
283 reg = le32_to_cpu(prsp_sds[0].host_consumer_crb); 275 reg = le32_to_cpu(prsp_sds[0].host_consumer_crb);
284 recv_ctx->crb_sts_consumer = NETXEN_NIC_REG(reg - 0x200); 276 recv_ctx->crb_sts_consumer = NETXEN_NIC_REG(reg - 0x200);
285 277
@@ -288,7 +280,7 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
288 280
289 recv_ctx->state = le32_to_cpu(prsp->host_ctx_state); 281 recv_ctx->state = le32_to_cpu(prsp->host_ctx_state);
290 recv_ctx->context_id = le16_to_cpu(prsp->context_id); 282 recv_ctx->context_id = le16_to_cpu(prsp->context_id);
291 recv_ctx->virt_port = le16_to_cpu(prsp->virt_port); 283 recv_ctx->virt_port = prsp->virt_port;
292 284
293out_free_rsp: 285out_free_rsp:
294 pci_free_consistent(adapter->pdev, rsp_size, prsp, cardrsp_phys_addr); 286 pci_free_consistent(adapter->pdev, rsp_size, prsp, cardrsp_phys_addr);
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c
index e45ce2951729..c0bd40fcf708 100644
--- a/drivers/net/netxen/netxen_nic_ethtool.c
+++ b/drivers/net/netxen/netxen_nic_ethtool.c
@@ -136,11 +136,9 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
136 136
137 ecmd->port = PORT_TP; 137 ecmd->port = PORT_TP;
138 138
139 if (netif_running(dev)) { 139 ecmd->speed = adapter->link_speed;
140 ecmd->speed = adapter->link_speed; 140 ecmd->duplex = adapter->link_duplex;
141 ecmd->duplex = adapter->link_duplex; 141 ecmd->autoneg = adapter->link_autoneg;
142 ecmd->autoneg = adapter->link_autoneg;
143 }
144 142
145 } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { 143 } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
146 u32 val; 144 u32 val;
@@ -171,7 +169,7 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
171 } else 169 } else
172 return -EIO; 170 return -EIO;
173 171
174 ecmd->phy_address = adapter->portnum; 172 ecmd->phy_address = adapter->physical_port;
175 ecmd->transceiver = XCVR_EXTERNAL; 173 ecmd->transceiver = XCVR_EXTERNAL;
176 174
177 switch ((netxen_brdtype_t) boardinfo->board_type) { 175 switch ((netxen_brdtype_t) boardinfo->board_type) {
@@ -180,13 +178,13 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
180 case NETXEN_BRDTYPE_P3_REF_QG: 178 case NETXEN_BRDTYPE_P3_REF_QG:
181 case NETXEN_BRDTYPE_P3_4_GB: 179 case NETXEN_BRDTYPE_P3_4_GB:
182 case NETXEN_BRDTYPE_P3_4_GB_MM: 180 case NETXEN_BRDTYPE_P3_4_GB_MM:
183 case NETXEN_BRDTYPE_P3_10000_BASE_T:
184 181
185 ecmd->supported |= SUPPORTED_Autoneg; 182 ecmd->supported |= SUPPORTED_Autoneg;
186 ecmd->advertising |= ADVERTISED_Autoneg; 183 ecmd->advertising |= ADVERTISED_Autoneg;
187 case NETXEN_BRDTYPE_P2_SB31_10G_CX4: 184 case NETXEN_BRDTYPE_P2_SB31_10G_CX4:
188 case NETXEN_BRDTYPE_P3_10G_CX4: 185 case NETXEN_BRDTYPE_P3_10G_CX4:
189 case NETXEN_BRDTYPE_P3_10G_CX4_LP: 186 case NETXEN_BRDTYPE_P3_10G_CX4_LP:
187 case NETXEN_BRDTYPE_P3_10000_BASE_T:
190 ecmd->supported |= SUPPORTED_TP; 188 ecmd->supported |= SUPPORTED_TP;
191 ecmd->advertising |= ADVERTISED_TP; 189 ecmd->advertising |= ADVERTISED_TP;
192 ecmd->port = PORT_TP; 190 ecmd->port = PORT_TP;
@@ -204,16 +202,33 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
204 ecmd->port = PORT_FIBRE; 202 ecmd->port = PORT_FIBRE;
205 ecmd->autoneg = AUTONEG_DISABLE; 203 ecmd->autoneg = AUTONEG_DISABLE;
206 break; 204 break;
207 case NETXEN_BRDTYPE_P2_SB31_10G:
208 case NETXEN_BRDTYPE_P3_10G_SFP_PLUS: 205 case NETXEN_BRDTYPE_P3_10G_SFP_PLUS:
209 case NETXEN_BRDTYPE_P3_10G_SFP_CT: 206 case NETXEN_BRDTYPE_P3_10G_SFP_CT:
210 case NETXEN_BRDTYPE_P3_10G_SFP_QT: 207 case NETXEN_BRDTYPE_P3_10G_SFP_QT:
208 ecmd->advertising |= ADVERTISED_TP;
209 ecmd->supported |= SUPPORTED_TP;
210 case NETXEN_BRDTYPE_P2_SB31_10G:
211 case NETXEN_BRDTYPE_P3_10G_XFP: 211 case NETXEN_BRDTYPE_P3_10G_XFP:
212 ecmd->supported |= SUPPORTED_FIBRE; 212 ecmd->supported |= SUPPORTED_FIBRE;
213 ecmd->advertising |= ADVERTISED_FIBRE; 213 ecmd->advertising |= ADVERTISED_FIBRE;
214 ecmd->port = PORT_FIBRE; 214 ecmd->port = PORT_FIBRE;
215 ecmd->autoneg = AUTONEG_DISABLE; 215 ecmd->autoneg = AUTONEG_DISABLE;
216 break; 216 break;
217 case NETXEN_BRDTYPE_P3_10G_TP:
218 if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
219 ecmd->autoneg = AUTONEG_DISABLE;
220 ecmd->supported |= (SUPPORTED_FIBRE | SUPPORTED_TP);
221 ecmd->advertising |=
222 (ADVERTISED_FIBRE | ADVERTISED_TP);
223 ecmd->port = PORT_FIBRE;
224 } else {
225 ecmd->autoneg = AUTONEG_ENABLE;
226 ecmd->supported |= (SUPPORTED_TP |SUPPORTED_Autoneg);
227 ecmd->advertising |=
228 (ADVERTISED_TP | ADVERTISED_Autoneg);
229 ecmd->port = PORT_TP;
230 }
231 break;
217 default: 232 default:
218 printk(KERN_ERR "netxen-nic: Unsupported board model %d\n", 233 printk(KERN_ERR "netxen-nic: Unsupported board model %d\n",
219 (netxen_brdtype_t) boardinfo->board_type); 234 (netxen_brdtype_t) boardinfo->board_type);
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
index aa6e603bfcbf..821cff68b3f3 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -503,17 +503,15 @@ netxen_send_cmd_descs(struct netxen_adapter *adapter,
503 503
504 i = 0; 504 i = 0;
505 505
506 netif_tx_lock_bh(adapter->netdev);
507
506 producer = adapter->cmd_producer; 508 producer = adapter->cmd_producer;
507 do { 509 do {
508 cmd_desc = &cmd_desc_arr[i]; 510 cmd_desc = &cmd_desc_arr[i];
509 511
510 pbuf = &adapter->cmd_buf_arr[producer]; 512 pbuf = &adapter->cmd_buf_arr[producer];
511 pbuf->mss = 0;
512 pbuf->total_length = 0;
513 pbuf->skb = NULL; 513 pbuf->skb = NULL;
514 pbuf->cmd = 0;
515 pbuf->frag_count = 0; 514 pbuf->frag_count = 0;
516 pbuf->port = 0;
517 515
518 /* adapter->ahw.cmd_desc_head[producer] = *cmd_desc; */ 516 /* adapter->ahw.cmd_desc_head[producer] = *cmd_desc; */
519 memcpy(&adapter->ahw.cmd_desc_head[producer], 517 memcpy(&adapter->ahw.cmd_desc_head[producer],
@@ -531,6 +529,8 @@ netxen_send_cmd_descs(struct netxen_adapter *adapter,
531 529
532 netxen_nic_update_cmd_producer(adapter, adapter->cmd_producer); 530 netxen_nic_update_cmd_producer(adapter, adapter->cmd_producer);
533 531
532 netif_tx_unlock_bh(adapter->netdev);
533
534 return 0; 534 return 0;
535} 535}
536 536
@@ -539,16 +539,19 @@ static int nx_p3_sre_macaddr_change(struct net_device *dev,
539{ 539{
540 struct netxen_adapter *adapter = netdev_priv(dev); 540 struct netxen_adapter *adapter = netdev_priv(dev);
541 nx_nic_req_t req; 541 nx_nic_req_t req;
542 nx_mac_req_t mac_req; 542 nx_mac_req_t *mac_req;
543 u64 word;
543 int rv; 544 int rv;
544 545
545 memset(&req, 0, sizeof(nx_nic_req_t)); 546 memset(&req, 0, sizeof(nx_nic_req_t));
546 req.qhdr |= (NX_NIC_REQUEST << 23); 547 req.qhdr = cpu_to_le64(NX_NIC_REQUEST << 23);
547 req.req_hdr |= NX_MAC_EVENT; 548
548 req.req_hdr |= ((u64)adapter->portnum << 16); 549 word = NX_MAC_EVENT | ((u64)adapter->portnum << 16);
549 mac_req.op = op; 550 req.req_hdr = cpu_to_le64(word);
550 memcpy(&mac_req.mac_addr, addr, 6); 551
551 req.words[0] = cpu_to_le64(*(u64 *)&mac_req); 552 mac_req = (nx_mac_req_t *)&req.words[0];
553 mac_req->op = op;
554 memcpy(mac_req->mac_addr, addr, 6);
552 555
553 rv = netxen_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1); 556 rv = netxen_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1);
554 if (rv != 0) { 557 if (rv != 0) {
@@ -612,18 +615,35 @@ send_fw_cmd:
612int netxen_p3_nic_set_promisc(struct netxen_adapter *adapter, u32 mode) 615int netxen_p3_nic_set_promisc(struct netxen_adapter *adapter, u32 mode)
613{ 616{
614 nx_nic_req_t req; 617 nx_nic_req_t req;
618 u64 word;
615 619
616 memset(&req, 0, sizeof(nx_nic_req_t)); 620 memset(&req, 0, sizeof(nx_nic_req_t));
617 621
618 req.qhdr |= (NX_HOST_REQUEST << 23); 622 req.qhdr = cpu_to_le64(NX_HOST_REQUEST << 23);
619 req.req_hdr |= NX_NIC_H2C_OPCODE_PROXY_SET_VPORT_MISS_MODE; 623
620 req.req_hdr |= ((u64)adapter->portnum << 16); 624 word = NX_NIC_H2C_OPCODE_PROXY_SET_VPORT_MISS_MODE |
625 ((u64)adapter->portnum << 16);
626 req.req_hdr = cpu_to_le64(word);
627
621 req.words[0] = cpu_to_le64(mode); 628 req.words[0] = cpu_to_le64(mode);
622 629
623 return netxen_send_cmd_descs(adapter, 630 return netxen_send_cmd_descs(adapter,
624 (struct cmd_desc_type0 *)&req, 1); 631 (struct cmd_desc_type0 *)&req, 1);
625} 632}
626 633
634void netxen_p3_free_mac_list(struct netxen_adapter *adapter)
635{
636 nx_mac_list_t *cur, *next;
637
638 cur = adapter->mac_list;
639
640 while (cur) {
641 next = cur->next;
642 kfree(cur);
643 cur = next;
644 }
645}
646
627#define NETXEN_CONFIG_INTR_COALESCE 3 647#define NETXEN_CONFIG_INTR_COALESCE 3
628 648
629/* 649/*
@@ -632,13 +652,15 @@ int netxen_p3_nic_set_promisc(struct netxen_adapter *adapter, u32 mode)
632int netxen_config_intr_coalesce(struct netxen_adapter *adapter) 652int netxen_config_intr_coalesce(struct netxen_adapter *adapter)
633{ 653{
634 nx_nic_req_t req; 654 nx_nic_req_t req;
655 u64 word;
635 int rv; 656 int rv;
636 657
637 memset(&req, 0, sizeof(nx_nic_req_t)); 658 memset(&req, 0, sizeof(nx_nic_req_t));
638 659
639 req.qhdr |= (NX_NIC_REQUEST << 23); 660 req.qhdr = cpu_to_le64(NX_NIC_REQUEST << 23);
640 req.req_hdr |= NETXEN_CONFIG_INTR_COALESCE; 661
641 req.req_hdr |= ((u64)adapter->portnum << 16); 662 word = NETXEN_CONFIG_INTR_COALESCE | ((u64)adapter->portnum << 16);
663 req.req_hdr = cpu_to_le64(word);
642 664
643 memcpy(&req.words[0], &adapter->coal, sizeof(adapter->coal)); 665 memcpy(&req.words[0], &adapter->coal, sizeof(adapter->coal));
644 666
@@ -772,13 +794,10 @@ int netxen_p3_get_mac_addr(struct netxen_adapter *adapter, __le64 *mac)
772 adapter->hw_read_wx(adapter, crbaddr, &mac_lo, 4); 794 adapter->hw_read_wx(adapter, crbaddr, &mac_lo, 4);
773 adapter->hw_read_wx(adapter, crbaddr+4, &mac_hi, 4); 795 adapter->hw_read_wx(adapter, crbaddr+4, &mac_hi, 4);
774 796
775 mac_hi = cpu_to_le32(mac_hi);
776 mac_lo = cpu_to_le32(mac_lo);
777
778 if (pci_func & 1) 797 if (pci_func & 1)
779 *mac = ((mac_lo >> 16) | ((u64)mac_hi << 16)); 798 *mac = le64_to_cpu((mac_lo >> 16) | ((u64)mac_hi << 16));
780 else 799 else
781 *mac = ((mac_lo) | ((u64)mac_hi << 32)); 800 *mac = le64_to_cpu((u64)mac_lo | ((u64)mac_hi << 32));
782 801
783 return 0; 802 return 0;
784} 803}
@@ -937,7 +956,7 @@ int netxen_load_firmware(struct netxen_adapter *adapter)
937{ 956{
938 int i; 957 int i;
939 u32 data, size = 0; 958 u32 data, size = 0;
940 u32 flashaddr = NETXEN_BOOTLD_START, memaddr = NETXEN_BOOTLD_START; 959 u32 flashaddr = NETXEN_BOOTLD_START;
941 960
942 size = (NETXEN_IMAGE_START - NETXEN_BOOTLD_START)/4; 961 size = (NETXEN_IMAGE_START - NETXEN_BOOTLD_START)/4;
943 962
@@ -949,10 +968,8 @@ int netxen_load_firmware(struct netxen_adapter *adapter)
949 if (netxen_rom_fast_read(adapter, flashaddr, (int *)&data) != 0) 968 if (netxen_rom_fast_read(adapter, flashaddr, (int *)&data) != 0)
950 return -EIO; 969 return -EIO;
951 970
952 adapter->pci_mem_write(adapter, memaddr, &data, 4); 971 adapter->pci_mem_write(adapter, flashaddr, &data, 4);
953 flashaddr += 4; 972 flashaddr += 4;
954 memaddr += 4;
955 cond_resched();
956 } 973 }
957 msleep(1); 974 msleep(1);
958 975
@@ -2034,7 +2051,13 @@ int netxen_nic_get_board_info(struct netxen_adapter *adapter)
2034 rv = -1; 2051 rv = -1;
2035 } 2052 }
2036 2053
2037 DPRINTK(INFO, "Discovered board type:0x%x ", boardinfo->board_type); 2054 if (boardinfo->board_type == NETXEN_BRDTYPE_P3_4_GB_MM) {
2055 u32 gpio = netxen_nic_reg_read(adapter,
2056 NETXEN_ROMUSB_GLB_PAD_GPIO_I);
2057 if ((gpio & 0x8000) == 0)
2058 boardinfo->board_type = NETXEN_BRDTYPE_P3_10G_TP;
2059 }
2060
2038 switch ((netxen_brdtype_t) boardinfo->board_type) { 2061 switch ((netxen_brdtype_t) boardinfo->board_type) {
2039 case NETXEN_BRDTYPE_P2_SB35_4G: 2062 case NETXEN_BRDTYPE_P2_SB35_4G:
2040 adapter->ahw.board_type = NETXEN_NIC_GBE; 2063 adapter->ahw.board_type = NETXEN_NIC_GBE;
@@ -2053,7 +2076,6 @@ int netxen_nic_get_board_info(struct netxen_adapter *adapter)
2053 case NETXEN_BRDTYPE_P3_10G_SFP_QT: 2076 case NETXEN_BRDTYPE_P3_10G_SFP_QT:
2054 case NETXEN_BRDTYPE_P3_10G_XFP: 2077 case NETXEN_BRDTYPE_P3_10G_XFP:
2055 case NETXEN_BRDTYPE_P3_10000_BASE_T: 2078 case NETXEN_BRDTYPE_P3_10000_BASE_T:
2056
2057 adapter->ahw.board_type = NETXEN_NIC_XGBE; 2079 adapter->ahw.board_type = NETXEN_NIC_XGBE;
2058 break; 2080 break;
2059 case NETXEN_BRDTYPE_P1_BD: 2081 case NETXEN_BRDTYPE_P1_BD:
@@ -2063,9 +2085,12 @@ int netxen_nic_get_board_info(struct netxen_adapter *adapter)
2063 case NETXEN_BRDTYPE_P3_REF_QG: 2085 case NETXEN_BRDTYPE_P3_REF_QG:
2064 case NETXEN_BRDTYPE_P3_4_GB: 2086 case NETXEN_BRDTYPE_P3_4_GB:
2065 case NETXEN_BRDTYPE_P3_4_GB_MM: 2087 case NETXEN_BRDTYPE_P3_4_GB_MM:
2066
2067 adapter->ahw.board_type = NETXEN_NIC_GBE; 2088 adapter->ahw.board_type = NETXEN_NIC_GBE;
2068 break; 2089 break;
2090 case NETXEN_BRDTYPE_P3_10G_TP:
2091 adapter->ahw.board_type = (adapter->portnum < 2) ?
2092 NETXEN_NIC_XGBE : NETXEN_NIC_GBE;
2093 break;
2069 default: 2094 default:
2070 printk("%s: Unknown(%x)\n", netxen_nic_driver_name, 2095 printk("%s: Unknown(%x)\n", netxen_nic_driver_name,
2071 boardinfo->board_type); 2096 boardinfo->board_type);
@@ -2110,12 +2135,16 @@ void netxen_nic_set_link_parameters(struct netxen_adapter *adapter)
2110{ 2135{
2111 __u32 status; 2136 __u32 status;
2112 __u32 autoneg; 2137 __u32 autoneg;
2113 __u32 mode;
2114 __u32 port_mode; 2138 __u32 port_mode;
2115 2139
2116 netxen_nic_read_w0(adapter, NETXEN_NIU_MODE, &mode); 2140 if (!netif_carrier_ok(adapter->netdev)) {
2117 if (netxen_get_niu_enable_ge(mode)) { /* Gb 10/100/1000 Mbps mode */ 2141 adapter->link_speed = 0;
2142 adapter->link_duplex = -1;
2143 adapter->link_autoneg = AUTONEG_ENABLE;
2144 return;
2145 }
2118 2146
2147 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
2119 adapter->hw_read_wx(adapter, 2148 adapter->hw_read_wx(adapter,
2120 NETXEN_PORT_MODE_ADDR, &port_mode, 4); 2149 NETXEN_PORT_MODE_ADDR, &port_mode, 4);
2121 if (port_mode == NETXEN_PORT_MODE_802_3_AP) { 2150 if (port_mode == NETXEN_PORT_MODE_802_3_AP) {
@@ -2141,7 +2170,7 @@ void netxen_nic_set_link_parameters(struct netxen_adapter *adapter)
2141 adapter->link_speed = SPEED_1000; 2170 adapter->link_speed = SPEED_1000;
2142 break; 2171 break;
2143 default: 2172 default:
2144 adapter->link_speed = -1; 2173 adapter->link_speed = 0;
2145 break; 2174 break;
2146 } 2175 }
2147 switch (netxen_get_phy_duplex(status)) { 2176 switch (netxen_get_phy_duplex(status)) {
@@ -2164,7 +2193,7 @@ void netxen_nic_set_link_parameters(struct netxen_adapter *adapter)
2164 goto link_down; 2193 goto link_down;
2165 } else { 2194 } else {
2166 link_down: 2195 link_down:
2167 adapter->link_speed = -1; 2196 adapter->link_speed = 0;
2168 adapter->link_duplex = -1; 2197 adapter->link_duplex = -1;
2169 } 2198 }
2170 } 2199 }
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index d924468e506e..ca7c8d8050c9 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -308,7 +308,6 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
308 } 308 }
309 memset(rds_ring->rx_buf_arr, 0, RCV_BUFFSIZE); 309 memset(rds_ring->rx_buf_arr, 0, RCV_BUFFSIZE);
310 INIT_LIST_HEAD(&rds_ring->free_list); 310 INIT_LIST_HEAD(&rds_ring->free_list);
311 rds_ring->begin_alloc = 0;
312 /* 311 /*
313 * Now go through all of them, set reference handles 312 * Now go through all of them, set reference handles
314 * and put them in the queues. 313 * and put them in the queues.
@@ -439,6 +438,8 @@ static int netxen_wait_rom_done(struct netxen_adapter *adapter)
439 long timeout = 0; 438 long timeout = 0;
440 long done = 0; 439 long done = 0;
441 440
441 cond_resched();
442
442 while (done == 0) { 443 while (done == 0) {
443 done = netxen_nic_reg_read(adapter, NETXEN_ROMUSB_GLB_STATUS); 444 done = netxen_nic_reg_read(adapter, NETXEN_ROMUSB_GLB_STATUS);
444 done &= 2; 445 done &= 2;
@@ -533,12 +534,9 @@ static int do_rom_fast_write(struct netxen_adapter *adapter, int addr,
533static int do_rom_fast_read(struct netxen_adapter *adapter, 534static int do_rom_fast_read(struct netxen_adapter *adapter,
534 int addr, int *valp) 535 int addr, int *valp)
535{ 536{
536 cond_resched();
537
538 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ADDRESS, addr); 537 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ADDRESS, addr);
539 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 3);
540 udelay(100); /* prevent bursting on CRB */
541 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT, 0); 538 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT, 0);
539 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 3);
542 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE, 0xb); 540 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE, 0xb);
543 if (netxen_wait_rom_done(adapter)) { 541 if (netxen_wait_rom_done(adapter)) {
544 printk("Error waiting for rom done\n"); 542 printk("Error waiting for rom done\n");
@@ -546,7 +544,7 @@ static int do_rom_fast_read(struct netxen_adapter *adapter,
546 } 544 }
547 /* reset abyte_cnt and dummy_byte_cnt */ 545 /* reset abyte_cnt and dummy_byte_cnt */
548 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0); 546 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0);
549 udelay(100); /* prevent bursting on CRB */ 547 udelay(10);
550 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT, 0); 548 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT, 0);
551 549
552 *valp = netxen_nic_reg_read(adapter, NETXEN_ROMUSB_ROM_RDATA); 550 *valp = netxen_nic_reg_read(adapter, NETXEN_ROMUSB_ROM_RDATA);
@@ -884,14 +882,16 @@ int netxen_flash_unlock(struct netxen_adapter *adapter)
884int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose) 882int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
885{ 883{
886 int addr, val; 884 int addr, val;
887 int i, init_delay = 0; 885 int i, n, init_delay = 0;
888 struct crb_addr_pair *buf; 886 struct crb_addr_pair *buf;
889 unsigned offset, n; 887 unsigned offset;
890 u32 off; 888 u32 off;
891 889
892 /* resetall */ 890 /* resetall */
891 rom_lock(adapter);
893 netxen_crb_writelit_adapter(adapter, NETXEN_ROMUSB_GLB_SW_RESET, 892 netxen_crb_writelit_adapter(adapter, NETXEN_ROMUSB_GLB_SW_RESET,
894 0xffffffff); 893 0xffffffff);
894 netxen_rom_unlock(adapter);
895 895
896 if (verbose) { 896 if (verbose) {
897 if (netxen_rom_fast_read(adapter, NETXEN_BOARDTYPE, &val) == 0) 897 if (netxen_rom_fast_read(adapter, NETXEN_BOARDTYPE, &val) == 0)
@@ -910,7 +910,7 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
910 910
911 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { 911 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
912 if (netxen_rom_fast_read(adapter, 0, &n) != 0 || 912 if (netxen_rom_fast_read(adapter, 0, &n) != 0 ||
913 (n != 0xcafecafeUL) || 913 (n != 0xcafecafe) ||
914 netxen_rom_fast_read(adapter, 4, &n) != 0) { 914 netxen_rom_fast_read(adapter, 4, &n) != 0) {
915 printk(KERN_ERR "%s: ERROR Reading crb_init area: " 915 printk(KERN_ERR "%s: ERROR Reading crb_init area: "
916 "n: %08x\n", netxen_nic_driver_name, n); 916 "n: %08x\n", netxen_nic_driver_name, n);
@@ -975,6 +975,14 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
975 /* do not reset PCI */ 975 /* do not reset PCI */
976 if (off == (ROMUSB_GLB + 0xbc)) 976 if (off == (ROMUSB_GLB + 0xbc))
977 continue; 977 continue;
978 if (off == (ROMUSB_GLB + 0xa8))
979 continue;
980 if (off == (ROMUSB_GLB + 0xc8)) /* core clock */
981 continue;
982 if (off == (ROMUSB_GLB + 0x24)) /* MN clock */
983 continue;
984 if (off == (ROMUSB_GLB + 0x1c)) /* MS clock */
985 continue;
978 if (off == (NETXEN_CRB_PEG_NET_1 + 0x18)) 986 if (off == (NETXEN_CRB_PEG_NET_1 + 0x18))
979 buf[i].data = 0x1020; 987 buf[i].data = 0x1020;
980 /* skip the function enable register */ 988 /* skip the function enable register */
@@ -992,23 +1000,21 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
992 continue; 1000 continue;
993 } 1001 }
994 1002
1003 init_delay = 1;
995 /* After writing this register, HW needs time for CRB */ 1004 /* After writing this register, HW needs time for CRB */
996 /* to quiet down (else crb_window returns 0xffffffff) */ 1005 /* to quiet down (else crb_window returns 0xffffffff) */
997 if (off == NETXEN_ROMUSB_GLB_SW_RESET) { 1006 if (off == NETXEN_ROMUSB_GLB_SW_RESET) {
998 init_delay = 1; 1007 init_delay = 1000;
999 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { 1008 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
1000 /* hold xdma in reset also */ 1009 /* hold xdma in reset also */
1001 buf[i].data = NETXEN_NIC_XDMA_RESET; 1010 buf[i].data = NETXEN_NIC_XDMA_RESET;
1011 buf[i].data = 0x8000ff;
1002 } 1012 }
1003 } 1013 }
1004 1014
1005 adapter->hw_write_wx(adapter, off, &buf[i].data, 4); 1015 adapter->hw_write_wx(adapter, off, &buf[i].data, 4);
1006 1016
1007 if (init_delay == 1) { 1017 msleep(init_delay);
1008 msleep(1000);
1009 init_delay = 0;
1010 }
1011 msleep(1);
1012 } 1018 }
1013 kfree(buf); 1019 kfree(buf);
1014 1020
@@ -1277,7 +1283,7 @@ static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
1277 1283
1278 dev_kfree_skb_any(skb); 1284 dev_kfree_skb_any(skb);
1279 for (i = 0; i < nr_frags; i++) { 1285 for (i = 0; i < nr_frags; i++) {
1280 index = frag_desc->frag_handles[i]; 1286 index = le16_to_cpu(frag_desc->frag_handles[i]);
1281 skb = netxen_process_rxbuf(adapter, 1287 skb = netxen_process_rxbuf(adapter,
1282 rds_ring, index, cksum); 1288 rds_ring, index, cksum);
1283 if (skb) 1289 if (skb)
@@ -1428,7 +1434,6 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1428 struct rcv_desc *pdesc; 1434 struct rcv_desc *pdesc;
1429 struct netxen_rx_buffer *buffer; 1435 struct netxen_rx_buffer *buffer;
1430 int count = 0; 1436 int count = 0;
1431 int index = 0;
1432 netxen_ctx_msg msg = 0; 1437 netxen_ctx_msg msg = 0;
1433 dma_addr_t dma; 1438 dma_addr_t dma;
1434 struct list_head *head; 1439 struct list_head *head;
@@ -1436,7 +1441,6 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1436 rds_ring = &recv_ctx->rds_rings[ringid]; 1441 rds_ring = &recv_ctx->rds_rings[ringid];
1437 1442
1438 producer = rds_ring->producer; 1443 producer = rds_ring->producer;
1439 index = rds_ring->begin_alloc;
1440 head = &rds_ring->free_list; 1444 head = &rds_ring->free_list;
1441 1445
1442 /* We can start writing rx descriptors into the phantom memory. */ 1446 /* We can start writing rx descriptors into the phantom memory. */
@@ -1444,39 +1448,37 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1444 1448
1445 skb = dev_alloc_skb(rds_ring->skb_size); 1449 skb = dev_alloc_skb(rds_ring->skb_size);
1446 if (unlikely(!skb)) { 1450 if (unlikely(!skb)) {
1447 rds_ring->begin_alloc = index;
1448 break; 1451 break;
1449 } 1452 }
1450 1453
1454 if (!adapter->ahw.cut_through)
1455 skb_reserve(skb, 2);
1456
1457 dma = pci_map_single(pdev, skb->data,
1458 rds_ring->dma_size, PCI_DMA_FROMDEVICE);
1459 if (pci_dma_mapping_error(pdev, dma)) {
1460 dev_kfree_skb_any(skb);
1461 break;
1462 }
1463
1464 count++;
1451 buffer = list_entry(head->next, struct netxen_rx_buffer, list); 1465 buffer = list_entry(head->next, struct netxen_rx_buffer, list);
1452 list_del(&buffer->list); 1466 list_del(&buffer->list);
1453 1467
1454 count++; /* now there should be no failure */
1455 pdesc = &rds_ring->desc_head[producer];
1456
1457 if (!adapter->ahw.cut_through)
1458 skb_reserve(skb, 2);
1459 /* This will be setup when we receive the
1460 * buffer after it has been filled FSL TBD TBD
1461 * skb->dev = netdev;
1462 */
1463 dma = pci_map_single(pdev, skb->data, rds_ring->dma_size,
1464 PCI_DMA_FROMDEVICE);
1465 pdesc->addr_buffer = cpu_to_le64(dma);
1466 buffer->skb = skb; 1468 buffer->skb = skb;
1467 buffer->state = NETXEN_BUFFER_BUSY; 1469 buffer->state = NETXEN_BUFFER_BUSY;
1468 buffer->dma = dma; 1470 buffer->dma = dma;
1471
1469 /* make a rcv descriptor */ 1472 /* make a rcv descriptor */
1473 pdesc = &rds_ring->desc_head[producer];
1474 pdesc->addr_buffer = cpu_to_le64(dma);
1470 pdesc->reference_handle = cpu_to_le16(buffer->ref_handle); 1475 pdesc->reference_handle = cpu_to_le16(buffer->ref_handle);
1471 pdesc->buffer_length = cpu_to_le32(rds_ring->dma_size); 1476 pdesc->buffer_length = cpu_to_le32(rds_ring->dma_size);
1472 DPRINTK(INFO, "done writing descripter\n"); 1477
1473 producer = 1478 producer = get_next_index(producer, rds_ring->max_rx_desc_count);
1474 get_next_index(producer, rds_ring->max_rx_desc_count);
1475 index = get_next_index(index, rds_ring->max_rx_desc_count);
1476 } 1479 }
1477 /* if we did allocate buffers, then write the count to Phantom */ 1480 /* if we did allocate buffers, then write the count to Phantom */
1478 if (count) { 1481 if (count) {
1479 rds_ring->begin_alloc = index;
1480 rds_ring->producer = producer; 1482 rds_ring->producer = producer;
1481 /* Window = 1 */ 1483 /* Window = 1 */
1482 adapter->pci_write_normalize(adapter, 1484 adapter->pci_write_normalize(adapter,
@@ -1515,49 +1517,50 @@ static void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter,
1515 struct rcv_desc *pdesc; 1517 struct rcv_desc *pdesc;
1516 struct netxen_rx_buffer *buffer; 1518 struct netxen_rx_buffer *buffer;
1517 int count = 0; 1519 int count = 0;
1518 int index = 0;
1519 struct list_head *head; 1520 struct list_head *head;
1521 dma_addr_t dma;
1520 1522
1521 rds_ring = &recv_ctx->rds_rings[ringid]; 1523 rds_ring = &recv_ctx->rds_rings[ringid];
1522 1524
1523 producer = rds_ring->producer; 1525 producer = rds_ring->producer;
1524 index = rds_ring->begin_alloc;
1525 head = &rds_ring->free_list; 1526 head = &rds_ring->free_list;
1526 /* We can start writing rx descriptors into the phantom memory. */ 1527 /* We can start writing rx descriptors into the phantom memory. */
1527 while (!list_empty(head)) { 1528 while (!list_empty(head)) {
1528 1529
1529 skb = dev_alloc_skb(rds_ring->skb_size); 1530 skb = dev_alloc_skb(rds_ring->skb_size);
1530 if (unlikely(!skb)) { 1531 if (unlikely(!skb)) {
1531 rds_ring->begin_alloc = index;
1532 break; 1532 break;
1533 } 1533 }
1534 1534
1535 if (!adapter->ahw.cut_through)
1536 skb_reserve(skb, 2);
1537
1538 dma = pci_map_single(pdev, skb->data,
1539 rds_ring->dma_size, PCI_DMA_FROMDEVICE);
1540 if (pci_dma_mapping_error(pdev, dma)) {
1541 dev_kfree_skb_any(skb);
1542 break;
1543 }
1544
1545 count++;
1535 buffer = list_entry(head->next, struct netxen_rx_buffer, list); 1546 buffer = list_entry(head->next, struct netxen_rx_buffer, list);
1536 list_del(&buffer->list); 1547 list_del(&buffer->list);
1537 1548
1538 count++; /* now there should be no failure */
1539 pdesc = &rds_ring->desc_head[producer];
1540 if (!adapter->ahw.cut_through)
1541 skb_reserve(skb, 2);
1542 buffer->skb = skb; 1549 buffer->skb = skb;
1543 buffer->state = NETXEN_BUFFER_BUSY; 1550 buffer->state = NETXEN_BUFFER_BUSY;
1544 buffer->dma = pci_map_single(pdev, skb->data, 1551 buffer->dma = dma;
1545 rds_ring->dma_size,
1546 PCI_DMA_FROMDEVICE);
1547 1552
1548 /* make a rcv descriptor */ 1553 /* make a rcv descriptor */
1554 pdesc = &rds_ring->desc_head[producer];
1549 pdesc->reference_handle = cpu_to_le16(buffer->ref_handle); 1555 pdesc->reference_handle = cpu_to_le16(buffer->ref_handle);
1550 pdesc->buffer_length = cpu_to_le32(rds_ring->dma_size); 1556 pdesc->buffer_length = cpu_to_le32(rds_ring->dma_size);
1551 pdesc->addr_buffer = cpu_to_le64(buffer->dma); 1557 pdesc->addr_buffer = cpu_to_le64(buffer->dma);
1552 producer = 1558
1553 get_next_index(producer, rds_ring->max_rx_desc_count); 1559 producer = get_next_index(producer, rds_ring->max_rx_desc_count);
1554 index = get_next_index(index, rds_ring->max_rx_desc_count);
1555 buffer = &rds_ring->rx_buf_arr[index];
1556 } 1560 }
1557 1561
1558 /* if we did allocate buffers, then write the count to Phantom */ 1562 /* if we did allocate buffers, then write the count to Phantom */
1559 if (count) { 1563 if (count) {
1560 rds_ring->begin_alloc = index;
1561 rds_ring->producer = producer; 1564 rds_ring->producer = producer;
1562 /* Window = 1 */ 1565 /* Window = 1 */
1563 adapter->pci_write_normalize(adapter, 1566 adapter->pci_write_normalize(adapter,
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index ba01524b5531..d854f07ef4d3 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -39,7 +39,9 @@
39#include "netxen_nic_phan_reg.h" 39#include "netxen_nic_phan_reg.h"
40 40
41#include <linux/dma-mapping.h> 41#include <linux/dma-mapping.h>
42#include <linux/if_vlan.h>
42#include <net/ip.h> 43#include <net/ip.h>
44#include <linux/ipv6.h>
43 45
44MODULE_DESCRIPTION("NetXen Multi port (1/10) Gigabit Network Driver"); 46MODULE_DESCRIPTION("NetXen Multi port (1/10) Gigabit Network Driver");
45MODULE_LICENSE("GPL"); 47MODULE_LICENSE("GPL");
@@ -242,7 +244,7 @@ static void netxen_check_options(struct netxen_adapter *adapter)
242 case NETXEN_BRDTYPE_P3_4_GB: 244 case NETXEN_BRDTYPE_P3_4_GB:
243 case NETXEN_BRDTYPE_P3_4_GB_MM: 245 case NETXEN_BRDTYPE_P3_4_GB_MM:
244 adapter->msix_supported = !!use_msi_x; 246 adapter->msix_supported = !!use_msi_x;
245 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_10G; 247 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G;
246 break; 248 break;
247 249
248 case NETXEN_BRDTYPE_P2_SB35_4G: 250 case NETXEN_BRDTYPE_P2_SB35_4G:
@@ -251,6 +253,14 @@ static void netxen_check_options(struct netxen_adapter *adapter)
251 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G; 253 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G;
252 break; 254 break;
253 255
256 case NETXEN_BRDTYPE_P3_10G_TP:
257 adapter->msix_supported = !!use_msi_x;
258 if (adapter->ahw.board_type == NETXEN_NIC_XGBE)
259 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_10G;
260 else
261 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G;
262 break;
263
254 default: 264 default:
255 adapter->msix_supported = 0; 265 adapter->msix_supported = 0;
256 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G; 266 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G;
@@ -271,10 +281,15 @@ static void netxen_check_options(struct netxen_adapter *adapter)
271static int 281static int
272netxen_check_hw_init(struct netxen_adapter *adapter, int first_boot) 282netxen_check_hw_init(struct netxen_adapter *adapter, int first_boot)
273{ 283{
274 int ret = 0; 284 u32 val, timeout;
275 285
276 if (first_boot == 0x55555555) { 286 if (first_boot == 0x55555555) {
277 /* This is the first boot after power up */ 287 /* This is the first boot after power up */
288 adapter->pci_write_normalize(adapter,
289 NETXEN_CAM_RAM(0x1fc), NETXEN_BDINFO_MAGIC);
290
291 if (!NX_IS_REVISION_P2(adapter->ahw.revision_id))
292 return 0;
278 293
279 /* PCI bus master workaround */ 294 /* PCI bus master workaround */
280 adapter->hw_read_wx(adapter, 295 adapter->hw_read_wx(adapter,
@@ -294,18 +309,26 @@ netxen_check_hw_init(struct netxen_adapter *adapter, int first_boot)
294 /* clear the register for future unloads/loads */ 309 /* clear the register for future unloads/loads */
295 adapter->pci_write_normalize(adapter, 310 adapter->pci_write_normalize(adapter,
296 NETXEN_CAM_RAM(0x1fc), 0); 311 NETXEN_CAM_RAM(0x1fc), 0);
297 ret = -1; 312 return -EIO;
298 } 313 }
299 314
300 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { 315 /* Start P2 boot loader */
301 /* Start P2 boot loader */ 316 val = adapter->pci_read_normalize(adapter,
302 adapter->pci_write_normalize(adapter, 317 NETXEN_ROMUSB_GLB_PEGTUNE_DONE);
303 NETXEN_CAM_RAM(0x1fc), NETXEN_BDINFO_MAGIC); 318 adapter->pci_write_normalize(adapter,
304 adapter->pci_write_normalize(adapter, 319 NETXEN_ROMUSB_GLB_PEGTUNE_DONE, val | 0x1);
305 NETXEN_ROMUSB_GLB_PEGTUNE_DONE, 1); 320 timeout = 0;
306 } 321 do {
322 msleep(1);
323 val = adapter->pci_read_normalize(adapter,
324 NETXEN_CAM_RAM(0x1fc));
325
326 if (++timeout > 5000)
327 return -EIO;
328
329 } while (val == NETXEN_BDINFO_MAGIC);
307 } 330 }
308 return ret; 331 return 0;
309} 332}
310 333
311static void netxen_set_port_mode(struct netxen_adapter *adapter) 334static void netxen_set_port_mode(struct netxen_adapter *adapter)
@@ -784,8 +807,8 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
784 CRB_CMDPEG_STATE, 0); 807 CRB_CMDPEG_STATE, 0);
785 netxen_pinit_from_rom(adapter, 0); 808 netxen_pinit_from_rom(adapter, 0);
786 msleep(1); 809 msleep(1);
787 netxen_load_firmware(adapter);
788 } 810 }
811 netxen_load_firmware(adapter);
789 812
790 if (NX_IS_REVISION_P3(revision_id)) 813 if (NX_IS_REVISION_P3(revision_id))
791 netxen_pcie_strap_init(adapter); 814 netxen_pcie_strap_init(adapter);
@@ -801,13 +824,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
801 824
802 } 825 }
803 826
804 if ((first_boot == 0x55555555) &&
805 (NX_IS_REVISION_P2(revision_id))) {
806 /* Unlock the HW, prompting the boot sequence */
807 adapter->pci_write_normalize(adapter,
808 NETXEN_ROMUSB_GLB_PEGTUNE_DONE, 1);
809 }
810
811 err = netxen_initialize_adapter_offload(adapter); 827 err = netxen_initialize_adapter_offload(adapter);
812 if (err) 828 if (err)
813 goto err_out_iounmap; 829 goto err_out_iounmap;
@@ -821,7 +837,9 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
821 adapter->pci_write_normalize(adapter, CRB_DRIVER_VERSION, i); 837 adapter->pci_write_normalize(adapter, CRB_DRIVER_VERSION, i);
822 838
823 /* Handshake with the card before we register the devices. */ 839 /* Handshake with the card before we register the devices. */
824 netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); 840 err = netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
841 if (err)
842 goto err_out_free_offload;
825 843
826 } /* first_driver */ 844 } /* first_driver */
827 845
@@ -925,6 +943,7 @@ err_out_disable_msi:
925 if (adapter->flags & NETXEN_NIC_MSI_ENABLED) 943 if (adapter->flags & NETXEN_NIC_MSI_ENABLED)
926 pci_disable_msi(pdev); 944 pci_disable_msi(pdev);
927 945
946err_out_free_offload:
928 if (first_driver) 947 if (first_driver)
929 netxen_free_adapter_offload(adapter); 948 netxen_free_adapter_offload(adapter);
930 949
@@ -968,6 +987,9 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
968 netxen_free_hw_resources(adapter); 987 netxen_free_hw_resources(adapter);
969 netxen_release_rx_buffers(adapter); 988 netxen_release_rx_buffers(adapter);
970 netxen_free_sw_resources(adapter); 989 netxen_free_sw_resources(adapter);
990
991 if (NX_IS_REVISION_P3(adapter->ahw.revision_id))
992 netxen_p3_free_mac_list(adapter);
971 } 993 }
972 994
973 if (adapter->portnum == 0) 995 if (adapter->portnum == 0)
@@ -983,8 +1005,10 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
983 1005
984 iounmap(adapter->ahw.db_base); 1006 iounmap(adapter->ahw.db_base);
985 iounmap(adapter->ahw.pci_base0); 1007 iounmap(adapter->ahw.pci_base0);
986 iounmap(adapter->ahw.pci_base1); 1008 if (adapter->ahw.pci_base1 != NULL)
987 iounmap(adapter->ahw.pci_base2); 1009 iounmap(adapter->ahw.pci_base1);
1010 if (adapter->ahw.pci_base2 != NULL)
1011 iounmap(adapter->ahw.pci_base2);
988 1012
989 pci_release_regions(pdev); 1013 pci_release_regions(pdev);
990 pci_disable_device(pdev); 1014 pci_disable_device(pdev);
@@ -1137,29 +1161,64 @@ static int netxen_nic_close(struct net_device *netdev)
1137 return 0; 1161 return 0;
1138} 1162}
1139 1163
1140void netxen_tso_check(struct netxen_adapter *adapter, 1164static bool netxen_tso_check(struct net_device *netdev,
1141 struct cmd_desc_type0 *desc, struct sk_buff *skb) 1165 struct cmd_desc_type0 *desc, struct sk_buff *skb)
1142{ 1166{
1143 if (desc->mss) { 1167 bool tso = false;
1144 desc->total_hdr_length = (sizeof(struct ethhdr) + 1168 u8 opcode = TX_ETHER_PKT;
1145 ip_hdrlen(skb) + tcp_hdrlen(skb));
1146 1169
1147 if ((NX_IS_REVISION_P3(adapter->ahw.revision_id)) && 1170 if ((netdev->features & (NETIF_F_TSO | NETIF_F_TSO6)) &&
1148 (skb->protocol == htons(ETH_P_IPV6))) 1171 skb_shinfo(skb)->gso_size > 0) {
1149 netxen_set_cmd_desc_opcode(desc, TX_TCP_LSO6); 1172
1150 else 1173 desc->mss = cpu_to_le16(skb_shinfo(skb)->gso_size);
1151 netxen_set_cmd_desc_opcode(desc, TX_TCP_LSO); 1174 desc->total_hdr_length =
1175 skb_transport_offset(skb) + tcp_hdrlen(skb);
1176
1177 opcode = (skb->protocol == htons(ETH_P_IPV6)) ?
1178 TX_TCP_LSO6 : TX_TCP_LSO;
1179 tso = true;
1152 1180
1153 } else if (skb->ip_summed == CHECKSUM_PARTIAL) { 1181 } else if (skb->ip_summed == CHECKSUM_PARTIAL) {
1154 if (ip_hdr(skb)->protocol == IPPROTO_TCP) 1182 u8 l4proto;
1155 netxen_set_cmd_desc_opcode(desc, TX_TCP_PKT); 1183
1156 else if (ip_hdr(skb)->protocol == IPPROTO_UDP) 1184 if (skb->protocol == htons(ETH_P_IP)) {
1157 netxen_set_cmd_desc_opcode(desc, TX_UDP_PKT); 1185 l4proto = ip_hdr(skb)->protocol;
1158 else 1186
1159 return; 1187 if (l4proto == IPPROTO_TCP)
1188 opcode = TX_TCP_PKT;
1189 else if(l4proto == IPPROTO_UDP)
1190 opcode = TX_UDP_PKT;
1191 } else if (skb->protocol == htons(ETH_P_IPV6)) {
1192 l4proto = ipv6_hdr(skb)->nexthdr;
1193
1194 if (l4proto == IPPROTO_TCP)
1195 opcode = TX_TCPV6_PKT;
1196 else if(l4proto == IPPROTO_UDP)
1197 opcode = TX_UDPV6_PKT;
1198 }
1160 } 1199 }
1161 desc->tcp_hdr_offset = skb_transport_offset(skb); 1200 desc->tcp_hdr_offset = skb_transport_offset(skb);
1162 desc->ip_hdr_offset = skb_network_offset(skb); 1201 desc->ip_hdr_offset = skb_network_offset(skb);
1202 netxen_set_tx_flags_opcode(desc, 0, opcode);
1203 return tso;
1204}
1205
1206static void
1207netxen_clean_tx_dma_mapping(struct pci_dev *pdev,
1208 struct netxen_cmd_buffer *pbuf, int last)
1209{
1210 int k;
1211 struct netxen_skb_frag *buffrag;
1212
1213 buffrag = &pbuf->frag_array[0];
1214 pci_unmap_single(pdev, buffrag->dma,
1215 buffrag->length, PCI_DMA_TODEVICE);
1216
1217 for (k = 1; k < last; k++) {
1218 buffrag = &pbuf->frag_array[k];
1219 pci_unmap_page(pdev, buffrag->dma,
1220 buffrag->length, PCI_DMA_TODEVICE);
1221 }
1163} 1222}
1164 1223
1165static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) 1224static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
@@ -1167,33 +1226,22 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1167 struct netxen_adapter *adapter = netdev_priv(netdev); 1226 struct netxen_adapter *adapter = netdev_priv(netdev);
1168 struct netxen_hardware_context *hw = &adapter->ahw; 1227 struct netxen_hardware_context *hw = &adapter->ahw;
1169 unsigned int first_seg_len = skb->len - skb->data_len; 1228 unsigned int first_seg_len = skb->len - skb->data_len;
1229 struct netxen_cmd_buffer *pbuf;
1170 struct netxen_skb_frag *buffrag; 1230 struct netxen_skb_frag *buffrag;
1171 unsigned int i; 1231 struct cmd_desc_type0 *hwdesc;
1232 struct pci_dev *pdev = adapter->pdev;
1233 dma_addr_t temp_dma;
1234 int i, k;
1172 1235
1173 u32 producer, consumer; 1236 u32 producer, consumer;
1174 u32 saved_producer = 0; 1237 int frag_count, no_of_desc;
1175 struct cmd_desc_type0 *hwdesc;
1176 int k;
1177 struct netxen_cmd_buffer *pbuf = NULL;
1178 int frag_count;
1179 int no_of_desc;
1180 u32 num_txd = adapter->max_tx_desc_count; 1238 u32 num_txd = adapter->max_tx_desc_count;
1239 bool is_tso = false;
1181 1240
1182 frag_count = skb_shinfo(skb)->nr_frags + 1; 1241 frag_count = skb_shinfo(skb)->nr_frags + 1;
1183 1242
1184 /* There 4 fragments per descriptor */ 1243 /* There 4 fragments per descriptor */
1185 no_of_desc = (frag_count + 3) >> 2; 1244 no_of_desc = (frag_count + 3) >> 2;
1186 if (netdev->features & (NETIF_F_TSO | NETIF_F_TSO6)) {
1187 if (skb_shinfo(skb)->gso_size > 0) {
1188
1189 no_of_desc++;
1190 if ((ip_hdrlen(skb) + tcp_hdrlen(skb) +
1191 sizeof(struct ethhdr)) >
1192 (sizeof(struct cmd_desc_type0) - 2)) {
1193 no_of_desc++;
1194 }
1195 }
1196 }
1197 1245
1198 producer = adapter->cmd_producer; 1246 producer = adapter->cmd_producer;
1199 smp_mb(); 1247 smp_mb();
@@ -1205,34 +1253,26 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1205 } 1253 }
1206 1254
1207 /* Copy the descriptors into the hardware */ 1255 /* Copy the descriptors into the hardware */
1208 saved_producer = producer;
1209 hwdesc = &hw->cmd_desc_head[producer]; 1256 hwdesc = &hw->cmd_desc_head[producer];
1210 memset(hwdesc, 0, sizeof(struct cmd_desc_type0)); 1257 memset(hwdesc, 0, sizeof(struct cmd_desc_type0));
1211 /* Take skb->data itself */ 1258 /* Take skb->data itself */
1212 pbuf = &adapter->cmd_buf_arr[producer]; 1259 pbuf = &adapter->cmd_buf_arr[producer];
1213 if ((netdev->features & (NETIF_F_TSO | NETIF_F_TSO6)) && 1260
1214 skb_shinfo(skb)->gso_size > 0) { 1261 is_tso = netxen_tso_check(netdev, hwdesc, skb);
1215 pbuf->mss = skb_shinfo(skb)->gso_size; 1262
1216 hwdesc->mss = cpu_to_le16(skb_shinfo(skb)->gso_size);
1217 } else {
1218 pbuf->mss = 0;
1219 hwdesc->mss = 0;
1220 }
1221 pbuf->total_length = skb->len;
1222 pbuf->skb = skb; 1263 pbuf->skb = skb;
1223 pbuf->cmd = TX_ETHER_PKT;
1224 pbuf->frag_count = frag_count; 1264 pbuf->frag_count = frag_count;
1225 pbuf->port = adapter->portnum;
1226 buffrag = &pbuf->frag_array[0]; 1265 buffrag = &pbuf->frag_array[0];
1227 buffrag->dma = pci_map_single(adapter->pdev, skb->data, first_seg_len, 1266 temp_dma = pci_map_single(pdev, skb->data, first_seg_len,
1228 PCI_DMA_TODEVICE); 1267 PCI_DMA_TODEVICE);
1268 if (pci_dma_mapping_error(pdev, temp_dma))
1269 goto drop_packet;
1270
1271 buffrag->dma = temp_dma;
1229 buffrag->length = first_seg_len; 1272 buffrag->length = first_seg_len;
1230 netxen_set_cmd_desc_totallength(hwdesc, skb->len); 1273 netxen_set_tx_frags_len(hwdesc, frag_count, skb->len);
1231 netxen_set_cmd_desc_num_of_buff(hwdesc, frag_count); 1274 netxen_set_tx_port(hwdesc, adapter->portnum);
1232 netxen_set_cmd_desc_opcode(hwdesc, TX_ETHER_PKT);
1233 1275
1234 netxen_set_cmd_desc_port(hwdesc, adapter->portnum);
1235 netxen_set_cmd_desc_ctxid(hwdesc, adapter->portnum);
1236 hwdesc->buffer1_length = cpu_to_le16(first_seg_len); 1276 hwdesc->buffer1_length = cpu_to_le16(first_seg_len);
1237 hwdesc->addr_buffer1 = cpu_to_le64(buffrag->dma); 1277 hwdesc->addr_buffer1 = cpu_to_le64(buffrag->dma);
1238 1278
@@ -1240,7 +1280,6 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1240 struct skb_frag_struct *frag; 1280 struct skb_frag_struct *frag;
1241 int len, temp_len; 1281 int len, temp_len;
1242 unsigned long offset; 1282 unsigned long offset;
1243 dma_addr_t temp_dma;
1244 1283
1245 /* move to next desc. if there is a need */ 1284 /* move to next desc. if there is a need */
1246 if ((i & 0x3) == 0) { 1285 if ((i & 0x3) == 0) {
@@ -1256,8 +1295,12 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1256 offset = frag->page_offset; 1295 offset = frag->page_offset;
1257 1296
1258 temp_len = len; 1297 temp_len = len;
1259 temp_dma = pci_map_page(adapter->pdev, frag->page, offset, 1298 temp_dma = pci_map_page(pdev, frag->page, offset,
1260 len, PCI_DMA_TODEVICE); 1299 len, PCI_DMA_TODEVICE);
1300 if (pci_dma_mapping_error(pdev, temp_dma)) {
1301 netxen_clean_tx_dma_mapping(pdev, pbuf, i);
1302 goto drop_packet;
1303 }
1261 1304
1262 buffrag++; 1305 buffrag++;
1263 buffrag->dma = temp_dma; 1306 buffrag->dma = temp_dma;
@@ -1285,16 +1328,12 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1285 } 1328 }
1286 producer = get_next_index(producer, num_txd); 1329 producer = get_next_index(producer, num_txd);
1287 1330
1288 /* might change opcode to TX_TCP_LSO */
1289 netxen_tso_check(adapter, &hw->cmd_desc_head[saved_producer], skb);
1290
1291 /* For LSO, we need to copy the MAC/IP/TCP headers into 1331 /* For LSO, we need to copy the MAC/IP/TCP headers into
1292 * the descriptor ring 1332 * the descriptor ring
1293 */ 1333 */
1294 if (netxen_get_cmd_desc_opcode(&hw->cmd_desc_head[saved_producer]) 1334 if (is_tso) {
1295 == TX_TCP_LSO) {
1296 int hdr_len, first_hdr_len, more_hdr; 1335 int hdr_len, first_hdr_len, more_hdr;
1297 hdr_len = hw->cmd_desc_head[saved_producer].total_hdr_length; 1336 hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
1298 if (hdr_len > (sizeof(struct cmd_desc_type0) - 2)) { 1337 if (hdr_len > (sizeof(struct cmd_desc_type0) - 2)) {
1299 first_hdr_len = sizeof(struct cmd_desc_type0) - 2; 1338 first_hdr_len = sizeof(struct cmd_desc_type0) - 2;
1300 more_hdr = 1; 1339 more_hdr = 1;
@@ -1336,6 +1375,11 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1336 netdev->trans_start = jiffies; 1375 netdev->trans_start = jiffies;
1337 1376
1338 return NETDEV_TX_OK; 1377 return NETDEV_TX_OK;
1378
1379drop_packet:
1380 adapter->stats.txdropped++;
1381 dev_kfree_skb_any(skb);
1382 return NETDEV_TX_OK;
1339} 1383}
1340 1384
1341static int netxen_nic_check_temp(struct netxen_adapter *adapter) 1385static int netxen_nic_check_temp(struct netxen_adapter *adapter)
@@ -1407,6 +1451,8 @@ static void netxen_nic_handle_phy_intr(struct netxen_adapter *adapter)
1407 netif_carrier_off(netdev); 1451 netif_carrier_off(netdev);
1408 netif_stop_queue(netdev); 1452 netif_stop_queue(netdev);
1409 } 1453 }
1454
1455 netxen_nic_set_link_parameters(adapter);
1410 } else if (!adapter->ahw.linkup && linkup) { 1456 } else if (!adapter->ahw.linkup && linkup) {
1411 printk(KERN_INFO "%s: %s NIC Link is up\n", 1457 printk(KERN_INFO "%s: %s NIC Link is up\n",
1412 netxen_nic_driver_name, netdev->name); 1458 netxen_nic_driver_name, netdev->name);
@@ -1415,6 +1461,8 @@ static void netxen_nic_handle_phy_intr(struct netxen_adapter *adapter)
1415 netif_carrier_on(netdev); 1461 netif_carrier_on(netdev);
1416 netif_wake_queue(netdev); 1462 netif_wake_queue(netdev);
1417 } 1463 }
1464
1465 netxen_nic_set_link_parameters(adapter);
1418 } 1466 }
1419} 1467}
1420 1468
diff --git a/drivers/net/ns83820.c b/drivers/net/ns83820.c
index 46b0772489e4..e80294d8cc19 100644
--- a/drivers/net/ns83820.c
+++ b/drivers/net/ns83820.c
@@ -1956,7 +1956,11 @@ static const struct net_device_ops netdev_ops = {
1956 .ndo_change_mtu = ns83820_change_mtu, 1956 .ndo_change_mtu = ns83820_change_mtu,
1957 .ndo_set_multicast_list = ns83820_set_multicast, 1957 .ndo_set_multicast_list = ns83820_set_multicast,
1958 .ndo_validate_addr = eth_validate_addr, 1958 .ndo_validate_addr = eth_validate_addr,
1959 .ndo_set_mac_address = eth_mac_addr,
1959 .ndo_tx_timeout = ns83820_tx_timeout, 1960 .ndo_tx_timeout = ns83820_tx_timeout,
1961#ifdef NS83820_VLAN_ACCEL_SUPPORT
1962 .ndo_vlan_rx_register = ns83820_vlan_rx_register,
1963#endif
1960}; 1964};
1961 1965
1962static int __devinit ns83820_init_one(struct pci_dev *pci_dev, 1966static int __devinit ns83820_init_one(struct pci_dev *pci_dev,
@@ -2216,7 +2220,6 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev,
2216#ifdef NS83820_VLAN_ACCEL_SUPPORT 2220#ifdef NS83820_VLAN_ACCEL_SUPPORT
2217 /* We also support hardware vlan acceleration */ 2221 /* We also support hardware vlan acceleration */
2218 ndev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; 2222 ndev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
2219 ndev->vlan_rx_register = ns83820_vlan_rx_register;
2220#endif 2223#endif
2221 2224
2222 if (using_dac) { 2225 if (using_dac) {
diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c
index 5b7a574ce571..d0349e7d73ea 100644
--- a/drivers/net/pasemi_mac.c
+++ b/drivers/net/pasemi_mac.c
@@ -712,7 +712,7 @@ static inline void pasemi_mac_rx_error(const struct pasemi_mac *mac,
712 rcmdsta = read_dma_reg(PAS_DMA_RXINT_RCMDSTA(mac->dma_if)); 712 rcmdsta = read_dma_reg(PAS_DMA_RXINT_RCMDSTA(mac->dma_if));
713 ccmdsta = read_dma_reg(PAS_DMA_RXCHAN_CCMDSTA(chan->chno)); 713 ccmdsta = read_dma_reg(PAS_DMA_RXCHAN_CCMDSTA(chan->chno));
714 714
715 printk(KERN_ERR "pasemi_mac: rx error. macrx %016lx, rx status %lx\n", 715 printk(KERN_ERR "pasemi_mac: rx error. macrx %016llx, rx status %llx\n",
716 macrx, *chan->status); 716 macrx, *chan->status);
717 717
718 printk(KERN_ERR "pasemi_mac: rcmdsta %08x ccmdsta %08x\n", 718 printk(KERN_ERR "pasemi_mac: rcmdsta %08x ccmdsta %08x\n",
@@ -730,8 +730,8 @@ static inline void pasemi_mac_tx_error(const struct pasemi_mac *mac,
730 730
731 cmdsta = read_dma_reg(PAS_DMA_TXCHAN_TCMDSTA(chan->chno)); 731 cmdsta = read_dma_reg(PAS_DMA_TXCHAN_TCMDSTA(chan->chno));
732 732
733 printk(KERN_ERR "pasemi_mac: tx error. mactx 0x%016lx, "\ 733 printk(KERN_ERR "pasemi_mac: tx error. mactx 0x%016llx, "\
734 "tx status 0x%016lx\n", mactx, *chan->status); 734 "tx status 0x%016llx\n", mactx, *chan->status);
735 735
736 printk(KERN_ERR "pasemi_mac: tcmdsta 0x%08x\n", cmdsta); 736 printk(KERN_ERR "pasemi_mac: tcmdsta 0x%08x\n", cmdsta);
737} 737}
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index 044b7b07f5f4..665a4286da39 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -1568,6 +1568,22 @@ pcnet32_probe_pci(struct pci_dev *pdev, const struct pci_device_id *ent)
1568 return err; 1568 return err;
1569} 1569}
1570 1570
1571static const struct net_device_ops pcnet32_netdev_ops = {
1572 .ndo_open = pcnet32_open,
1573 .ndo_stop = pcnet32_close,
1574 .ndo_start_xmit = pcnet32_start_xmit,
1575 .ndo_tx_timeout = pcnet32_tx_timeout,
1576 .ndo_get_stats = pcnet32_get_stats,
1577 .ndo_set_multicast_list = pcnet32_set_multicast_list,
1578 .ndo_do_ioctl = pcnet32_ioctl,
1579 .ndo_change_mtu = eth_change_mtu,
1580 .ndo_set_mac_address = eth_mac_addr,
1581 .ndo_validate_addr = eth_validate_addr,
1582#ifdef CONFIG_NET_POLL_CONTROLLER
1583 .ndo_poll_controller = pcnet32_poll_controller,
1584#endif
1585};
1586
1571/* pcnet32_probe1 1587/* pcnet32_probe1
1572 * Called from both pcnet32_probe_vlbus and pcnet_probe_pci. 1588 * Called from both pcnet32_probe_vlbus and pcnet_probe_pci.
1573 * pdev will be NULL when called from pcnet32_probe_vlbus. 1589 * pdev will be NULL when called from pcnet32_probe_vlbus.
@@ -1934,20 +1950,10 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1934 lp->watchdog_timer.function = (void *)&pcnet32_watchdog; 1950 lp->watchdog_timer.function = (void *)&pcnet32_watchdog;
1935 1951
1936 /* The PCNET32-specific entries in the device structure. */ 1952 /* The PCNET32-specific entries in the device structure. */
1937 dev->open = &pcnet32_open; 1953 dev->netdev_ops = &pcnet32_netdev_ops;
1938 dev->hard_start_xmit = &pcnet32_start_xmit;
1939 dev->stop = &pcnet32_close;
1940 dev->get_stats = &pcnet32_get_stats;
1941 dev->set_multicast_list = &pcnet32_set_multicast_list;
1942 dev->do_ioctl = &pcnet32_ioctl;
1943 dev->ethtool_ops = &pcnet32_ethtool_ops; 1954 dev->ethtool_ops = &pcnet32_ethtool_ops;
1944 dev->tx_timeout = pcnet32_tx_timeout;
1945 dev->watchdog_timeo = (5 * HZ); 1955 dev->watchdog_timeo = (5 * HZ);
1946 1956
1947#ifdef CONFIG_NET_POLL_CONTROLLER
1948 dev->poll_controller = pcnet32_poll_controller;
1949#endif
1950
1951 /* Fill in the generic fields of the device structure. */ 1957 /* Fill in the generic fields of the device structure. */
1952 if (register_netdev(dev)) 1958 if (register_netdev(dev))
1953 goto err_free_ring; 1959 goto err_free_ring;
@@ -2276,7 +2282,7 @@ static int pcnet32_open(struct net_device *dev)
2276 if (lp->chip_version >= PCNET32_79C970A) { 2282 if (lp->chip_version >= PCNET32_79C970A) {
2277 /* Print the link status and start the watchdog */ 2283 /* Print the link status and start the watchdog */
2278 pcnet32_check_media(dev, 1); 2284 pcnet32_check_media(dev, 1);
2279 mod_timer(&(lp->watchdog_timer), PCNET32_WATCHDOG_TIMEOUT); 2285 mod_timer(&lp->watchdog_timer, PCNET32_WATCHDOG_TIMEOUT);
2280 } 2286 }
2281 2287
2282 i = 0; 2288 i = 0;
@@ -2911,7 +2917,7 @@ static void pcnet32_watchdog(struct net_device *dev)
2911 pcnet32_check_media(dev, 0); 2917 pcnet32_check_media(dev, 0);
2912 spin_unlock_irqrestore(&lp->lock, flags); 2918 spin_unlock_irqrestore(&lp->lock, flags);
2913 2919
2914 mod_timer(&(lp->watchdog_timer), PCNET32_WATCHDOG_TIMEOUT); 2920 mod_timer(&lp->watchdog_timer, round_jiffies(PCNET32_WATCHDOG_TIMEOUT));
2915} 2921}
2916 2922
2917static int pcnet32_pm_suspend(struct pci_dev *pdev, pm_message_t state) 2923static int pcnet32_pm_suspend(struct pci_dev *pdev, pm_message_t state)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index e35460165bf7..0a06e4fd37d9 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -231,15 +231,6 @@ struct phy_device * get_phy_device(struct mii_bus *bus, int addr)
231 if ((phy_id & 0x1fffffff) == 0x1fffffff) 231 if ((phy_id & 0x1fffffff) == 0x1fffffff)
232 return NULL; 232 return NULL;
233 233
234 /*
235 * Broken hardware is sometimes missing the pull-up resistor on the
236 * MDIO line, which results in reads to non-existent devices returning
237 * 0 rather than 0xffff. Catch this here and treat 0 as a non-existent
238 * device as well.
239 */
240 if (phy_id == 0)
241 return NULL;
242
243 dev = phy_device_create(bus, addr, phy_id); 234 dev = phy_device_create(bus, addr, phy_id);
244 235
245 return dev; 236 return dev;
diff --git a/drivers/net/plip.c b/drivers/net/plip.c
index 0c46d603b8fe..0be0f0b164f3 100644
--- a/drivers/net/plip.c
+++ b/drivers/net/plip.c
@@ -265,6 +265,13 @@ static const struct header_ops plip_header_ops = {
265 .cache = plip_hard_header_cache, 265 .cache = plip_hard_header_cache,
266}; 266};
267 267
268static const struct net_device_ops plip_netdev_ops = {
269 .ndo_open = plip_open,
270 .ndo_stop = plip_close,
271 .ndo_start_xmit = plip_tx_packet,
272 .ndo_do_ioctl = plip_ioctl,
273};
274
268/* Entry point of PLIP driver. 275/* Entry point of PLIP driver.
269 Probe the hardware, and register/initialize the driver. 276 Probe the hardware, and register/initialize the driver.
270 277
@@ -280,15 +287,11 @@ plip_init_netdev(struct net_device *dev)
280 struct net_local *nl = netdev_priv(dev); 287 struct net_local *nl = netdev_priv(dev);
281 288
282 /* Then, override parts of it */ 289 /* Then, override parts of it */
283 dev->hard_start_xmit = plip_tx_packet;
284 dev->open = plip_open;
285 dev->stop = plip_close;
286 dev->do_ioctl = plip_ioctl;
287
288 dev->tx_queue_len = 10; 290 dev->tx_queue_len = 10;
289 dev->flags = IFF_POINTOPOINT|IFF_NOARP; 291 dev->flags = IFF_POINTOPOINT|IFF_NOARP;
290 memset(dev->dev_addr, 0xfc, ETH_ALEN); 292 memset(dev->dev_addr, 0xfc, ETH_ALEN);
291 293
294 dev->netdev_ops = &plip_netdev_ops;
292 dev->header_ops = &plip_header_ops; 295 dev->header_ops = &plip_header_ops;
293 296
294 297
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 06b448285eb5..7b2728b8f1b7 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -250,6 +250,7 @@ static int ppp_connect_channel(struct channel *pch, int unit);
250static int ppp_disconnect_channel(struct channel *pch); 250static int ppp_disconnect_channel(struct channel *pch);
251static void ppp_destroy_channel(struct channel *pch); 251static void ppp_destroy_channel(struct channel *pch);
252static int unit_get(struct idr *p, void *ptr); 252static int unit_get(struct idr *p, void *ptr);
253static int unit_set(struct idr *p, void *ptr, int n);
253static void unit_put(struct idr *p, int n); 254static void unit_put(struct idr *p, int n);
254static void *unit_find(struct idr *p, int n); 255static void *unit_find(struct idr *p, int n);
255 256
@@ -2432,11 +2433,18 @@ ppp_create_interface(int unit, int *retp)
2432 } else { 2433 } else {
2433 if (unit_find(&ppp_units_idr, unit)) 2434 if (unit_find(&ppp_units_idr, unit))
2434 goto out2; /* unit already exists */ 2435 goto out2; /* unit already exists */
2435 else { 2436 /*
2436 /* darn, someone is cheating us? */ 2437 * if caller need a specified unit number
2437 *retp = -EINVAL; 2438 * lets try to satisfy him, otherwise --
2439 * he should better ask us for new unit number
2440 *
2441 * NOTE: yes I know that returning EEXIST it's not
2442 * fair but at least pppd will ask us to allocate
2443 * new unit in this case so user is happy :)
2444 */
2445 unit = unit_set(&ppp_units_idr, ppp, unit);
2446 if (unit < 0)
2438 goto out2; 2447 goto out2;
2439 }
2440 } 2448 }
2441 2449
2442 /* Initialize the new ppp unit */ 2450 /* Initialize the new ppp unit */
@@ -2677,14 +2685,37 @@ static void __exit ppp_cleanup(void)
2677 * by holding all_ppp_mutex 2685 * by holding all_ppp_mutex
2678 */ 2686 */
2679 2687
2688/* associate pointer with specified number */
2689static int unit_set(struct idr *p, void *ptr, int n)
2690{
2691 int unit, err;
2692
2693again:
2694 if (!idr_pre_get(p, GFP_KERNEL)) {
2695 printk(KERN_ERR "PPP: No free memory for idr\n");
2696 return -ENOMEM;
2697 }
2698
2699 err = idr_get_new_above(p, ptr, n, &unit);
2700 if (err == -EAGAIN)
2701 goto again;
2702
2703 if (unit != n) {
2704 idr_remove(p, unit);
2705 return -EINVAL;
2706 }
2707
2708 return unit;
2709}
2710
2680/* get new free unit number and associate pointer with it */ 2711/* get new free unit number and associate pointer with it */
2681static int unit_get(struct idr *p, void *ptr) 2712static int unit_get(struct idr *p, void *ptr)
2682{ 2713{
2683 int unit, err; 2714 int unit, err;
2684 2715
2685again: 2716again:
2686 if (idr_pre_get(p, GFP_KERNEL) == 0) { 2717 if (!idr_pre_get(p, GFP_KERNEL)) {
2687 printk(KERN_ERR "Out of memory expanding drawable idr\n"); 2718 printk(KERN_ERR "PPP: No free memory for idr\n");
2688 return -ENOMEM; 2719 return -ENOMEM;
2689 } 2720 }
2690 2721
diff --git a/drivers/net/qlge/qlge.h b/drivers/net/qlge/qlge.h
index 459663a4023d..c1dadadfab18 100644
--- a/drivers/net/qlge/qlge.h
+++ b/drivers/net/qlge/qlge.h
@@ -28,11 +28,11 @@
28 } while (0) 28 } while (0)
29 29
30#define QLGE_VENDOR_ID 0x1077 30#define QLGE_VENDOR_ID 0x1077
31#define QLGE_DEVICE_ID1 0x8012 31#define QLGE_DEVICE_ID 0x8012
32#define QLGE_DEVICE_ID 0x8000
33 32
34#define MAX_RX_RINGS 128 33#define MAX_CPUS 8
35#define MAX_TX_RINGS 128 34#define MAX_TX_RINGS MAX_CPUS
35#define MAX_RX_RINGS ((MAX_CPUS * 2) + 1)
36 36
37#define NUM_TX_RING_ENTRIES 256 37#define NUM_TX_RING_ENTRIES 256
38#define NUM_RX_RING_ENTRIES 256 38#define NUM_RX_RING_ENTRIES 256
@@ -45,6 +45,7 @@
45#define MAX_SPLIT_SIZE 1023 45#define MAX_SPLIT_SIZE 1023
46#define QLGE_SB_PAD 32 46#define QLGE_SB_PAD 32
47 47
48#define MAX_CQ 128
48#define DFLT_COALESCE_WAIT 100 /* 100 usec wait for coalescing */ 49#define DFLT_COALESCE_WAIT 100 /* 100 usec wait for coalescing */
49#define MAX_INTER_FRAME_WAIT 10 /* 10 usec max interframe-wait for coalescing */ 50#define MAX_INTER_FRAME_WAIT 10 /* 10 usec max interframe-wait for coalescing */
50#define DFLT_INTER_FRAME_WAIT (MAX_INTER_FRAME_WAIT/2) 51#define DFLT_INTER_FRAME_WAIT (MAX_INTER_FRAME_WAIT/2)
@@ -961,8 +962,7 @@ struct ib_mac_iocb_rsp {
961#define IB_MAC_IOCB_RSP_DS 0x40 /* data is in small buffer */ 962#define IB_MAC_IOCB_RSP_DS 0x40 /* data is in small buffer */
962#define IB_MAC_IOCB_RSP_DL 0x80 /* data is in large buffer */ 963#define IB_MAC_IOCB_RSP_DL 0x80 /* data is in large buffer */
963 __le32 data_len; /* */ 964 __le32 data_len; /* */
964 __le32 data_addr_lo; /* */ 965 __le64 data_addr; /* */
965 __le32 data_addr_hi; /* */
966 __le32 rss; /* */ 966 __le32 rss; /* */
967 __le16 vlan_id; /* 12 bits */ 967 __le16 vlan_id; /* 12 bits */
968#define IB_MAC_IOCB_RSP_C 0x1000 /* VLAN CFI bit */ 968#define IB_MAC_IOCB_RSP_C 0x1000 /* VLAN CFI bit */
@@ -976,8 +976,7 @@ struct ib_mac_iocb_rsp {
976#define IB_MAC_IOCB_RSP_HS 0x40 976#define IB_MAC_IOCB_RSP_HS 0x40
977#define IB_MAC_IOCB_RSP_HL 0x80 977#define IB_MAC_IOCB_RSP_HL 0x80
978 __le32 hdr_len; /* */ 978 __le32 hdr_len; /* */
979 __le32 hdr_addr_lo; /* */ 979 __le64 hdr_addr; /* */
980 __le32 hdr_addr_hi; /* */
981} __attribute((packed)); 980} __attribute((packed));
982 981
983struct ib_ae_iocb_rsp { 982struct ib_ae_iocb_rsp {
@@ -1042,10 +1041,8 @@ struct wqicb {
1042 __le16 cq_id_rss; 1041 __le16 cq_id_rss;
1043#define Q_CQ_ID_RSS_RV 0x8000 1042#define Q_CQ_ID_RSS_RV 0x8000
1044 __le16 rid; 1043 __le16 rid;
1045 __le32 addr_lo; 1044 __le64 addr;
1046 __le32 addr_hi; 1045 __le64 cnsmr_idx_addr;
1047 __le32 cnsmr_idx_addr_lo;
1048 __le32 cnsmr_idx_addr_hi;
1049} __attribute((packed)); 1046} __attribute((packed));
1050 1047
1051/* 1048/*
@@ -1070,18 +1067,14 @@ struct cqicb {
1070#define LEN_CPP_64 0x0002 1067#define LEN_CPP_64 0x0002
1071#define LEN_CPP_128 0x0003 1068#define LEN_CPP_128 0x0003
1072 __le16 rid; 1069 __le16 rid;
1073 __le32 addr_lo; 1070 __le64 addr;
1074 __le32 addr_hi; 1071 __le64 prod_idx_addr;
1075 __le32 prod_idx_addr_lo;
1076 __le32 prod_idx_addr_hi;
1077 __le16 pkt_delay; 1072 __le16 pkt_delay;
1078 __le16 irq_delay; 1073 __le16 irq_delay;
1079 __le32 lbq_addr_lo; 1074 __le64 lbq_addr;
1080 __le32 lbq_addr_hi;
1081 __le16 lbq_buf_size; 1075 __le16 lbq_buf_size;
1082 __le16 lbq_len; /* entry count */ 1076 __le16 lbq_len; /* entry count */
1083 __le32 sbq_addr_lo; 1077 __le64 sbq_addr;
1084 __le32 sbq_addr_hi;
1085 __le16 sbq_buf_size; 1078 __le16 sbq_buf_size;
1086 __le16 sbq_len; /* entry count */ 1079 __le16 sbq_len; /* entry count */
1087} __attribute((packed)); 1080} __attribute((packed));
@@ -1145,7 +1138,7 @@ struct tx_ring {
1145 struct wqicb wqicb; /* structure used to inform chip of new queue */ 1138 struct wqicb wqicb; /* structure used to inform chip of new queue */
1146 void *wq_base; /* pci_alloc:virtual addr for tx */ 1139 void *wq_base; /* pci_alloc:virtual addr for tx */
1147 dma_addr_t wq_base_dma; /* pci_alloc:dma addr for tx */ 1140 dma_addr_t wq_base_dma; /* pci_alloc:dma addr for tx */
1148 u32 *cnsmr_idx_sh_reg; /* shadow copy of consumer idx */ 1141 __le32 *cnsmr_idx_sh_reg; /* shadow copy of consumer idx */
1149 dma_addr_t cnsmr_idx_sh_reg_dma; /* dma-shadow copy of consumer */ 1142 dma_addr_t cnsmr_idx_sh_reg_dma; /* dma-shadow copy of consumer */
1150 u32 wq_size; /* size in bytes of queue area */ 1143 u32 wq_size; /* size in bytes of queue area */
1151 u32 wq_len; /* number of entries in queue */ 1144 u32 wq_len; /* number of entries in queue */
@@ -1181,7 +1174,7 @@ struct rx_ring {
1181 u32 cq_size; 1174 u32 cq_size;
1182 u32 cq_len; 1175 u32 cq_len;
1183 u16 cq_id; 1176 u16 cq_id;
1184 volatile __le32 *prod_idx_sh_reg; /* Shadowed producer register. */ 1177 __le32 *prod_idx_sh_reg; /* Shadowed producer register. */
1185 dma_addr_t prod_idx_sh_reg_dma; 1178 dma_addr_t prod_idx_sh_reg_dma;
1186 void __iomem *cnsmr_idx_db_reg; /* PCI doorbell mem area + 0 */ 1179 void __iomem *cnsmr_idx_db_reg; /* PCI doorbell mem area + 0 */
1187 u32 cnsmr_idx; /* current sw idx */ 1180 u32 cnsmr_idx; /* current sw idx */
@@ -1402,9 +1395,11 @@ struct ql_adapter {
1402 int rx_ring_count; 1395 int rx_ring_count;
1403 int ring_mem_size; 1396 int ring_mem_size;
1404 void *ring_mem; 1397 void *ring_mem;
1405 struct rx_ring *rx_ring; 1398
1399 struct rx_ring rx_ring[MAX_RX_RINGS];
1400 struct tx_ring tx_ring[MAX_TX_RINGS];
1401
1406 int rx_csum; 1402 int rx_csum;
1407 struct tx_ring *tx_ring;
1408 u32 default_rx_queue; 1403 u32 default_rx_queue;
1409 1404
1410 u16 rx_coalesce_usecs; /* cqicb->int_delay */ 1405 u16 rx_coalesce_usecs; /* cqicb->int_delay */
@@ -1459,6 +1454,24 @@ static inline void ql_write_db_reg(u32 val, void __iomem *addr)
1459 mmiowb(); 1454 mmiowb();
1460} 1455}
1461 1456
1457/*
1458 * Shadow Registers:
1459 * Outbound queues have a consumer index that is maintained by the chip.
1460 * Inbound queues have a producer index that is maintained by the chip.
1461 * For lower overhead, these registers are "shadowed" to host memory
1462 * which allows the device driver to track the queue progress without
1463 * PCI reads. When an entry is placed on an inbound queue, the chip will
1464 * update the relevant index register and then copy the value to the
1465 * shadow register in host memory.
1466 */
1467static inline u32 ql_read_sh_reg(__le32 *addr)
1468{
1469 u32 reg;
1470 reg = le32_to_cpu(*addr);
1471 rmb();
1472 return reg;
1473}
1474
1462extern char qlge_driver_name[]; 1475extern char qlge_driver_name[];
1463extern const char qlge_driver_version[]; 1476extern const char qlge_driver_version[];
1464extern const struct ethtool_ops qlge_ethtool_ops; 1477extern const struct ethtool_ops qlge_ethtool_ops;
diff --git a/drivers/net/qlge/qlge_dbg.c b/drivers/net/qlge/qlge_dbg.c
index 3f5e02d2e4a9..379b895ed6e6 100644
--- a/drivers/net/qlge/qlge_dbg.c
+++ b/drivers/net/qlge/qlge_dbg.c
@@ -435,14 +435,10 @@ void ql_dump_wqicb(struct wqicb *wqicb)
435 printk(KERN_ERR PFX "wqicb->cq_id_rss = %d.\n", 435 printk(KERN_ERR PFX "wqicb->cq_id_rss = %d.\n",
436 le16_to_cpu(wqicb->cq_id_rss)); 436 le16_to_cpu(wqicb->cq_id_rss));
437 printk(KERN_ERR PFX "wqicb->rid = 0x%x.\n", le16_to_cpu(wqicb->rid)); 437 printk(KERN_ERR PFX "wqicb->rid = 0x%x.\n", le16_to_cpu(wqicb->rid));
438 printk(KERN_ERR PFX "wqicb->wq_addr_lo = 0x%.08x.\n", 438 printk(KERN_ERR PFX "wqicb->wq_addr = 0x%llx.\n",
439 le32_to_cpu(wqicb->addr_lo)); 439 (unsigned long long) le64_to_cpu(wqicb->addr));
440 printk(KERN_ERR PFX "wqicb->wq_addr_hi = 0x%.08x.\n", 440 printk(KERN_ERR PFX "wqicb->wq_cnsmr_idx_addr = 0x%llx.\n",
441 le32_to_cpu(wqicb->addr_hi)); 441 (unsigned long long) le64_to_cpu(wqicb->cnsmr_idx_addr));
442 printk(KERN_ERR PFX "wqicb->wq_cnsmr_idx_addr_lo = 0x%.08x.\n",
443 le32_to_cpu(wqicb->cnsmr_idx_addr_lo));
444 printk(KERN_ERR PFX "wqicb->wq_cnsmr_idx_addr_hi = 0x%.08x.\n",
445 le32_to_cpu(wqicb->cnsmr_idx_addr_hi));
446} 442}
447 443
448void ql_dump_tx_ring(struct tx_ring *tx_ring) 444void ql_dump_tx_ring(struct tx_ring *tx_ring)
@@ -455,10 +451,11 @@ void ql_dump_tx_ring(struct tx_ring *tx_ring)
455 printk(KERN_ERR PFX "tx_ring->base = %p.\n", tx_ring->wq_base); 451 printk(KERN_ERR PFX "tx_ring->base = %p.\n", tx_ring->wq_base);
456 printk(KERN_ERR PFX "tx_ring->base_dma = 0x%llx.\n", 452 printk(KERN_ERR PFX "tx_ring->base_dma = 0x%llx.\n",
457 (unsigned long long) tx_ring->wq_base_dma); 453 (unsigned long long) tx_ring->wq_base_dma);
458 printk(KERN_ERR PFX "tx_ring->cnsmr_idx_sh_reg = %p.\n", 454 printk(KERN_ERR PFX
459 tx_ring->cnsmr_idx_sh_reg); 455 "tx_ring->cnsmr_idx_sh_reg, addr = 0x%p, value = %d.\n",
460 printk(KERN_ERR PFX "tx_ring->cnsmr_idx_sh_reg_dma = 0x%llx.\n", 456 tx_ring->cnsmr_idx_sh_reg,
461 (unsigned long long) tx_ring->cnsmr_idx_sh_reg_dma); 457 tx_ring->cnsmr_idx_sh_reg
458 ? ql_read_sh_reg(tx_ring->cnsmr_idx_sh_reg) : 0);
462 printk(KERN_ERR PFX "tx_ring->size = %d.\n", tx_ring->wq_size); 459 printk(KERN_ERR PFX "tx_ring->size = %d.\n", tx_ring->wq_size);
463 printk(KERN_ERR PFX "tx_ring->len = %d.\n", tx_ring->wq_len); 460 printk(KERN_ERR PFX "tx_ring->len = %d.\n", tx_ring->wq_len);
464 printk(KERN_ERR PFX "tx_ring->prod_idx_db_reg = %p.\n", 461 printk(KERN_ERR PFX "tx_ring->prod_idx_db_reg = %p.\n",
@@ -510,30 +507,22 @@ void ql_dump_cqicb(struct cqicb *cqicb)
510 printk(KERN_ERR PFX "cqicb->msix_vect = %d.\n", cqicb->msix_vect); 507 printk(KERN_ERR PFX "cqicb->msix_vect = %d.\n", cqicb->msix_vect);
511 printk(KERN_ERR PFX "cqicb->flags = %x.\n", cqicb->flags); 508 printk(KERN_ERR PFX "cqicb->flags = %x.\n", cqicb->flags);
512 printk(KERN_ERR PFX "cqicb->len = %d.\n", le16_to_cpu(cqicb->len)); 509 printk(KERN_ERR PFX "cqicb->len = %d.\n", le16_to_cpu(cqicb->len));
513 printk(KERN_ERR PFX "cqicb->addr_lo = %x.\n", 510 printk(KERN_ERR PFX "cqicb->addr = 0x%llx.\n",
514 le32_to_cpu(cqicb->addr_lo)); 511 (unsigned long long) le64_to_cpu(cqicb->addr));
515 printk(KERN_ERR PFX "cqicb->addr_hi = %x.\n", 512 printk(KERN_ERR PFX "cqicb->prod_idx_addr = 0x%llx.\n",
516 le32_to_cpu(cqicb->addr_hi)); 513 (unsigned long long) le64_to_cpu(cqicb->prod_idx_addr));
517 printk(KERN_ERR PFX "cqicb->prod_idx_addr_lo = %x.\n",
518 le32_to_cpu(cqicb->prod_idx_addr_lo));
519 printk(KERN_ERR PFX "cqicb->prod_idx_addr_hi = %x.\n",
520 le32_to_cpu(cqicb->prod_idx_addr_hi));
521 printk(KERN_ERR PFX "cqicb->pkt_delay = 0x%.04x.\n", 514 printk(KERN_ERR PFX "cqicb->pkt_delay = 0x%.04x.\n",
522 le16_to_cpu(cqicb->pkt_delay)); 515 le16_to_cpu(cqicb->pkt_delay));
523 printk(KERN_ERR PFX "cqicb->irq_delay = 0x%.04x.\n", 516 printk(KERN_ERR PFX "cqicb->irq_delay = 0x%.04x.\n",
524 le16_to_cpu(cqicb->irq_delay)); 517 le16_to_cpu(cqicb->irq_delay));
525 printk(KERN_ERR PFX "cqicb->lbq_addr_lo = %x.\n", 518 printk(KERN_ERR PFX "cqicb->lbq_addr = 0x%llx.\n",
526 le32_to_cpu(cqicb->lbq_addr_lo)); 519 (unsigned long long) le64_to_cpu(cqicb->lbq_addr));
527 printk(KERN_ERR PFX "cqicb->lbq_addr_hi = %x.\n",
528 le32_to_cpu(cqicb->lbq_addr_hi));
529 printk(KERN_ERR PFX "cqicb->lbq_buf_size = 0x%.04x.\n", 520 printk(KERN_ERR PFX "cqicb->lbq_buf_size = 0x%.04x.\n",
530 le16_to_cpu(cqicb->lbq_buf_size)); 521 le16_to_cpu(cqicb->lbq_buf_size));
531 printk(KERN_ERR PFX "cqicb->lbq_len = 0x%.04x.\n", 522 printk(KERN_ERR PFX "cqicb->lbq_len = 0x%.04x.\n",
532 le16_to_cpu(cqicb->lbq_len)); 523 le16_to_cpu(cqicb->lbq_len));
533 printk(KERN_ERR PFX "cqicb->sbq_addr_lo = %x.\n", 524 printk(KERN_ERR PFX "cqicb->sbq_addr = 0x%llx.\n",
534 le32_to_cpu(cqicb->sbq_addr_lo)); 525 (unsigned long long) le64_to_cpu(cqicb->sbq_addr));
535 printk(KERN_ERR PFX "cqicb->sbq_addr_hi = %x.\n",
536 le32_to_cpu(cqicb->sbq_addr_hi));
537 printk(KERN_ERR PFX "cqicb->sbq_buf_size = 0x%.04x.\n", 526 printk(KERN_ERR PFX "cqicb->sbq_buf_size = 0x%.04x.\n",
538 le16_to_cpu(cqicb->sbq_buf_size)); 527 le16_to_cpu(cqicb->sbq_buf_size));
539 printk(KERN_ERR PFX "cqicb->sbq_len = 0x%.04x.\n", 528 printk(KERN_ERR PFX "cqicb->sbq_len = 0x%.04x.\n",
@@ -558,9 +547,10 @@ void ql_dump_rx_ring(struct rx_ring *rx_ring)
558 printk(KERN_ERR PFX "rx_ring->cq_size = %d.\n", rx_ring->cq_size); 547 printk(KERN_ERR PFX "rx_ring->cq_size = %d.\n", rx_ring->cq_size);
559 printk(KERN_ERR PFX "rx_ring->cq_len = %d.\n", rx_ring->cq_len); 548 printk(KERN_ERR PFX "rx_ring->cq_len = %d.\n", rx_ring->cq_len);
560 printk(KERN_ERR PFX 549 printk(KERN_ERR PFX
561 "rx_ring->prod_idx_sh_reg, addr = %p, value = %d.\n", 550 "rx_ring->prod_idx_sh_reg, addr = 0x%p, value = %d.\n",
562 rx_ring->prod_idx_sh_reg, 551 rx_ring->prod_idx_sh_reg,
563 rx_ring->prod_idx_sh_reg ? *(rx_ring->prod_idx_sh_reg) : 0); 552 rx_ring->prod_idx_sh_reg
553 ? ql_read_sh_reg(rx_ring->prod_idx_sh_reg) : 0);
564 printk(KERN_ERR PFX "rx_ring->prod_idx_sh_reg_dma = %llx.\n", 554 printk(KERN_ERR PFX "rx_ring->prod_idx_sh_reg_dma = %llx.\n",
565 (unsigned long long) rx_ring->prod_idx_sh_reg_dma); 555 (unsigned long long) rx_ring->prod_idx_sh_reg_dma);
566 printk(KERN_ERR PFX "rx_ring->cnsmr_idx_db_reg = %p.\n", 556 printk(KERN_ERR PFX "rx_ring->cnsmr_idx_db_reg = %p.\n",
@@ -809,10 +799,8 @@ void ql_dump_ib_mac_rsp(struct ib_mac_iocb_rsp *ib_mac_rsp)
809 799
810 printk(KERN_ERR PFX "data_len = %d\n", 800 printk(KERN_ERR PFX "data_len = %d\n",
811 le32_to_cpu(ib_mac_rsp->data_len)); 801 le32_to_cpu(ib_mac_rsp->data_len));
812 printk(KERN_ERR PFX "data_addr_hi = 0x%x\n", 802 printk(KERN_ERR PFX "data_addr = 0x%llx\n",
813 le32_to_cpu(ib_mac_rsp->data_addr_hi)); 803 (unsigned long long) le64_to_cpu(ib_mac_rsp->data_addr));
814 printk(KERN_ERR PFX "data_addr_lo = 0x%x\n",
815 le32_to_cpu(ib_mac_rsp->data_addr_lo));
816 if (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_RSS_MASK) 804 if (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_RSS_MASK)
817 printk(KERN_ERR PFX "rss = %x\n", 805 printk(KERN_ERR PFX "rss = %x\n",
818 le32_to_cpu(ib_mac_rsp->rss)); 806 le32_to_cpu(ib_mac_rsp->rss));
@@ -828,10 +816,8 @@ void ql_dump_ib_mac_rsp(struct ib_mac_iocb_rsp *ib_mac_rsp)
828 if (ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV) { 816 if (ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV) {
829 printk(KERN_ERR PFX "hdr length = %d.\n", 817 printk(KERN_ERR PFX "hdr length = %d.\n",
830 le32_to_cpu(ib_mac_rsp->hdr_len)); 818 le32_to_cpu(ib_mac_rsp->hdr_len));
831 printk(KERN_ERR PFX "hdr addr_hi = 0x%x.\n", 819 printk(KERN_ERR PFX "hdr addr = 0x%llx.\n",
832 le32_to_cpu(ib_mac_rsp->hdr_addr_hi)); 820 (unsigned long long) le64_to_cpu(ib_mac_rsp->hdr_addr));
833 printk(KERN_ERR PFX "hdr addr_lo = 0x%x.\n",
834 le32_to_cpu(ib_mac_rsp->hdr_addr_lo));
835 } 821 }
836} 822}
837#endif 823#endif
diff --git a/drivers/net/qlge/qlge_main.c b/drivers/net/qlge/qlge_main.c
index f4c016012f18..45421c8b6010 100644
--- a/drivers/net/qlge/qlge_main.c
+++ b/drivers/net/qlge/qlge_main.c
@@ -76,7 +76,6 @@ MODULE_PARM_DESC(irq_type, "0 = MSI-X, 1 = MSI, 2 = Legacy.");
76 76
77static struct pci_device_id qlge_pci_tbl[] __devinitdata = { 77static struct pci_device_id qlge_pci_tbl[] __devinitdata = {
78 {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, QLGE_DEVICE_ID)}, 78 {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, QLGE_DEVICE_ID)},
79 {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, QLGE_DEVICE_ID1)},
80 /* required last entry */ 79 /* required last entry */
81 {0,} 80 {0,}
82}; 81};
@@ -127,12 +126,12 @@ static int ql_sem_trylock(struct ql_adapter *qdev, u32 sem_mask)
127 126
128int ql_sem_spinlock(struct ql_adapter *qdev, u32 sem_mask) 127int ql_sem_spinlock(struct ql_adapter *qdev, u32 sem_mask)
129{ 128{
130 unsigned int seconds = 3; 129 unsigned int wait_count = 30;
131 do { 130 do {
132 if (!ql_sem_trylock(qdev, sem_mask)) 131 if (!ql_sem_trylock(qdev, sem_mask))
133 return 0; 132 return 0;
134 ssleep(1); 133 udelay(100);
135 } while (--seconds); 134 } while (--wait_count);
136 return -ETIMEDOUT; 135 return -ETIMEDOUT;
137} 136}
138 137
@@ -1545,7 +1544,7 @@ static void ql_process_chip_ae_intr(struct ql_adapter *qdev,
1545static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring) 1544static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring)
1546{ 1545{
1547 struct ql_adapter *qdev = rx_ring->qdev; 1546 struct ql_adapter *qdev = rx_ring->qdev;
1548 u32 prod = le32_to_cpu(*rx_ring->prod_idx_sh_reg); 1547 u32 prod = ql_read_sh_reg(rx_ring->prod_idx_sh_reg);
1549 struct ob_mac_iocb_rsp *net_rsp = NULL; 1548 struct ob_mac_iocb_rsp *net_rsp = NULL;
1550 int count = 0; 1549 int count = 0;
1551 1550
@@ -1571,7 +1570,7 @@ static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring)
1571 } 1570 }
1572 count++; 1571 count++;
1573 ql_update_cq(rx_ring); 1572 ql_update_cq(rx_ring);
1574 prod = le32_to_cpu(*rx_ring->prod_idx_sh_reg); 1573 prod = ql_read_sh_reg(rx_ring->prod_idx_sh_reg);
1575 } 1574 }
1576 ql_write_cq_idx(rx_ring); 1575 ql_write_cq_idx(rx_ring);
1577 if (netif_queue_stopped(qdev->ndev) && net_rsp != NULL) { 1576 if (netif_queue_stopped(qdev->ndev) && net_rsp != NULL) {
@@ -1591,7 +1590,7 @@ static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring)
1591static int ql_clean_inbound_rx_ring(struct rx_ring *rx_ring, int budget) 1590static int ql_clean_inbound_rx_ring(struct rx_ring *rx_ring, int budget)
1592{ 1591{
1593 struct ql_adapter *qdev = rx_ring->qdev; 1592 struct ql_adapter *qdev = rx_ring->qdev;
1594 u32 prod = le32_to_cpu(*rx_ring->prod_idx_sh_reg); 1593 u32 prod = ql_read_sh_reg(rx_ring->prod_idx_sh_reg);
1595 struct ql_net_rsp_iocb *net_rsp; 1594 struct ql_net_rsp_iocb *net_rsp;
1596 int count = 0; 1595 int count = 0;
1597 1596
@@ -1624,7 +1623,7 @@ static int ql_clean_inbound_rx_ring(struct rx_ring *rx_ring, int budget)
1624 } 1623 }
1625 count++; 1624 count++;
1626 ql_update_cq(rx_ring); 1625 ql_update_cq(rx_ring);
1627 prod = le32_to_cpu(*rx_ring->prod_idx_sh_reg); 1626 prod = ql_read_sh_reg(rx_ring->prod_idx_sh_reg);
1628 if (count == budget) 1627 if (count == budget)
1629 break; 1628 break;
1630 } 1629 }
@@ -1787,7 +1786,7 @@ static irqreturn_t qlge_isr(int irq, void *dev_id)
1787 * Check the default queue and wake handler if active. 1786 * Check the default queue and wake handler if active.
1788 */ 1787 */
1789 rx_ring = &qdev->rx_ring[0]; 1788 rx_ring = &qdev->rx_ring[0];
1790 if (le32_to_cpu(*rx_ring->prod_idx_sh_reg) != rx_ring->cnsmr_idx) { 1789 if (ql_read_sh_reg(rx_ring->prod_idx_sh_reg) != rx_ring->cnsmr_idx) {
1791 QPRINTK(qdev, INTR, INFO, "Waking handler for rx_ring[0].\n"); 1790 QPRINTK(qdev, INTR, INFO, "Waking handler for rx_ring[0].\n");
1792 ql_disable_completion_interrupt(qdev, intr_context->intr); 1791 ql_disable_completion_interrupt(qdev, intr_context->intr);
1793 queue_delayed_work_on(smp_processor_id(), qdev->q_workqueue, 1792 queue_delayed_work_on(smp_processor_id(), qdev->q_workqueue,
@@ -1801,7 +1800,7 @@ static irqreturn_t qlge_isr(int irq, void *dev_id)
1801 */ 1800 */
1802 for (i = 1; i < qdev->rx_ring_count; i++) { 1801 for (i = 1; i < qdev->rx_ring_count; i++) {
1803 rx_ring = &qdev->rx_ring[i]; 1802 rx_ring = &qdev->rx_ring[i];
1804 if (le32_to_cpu(*rx_ring->prod_idx_sh_reg) != 1803 if (ql_read_sh_reg(rx_ring->prod_idx_sh_reg) !=
1805 rx_ring->cnsmr_idx) { 1804 rx_ring->cnsmr_idx) {
1806 QPRINTK(qdev, INTR, INFO, 1805 QPRINTK(qdev, INTR, INFO,
1807 "Waking handler for rx_ring[%d].\n", i); 1806 "Waking handler for rx_ring[%d].\n", i);
@@ -2356,28 +2355,6 @@ static void ql_tx_ring_clean(struct ql_adapter *qdev)
2356 } 2355 }
2357} 2356}
2358 2357
2359static void ql_free_ring_cb(struct ql_adapter *qdev)
2360{
2361 kfree(qdev->ring_mem);
2362}
2363
2364static int ql_alloc_ring_cb(struct ql_adapter *qdev)
2365{
2366 /* Allocate space for tx/rx ring control blocks. */
2367 qdev->ring_mem_size =
2368 (qdev->tx_ring_count * sizeof(struct tx_ring)) +
2369 (qdev->rx_ring_count * sizeof(struct rx_ring));
2370 qdev->ring_mem = kmalloc(qdev->ring_mem_size, GFP_KERNEL);
2371 if (qdev->ring_mem == NULL) {
2372 return -ENOMEM;
2373 } else {
2374 qdev->rx_ring = qdev->ring_mem;
2375 qdev->tx_ring = qdev->ring_mem +
2376 (qdev->rx_ring_count * sizeof(struct rx_ring));
2377 }
2378 return 0;
2379}
2380
2381static void ql_free_mem_resources(struct ql_adapter *qdev) 2358static void ql_free_mem_resources(struct ql_adapter *qdev)
2382{ 2359{
2383 int i; 2360 int i;
@@ -2467,12 +2444,9 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring)
2467 bq_len = (rx_ring->cq_len == 65536) ? 0 : (u16) rx_ring->cq_len; 2444 bq_len = (rx_ring->cq_len == 65536) ? 0 : (u16) rx_ring->cq_len;
2468 cqicb->len = cpu_to_le16(bq_len | LEN_V | LEN_CPP_CONT); 2445 cqicb->len = cpu_to_le16(bq_len | LEN_V | LEN_CPP_CONT);
2469 2446
2470 cqicb->addr_lo = cpu_to_le32(rx_ring->cq_base_dma); 2447 cqicb->addr = cpu_to_le64(rx_ring->cq_base_dma);
2471 cqicb->addr_hi = cpu_to_le32((u64) rx_ring->cq_base_dma >> 32);
2472 2448
2473 cqicb->prod_idx_addr_lo = cpu_to_le32(rx_ring->prod_idx_sh_reg_dma); 2449 cqicb->prod_idx_addr = cpu_to_le64(rx_ring->prod_idx_sh_reg_dma);
2474 cqicb->prod_idx_addr_hi =
2475 cpu_to_le32((u64) rx_ring->prod_idx_sh_reg_dma >> 32);
2476 2450
2477 /* 2451 /*
2478 * Set up the control block load flags. 2452 * Set up the control block load flags.
@@ -2483,10 +2457,8 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring)
2483 if (rx_ring->lbq_len) { 2457 if (rx_ring->lbq_len) {
2484 cqicb->flags |= FLAGS_LL; /* Load lbq values */ 2458 cqicb->flags |= FLAGS_LL; /* Load lbq values */
2485 *((u64 *) rx_ring->lbq_base_indirect) = rx_ring->lbq_base_dma; 2459 *((u64 *) rx_ring->lbq_base_indirect) = rx_ring->lbq_base_dma;
2486 cqicb->lbq_addr_lo = 2460 cqicb->lbq_addr =
2487 cpu_to_le32(rx_ring->lbq_base_indirect_dma); 2461 cpu_to_le64(rx_ring->lbq_base_indirect_dma);
2488 cqicb->lbq_addr_hi =
2489 cpu_to_le32((u64) rx_ring->lbq_base_indirect_dma >> 32);
2490 bq_len = (rx_ring->lbq_buf_size == 65536) ? 0 : 2462 bq_len = (rx_ring->lbq_buf_size == 65536) ? 0 :
2491 (u16) rx_ring->lbq_buf_size; 2463 (u16) rx_ring->lbq_buf_size;
2492 cqicb->lbq_buf_size = cpu_to_le16(bq_len); 2464 cqicb->lbq_buf_size = cpu_to_le16(bq_len);
@@ -2501,10 +2473,8 @@ static int ql_start_rx_ring(struct ql_adapter *qdev, struct rx_ring *rx_ring)
2501 if (rx_ring->sbq_len) { 2473 if (rx_ring->sbq_len) {
2502 cqicb->flags |= FLAGS_LS; /* Load sbq values */ 2474 cqicb->flags |= FLAGS_LS; /* Load sbq values */
2503 *((u64 *) rx_ring->sbq_base_indirect) = rx_ring->sbq_base_dma; 2475 *((u64 *) rx_ring->sbq_base_indirect) = rx_ring->sbq_base_dma;
2504 cqicb->sbq_addr_lo = 2476 cqicb->sbq_addr =
2505 cpu_to_le32(rx_ring->sbq_base_indirect_dma); 2477 cpu_to_le64(rx_ring->sbq_base_indirect_dma);
2506 cqicb->sbq_addr_hi =
2507 cpu_to_le32((u64) rx_ring->sbq_base_indirect_dma >> 32);
2508 cqicb->sbq_buf_size = 2478 cqicb->sbq_buf_size =
2509 cpu_to_le16(((rx_ring->sbq_buf_size / 2) + 8) & 0xfffffff8); 2479 cpu_to_le16(((rx_ring->sbq_buf_size / 2) + 8) & 0xfffffff8);
2510 bq_len = (rx_ring->sbq_len == 65536) ? 0 : 2480 bq_len = (rx_ring->sbq_len == 65536) ? 0 :
@@ -2611,12 +2581,9 @@ static int ql_start_tx_ring(struct ql_adapter *qdev, struct tx_ring *tx_ring)
2611 Q_FLAGS_LB | Q_FLAGS_LI | Q_FLAGS_LO); 2581 Q_FLAGS_LB | Q_FLAGS_LI | Q_FLAGS_LO);
2612 wqicb->cq_id_rss = cpu_to_le16(tx_ring->cq_id); 2582 wqicb->cq_id_rss = cpu_to_le16(tx_ring->cq_id);
2613 wqicb->rid = 0; 2583 wqicb->rid = 0;
2614 wqicb->addr_lo = cpu_to_le32(tx_ring->wq_base_dma); 2584 wqicb->addr = cpu_to_le64(tx_ring->wq_base_dma);
2615 wqicb->addr_hi = cpu_to_le32((u64) tx_ring->wq_base_dma >> 32);
2616 2585
2617 wqicb->cnsmr_idx_addr_lo = cpu_to_le32(tx_ring->cnsmr_idx_sh_reg_dma); 2586 wqicb->cnsmr_idx_addr = cpu_to_le64(tx_ring->cnsmr_idx_sh_reg_dma);
2618 wqicb->cnsmr_idx_addr_hi =
2619 cpu_to_le32((u64) tx_ring->cnsmr_idx_sh_reg_dma >> 32);
2620 2587
2621 ql_init_tx_ring(qdev, tx_ring); 2588 ql_init_tx_ring(qdev, tx_ring);
2622 2589
@@ -2746,14 +2713,14 @@ static void ql_resolve_queues_to_irqs(struct ql_adapter *qdev)
2746 * Outbound queue is for outbound completions only. 2713 * Outbound queue is for outbound completions only.
2747 */ 2714 */
2748 intr_context->handler = qlge_msix_tx_isr; 2715 intr_context->handler = qlge_msix_tx_isr;
2749 sprintf(intr_context->name, "%s-txq-%d", 2716 sprintf(intr_context->name, "%s-tx-%d",
2750 qdev->ndev->name, i); 2717 qdev->ndev->name, i);
2751 } else { 2718 } else {
2752 /* 2719 /*
2753 * Inbound queues handle unicast frames only. 2720 * Inbound queues handle unicast frames only.
2754 */ 2721 */
2755 intr_context->handler = qlge_msix_rx_isr; 2722 intr_context->handler = qlge_msix_rx_isr;
2756 sprintf(intr_context->name, "%s-rxq-%d", 2723 sprintf(intr_context->name, "%s-rx-%d",
2757 qdev->ndev->name, i); 2724 qdev->ndev->name, i);
2758 } 2725 }
2759 } 2726 }
@@ -3247,7 +3214,6 @@ static int qlge_close(struct net_device *ndev)
3247 msleep(1); 3214 msleep(1);
3248 ql_adapter_down(qdev); 3215 ql_adapter_down(qdev);
3249 ql_release_adapter_resources(qdev); 3216 ql_release_adapter_resources(qdev);
3250 ql_free_ring_cb(qdev);
3251 return 0; 3217 return 0;
3252} 3218}
3253 3219
@@ -3273,8 +3239,8 @@ static int ql_configure_rings(struct ql_adapter *qdev)
3273 * This limitation can be removed when requested. 3239 * This limitation can be removed when requested.
3274 */ 3240 */
3275 3241
3276 if (cpu_cnt > 8) 3242 if (cpu_cnt > MAX_CPUS)
3277 cpu_cnt = 8; 3243 cpu_cnt = MAX_CPUS;
3278 3244
3279 /* 3245 /*
3280 * rx_ring[0] is always the default queue. 3246 * rx_ring[0] is always the default queue.
@@ -3294,9 +3260,6 @@ static int ql_configure_rings(struct ql_adapter *qdev)
3294 */ 3260 */
3295 qdev->rx_ring_count = qdev->tx_ring_count + qdev->rss_ring_count + 1; 3261 qdev->rx_ring_count = qdev->tx_ring_count + qdev->rss_ring_count + 1;
3296 3262
3297 if (ql_alloc_ring_cb(qdev))
3298 return -ENOMEM;
3299
3300 for (i = 0; i < qdev->tx_ring_count; i++) { 3263 for (i = 0; i < qdev->tx_ring_count; i++) {
3301 tx_ring = &qdev->tx_ring[i]; 3264 tx_ring = &qdev->tx_ring[i];
3302 memset((void *)tx_ring, 0, sizeof(tx_ring)); 3265 memset((void *)tx_ring, 0, sizeof(tx_ring));
@@ -3393,7 +3356,6 @@ static int qlge_open(struct net_device *ndev)
3393 3356
3394error_up: 3357error_up:
3395 ql_release_adapter_resources(qdev); 3358 ql_release_adapter_resources(qdev);
3396 ql_free_ring_cb(qdev);
3397 return err; 3359 return err;
3398} 3360}
3399 3361
diff --git a/drivers/net/r6040.c b/drivers/net/r6040.c
index 53bbddfc8c95..72fd9e97c190 100644
--- a/drivers/net/r6040.c
+++ b/drivers/net/r6040.c
@@ -49,8 +49,8 @@
49#include <asm/processor.h> 49#include <asm/processor.h>
50 50
51#define DRV_NAME "r6040" 51#define DRV_NAME "r6040"
52#define DRV_VERSION "0.19" 52#define DRV_VERSION "0.21"
53#define DRV_RELDATE "18Dec2008" 53#define DRV_RELDATE "09Jan2009"
54 54
55/* PHY CHIP Address */ 55/* PHY CHIP Address */
56#define PHY1_ADDR 1 /* For MAC1 */ 56#define PHY1_ADDR 1 /* For MAC1 */
@@ -200,7 +200,7 @@ struct r6040_private {
200 200
201static char version[] __devinitdata = KERN_INFO DRV_NAME 201static char version[] __devinitdata = KERN_INFO DRV_NAME
202 ": RDC R6040 NAPI net driver," 202 ": RDC R6040 NAPI net driver,"
203 "version "DRV_VERSION " (" DRV_RELDATE ")\n"; 203 "version "DRV_VERSION " (" DRV_RELDATE ")";
204 204
205static int phy_table[] = { PHY1_ADDR, PHY2_ADDR }; 205static int phy_table[] = { PHY1_ADDR, PHY2_ADDR };
206 206
@@ -330,7 +330,7 @@ static int r6040_alloc_rxbufs(struct net_device *dev)
330 do { 330 do {
331 skb = netdev_alloc_skb(dev, MAX_BUF_SIZE); 331 skb = netdev_alloc_skb(dev, MAX_BUF_SIZE);
332 if (!skb) { 332 if (!skb) {
333 printk(KERN_ERR "%s: failed to alloc skb for rx\n", dev->name); 333 printk(KERN_ERR DRV_NAME "%s: failed to alloc skb for rx\n", dev->name);
334 rc = -ENOMEM; 334 rc = -ENOMEM;
335 goto err_exit; 335 goto err_exit;
336 } 336 }
@@ -457,22 +457,12 @@ static void r6040_down(struct net_device *dev)
457 iowrite16(adrp[0], ioaddr + MID_0L); 457 iowrite16(adrp[0], ioaddr + MID_0L);
458 iowrite16(adrp[1], ioaddr + MID_0M); 458 iowrite16(adrp[1], ioaddr + MID_0M);
459 iowrite16(adrp[2], ioaddr + MID_0H); 459 iowrite16(adrp[2], ioaddr + MID_0H);
460 free_irq(dev->irq, dev);
461
462 /* Free RX buffer */
463 r6040_free_rxbufs(dev);
464
465 /* Free TX buffer */
466 r6040_free_txbufs(dev);
467
468 /* Free Descriptor memory */
469 pci_free_consistent(pdev, RX_DESC_SIZE, lp->rx_ring, lp->rx_ring_dma);
470 pci_free_consistent(pdev, TX_DESC_SIZE, lp->tx_ring, lp->tx_ring_dma);
471} 460}
472 461
473static int r6040_close(struct net_device *dev) 462static int r6040_close(struct net_device *dev)
474{ 463{
475 struct r6040_private *lp = netdev_priv(dev); 464 struct r6040_private *lp = netdev_priv(dev);
465 struct pci_dev *pdev = lp->pdev;
476 466
477 /* deleted timer */ 467 /* deleted timer */
478 del_timer_sync(&lp->timer); 468 del_timer_sync(&lp->timer);
@@ -481,8 +471,28 @@ static int r6040_close(struct net_device *dev)
481 napi_disable(&lp->napi); 471 napi_disable(&lp->napi);
482 netif_stop_queue(dev); 472 netif_stop_queue(dev);
483 r6040_down(dev); 473 r6040_down(dev);
474
475 free_irq(dev->irq, dev);
476
477 /* Free RX buffer */
478 r6040_free_rxbufs(dev);
479
480 /* Free TX buffer */
481 r6040_free_txbufs(dev);
482
484 spin_unlock_irq(&lp->lock); 483 spin_unlock_irq(&lp->lock);
485 484
485 /* Free Descriptor memory */
486 if (lp->rx_ring) {
487 pci_free_consistent(pdev, RX_DESC_SIZE, lp->rx_ring, lp->rx_ring_dma);
488 lp->rx_ring = 0;
489 }
490
491 if (lp->tx_ring) {
492 pci_free_consistent(pdev, TX_DESC_SIZE, lp->tx_ring, lp->tx_ring_dma);
493 lp->tx_ring = 0;
494 }
495
486 return 0; 496 return 0;
487} 497}
488 498
@@ -1049,6 +1059,7 @@ static const struct net_device_ops r6040_netdev_ops = {
1049 .ndo_set_multicast_list = r6040_multicast_list, 1059 .ndo_set_multicast_list = r6040_multicast_list,
1050 .ndo_change_mtu = eth_change_mtu, 1060 .ndo_change_mtu = eth_change_mtu,
1051 .ndo_validate_addr = eth_validate_addr, 1061 .ndo_validate_addr = eth_validate_addr,
1062 .ndo_set_mac_address = eth_mac_addr,
1052 .ndo_do_ioctl = r6040_ioctl, 1063 .ndo_do_ioctl = r6040_ioctl,
1053 .ndo_tx_timeout = r6040_tx_timeout, 1064 .ndo_tx_timeout = r6040_tx_timeout,
1054#ifdef CONFIG_NET_POLL_CONTROLLER 1065#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -1077,20 +1088,20 @@ static int __devinit r6040_init_one(struct pci_dev *pdev,
1077 /* this should always be supported */ 1088 /* this should always be supported */
1078 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 1089 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
1079 if (err) { 1090 if (err) {
1080 printk(KERN_ERR DRV_NAME "32-bit PCI DMA addresses" 1091 printk(KERN_ERR DRV_NAME ": 32-bit PCI DMA addresses"
1081 "not supported by the card\n"); 1092 "not supported by the card\n");
1082 goto err_out; 1093 goto err_out;
1083 } 1094 }
1084 err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); 1095 err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
1085 if (err) { 1096 if (err) {
1086 printk(KERN_ERR DRV_NAME "32-bit PCI DMA addresses" 1097 printk(KERN_ERR DRV_NAME ": 32-bit PCI DMA addresses"
1087 "not supported by the card\n"); 1098 "not supported by the card\n");
1088 goto err_out; 1099 goto err_out;
1089 } 1100 }
1090 1101
1091 /* IO Size check */ 1102 /* IO Size check */
1092 if (pci_resource_len(pdev, 0) < io_size) { 1103 if (pci_resource_len(pdev, 0) < io_size) {
1093 printk(KERN_ERR DRV_NAME "Insufficient PCI resources, aborting\n"); 1104 printk(KERN_ERR DRV_NAME ": Insufficient PCI resources, aborting\n");
1094 err = -EIO; 1105 err = -EIO;
1095 goto err_out; 1106 goto err_out;
1096 } 1107 }
@@ -1100,7 +1111,7 @@ static int __devinit r6040_init_one(struct pci_dev *pdev,
1100 1111
1101 dev = alloc_etherdev(sizeof(struct r6040_private)); 1112 dev = alloc_etherdev(sizeof(struct r6040_private));
1102 if (!dev) { 1113 if (!dev) {
1103 printk(KERN_ERR DRV_NAME "Failed to allocate etherdev\n"); 1114 printk(KERN_ERR DRV_NAME ": Failed to allocate etherdev\n");
1104 err = -ENOMEM; 1115 err = -ENOMEM;
1105 goto err_out; 1116 goto err_out;
1106 } 1117 }
@@ -1116,11 +1127,15 @@ static int __devinit r6040_init_one(struct pci_dev *pdev,
1116 1127
1117 ioaddr = pci_iomap(pdev, bar, io_size); 1128 ioaddr = pci_iomap(pdev, bar, io_size);
1118 if (!ioaddr) { 1129 if (!ioaddr) {
1119 printk(KERN_ERR "ioremap failed for device %s\n", 1130 printk(KERN_ERR DRV_NAME ": ioremap failed for device %s\n",
1120 pci_name(pdev)); 1131 pci_name(pdev));
1121 err = -EIO; 1132 err = -EIO;
1122 goto err_out_free_res; 1133 goto err_out_free_res;
1123 } 1134 }
1135 /* If PHY status change register is still set to zero it means the
1136 * bootloader didn't initialize it */
1137 if (ioread16(ioaddr + PHY_CC) == 0)
1138 iowrite16(0x9f07, ioaddr + PHY_CC);
1124 1139
1125 /* Init system & device */ 1140 /* Init system & device */
1126 lp->base = ioaddr; 1141 lp->base = ioaddr;
@@ -1137,6 +1152,13 @@ static int __devinit r6040_init_one(struct pci_dev *pdev,
1137 adrp[1] = ioread16(ioaddr + MID_0M); 1152 adrp[1] = ioread16(ioaddr + MID_0M);
1138 adrp[2] = ioread16(ioaddr + MID_0H); 1153 adrp[2] = ioread16(ioaddr + MID_0H);
1139 1154
1155 /* Some bootloader/BIOSes do not initialize
1156 * MAC address, warn about that */
1157 if (!(adrp[0] || adrp[1] || adrp[2])) {
1158 printk(KERN_WARNING DRV_NAME ": MAC address not initialized, generating random\n");
1159 random_ether_addr(dev->dev_addr);
1160 }
1161
1140 /* Link new device into r6040_root_dev */ 1162 /* Link new device into r6040_root_dev */
1141 lp->pdev = pdev; 1163 lp->pdev = pdev;
1142 lp->dev = dev; 1164 lp->dev = dev;
diff --git a/drivers/net/sb1000.c b/drivers/net/sb1000.c
index be3025310e90..fc0e38bddeeb 100644
--- a/drivers/net/sb1000.c
+++ b/drivers/net/sb1000.c
@@ -134,6 +134,16 @@ static const struct pnp_device_id sb1000_pnp_ids[] = {
134}; 134};
135MODULE_DEVICE_TABLE(pnp, sb1000_pnp_ids); 135MODULE_DEVICE_TABLE(pnp, sb1000_pnp_ids);
136 136
137static const struct net_device_ops sb1000_netdev_ops = {
138 .ndo_open = sb1000_open,
139 .ndo_start_xmit = sb1000_start_xmit,
140 .ndo_do_ioctl = sb1000_dev_ioctl,
141 .ndo_stop = sb1000_close,
142 .ndo_change_mtu = eth_change_mtu,
143 .ndo_set_mac_address = eth_mac_addr,
144 .ndo_validate_addr = eth_validate_addr,
145};
146
137static int 147static int
138sb1000_probe_one(struct pnp_dev *pdev, const struct pnp_device_id *id) 148sb1000_probe_one(struct pnp_dev *pdev, const struct pnp_device_id *id)
139{ 149{
@@ -192,11 +202,7 @@ sb1000_probe_one(struct pnp_dev *pdev, const struct pnp_device_id *id)
192 if (sb1000_debug > 0) 202 if (sb1000_debug > 0)
193 printk(KERN_NOTICE "%s", version); 203 printk(KERN_NOTICE "%s", version);
194 204
195 /* The SB1000-specific entries in the device structure. */ 205 dev->netdev_ops = &sb1000_netdev_ops;
196 dev->open = sb1000_open;
197 dev->do_ioctl = sb1000_dev_ioctl;
198 dev->hard_start_xmit = sb1000_start_xmit;
199 dev->stop = sb1000_close;
200 206
201 /* hardware address is 0:0:serial_number */ 207 /* hardware address is 0:0:serial_number */
202 dev->dev_addr[2] = serial_number >> 24 & 0xff; 208 dev->dev_addr[2] = serial_number >> 24 & 0xff;
diff --git a/drivers/net/sc92031.c b/drivers/net/sc92031.c
index 42fd31276602..8b75bef4a841 100644
--- a/drivers/net/sc92031.c
+++ b/drivers/net/sc92031.c
@@ -1408,6 +1408,7 @@ static const struct net_device_ops sc92031_netdev_ops = {
1408 .ndo_set_multicast_list = sc92031_set_multicast_list, 1408 .ndo_set_multicast_list = sc92031_set_multicast_list,
1409 .ndo_change_mtu = eth_change_mtu, 1409 .ndo_change_mtu = eth_change_mtu,
1410 .ndo_validate_addr = eth_validate_addr, 1410 .ndo_validate_addr = eth_validate_addr,
1411 .ndo_set_mac_address = eth_mac_addr,
1411 .ndo_tx_timeout = sc92031_tx_timeout, 1412 .ndo_tx_timeout = sc92031_tx_timeout,
1412#ifdef CONFIG_NET_POLL_CONTROLLER 1413#ifdef CONFIG_NET_POLL_CONTROLLER
1413 .ndo_poll_controller = sc92031_poll_controller, 1414 .ndo_poll_controller = sc92031_poll_controller,
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c
index 6884dc8c1f82..5b9f2d9cc4ed 100644
--- a/drivers/net/sfc/falcon.c
+++ b/drivers/net/sfc/falcon.c
@@ -1403,9 +1403,9 @@ static irqreturn_t falcon_fatal_interrupt(struct efx_nic *efx)
1403 } 1403 }
1404 1404
1405 /* Disable both devices */ 1405 /* Disable both devices */
1406 pci_disable_device(efx->pci_dev); 1406 pci_clear_master(efx->pci_dev);
1407 if (FALCON_IS_DUAL_FUNC(efx)) 1407 if (FALCON_IS_DUAL_FUNC(efx))
1408 pci_disable_device(nic_data->pci_dev2); 1408 pci_clear_master(nic_data->pci_dev2);
1409 falcon_disable_interrupts(efx); 1409 falcon_disable_interrupts(efx);
1410 1410
1411 if (++n_int_errors < FALCON_MAX_INT_ERRORS) { 1411 if (++n_int_errors < FALCON_MAX_INT_ERRORS) {
diff --git a/drivers/net/sfc/tenxpress.c b/drivers/net/sfc/tenxpress.c
index b9768760fae7..9ecb77da9545 100644
--- a/drivers/net/sfc/tenxpress.c
+++ b/drivers/net/sfc/tenxpress.c
@@ -636,10 +636,11 @@ static void tenxpress_phy_fini(struct efx_nic *efx)
636{ 636{
637 int reg; 637 int reg;
638 638
639 if (efx->phy_type == PHY_TYPE_SFT9001B) { 639 if (efx->phy_type == PHY_TYPE_SFT9001B)
640 device_remove_file(&efx->pci_dev->dev, 640 device_remove_file(&efx->pci_dev->dev,
641 &dev_attr_phy_short_reach); 641 &dev_attr_phy_short_reach);
642 } else { 642
643 if (efx->phy_type == PHY_TYPE_SFX7101) {
643 /* Power down the LNPGA */ 644 /* Power down the LNPGA */
644 reg = (1 << PMA_PMD_LNPGA_POWERDOWN_LBN); 645 reg = (1 << PMA_PMD_LNPGA_POWERDOWN_LBN);
645 mdio_clause45_write(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD, 646 mdio_clause45_write(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD,
diff --git a/drivers/net/sis190.c b/drivers/net/sis190.c
index 83cc3c5f7946..a9732686134b 100644
--- a/drivers/net/sis190.c
+++ b/drivers/net/sis190.c
@@ -1782,6 +1782,21 @@ static int sis190_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1782 generic_mii_ioctl(&tp->mii_if, if_mii(ifr), cmd, NULL); 1782 generic_mii_ioctl(&tp->mii_if, if_mii(ifr), cmd, NULL);
1783} 1783}
1784 1784
1785static const struct net_device_ops sis190_netdev_ops = {
1786 .ndo_open = sis190_open,
1787 .ndo_stop = sis190_close,
1788 .ndo_do_ioctl = sis190_ioctl,
1789 .ndo_start_xmit = sis190_start_xmit,
1790 .ndo_tx_timeout = sis190_tx_timeout,
1791 .ndo_set_multicast_list = sis190_set_rx_mode,
1792 .ndo_change_mtu = eth_change_mtu,
1793 .ndo_set_mac_address = eth_mac_addr,
1794 .ndo_validate_addr = eth_validate_addr,
1795#ifdef CONFIG_NET_POLL_CONTROLLER
1796 .ndo_poll_controller = sis190_netpoll,
1797#endif
1798};
1799
1785static int __devinit sis190_init_one(struct pci_dev *pdev, 1800static int __devinit sis190_init_one(struct pci_dev *pdev,
1786 const struct pci_device_id *ent) 1801 const struct pci_device_id *ent)
1787{ 1802{
@@ -1815,19 +1830,12 @@ static int __devinit sis190_init_one(struct pci_dev *pdev,
1815 1830
1816 INIT_WORK(&tp->phy_task, sis190_phy_task); 1831 INIT_WORK(&tp->phy_task, sis190_phy_task);
1817 1832
1818 dev->open = sis190_open; 1833 dev->netdev_ops = &sis190_netdev_ops;
1819 dev->stop = sis190_close; 1834
1820 dev->do_ioctl = sis190_ioctl;
1821 dev->tx_timeout = sis190_tx_timeout;
1822 dev->watchdog_timeo = SIS190_TX_TIMEOUT;
1823 dev->hard_start_xmit = sis190_start_xmit;
1824#ifdef CONFIG_NET_POLL_CONTROLLER
1825 dev->poll_controller = sis190_netpoll;
1826#endif
1827 dev->set_multicast_list = sis190_set_rx_mode;
1828 SET_ETHTOOL_OPS(dev, &sis190_ethtool_ops); 1835 SET_ETHTOOL_OPS(dev, &sis190_ethtool_ops);
1829 dev->irq = pdev->irq; 1836 dev->irq = pdev->irq;
1830 dev->base_addr = (unsigned long) 0xdead; 1837 dev->base_addr = (unsigned long) 0xdead;
1838 dev->watchdog_timeo = SIS190_TX_TIMEOUT;
1831 1839
1832 spin_lock_init(&tp->lock); 1840 spin_lock_init(&tp->lock);
1833 1841
diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c
index 4acd41a093ad..be4465bc0a69 100644
--- a/drivers/net/sis900.c
+++ b/drivers/net/sis900.c
@@ -389,6 +389,7 @@ static const struct net_device_ops sis900_netdev_ops = {
389 .ndo_set_multicast_list = set_rx_mode, 389 .ndo_set_multicast_list = set_rx_mode,
390 .ndo_change_mtu = eth_change_mtu, 390 .ndo_change_mtu = eth_change_mtu,
391 .ndo_validate_addr = eth_validate_addr, 391 .ndo_validate_addr = eth_validate_addr,
392 .ndo_set_mac_address = eth_mac_addr,
392 .ndo_do_ioctl = mii_ioctl, 393 .ndo_do_ioctl = mii_ioctl,
393 .ndo_tx_timeout = sis900_tx_timeout, 394 .ndo_tx_timeout = sis900_tx_timeout,
394#ifdef CONFIG_NET_POLL_CONTROLLER 395#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -508,10 +509,10 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
508 else 509 else
509 ret = sis900_get_mac_addr(pci_dev, net_dev); 510 ret = sis900_get_mac_addr(pci_dev, net_dev);
510 511
511 if (ret == 0) { 512 if (!ret || !is_valid_ether_addr(net_dev->dev_addr)) {
512 printk(KERN_WARNING "%s: Cannot read MAC address.\n", dev_name); 513 random_ether_addr(net_dev->dev_addr);
513 ret = -ENODEV; 514 printk(KERN_WARNING "%s: Unreadable or invalid MAC address,"
514 goto err_unmap_rx; 515 "using random generated one\n", dev_name);
515 } 516 }
516 517
517 /* 630ET : set the mii access mode as software-mode */ 518 /* 630ET : set the mii access mode as software-mode */
diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index 8e1c0baf6958..5c61d5fad908 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -603,7 +603,6 @@ static int sl_init(struct net_device *dev)
603 dev->mtu = sl->mtu; 603 dev->mtu = sl->mtu;
604 dev->type = ARPHRD_SLIP + sl->mode; 604 dev->type = ARPHRD_SLIP + sl->mode;
605#ifdef SL_CHECK_TRANSMIT 605#ifdef SL_CHECK_TRANSMIT
606 dev->tx_timeout = sl_tx_timeout;
607 dev->watchdog_timeo = 20*HZ; 606 dev->watchdog_timeo = 20*HZ;
608#endif 607#endif
609 return 0; 608 return 0;
@@ -617,19 +616,26 @@ static void sl_uninit(struct net_device *dev)
617 sl_free_bufs(sl); 616 sl_free_bufs(sl);
618} 617}
619 618
619static const struct net_device_ops sl_netdev_ops = {
620 .ndo_init = sl_init,
621 .ndo_uninit = sl_uninit,
622 .ndo_open = sl_open,
623 .ndo_stop = sl_close,
624 .ndo_start_xmit = sl_xmit,
625 .ndo_get_stats = sl_get_stats,
626 .ndo_change_mtu = sl_change_mtu,
627 .ndo_tx_timeout = sl_tx_timeout,
628#ifdef CONFIG_SLIP_SMART
629 .ndo_do_ioctl = sl_ioctl,
630#endif
631};
632
633
620static void sl_setup(struct net_device *dev) 634static void sl_setup(struct net_device *dev)
621{ 635{
622 dev->init = sl_init; 636 dev->netdev_ops = &sl_netdev_ops;
623 dev->uninit = sl_uninit;
624 dev->open = sl_open;
625 dev->destructor = free_netdev; 637 dev->destructor = free_netdev;
626 dev->stop = sl_close; 638
627 dev->get_stats = sl_get_stats;
628 dev->change_mtu = sl_change_mtu;
629 dev->hard_start_xmit = sl_xmit;
630#ifdef CONFIG_SLIP_SMART
631 dev->do_ioctl = sl_ioctl;
632#endif
633 dev->hard_header_len = 0; 639 dev->hard_header_len = 0;
634 dev->addr_len = 0; 640 dev->addr_len = 0;
635 dev->tx_queue_len = 10; 641 dev->tx_queue_len = 10;
diff --git a/drivers/net/slip.h b/drivers/net/slip.h
index 853e0f6ec710..9ea5c11287d2 100644
--- a/drivers/net/slip.h
+++ b/drivers/net/slip.h
@@ -75,7 +75,7 @@ struct slip {
75 unsigned long tx_errors; /* Planned stuff */ 75 unsigned long tx_errors; /* Planned stuff */
76 unsigned long rx_dropped; /* No memory for skb */ 76 unsigned long rx_dropped; /* No memory for skb */
77 unsigned long tx_dropped; /* When MTU change */ 77 unsigned long tx_dropped; /* When MTU change */
78 unsigned long rx_over_errors; /* Frame bigger then SLIP buf. */ 78 unsigned long rx_over_errors; /* Frame bigger than SLIP buf. */
79#ifdef SL_INCLUDE_CSLIP 79#ifdef SL_INCLUDE_CSLIP
80 unsigned long tx_compressed; 80 unsigned long tx_compressed;
81 unsigned long rx_compressed; 81 unsigned long rx_compressed;
diff --git a/drivers/net/smc-mca.c b/drivers/net/smc-mca.c
index 404b80e5ba11..8d36d40649ef 100644
--- a/drivers/net/smc-mca.c
+++ b/drivers/net/smc-mca.c
@@ -192,6 +192,7 @@ static const struct net_device_ops ultramca_netdev_ops = {
192 .ndo_get_stats = ei_get_stats, 192 .ndo_get_stats = ei_get_stats,
193 .ndo_set_multicast_list = ei_set_multicast_list, 193 .ndo_set_multicast_list = ei_set_multicast_list,
194 .ndo_validate_addr = eth_validate_addr, 194 .ndo_validate_addr = eth_validate_addr,
195 .ndo_set_mac_address = eth_mac_addr,
195 .ndo_change_mtu = eth_change_mtu, 196 .ndo_change_mtu = eth_change_mtu,
196#ifdef CONFIG_NET_POLL_CONTROLLER 197#ifdef CONFIG_NET_POLL_CONTROLLER
197 .ndo_poll_controller = ei_poll, 198 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/smc-ultra.c b/drivers/net/smc-ultra.c
index b3866089a206..2033fee3143a 100644
--- a/drivers/net/smc-ultra.c
+++ b/drivers/net/smc-ultra.c
@@ -196,6 +196,7 @@ static const struct net_device_ops ultra_netdev_ops = {
196 .ndo_get_stats = ei_get_stats, 196 .ndo_get_stats = ei_get_stats,
197 .ndo_set_multicast_list = ei_set_multicast_list, 197 .ndo_set_multicast_list = ei_set_multicast_list,
198 .ndo_validate_addr = eth_validate_addr, 198 .ndo_validate_addr = eth_validate_addr,
199 .ndo_set_mac_address = eth_mac_addr,
199 .ndo_change_mtu = eth_change_mtu, 200 .ndo_change_mtu = eth_change_mtu,
200#ifdef CONFIG_NET_POLL_CONTROLLER 201#ifdef CONFIG_NET_POLL_CONTROLLER
201 .ndo_poll_controller = ei_poll, 202 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/smsc911x.c b/drivers/net/smsc911x.c
index dc3f1108884d..f513bdf1c887 100644
--- a/drivers/net/smsc911x.c
+++ b/drivers/net/smsc911x.c
@@ -144,6 +144,7 @@ static inline u32 smsc911x_reg_read(struct smsc911x_data *pdata, u32 reg)
144 } 144 }
145 145
146 BUG(); 146 BUG();
147 return 0;
147} 148}
148 149
149static inline void smsc911x_reg_write(struct smsc911x_data *pdata, u32 reg, 150static inline void smsc911x_reg_write(struct smsc911x_data *pdata, u32 reg,
@@ -1740,6 +1741,7 @@ static const struct net_device_ops smsc911x_netdev_ops = {
1740 .ndo_set_multicast_list = smsc911x_set_multicast_list, 1741 .ndo_set_multicast_list = smsc911x_set_multicast_list,
1741 .ndo_do_ioctl = smsc911x_do_ioctl, 1742 .ndo_do_ioctl = smsc911x_do_ioctl,
1742 .ndo_validate_addr = eth_validate_addr, 1743 .ndo_validate_addr = eth_validate_addr,
1744 .ndo_set_mac_address = eth_mac_addr,
1743#ifdef CONFIG_NET_POLL_CONTROLLER 1745#ifdef CONFIG_NET_POLL_CONTROLLER
1744 .ndo_poll_controller = smsc911x_poll_controller, 1746 .ndo_poll_controller = smsc911x_poll_controller,
1745#endif 1747#endif
@@ -1967,7 +1969,7 @@ static int __devinit smsc911x_drv_probe(struct platform_device *pdev)
1967 smsc911x_reg_write(pdata, INT_STS, 0xFFFFFFFF); 1969 smsc911x_reg_write(pdata, INT_STS, 0xFFFFFFFF);
1968 1970
1969 retval = request_irq(dev->irq, smsc911x_irqhandler, IRQF_DISABLED, 1971 retval = request_irq(dev->irq, smsc911x_irqhandler, IRQF_DISABLED,
1970 SMSC_CHIPNAME, dev); 1972 dev->name, dev);
1971 if (retval) { 1973 if (retval) {
1972 SMSC_WARNING(PROBE, 1974 SMSC_WARNING(PROBE,
1973 "Unable to claim requested irq: %d", dev->irq); 1975 "Unable to claim requested irq: %d", dev->irq);
diff --git a/drivers/net/smsc9420.c b/drivers/net/smsc9420.c
index 27e017d96966..c14a4c6452c7 100644
--- a/drivers/net/smsc9420.c
+++ b/drivers/net/smsc9420.c
@@ -1551,6 +1551,7 @@ static const struct net_device_ops smsc9420_netdev_ops = {
1551 .ndo_set_multicast_list = smsc9420_set_multicast_list, 1551 .ndo_set_multicast_list = smsc9420_set_multicast_list,
1552 .ndo_do_ioctl = smsc9420_do_ioctl, 1552 .ndo_do_ioctl = smsc9420_do_ioctl,
1553 .ndo_validate_addr = eth_validate_addr, 1553 .ndo_validate_addr = eth_validate_addr,
1554 .ndo_set_mac_address = eth_mac_addr,
1554#ifdef CONFIG_NET_POLL_CONTROLLER 1555#ifdef CONFIG_NET_POLL_CONTROLLER
1555 .ndo_poll_controller = smsc9420_poll_controller, 1556 .ndo_poll_controller = smsc9420_poll_controller,
1556#endif /* CONFIG_NET_POLL_CONTROLLER */ 1557#endif /* CONFIG_NET_POLL_CONTROLLER */
diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c
index 57fb1f71c47b..da3a76b18eff 100644
--- a/drivers/net/starfire.c
+++ b/drivers/net/starfire.c
@@ -648,6 +648,24 @@ static void netdev_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
648#endif /* VLAN_SUPPORT */ 648#endif /* VLAN_SUPPORT */
649 649
650 650
651static const struct net_device_ops netdev_ops = {
652 .ndo_open = netdev_open,
653 .ndo_stop = netdev_close,
654 .ndo_start_xmit = start_tx,
655 .ndo_tx_timeout = tx_timeout,
656 .ndo_get_stats = get_stats,
657 .ndo_set_multicast_list = &set_rx_mode,
658 .ndo_do_ioctl = netdev_ioctl,
659 .ndo_change_mtu = eth_change_mtu,
660 .ndo_set_mac_address = eth_mac_addr,
661 .ndo_validate_addr = eth_validate_addr,
662#ifdef VLAN_SUPPORT
663 .ndo_vlan_rx_register = netdev_vlan_rx_register,
664 .ndo_vlan_rx_add_vid = netdev_vlan_rx_add_vid,
665 .ndo_vlan_rx_kill_vid = netdev_vlan_rx_kill_vid,
666#endif
667};
668
651static int __devinit starfire_init_one(struct pci_dev *pdev, 669static int __devinit starfire_init_one(struct pci_dev *pdev,
652 const struct pci_device_id *ent) 670 const struct pci_device_id *ent)
653{ 671{
@@ -710,11 +728,9 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
710 if (enable_hw_cksum) 728 if (enable_hw_cksum)
711 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG; 729 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
712#endif /* ZEROCOPY */ 730#endif /* ZEROCOPY */
731
713#ifdef VLAN_SUPPORT 732#ifdef VLAN_SUPPORT
714 dev->features |= NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_FILTER; 733 dev->features |= NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_FILTER;
715 dev->vlan_rx_register = netdev_vlan_rx_register;
716 dev->vlan_rx_add_vid = netdev_vlan_rx_add_vid;
717 dev->vlan_rx_kill_vid = netdev_vlan_rx_kill_vid;
718#endif /* VLAN_RX_KILL_VID */ 734#endif /* VLAN_RX_KILL_VID */
719#ifdef ADDR_64BITS 735#ifdef ADDR_64BITS
720 dev->features |= NETIF_F_HIGHDMA; 736 dev->features |= NETIF_F_HIGHDMA;
@@ -810,18 +826,12 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
810 } 826 }
811 } 827 }
812 828
813 /* The chip-specific entries in the device structure. */ 829 dev->netdev_ops = &netdev_ops;
814 dev->open = &netdev_open;
815 dev->hard_start_xmit = &start_tx;
816 dev->tx_timeout = tx_timeout;
817 dev->watchdog_timeo = TX_TIMEOUT; 830 dev->watchdog_timeo = TX_TIMEOUT;
818 netif_napi_add(dev, &np->napi, netdev_poll, max_interrupt_work);
819 dev->stop = &netdev_close;
820 dev->get_stats = &get_stats;
821 dev->set_multicast_list = &set_rx_mode;
822 dev->do_ioctl = &netdev_ioctl;
823 SET_ETHTOOL_OPS(dev, &ethtool_ops); 831 SET_ETHTOOL_OPS(dev, &ethtool_ops);
824 832
833 netif_napi_add(dev, &np->napi, netdev_poll, max_interrupt_work);
834
825 if (mtu) 835 if (mtu)
826 dev->mtu = mtu; 836 dev->mtu = mtu;
827 837
diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c
index 698893b92003..feaf0e0577d7 100644
--- a/drivers/net/sundance.c
+++ b/drivers/net/sundance.c
@@ -449,6 +449,19 @@ static void sundance_reset(struct net_device *dev, unsigned long reset_cmd)
449 } 449 }
450} 450}
451 451
452static const struct net_device_ops netdev_ops = {
453 .ndo_open = netdev_open,
454 .ndo_stop = netdev_close,
455 .ndo_start_xmit = start_tx,
456 .ndo_get_stats = get_stats,
457 .ndo_set_multicast_list = set_rx_mode,
458 .ndo_do_ioctl = netdev_ioctl,
459 .ndo_tx_timeout = tx_timeout,
460 .ndo_change_mtu = change_mtu,
461 .ndo_set_mac_address = eth_mac_addr,
462 .ndo_validate_addr = eth_validate_addr,
463};
464
452static int __devinit sundance_probe1 (struct pci_dev *pdev, 465static int __devinit sundance_probe1 (struct pci_dev *pdev,
453 const struct pci_device_id *ent) 466 const struct pci_device_id *ent)
454{ 467{
@@ -530,16 +543,10 @@ static int __devinit sundance_probe1 (struct pci_dev *pdev,
530 np->mii_if.reg_num_mask = 0x1f; 543 np->mii_if.reg_num_mask = 0x1f;
531 544
532 /* The chip-specific entries in the device structure. */ 545 /* The chip-specific entries in the device structure. */
533 dev->open = &netdev_open; 546 dev->netdev_ops = &netdev_ops;
534 dev->hard_start_xmit = &start_tx;
535 dev->stop = &netdev_close;
536 dev->get_stats = &get_stats;
537 dev->set_multicast_list = &set_rx_mode;
538 dev->do_ioctl = &netdev_ioctl;
539 SET_ETHTOOL_OPS(dev, &ethtool_ops); 547 SET_ETHTOOL_OPS(dev, &ethtool_ops);
540 dev->tx_timeout = &tx_timeout;
541 dev->watchdog_timeo = TX_TIMEOUT; 548 dev->watchdog_timeo = TX_TIMEOUT;
542 dev->change_mtu = &change_mtu; 549
543 pci_set_drvdata(pdev, dev); 550 pci_set_drvdata(pdev, dev);
544 551
545 i = register_netdev(dev); 552 i = register_netdev(dev);
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c
index 8a7460412482..86c765d83de1 100644
--- a/drivers/net/sungem.c
+++ b/drivers/net/sungem.c
@@ -2989,6 +2989,19 @@ static void gem_remove_one(struct pci_dev *pdev)
2989 } 2989 }
2990} 2990}
2991 2991
2992static const struct net_device_ops gem_netdev_ops = {
2993 .ndo_open = gem_open,
2994 .ndo_stop = gem_close,
2995 .ndo_start_xmit = gem_start_xmit,
2996 .ndo_get_stats = gem_get_stats,
2997 .ndo_set_multicast_list = gem_set_multicast,
2998 .ndo_do_ioctl = gem_ioctl,
2999 .ndo_tx_timeout = gem_tx_timeout,
3000 .ndo_change_mtu = gem_change_mtu,
3001 .ndo_set_mac_address = eth_mac_addr,
3002 .ndo_validate_addr = eth_validate_addr,
3003};
3004
2992static int __devinit gem_init_one(struct pci_dev *pdev, 3005static int __devinit gem_init_one(struct pci_dev *pdev,
2993 const struct pci_device_id *ent) 3006 const struct pci_device_id *ent)
2994{ 3007{
@@ -3142,17 +3155,10 @@ static int __devinit gem_init_one(struct pci_dev *pdev,
3142 if (gem_get_device_address(gp)) 3155 if (gem_get_device_address(gp))
3143 goto err_out_free_consistent; 3156 goto err_out_free_consistent;
3144 3157
3145 dev->open = gem_open; 3158 dev->netdev_ops = &gem_netdev_ops;
3146 dev->stop = gem_close;
3147 dev->hard_start_xmit = gem_start_xmit;
3148 dev->get_stats = gem_get_stats;
3149 dev->set_multicast_list = gem_set_multicast;
3150 dev->do_ioctl = gem_ioctl;
3151 netif_napi_add(dev, &gp->napi, gem_poll, 64); 3159 netif_napi_add(dev, &gp->napi, gem_poll, 64);
3152 dev->ethtool_ops = &gem_ethtool_ops; 3160 dev->ethtool_ops = &gem_ethtool_ops;
3153 dev->tx_timeout = gem_tx_timeout;
3154 dev->watchdog_timeo = 5 * HZ; 3161 dev->watchdog_timeo = 5 * HZ;
3155 dev->change_mtu = gem_change_mtu;
3156 dev->irq = pdev->irq; 3162 dev->irq = pdev->irq;
3157 dev->dma = 0; 3163 dev->dma = 0;
3158 dev->set_mac_address = gem_set_mac_address; 3164 dev->set_mac_address = gem_set_mac_address;
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c
index b22d3355fb45..7a72a3112f0a 100644
--- a/drivers/net/sunhme.c
+++ b/drivers/net/sunhme.c
@@ -2607,6 +2607,18 @@ static struct quattro * __devinit quattro_pci_find(struct pci_dev *pdev)
2607} 2607}
2608#endif /* CONFIG_PCI */ 2608#endif /* CONFIG_PCI */
2609 2609
2610static const struct net_device_ops hme_netdev_ops = {
2611 .ndo_open = happy_meal_open,
2612 .ndo_stop = happy_meal_close,
2613 .ndo_start_xmit = happy_meal_start_xmit,
2614 .ndo_tx_timeout = happy_meal_tx_timeout,
2615 .ndo_get_stats = happy_meal_get_stats,
2616 .ndo_set_multicast_list = happy_meal_set_multicast,
2617 .ndo_change_mtu = eth_change_mtu,
2618 .ndo_set_mac_address = eth_mac_addr,
2619 .ndo_validate_addr = eth_validate_addr,
2620};
2621
2610#ifdef CONFIG_SBUS 2622#ifdef CONFIG_SBUS
2611static int __devinit happy_meal_sbus_probe_one(struct of_device *op, int is_qfe) 2623static int __devinit happy_meal_sbus_probe_one(struct of_device *op, int is_qfe)
2612{ 2624{
@@ -2750,12 +2762,7 @@ static int __devinit happy_meal_sbus_probe_one(struct of_device *op, int is_qfe)
2750 init_timer(&hp->happy_timer); 2762 init_timer(&hp->happy_timer);
2751 2763
2752 hp->dev = dev; 2764 hp->dev = dev;
2753 dev->open = &happy_meal_open; 2765 dev->netdev_ops = &hme_netdev_ops;
2754 dev->stop = &happy_meal_close;
2755 dev->hard_start_xmit = &happy_meal_start_xmit;
2756 dev->get_stats = &happy_meal_get_stats;
2757 dev->set_multicast_list = &happy_meal_set_multicast;
2758 dev->tx_timeout = &happy_meal_tx_timeout;
2759 dev->watchdog_timeo = 5*HZ; 2766 dev->watchdog_timeo = 5*HZ;
2760 dev->ethtool_ops = &hme_ethtool_ops; 2767 dev->ethtool_ops = &hme_ethtool_ops;
2761 2768
@@ -3076,12 +3083,7 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev,
3076 init_timer(&hp->happy_timer); 3083 init_timer(&hp->happy_timer);
3077 3084
3078 hp->dev = dev; 3085 hp->dev = dev;
3079 dev->open = &happy_meal_open; 3086 dev->netdev_ops = &hme_netdev_ops;
3080 dev->stop = &happy_meal_close;
3081 dev->hard_start_xmit = &happy_meal_start_xmit;
3082 dev->get_stats = &happy_meal_get_stats;
3083 dev->set_multicast_list = &happy_meal_set_multicast;
3084 dev->tx_timeout = &happy_meal_tx_timeout;
3085 dev->watchdog_timeo = 5*HZ; 3087 dev->watchdog_timeo = 5*HZ;
3086 dev->ethtool_ops = &hme_ethtool_ops; 3088 dev->ethtool_ops = &hme_ethtool_ops;
3087 dev->irq = pdev->irq; 3089 dev->irq = pdev->irq;
diff --git a/drivers/net/sunvnet.c b/drivers/net/sunvnet.c
index 233f1cda36e5..611230fef2b6 100644
--- a/drivers/net/sunvnet.c
+++ b/drivers/net/sunvnet.c
@@ -336,7 +336,7 @@ static int vnet_walk_rx_one(struct vnet_port *port,
336 if (IS_ERR(desc)) 336 if (IS_ERR(desc))
337 return PTR_ERR(desc); 337 return PTR_ERR(desc);
338 338
339 viodbg(DATA, "vio_walk_rx_one desc[%02x:%02x:%08x:%08x:%lx:%lx]\n", 339 viodbg(DATA, "vio_walk_rx_one desc[%02x:%02x:%08x:%08x:%llx:%llx]\n",
340 desc->hdr.state, desc->hdr.ack, 340 desc->hdr.state, desc->hdr.ack,
341 desc->size, desc->ncookies, 341 desc->size, desc->ncookies,
342 desc->cookies[0].cookie_addr, 342 desc->cookies[0].cookie_addr,
@@ -394,14 +394,14 @@ static int vnet_rx(struct vnet_port *port, void *msgbuf)
394 struct vio_dring_state *dr = &port->vio.drings[VIO_DRIVER_RX_RING]; 394 struct vio_dring_state *dr = &port->vio.drings[VIO_DRIVER_RX_RING];
395 struct vio_driver_state *vio = &port->vio; 395 struct vio_driver_state *vio = &port->vio;
396 396
397 viodbg(DATA, "vnet_rx stype_env[%04x] seq[%016lx] rcv_nxt[%016lx]\n", 397 viodbg(DATA, "vnet_rx stype_env[%04x] seq[%016llx] rcv_nxt[%016llx]\n",
398 pkt->tag.stype_env, pkt->seq, dr->rcv_nxt); 398 pkt->tag.stype_env, pkt->seq, dr->rcv_nxt);
399 399
400 if (unlikely(pkt->tag.stype_env != VIO_DRING_DATA)) 400 if (unlikely(pkt->tag.stype_env != VIO_DRING_DATA))
401 return 0; 401 return 0;
402 if (unlikely(pkt->seq != dr->rcv_nxt)) { 402 if (unlikely(pkt->seq != dr->rcv_nxt)) {
403 printk(KERN_ERR PFX "RX out of sequence seq[0x%lx] " 403 printk(KERN_ERR PFX "RX out of sequence seq[0x%llx] "
404 "rcv_nxt[0x%lx]\n", pkt->seq, dr->rcv_nxt); 404 "rcv_nxt[0x%llx]\n", pkt->seq, dr->rcv_nxt);
405 return 0; 405 return 0;
406 } 406 }
407 407
diff --git a/drivers/net/tehuti.c b/drivers/net/tehuti.c
index a10a83a11d9f..a7a4dc4d6313 100644
--- a/drivers/net/tehuti.c
+++ b/drivers/net/tehuti.c
@@ -1004,7 +1004,7 @@ static inline void bdx_rxdb_free_elem(struct rxdb *db, int n)
1004 * skb for rx. It assumes that Rx is desabled in HW 1004 * skb for rx. It assumes that Rx is desabled in HW
1005 * funcs are grouped for better cache usage 1005 * funcs are grouped for better cache usage
1006 * 1006 *
1007 * RxD fifo is smaller then RxF fifo by design. Upon high load, RxD will be 1007 * RxD fifo is smaller than RxF fifo by design. Upon high load, RxD will be
1008 * filled and packets will be dropped by nic without getting into host or 1008 * filled and packets will be dropped by nic without getting into host or
1009 * cousing interrupt. Anyway, in that condition, host has no chance to proccess 1009 * cousing interrupt. Anyway, in that condition, host has no chance to proccess
1010 * all packets, but dropping in nic is cheaper, since it takes 0 cpu cycles 1010 * all packets, but dropping in nic is cheaper, since it takes 0 cpu cycles
@@ -1826,7 +1826,7 @@ static void bdx_tx_free(struct bdx_priv *priv)
1826 * 1826 *
1827 * Pushes desc to TxD fifo and overlaps it if needed. 1827 * Pushes desc to TxD fifo and overlaps it if needed.
1828 * NOTE: this func does not check for available space. this is responsibility 1828 * NOTE: this func does not check for available space. this is responsibility
1829 * of the caller. Neither does it check that data size is smaller then 1829 * of the caller. Neither does it check that data size is smaller than
1830 * fifo size. 1830 * fifo size.
1831 */ 1831 */
1832static void bdx_tx_push_desc(struct bdx_priv *priv, void *data, int size) 1832static void bdx_tx_push_desc(struct bdx_priv *priv, void *data, int size)
diff --git a/drivers/net/tlan.c b/drivers/net/tlan.c
index 85ef8b744557..68b967b585aa 100644
--- a/drivers/net/tlan.c
+++ b/drivers/net/tlan.c
@@ -831,6 +831,21 @@ static void TLan_Poll(struct net_device *dev)
831} 831}
832#endif 832#endif
833 833
834static const struct net_device_ops TLan_netdev_ops = {
835 .ndo_open = TLan_Open,
836 .ndo_stop = TLan_Close,
837 .ndo_start_xmit = TLan_StartTx,
838 .ndo_tx_timeout = TLan_tx_timeout,
839 .ndo_get_stats = TLan_GetStats,
840 .ndo_set_multicast_list = TLan_SetMulticastList,
841 .ndo_do_ioctl = TLan_ioctl,
842 .ndo_change_mtu = eth_change_mtu,
843 .ndo_set_mac_address = eth_mac_addr,
844 .ndo_validate_addr = eth_validate_addr,
845#ifdef CONFIG_NET_POLL_CONTROLLER
846 .ndo_poll_controller = TLan_Poll,
847#endif
848};
834 849
835 850
836 851
@@ -892,16 +907,7 @@ static int TLan_Init( struct net_device *dev )
892 netif_carrier_off(dev); 907 netif_carrier_off(dev);
893 908
894 /* Device methods */ 909 /* Device methods */
895 dev->open = &TLan_Open; 910 dev->netdev_ops = &TLan_netdev_ops;
896 dev->hard_start_xmit = &TLan_StartTx;
897 dev->stop = &TLan_Close;
898 dev->get_stats = &TLan_GetStats;
899 dev->set_multicast_list = &TLan_SetMulticastList;
900 dev->do_ioctl = &TLan_ioctl;
901#ifdef CONFIG_NET_POLL_CONTROLLER
902 dev->poll_controller = &TLan_Poll;
903#endif
904 dev->tx_timeout = &TLan_tx_timeout;
905 dev->watchdog_timeo = TX_TIMEOUT; 911 dev->watchdog_timeo = TX_TIMEOUT;
906 912
907 return 0; 913 return 0;
diff --git a/drivers/net/tokenring/smctr.c b/drivers/net/tokenring/smctr.c
index a011666342ff..50eb29ce3c87 100644
--- a/drivers/net/tokenring/smctr.c
+++ b/drivers/net/tokenring/smctr.c
@@ -3064,7 +3064,7 @@ static int smctr_load_node_addr(struct net_device *dev)
3064 * will consequently cause a timeout. 3064 * will consequently cause a timeout.
3065 * 3065 *
3066 * NOTE 1: If the monitor_state is MS_BEACON_TEST_STATE, all transmit 3066 * NOTE 1: If the monitor_state is MS_BEACON_TEST_STATE, all transmit
3067 * queues other then the one used for the lobe_media_test should be 3067 * queues other than the one used for the lobe_media_test should be
3068 * disabled.!? 3068 * disabled.!?
3069 * 3069 *
3070 * NOTE 2: If the monitor_state is MS_BEACON_TEST_STATE and the receive_mask 3070 * NOTE 2: If the monitor_state is MS_BEACON_TEST_STATE and the receive_mask
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index 5166be930a52..d5d53b633cf8 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -1922,6 +1922,18 @@ bad_srom:
1922 goto fill_defaults; 1922 goto fill_defaults;
1923} 1923}
1924 1924
1925static const struct net_device_ops de_netdev_ops = {
1926 .ndo_open = de_open,
1927 .ndo_stop = de_close,
1928 .ndo_set_multicast_list = de_set_rx_mode,
1929 .ndo_start_xmit = de_start_xmit,
1930 .ndo_get_stats = de_get_stats,
1931 .ndo_tx_timeout = de_tx_timeout,
1932 .ndo_change_mtu = eth_change_mtu,
1933 .ndo_set_mac_address = eth_mac_addr,
1934 .ndo_validate_addr = eth_validate_addr,
1935};
1936
1925static int __devinit de_init_one (struct pci_dev *pdev, 1937static int __devinit de_init_one (struct pci_dev *pdev,
1926 const struct pci_device_id *ent) 1938 const struct pci_device_id *ent)
1927{ 1939{
@@ -1944,14 +1956,9 @@ static int __devinit de_init_one (struct pci_dev *pdev,
1944 if (!dev) 1956 if (!dev)
1945 return -ENOMEM; 1957 return -ENOMEM;
1946 1958
1959 dev->netdev_ops = &de_netdev_ops;
1947 SET_NETDEV_DEV(dev, &pdev->dev); 1960 SET_NETDEV_DEV(dev, &pdev->dev);
1948 dev->open = de_open;
1949 dev->stop = de_close;
1950 dev->set_multicast_list = de_set_rx_mode;
1951 dev->hard_start_xmit = de_start_xmit;
1952 dev->get_stats = de_get_stats;
1953 dev->ethtool_ops = &de_ethtool_ops; 1961 dev->ethtool_ops = &de_ethtool_ops;
1954 dev->tx_timeout = de_tx_timeout;
1955 dev->watchdog_timeo = TX_TIMEOUT; 1962 dev->watchdog_timeo = TX_TIMEOUT;
1956 1963
1957 de = netdev_priv(dev); 1964 de = netdev_priv(dev);
diff --git a/drivers/net/tulip/de4x5.c b/drivers/net/tulip/de4x5.c
index 67bfd6f43366..6418f74415d7 100644
--- a/drivers/net/tulip/de4x5.c
+++ b/drivers/net/tulip/de4x5.c
@@ -1077,6 +1077,18 @@ static int (*dc_infoblock[])(struct net_device *dev, u_char, u_char *) = {
1077 mdelay(2); /* Wait for 2ms */\ 1077 mdelay(2); /* Wait for 2ms */\
1078} 1078}
1079 1079
1080static const struct net_device_ops de4x5_netdev_ops = {
1081 .ndo_open = de4x5_open,
1082 .ndo_stop = de4x5_close,
1083 .ndo_start_xmit = de4x5_queue_pkt,
1084 .ndo_get_stats = de4x5_get_stats,
1085 .ndo_set_multicast_list = set_multicast_list,
1086 .ndo_do_ioctl = de4x5_ioctl,
1087 .ndo_change_mtu = eth_change_mtu,
1088 .ndo_set_mac_address= eth_mac_addr,
1089 .ndo_validate_addr = eth_validate_addr,
1090};
1091
1080 1092
1081static int __devinit 1093static int __devinit
1082de4x5_hw_init(struct net_device *dev, u_long iobase, struct device *gendev) 1094de4x5_hw_init(struct net_device *dev, u_long iobase, struct device *gendev)
@@ -1258,13 +1270,7 @@ de4x5_hw_init(struct net_device *dev, u_long iobase, struct device *gendev)
1258 1270
1259 /* The DE4X5-specific entries in the device structure. */ 1271 /* The DE4X5-specific entries in the device structure. */
1260 SET_NETDEV_DEV(dev, gendev); 1272 SET_NETDEV_DEV(dev, gendev);
1261 dev->open = &de4x5_open; 1273 dev->netdev_ops = &de4x5_netdev_ops;
1262 dev->hard_start_xmit = &de4x5_queue_pkt;
1263 dev->stop = &de4x5_close;
1264 dev->get_stats = &de4x5_get_stats;
1265 dev->set_multicast_list = &set_multicast_list;
1266 dev->do_ioctl = &de4x5_ioctl;
1267
1268 dev->mem_start = 0; 1274 dev->mem_start = 0;
1269 1275
1270 /* Fill in the generic fields of the device structure. */ 1276 /* Fill in the generic fields of the device structure. */
diff --git a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c
index 28a5c51b43a0..2e5c99941f35 100644
--- a/drivers/net/tulip/dmfe.c
+++ b/drivers/net/tulip/dmfe.c
@@ -257,9 +257,6 @@ struct dmfe_board_info {
257 u8 wol_mode; /* user WOL settings */ 257 u8 wol_mode; /* user WOL settings */
258 struct timer_list timer; 258 struct timer_list timer;
259 259
260 /* System defined statistic counter */
261 struct net_device_stats stats;
262
263 /* Driver defined statistic counter */ 260 /* Driver defined statistic counter */
264 unsigned long tx_fifo_underrun; 261 unsigned long tx_fifo_underrun;
265 unsigned long tx_loss_carrier; 262 unsigned long tx_loss_carrier;
@@ -316,7 +313,6 @@ static u8 SF_mode; /* Special Function: 1:VLAN, 2:RX Flow Control
316static int dmfe_open(struct DEVICE *); 313static int dmfe_open(struct DEVICE *);
317static int dmfe_start_xmit(struct sk_buff *, struct DEVICE *); 314static int dmfe_start_xmit(struct sk_buff *, struct DEVICE *);
318static int dmfe_stop(struct DEVICE *); 315static int dmfe_stop(struct DEVICE *);
319static struct net_device_stats * dmfe_get_stats(struct DEVICE *);
320static void dmfe_set_filter_mode(struct DEVICE *); 316static void dmfe_set_filter_mode(struct DEVICE *);
321static const struct ethtool_ops netdev_ethtool_ops; 317static const struct ethtool_ops netdev_ethtool_ops;
322static u16 read_srom_word(long ,int); 318static u16 read_srom_word(long ,int);
@@ -351,6 +347,19 @@ static void dmfe_set_phyxcer(struct dmfe_board_info *);
351 347
352/* DM910X network board routine ---------------------------- */ 348/* DM910X network board routine ---------------------------- */
353 349
350static const struct net_device_ops netdev_ops = {
351 .ndo_open = dmfe_open,
352 .ndo_stop = dmfe_stop,
353 .ndo_start_xmit = dmfe_start_xmit,
354 .ndo_set_multicast_list = dmfe_set_filter_mode,
355 .ndo_change_mtu = eth_change_mtu,
356 .ndo_set_mac_address = eth_mac_addr,
357 .ndo_validate_addr = eth_validate_addr,
358#ifdef CONFIG_NET_POLL_CONTROLLER
359 .ndo_poll_controller = poll_dmfe,
360#endif
361};
362
354/* 363/*
355 * Search DM910X board ,allocate space and register it 364 * Search DM910X board ,allocate space and register it
356 */ 365 */
@@ -442,14 +451,7 @@ static int __devinit dmfe_init_one (struct pci_dev *pdev,
442 dev->base_addr = db->ioaddr; 451 dev->base_addr = db->ioaddr;
443 dev->irq = pdev->irq; 452 dev->irq = pdev->irq;
444 pci_set_drvdata(pdev, dev); 453 pci_set_drvdata(pdev, dev);
445 dev->open = &dmfe_open; 454 dev->netdev_ops = &netdev_ops;
446 dev->hard_start_xmit = &dmfe_start_xmit;
447 dev->stop = &dmfe_stop;
448 dev->get_stats = &dmfe_get_stats;
449 dev->set_multicast_list = &dmfe_set_filter_mode;
450#ifdef CONFIG_NET_POLL_CONTROLLER
451 dev->poll_controller = &poll_dmfe;
452#endif
453 dev->ethtool_ops = &netdev_ethtool_ops; 455 dev->ethtool_ops = &netdev_ethtool_ops;
454 netif_carrier_off(dev); 456 netif_carrier_off(dev);
455 spin_lock_init(&db->lock); 457 spin_lock_init(&db->lock);
@@ -867,15 +869,15 @@ static void dmfe_free_tx_pkt(struct DEVICE *dev, struct dmfe_board_info * db)
867 869
868 /* A packet sent completed */ 870 /* A packet sent completed */
869 db->tx_packet_cnt--; 871 db->tx_packet_cnt--;
870 db->stats.tx_packets++; 872 dev->stats.tx_packets++;
871 873
872 /* Transmit statistic counter */ 874 /* Transmit statistic counter */
873 if ( tdes0 != 0x7fffffff ) { 875 if ( tdes0 != 0x7fffffff ) {
874 /* printk(DRV_NAME ": tdes0=%x\n", tdes0); */ 876 /* printk(DRV_NAME ": tdes0=%x\n", tdes0); */
875 db->stats.collisions += (tdes0 >> 3) & 0xf; 877 dev->stats.collisions += (tdes0 >> 3) & 0xf;
876 db->stats.tx_bytes += le32_to_cpu(txptr->tdes1) & 0x7ff; 878 dev->stats.tx_bytes += le32_to_cpu(txptr->tdes1) & 0x7ff;
877 if (tdes0 & TDES0_ERR_MASK) { 879 if (tdes0 & TDES0_ERR_MASK) {
878 db->stats.tx_errors++; 880 dev->stats.tx_errors++;
879 881
880 if (tdes0 & 0x0002) { /* UnderRun */ 882 if (tdes0 & 0x0002) { /* UnderRun */
881 db->tx_fifo_underrun++; 883 db->tx_fifo_underrun++;
@@ -969,13 +971,13 @@ static void dmfe_rx_packet(struct DEVICE *dev, struct dmfe_board_info * db)
969 if (rdes0 & 0x8000) { 971 if (rdes0 & 0x8000) {
970 /* This is a error packet */ 972 /* This is a error packet */
971 //printk(DRV_NAME ": rdes0: %lx\n", rdes0); 973 //printk(DRV_NAME ": rdes0: %lx\n", rdes0);
972 db->stats.rx_errors++; 974 dev->stats.rx_errors++;
973 if (rdes0 & 1) 975 if (rdes0 & 1)
974 db->stats.rx_fifo_errors++; 976 dev->stats.rx_fifo_errors++;
975 if (rdes0 & 2) 977 if (rdes0 & 2)
976 db->stats.rx_crc_errors++; 978 dev->stats.rx_crc_errors++;
977 if (rdes0 & 0x80) 979 if (rdes0 & 0x80)
978 db->stats.rx_length_errors++; 980 dev->stats.rx_length_errors++;
979 } 981 }
980 982
981 if ( !(rdes0 & 0x8000) || 983 if ( !(rdes0 & 0x8000) ||
@@ -1008,8 +1010,8 @@ static void dmfe_rx_packet(struct DEVICE *dev, struct dmfe_board_info * db)
1008 1010
1009 skb->protocol = eth_type_trans(skb, dev); 1011 skb->protocol = eth_type_trans(skb, dev);
1010 netif_rx(skb); 1012 netif_rx(skb);
1011 db->stats.rx_packets++; 1013 dev->stats.rx_packets++;
1012 db->stats.rx_bytes += rxlen; 1014 dev->stats.rx_bytes += rxlen;
1013 } 1015 }
1014 } else { 1016 } else {
1015 /* Reuse SKB buffer when the packet is error */ 1017 /* Reuse SKB buffer when the packet is error */
@@ -1024,20 +1026,6 @@ static void dmfe_rx_packet(struct DEVICE *dev, struct dmfe_board_info * db)
1024 db->rx_ready_ptr = rxptr; 1026 db->rx_ready_ptr = rxptr;
1025} 1027}
1026 1028
1027
1028/*
1029 * Get statistics from driver.
1030 */
1031
1032static struct net_device_stats * dmfe_get_stats(struct DEVICE *dev)
1033{
1034 struct dmfe_board_info *db = netdev_priv(dev);
1035
1036 DMFE_DBUG(0, "dmfe_get_stats", 0);
1037 return &db->stats;
1038}
1039
1040
1041/* 1029/*
1042 * Set DM910X multicast address 1030 * Set DM910X multicast address
1043 */ 1031 */
@@ -1161,7 +1149,7 @@ static void dmfe_timer(unsigned long data)
1161 1149
1162 /* Operating Mode Check */ 1150 /* Operating Mode Check */
1163 if ( (db->dm910x_chk_mode & 0x1) && 1151 if ( (db->dm910x_chk_mode & 0x1) &&
1164 (db->stats.rx_packets > MAX_CHECK_PACKET) ) 1152 (dev->stats.rx_packets > MAX_CHECK_PACKET) )
1165 db->dm910x_chk_mode = 0x4; 1153 db->dm910x_chk_mode = 0x4;
1166 1154
1167 /* Dynamic reset DM910X : system error or transmit time-out */ 1155 /* Dynamic reset DM910X : system error or transmit time-out */
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index ff84babb3ff3..bee75fa87a9c 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -1225,6 +1225,22 @@ static int tulip_uli_dm_quirk(struct pci_dev *pdev)
1225 return 0; 1225 return 0;
1226} 1226}
1227 1227
1228static const struct net_device_ops tulip_netdev_ops = {
1229 .ndo_open = tulip_open,
1230 .ndo_start_xmit = tulip_start_xmit,
1231 .ndo_tx_timeout = tulip_tx_timeout,
1232 .ndo_stop = tulip_close,
1233 .ndo_get_stats = tulip_get_stats,
1234 .ndo_do_ioctl = private_ioctl,
1235 .ndo_set_multicast_list = set_rx_mode,
1236 .ndo_change_mtu = eth_change_mtu,
1237 .ndo_set_mac_address = eth_mac_addr,
1238 .ndo_validate_addr = eth_validate_addr,
1239#ifdef CONFIG_NET_POLL_CONTROLLER
1240 .ndo_poll_controller = poll_tulip,
1241#endif
1242};
1243
1228static int __devinit tulip_init_one (struct pci_dev *pdev, 1244static int __devinit tulip_init_one (struct pci_dev *pdev,
1229 const struct pci_device_id *ent) 1245 const struct pci_device_id *ent)
1230{ 1246{
@@ -1601,20 +1617,11 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1601 } 1617 }
1602 1618
1603 /* The Tulip-specific entries in the device structure. */ 1619 /* The Tulip-specific entries in the device structure. */
1604 dev->open = tulip_open; 1620 dev->netdev_ops = &tulip_netdev_ops;
1605 dev->hard_start_xmit = tulip_start_xmit;
1606 dev->tx_timeout = tulip_tx_timeout;
1607 dev->watchdog_timeo = TX_TIMEOUT; 1621 dev->watchdog_timeo = TX_TIMEOUT;
1608#ifdef CONFIG_TULIP_NAPI 1622#ifdef CONFIG_TULIP_NAPI
1609 netif_napi_add(dev, &tp->napi, tulip_poll, 16); 1623 netif_napi_add(dev, &tp->napi, tulip_poll, 16);
1610#endif 1624#endif
1611 dev->stop = tulip_close;
1612 dev->get_stats = tulip_get_stats;
1613 dev->do_ioctl = private_ioctl;
1614 dev->set_multicast_list = set_rx_mode;
1615#ifdef CONFIG_NET_POLL_CONTROLLER
1616 dev->poll_controller = &poll_tulip;
1617#endif
1618 SET_ETHTOOL_OPS(dev, &ops); 1625 SET_ETHTOOL_OPS(dev, &ops);
1619 1626
1620 if (register_netdev(dev)) 1627 if (register_netdev(dev))
diff --git a/drivers/net/tulip/uli526x.c b/drivers/net/tulip/uli526x.c
index 00cbc5251dcc..030e02e63023 100644
--- a/drivers/net/tulip/uli526x.c
+++ b/drivers/net/tulip/uli526x.c
@@ -168,9 +168,6 @@ struct uli526x_board_info {
168 u8 wait_reset; /* Hardware failed, need to reset */ 168 u8 wait_reset; /* Hardware failed, need to reset */
169 struct timer_list timer; 169 struct timer_list timer;
170 170
171 /* System defined statistic counter */
172 struct net_device_stats stats;
173
174 /* Driver defined statistic counter */ 171 /* Driver defined statistic counter */
175 unsigned long tx_fifo_underrun; 172 unsigned long tx_fifo_underrun;
176 unsigned long tx_loss_carrier; 173 unsigned long tx_loss_carrier;
@@ -220,7 +217,6 @@ static int mode = 8;
220static int uli526x_open(struct net_device *); 217static int uli526x_open(struct net_device *);
221static int uli526x_start_xmit(struct sk_buff *, struct net_device *); 218static int uli526x_start_xmit(struct sk_buff *, struct net_device *);
222static int uli526x_stop(struct net_device *); 219static int uli526x_stop(struct net_device *);
223static struct net_device_stats * uli526x_get_stats(struct net_device *);
224static void uli526x_set_filter_mode(struct net_device *); 220static void uli526x_set_filter_mode(struct net_device *);
225static const struct ethtool_ops netdev_ethtool_ops; 221static const struct ethtool_ops netdev_ethtool_ops;
226static u16 read_srom_word(long, int); 222static u16 read_srom_word(long, int);
@@ -251,6 +247,19 @@ static void uli526x_set_phyxcer(struct uli526x_board_info *);
251 247
252/* ULI526X network board routine ---------------------------- */ 248/* ULI526X network board routine ---------------------------- */
253 249
250static const struct net_device_ops netdev_ops = {
251 .ndo_open = uli526x_open,
252 .ndo_stop = uli526x_stop,
253 .ndo_start_xmit = uli526x_start_xmit,
254 .ndo_set_multicast_list = uli526x_set_filter_mode,
255 .ndo_change_mtu = eth_change_mtu,
256 .ndo_set_mac_address = eth_mac_addr,
257 .ndo_validate_addr = eth_validate_addr,
258#ifdef CONFIG_NET_POLL_CONTROLLER
259 .ndo_poll_controller = uli526x_poll,
260#endif
261};
262
254/* 263/*
255 * Search ULI526X board, allocate space and register it 264 * Search ULI526X board, allocate space and register it
256 */ 265 */
@@ -335,15 +344,9 @@ static int __devinit uli526x_init_one (struct pci_dev *pdev,
335 pci_set_drvdata(pdev, dev); 344 pci_set_drvdata(pdev, dev);
336 345
337 /* Register some necessary functions */ 346 /* Register some necessary functions */
338 dev->open = &uli526x_open; 347 dev->netdev_ops = &netdev_ops;
339 dev->hard_start_xmit = &uli526x_start_xmit;
340 dev->stop = &uli526x_stop;
341 dev->get_stats = &uli526x_get_stats;
342 dev->set_multicast_list = &uli526x_set_filter_mode;
343 dev->ethtool_ops = &netdev_ethtool_ops; 348 dev->ethtool_ops = &netdev_ethtool_ops;
344#ifdef CONFIG_NET_POLL_CONTROLLER 349
345 dev->poll_controller = &uli526x_poll;
346#endif
347 spin_lock_init(&db->lock); 350 spin_lock_init(&db->lock);
348 351
349 352
@@ -733,7 +736,8 @@ static void uli526x_poll(struct net_device *dev)
733 * Free TX resource after TX complete 736 * Free TX resource after TX complete
734 */ 737 */
735 738
736static void uli526x_free_tx_pkt(struct net_device *dev, struct uli526x_board_info * db) 739static void uli526x_free_tx_pkt(struct net_device *dev,
740 struct uli526x_board_info * db)
737{ 741{
738 struct tx_desc *txptr; 742 struct tx_desc *txptr;
739 u32 tdes0; 743 u32 tdes0;
@@ -747,15 +751,15 @@ static void uli526x_free_tx_pkt(struct net_device *dev, struct uli526x_board_inf
747 751
748 /* A packet sent completed */ 752 /* A packet sent completed */
749 db->tx_packet_cnt--; 753 db->tx_packet_cnt--;
750 db->stats.tx_packets++; 754 dev->stats.tx_packets++;
751 755
752 /* Transmit statistic counter */ 756 /* Transmit statistic counter */
753 if ( tdes0 != 0x7fffffff ) { 757 if ( tdes0 != 0x7fffffff ) {
754 /* printk(DRV_NAME ": tdes0=%x\n", tdes0); */ 758 /* printk(DRV_NAME ": tdes0=%x\n", tdes0); */
755 db->stats.collisions += (tdes0 >> 3) & 0xf; 759 dev->stats.collisions += (tdes0 >> 3) & 0xf;
756 db->stats.tx_bytes += le32_to_cpu(txptr->tdes1) & 0x7ff; 760 dev->stats.tx_bytes += le32_to_cpu(txptr->tdes1) & 0x7ff;
757 if (tdes0 & TDES0_ERR_MASK) { 761 if (tdes0 & TDES0_ERR_MASK) {
758 db->stats.tx_errors++; 762 dev->stats.tx_errors++;
759 if (tdes0 & 0x0002) { /* UnderRun */ 763 if (tdes0 & 0x0002) { /* UnderRun */
760 db->tx_fifo_underrun++; 764 db->tx_fifo_underrun++;
761 if ( !(db->cr6_data & CR6_SFT) ) { 765 if ( !(db->cr6_data & CR6_SFT) ) {
@@ -825,13 +829,13 @@ static void uli526x_rx_packet(struct net_device *dev, struct uli526x_board_info
825 if (rdes0 & 0x8000) { 829 if (rdes0 & 0x8000) {
826 /* This is a error packet */ 830 /* This is a error packet */
827 //printk(DRV_NAME ": rdes0: %lx\n", rdes0); 831 //printk(DRV_NAME ": rdes0: %lx\n", rdes0);
828 db->stats.rx_errors++; 832 dev->stats.rx_errors++;
829 if (rdes0 & 1) 833 if (rdes0 & 1)
830 db->stats.rx_fifo_errors++; 834 dev->stats.rx_fifo_errors++;
831 if (rdes0 & 2) 835 if (rdes0 & 2)
832 db->stats.rx_crc_errors++; 836 dev->stats.rx_crc_errors++;
833 if (rdes0 & 0x80) 837 if (rdes0 & 0x80)
834 db->stats.rx_length_errors++; 838 dev->stats.rx_length_errors++;
835 } 839 }
836 840
837 if ( !(rdes0 & 0x8000) || 841 if ( !(rdes0 & 0x8000) ||
@@ -854,8 +858,8 @@ static void uli526x_rx_packet(struct net_device *dev, struct uli526x_board_info
854 858
855 skb->protocol = eth_type_trans(skb, dev); 859 skb->protocol = eth_type_trans(skb, dev);
856 netif_rx(skb); 860 netif_rx(skb);
857 db->stats.rx_packets++; 861 dev->stats.rx_packets++;
858 db->stats.rx_bytes += rxlen; 862 dev->stats.rx_bytes += rxlen;
859 863
860 } else { 864 } else {
861 /* Reuse SKB buffer when the packet is error */ 865 /* Reuse SKB buffer when the packet is error */
@@ -872,19 +876,6 @@ static void uli526x_rx_packet(struct net_device *dev, struct uli526x_board_info
872 876
873 877
874/* 878/*
875 * Get statistics from driver.
876 */
877
878static struct net_device_stats * uli526x_get_stats(struct net_device *dev)
879{
880 struct uli526x_board_info *db = netdev_priv(dev);
881
882 ULI526X_DBUG(0, "uli526x_get_stats", 0);
883 return &db->stats;
884}
885
886
887/*
888 * Set ULI526X multicast address 879 * Set ULI526X multicast address
889 */ 880 */
890 881
diff --git a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c
index 022d99af8646..f467bf87817d 100644
--- a/drivers/net/tulip/winbond-840.c
+++ b/drivers/net/tulip/winbond-840.c
@@ -343,7 +343,18 @@ static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
343static const struct ethtool_ops netdev_ethtool_ops; 343static const struct ethtool_ops netdev_ethtool_ops;
344static int netdev_close(struct net_device *dev); 344static int netdev_close(struct net_device *dev);
345 345
346 346static const struct net_device_ops netdev_ops = {
347 .ndo_open = netdev_open,
348 .ndo_stop = netdev_close,
349 .ndo_start_xmit = start_tx,
350 .ndo_get_stats = get_stats,
351 .ndo_set_multicast_list = set_rx_mode,
352 .ndo_do_ioctl = netdev_ioctl,
353 .ndo_tx_timeout = tx_timeout,
354 .ndo_change_mtu = eth_change_mtu,
355 .ndo_set_mac_address = eth_mac_addr,
356 .ndo_validate_addr = eth_validate_addr,
357};
347 358
348static int __devinit w840_probe1 (struct pci_dev *pdev, 359static int __devinit w840_probe1 (struct pci_dev *pdev,
349 const struct pci_device_id *ent) 360 const struct pci_device_id *ent)
@@ -420,14 +431,8 @@ static int __devinit w840_probe1 (struct pci_dev *pdev,
420 np->mii_if.force_media = 1; 431 np->mii_if.force_media = 1;
421 432
422 /* The chip-specific entries in the device structure. */ 433 /* The chip-specific entries in the device structure. */
423 dev->open = &netdev_open; 434 dev->netdev_ops = &netdev_ops;
424 dev->hard_start_xmit = &start_tx;
425 dev->stop = &netdev_close;
426 dev->get_stats = &get_stats;
427 dev->set_multicast_list = &set_rx_mode;
428 dev->do_ioctl = &netdev_ioctl;
429 dev->ethtool_ops = &netdev_ethtool_ops; 435 dev->ethtool_ops = &netdev_ethtool_ops;
430 dev->tx_timeout = &tx_timeout;
431 dev->watchdog_timeo = TX_TIMEOUT; 436 dev->watchdog_timeo = TX_TIMEOUT;
432 437
433 i = register_netdev(dev); 438 i = register_netdev(dev);
@@ -1555,7 +1560,7 @@ static void __devexit w840_remove1 (struct pci_dev *pdev)
1555 * rtnl_lock, & netif_device_detach after the rtnl_unlock. 1560 * rtnl_lock, & netif_device_detach after the rtnl_unlock.
1556 * - get_stats: 1561 * - get_stats:
1557 * spin_lock_irq(np->lock), doesn't touch hw if not present 1562 * spin_lock_irq(np->lock), doesn't touch hw if not present
1558 * - hard_start_xmit: 1563 * - start_xmit:
1559 * synchronize_irq + netif_tx_disable; 1564 * synchronize_irq + netif_tx_disable;
1560 * - tx_timeout: 1565 * - tx_timeout:
1561 * netif_device_detach + netif_tx_disable; 1566 * netif_device_detach + netif_tx_disable;
diff --git a/drivers/net/tulip/xircom_cb.c b/drivers/net/tulip/xircom_cb.c
index 13c8703ecb9f..c2ca9f40e40e 100644
--- a/drivers/net/tulip/xircom_cb.c
+++ b/drivers/net/tulip/xircom_cb.c
@@ -104,10 +104,8 @@ struct xircom_private {
104 */ 104 */
105 spinlock_t lock; 105 spinlock_t lock;
106 106
107
108 struct pci_dev *pdev; 107 struct pci_dev *pdev;
109 struct net_device *dev; 108 struct net_device *dev;
110 struct net_device_stats stats;
111}; 109};
112 110
113 111
@@ -119,7 +117,6 @@ static int xircom_start_xmit(struct sk_buff *skb, struct net_device *dev);
119static int xircom_open(struct net_device *dev); 117static int xircom_open(struct net_device *dev);
120static int xircom_close(struct net_device *dev); 118static int xircom_close(struct net_device *dev);
121static void xircom_up(struct xircom_private *card); 119static void xircom_up(struct xircom_private *card);
122static struct net_device_stats *xircom_get_stats(struct net_device *dev);
123#ifdef CONFIG_NET_POLL_CONTROLLER 120#ifdef CONFIG_NET_POLL_CONTROLLER
124static void xircom_poll_controller(struct net_device *dev); 121static void xircom_poll_controller(struct net_device *dev);
125#endif 122#endif
@@ -194,6 +191,18 @@ static const struct ethtool_ops netdev_ethtool_ops = {
194 .get_drvinfo = netdev_get_drvinfo, 191 .get_drvinfo = netdev_get_drvinfo,
195}; 192};
196 193
194static const struct net_device_ops netdev_ops = {
195 .ndo_open = xircom_open,
196 .ndo_stop = xircom_close,
197 .ndo_start_xmit = xircom_start_xmit,
198 .ndo_change_mtu = eth_change_mtu,
199 .ndo_set_mac_address = eth_mac_addr,
200 .ndo_validate_addr = eth_validate_addr,
201#ifdef CONFIG_NET_POLL_CONTROLLER
202 .ndo_poll_controller = xircom_poll_controller,
203#endif
204};
205
197/* xircom_probe is the code that gets called on device insertion. 206/* xircom_probe is the code that gets called on device insertion.
198 it sets up the hardware and registers the device to the networklayer. 207 it sets up the hardware and registers the device to the networklayer.
199 208
@@ -266,13 +275,7 @@ static int __devinit xircom_probe(struct pci_dev *pdev, const struct pci_device_
266 read_mac_address(private); 275 read_mac_address(private);
267 setup_descriptors(private); 276 setup_descriptors(private);
268 277
269 dev->open = &xircom_open; 278 dev->netdev_ops = &netdev_ops;
270 dev->hard_start_xmit = &xircom_start_xmit;
271 dev->stop = &xircom_close;
272 dev->get_stats = &xircom_get_stats;
273#ifdef CONFIG_NET_POLL_CONTROLLER
274 dev->poll_controller = &xircom_poll_controller;
275#endif
276 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 279 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
277 pci_set_drvdata(pdev, dev); 280 pci_set_drvdata(pdev, dev);
278 281
@@ -497,14 +500,6 @@ static int xircom_close(struct net_device *dev)
497} 500}
498 501
499 502
500
501static struct net_device_stats *xircom_get_stats(struct net_device *dev)
502{
503 struct xircom_private *card = netdev_priv(dev);
504 return &card->stats;
505}
506
507
508#ifdef CONFIG_NET_POLL_CONTROLLER 503#ifdef CONFIG_NET_POLL_CONTROLLER
509static void xircom_poll_controller(struct net_device *dev) 504static void xircom_poll_controller(struct net_device *dev)
510{ 505{
@@ -1193,7 +1188,7 @@ static void investigate_read_descriptor(struct net_device *dev,struct xircom_pri
1193 1188
1194 skb = dev_alloc_skb(pkt_len + 2); 1189 skb = dev_alloc_skb(pkt_len + 2);
1195 if (skb == NULL) { 1190 if (skb == NULL) {
1196 card->stats.rx_dropped++; 1191 dev->stats.rx_dropped++;
1197 goto out; 1192 goto out;
1198 } 1193 }
1199 skb_reserve(skb, 2); 1194 skb_reserve(skb, 2);
@@ -1201,8 +1196,8 @@ static void investigate_read_descriptor(struct net_device *dev,struct xircom_pri
1201 skb_put(skb, pkt_len); 1196 skb_put(skb, pkt_len);
1202 skb->protocol = eth_type_trans(skb, dev); 1197 skb->protocol = eth_type_trans(skb, dev);
1203 netif_rx(skb); 1198 netif_rx(skb);
1204 card->stats.rx_packets++; 1199 dev->stats.rx_packets++;
1205 card->stats.rx_bytes += pkt_len; 1200 dev->stats.rx_bytes += pkt_len;
1206 1201
1207 out: 1202 out:
1208 /* give the buffer back to the card */ 1203 /* give the buffer back to the card */
@@ -1232,16 +1227,16 @@ static void investigate_write_descriptor(struct net_device *dev, struct xircom_p
1232#endif 1227#endif
1233 if (status > 0) { /* bit 31 is 0 when done */ 1228 if (status > 0) { /* bit 31 is 0 when done */
1234 if (card->tx_skb[descnr]!=NULL) { 1229 if (card->tx_skb[descnr]!=NULL) {
1235 card->stats.tx_bytes += card->tx_skb[descnr]->len; 1230 dev->stats.tx_bytes += card->tx_skb[descnr]->len;
1236 dev_kfree_skb_irq(card->tx_skb[descnr]); 1231 dev_kfree_skb_irq(card->tx_skb[descnr]);
1237 } 1232 }
1238 card->tx_skb[descnr] = NULL; 1233 card->tx_skb[descnr] = NULL;
1239 /* Bit 8 in the status field is 1 if there was a collision */ 1234 /* Bit 8 in the status field is 1 if there was a collision */
1240 if (status&(1<<8)) 1235 if (status&(1<<8))
1241 card->stats.collisions++; 1236 dev->stats.collisions++;
1242 card->tx_buffer[4*descnr] = 0; /* descriptor is free again */ 1237 card->tx_buffer[4*descnr] = 0; /* descriptor is free again */
1243 netif_wake_queue (dev); 1238 netif_wake_queue (dev);
1244 card->stats.tx_packets++; 1239 dev->stats.tx_packets++;
1245 } 1240 }
1246 1241
1247 leave("investigate_write_descriptor"); 1242 leave("investigate_write_descriptor");
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c
index 0009f4e34433..3af9a9516ccb 100644
--- a/drivers/net/typhoon.c
+++ b/drivers/net/typhoon.c
@@ -2296,6 +2296,19 @@ out:
2296 return mode; 2296 return mode;
2297} 2297}
2298 2298
2299static const struct net_device_ops typhoon_netdev_ops = {
2300 .ndo_open = typhoon_open,
2301 .ndo_stop = typhoon_close,
2302 .ndo_start_xmit = typhoon_start_tx,
2303 .ndo_set_multicast_list = typhoon_set_rx_mode,
2304 .ndo_tx_timeout = typhoon_tx_timeout,
2305 .ndo_get_stats = typhoon_get_stats,
2306 .ndo_validate_addr = eth_validate_addr,
2307 .ndo_set_mac_address = typhoon_set_mac_address,
2308 .ndo_change_mtu = eth_change_mtu,
2309 .ndo_vlan_rx_register = typhoon_vlan_rx_register,
2310};
2311
2299static int __devinit 2312static int __devinit
2300typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 2313typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2301{ 2314{
@@ -2495,16 +2508,9 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2495 } 2508 }
2496 2509
2497 /* The chip-specific entries in the device structure. */ 2510 /* The chip-specific entries in the device structure. */
2498 dev->open = typhoon_open; 2511 dev->netdev_ops = &typhoon_netdev_ops;
2499 dev->hard_start_xmit = typhoon_start_tx;
2500 dev->stop = typhoon_close;
2501 dev->set_multicast_list = typhoon_set_rx_mode;
2502 dev->tx_timeout = typhoon_tx_timeout;
2503 netif_napi_add(dev, &tp->napi, typhoon_poll, 16); 2512 netif_napi_add(dev, &tp->napi, typhoon_poll, 16);
2504 dev->watchdog_timeo = TX_TIMEOUT; 2513 dev->watchdog_timeo = TX_TIMEOUT;
2505 dev->get_stats = typhoon_get_stats;
2506 dev->set_mac_address = typhoon_set_mac_address;
2507 dev->vlan_rx_register = typhoon_vlan_rx_register;
2508 2514
2509 SET_ETHTOOL_OPS(dev, &typhoon_ethtool_ops); 2515 SET_ETHTOOL_OPS(dev, &typhoon_ethtool_ops);
2510 2516
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index 7d5a1303e30d..11441225bf41 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -442,40 +442,30 @@ static void magic_packet_detection_enable(struct ucc_geth_private *ugeth)
442{ 442{
443 struct ucc_fast_private *uccf; 443 struct ucc_fast_private *uccf;
444 struct ucc_geth __iomem *ug_regs; 444 struct ucc_geth __iomem *ug_regs;
445 u32 maccfg2, uccm;
446 445
447 uccf = ugeth->uccf; 446 uccf = ugeth->uccf;
448 ug_regs = ugeth->ug_regs; 447 ug_regs = ugeth->ug_regs;
449 448
450 /* Enable interrupts for magic packet detection */ 449 /* Enable interrupts for magic packet detection */
451 uccm = in_be32(uccf->p_uccm); 450 setbits32(uccf->p_uccm, UCC_GETH_UCCE_MPD);
452 uccm |= UCCE_MPD;
453 out_be32(uccf->p_uccm, uccm);
454 451
455 /* Enable magic packet detection */ 452 /* Enable magic packet detection */
456 maccfg2 = in_be32(&ug_regs->maccfg2); 453 setbits32(&ug_regs->maccfg2, MACCFG2_MPE);
457 maccfg2 |= MACCFG2_MPE;
458 out_be32(&ug_regs->maccfg2, maccfg2);
459} 454}
460 455
461static void magic_packet_detection_disable(struct ucc_geth_private *ugeth) 456static void magic_packet_detection_disable(struct ucc_geth_private *ugeth)
462{ 457{
463 struct ucc_fast_private *uccf; 458 struct ucc_fast_private *uccf;
464 struct ucc_geth __iomem *ug_regs; 459 struct ucc_geth __iomem *ug_regs;
465 u32 maccfg2, uccm;
466 460
467 uccf = ugeth->uccf; 461 uccf = ugeth->uccf;
468 ug_regs = ugeth->ug_regs; 462 ug_regs = ugeth->ug_regs;
469 463
470 /* Disable interrupts for magic packet detection */ 464 /* Disable interrupts for magic packet detection */
471 uccm = in_be32(uccf->p_uccm); 465 clrbits32(uccf->p_uccm, UCC_GETH_UCCE_MPD);
472 uccm &= ~UCCE_MPD;
473 out_be32(uccf->p_uccm, uccm);
474 466
475 /* Disable magic packet detection */ 467 /* Disable magic packet detection */
476 maccfg2 = in_be32(&ug_regs->maccfg2); 468 clrbits32(&ug_regs->maccfg2, MACCFG2_MPE);
477 maccfg2 &= ~MACCFG2_MPE;
478 out_be32(&ug_regs->maccfg2, maccfg2);
479} 469}
480#endif /* MAGIC_PACKET */ 470#endif /* MAGIC_PACKET */
481 471
@@ -585,7 +575,8 @@ static void get_statistics(struct ucc_geth_private *ugeth,
585 575
586 /* Hardware only if user handed pointer and driver actually 576 /* Hardware only if user handed pointer and driver actually
587 gathers hardware statistics */ 577 gathers hardware statistics */
588 if (hardware_statistics && (in_be32(&uf_regs->upsmr) & UPSMR_HSE)) { 578 if (hardware_statistics &&
579 (in_be32(&uf_regs->upsmr) & UCC_GETH_UPSMR_HSE)) {
589 hardware_statistics->tx64 = in_be32(&ug_regs->tx64); 580 hardware_statistics->tx64 = in_be32(&ug_regs->tx64);
590 hardware_statistics->tx127 = in_be32(&ug_regs->tx127); 581 hardware_statistics->tx127 = in_be32(&ug_regs->tx127);
591 hardware_statistics->tx255 = in_be32(&ug_regs->tx255); 582 hardware_statistics->tx255 = in_be32(&ug_regs->tx255);
@@ -1181,9 +1172,7 @@ int init_flow_control_params(u32 automatic_flow_control_mode,
1181 out_be32(uempr_register, value); 1172 out_be32(uempr_register, value);
1182 1173
1183 /* Set UPSMR register */ 1174 /* Set UPSMR register */
1184 value = in_be32(upsmr_register); 1175 setbits32(upsmr_register, automatic_flow_control_mode);
1185 value |= automatic_flow_control_mode;
1186 out_be32(upsmr_register, value);
1187 1176
1188 value = in_be32(maccfg1_register); 1177 value = in_be32(maccfg1_register);
1189 if (rx_flow_control_enable) 1178 if (rx_flow_control_enable)
@@ -1200,14 +1189,11 @@ static int init_hw_statistics_gathering_mode(int enable_hardware_statistics,
1200 u32 __iomem *upsmr_register, 1189 u32 __iomem *upsmr_register,
1201 u16 __iomem *uescr_register) 1190 u16 __iomem *uescr_register)
1202{ 1191{
1203 u32 upsmr_value = 0;
1204 u16 uescr_value = 0; 1192 u16 uescr_value = 0;
1193
1205 /* Enable hardware statistics gathering if requested */ 1194 /* Enable hardware statistics gathering if requested */
1206 if (enable_hardware_statistics) { 1195 if (enable_hardware_statistics)
1207 upsmr_value = in_be32(upsmr_register); 1196 setbits32(upsmr_register, UCC_GETH_UPSMR_HSE);
1208 upsmr_value |= UPSMR_HSE;
1209 out_be32(upsmr_register, upsmr_value);
1210 }
1211 1197
1212 /* Clear hardware statistics counters */ 1198 /* Clear hardware statistics counters */
1213 uescr_value = in_be16(uescr_register); 1199 uescr_value = in_be16(uescr_register);
@@ -1233,23 +1219,17 @@ static int init_firmware_statistics_gathering_mode(int
1233{ 1219{
1234 /* Note: this function does not check if */ 1220 /* Note: this function does not check if */
1235 /* the parameters it receives are NULL */ 1221 /* the parameters it receives are NULL */
1236 u16 temoder_value;
1237 u32 remoder_value;
1238 1222
1239 if (enable_tx_firmware_statistics) { 1223 if (enable_tx_firmware_statistics) {
1240 out_be32(tx_rmon_base_ptr, 1224 out_be32(tx_rmon_base_ptr,
1241 tx_firmware_statistics_structure_address); 1225 tx_firmware_statistics_structure_address);
1242 temoder_value = in_be16(temoder_register); 1226 setbits16(temoder_register, TEMODER_TX_RMON_STATISTICS_ENABLE);
1243 temoder_value |= TEMODER_TX_RMON_STATISTICS_ENABLE;
1244 out_be16(temoder_register, temoder_value);
1245 } 1227 }
1246 1228
1247 if (enable_rx_firmware_statistics) { 1229 if (enable_rx_firmware_statistics) {
1248 out_be32(rx_rmon_base_ptr, 1230 out_be32(rx_rmon_base_ptr,
1249 rx_firmware_statistics_structure_address); 1231 rx_firmware_statistics_structure_address);
1250 remoder_value = in_be32(remoder_register); 1232 setbits32(remoder_register, REMODER_RX_RMON_STATISTICS_ENABLE);
1251 remoder_value |= REMODER_RX_RMON_STATISTICS_ENABLE;
1252 out_be32(remoder_register, remoder_value);
1253 } 1233 }
1254 1234
1255 return 0; 1235 return 0;
@@ -1316,15 +1296,12 @@ static int init_check_frame_length_mode(int length_check,
1316static int init_preamble_length(u8 preamble_length, 1296static int init_preamble_length(u8 preamble_length,
1317 u32 __iomem *maccfg2_register) 1297 u32 __iomem *maccfg2_register)
1318{ 1298{
1319 u32 value = 0;
1320
1321 if ((preamble_length < 3) || (preamble_length > 7)) 1299 if ((preamble_length < 3) || (preamble_length > 7))
1322 return -EINVAL; 1300 return -EINVAL;
1323 1301
1324 value = in_be32(maccfg2_register); 1302 clrsetbits_be32(maccfg2_register, MACCFG2_PREL_MASK,
1325 value &= ~MACCFG2_PREL_MASK; 1303 preamble_length << MACCFG2_PREL_SHIFT);
1326 value |= (preamble_length << MACCFG2_PREL_SHIFT); 1304
1327 out_be32(maccfg2_register, value);
1328 return 0; 1305 return 0;
1329} 1306}
1330 1307
@@ -1337,19 +1314,19 @@ static int init_rx_parameters(int reject_broadcast,
1337 value = in_be32(upsmr_register); 1314 value = in_be32(upsmr_register);
1338 1315
1339 if (reject_broadcast) 1316 if (reject_broadcast)
1340 value |= UPSMR_BRO; 1317 value |= UCC_GETH_UPSMR_BRO;
1341 else 1318 else
1342 value &= ~UPSMR_BRO; 1319 value &= ~UCC_GETH_UPSMR_BRO;
1343 1320
1344 if (receive_short_frames) 1321 if (receive_short_frames)
1345 value |= UPSMR_RSH; 1322 value |= UCC_GETH_UPSMR_RSH;
1346 else 1323 else
1347 value &= ~UPSMR_RSH; 1324 value &= ~UCC_GETH_UPSMR_RSH;
1348 1325
1349 if (promiscuous) 1326 if (promiscuous)
1350 value |= UPSMR_PRO; 1327 value |= UCC_GETH_UPSMR_PRO;
1351 else 1328 else
1352 value &= ~UPSMR_PRO; 1329 value &= ~UCC_GETH_UPSMR_PRO;
1353 1330
1354 out_be32(upsmr_register, value); 1331 out_be32(upsmr_register, value);
1355 1332
@@ -1410,26 +1387,27 @@ static int adjust_enet_interface(struct ucc_geth_private *ugeth)
1410 1387
1411 /* Set UPSMR */ 1388 /* Set UPSMR */
1412 upsmr = in_be32(&uf_regs->upsmr); 1389 upsmr = in_be32(&uf_regs->upsmr);
1413 upsmr &= ~(UPSMR_RPM | UPSMR_R10M | UPSMR_TBIM | UPSMR_RMM); 1390 upsmr &= ~(UCC_GETH_UPSMR_RPM | UCC_GETH_UPSMR_R10M |
1391 UCC_GETH_UPSMR_TBIM | UCC_GETH_UPSMR_RMM);
1414 if ((ugeth->phy_interface == PHY_INTERFACE_MODE_RMII) || 1392 if ((ugeth->phy_interface == PHY_INTERFACE_MODE_RMII) ||
1415 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII) || 1393 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII) ||
1416 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) || 1394 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) ||
1417 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID) || 1395 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID) ||
1418 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) || 1396 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) ||
1419 (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) { 1397 (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) {
1420 upsmr |= UPSMR_RPM; 1398 upsmr |= UCC_GETH_UPSMR_RPM;
1421 switch (ugeth->max_speed) { 1399 switch (ugeth->max_speed) {
1422 case SPEED_10: 1400 case SPEED_10:
1423 upsmr |= UPSMR_R10M; 1401 upsmr |= UCC_GETH_UPSMR_R10M;
1424 /* FALLTHROUGH */ 1402 /* FALLTHROUGH */
1425 case SPEED_100: 1403 case SPEED_100:
1426 if (ugeth->phy_interface != PHY_INTERFACE_MODE_RTBI) 1404 if (ugeth->phy_interface != PHY_INTERFACE_MODE_RTBI)
1427 upsmr |= UPSMR_RMM; 1405 upsmr |= UCC_GETH_UPSMR_RMM;
1428 } 1406 }
1429 } 1407 }
1430 if ((ugeth->phy_interface == PHY_INTERFACE_MODE_TBI) || 1408 if ((ugeth->phy_interface == PHY_INTERFACE_MODE_TBI) ||
1431 (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) { 1409 (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) {
1432 upsmr |= UPSMR_TBIM; 1410 upsmr |= UCC_GETH_UPSMR_TBIM;
1433 } 1411 }
1434 out_be32(&uf_regs->upsmr, upsmr); 1412 out_be32(&uf_regs->upsmr, upsmr);
1435 1413
@@ -1517,9 +1495,9 @@ static void adjust_link(struct net_device *dev)
1517 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) || 1495 (ugeth->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) ||
1518 (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) { 1496 (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) {
1519 if (phydev->speed == SPEED_10) 1497 if (phydev->speed == SPEED_10)
1520 upsmr |= UPSMR_R10M; 1498 upsmr |= UCC_GETH_UPSMR_R10M;
1521 else 1499 else
1522 upsmr &= ~(UPSMR_R10M); 1500 upsmr &= ~UCC_GETH_UPSMR_R10M;
1523 } 1501 }
1524 break; 1502 break;
1525 default: 1503 default:
@@ -1602,10 +1580,8 @@ static int ugeth_graceful_stop_tx(struct ucc_geth_private *ugeth)
1602 uccf = ugeth->uccf; 1580 uccf = ugeth->uccf;
1603 1581
1604 /* Mask GRACEFUL STOP TX interrupt bit and clear it */ 1582 /* Mask GRACEFUL STOP TX interrupt bit and clear it */
1605 temp = in_be32(uccf->p_uccm); 1583 clrbits32(uccf->p_uccm, UCC_GETH_UCCE_GRA);
1606 temp &= ~UCCE_GRA; 1584 out_be32(uccf->p_ucce, UCC_GETH_UCCE_GRA); /* clear by writing 1 */
1607 out_be32(uccf->p_uccm, temp);
1608 out_be32(uccf->p_ucce, UCCE_GRA); /* clear by writing 1 */
1609 1585
1610 /* Issue host command */ 1586 /* Issue host command */
1611 cecr_subblock = 1587 cecr_subblock =
@@ -1617,7 +1593,7 @@ static int ugeth_graceful_stop_tx(struct ucc_geth_private *ugeth)
1617 do { 1593 do {
1618 msleep(10); 1594 msleep(10);
1619 temp = in_be32(uccf->p_ucce); 1595 temp = in_be32(uccf->p_ucce);
1620 } while (!(temp & UCCE_GRA) && --i); 1596 } while (!(temp & UCC_GETH_UCCE_GRA) && --i);
1621 1597
1622 uccf->stopped_tx = 1; 1598 uccf->stopped_tx = 1;
1623 1599
@@ -1975,12 +1951,9 @@ static void ucc_geth_set_multi(struct net_device *dev)
1975 uf_regs = ugeth->uccf->uf_regs; 1951 uf_regs = ugeth->uccf->uf_regs;
1976 1952
1977 if (dev->flags & IFF_PROMISC) { 1953 if (dev->flags & IFF_PROMISC) {
1978 1954 setbits32(&uf_regs->upsmr, UCC_GETH_UPSMR_PRO);
1979 out_be32(&uf_regs->upsmr, in_be32(&uf_regs->upsmr) | UPSMR_PRO);
1980
1981 } else { 1955 } else {
1982 1956 clrbits32(&uf_regs->upsmr, UCC_GETH_UPSMR_PRO);
1983 out_be32(&uf_regs->upsmr, in_be32(&uf_regs->upsmr)&~UPSMR_PRO);
1984 1957
1985 p_82xx_addr_filt = 1958 p_82xx_addr_filt =
1986 (struct ucc_geth_82xx_address_filtering_pram __iomem *) ugeth-> 1959 (struct ucc_geth_82xx_address_filtering_pram __iomem *) ugeth->
@@ -2020,7 +1993,6 @@ static void ucc_geth_stop(struct ucc_geth_private *ugeth)
2020{ 1993{
2021 struct ucc_geth __iomem *ug_regs = ugeth->ug_regs; 1994 struct ucc_geth __iomem *ug_regs = ugeth->ug_regs;
2022 struct phy_device *phydev = ugeth->phydev; 1995 struct phy_device *phydev = ugeth->phydev;
2023 u32 tempval;
2024 1996
2025 ugeth_vdbg("%s: IN", __func__); 1997 ugeth_vdbg("%s: IN", __func__);
2026 1998
@@ -2037,9 +2009,7 @@ static void ucc_geth_stop(struct ucc_geth_private *ugeth)
2037 out_be32(ugeth->uccf->p_ucce, 0xffffffff); 2009 out_be32(ugeth->uccf->p_ucce, 0xffffffff);
2038 2010
2039 /* Disable Rx and Tx */ 2011 /* Disable Rx and Tx */
2040 tempval = in_be32(&ug_regs->maccfg1); 2012 clrbits32(&ug_regs->maccfg1, MACCFG1_ENABLE_RX | MACCFG1_ENABLE_TX);
2041 tempval &= ~(MACCFG1_ENABLE_RX | MACCFG1_ENABLE_TX);
2042 out_be32(&ug_regs->maccfg1, tempval);
2043 2013
2044 ucc_geth_memclean(ugeth); 2014 ucc_geth_memclean(ugeth);
2045} 2015}
@@ -2153,10 +2123,10 @@ static int ucc_struct_init(struct ucc_geth_private *ugeth)
2153 /* Generate uccm_mask for receive */ 2123 /* Generate uccm_mask for receive */
2154 uf_info->uccm_mask = ug_info->eventRegMask & UCCE_OTHER;/* Errors */ 2124 uf_info->uccm_mask = ug_info->eventRegMask & UCCE_OTHER;/* Errors */
2155 for (i = 0; i < ug_info->numQueuesRx; i++) 2125 for (i = 0; i < ug_info->numQueuesRx; i++)
2156 uf_info->uccm_mask |= (UCCE_RXBF_SINGLE_MASK << i); 2126 uf_info->uccm_mask |= (UCC_GETH_UCCE_RXF0 << i);
2157 2127
2158 for (i = 0; i < ug_info->numQueuesTx; i++) 2128 for (i = 0; i < ug_info->numQueuesTx; i++)
2159 uf_info->uccm_mask |= (UCCE_TXBF_SINGLE_MASK << i); 2129 uf_info->uccm_mask |= (UCC_GETH_UCCE_TXB0 << i);
2160 /* Initialize the general fast UCC block. */ 2130 /* Initialize the general fast UCC block. */
2161 if (ucc_fast_init(uf_info, &ugeth->uccf)) { 2131 if (ucc_fast_init(uf_info, &ugeth->uccf)) {
2162 if (netif_msg_probe(ugeth)) 2132 if (netif_msg_probe(ugeth))
@@ -2185,7 +2155,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2185 struct ucc_geth __iomem *ug_regs; 2155 struct ucc_geth __iomem *ug_regs;
2186 int ret_val = -EINVAL; 2156 int ret_val = -EINVAL;
2187 u32 remoder = UCC_GETH_REMODER_INIT; 2157 u32 remoder = UCC_GETH_REMODER_INIT;
2188 u32 init_enet_pram_offset, cecr_subblock, command, maccfg1; 2158 u32 init_enet_pram_offset, cecr_subblock, command;
2189 u32 ifstat, i, j, size, l2qt, l3qt, length; 2159 u32 ifstat, i, j, size, l2qt, l3qt, length;
2190 u16 temoder = UCC_GETH_TEMODER_INIT; 2160 u16 temoder = UCC_GETH_TEMODER_INIT;
2191 u16 test; 2161 u16 test;
@@ -2281,10 +2251,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2281 &uf_regs->upsmr, 2251 &uf_regs->upsmr,
2282 &ug_regs->uempr, &ug_regs->maccfg1); 2252 &ug_regs->uempr, &ug_regs->maccfg1);
2283 2253
2284 maccfg1 = in_be32(&ug_regs->maccfg1); 2254 setbits32(&ug_regs->maccfg1, MACCFG1_ENABLE_RX | MACCFG1_ENABLE_TX);
2285 maccfg1 |= MACCFG1_ENABLE_RX;
2286 maccfg1 |= MACCFG1_ENABLE_TX;
2287 out_be32(&ug_regs->maccfg1, maccfg1);
2288 2255
2289 /* Set IPGIFG */ 2256 /* Set IPGIFG */
2290 /* For more details see the hardware spec. */ 2257 /* For more details see the hardware spec. */
@@ -3274,7 +3241,6 @@ static int ucc_geth_tx(struct net_device *dev, u8 txQ)
3274static int ucc_geth_poll(struct napi_struct *napi, int budget) 3241static int ucc_geth_poll(struct napi_struct *napi, int budget)
3275{ 3242{
3276 struct ucc_geth_private *ugeth = container_of(napi, struct ucc_geth_private, napi); 3243 struct ucc_geth_private *ugeth = container_of(napi, struct ucc_geth_private, napi);
3277 struct net_device *dev = ugeth->dev;
3278 struct ucc_geth_info *ug_info; 3244 struct ucc_geth_info *ug_info;
3279 int howmany, i; 3245 int howmany, i;
3280 3246
@@ -3285,14 +3251,8 @@ static int ucc_geth_poll(struct napi_struct *napi, int budget)
3285 howmany += ucc_geth_rx(ugeth, i, budget - howmany); 3251 howmany += ucc_geth_rx(ugeth, i, budget - howmany);
3286 3252
3287 if (howmany < budget) { 3253 if (howmany < budget) {
3288 struct ucc_fast_private *uccf;
3289 u32 uccm;
3290
3291 netif_rx_complete(napi); 3254 netif_rx_complete(napi);
3292 uccf = ugeth->uccf; 3255 setbits32(ugeth->uccf->p_uccm, UCCE_RX_EVENTS);
3293 uccm = in_be32(uccf->p_uccm);
3294 uccm |= UCCE_RX_EVENTS;
3295 out_be32(uccf->p_uccm, uccm);
3296 } 3256 }
3297 3257
3298 return howmany; 3258 return howmany;
@@ -3332,7 +3292,7 @@ static irqreturn_t ucc_geth_irq_handler(int irq, void *info)
3332 /* Tx event processing */ 3292 /* Tx event processing */
3333 if (ucce & UCCE_TX_EVENTS) { 3293 if (ucce & UCCE_TX_EVENTS) {
3334 spin_lock(&ugeth->lock); 3294 spin_lock(&ugeth->lock);
3335 tx_mask = UCCE_TXBF_SINGLE_MASK; 3295 tx_mask = UCC_GETH_UCCE_TXB0;
3336 for (i = 0; i < ug_info->numQueuesTx; i++) { 3296 for (i = 0; i < ug_info->numQueuesTx; i++) {
3337 if (ucce & tx_mask) 3297 if (ucce & tx_mask)
3338 ucc_geth_tx(dev, i); 3298 ucc_geth_tx(dev, i);
@@ -3344,12 +3304,10 @@ static irqreturn_t ucc_geth_irq_handler(int irq, void *info)
3344 3304
3345 /* Errors and other events */ 3305 /* Errors and other events */
3346 if (ucce & UCCE_OTHER) { 3306 if (ucce & UCCE_OTHER) {
3347 if (ucce & UCCE_BSY) { 3307 if (ucce & UCC_GETH_UCCE_BSY)
3348 dev->stats.rx_errors++; 3308 dev->stats.rx_errors++;
3349 } 3309 if (ucce & UCC_GETH_UCCE_TXE)
3350 if (ucce & UCCE_TXE) {
3351 dev->stats.tx_errors++; 3310 dev->stats.tx_errors++;
3352 }
3353 } 3311 }
3354 3312
3355 return IRQ_HANDLED; 3313 return IRQ_HANDLED;
diff --git a/drivers/net/ucc_geth.h b/drivers/net/ucc_geth.h
index d74d2f7cb739..8f699cb773ee 100644
--- a/drivers/net/ucc_geth.h
+++ b/drivers/net/ucc_geth.h
@@ -162,92 +162,27 @@ struct ucc_geth {
162 boundary */ 162 boundary */
163 163
164/* UCC GETH Event Register */ 164/* UCC GETH Event Register */
165#define UCCE_MPD 0x80000000 /* Magic packet 165#define UCCE_TXB (UCC_GETH_UCCE_TXB7 | UCC_GETH_UCCE_TXB6 | \
166 detection */ 166 UCC_GETH_UCCE_TXB5 | UCC_GETH_UCCE_TXB4 | \
167#define UCCE_SCAR 0x40000000 167 UCC_GETH_UCCE_TXB3 | UCC_GETH_UCCE_TXB2 | \
168#define UCCE_GRA 0x20000000 /* Tx graceful 168 UCC_GETH_UCCE_TXB1 | UCC_GETH_UCCE_TXB0)
169 stop 169
170 complete */ 170#define UCCE_RXB (UCC_GETH_UCCE_RXB7 | UCC_GETH_UCCE_RXB6 | \
171#define UCCE_CBPR 0x10000000 171 UCC_GETH_UCCE_RXB5 | UCC_GETH_UCCE_RXB4 | \
172#define UCCE_BSY 0x08000000 172 UCC_GETH_UCCE_RXB3 | UCC_GETH_UCCE_RXB2 | \
173#define UCCE_RXC 0x04000000 173 UCC_GETH_UCCE_RXB1 | UCC_GETH_UCCE_RXB0)
174#define UCCE_TXC 0x02000000 174
175#define UCCE_TXE 0x01000000 175#define UCCE_RXF (UCC_GETH_UCCE_RXF7 | UCC_GETH_UCCE_RXF6 | \
176#define UCCE_TXB7 0x00800000 176 UCC_GETH_UCCE_RXF5 | UCC_GETH_UCCE_RXF4 | \
177#define UCCE_TXB6 0x00400000 177 UCC_GETH_UCCE_RXF3 | UCC_GETH_UCCE_RXF2 | \
178#define UCCE_TXB5 0x00200000 178 UCC_GETH_UCCE_RXF1 | UCC_GETH_UCCE_RXF0)
179#define UCCE_TXB4 0x00100000 179
180#define UCCE_TXB3 0x00080000 180#define UCCE_OTHER (UCC_GETH_UCCE_SCAR | UCC_GETH_UCCE_GRA | \
181#define UCCE_TXB2 0x00040000 181 UCC_GETH_UCCE_CBPR | UCC_GETH_UCCE_BSY | \
182#define UCCE_TXB1 0x00020000 182 UCC_GETH_UCCE_RXC | UCC_GETH_UCCE_TXC | UCC_GETH_UCCE_TXE)
183#define UCCE_TXB0 0x00010000 183
184#define UCCE_RXB7 0x00008000 184#define UCCE_RX_EVENTS (UCCE_RXF | UCC_GETH_UCCE_BSY)
185#define UCCE_RXB6 0x00004000 185#define UCCE_TX_EVENTS (UCCE_TXB | UCC_GETH_UCCE_TXE)
186#define UCCE_RXB5 0x00002000
187#define UCCE_RXB4 0x00001000
188#define UCCE_RXB3 0x00000800
189#define UCCE_RXB2 0x00000400
190#define UCCE_RXB1 0x00000200
191#define UCCE_RXB0 0x00000100
192#define UCCE_RXF7 0x00000080
193#define UCCE_RXF6 0x00000040
194#define UCCE_RXF5 0x00000020
195#define UCCE_RXF4 0x00000010
196#define UCCE_RXF3 0x00000008
197#define UCCE_RXF2 0x00000004
198#define UCCE_RXF1 0x00000002
199#define UCCE_RXF0 0x00000001
200
201#define UCCE_RXBF_SINGLE_MASK (UCCE_RXF0)
202#define UCCE_TXBF_SINGLE_MASK (UCCE_TXB0)
203
204#define UCCE_TXB (UCCE_TXB7 | UCCE_TXB6 | UCCE_TXB5 | UCCE_TXB4 |\
205 UCCE_TXB3 | UCCE_TXB2 | UCCE_TXB1 | UCCE_TXB0)
206#define UCCE_RXB (UCCE_RXB7 | UCCE_RXB6 | UCCE_RXB5 | UCCE_RXB4 |\
207 UCCE_RXB3 | UCCE_RXB2 | UCCE_RXB1 | UCCE_RXB0)
208#define UCCE_RXF (UCCE_RXF7 | UCCE_RXF6 | UCCE_RXF5 | UCCE_RXF4 |\
209 UCCE_RXF3 | UCCE_RXF2 | UCCE_RXF1 | UCCE_RXF0)
210#define UCCE_OTHER (UCCE_SCAR | UCCE_GRA | UCCE_CBPR | UCCE_BSY |\
211 UCCE_RXC | UCCE_TXC | UCCE_TXE)
212
213#define UCCE_RX_EVENTS (UCCE_RXF | UCCE_BSY)
214#define UCCE_TX_EVENTS (UCCE_TXB | UCCE_TXE)
215
216/* UCC GETH UPSMR (Protocol Specific Mode Register) */
217#define UPSMR_ECM 0x04000000 /* Enable CAM
218 Miss or
219 Enable
220 Filtering
221 Miss */
222#define UPSMR_HSE 0x02000000 /* Hardware
223 Statistics
224 Enable */
225#define UPSMR_PRO 0x00400000 /* Promiscuous*/
226#define UPSMR_CAP 0x00200000 /* CAM polarity
227 */
228#define UPSMR_RSH 0x00100000 /* Receive
229 Short Frames
230 */
231#define UPSMR_RPM 0x00080000 /* Reduced Pin
232 Mode
233 interfaces */
234#define UPSMR_R10M 0x00040000 /* RGMII/RMII
235 10 Mode */
236#define UPSMR_RLPB 0x00020000 /* RMII
237 Loopback
238 Mode */
239#define UPSMR_TBIM 0x00010000 /* Ten-bit
240 Interface
241 Mode */
242#define UPSMR_RMM 0x00001000 /* RMII/RGMII
243 Mode */
244#define UPSMR_CAM 0x00000400 /* CAM Address
245 Matching */
246#define UPSMR_BRO 0x00000200 /* Broadcast
247 Address */
248#define UPSMR_RES1 0x00002000 /* Reserved
249 feild - must
250 be 1 */
251 186
252/* UCC GETH MACCFG1 (MAC Configuration 1 Register) */ 187/* UCC GETH MACCFG1 (MAC Configuration 1 Register) */
253#define MACCFG1_FLOW_RX 0x00000020 /* Flow Control 188#define MACCFG1_FLOW_RX 0x00000020 /* Flow Control
@@ -945,9 +880,10 @@ struct ucc_geth_hardware_statistics {
945#define UCC_GETH_REMODER_INIT 0 /* bits that must be 880#define UCC_GETH_REMODER_INIT 0 /* bits that must be
946 set */ 881 set */
947#define UCC_GETH_TEMODER_INIT 0xC000 /* bits that must */ 882#define UCC_GETH_TEMODER_INIT 0xC000 /* bits that must */
948#define UCC_GETH_UPSMR_INIT (UPSMR_RES1) /* Start value 883
949 for this 884/* Initial value for UPSMR */
950 register */ 885#define UCC_GETH_UPSMR_INIT UCC_GETH_UPSMR_RES1
886
951#define UCC_GETH_MACCFG1_INIT 0 887#define UCC_GETH_MACCFG1_INIT 0
952#define UCC_GETH_MACCFG2_INIT (MACCFG2_RESERVED_1) 888#define UCC_GETH_MACCFG2_INIT (MACCFG2_RESERVED_1)
953 889
diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
index edd244f3acb5..5b67bbf1987e 100644
--- a/drivers/net/usb/dm9601.c
+++ b/drivers/net/usb/dm9601.c
@@ -23,7 +23,7 @@
23#include <linux/usb/usbnet.h> 23#include <linux/usb/usbnet.h>
24 24
25/* datasheet: 25/* datasheet:
26 http://www.davicom.com.tw/big5/download/Data%20Sheet/DM9601-DS-P01-930914.pdf 26 http://ptm2.cc.utu.fi/ftp/network/cards/DM9601/From_NET/DM9601-DS-P01-930914.pdf
27*/ 27*/
28 28
29/* control requests */ 29/* control requests */
@@ -397,16 +397,24 @@ static void dm9601_set_multicast(struct net_device *net)
397 dm_write_reg_async(dev, DM_RX_CTRL, rx_ctl); 397 dm_write_reg_async(dev, DM_RX_CTRL, rx_ctl);
398} 398}
399 399
400static void __dm9601_set_mac_address(struct usbnet *dev)
401{
402 dm_write_async(dev, DM_PHY_ADDR, ETH_ALEN, dev->net->dev_addr);
403}
404
400static int dm9601_set_mac_address(struct net_device *net, void *p) 405static int dm9601_set_mac_address(struct net_device *net, void *p)
401{ 406{
402 struct sockaddr *addr = p; 407 struct sockaddr *addr = p;
403 struct usbnet *dev = netdev_priv(net); 408 struct usbnet *dev = netdev_priv(net);
404 409
405 if (!is_valid_ether_addr(addr->sa_data)) 410 if (!is_valid_ether_addr(addr->sa_data)) {
411 dev_err(&net->dev, "not setting invalid mac address %pM\n",
412 addr->sa_data);
406 return -EINVAL; 413 return -EINVAL;
414 }
407 415
408 memcpy(net->dev_addr, addr->sa_data, net->addr_len); 416 memcpy(net->dev_addr, addr->sa_data, net->addr_len);
409 dm_write_async(dev, DM_PHY_ADDR, net->addr_len, net->dev_addr); 417 __dm9601_set_mac_address(dev);
410 418
411 return 0; 419 return 0;
412} 420}
@@ -414,6 +422,7 @@ static int dm9601_set_mac_address(struct net_device *net, void *p)
414static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf) 422static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf)
415{ 423{
416 int ret; 424 int ret;
425 u8 mac[ETH_ALEN];
417 426
418 ret = usbnet_get_endpoints(dev, intf); 427 ret = usbnet_get_endpoints(dev, intf);
419 if (ret) 428 if (ret)
@@ -438,12 +447,24 @@ static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf)
438 udelay(20); 447 udelay(20);
439 448
440 /* read MAC */ 449 /* read MAC */
441 if (dm_read(dev, DM_PHY_ADDR, ETH_ALEN, dev->net->dev_addr) < 0) { 450 if (dm_read(dev, DM_PHY_ADDR, ETH_ALEN, mac) < 0) {
442 printk(KERN_ERR "Error reading MAC address\n"); 451 printk(KERN_ERR "Error reading MAC address\n");
443 ret = -ENODEV; 452 ret = -ENODEV;
444 goto out; 453 goto out;
445 } 454 }
446 455
456 /*
457 * Overwrite the auto-generated address only with good ones.
458 */
459 if (is_valid_ether_addr(mac))
460 memcpy(dev->net->dev_addr, mac, ETH_ALEN);
461 else {
462 printk(KERN_WARNING
463 "dm9601: No valid MAC address in EEPROM, using %pM\n",
464 dev->net->dev_addr);
465 __dm9601_set_mac_address(dev);
466 }
467
447 /* power up phy */ 468 /* power up phy */
448 dm_write_reg(dev, DM_GPR_CTRL, 1); 469 dm_write_reg(dev, DM_GPR_CTRL, 1);
449 dm_write_reg(dev, DM_GPR_DATA, 0); 470 dm_write_reg(dev, DM_GPR_DATA, 0);
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index c4918b86ed19..0d0fa91c0251 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -1297,6 +1297,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
1297 /* setup */ 1297 /* setup */
1298 spin_lock_irq(&serial->serial_lock); 1298 spin_lock_irq(&serial->serial_lock);
1299 tty->driver_data = serial; 1299 tty->driver_data = serial;
1300 tty_kref_put(serial->tty);
1300 serial->tty = tty_kref_get(tty); 1301 serial->tty = tty_kref_get(tty);
1301 spin_unlock_irq(&serial->serial_lock); 1302 spin_unlock_irq(&serial->serial_lock);
1302 1303
@@ -1792,8 +1793,8 @@ static int mux_device_request(struct hso_serial *serial, u8 type, u16 port,
1792 1793
1793 /* initialize */ 1794 /* initialize */
1794 ctrl_req->wValue = 0; 1795 ctrl_req->wValue = 0;
1795 ctrl_req->wIndex = hso_port_to_mux(port); 1796 ctrl_req->wIndex = cpu_to_le16(hso_port_to_mux(port));
1796 ctrl_req->wLength = size; 1797 ctrl_req->wLength = cpu_to_le16(size);
1797 1798
1798 if (type == USB_CDC_GET_ENCAPSULATED_RESPONSE) { 1799 if (type == USB_CDC_GET_ENCAPSULATED_RESPONSE) {
1799 /* Reading command */ 1800 /* Reading command */
@@ -2043,9 +2044,8 @@ static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial)
2043 return -2; 2044 return -2;
2044 } 2045 }
2045 2046
2046 spin_lock(&serial->serial_lock); 2047 /* All callers to put_rxbuf_data hold serial_lock */
2047 tty = tty_kref_get(serial->tty); 2048 tty = tty_kref_get(serial->tty);
2048 spin_unlock(&serial->serial_lock);
2049 2049
2050 /* Push data to tty */ 2050 /* Push data to tty */
2051 if (tty) { 2051 if (tty) {
@@ -2053,8 +2053,10 @@ static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial)
2053 serial->curr_rx_urb_offset; 2053 serial->curr_rx_urb_offset;
2054 D1("data to push to tty"); 2054 D1("data to push to tty");
2055 while (write_length_remaining) { 2055 while (write_length_remaining) {
2056 if (test_bit(TTY_THROTTLED, &tty->flags)) 2056 if (test_bit(TTY_THROTTLED, &tty->flags)) {
2057 tty_kref_put(tty);
2057 return -1; 2058 return -1;
2059 }
2058 curr_write_len = tty_insert_flip_string 2060 curr_write_len = tty_insert_flip_string
2059 (tty, urb->transfer_buffer + 2061 (tty, urb->transfer_buffer +
2060 serial->curr_rx_urb_offset, 2062 serial->curr_rx_urb_offset,
diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c
index 2ee034f70d1c..7cb10a0a5316 100644
--- a/drivers/net/usb/kaweth.c
+++ b/drivers/net/usb/kaweth.c
@@ -251,7 +251,6 @@ struct kaweth_device
251 struct net_device_stats stats; 251 struct net_device_stats stats;
252}; 252};
253 253
254
255/**************************************************************** 254/****************************************************************
256 * kaweth_control 255 * kaweth_control
257 ****************************************************************/ 256 ****************************************************************/
@@ -283,9 +282,9 @@ static int kaweth_control(struct kaweth_device *kaweth,
283 282
284 dr->bRequestType= requesttype; 283 dr->bRequestType= requesttype;
285 dr->bRequest = request; 284 dr->bRequest = request;
286 dr->wValue = cpu_to_le16p(&value); 285 dr->wValue = cpu_to_le16(value);
287 dr->wIndex = cpu_to_le16p(&index); 286 dr->wIndex = cpu_to_le16(index);
288 dr->wLength = cpu_to_le16p(&size); 287 dr->wLength = cpu_to_le16(size);
289 288
290 return kaweth_internal_control_msg(kaweth->dev, 289 return kaweth_internal_control_msg(kaweth->dev,
291 pipe, 290 pipe,
@@ -975,6 +974,17 @@ static int kaweth_resume(struct usb_interface *intf)
975/**************************************************************** 974/****************************************************************
976 * kaweth_probe 975 * kaweth_probe
977 ****************************************************************/ 976 ****************************************************************/
977
978
979static const struct net_device_ops kaweth_netdev_ops = {
980 .ndo_open = kaweth_open,
981 .ndo_stop = kaweth_close,
982 .ndo_start_xmit = kaweth_start_xmit,
983 .ndo_tx_timeout = kaweth_tx_timeout,
984 .ndo_set_multicast_list = kaweth_set_rx_mode,
985 .ndo_get_stats = kaweth_netdev_stats,
986};
987
978static int kaweth_probe( 988static int kaweth_probe(
979 struct usb_interface *intf, 989 struct usb_interface *intf,
980 const struct usb_device_id *id /* from id_table */ 990 const struct usb_device_id *id /* from id_table */
@@ -1147,22 +1157,13 @@ err_fw:
1147 memcpy(netdev->dev_addr, &kaweth->configuration.hw_addr, 1157 memcpy(netdev->dev_addr, &kaweth->configuration.hw_addr,
1148 sizeof(kaweth->configuration.hw_addr)); 1158 sizeof(kaweth->configuration.hw_addr));
1149 1159
1150 netdev->open = kaweth_open; 1160 netdev->netdev_ops = &kaweth_netdev_ops;
1151 netdev->stop = kaweth_close;
1152
1153 netdev->watchdog_timeo = KAWETH_TX_TIMEOUT; 1161 netdev->watchdog_timeo = KAWETH_TX_TIMEOUT;
1154 netdev->tx_timeout = kaweth_tx_timeout;
1155
1156 netdev->hard_start_xmit = kaweth_start_xmit;
1157 netdev->set_multicast_list = kaweth_set_rx_mode;
1158 netdev->get_stats = kaweth_netdev_stats;
1159 netdev->mtu = le16_to_cpu(kaweth->configuration.segment_size); 1162 netdev->mtu = le16_to_cpu(kaweth->configuration.segment_size);
1160 SET_ETHTOOL_OPS(netdev, &ops); 1163 SET_ETHTOOL_OPS(netdev, &ops);
1161 1164
1162 /* kaweth is zeroed as part of alloc_netdev */ 1165 /* kaweth is zeroed as part of alloc_netdev */
1163
1164 INIT_DELAYED_WORK(&kaweth->lowmem_work, kaweth_resubmit_tl); 1166 INIT_DELAYED_WORK(&kaweth->lowmem_work, kaweth_resubmit_tl);
1165
1166 usb_set_intfdata(intf, kaweth); 1167 usb_set_intfdata(intf, kaweth);
1167 1168
1168#if 0 1169#if 0
diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c
index 166880c113d6..a8228d87c8cf 100644
--- a/drivers/net/usb/pegasus.c
+++ b/drivers/net/usb/pegasus.c
@@ -93,6 +93,7 @@ module_param (msg_level, int, 0);
93MODULE_PARM_DESC (msg_level, "Override default message level"); 93MODULE_PARM_DESC (msg_level, "Override default message level");
94 94
95MODULE_DEVICE_TABLE(usb, pegasus_ids); 95MODULE_DEVICE_TABLE(usb, pegasus_ids);
96static const struct net_device_ops pegasus_netdev_ops;
96 97
97static int update_eth_regs_async(pegasus_t *); 98static int update_eth_regs_async(pegasus_t *);
98/* Aargh!!! I _really_ hate such tweaks */ 99/* Aargh!!! I _really_ hate such tweaks */
@@ -150,8 +151,8 @@ static int get_registers(pegasus_t * pegasus, __u16 indx, __u16 size,
150 pegasus->dr.bRequestType = PEGASUS_REQT_READ; 151 pegasus->dr.bRequestType = PEGASUS_REQT_READ;
151 pegasus->dr.bRequest = PEGASUS_REQ_GET_REGS; 152 pegasus->dr.bRequest = PEGASUS_REQ_GET_REGS;
152 pegasus->dr.wValue = cpu_to_le16(0); 153 pegasus->dr.wValue = cpu_to_le16(0);
153 pegasus->dr.wIndex = cpu_to_le16p(&indx); 154 pegasus->dr.wIndex = cpu_to_le16(indx);
154 pegasus->dr.wLength = cpu_to_le16p(&size); 155 pegasus->dr.wLength = cpu_to_le16(size);
155 pegasus->ctrl_urb->transfer_buffer_length = size; 156 pegasus->ctrl_urb->transfer_buffer_length = size;
156 157
157 usb_fill_control_urb(pegasus->ctrl_urb, pegasus->usb, 158 usb_fill_control_urb(pegasus->ctrl_urb, pegasus->usb,
@@ -208,8 +209,8 @@ static int set_registers(pegasus_t * pegasus, __u16 indx, __u16 size,
208 pegasus->dr.bRequestType = PEGASUS_REQT_WRITE; 209 pegasus->dr.bRequestType = PEGASUS_REQT_WRITE;
209 pegasus->dr.bRequest = PEGASUS_REQ_SET_REGS; 210 pegasus->dr.bRequest = PEGASUS_REQ_SET_REGS;
210 pegasus->dr.wValue = cpu_to_le16(0); 211 pegasus->dr.wValue = cpu_to_le16(0);
211 pegasus->dr.wIndex = cpu_to_le16p(&indx); 212 pegasus->dr.wIndex = cpu_to_le16(indx);
212 pegasus->dr.wLength = cpu_to_le16p(&size); 213 pegasus->dr.wLength = cpu_to_le16(size);
213 pegasus->ctrl_urb->transfer_buffer_length = size; 214 pegasus->ctrl_urb->transfer_buffer_length = size;
214 215
215 usb_fill_control_urb(pegasus->ctrl_urb, pegasus->usb, 216 usb_fill_control_urb(pegasus->ctrl_urb, pegasus->usb,
@@ -261,7 +262,7 @@ static int set_register(pegasus_t * pegasus, __u16 indx, __u8 data)
261 pegasus->dr.bRequestType = PEGASUS_REQT_WRITE; 262 pegasus->dr.bRequestType = PEGASUS_REQT_WRITE;
262 pegasus->dr.bRequest = PEGASUS_REQ_SET_REG; 263 pegasus->dr.bRequest = PEGASUS_REQ_SET_REG;
263 pegasus->dr.wValue = cpu_to_le16(data); 264 pegasus->dr.wValue = cpu_to_le16(data);
264 pegasus->dr.wIndex = cpu_to_le16p(&indx); 265 pegasus->dr.wIndex = cpu_to_le16(indx);
265 pegasus->dr.wLength = cpu_to_le16(1); 266 pegasus->dr.wLength = cpu_to_le16(1);
266 pegasus->ctrl_urb->transfer_buffer_length = 1; 267 pegasus->ctrl_urb->transfer_buffer_length = 1;
267 268
@@ -476,7 +477,7 @@ static inline void get_node_id(pegasus_t * pegasus, __u8 * id)
476 477
477 for (i = 0; i < 3; i++) { 478 for (i = 0; i < 3; i++) {
478 read_eprom_word(pegasus, i, &w16); 479 read_eprom_word(pegasus, i, &w16);
479 ((__le16 *) id)[i] = cpu_to_le16p(&w16); 480 ((__le16 *) id)[i] = cpu_to_le16(w16);
480 } 481 }
481} 482}
482 483
@@ -1360,14 +1361,10 @@ static int pegasus_probe(struct usb_interface *intf,
1360 pegasus->intf = intf; 1361 pegasus->intf = intf;
1361 pegasus->usb = dev; 1362 pegasus->usb = dev;
1362 pegasus->net = net; 1363 pegasus->net = net;
1363 net->open = pegasus_open; 1364
1364 net->stop = pegasus_close; 1365
1365 net->watchdog_timeo = PEGASUS_TX_TIMEOUT; 1366 net->watchdog_timeo = PEGASUS_TX_TIMEOUT;
1366 net->tx_timeout = pegasus_tx_timeout; 1367 net->netdev_ops = &pegasus_netdev_ops;
1367 net->do_ioctl = pegasus_ioctl;
1368 net->hard_start_xmit = pegasus_start_xmit;
1369 net->set_multicast_list = pegasus_set_multicast;
1370 net->get_stats = pegasus_netdev_stats;
1371 SET_ETHTOOL_OPS(net, &ops); 1368 SET_ETHTOOL_OPS(net, &ops);
1372 pegasus->mii.dev = net; 1369 pegasus->mii.dev = net;
1373 pegasus->mii.mdio_read = mdio_read; 1370 pegasus->mii.mdio_read = mdio_read;
@@ -1482,6 +1479,16 @@ static int pegasus_resume (struct usb_interface *intf)
1482 return 0; 1479 return 0;
1483} 1480}
1484 1481
1482static const struct net_device_ops pegasus_netdev_ops = {
1483 .ndo_open = pegasus_open,
1484 .ndo_stop = pegasus_close,
1485 .ndo_do_ioctl = pegasus_ioctl,
1486 .ndo_start_xmit = pegasus_start_xmit,
1487 .ndo_set_multicast_list = pegasus_set_multicast,
1488 .ndo_get_stats = pegasus_netdev_stats,
1489 .ndo_tx_timeout = pegasus_tx_timeout,
1490};
1491
1485static struct usb_driver pegasus_driver = { 1492static struct usb_driver pegasus_driver = {
1486 .name = driver_name, 1493 .name = driver_name,
1487 .probe = pegasus_probe, 1494 .probe = pegasus_probe,
diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
index ac07cc6e3cb2..3b8e63254277 100644
--- a/drivers/net/via-rhine.c
+++ b/drivers/net/via-rhine.c
@@ -622,6 +622,7 @@ static const struct net_device_ops rhine_netdev_ops = {
622 .ndo_get_stats = rhine_get_stats, 622 .ndo_get_stats = rhine_get_stats,
623 .ndo_set_multicast_list = rhine_set_rx_mode, 623 .ndo_set_multicast_list = rhine_set_rx_mode,
624 .ndo_validate_addr = eth_validate_addr, 624 .ndo_validate_addr = eth_validate_addr,
625 .ndo_set_mac_address = eth_mac_addr,
625 .ndo_do_ioctl = netdev_ioctl, 626 .ndo_do_ioctl = netdev_ioctl,
626 .ndo_tx_timeout = rhine_tx_timeout, 627 .ndo_tx_timeout = rhine_tx_timeout,
627#ifdef CONFIG_NET_POLL_CONTROLLER 628#ifdef CONFIG_NET_POLL_CONTROLLER
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
index 58e25d090ae0..a75f91dc3153 100644
--- a/drivers/net/via-velocity.c
+++ b/drivers/net/via-velocity.c
@@ -855,6 +855,7 @@ static const struct net_device_ops velocity_netdev_ops = {
855 .ndo_start_xmit = velocity_xmit, 855 .ndo_start_xmit = velocity_xmit,
856 .ndo_get_stats = velocity_get_stats, 856 .ndo_get_stats = velocity_get_stats,
857 .ndo_validate_addr = eth_validate_addr, 857 .ndo_validate_addr = eth_validate_addr,
858 .ndo_set_mac_address = eth_mac_addr,
858 .ndo_set_multicast_list = velocity_set_multi, 859 .ndo_set_multicast_list = velocity_set_multi,
859 .ndo_change_mtu = velocity_change_mtu, 860 .ndo_change_mtu = velocity_change_mtu,
860 .ndo_do_ioctl = velocity_ioctl, 861 .ndo_do_ioctl = velocity_ioctl,
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index b7004ff36451..43f6523c40be 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -624,6 +624,18 @@ static int virtnet_change_mtu(struct net_device *dev, int new_mtu)
624 return 0; 624 return 0;
625} 625}
626 626
627static const struct net_device_ops virtnet_netdev = {
628 .ndo_open = virtnet_open,
629 .ndo_stop = virtnet_close,
630 .ndo_start_xmit = start_xmit,
631 .ndo_validate_addr = eth_validate_addr,
632 .ndo_set_mac_address = eth_mac_addr,
633 .ndo_change_mtu = virtnet_change_mtu,
634#ifdef CONFIG_NET_POLL_CONTROLLER
635 .ndo_poll_controller = virtnet_netpoll,
636#endif
637};
638
627static int virtnet_probe(struct virtio_device *vdev) 639static int virtnet_probe(struct virtio_device *vdev)
628{ 640{
629 int err; 641 int err;
@@ -636,14 +648,8 @@ static int virtnet_probe(struct virtio_device *vdev)
636 return -ENOMEM; 648 return -ENOMEM;
637 649
638 /* Set up network device as normal. */ 650 /* Set up network device as normal. */
639 dev->open = virtnet_open; 651 dev->netdev_ops = &virtnet_netdev;
640 dev->stop = virtnet_close;
641 dev->hard_start_xmit = start_xmit;
642 dev->change_mtu = virtnet_change_mtu;
643 dev->features = NETIF_F_HIGHDMA; 652 dev->features = NETIF_F_HIGHDMA;
644#ifdef CONFIG_NET_POLL_CONTROLLER
645 dev->poll_controller = virtnet_netpoll;
646#endif
647 SET_ETHTOOL_OPS(dev, &virtnet_ethtool_ops); 653 SET_ETHTOOL_OPS(dev, &virtnet_ethtool_ops);
648 SET_NETDEV_DEV(dev, &vdev->dev); 654 SET_NETDEV_DEV(dev, &vdev->dev);
649 655
diff --git a/drivers/net/wan/ixp4xx_hss.c b/drivers/net/wan/ixp4xx_hss.c
index 2dc241689d37..0dbd85b0162d 100644
--- a/drivers/net/wan/ixp4xx_hss.c
+++ b/drivers/net/wan/ixp4xx_hss.c
@@ -622,7 +622,7 @@ static void hss_hdlc_rx_irq(void *pdev)
622 printk(KERN_DEBUG "%s: hss_hdlc_rx_irq\n", dev->name); 622 printk(KERN_DEBUG "%s: hss_hdlc_rx_irq\n", dev->name);
623#endif 623#endif
624 qmgr_disable_irq(queue_ids[port->id].rx); 624 qmgr_disable_irq(queue_ids[port->id].rx);
625 netif_rx_schedule(dev, &port->napi); 625 netif_rx_schedule(&port->napi);
626} 626}
627 627
628static int hss_hdlc_poll(struct napi_struct *napi, int budget) 628static int hss_hdlc_poll(struct napi_struct *napi, int budget)
@@ -651,7 +651,7 @@ static int hss_hdlc_poll(struct napi_struct *napi, int budget)
651 printk(KERN_DEBUG "%s: hss_hdlc_poll" 651 printk(KERN_DEBUG "%s: hss_hdlc_poll"
652 " netif_rx_complete\n", dev->name); 652 " netif_rx_complete\n", dev->name);
653#endif 653#endif
654 netif_rx_complete(dev, napi); 654 netif_rx_complete(napi);
655 qmgr_enable_irq(rxq); 655 qmgr_enable_irq(rxq);
656 if (!qmgr_stat_empty(rxq) && 656 if (!qmgr_stat_empty(rxq) &&
657 netif_rx_reschedule(napi)) { 657 netif_rx_reschedule(napi)) {
@@ -1069,7 +1069,7 @@ static int hss_hdlc_open(struct net_device *dev)
1069 hss_start_hdlc(port); 1069 hss_start_hdlc(port);
1070 1070
1071 /* we may already have RX data, enables IRQ */ 1071 /* we may already have RX data, enables IRQ */
1072 netif_rx_schedule(dev, &port->napi); 1072 netif_rx_schedule(&port->napi);
1073 return 0; 1073 return 0;
1074 1074
1075err_unlock: 1075err_unlock:
diff --git a/drivers/net/wd.c b/drivers/net/wd.c
index 3c1edda08d3d..d8322d2d1e29 100644
--- a/drivers/net/wd.c
+++ b/drivers/net/wd.c
@@ -155,6 +155,7 @@ static const struct net_device_ops wd_netdev_ops = {
155 .ndo_get_stats = ei_get_stats, 155 .ndo_get_stats = ei_get_stats,
156 .ndo_set_multicast_list = ei_set_multicast_list, 156 .ndo_set_multicast_list = ei_set_multicast_list,
157 .ndo_validate_addr = eth_validate_addr, 157 .ndo_validate_addr = eth_validate_addr,
158 .ndo_set_mac_address = eth_mac_addr,
158 .ndo_change_mtu = eth_change_mtu, 159 .ndo_change_mtu = eth_change_mtu,
159#ifdef CONFIG_NET_POLL_CONTROLLER 160#ifdef CONFIG_NET_POLL_CONTROLLER
160 .ndo_poll_controller = ei_poll, 161 .ndo_poll_controller = ei_poll,
diff --git a/drivers/net/wimax/Kconfig b/drivers/net/wimax/Kconfig
new file mode 100644
index 000000000000..565018ec1e3b
--- /dev/null
+++ b/drivers/net/wimax/Kconfig
@@ -0,0 +1,17 @@
1#
2# WiMAX LAN device drivers configuration
3#
4
5
6comment "Enable WiMAX (Networking options) to see the WiMAX drivers"
7 depends on WIMAX = n
8
9if WIMAX
10
11menu "WiMAX Wireless Broadband devices"
12
13source "drivers/net/wimax/i2400m/Kconfig"
14
15endmenu
16
17endif
diff --git a/drivers/net/wimax/Makefile b/drivers/net/wimax/Makefile
new file mode 100644
index 000000000000..992bc02bc016
--- /dev/null
+++ b/drivers/net/wimax/Makefile
@@ -0,0 +1,5 @@
1
2obj-$(CONFIG_WIMAX_I2400M) += i2400m/
3
4# (from Sam Ravnborg) force kbuild to create built-in.o
5obj- := dummy.o
diff --git a/drivers/net/wimax/i2400m/Kconfig b/drivers/net/wimax/i2400m/Kconfig
new file mode 100644
index 000000000000..d623b3d99a4b
--- /dev/null
+++ b/drivers/net/wimax/i2400m/Kconfig
@@ -0,0 +1,49 @@
1
2config WIMAX_I2400M
3 tristate
4 depends on WIMAX
5 select FW_LOADER
6
7comment "Enable USB support to see WiMAX USB drivers"
8 depends on USB = n
9
10comment "Enable MMC support to see WiMAX SDIO drivers"
11 depends on MMC = n
12
13config WIMAX_I2400M_USB
14 tristate "Intel Wireless WiMAX Connection 2400 over USB (including 5x50)"
15 depends on WIMAX && USB
16 select WIMAX_I2400M
17 help
18 Select if you have a device based on the Intel WiMAX
19 Connection 2400 over USB (like any of the Intel Wireless
20 WiMAX/WiFi Link 5x50 series).
21
22 If unsure, it is safe to select M (module).
23
24config WIMAX_I2400M_SDIO
25 tristate "Intel Wireless WiMAX Connection 2400 over SDIO"
26 depends on WIMAX && MMC
27 select WIMAX_I2400M
28 help
29 Select if you have a device based on the Intel WiMAX
30 Connection 2400 over SDIO.
31
32 If unsure, it is safe to select M (module).
33
34config WIMAX_I2400M_DEBUG_LEVEL
35 int "WiMAX i2400m debug level"
36 depends on WIMAX_I2400M
37 default 8
38 help
39
40 Select the maximum debug verbosity level to be compiled into
41 the WiMAX i2400m driver code.
42
43 By default, this is disabled at runtime and can be
44 selectively enabled at runtime for different parts of the
45 code using the sysfs debug-levels file.
46
47 If set at zero, this will compile out all the debug code.
48
49 It is recommended that it is left at 8.
diff --git a/drivers/net/wimax/i2400m/Makefile b/drivers/net/wimax/i2400m/Makefile
new file mode 100644
index 000000000000..1696e936cf5a
--- /dev/null
+++ b/drivers/net/wimax/i2400m/Makefile
@@ -0,0 +1,29 @@
1
2obj-$(CONFIG_WIMAX_I2400M) += i2400m.o
3obj-$(CONFIG_WIMAX_I2400M_USB) += i2400m-usb.o
4obj-$(CONFIG_WIMAX_I2400M_SDIO) += i2400m-sdio.o
5
6i2400m-y := \
7 control.o \
8 driver.o \
9 fw.o \
10 op-rfkill.o \
11 netdev.o \
12 tx.o \
13 rx.o
14
15i2400m-$(CONFIG_DEBUG_FS) += debugfs.o
16
17i2400m-usb-y := \
18 usb-fw.o \
19 usb-notif.o \
20 usb-tx.o \
21 usb-rx.o \
22 usb.o
23
24
25i2400m-sdio-y := \
26 sdio.o \
27 sdio-tx.o \
28 sdio-fw.o \
29 sdio-rx.o
diff --git a/drivers/net/wimax/i2400m/control.c b/drivers/net/wimax/i2400m/control.c
new file mode 100644
index 000000000000..d3d37fed6893
--- /dev/null
+++ b/drivers/net/wimax/i2400m/control.c
@@ -0,0 +1,1291 @@
1/*
2 * Intel Wireless WiMAX Connection 2400m
3 * Miscellaneous control functions for managing the device
4 *
5 *
6 * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 *
35 * Intel Corporation <linux-wimax@intel.com>
36 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
37 * - Initial implementation
38 *
39 * This is a collection of functions used to control the device (plus
40 * a few helpers).
41 *
42 * There are utilities for handling TLV buffers, hooks on the device's
43 * reports to act on device changes of state [i2400m_report_hook()],
44 * on acks to commands [i2400m_msg_ack_hook()], a helper for sending
45 * commands to the device and blocking until a reply arrives
46 * [i2400m_msg_to_dev()], a few high level commands for manipulating
47 * the device state, powersving mode and configuration plus the
48 * routines to setup the device once communication is stablished with
49 * it [i2400m_dev_initialize()].
50 *
51 * ROADMAP
52 *
53 * i2400m_dev_initalize() Called by i2400m_dev_start()
54 * i2400m_set_init_config()
55 * i2400m_firmware_check()
56 * i2400m_cmd_get_state()
57 * i2400m_dev_shutdown() Called by i2400m_dev_stop()
58 * i2400m->bus_reset()
59 *
60 * i2400m_{cmd,get,set}_*()
61 * i2400m_msg_to_dev()
62 * i2400m_msg_check_status()
63 *
64 * i2400m_report_hook() Called on reception of an event
65 * i2400m_report_state_hook()
66 * i2400m_tlv_buffer_walk()
67 * i2400m_tlv_match()
68 * i2400m_report_tlv_system_state()
69 * i2400m_report_tlv_rf_switches_status()
70 * i2400m_report_tlv_media_status()
71 * i2400m_cmd_enter_powersave()
72 *
73 * i2400m_msg_ack_hook() Called on reception of a reply to a
74 * command, get or set
75 */
76
77#include <stdarg.h>
78#include "i2400m.h"
79#include <linux/kernel.h>
80#include <linux/wimax/i2400m.h>
81
82
83#define D_SUBMODULE control
84#include "debug-levels.h"
85
86
87/*
88 * Return if a TLV is of a give type and size
89 *
90 * @tlv_hdr: pointer to the TLV
91 * @tlv_type: type of the TLV we are looking for
92 * @tlv_size: expected size of the TLV we are looking for (if -1,
93 * don't check the size). This includes the header
94 * Returns: 0 if the TLV matches
95 * < 0 if it doesn't match at all
96 * > 0 total TLV + payload size, if the type matches, but not
97 * the size
98 */
99static
100ssize_t i2400m_tlv_match(const struct i2400m_tlv_hdr *tlv,
101 enum i2400m_tlv tlv_type, ssize_t tlv_size)
102{
103 if (le16_to_cpu(tlv->type) != tlv_type) /* Not our type? skip */
104 return -1;
105 if (tlv_size != -1
106 && le16_to_cpu(tlv->length) + sizeof(*tlv) != tlv_size) {
107 size_t size = le16_to_cpu(tlv->length) + sizeof(*tlv);
108 printk(KERN_WARNING "W: tlv type 0x%x mismatched because of "
109 "size (got %zu vs %zu expected)\n",
110 tlv_type, size, tlv_size);
111 return size;
112 }
113 return 0;
114}
115
116
117/*
118 * Given a buffer of TLVs, iterate over them
119 *
120 * @i2400m: device instance
121 * @tlv_buf: pointer to the beginning of the TLV buffer
122 * @buf_size: buffer size in bytes
123 * @tlv_pos: seek position; this is assumed to be a pointer returned
124 * by i2400m_tlv_buffer_walk() [and thus, validated]. The
125 * TLV returned will be the one following this one.
126 *
127 * Usage:
128 *
129 * tlv_itr = NULL;
130 * while (tlv_itr = i2400m_tlv_buffer_walk(i2400m, buf, size, tlv_itr)) {
131 * ...
132 * // Do stuff with tlv_itr, DON'T MODIFY IT
133 * ...
134 * }
135 */
136static
137const struct i2400m_tlv_hdr *i2400m_tlv_buffer_walk(
138 struct i2400m *i2400m,
139 const void *tlv_buf, size_t buf_size,
140 const struct i2400m_tlv_hdr *tlv_pos)
141{
142 struct device *dev = i2400m_dev(i2400m);
143 const struct i2400m_tlv_hdr *tlv_top = tlv_buf + buf_size;
144 size_t offset, length, avail_size;
145 unsigned type;
146
147 if (tlv_pos == NULL) /* Take the first one? */
148 tlv_pos = tlv_buf;
149 else /* Nope, the next one */
150 tlv_pos = (void *) tlv_pos
151 + le16_to_cpu(tlv_pos->length) + sizeof(*tlv_pos);
152 if (tlv_pos == tlv_top) { /* buffer done */
153 tlv_pos = NULL;
154 goto error_beyond_end;
155 }
156 if (tlv_pos > tlv_top) {
157 tlv_pos = NULL;
158 WARN_ON(1);
159 goto error_beyond_end;
160 }
161 offset = (void *) tlv_pos - (void *) tlv_buf;
162 avail_size = buf_size - offset;
163 if (avail_size < sizeof(*tlv_pos)) {
164 dev_err(dev, "HW BUG? tlv_buf %p [%zu bytes], tlv @%zu: "
165 "short header\n", tlv_buf, buf_size, offset);
166 goto error_short_header;
167 }
168 type = le16_to_cpu(tlv_pos->type);
169 length = le16_to_cpu(tlv_pos->length);
170 if (avail_size < sizeof(*tlv_pos) + length) {
171 dev_err(dev, "HW BUG? tlv_buf %p [%zu bytes], "
172 "tlv type 0x%04x @%zu: "
173 "short data (%zu bytes vs %zu needed)\n",
174 tlv_buf, buf_size, type, offset, avail_size,
175 sizeof(*tlv_pos) + length);
176 goto error_short_header;
177 }
178error_short_header:
179error_beyond_end:
180 return tlv_pos;
181}
182
183
184/*
185 * Find a TLV in a buffer of sequential TLVs
186 *
187 * @i2400m: device descriptor
188 * @tlv_hdr: pointer to the first TLV in the sequence
189 * @size: size of the buffer in bytes; all TLVs are assumed to fit
190 * fully in the buffer (otherwise we'll complain).
191 * @tlv_type: type of the TLV we are looking for
192 * @tlv_size: expected size of the TLV we are looking for (if -1,
193 * don't check the size). This includes the header
194 *
195 * Returns: NULL if the TLV is not found, otherwise a pointer to
196 * it. If the sizes don't match, an error is printed and NULL
197 * returned.
198 */
199static
200const struct i2400m_tlv_hdr *i2400m_tlv_find(
201 struct i2400m *i2400m,
202 const struct i2400m_tlv_hdr *tlv_hdr, size_t size,
203 enum i2400m_tlv tlv_type, ssize_t tlv_size)
204{
205 ssize_t match;
206 struct device *dev = i2400m_dev(i2400m);
207 const struct i2400m_tlv_hdr *tlv = NULL;
208 while ((tlv = i2400m_tlv_buffer_walk(i2400m, tlv_hdr, size, tlv))) {
209 match = i2400m_tlv_match(tlv, tlv_type, tlv_size);
210 if (match == 0) /* found it :) */
211 break;
212 if (match > 0)
213 dev_warn(dev, "TLV type 0x%04x found with size "
214 "mismatch (%zu vs %zu needed)\n",
215 tlv_type, match, tlv_size);
216 }
217 return tlv;
218}
219
220
221static const struct
222{
223 char *msg;
224 int errno;
225} ms_to_errno[I2400M_MS_MAX] = {
226 [I2400M_MS_DONE_OK] = { "", 0 },
227 [I2400M_MS_DONE_IN_PROGRESS] = { "", 0 },
228 [I2400M_MS_INVALID_OP] = { "invalid opcode", -ENOSYS },
229 [I2400M_MS_BAD_STATE] = { "invalid state", -EILSEQ },
230 [I2400M_MS_ILLEGAL_VALUE] = { "illegal value", -EINVAL },
231 [I2400M_MS_MISSING_PARAMS] = { "missing parameters", -ENOMSG },
232 [I2400M_MS_VERSION_ERROR] = { "bad version", -EIO },
233 [I2400M_MS_ACCESSIBILITY_ERROR] = { "accesibility error", -EIO },
234 [I2400M_MS_BUSY] = { "busy", -EBUSY },
235 [I2400M_MS_CORRUPTED_TLV] = { "corrupted TLV", -EILSEQ },
236 [I2400M_MS_UNINITIALIZED] = { "not unitialized", -EILSEQ },
237 [I2400M_MS_UNKNOWN_ERROR] = { "unknown error", -EIO },
238 [I2400M_MS_PRODUCTION_ERROR] = { "production error", -EIO },
239 [I2400M_MS_NO_RF] = { "no RF", -EIO },
240 [I2400M_MS_NOT_READY_FOR_POWERSAVE] =
241 { "not ready for powersave", -EACCES },
242 [I2400M_MS_THERMAL_CRITICAL] = { "thermal critical", -EL3HLT },
243};
244
245
246/*
247 * i2400m_msg_check_status - translate a message's status code
248 *
249 * @i2400m: device descriptor
250 * @l3l4_hdr: message header
251 * @strbuf: buffer to place a formatted error message (unless NULL).
252 * @strbuf_size: max amount of available space; larger messages will
253 * be truncated.
254 *
255 * Returns: errno code corresponding to the status code in @l3l4_hdr
256 * and a message in @strbuf describing the error.
257 */
258int i2400m_msg_check_status(const struct i2400m_l3l4_hdr *l3l4_hdr,
259 char *strbuf, size_t strbuf_size)
260{
261 int result;
262 enum i2400m_ms status = le16_to_cpu(l3l4_hdr->status);
263 const char *str;
264
265 if (status == 0)
266 return 0;
267 if (status > ARRAY_SIZE(ms_to_errno)) {
268 str = "unknown status code";
269 result = -EBADR;
270 } else {
271 str = ms_to_errno[status].msg;
272 result = ms_to_errno[status].errno;
273 }
274 if (strbuf)
275 snprintf(strbuf, strbuf_size, "%s (%d)", str, status);
276 return result;
277}
278
279
280/*
281 * Act on a TLV System State reported by the device
282 *
283 * @i2400m: device descriptor
284 * @ss: validated System State TLV
285 */
286static
287void i2400m_report_tlv_system_state(struct i2400m *i2400m,
288 const struct i2400m_tlv_system_state *ss)
289{
290 struct device *dev = i2400m_dev(i2400m);
291 struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
292 enum i2400m_system_state i2400m_state = le32_to_cpu(ss->state);
293
294 d_fnstart(3, dev, "(i2400m %p ss %p [%u])\n", i2400m, ss, i2400m_state);
295
296 if (unlikely(i2400m->ready == 0)) /* act if up */
297 goto out;
298 if (i2400m->state != i2400m_state) {
299 i2400m->state = i2400m_state;
300 wake_up_all(&i2400m->state_wq);
301 }
302 switch (i2400m_state) {
303 case I2400M_SS_UNINITIALIZED:
304 case I2400M_SS_INIT:
305 case I2400M_SS_CONFIG:
306 case I2400M_SS_PRODUCTION:
307 wimax_state_change(wimax_dev, WIMAX_ST_UNINITIALIZED);
308 break;
309
310 case I2400M_SS_RF_OFF:
311 case I2400M_SS_RF_SHUTDOWN:
312 wimax_state_change(wimax_dev, WIMAX_ST_RADIO_OFF);
313 break;
314
315 case I2400M_SS_READY:
316 case I2400M_SS_STANDBY:
317 case I2400M_SS_SLEEPACTIVE:
318 wimax_state_change(wimax_dev, WIMAX_ST_READY);
319 break;
320
321 case I2400M_SS_CONNECTING:
322 case I2400M_SS_WIMAX_CONNECTED:
323 wimax_state_change(wimax_dev, WIMAX_ST_READY);
324 break;
325
326 case I2400M_SS_SCAN:
327 case I2400M_SS_OUT_OF_ZONE:
328 wimax_state_change(wimax_dev, WIMAX_ST_SCANNING);
329 break;
330
331 case I2400M_SS_IDLE:
332 d_printf(1, dev, "entering BS-negotiated idle mode\n");
333 case I2400M_SS_DISCONNECTING:
334 case I2400M_SS_DATA_PATH_CONNECTED:
335 wimax_state_change(wimax_dev, WIMAX_ST_CONNECTED);
336 break;
337
338 default:
339 /* Huh? just in case, shut it down */
340 dev_err(dev, "HW BUG? unknown state %u: shutting down\n",
341 i2400m_state);
342 i2400m->bus_reset(i2400m, I2400M_RT_WARM);
343 break;
344 };
345out:
346 d_fnend(3, dev, "(i2400m %p ss %p [%u]) = void\n",
347 i2400m, ss, i2400m_state);
348}
349
350
351/*
352 * Parse and act on a TLV Media Status sent by the device
353 *
354 * @i2400m: device descriptor
355 * @ms: validated Media Status TLV
356 *
357 * This will set the carrier up on down based on the device's link
358 * report. This is done asides of what the WiMAX stack does based on
359 * the device's state as sometimes we need to do a link-renew (the BS
360 * wants us to renew a DHCP lease, for example).
361 *
362 * In fact, doc says that everytime we get a link-up, we should do a
363 * DHCP negotiation...
364 */
365static
366void i2400m_report_tlv_media_status(struct i2400m *i2400m,
367 const struct i2400m_tlv_media_status *ms)
368{
369 struct device *dev = i2400m_dev(i2400m);
370 struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
371 struct net_device *net_dev = wimax_dev->net_dev;
372 enum i2400m_media_status status = le32_to_cpu(ms->media_status);
373
374 d_fnstart(3, dev, "(i2400m %p ms %p [%u])\n", i2400m, ms, status);
375
376 if (unlikely(i2400m->ready == 0)) /* act if up */
377 goto out;
378 switch (status) {
379 case I2400M_MEDIA_STATUS_LINK_UP:
380 netif_carrier_on(net_dev);
381 break;
382 case I2400M_MEDIA_STATUS_LINK_DOWN:
383 netif_carrier_off(net_dev);
384 break;
385 /*
386 * This is the network telling us we need to retrain the DHCP
387 * lease -- so far, we are trusting the WiMAX Network Service
388 * in user space to pick this up and poke the DHCP client.
389 */
390 case I2400M_MEDIA_STATUS_LINK_RENEW:
391 netif_carrier_on(net_dev);
392 break;
393 default:
394 dev_err(dev, "HW BUG? unknown media status %u\n",
395 status);
396 };
397out:
398 d_fnend(3, dev, "(i2400m %p ms %p [%u]) = void\n",
399 i2400m, ms, status);
400}
401
402
403/*
404 * Parse a 'state report' and extract carrier on/off information
405 *
406 * @i2400m: device descriptor
407 * @l3l4_hdr: pointer to message; it has been already validated for
408 * consistent size.
409 * @size: size of the message (header + payload). The header length
410 * declaration is assumed to be congruent with @size (as in
411 * sizeof(*l3l4_hdr) + l3l4_hdr->length == size)
412 *
413 * Extract from the report state the system state TLV and infer from
414 * there if we have a carrier or not. Update our local state and tell
415 * netdev.
416 *
417 * When setting the carrier, it's fine to set OFF twice (for example),
418 * as netif_carrier_off() will not generate two OFF events (just on
419 * the transitions).
420 */
421static
422void i2400m_report_state_hook(struct i2400m *i2400m,
423 const struct i2400m_l3l4_hdr *l3l4_hdr,
424 size_t size, const char *tag)
425{
426 struct device *dev = i2400m_dev(i2400m);
427 const struct i2400m_tlv_hdr *tlv;
428 const struct i2400m_tlv_system_state *ss;
429 const struct i2400m_tlv_rf_switches_status *rfss;
430 const struct i2400m_tlv_media_status *ms;
431 size_t tlv_size = le16_to_cpu(l3l4_hdr->length);
432
433 d_fnstart(4, dev, "(i2400m %p, l3l4_hdr %p, size %zu, %s)\n",
434 i2400m, l3l4_hdr, size, tag);
435 tlv = NULL;
436
437 while ((tlv = i2400m_tlv_buffer_walk(i2400m, &l3l4_hdr->pl,
438 tlv_size, tlv))) {
439 if (0 == i2400m_tlv_match(tlv, I2400M_TLV_SYSTEM_STATE,
440 sizeof(*ss))) {
441 ss = container_of(tlv, typeof(*ss), hdr);
442 d_printf(2, dev, "%s: system state TLV "
443 "found (0x%04x), state 0x%08x\n",
444 tag, I2400M_TLV_SYSTEM_STATE,
445 le32_to_cpu(ss->state));
446 i2400m_report_tlv_system_state(i2400m, ss);
447 }
448 if (0 == i2400m_tlv_match(tlv, I2400M_TLV_RF_STATUS,
449 sizeof(*rfss))) {
450 rfss = container_of(tlv, typeof(*rfss), hdr);
451 d_printf(2, dev, "%s: RF status TLV "
452 "found (0x%04x), sw 0x%02x hw 0x%02x\n",
453 tag, I2400M_TLV_RF_STATUS,
454 le32_to_cpu(rfss->sw_rf_switch),
455 le32_to_cpu(rfss->hw_rf_switch));
456 i2400m_report_tlv_rf_switches_status(i2400m, rfss);
457 }
458 if (0 == i2400m_tlv_match(tlv, I2400M_TLV_MEDIA_STATUS,
459 sizeof(*ms))) {
460 ms = container_of(tlv, typeof(*ms), hdr);
461 d_printf(2, dev, "%s: Media Status TLV: %u\n",
462 tag, le32_to_cpu(ms->media_status));
463 i2400m_report_tlv_media_status(i2400m, ms);
464 }
465 }
466 d_fnend(4, dev, "(i2400m %p, l3l4_hdr %p, size %zu, %s) = void\n",
467 i2400m, l3l4_hdr, size, tag);
468}
469
470
471/*
472 * i2400m_report_hook - (maybe) act on a report
473 *
474 * @i2400m: device descriptor
475 * @l3l4_hdr: pointer to message; it has been already validated for
476 * consistent size.
477 * @size: size of the message (header + payload). The header length
478 * declaration is assumed to be congruent with @size (as in
479 * sizeof(*l3l4_hdr) + l3l4_hdr->length == size)
480 *
481 * Extract information we might need (like carrien on/off) from a
482 * device report.
483 */
484void i2400m_report_hook(struct i2400m *i2400m,
485 const struct i2400m_l3l4_hdr *l3l4_hdr, size_t size)
486{
487 struct device *dev = i2400m_dev(i2400m);
488 unsigned msg_type;
489
490 d_fnstart(3, dev, "(i2400m %p l3l4_hdr %p size %zu)\n",
491 i2400m, l3l4_hdr, size);
492 /* Chew on the message, we might need some information from
493 * here */
494 msg_type = le16_to_cpu(l3l4_hdr->type);
495 switch (msg_type) {
496 case I2400M_MT_REPORT_STATE: /* carrier detection... */
497 i2400m_report_state_hook(i2400m,
498 l3l4_hdr, size, "REPORT STATE");
499 break;
500 /* If the device is ready for power save, then ask it to do
501 * it. */
502 case I2400M_MT_REPORT_POWERSAVE_READY: /* zzzzz */
503 if (l3l4_hdr->status == cpu_to_le16(I2400M_MS_DONE_OK)) {
504 d_printf(1, dev, "ready for powersave, requesting\n");
505 i2400m_cmd_enter_powersave(i2400m);
506 }
507 break;
508 };
509 d_fnend(3, dev, "(i2400m %p l3l4_hdr %p size %zu) = void\n",
510 i2400m, l3l4_hdr, size);
511}
512
513
514/*
515 * i2400m_msg_ack_hook - process cmd/set/get ack for internal status
516 *
517 * @i2400m: device descriptor
518 * @l3l4_hdr: pointer to message; it has been already validated for
519 * consistent size.
520 * @size: size of the message
521 *
522 * Extract information we might need from acks to commands and act on
523 * it. This is akin to i2400m_report_hook(). Note most of this
524 * processing should be done in the function that calls the
525 * command. This is here for some cases where it can't happen...
526 */
527void i2400m_msg_ack_hook(struct i2400m *i2400m,
528 const struct i2400m_l3l4_hdr *l3l4_hdr, size_t size)
529{
530 int result;
531 struct device *dev = i2400m_dev(i2400m);
532 unsigned ack_type, ack_status;
533 char strerr[32];
534
535 /* Chew on the message, we might need some information from
536 * here */
537 ack_type = le16_to_cpu(l3l4_hdr->type);
538 ack_status = le16_to_cpu(l3l4_hdr->status);
539 switch (ack_type) {
540 case I2400M_MT_CMD_ENTER_POWERSAVE:
541 /* This is just left here for the sake of example, as
542 * the processing is done somewhere else. */
543 if (0) {
544 result = i2400m_msg_check_status(
545 l3l4_hdr, strerr, sizeof(strerr));
546 if (result >= 0)
547 d_printf(1, dev, "ready for power save: %zd\n",
548 size);
549 }
550 break;
551 };
552 return;
553}
554
555
556/*
557 * i2400m_msg_size_check() - verify message size and header are congruent
558 *
559 * It is ok if the total message size is larger than the expected
560 * size, as there can be padding.
561 */
562int i2400m_msg_size_check(struct i2400m *i2400m,
563 const struct i2400m_l3l4_hdr *l3l4_hdr,
564 size_t msg_size)
565{
566 int result;
567 struct device *dev = i2400m_dev(i2400m);
568 size_t expected_size;
569 d_fnstart(4, dev, "(i2400m %p l3l4_hdr %p msg_size %zu)\n",
570 i2400m, l3l4_hdr, msg_size);
571 if (msg_size < sizeof(*l3l4_hdr)) {
572 dev_err(dev, "bad size for message header "
573 "(expected at least %zu, got %zu)\n",
574 (size_t) sizeof(*l3l4_hdr), msg_size);
575 result = -EIO;
576 goto error_hdr_size;
577 }
578 expected_size = le16_to_cpu(l3l4_hdr->length) + sizeof(*l3l4_hdr);
579 if (msg_size < expected_size) {
580 dev_err(dev, "bad size for message code 0x%04x (expected %zu, "
581 "got %zu)\n", le16_to_cpu(l3l4_hdr->type),
582 expected_size, msg_size);
583 result = -EIO;
584 } else
585 result = 0;
586error_hdr_size:
587 d_fnend(4, dev,
588 "(i2400m %p l3l4_hdr %p msg_size %zu) = %d\n",
589 i2400m, l3l4_hdr, msg_size, result);
590 return result;
591}
592
593
594
595/*
596 * Cancel a wait for a command ACK
597 *
598 * @i2400m: device descriptor
599 * @code: [negative] errno code to cancel with (don't use
600 * -EINPROGRESS)
601 *
602 * If there is an ack already filled out, free it.
603 */
604void i2400m_msg_to_dev_cancel_wait(struct i2400m *i2400m, int code)
605{
606 struct sk_buff *ack_skb;
607 unsigned long flags;
608
609 spin_lock_irqsave(&i2400m->rx_lock, flags);
610 ack_skb = i2400m->ack_skb;
611 if (ack_skb && !IS_ERR(ack_skb))
612 kfree(ack_skb);
613 i2400m->ack_skb = ERR_PTR(code);
614 spin_unlock_irqrestore(&i2400m->rx_lock, flags);
615}
616
617
618/**
619 * i2400m_msg_to_dev - Send a control message to the device and get a response
620 *
621 * @i2400m: device descriptor
622 *
623 * @msg_skb: an skb *
624 *
625 * @buf: pointer to the buffer containing the message to be sent; it
626 * has to start with a &struct i2400M_l3l4_hdr and then
627 * followed by the payload. Once this function returns, the
628 * buffer can be reused.
629 *
630 * @buf_len: buffer size
631 *
632 * Returns:
633 *
634 * Pointer to skb containing the ack message. You need to check the
635 * pointer with IS_ERR(), as it might be an error code. Error codes
636 * could happen because:
637 *
638 * - the message wasn't formatted correctly
639 * - couldn't send the message
640 * - failed waiting for a response
641 * - the ack message wasn't formatted correctly
642 *
643 * The returned skb has been allocated with wimax_msg_to_user_alloc(),
644 * it contains the reponse in a netlink attribute and is ready to be
645 * passed up to user space with wimax_msg_to_user_send(). To access
646 * the payload and its length, use wimax_msg_{data,len}() on the skb.
647 *
648 * The skb has to be freed with kfree_skb() once done.
649 *
650 * Description:
651 *
652 * This function delivers a message/command to the device and waits
653 * for an ack to be received. The format is described in
654 * linux/wimax/i2400m.h. In summary, a command/get/set is followed by an
655 * ack.
656 *
657 * This function will not check the ack status, that's left up to the
658 * caller. Once done with the ack skb, it has to be kfree_skb()ed.
659 *
660 * The i2400m handles only one message at the same time, thus we need
661 * the mutex to exclude other players.
662 *
663 * We write the message and then wait for an answer to come back. The
664 * RX path intercepts control messages and handles them in
665 * i2400m_rx_ctl(). Reports (notifications) are (maybe) processed
666 * locally and then forwarded (as needed) to user space on the WiMAX
667 * stack message pipe. Acks are saved and passed back to us through an
668 * skb in i2400m->ack_skb which is ready to be given to generic
669 * netlink if need be.
670 */
671struct sk_buff *i2400m_msg_to_dev(struct i2400m *i2400m,
672 const void *buf, size_t buf_len)
673{
674 int result;
675 struct device *dev = i2400m_dev(i2400m);
676 const struct i2400m_l3l4_hdr *msg_l3l4_hdr;
677 struct sk_buff *ack_skb;
678 const struct i2400m_l3l4_hdr *ack_l3l4_hdr;
679 size_t ack_len;
680 int ack_timeout;
681 unsigned msg_type;
682 unsigned long flags;
683
684 d_fnstart(3, dev, "(i2400m %p buf %p len %zu)\n",
685 i2400m, buf, buf_len);
686
687 if (i2400m->boot_mode)
688 return ERR_PTR(-ENODEV);
689
690 msg_l3l4_hdr = buf;
691 /* Check msg & payload consistency */
692 result = i2400m_msg_size_check(i2400m, msg_l3l4_hdr, buf_len);
693 if (result < 0)
694 goto error_bad_msg;
695 msg_type = le16_to_cpu(msg_l3l4_hdr->type);
696 d_printf(1, dev, "CMD/GET/SET 0x%04x %zu bytes\n",
697 msg_type, buf_len);
698 d_dump(2, dev, buf, buf_len);
699
700 /* Setup the completion, ack_skb ("we are waiting") and send
701 * the message to the device */
702 mutex_lock(&i2400m->msg_mutex);
703 spin_lock_irqsave(&i2400m->rx_lock, flags);
704 i2400m->ack_skb = ERR_PTR(-EINPROGRESS);
705 spin_unlock_irqrestore(&i2400m->rx_lock, flags);
706 init_completion(&i2400m->msg_completion);
707 result = i2400m_tx(i2400m, buf, buf_len, I2400M_PT_CTRL);
708 if (result < 0) {
709 dev_err(dev, "can't send message 0x%04x: %d\n",
710 le16_to_cpu(msg_l3l4_hdr->type), result);
711 goto error_tx;
712 }
713
714 /* Some commands take longer to execute because of crypto ops,
715 * so we give them some more leeway on timeout */
716 switch (msg_type) {
717 case I2400M_MT_GET_TLS_OPERATION_RESULT:
718 case I2400M_MT_CMD_SEND_EAP_RESPONSE:
719 ack_timeout = 5 * HZ;
720 break;
721 default:
722 ack_timeout = HZ;
723 };
724
725 /* The RX path in rx.c will put any response for this message
726 * in i2400m->ack_skb and wake us up. If we cancel the wait,
727 * we need to change the value of i2400m->ack_skb to something
728 * not -EINPROGRESS so RX knows there is no one waiting. */
729 result = wait_for_completion_interruptible_timeout(
730 &i2400m->msg_completion, ack_timeout);
731 if (result == 0) {
732 dev_err(dev, "timeout waiting for reply to message 0x%04x\n",
733 msg_type);
734 result = -ETIMEDOUT;
735 i2400m_msg_to_dev_cancel_wait(i2400m, result);
736 goto error_wait_for_completion;
737 } else if (result < 0) {
738 dev_err(dev, "error waiting for reply to message 0x%04x: %d\n",
739 msg_type, result);
740 i2400m_msg_to_dev_cancel_wait(i2400m, result);
741 goto error_wait_for_completion;
742 }
743
744 /* Pull out the ack data from i2400m->ack_skb -- see if it is
745 * an error and act accordingly */
746 spin_lock_irqsave(&i2400m->rx_lock, flags);
747 ack_skb = i2400m->ack_skb;
748 if (IS_ERR(ack_skb))
749 result = PTR_ERR(ack_skb);
750 else
751 result = 0;
752 i2400m->ack_skb = NULL;
753 spin_unlock_irqrestore(&i2400m->rx_lock, flags);
754 if (result < 0)
755 goto error_ack_status;
756 ack_l3l4_hdr = wimax_msg_data_len(ack_skb, &ack_len);
757
758 /* Check the ack and deliver it if it is ok */
759 result = i2400m_msg_size_check(i2400m, ack_l3l4_hdr, ack_len);
760 if (result < 0) {
761 dev_err(dev, "HW BUG? reply to message 0x%04x: %d\n",
762 msg_type, result);
763 goto error_bad_ack_len;
764 }
765 if (msg_type != le16_to_cpu(ack_l3l4_hdr->type)) {
766 dev_err(dev, "HW BUG? bad reply 0x%04x to message 0x%04x\n",
767 le16_to_cpu(ack_l3l4_hdr->type), msg_type);
768 result = -EIO;
769 goto error_bad_ack_type;
770 }
771 i2400m_msg_ack_hook(i2400m, ack_l3l4_hdr, ack_len);
772 mutex_unlock(&i2400m->msg_mutex);
773 d_fnend(3, dev, "(i2400m %p buf %p len %zu) = %p\n",
774 i2400m, buf, buf_len, ack_skb);
775 return ack_skb;
776
777error_bad_ack_type:
778error_bad_ack_len:
779 kfree_skb(ack_skb);
780error_ack_status:
781error_wait_for_completion:
782error_tx:
783 mutex_unlock(&i2400m->msg_mutex);
784error_bad_msg:
785 d_fnend(3, dev, "(i2400m %p buf %p len %zu) = %d\n",
786 i2400m, buf, buf_len, result);
787 return ERR_PTR(result);
788}
789
790
791/*
792 * Definitions for the Enter Power Save command
793 *
794 * The Enter Power Save command requests the device to go into power
795 * saving mode. The device will ack or nak the command depending on it
796 * being ready for it. If it acks, we tell the USB subsystem to
797 *
798 * As well, the device might request to go into power saving mode by
799 * sending a report (REPORT_POWERSAVE_READY), in which case, we issue
800 * this command. The hookups in the RX coder allow
801 */
802enum {
803 I2400M_WAKEUP_ENABLED = 0x01,
804 I2400M_WAKEUP_DISABLED = 0x02,
805 I2400M_TLV_TYPE_WAKEUP_MODE = 144,
806};
807
808struct i2400m_cmd_enter_power_save {
809 struct i2400m_l3l4_hdr hdr;
810 struct i2400m_tlv_hdr tlv;
811 __le32 val;
812} __attribute__((packed));
813
814
815/*
816 * Request entering power save
817 *
818 * This command is (mainly) executed when the device indicates that it
819 * is ready to go into powersave mode via a REPORT_POWERSAVE_READY.
820 */
821int i2400m_cmd_enter_powersave(struct i2400m *i2400m)
822{
823 int result;
824 struct device *dev = i2400m_dev(i2400m);
825 struct sk_buff *ack_skb;
826 struct i2400m_cmd_enter_power_save *cmd;
827 char strerr[32];
828
829 result = -ENOMEM;
830 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
831 if (cmd == NULL)
832 goto error_alloc;
833 cmd->hdr.type = cpu_to_le16(I2400M_MT_CMD_ENTER_POWERSAVE);
834 cmd->hdr.length = cpu_to_le16(sizeof(*cmd) - sizeof(cmd->hdr));
835 cmd->hdr.version = cpu_to_le16(I2400M_L3L4_VERSION);
836 cmd->tlv.type = cpu_to_le16(I2400M_TLV_TYPE_WAKEUP_MODE);
837 cmd->tlv.length = cpu_to_le16(sizeof(cmd->val));
838 cmd->val = cpu_to_le32(I2400M_WAKEUP_ENABLED);
839
840 ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
841 result = PTR_ERR(ack_skb);
842 if (IS_ERR(ack_skb)) {
843 dev_err(dev, "Failed to issue 'Enter power save' command: %d\n",
844 result);
845 goto error_msg_to_dev;
846 }
847 result = i2400m_msg_check_status(wimax_msg_data(ack_skb),
848 strerr, sizeof(strerr));
849 if (result == -EACCES)
850 d_printf(1, dev, "Cannot enter power save mode\n");
851 else if (result < 0)
852 dev_err(dev, "'Enter power save' (0x%04x) command failed: "
853 "%d - %s\n", I2400M_MT_CMD_ENTER_POWERSAVE,
854 result, strerr);
855 else
856 d_printf(1, dev, "device ready to power save\n");
857 kfree_skb(ack_skb);
858error_msg_to_dev:
859 kfree(cmd);
860error_alloc:
861 return result;
862}
863EXPORT_SYMBOL_GPL(i2400m_cmd_enter_powersave);
864
865
866/*
867 * Definitions for getting device information
868 */
869enum {
870 I2400M_TLV_DETAILED_DEVICE_INFO = 140
871};
872
873/**
874 * i2400m_get_device_info - Query the device for detailed device information
875 *
876 * @i2400m: device descriptor
877 *
878 * Returns: an skb whose skb->data points to a 'struct
879 * i2400m_tlv_detailed_device_info'. When done, kfree_skb() it. The
880 * skb is *guaranteed* to contain the whole TLV data structure.
881 *
882 * On error, IS_ERR(skb) is true and ERR_PTR(skb) is the error
883 * code.
884 */
885struct sk_buff *i2400m_get_device_info(struct i2400m *i2400m)
886{
887 int result;
888 struct device *dev = i2400m_dev(i2400m);
889 struct sk_buff *ack_skb;
890 struct i2400m_l3l4_hdr *cmd;
891 const struct i2400m_l3l4_hdr *ack;
892 size_t ack_len;
893 const struct i2400m_tlv_hdr *tlv;
894 const struct i2400m_tlv_detailed_device_info *ddi;
895 char strerr[32];
896
897 ack_skb = ERR_PTR(-ENOMEM);
898 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
899 if (cmd == NULL)
900 goto error_alloc;
901 cmd->type = cpu_to_le16(I2400M_MT_GET_DEVICE_INFO);
902 cmd->length = 0;
903 cmd->version = cpu_to_le16(I2400M_L3L4_VERSION);
904
905 ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
906 if (IS_ERR(ack_skb)) {
907 dev_err(dev, "Failed to issue 'get device info' command: %ld\n",
908 PTR_ERR(ack_skb));
909 goto error_msg_to_dev;
910 }
911 ack = wimax_msg_data_len(ack_skb, &ack_len);
912 result = i2400m_msg_check_status(ack, strerr, sizeof(strerr));
913 if (result < 0) {
914 dev_err(dev, "'get device info' (0x%04x) command failed: "
915 "%d - %s\n", I2400M_MT_GET_DEVICE_INFO, result,
916 strerr);
917 goto error_cmd_failed;
918 }
919 tlv = i2400m_tlv_find(i2400m, ack->pl, ack_len - sizeof(*ack),
920 I2400M_TLV_DETAILED_DEVICE_INFO, sizeof(*ddi));
921 if (tlv == NULL) {
922 dev_err(dev, "GET DEVICE INFO: "
923 "detailed device info TLV not found (0x%04x)\n",
924 I2400M_TLV_DETAILED_DEVICE_INFO);
925 result = -EIO;
926 goto error_no_tlv;
927 }
928 skb_pull(ack_skb, (void *) tlv - (void *) ack_skb->data);
929error_msg_to_dev:
930 kfree(cmd);
931error_alloc:
932 return ack_skb;
933
934error_no_tlv:
935error_cmd_failed:
936 kfree_skb(ack_skb);
937 kfree(cmd);
938 return ERR_PTR(result);
939}
940
941
942/* Firmware interface versions we support */
943enum {
944 I2400M_HDIv_MAJOR = 9,
945 I2400M_HDIv_MAJOR_2 = 8,
946 I2400M_HDIv_MINOR = 1,
947};
948
949
950/**
951 * i2400m_firmware_check - check firmware versions are compatible with
952 * the driver
953 *
954 * @i2400m: device descriptor
955 *
956 * Returns: 0 if ok, < 0 errno code an error and a message in the
957 * kernel log.
958 *
959 * Long function, but quite simple; first chunk launches the command
960 * and double checks the reply for the right TLV. Then we process the
961 * TLV (where the meat is).
962 */
963int i2400m_firmware_check(struct i2400m *i2400m)
964{
965 int result;
966 struct device *dev = i2400m_dev(i2400m);
967 struct sk_buff *ack_skb;
968 struct i2400m_l3l4_hdr *cmd;
969 const struct i2400m_l3l4_hdr *ack;
970 size_t ack_len;
971 const struct i2400m_tlv_hdr *tlv;
972 const struct i2400m_tlv_l4_message_versions *l4mv;
973 char strerr[32];
974 unsigned major, minor, branch;
975
976 result = -ENOMEM;
977 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
978 if (cmd == NULL)
979 goto error_alloc;
980 cmd->type = cpu_to_le16(I2400M_MT_GET_LM_VERSION);
981 cmd->length = 0;
982 cmd->version = cpu_to_le16(I2400M_L3L4_VERSION);
983
984 ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
985 if (IS_ERR(ack_skb)) {
986 result = PTR_ERR(ack_skb);
987 dev_err(dev, "Failed to issue 'get lm version' command: %-d\n",
988 result);
989 goto error_msg_to_dev;
990 }
991 ack = wimax_msg_data_len(ack_skb, &ack_len);
992 result = i2400m_msg_check_status(ack, strerr, sizeof(strerr));
993 if (result < 0) {
994 dev_err(dev, "'get lm version' (0x%04x) command failed: "
995 "%d - %s\n", I2400M_MT_GET_LM_VERSION, result,
996 strerr);
997 goto error_cmd_failed;
998 }
999 tlv = i2400m_tlv_find(i2400m, ack->pl, ack_len - sizeof(*ack),
1000 I2400M_TLV_L4_MESSAGE_VERSIONS, sizeof(*l4mv));
1001 if (tlv == NULL) {
1002 dev_err(dev, "get lm version: TLV not found (0x%04x)\n",
1003 I2400M_TLV_L4_MESSAGE_VERSIONS);
1004 result = -EIO;
1005 goto error_no_tlv;
1006 }
1007 l4mv = container_of(tlv, typeof(*l4mv), hdr);
1008 major = le16_to_cpu(l4mv->major);
1009 minor = le16_to_cpu(l4mv->minor);
1010 branch = le16_to_cpu(l4mv->branch);
1011 result = -EINVAL;
1012 if (major != I2400M_HDIv_MAJOR
1013 && major != I2400M_HDIv_MAJOR_2) {
1014 dev_err(dev, "unsupported major fw interface version "
1015 "%u.%u.%u\n", major, minor, branch);
1016 goto error_bad_major;
1017 }
1018 if (major == I2400M_HDIv_MAJOR_2)
1019 dev_err(dev, "deprecated major fw interface version "
1020 "%u.%u.%u\n", major, minor, branch);
1021 result = 0;
1022 if (minor != I2400M_HDIv_MINOR)
1023 dev_warn(dev, "untested minor fw firmware version %u.%u.%u\n",
1024 major, minor, branch);
1025error_bad_major:
1026 dev_info(dev, "firmware interface version %u.%u.%u\n",
1027 major, minor, branch);
1028error_no_tlv:
1029error_cmd_failed:
1030 kfree_skb(ack_skb);
1031error_msg_to_dev:
1032 kfree(cmd);
1033error_alloc:
1034 return result;
1035}
1036
1037
1038/*
1039 * Send an DoExitIdle command to the device to ask it to go out of
1040 * basestation-idle mode.
1041 *
1042 * @i2400m: device descriptor
1043 *
1044 * This starts a renegotiation with the basestation that might involve
1045 * another crypto handshake with user space.
1046 *
1047 * Returns: 0 if ok, < 0 errno code on error.
1048 */
1049int i2400m_cmd_exit_idle(struct i2400m *i2400m)
1050{
1051 int result;
1052 struct device *dev = i2400m_dev(i2400m);
1053 struct sk_buff *ack_skb;
1054 struct i2400m_l3l4_hdr *cmd;
1055 char strerr[32];
1056
1057 result = -ENOMEM;
1058 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
1059 if (cmd == NULL)
1060 goto error_alloc;
1061 cmd->type = cpu_to_le16(I2400M_MT_CMD_EXIT_IDLE);
1062 cmd->length = 0;
1063 cmd->version = cpu_to_le16(I2400M_L3L4_VERSION);
1064
1065 ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
1066 result = PTR_ERR(ack_skb);
1067 if (IS_ERR(ack_skb)) {
1068 dev_err(dev, "Failed to issue 'exit idle' command: %d\n",
1069 result);
1070 goto error_msg_to_dev;
1071 }
1072 result = i2400m_msg_check_status(wimax_msg_data(ack_skb),
1073 strerr, sizeof(strerr));
1074 kfree_skb(ack_skb);
1075error_msg_to_dev:
1076 kfree(cmd);
1077error_alloc:
1078 return result;
1079
1080}
1081
1082
1083/*
1084 * Query the device for its state, update the WiMAX stack's idea of it
1085 *
1086 * @i2400m: device descriptor
1087 *
1088 * Returns: 0 if ok, < 0 errno code on error.
1089 *
1090 * Executes a 'Get State' command and parses the returned
1091 * TLVs.
1092 *
1093 * Because this is almost identical to a 'Report State', we use
1094 * i2400m_report_state_hook() to parse the answer. This will set the
1095 * carrier state, as well as the RF Kill switches state.
1096 */
1097int i2400m_cmd_get_state(struct i2400m *i2400m)
1098{
1099 int result;
1100 struct device *dev = i2400m_dev(i2400m);
1101 struct sk_buff *ack_skb;
1102 struct i2400m_l3l4_hdr *cmd;
1103 const struct i2400m_l3l4_hdr *ack;
1104 size_t ack_len;
1105 char strerr[32];
1106
1107 result = -ENOMEM;
1108 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
1109 if (cmd == NULL)
1110 goto error_alloc;
1111 cmd->type = cpu_to_le16(I2400M_MT_GET_STATE);
1112 cmd->length = 0;
1113 cmd->version = cpu_to_le16(I2400M_L3L4_VERSION);
1114
1115 ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
1116 if (IS_ERR(ack_skb)) {
1117 dev_err(dev, "Failed to issue 'get state' command: %ld\n",
1118 PTR_ERR(ack_skb));
1119 result = PTR_ERR(ack_skb);
1120 goto error_msg_to_dev;
1121 }
1122 ack = wimax_msg_data_len(ack_skb, &ack_len);
1123 result = i2400m_msg_check_status(ack, strerr, sizeof(strerr));
1124 if (result < 0) {
1125 dev_err(dev, "'get state' (0x%04x) command failed: "
1126 "%d - %s\n", I2400M_MT_GET_STATE, result, strerr);
1127 goto error_cmd_failed;
1128 }
1129 i2400m_report_state_hook(i2400m, ack, ack_len - sizeof(*ack),
1130 "GET STATE");
1131 result = 0;
1132 kfree_skb(ack_skb);
1133error_cmd_failed:
1134error_msg_to_dev:
1135 kfree(cmd);
1136error_alloc:
1137 return result;
1138}
1139EXPORT_SYMBOL_GPL(i2400m_cmd_get_state);
1140
1141
1142/**
1143 * Set basic configuration settings
1144 *
1145 * @i2400m: device descriptor
1146 * @args: array of pointers to the TLV headers to send for
1147 * configuration (each followed by its payload).
1148 * TLV headers and payloads must be properly initialized, with the
1149 * right endianess (LE).
1150 * @arg_size: number of pointers in the @args array
1151 */
1152int i2400m_set_init_config(struct i2400m *i2400m,
1153 const struct i2400m_tlv_hdr **arg, size_t args)
1154{
1155 int result;
1156 struct device *dev = i2400m_dev(i2400m);
1157 struct sk_buff *ack_skb;
1158 struct i2400m_l3l4_hdr *cmd;
1159 char strerr[32];
1160 unsigned argc, argsize, tlv_size;
1161 const struct i2400m_tlv_hdr *tlv_hdr;
1162 void *buf, *itr;
1163
1164 d_fnstart(3, dev, "(i2400m %p arg %p args %zu)\n", i2400m, arg, args);
1165 result = 0;
1166 if (args == 0)
1167 goto none;
1168 /* Compute the size of all the TLVs, so we can alloc a
1169 * contiguous command block to copy them. */
1170 argsize = 0;
1171 for (argc = 0; argc < args; argc++) {
1172 tlv_hdr = arg[argc];
1173 argsize += sizeof(*tlv_hdr) + le16_to_cpu(tlv_hdr->length);
1174 }
1175 WARN_ON(argc >= 9); /* As per hw spec */
1176
1177 /* Alloc the space for the command and TLVs*/
1178 result = -ENOMEM;
1179 buf = kzalloc(sizeof(*cmd) + argsize, GFP_KERNEL);
1180 if (buf == NULL)
1181 goto error_alloc;
1182 cmd = buf;
1183 cmd->type = cpu_to_le16(I2400M_MT_SET_INIT_CONFIG);
1184 cmd->length = cpu_to_le16(argsize);
1185 cmd->version = cpu_to_le16(I2400M_L3L4_VERSION);
1186
1187 /* Copy the TLVs */
1188 itr = buf + sizeof(*cmd);
1189 for (argc = 0; argc < args; argc++) {
1190 tlv_hdr = arg[argc];
1191 tlv_size = sizeof(*tlv_hdr) + le16_to_cpu(tlv_hdr->length);
1192 memcpy(itr, tlv_hdr, tlv_size);
1193 itr += tlv_size;
1194 }
1195
1196 /* Send the message! */
1197 ack_skb = i2400m_msg_to_dev(i2400m, buf, sizeof(*cmd) + argsize);
1198 result = PTR_ERR(ack_skb);
1199 if (IS_ERR(ack_skb)) {
1200 dev_err(dev, "Failed to issue 'init config' command: %d\n",
1201 result);
1202
1203 goto error_msg_to_dev;
1204 }
1205 result = i2400m_msg_check_status(wimax_msg_data(ack_skb),
1206 strerr, sizeof(strerr));
1207 if (result < 0)
1208 dev_err(dev, "'init config' (0x%04x) command failed: %d - %s\n",
1209 I2400M_MT_SET_INIT_CONFIG, result, strerr);
1210 kfree_skb(ack_skb);
1211error_msg_to_dev:
1212 kfree(buf);
1213error_alloc:
1214none:
1215 d_fnend(3, dev, "(i2400m %p arg %p args %zu) = %d\n",
1216 i2400m, arg, args, result);
1217 return result;
1218
1219}
1220EXPORT_SYMBOL_GPL(i2400m_set_init_config);
1221
1222
1223/**
1224 * i2400m_dev_initialize - Initialize the device once communications are ready
1225 *
1226 * @i2400m: device descriptor
1227 *
1228 * Returns: 0 if ok, < 0 errno code on error.
1229 *
1230 * Configures the device to work the way we like it.
1231 *
1232 * At the point of this call, the device is registered with the WiMAX
1233 * and netdev stacks, firmware is uploaded and we can talk to the
1234 * device normally.
1235 */
1236int i2400m_dev_initialize(struct i2400m *i2400m)
1237{
1238 int result;
1239 struct device *dev = i2400m_dev(i2400m);
1240 struct i2400m_tlv_config_idle_parameters idle_params;
1241 const struct i2400m_tlv_hdr *args[9];
1242 unsigned argc = 0;
1243
1244 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
1245 /* Useless for now...might change */
1246 if (i2400m_idle_mode_disabled) {
1247 idle_params.hdr.type =
1248 cpu_to_le16(I2400M_TLV_CONFIG_IDLE_PARAMETERS);
1249 idle_params.hdr.length = cpu_to_le16(
1250 sizeof(idle_params) - sizeof(idle_params.hdr));
1251 idle_params.idle_timeout = 0;
1252 idle_params.idle_paging_interval = 0;
1253 args[argc++] = &idle_params.hdr;
1254 }
1255 result = i2400m_set_init_config(i2400m, args, argc);
1256 if (result < 0)
1257 goto error;
1258 result = i2400m_firmware_check(i2400m); /* fw versions ok? */
1259 if (result < 0)
1260 goto error;
1261 /*
1262 * Update state: Here it just calls a get state; parsing the
1263 * result (System State TLV and RF Status TLV [done in the rx
1264 * path hooks]) will set the hardware and software RF-Kill
1265 * status.
1266 */
1267 result = i2400m_cmd_get_state(i2400m);
1268error:
1269 d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
1270 return result;
1271}
1272
1273
1274/**
1275 * i2400m_dev_shutdown - Shutdown a running device
1276 *
1277 * @i2400m: device descriptor
1278 *
1279 * Gracefully stops the device, moving it to the lowest power
1280 * consumption state possible.
1281 */
1282void i2400m_dev_shutdown(struct i2400m *i2400m)
1283{
1284 int result = -ENODEV;
1285 struct device *dev = i2400m_dev(i2400m);
1286
1287 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
1288 result = i2400m->bus_reset(i2400m, I2400M_RT_WARM);
1289 d_fnend(3, dev, "(i2400m %p) = void [%d]\n", i2400m, result);
1290 return;
1291}
diff --git a/drivers/net/wimax/i2400m/debug-levels.h b/drivers/net/wimax/i2400m/debug-levels.h
new file mode 100644
index 000000000000..3183baa16a52
--- /dev/null
+++ b/drivers/net/wimax/i2400m/debug-levels.h
@@ -0,0 +1,45 @@
1/*
2 * Intel Wireless WiMAX Connection 2400m
3 * Debug levels control file for the i2400m module
4 *
5 *
6 * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License version
11 * 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301, USA.
22 */
23#ifndef __debug_levels__h__
24#define __debug_levels__h__
25
26/* Maximum compile and run time debug level for all submodules */
27#define D_MODULENAME i2400m
28#define D_MASTER CONFIG_WIMAX_I2400M_DEBUG_LEVEL
29
30#include <linux/wimax/debug.h>
31
32/* List of all the enabled modules */
33enum d_module {
34 D_SUBMODULE_DECLARE(control),
35 D_SUBMODULE_DECLARE(driver),
36 D_SUBMODULE_DECLARE(debugfs),
37 D_SUBMODULE_DECLARE(fw),
38 D_SUBMODULE_DECLARE(netdev),
39 D_SUBMODULE_DECLARE(rfkill),
40 D_SUBMODULE_DECLARE(rx),
41 D_SUBMODULE_DECLARE(tx),
42};
43
44
45#endif /* #ifndef __debug_levels__h__ */
diff --git a/drivers/net/wimax/i2400m/debugfs.c b/drivers/net/wimax/i2400m/debugfs.c
new file mode 100644
index 000000000000..626632985977
--- /dev/null
+++ b/drivers/net/wimax/i2400m/debugfs.c
@@ -0,0 +1,392 @@
1/*
2 * Intel Wireless WiMAX Connection 2400m
3 * Debugfs interfaces to manipulate driver and device information
4 *
5 *
6 * Copyright (C) 2007 Intel Corporation <linux-wimax@intel.com>
7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License version
11 * 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301, USA.
22 */
23
24#include <linux/debugfs.h>
25#include <linux/netdevice.h>
26#include <linux/etherdevice.h>
27#include <linux/spinlock.h>
28#include <linux/device.h>
29#include "i2400m.h"
30
31
32#define D_SUBMODULE debugfs
33#include "debug-levels.h"
34
35static
36int debugfs_netdev_queue_stopped_get(void *data, u64 *val)
37{
38 struct i2400m *i2400m = data;
39 *val = netif_queue_stopped(i2400m->wimax_dev.net_dev);
40 return 0;
41}
42DEFINE_SIMPLE_ATTRIBUTE(fops_netdev_queue_stopped,
43 debugfs_netdev_queue_stopped_get,
44 NULL, "%llu\n");
45
46
47static
48struct dentry *debugfs_create_netdev_queue_stopped(
49 const char *name, struct dentry *parent, struct i2400m *i2400m)
50{
51 return debugfs_create_file(name, 0400, parent, i2400m,
52 &fops_netdev_queue_stopped);
53}
54
55
56/*
57 * inode->i_private has the @data argument to debugfs_create_file()
58 */
59static
60int i2400m_stats_open(struct inode *inode, struct file *filp)
61{
62 filp->private_data = inode->i_private;
63 return 0;
64}
65
66/*
67 * We don't allow partial reads of this file, as then the reader would
68 * get weirdly confused data as it is updated.
69 *
70 * So or you read it all or nothing; if you try to read with an offset
71 * != 0, we consider you are done reading.
72 */
73static
74ssize_t i2400m_rx_stats_read(struct file *filp, char __user *buffer,
75 size_t count, loff_t *ppos)
76{
77 struct i2400m *i2400m = filp->private_data;
78 char buf[128];
79 unsigned long flags;
80
81 if (*ppos != 0)
82 return 0;
83 if (count < sizeof(buf))
84 return -ENOSPC;
85 spin_lock_irqsave(&i2400m->rx_lock, flags);
86 snprintf(buf, sizeof(buf), "%u %u %u %u %u %u %u\n",
87 i2400m->rx_pl_num, i2400m->rx_pl_min,
88 i2400m->rx_pl_max, i2400m->rx_num,
89 i2400m->rx_size_acc,
90 i2400m->rx_size_min, i2400m->rx_size_max);
91 spin_unlock_irqrestore(&i2400m->rx_lock, flags);
92 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
93}
94
95
96/* Any write clears the stats */
97static
98ssize_t i2400m_rx_stats_write(struct file *filp, const char __user *buffer,
99 size_t count, loff_t *ppos)
100{
101 struct i2400m *i2400m = filp->private_data;
102 unsigned long flags;
103
104 spin_lock_irqsave(&i2400m->rx_lock, flags);
105 i2400m->rx_pl_num = 0;
106 i2400m->rx_pl_max = 0;
107 i2400m->rx_pl_min = UINT_MAX;
108 i2400m->rx_num = 0;
109 i2400m->rx_size_acc = 0;
110 i2400m->rx_size_min = UINT_MAX;
111 i2400m->rx_size_max = 0;
112 spin_unlock_irqrestore(&i2400m->rx_lock, flags);
113 return count;
114}
115
116static
117const struct file_operations i2400m_rx_stats_fops = {
118 .owner = THIS_MODULE,
119 .open = i2400m_stats_open,
120 .read = i2400m_rx_stats_read,
121 .write = i2400m_rx_stats_write,
122};
123
124
125/* See i2400m_rx_stats_read() */
126static
127ssize_t i2400m_tx_stats_read(struct file *filp, char __user *buffer,
128 size_t count, loff_t *ppos)
129{
130 struct i2400m *i2400m = filp->private_data;
131 char buf[128];
132 unsigned long flags;
133
134 if (*ppos != 0)
135 return 0;
136 if (count < sizeof(buf))
137 return -ENOSPC;
138 spin_lock_irqsave(&i2400m->tx_lock, flags);
139 snprintf(buf, sizeof(buf), "%u %u %u %u %u %u %u\n",
140 i2400m->tx_pl_num, i2400m->tx_pl_min,
141 i2400m->tx_pl_max, i2400m->tx_num,
142 i2400m->tx_size_acc,
143 i2400m->tx_size_min, i2400m->tx_size_max);
144 spin_unlock_irqrestore(&i2400m->tx_lock, flags);
145 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
146}
147
148/* Any write clears the stats */
149static
150ssize_t i2400m_tx_stats_write(struct file *filp, const char __user *buffer,
151 size_t count, loff_t *ppos)
152{
153 struct i2400m *i2400m = filp->private_data;
154 unsigned long flags;
155
156 spin_lock_irqsave(&i2400m->tx_lock, flags);
157 i2400m->tx_pl_num = 0;
158 i2400m->tx_pl_max = 0;
159 i2400m->tx_pl_min = UINT_MAX;
160 i2400m->tx_num = 0;
161 i2400m->tx_size_acc = 0;
162 i2400m->tx_size_min = UINT_MAX;
163 i2400m->tx_size_max = 0;
164 spin_unlock_irqrestore(&i2400m->tx_lock, flags);
165 return count;
166}
167
168static
169const struct file_operations i2400m_tx_stats_fops = {
170 .owner = THIS_MODULE,
171 .open = i2400m_stats_open,
172 .read = i2400m_tx_stats_read,
173 .write = i2400m_tx_stats_write,
174};
175
176
177/* Write 1 to ask the device to go into suspend */
178static
179int debugfs_i2400m_suspend_set(void *data, u64 val)
180{
181 int result;
182 struct i2400m *i2400m = data;
183 result = i2400m_cmd_enter_powersave(i2400m);
184 if (result >= 0)
185 result = 0;
186 return result;
187}
188DEFINE_SIMPLE_ATTRIBUTE(fops_i2400m_suspend,
189 NULL, debugfs_i2400m_suspend_set,
190 "%llu\n");
191
192static
193struct dentry *debugfs_create_i2400m_suspend(
194 const char *name, struct dentry *parent, struct i2400m *i2400m)
195{
196 return debugfs_create_file(name, 0200, parent, i2400m,
197 &fops_i2400m_suspend);
198}
199
200
201/*
202 * Reset the device
203 *
204 * Write 0 to ask the device to soft reset, 1 to cold reset, 2 to bus
205 * reset (as defined by enum i2400m_reset_type).
206 */
207static
208int debugfs_i2400m_reset_set(void *data, u64 val)
209{
210 int result;
211 struct i2400m *i2400m = data;
212 enum i2400m_reset_type rt = val;
213 switch(rt) {
214 case I2400M_RT_WARM:
215 case I2400M_RT_COLD:
216 case I2400M_RT_BUS:
217 result = i2400m->bus_reset(i2400m, rt);
218 if (result >= 0)
219 result = 0;
220 default:
221 result = -EINVAL;
222 }
223 return result;
224}
225DEFINE_SIMPLE_ATTRIBUTE(fops_i2400m_reset,
226 NULL, debugfs_i2400m_reset_set,
227 "%llu\n");
228
229static
230struct dentry *debugfs_create_i2400m_reset(
231 const char *name, struct dentry *parent, struct i2400m *i2400m)
232{
233 return debugfs_create_file(name, 0200, parent, i2400m,
234 &fops_i2400m_reset);
235}
236
237/*
238 * Debug levels control; see debug.h
239 */
240struct d_level D_LEVEL[] = {
241 D_SUBMODULE_DEFINE(control),
242 D_SUBMODULE_DEFINE(driver),
243 D_SUBMODULE_DEFINE(debugfs),
244 D_SUBMODULE_DEFINE(fw),
245 D_SUBMODULE_DEFINE(netdev),
246 D_SUBMODULE_DEFINE(rfkill),
247 D_SUBMODULE_DEFINE(rx),
248 D_SUBMODULE_DEFINE(tx),
249};
250size_t D_LEVEL_SIZE = ARRAY_SIZE(D_LEVEL);
251
252#define __debugfs_register(prefix, name, parent) \
253do { \
254 result = d_level_register_debugfs(prefix, name, parent); \
255 if (result < 0) \
256 goto error; \
257} while (0)
258
259
260int i2400m_debugfs_add(struct i2400m *i2400m)
261{
262 int result;
263 struct device *dev = i2400m_dev(i2400m);
264 struct dentry *dentry = i2400m->wimax_dev.debugfs_dentry;
265 struct dentry *fd;
266
267 dentry = debugfs_create_dir("i2400m", dentry);
268 result = PTR_ERR(dentry);
269 if (IS_ERR(dentry)) {
270 if (result == -ENODEV)
271 result = 0; /* No debugfs support */
272 goto error;
273 }
274 i2400m->debugfs_dentry = dentry;
275 __debugfs_register("dl_", control, dentry);
276 __debugfs_register("dl_", driver, dentry);
277 __debugfs_register("dl_", debugfs, dentry);
278 __debugfs_register("dl_", fw, dentry);
279 __debugfs_register("dl_", netdev, dentry);
280 __debugfs_register("dl_", rfkill, dentry);
281 __debugfs_register("dl_", rx, dentry);
282 __debugfs_register("dl_", tx, dentry);
283
284 fd = debugfs_create_size_t("tx_in", 0400, dentry,
285 &i2400m->tx_in);
286 result = PTR_ERR(fd);
287 if (IS_ERR(fd) && result != -ENODEV) {
288 dev_err(dev, "Can't create debugfs entry "
289 "tx_in: %d\n", result);
290 goto error;
291 }
292
293 fd = debugfs_create_size_t("tx_out", 0400, dentry,
294 &i2400m->tx_out);
295 result = PTR_ERR(fd);
296 if (IS_ERR(fd) && result != -ENODEV) {
297 dev_err(dev, "Can't create debugfs entry "
298 "tx_out: %d\n", result);
299 goto error;
300 }
301
302 fd = debugfs_create_u32("state", 0600, dentry,
303 &i2400m->state);
304 result = PTR_ERR(fd);
305 if (IS_ERR(fd) && result != -ENODEV) {
306 dev_err(dev, "Can't create debugfs entry "
307 "state: %d\n", result);
308 goto error;
309 }
310
311 /*
312 * Trace received messages from user space
313 *
314 * In order to tap the bidirectional message stream in the
315 * 'msg' pipe, user space can read from the 'msg' pipe;
316 * however, due to limitations in libnl, we can't know what
317 * the different applications are sending down to the kernel.
318 *
319 * So we have this hack where the driver will echo any message
320 * received on the msg pipe from user space [through a call to
321 * wimax_dev->op_msg_from_user() into
322 * i2400m_op_msg_from_user()] into the 'trace' pipe that this
323 * driver creates.
324 *
325 * So then, reading from both the 'trace' and 'msg' pipes in
326 * user space will provide a full dump of the traffic.
327 *
328 * Write 1 to activate, 0 to clear.
329 *
330 * It is not really very atomic, but it is also not too
331 * critical.
332 */
333 fd = debugfs_create_u8("trace_msg_from_user", 0600, dentry,
334 &i2400m->trace_msg_from_user);
335 result = PTR_ERR(fd);
336 if (IS_ERR(fd) && result != -ENODEV) {
337 dev_err(dev, "Can't create debugfs entry "
338 "trace_msg_from_user: %d\n", result);
339 goto error;
340 }
341
342 fd = debugfs_create_netdev_queue_stopped("netdev_queue_stopped",
343 dentry, i2400m);
344 result = PTR_ERR(fd);
345 if (IS_ERR(fd) && result != -ENODEV) {
346 dev_err(dev, "Can't create debugfs entry "
347 "netdev_queue_stopped: %d\n", result);
348 goto error;
349 }
350
351 fd = debugfs_create_file("rx_stats", 0600, dentry, i2400m,
352 &i2400m_rx_stats_fops);
353 result = PTR_ERR(fd);
354 if (IS_ERR(fd) && result != -ENODEV) {
355 dev_err(dev, "Can't create debugfs entry "
356 "rx_stats: %d\n", result);
357 goto error;
358 }
359
360 fd = debugfs_create_file("tx_stats", 0600, dentry, i2400m,
361 &i2400m_tx_stats_fops);
362 result = PTR_ERR(fd);
363 if (IS_ERR(fd) && result != -ENODEV) {
364 dev_err(dev, "Can't create debugfs entry "
365 "tx_stats: %d\n", result);
366 goto error;
367 }
368
369 fd = debugfs_create_i2400m_suspend("suspend", dentry, i2400m);
370 result = PTR_ERR(fd);
371 if (IS_ERR(fd) && result != -ENODEV) {
372 dev_err(dev, "Can't create debugfs entry suspend: %d\n",
373 result);
374 goto error;
375 }
376
377 fd = debugfs_create_i2400m_reset("reset", dentry, i2400m);
378 result = PTR_ERR(fd);
379 if (IS_ERR(fd) && result != -ENODEV) {
380 dev_err(dev, "Can't create debugfs entry reset: %d\n", result);
381 goto error;
382 }
383
384 result = 0;
385error:
386 return result;
387}
388
389void i2400m_debugfs_rm(struct i2400m *i2400m)
390{
391 debugfs_remove_recursive(i2400m->debugfs_dentry);
392}
diff --git a/drivers/net/wimax/i2400m/driver.c b/drivers/net/wimax/i2400m/driver.c
new file mode 100644
index 000000000000..5f98047e18cf
--- /dev/null
+++ b/drivers/net/wimax/i2400m/driver.c
@@ -0,0 +1,728 @@
1/*
2 * Intel Wireless WiMAX Connection 2400m
3 * Generic probe/disconnect, reset and message passing
4 *
5 *
6 * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License version
11 * 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301, USA.
22 *
23 *
24 * See i2400m.h for driver documentation. This contains helpers for
25 * the driver model glue [_setup()/_release()], handling device resets
26 * [_dev_reset_handle()], and the backends for the WiMAX stack ops
27 * reset [_op_reset()] and message from user [_op_msg_from_user()].
28 *
29 * ROADMAP:
30 *
31 * i2400m_op_msg_from_user()
32 * i2400m_msg_to_dev()
33 * wimax_msg_to_user_send()
34 *
35 * i2400m_op_reset()
36 * i240m->bus_reset()
37 *
38 * i2400m_dev_reset_handle()
39 * __i2400m_dev_reset_handle()
40 * __i2400m_dev_stop()
41 * __i2400m_dev_start()
42 *
43 * i2400m_setup()
44 * i2400m_bootrom_init()
45 * register_netdev()
46 * i2400m_dev_start()
47 * __i2400m_dev_start()
48 * i2400m_dev_bootstrap()
49 * i2400m_tx_setup()
50 * i2400m->bus_dev_start()
51 * i2400m_check_mac_addr()
52 * wimax_dev_add()
53 *
54 * i2400m_release()
55 * wimax_dev_rm()
56 * i2400m_dev_stop()
57 * __i2400m_dev_stop()
58 * i2400m_dev_shutdown()
59 * i2400m->bus_dev_stop()
60 * i2400m_tx_release()
61 * unregister_netdev()
62 */
63#include "i2400m.h"
64#include <linux/wimax/i2400m.h>
65#include <linux/module.h>
66#include <linux/moduleparam.h>
67
68#define D_SUBMODULE driver
69#include "debug-levels.h"
70
71
72int i2400m_idle_mode_disabled; /* 0 (idle mode enabled) by default */
73module_param_named(idle_mode_disabled, i2400m_idle_mode_disabled, int, 0644);
74MODULE_PARM_DESC(idle_mode_disabled,
75 "If true, the device will not enable idle mode negotiation "
76 "with the base station (when connected) to save power.");
77
78/**
79 * i2400m_queue_work - schedule work on a i2400m's queue
80 *
81 * @i2400m: device descriptor
82 *
83 * @fn: function to run to execute work. It gets passed a 'struct
84 * work_struct' that is wrapped in a 'struct i2400m_work'. Once
85 * done, you have to (1) i2400m_put(i2400m_work->i2400m) and then
86 * (2) kfree(i2400m_work).
87 *
88 * @gfp_flags: GFP flags for memory allocation.
89 *
90 * @pl: pointer to a payload buffer that you want to pass to the _work
91 * function. Use this to pack (for example) a struct with extra
92 * arguments.
93 *
94 * @pl_size: size of the payload buffer.
95 *
96 * We do this quite often, so this just saves typing; allocate a
97 * wrapper for a i2400m, get a ref to it, pack arguments and launch
98 * the work.
99 *
100 * A usual workflow is:
101 *
102 * struct my_work_args {
103 * void *something;
104 * int whatever;
105 * };
106 * ...
107 *
108 * struct my_work_args my_args = {
109 * .something = FOO,
110 * .whaetever = BLAH
111 * };
112 * i2400m_queue_work(i2400m, 1, my_work_function, GFP_KERNEL,
113 * &args, sizeof(args))
114 *
115 * And now the work function can unpack the arguments and call the
116 * real function (or do the job itself):
117 *
118 * static
119 * void my_work_fn((struct work_struct *ws)
120 * {
121 * struct i2400m_work *iw =
122 * container_of(ws, struct i2400m_work, ws);
123 * struct my_work_args *my_args = (void *) iw->pl;
124 *
125 * my_work(iw->i2400m, my_args->something, my_args->whatevert);
126 * }
127 */
128int i2400m_queue_work(struct i2400m *i2400m,
129 void (*fn)(struct work_struct *), gfp_t gfp_flags,
130 const void *pl, size_t pl_size)
131{
132 int result;
133 struct i2400m_work *iw;
134
135 BUG_ON(i2400m->work_queue == NULL);
136 result = -ENOMEM;
137 iw = kzalloc(sizeof(*iw) + pl_size, gfp_flags);
138 if (iw == NULL)
139 goto error_kzalloc;
140 iw->i2400m = i2400m_get(i2400m);
141 memcpy(iw->pl, pl, pl_size);
142 INIT_WORK(&iw->ws, fn);
143 result = queue_work(i2400m->work_queue, &iw->ws);
144error_kzalloc:
145 return result;
146}
147EXPORT_SYMBOL_GPL(i2400m_queue_work);
148
149
150/*
151 * Schedule i2400m's specific work on the system's queue.
152 *
153 * Used for a few cases where we really need it; otherwise, identical
154 * to i2400m_queue_work().
155 *
156 * Returns < 0 errno code on error, 1 if ok.
157 *
158 * If it returns zero, something really bad happened, as it means the
159 * works struct was already queued, but we have just allocated it, so
160 * it should not happen.
161 */
162int i2400m_schedule_work(struct i2400m *i2400m,
163 void (*fn)(struct work_struct *), gfp_t gfp_flags)
164{
165 int result;
166 struct i2400m_work *iw;
167
168 BUG_ON(i2400m->work_queue == NULL);
169 result = -ENOMEM;
170 iw = kzalloc(sizeof(*iw), gfp_flags);
171 if (iw == NULL)
172 goto error_kzalloc;
173 iw->i2400m = i2400m_get(i2400m);
174 INIT_WORK(&iw->ws, fn);
175 result = schedule_work(&iw->ws);
176 if (result == 0)
177 result = -ENXIO;
178error_kzalloc:
179 return result;
180}
181
182
183/*
184 * WiMAX stack operation: relay a message from user space
185 *
186 * @wimax_dev: device descriptor
187 * @pipe_name: named pipe the message is for
188 * @msg_buf: pointer to the message bytes
189 * @msg_len: length of the buffer
190 * @genl_info: passed by the generic netlink layer
191 *
192 * The WiMAX stack will call this function when a message was received
193 * from user space.
194 *
195 * For the i2400m, this is an L3L4 message, as specified in
196 * include/linux/wimax/i2400m.h, and thus prefixed with a 'struct
197 * i2400m_l3l4_hdr'. Driver (and device) expect the messages to be
198 * coded in Little Endian.
199 *
200 * This function just verifies that the header declaration and the
201 * payload are consistent and then deals with it, either forwarding it
202 * to the device or procesing it locally.
203 *
204 * In the i2400m, messages are basically commands that will carry an
205 * ack, so we use i2400m_msg_to_dev() and then deliver the ack back to
206 * user space. The rx.c code might intercept the response and use it
207 * to update the driver's state, but then it will pass it on so it can
208 * be relayed back to user space.
209 *
210 * Note that asynchronous events from the device are processed and
211 * sent to user space in rx.c.
212 */
213static
214int i2400m_op_msg_from_user(struct wimax_dev *wimax_dev,
215 const char *pipe_name,
216 const void *msg_buf, size_t msg_len,
217 const struct genl_info *genl_info)
218{
219 int result;
220 struct i2400m *i2400m = wimax_dev_to_i2400m(wimax_dev);
221 struct device *dev = i2400m_dev(i2400m);
222 struct sk_buff *ack_skb;
223
224 d_fnstart(4, dev, "(wimax_dev %p [i2400m %p] msg_buf %p "
225 "msg_len %zu genl_info %p)\n", wimax_dev, i2400m,
226 msg_buf, msg_len, genl_info);
227 ack_skb = i2400m_msg_to_dev(i2400m, msg_buf, msg_len);
228 result = PTR_ERR(ack_skb);
229 if (IS_ERR(ack_skb))
230 goto error_msg_to_dev;
231 if (unlikely(i2400m->trace_msg_from_user))
232 wimax_msg(&i2400m->wimax_dev, "trace",
233 msg_buf, msg_len, GFP_KERNEL);
234 result = wimax_msg_send(&i2400m->wimax_dev, ack_skb);
235error_msg_to_dev:
236 d_fnend(4, dev, "(wimax_dev %p [i2400m %p] msg_buf %p msg_len %zu "
237 "genl_info %p) = %d\n", wimax_dev, i2400m, msg_buf, msg_len,
238 genl_info, result);
239 return result;
240}
241
242
243/*
244 * Context to wait for a reset to finalize
245 */
246struct i2400m_reset_ctx {
247 struct completion completion;
248 int result;
249};
250
251
252/*
253 * WiMAX stack operation: reset a device
254 *
255 * @wimax_dev: device descriptor
256 *
257 * See the documentation for wimax_reset() and wimax_dev->op_reset for
258 * the requirements of this function. The WiMAX stack guarantees
259 * serialization on calls to this function.
260 *
261 * Do a warm reset on the device; if it fails, resort to a cold reset
262 * and return -ENODEV. On successful warm reset, we need to block
263 * until it is complete.
264 *
265 * The bus-driver implementation of reset takes care of falling back
266 * to cold reset if warm fails.
267 */
268static
269int i2400m_op_reset(struct wimax_dev *wimax_dev)
270{
271 int result;
272 struct i2400m *i2400m = wimax_dev_to_i2400m(wimax_dev);
273 struct device *dev = i2400m_dev(i2400m);
274 struct i2400m_reset_ctx ctx = {
275 .completion = COMPLETION_INITIALIZER_ONSTACK(ctx.completion),
276 .result = 0,
277 };
278
279 d_fnstart(4, dev, "(wimax_dev %p)\n", wimax_dev);
280 mutex_lock(&i2400m->init_mutex);
281 i2400m->reset_ctx = &ctx;
282 mutex_unlock(&i2400m->init_mutex);
283 result = i2400m->bus_reset(i2400m, I2400M_RT_WARM);
284 if (result < 0)
285 goto out;
286 result = wait_for_completion_timeout(&ctx.completion, 4*HZ);
287 if (result == 0)
288 result = -ETIMEDOUT;
289 else if (result > 0)
290 result = ctx.result;
291 /* if result < 0, pass it on */
292 mutex_lock(&i2400m->init_mutex);
293 i2400m->reset_ctx = NULL;
294 mutex_unlock(&i2400m->init_mutex);
295out:
296 d_fnend(4, dev, "(wimax_dev %p) = %d\n", wimax_dev, result);
297 return result;
298}
299
300
301/*
302 * Check the MAC address we got from boot mode is ok
303 *
304 * @i2400m: device descriptor
305 *
306 * Returns: 0 if ok, < 0 errno code on error.
307 */
308static
309int i2400m_check_mac_addr(struct i2400m *i2400m)
310{
311 int result;
312 struct device *dev = i2400m_dev(i2400m);
313 struct sk_buff *skb;
314 const struct i2400m_tlv_detailed_device_info *ddi;
315 struct net_device *net_dev = i2400m->wimax_dev.net_dev;
316 const unsigned char zeromac[ETH_ALEN] = { 0 };
317
318 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
319 skb = i2400m_get_device_info(i2400m);
320 if (IS_ERR(skb)) {
321 result = PTR_ERR(skb);
322 dev_err(dev, "Cannot verify MAC address, error reading: %d\n",
323 result);
324 goto error;
325 }
326 /* Extract MAC addresss */
327 ddi = (void *) skb->data;
328 BUILD_BUG_ON(ETH_ALEN != sizeof(ddi->mac_address));
329 d_printf(2, dev, "GET DEVICE INFO: mac addr "
330 "%02x:%02x:%02x:%02x:%02x:%02x\n",
331 ddi->mac_address[0], ddi->mac_address[1],
332 ddi->mac_address[2], ddi->mac_address[3],
333 ddi->mac_address[4], ddi->mac_address[5]);
334 if (!memcmp(net_dev->perm_addr, ddi->mac_address,
335 sizeof(ddi->mac_address)))
336 goto ok;
337 dev_warn(dev, "warning: device reports a different MAC address "
338 "to that of boot mode's\n");
339 dev_warn(dev, "device reports %02x:%02x:%02x:%02x:%02x:%02x\n",
340 ddi->mac_address[0], ddi->mac_address[1],
341 ddi->mac_address[2], ddi->mac_address[3],
342 ddi->mac_address[4], ddi->mac_address[5]);
343 dev_warn(dev, "boot mode reported %02x:%02x:%02x:%02x:%02x:%02x\n",
344 net_dev->perm_addr[0], net_dev->perm_addr[1],
345 net_dev->perm_addr[2], net_dev->perm_addr[3],
346 net_dev->perm_addr[4], net_dev->perm_addr[5]);
347 if (!memcmp(zeromac, ddi->mac_address, sizeof(zeromac)))
348 dev_err(dev, "device reports an invalid MAC address, "
349 "not updating\n");
350 else {
351 dev_warn(dev, "updating MAC address\n");
352 net_dev->addr_len = ETH_ALEN;
353 memcpy(net_dev->perm_addr, ddi->mac_address, ETH_ALEN);
354 memcpy(net_dev->dev_addr, ddi->mac_address, ETH_ALEN);
355 }
356ok:
357 result = 0;
358 kfree_skb(skb);
359error:
360 d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
361 return result;
362}
363
364
365/**
366 * __i2400m_dev_start - Bring up driver communication with the device
367 *
368 * @i2400m: device descriptor
369 * @flags: boot mode flags
370 *
371 * Returns: 0 if ok, < 0 errno code on error.
372 *
373 * Uploads firmware and brings up all the resources needed to be able
374 * to communicate with the device.
375 *
376 * TX needs to be setup before the bus-specific code (otherwise on
377 * shutdown, the bus-tx code could try to access it).
378 */
379static
380int __i2400m_dev_start(struct i2400m *i2400m, enum i2400m_bri flags)
381{
382 int result;
383 struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
384 struct net_device *net_dev = wimax_dev->net_dev;
385 struct device *dev = i2400m_dev(i2400m);
386 int times = 3;
387
388 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
389retry:
390 result = i2400m_dev_bootstrap(i2400m, flags);
391 if (result < 0) {
392 dev_err(dev, "cannot bootstrap device: %d\n", result);
393 goto error_bootstrap;
394 }
395 result = i2400m_tx_setup(i2400m);
396 if (result < 0)
397 goto error_tx_setup;
398 result = i2400m->bus_dev_start(i2400m);
399 if (result < 0)
400 goto error_bus_dev_start;
401 i2400m->work_queue = create_singlethread_workqueue(wimax_dev->name);
402 if (i2400m->work_queue == NULL) {
403 result = -ENOMEM;
404 dev_err(dev, "cannot create workqueue\n");
405 goto error_create_workqueue;
406 }
407 /* At this point is ok to send commands to the device */
408 result = i2400m_check_mac_addr(i2400m);
409 if (result < 0)
410 goto error_check_mac_addr;
411 i2400m->ready = 1;
412 wimax_state_change(wimax_dev, WIMAX_ST_UNINITIALIZED);
413 result = i2400m_dev_initialize(i2400m);
414 if (result < 0)
415 goto error_dev_initialize;
416 /* At this point, reports will come for the device and set it
417 * to the right state if it is different than UNINITIALIZED */
418 d_fnend(3, dev, "(net_dev %p [i2400m %p]) = %d\n",
419 net_dev, i2400m, result);
420 return result;
421
422error_dev_initialize:
423error_check_mac_addr:
424 destroy_workqueue(i2400m->work_queue);
425error_create_workqueue:
426 i2400m->bus_dev_stop(i2400m);
427error_bus_dev_start:
428 i2400m_tx_release(i2400m);
429error_tx_setup:
430error_bootstrap:
431 if (result == -ERESTARTSYS && times-- > 0) {
432 flags = I2400M_BRI_SOFT;
433 goto retry;
434 }
435 d_fnend(3, dev, "(net_dev %p [i2400m %p]) = %d\n",
436 net_dev, i2400m, result);
437 return result;
438}
439
440
441static
442int i2400m_dev_start(struct i2400m *i2400m, enum i2400m_bri bm_flags)
443{
444 int result;
445 mutex_lock(&i2400m->init_mutex); /* Well, start the device */
446 result = __i2400m_dev_start(i2400m, bm_flags);
447 if (result >= 0)
448 i2400m->updown = 1;
449 mutex_unlock(&i2400m->init_mutex);
450 return result;
451}
452
453
454/**
455 * i2400m_dev_stop - Tear down driver communication with the device
456 *
457 * @i2400m: device descriptor
458 *
459 * Returns: 0 if ok, < 0 errno code on error.
460 *
461 * Releases all the resources allocated to communicate with the device.
462 */
463static
464void __i2400m_dev_stop(struct i2400m *i2400m)
465{
466 struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
467 struct device *dev = i2400m_dev(i2400m);
468
469 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
470 wimax_state_change(wimax_dev, __WIMAX_ST_QUIESCING);
471 i2400m_dev_shutdown(i2400m);
472 i2400m->ready = 0;
473 destroy_workqueue(i2400m->work_queue);
474 i2400m->bus_dev_stop(i2400m);
475 i2400m_tx_release(i2400m);
476 wimax_state_change(wimax_dev, WIMAX_ST_DOWN);
477 d_fnend(3, dev, "(i2400m %p) = 0\n", i2400m);
478}
479
480
481/*
482 * Watch out -- we only need to stop if there is a need for it. The
483 * device could have reset itself and failed to come up again (see
484 * _i2400m_dev_reset_handle()).
485 */
486static
487void i2400m_dev_stop(struct i2400m *i2400m)
488{
489 mutex_lock(&i2400m->init_mutex);
490 if (i2400m->updown) {
491 __i2400m_dev_stop(i2400m);
492 i2400m->updown = 0;
493 }
494 mutex_unlock(&i2400m->init_mutex);
495}
496
497
498/*
499 * The device has rebooted; fix up the device and the driver
500 *
501 * Tear down the driver communication with the device, reload the
502 * firmware and reinitialize the communication with the device.
503 *
504 * If someone calls a reset when the device's firmware is down, in
505 * theory we won't see it because we are not listening. However, just
506 * in case, leave the code to handle it.
507 *
508 * If there is a reset context, use it; this means someone is waiting
509 * for us to tell him when the reset operation is complete and the
510 * device is ready to rock again.
511 *
512 * NOTE: if we are in the process of bringing up or down the
513 * communication with the device [running i2400m_dev_start() or
514 * _stop()], don't do anything, let it fail and handle it.
515 *
516 * This function is ran always in a thread context
517 */
518static
519void __i2400m_dev_reset_handle(struct work_struct *ws)
520{
521 int result;
522 struct i2400m_work *iw = container_of(ws, struct i2400m_work, ws);
523 struct i2400m *i2400m = iw->i2400m;
524 struct device *dev = i2400m_dev(i2400m);
525 enum wimax_st wimax_state;
526 struct i2400m_reset_ctx *ctx = i2400m->reset_ctx;
527
528 d_fnstart(3, dev, "(ws %p i2400m %p)\n", ws, i2400m);
529 result = 0;
530 if (mutex_trylock(&i2400m->init_mutex) == 0) {
531 /* We are still in i2400m_dev_start() [let it fail] or
532 * i2400m_dev_stop() [we are shutting down anyway, so
533 * ignore it] or we are resetting somewhere else. */
534 dev_err(dev, "device rebooted\n");
535 i2400m_msg_to_dev_cancel_wait(i2400m, -ERESTARTSYS);
536 complete(&i2400m->msg_completion);
537 goto out;
538 }
539 wimax_state = wimax_state_get(&i2400m->wimax_dev);
540 if (wimax_state < WIMAX_ST_UNINITIALIZED) {
541 dev_info(dev, "device rebooted: it is down, ignoring\n");
542 goto out_unlock; /* ifconfig up/down wasn't called */
543 }
544 dev_err(dev, "device rebooted: reinitializing driver\n");
545 __i2400m_dev_stop(i2400m);
546 i2400m->updown = 0;
547 result = __i2400m_dev_start(i2400m,
548 I2400M_BRI_SOFT | I2400M_BRI_MAC_REINIT);
549 if (result < 0) {
550 dev_err(dev, "device reboot: cannot start the device: %d\n",
551 result);
552 result = i2400m->bus_reset(i2400m, I2400M_RT_BUS);
553 if (result >= 0)
554 result = -ENODEV;
555 } else
556 i2400m->updown = 1;
557out_unlock:
558 if (i2400m->reset_ctx) {
559 ctx->result = result;
560 complete(&ctx->completion);
561 }
562 mutex_unlock(&i2400m->init_mutex);
563out:
564 i2400m_put(i2400m);
565 kfree(iw);
566 d_fnend(3, dev, "(ws %p i2400m %p) = void\n", ws, i2400m);
567 return;
568}
569
570
571/**
572 * i2400m_dev_reset_handle - Handle a device's reset in a thread context
573 *
574 * Schedule a device reset handling out on a thread context, so it
575 * is safe to call from atomic context. We can't use the i2400m's
576 * queue as we are going to destroy it and reinitialize it as part of
577 * the driver bringup/bringup process.
578 *
579 * See __i2400m_dev_reset_handle() for details; that takes care of
580 * reinitializing the driver to handle the reset, calling into the
581 * bus-specific functions ops as needed.
582 */
583int i2400m_dev_reset_handle(struct i2400m *i2400m)
584{
585 return i2400m_schedule_work(i2400m, __i2400m_dev_reset_handle,
586 GFP_ATOMIC);
587}
588EXPORT_SYMBOL_GPL(i2400m_dev_reset_handle);
589
590
591/**
592 * i2400m_setup - bus-generic setup function for the i2400m device
593 *
594 * @i2400m: device descriptor (bus-specific parts have been initialized)
595 *
596 * Returns: 0 if ok, < 0 errno code on error.
597 *
598 * Initializes the bus-generic parts of the i2400m driver; the
599 * bus-specific parts have been initialized, function pointers filled
600 * out by the bus-specific probe function.
601 *
602 * As well, this registers the WiMAX and net device nodes. Once this
603 * function returns, the device is operative and has to be ready to
604 * receive and send network traffic and WiMAX control operations.
605 */
606int i2400m_setup(struct i2400m *i2400m, enum i2400m_bri bm_flags)
607{
608 int result = -ENODEV;
609 struct device *dev = i2400m_dev(i2400m);
610 struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
611 struct net_device *net_dev = i2400m->wimax_dev.net_dev;
612
613 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
614
615 snprintf(wimax_dev->name, sizeof(wimax_dev->name),
616 "i2400m-%s:%s", dev->bus->name, dev->bus_id);
617
618 i2400m->bm_cmd_buf = kzalloc(I2400M_BM_CMD_BUF_SIZE, GFP_KERNEL);
619 if (i2400m->bm_cmd_buf == NULL) {
620 dev_err(dev, "cannot allocate USB command buffer\n");
621 goto error_bm_cmd_kzalloc;
622 }
623 i2400m->bm_ack_buf = kzalloc(I2400M_BM_ACK_BUF_SIZE, GFP_KERNEL);
624 if (i2400m->bm_ack_buf == NULL) {
625 dev_err(dev, "cannot allocate USB ack buffer\n");
626 goto error_bm_ack_buf_kzalloc;
627 }
628 result = i2400m_bootrom_init(i2400m, bm_flags);
629 if (result < 0) {
630 dev_err(dev, "read mac addr: bootrom init "
631 "failed: %d\n", result);
632 goto error_bootrom_init;
633 }
634 result = i2400m_read_mac_addr(i2400m);
635 if (result < 0)
636 goto error_read_mac_addr;
637
638 result = register_netdev(net_dev); /* Okey dokey, bring it up */
639 if (result < 0) {
640 dev_err(dev, "cannot register i2400m network device: %d\n",
641 result);
642 goto error_register_netdev;
643 }
644 netif_carrier_off(net_dev);
645
646 result = i2400m_dev_start(i2400m, bm_flags);
647 if (result < 0)
648 goto error_dev_start;
649
650 i2400m->wimax_dev.op_msg_from_user = i2400m_op_msg_from_user;
651 i2400m->wimax_dev.op_rfkill_sw_toggle = i2400m_op_rfkill_sw_toggle;
652 i2400m->wimax_dev.op_reset = i2400m_op_reset;
653 result = wimax_dev_add(&i2400m->wimax_dev, net_dev);
654 if (result < 0)
655 goto error_wimax_dev_add;
656 /* User space needs to do some init stuff */
657 wimax_state_change(wimax_dev, WIMAX_ST_UNINITIALIZED);
658
659 /* Now setup all that requires a registered net and wimax device. */
660 result = i2400m_debugfs_add(i2400m);
661 if (result < 0) {
662 dev_err(dev, "cannot setup i2400m's debugfs: %d\n", result);
663 goto error_debugfs_setup;
664 }
665 d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
666 return result;
667
668error_debugfs_setup:
669 wimax_dev_rm(&i2400m->wimax_dev);
670error_wimax_dev_add:
671 i2400m_dev_stop(i2400m);
672error_dev_start:
673 unregister_netdev(net_dev);
674error_register_netdev:
675error_read_mac_addr:
676error_bootrom_init:
677 kfree(i2400m->bm_ack_buf);
678error_bm_ack_buf_kzalloc:
679 kfree(i2400m->bm_cmd_buf);
680error_bm_cmd_kzalloc:
681 d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
682 return result;
683}
684EXPORT_SYMBOL_GPL(i2400m_setup);
685
686
687/**
688 * i2400m_release - release the bus-generic driver resources
689 *
690 * Sends a disconnect message and undoes any setup done by i2400m_setup()
691 */
692void i2400m_release(struct i2400m *i2400m)
693{
694 struct device *dev = i2400m_dev(i2400m);
695
696 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
697 netif_stop_queue(i2400m->wimax_dev.net_dev);
698
699 i2400m_debugfs_rm(i2400m);
700 wimax_dev_rm(&i2400m->wimax_dev);
701 i2400m_dev_stop(i2400m);
702 unregister_netdev(i2400m->wimax_dev.net_dev);
703 kfree(i2400m->bm_ack_buf);
704 kfree(i2400m->bm_cmd_buf);
705 d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
706}
707EXPORT_SYMBOL_GPL(i2400m_release);
708
709
710static
711int __init i2400m_driver_init(void)
712{
713 return 0;
714}
715module_init(i2400m_driver_init);
716
717static
718void __exit i2400m_driver_exit(void)
719{
720 /* for scheds i2400m_dev_reset_handle() */
721 flush_scheduled_work();
722 return;
723}
724module_exit(i2400m_driver_exit);
725
726MODULE_AUTHOR("Intel Corporation <linux-wimax@intel.com>");
727MODULE_DESCRIPTION("Intel 2400M WiMAX networking bus-generic driver");
728MODULE_LICENSE("GPL");
diff --git a/drivers/net/wimax/i2400m/fw.c b/drivers/net/wimax/i2400m/fw.c
new file mode 100644
index 000000000000..1d8271f34c38
--- /dev/null
+++ b/drivers/net/wimax/i2400m/fw.c
@@ -0,0 +1,1095 @@
1/*
2 * Intel Wireless WiMAX Connection 2400m
3 * Firmware uploader
4 *
5 *
6 * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 *
35 * Intel Corporation <linux-wimax@intel.com>
36 * Yanir Lubetkin <yanirx.lubetkin@intel.com>
37 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
38 * - Initial implementation
39 *
40 *
41 * THE PROCEDURE
42 *
43 * (this is decribed for USB, but for SDIO is similar)
44 *
45 * The 2400m works in two modes: boot-mode or normal mode. In boot
46 * mode we can execute only a handful of commands targeted at
47 * uploading the firmware and launching it.
48 *
49 * The 2400m enters boot mode when it is first connected to the
50 * system, when it crashes and when you ask it to reboot. There are
51 * two submodes of the boot mode: signed and non-signed. Signed takes
52 * firmwares signed with a certain private key, non-signed takes any
53 * firmware. Normal hardware takes only signed firmware.
54 *
55 * Upon entrance to boot mode, the device sends a few zero length
56 * packets (ZLPs) on the notification endpoint, then a reboot barker
57 * (4 le32 words with value I2400M_{S,N}BOOT_BARKER). We ack it by
58 * sending the same barker on the bulk out endpoint. The device acks
59 * with a reboot ack barker (4 le32 words with value 0xfeedbabe) and
60 * then the device is fully rebooted. At this point we can upload the
61 * firmware.
62 *
63 * This process is accomplished by the i2400m_bootrom_init()
64 * function. All the device interaction happens through the
65 * i2400m_bm_cmd() [boot mode command]. Special return values will
66 * indicate if the device resets.
67 *
68 * After this, we read the MAC address and then (if needed)
69 * reinitialize the device. We need to read it ahead of time because
70 * in the future, we might not upload the firmware until userspace
71 * 'ifconfig up's the device.
72 *
73 * We can then upload the firmware file. The file is composed of a BCF
74 * header (basic data, keys and signatures) and a list of write
75 * commands and payloads. We first upload the header
76 * [i2400m_dnload_init()] and then pass the commands and payloads
77 * verbatim to the i2400m_bm_cmd() function
78 * [i2400m_dnload_bcf()]. Then we tell the device to jump to the new
79 * firmware [i2400m_dnload_finalize()].
80 *
81 * Once firmware is uploaded, we are good to go :)
82 *
83 * When we don't know in which mode we are, we first try by sending a
84 * warm reset request that will take us to boot-mode. If we time out
85 * waiting for a reboot barker, that means maybe we are already in
86 * boot mode, so we send a reboot barker.
87 *
88 * COMMAND EXECUTION
89 *
90 * This code (and process) is single threaded; for executing commands,
91 * we post a URB to the notification endpoint, post the command, wait
92 * for data on the notification buffer. We don't need to worry about
93 * others as we know we are the only ones in there.
94 *
95 * BACKEND IMPLEMENTATION
96 *
97 * This code is bus-generic; the bus-specific driver provides back end
98 * implementations to send a boot mode command to the device and to
99 * read an acknolwedgement from it (or an asynchronous notification)
100 * from it.
101 *
102 * ROADMAP
103 *
104 * i2400m_dev_bootstrap Called by __i2400m_dev_start()
105 * request_firmware
106 * i2400m_fw_check
107 * i2400m_fw_dnload
108 * release_firmware
109 *
110 * i2400m_fw_dnload
111 * i2400m_bootrom_init
112 * i2400m_bm_cmd
113 * i2400m->bus_reset
114 * i2400m_dnload_init
115 * i2400m_dnload_init_signed
116 * i2400m_dnload_init_nonsigned
117 * i2400m_download_chunk
118 * i2400m_bm_cmd
119 * i2400m_dnload_bcf
120 * i2400m_bm_cmd
121 * i2400m_dnload_finalize
122 * i2400m_bm_cmd
123 *
124 * i2400m_bm_cmd
125 * i2400m->bus_bm_cmd_send()
126 * i2400m->bus_bm_wait_for_ack
127 * __i2400m_bm_ack_verify
128 *
129 * i2400m_bm_cmd_prepare Used by bus-drivers to prep
130 * commands before sending
131 */
132#include <linux/firmware.h>
133#include <linux/sched.h>
134#include <linux/usb.h>
135#include "i2400m.h"
136
137
138#define D_SUBMODULE fw
139#include "debug-levels.h"
140
141
142static const __le32 i2400m_ACK_BARKER[4] = {
143 __constant_cpu_to_le32(I2400M_ACK_BARKER),
144 __constant_cpu_to_le32(I2400M_ACK_BARKER),
145 __constant_cpu_to_le32(I2400M_ACK_BARKER),
146 __constant_cpu_to_le32(I2400M_ACK_BARKER)
147};
148
149
150/**
151 * Prepare a boot-mode command for delivery
152 *
153 * @cmd: pointer to bootrom header to prepare
154 *
155 * Computes checksum if so needed. After calling this function, DO NOT
156 * modify the command or header as the checksum won't work anymore.
157 *
158 * We do it from here because some times we cannot do it in the
159 * original context the command was sent (it is a const), so when we
160 * copy it to our staging buffer, we add the checksum there.
161 */
162void i2400m_bm_cmd_prepare(struct i2400m_bootrom_header *cmd)
163{
164 if (i2400m_brh_get_use_checksum(cmd)) {
165 int i;
166 u32 checksum = 0;
167 const u32 *checksum_ptr = (void *) cmd->payload;
168 for (i = 0; i < cmd->data_size / 4; i++)
169 checksum += cpu_to_le32(*checksum_ptr++);
170 checksum += cmd->command + cmd->target_addr + cmd->data_size;
171 cmd->block_checksum = cpu_to_le32(checksum);
172 }
173}
174EXPORT_SYMBOL_GPL(i2400m_bm_cmd_prepare);
175
176
177/*
178 * Verify the ack data received
179 *
180 * Given a reply to a boot mode command, chew it and verify everything
181 * is ok.
182 *
183 * @opcode: opcode which generated this ack. For error messages.
184 * @ack: pointer to ack data we received
185 * @ack_size: size of that data buffer
186 * @flags: I2400M_BM_CMD_* flags we called the command with.
187 *
188 * Way too long function -- maybe it should be further split
189 */
190static
191ssize_t __i2400m_bm_ack_verify(struct i2400m *i2400m, int opcode,
192 struct i2400m_bootrom_header *ack,
193 size_t ack_size, int flags)
194{
195 ssize_t result = -ENOMEM;
196 struct device *dev = i2400m_dev(i2400m);
197
198 d_fnstart(8, dev, "(i2400m %p opcode %d ack %p size %zu)\n",
199 i2400m, opcode, ack, ack_size);
200 if (ack_size < sizeof(*ack)) {
201 result = -EIO;
202 dev_err(dev, "boot-mode cmd %d: HW BUG? notification didn't "
203 "return enough data (%zu bytes vs %zu expected)\n",
204 opcode, ack_size, sizeof(*ack));
205 goto error_ack_short;
206 }
207 if (ack_size == sizeof(i2400m_NBOOT_BARKER)
208 && memcmp(ack, i2400m_NBOOT_BARKER, sizeof(*ack)) == 0) {
209 result = -ERESTARTSYS;
210 i2400m->sboot = 0;
211 d_printf(6, dev, "boot-mode cmd %d: "
212 "HW non-signed boot barker\n", opcode);
213 goto error_reboot;
214 }
215 if (ack_size == sizeof(i2400m_SBOOT_BARKER)
216 && memcmp(ack, i2400m_SBOOT_BARKER, sizeof(*ack)) == 0) {
217 result = -ERESTARTSYS;
218 i2400m->sboot = 1;
219 d_printf(6, dev, "boot-mode cmd %d: HW signed reboot barker\n",
220 opcode);
221 goto error_reboot;
222 }
223 if (ack_size == sizeof(i2400m_ACK_BARKER)
224 && memcmp(ack, i2400m_ACK_BARKER, sizeof(*ack)) == 0) {
225 result = -EISCONN;
226 d_printf(3, dev, "boot-mode cmd %d: HW reboot ack barker\n",
227 opcode);
228 goto error_reboot_ack;
229 }
230 result = 0;
231 if (flags & I2400M_BM_CMD_RAW)
232 goto out_raw;
233 ack->data_size = le32_to_cpu(ack->data_size);
234 ack->target_addr = le32_to_cpu(ack->target_addr);
235 ack->block_checksum = le32_to_cpu(ack->block_checksum);
236 d_printf(5, dev, "boot-mode cmd %d: notification for opcode %u "
237 "response %u csum %u rr %u da %u\n",
238 opcode, i2400m_brh_get_opcode(ack),
239 i2400m_brh_get_response(ack),
240 i2400m_brh_get_use_checksum(ack),
241 i2400m_brh_get_response_required(ack),
242 i2400m_brh_get_direct_access(ack));
243 result = -EIO;
244 if (i2400m_brh_get_signature(ack) != 0xcbbc) {
245 dev_err(dev, "boot-mode cmd %d: HW BUG? wrong signature "
246 "0x%04x\n", opcode, i2400m_brh_get_signature(ack));
247 goto error_ack_signature;
248 }
249 if (opcode != -1 && opcode != i2400m_brh_get_opcode(ack)) {
250 dev_err(dev, "boot-mode cmd %d: HW BUG? "
251 "received response for opcode %u, expected %u\n",
252 opcode, i2400m_brh_get_opcode(ack), opcode);
253 goto error_ack_opcode;
254 }
255 if (i2400m_brh_get_response(ack) != 0) { /* failed? */
256 dev_err(dev, "boot-mode cmd %d: error; hw response %u\n",
257 opcode, i2400m_brh_get_response(ack));
258 goto error_ack_failed;
259 }
260 if (ack_size < ack->data_size + sizeof(*ack)) {
261 dev_err(dev, "boot-mode cmd %d: SW BUG "
262 "driver provided only %zu bytes for %zu bytes "
263 "of data\n", opcode, ack_size,
264 (size_t) le32_to_cpu(ack->data_size) + sizeof(*ack));
265 goto error_ack_short_buffer;
266 }
267 result = ack_size;
268 /* Don't you love this stack of empty targets? Well, I don't
269 * either, but it helps track exactly who comes in here and
270 * why :) */
271error_ack_short_buffer:
272error_ack_failed:
273error_ack_opcode:
274error_ack_signature:
275out_raw:
276error_reboot_ack:
277error_reboot:
278error_ack_short:
279 d_fnend(8, dev, "(i2400m %p opcode %d ack %p size %zu) = %d\n",
280 i2400m, opcode, ack, ack_size, (int) result);
281 return result;
282}
283
284
285/**
286 * i2400m_bm_cmd - Execute a boot mode command
287 *
288 * @cmd: buffer containing the command data (pointing at the header).
289 * This data can be ANYWHERE (for USB, we will copy it to an
290 * specific buffer). Make sure everything is in proper little
291 * endian.
292 *
293 * A raw buffer can be also sent, just cast it and set flags to
294 * I2400M_BM_CMD_RAW.
295 *
296 * This function will generate a checksum for you if the
297 * checksum bit in the command is set (unless I2400M_BM_CMD_RAW
298 * is set).
299 *
300 * You can use the i2400m->bm_cmd_buf to stage your commands and
301 * send them.
302 *
303 * If NULL, no command is sent (we just wait for an ack).
304 *
305 * @cmd_size: size of the command. Will be auto padded to the
306 * bus-specific drivers padding requirements.
307 *
308 * @ack: buffer where to place the acknowledgement. If it is a regular
309 * command response, all fields will be returned with the right,
310 * native endianess.
311 *
312 * You *cannot* use i2400m->bm_ack_buf for this buffer.
313 *
314 * @ack_size: size of @ack, 16 aligned; you need to provide at least
315 * sizeof(*ack) bytes and then enough to contain the return data
316 * from the command
317 *
318 * @flags: see I2400M_BM_CMD_* above.
319 *
320 * @returns: bytes received by the notification; if < 0, an errno code
321 * denoting an error or:
322 *
323 * -ERESTARTSYS The device has rebooted
324 *
325 * Executes a boot-mode command and waits for a response, doing basic
326 * validation on it; if a zero length response is received, it retries
327 * waiting for a response until a non-zero one is received (timing out
328 * after %I2400M_BOOT_RETRIES retries).
329 */
330static
331ssize_t i2400m_bm_cmd(struct i2400m *i2400m,
332 const struct i2400m_bootrom_header *cmd, size_t cmd_size,
333 struct i2400m_bootrom_header *ack, size_t ack_size,
334 int flags)
335{
336 ssize_t result = -ENOMEM, rx_bytes;
337 struct device *dev = i2400m_dev(i2400m);
338 int opcode = cmd == NULL ? -1 : i2400m_brh_get_opcode(cmd);
339
340 d_fnstart(6, dev, "(i2400m %p cmd %p size %zu ack %p size %zu)\n",
341 i2400m, cmd, cmd_size, ack, ack_size);
342 BUG_ON(ack_size < sizeof(*ack));
343 BUG_ON(i2400m->boot_mode == 0);
344
345 if (cmd != NULL) { /* send the command */
346 memcpy(i2400m->bm_cmd_buf, cmd, cmd_size);
347 result = i2400m->bus_bm_cmd_send(i2400m, cmd, cmd_size, flags);
348 if (result < 0)
349 goto error_cmd_send;
350 if ((flags & I2400M_BM_CMD_RAW) == 0)
351 d_printf(5, dev,
352 "boot-mode cmd %d csum %u rr %u da %u: "
353 "addr 0x%04x size %u block csum 0x%04x\n",
354 opcode, i2400m_brh_get_use_checksum(cmd),
355 i2400m_brh_get_response_required(cmd),
356 i2400m_brh_get_direct_access(cmd),
357 cmd->target_addr, cmd->data_size,
358 cmd->block_checksum);
359 }
360 result = i2400m->bus_bm_wait_for_ack(i2400m, ack, ack_size);
361 if (result < 0) {
362 dev_err(dev, "boot-mode cmd %d: error waiting for an ack: %d\n",
363 opcode, (int) result); /* bah, %zd doesn't work */
364 goto error_wait_for_ack;
365 }
366 rx_bytes = result;
367 /* verify the ack and read more if neccessary [result is the
368 * final amount of bytes we get in the ack] */
369 result = __i2400m_bm_ack_verify(i2400m, opcode, ack, ack_size, flags);
370 if (result < 0)
371 goto error_bad_ack;
372 /* Don't you love this stack of empty targets? Well, I don't
373 * either, but it helps track exactly who comes in here and
374 * why :) */
375 result = rx_bytes;
376error_bad_ack:
377error_wait_for_ack:
378error_cmd_send:
379 d_fnend(6, dev, "(i2400m %p cmd %p size %zu ack %p size %zu) = %d\n",
380 i2400m, cmd, cmd_size, ack, ack_size, (int) result);
381 return result;
382}
383
384
385/**
386 * i2400m_download_chunk - write a single chunk of data to the device's memory
387 *
388 * @i2400m: device descriptor
389 * @buf: the buffer to write
390 * @buf_len: length of the buffer to write
391 * @addr: address in the device memory space
392 * @direct: bootrom write mode
393 * @do_csum: should a checksum validation be performed
394 */
395static int i2400m_download_chunk(struct i2400m *i2400m, const void *chunk,
396 size_t __chunk_len, unsigned long addr,
397 unsigned int direct, unsigned int do_csum)
398{
399 int ret;
400 size_t chunk_len = ALIGN(__chunk_len, I2400M_PL_PAD);
401 struct device *dev = i2400m_dev(i2400m);
402 struct {
403 struct i2400m_bootrom_header cmd;
404 u8 cmd_payload[chunk_len];
405 } __attribute__((packed)) *buf;
406 struct i2400m_bootrom_header ack;
407
408 d_fnstart(5, dev, "(i2400m %p chunk %p __chunk_len %zu addr 0x%08lx "
409 "direct %u do_csum %u)\n", i2400m, chunk, __chunk_len,
410 addr, direct, do_csum);
411 buf = i2400m->bm_cmd_buf;
412 memcpy(buf->cmd_payload, chunk, __chunk_len);
413 memset(buf->cmd_payload + __chunk_len, 0xad, chunk_len - __chunk_len);
414
415 buf->cmd.command = i2400m_brh_command(I2400M_BRH_WRITE,
416 __chunk_len & 0x3 ? 0 : do_csum,
417 __chunk_len & 0xf ? 0 : direct);
418 buf->cmd.target_addr = cpu_to_le32(addr);
419 buf->cmd.data_size = cpu_to_le32(__chunk_len);
420 ret = i2400m_bm_cmd(i2400m, &buf->cmd, sizeof(buf->cmd) + chunk_len,
421 &ack, sizeof(ack), 0);
422 if (ret >= 0)
423 ret = 0;
424 d_fnend(5, dev, "(i2400m %p chunk %p __chunk_len %zu addr 0x%08lx "
425 "direct %u do_csum %u) = %d\n", i2400m, chunk, __chunk_len,
426 addr, direct, do_csum, ret);
427 return ret;
428}
429
430
431/*
432 * Download a BCF file's sections to the device
433 *
434 * @i2400m: device descriptor
435 * @bcf: pointer to firmware data (followed by the payloads). Assumed
436 * verified and consistent.
437 * @bcf_len: length (in bytes) of the @bcf buffer.
438 *
439 * Returns: < 0 errno code on error or the offset to the jump instruction.
440 *
441 * Given a BCF file, downloads each section (a command and a payload)
442 * to the device's address space. Actually, it just executes each
443 * command i the BCF file.
444 *
445 * The section size has to be aligned to 4 bytes AND the padding has
446 * to be taken from the firmware file, as the signature takes it into
447 * account.
448 */
449static
450ssize_t i2400m_dnload_bcf(struct i2400m *i2400m,
451 const struct i2400m_bcf_hdr *bcf, size_t bcf_len)
452{
453 ssize_t ret;
454 struct device *dev = i2400m_dev(i2400m);
455 size_t offset, /* iterator offset */
456 data_size, /* Size of the data payload */
457 section_size, /* Size of the whole section (cmd + payload) */
458 section = 1;
459 const struct i2400m_bootrom_header *bh;
460 struct i2400m_bootrom_header ack;
461
462 d_fnstart(3, dev, "(i2400m %p bcf %p bcf_len %zu)\n",
463 i2400m, bcf, bcf_len);
464 /* Iterate over the command blocks in the BCF file that start
465 * after the header */
466 offset = le32_to_cpu(bcf->header_len) * sizeof(u32);
467 while (1) { /* start sending the file */
468 bh = (void *) bcf + offset;
469 data_size = le32_to_cpu(bh->data_size);
470 section_size = ALIGN(sizeof(*bh) + data_size, 4);
471 d_printf(7, dev,
472 "downloading section #%zu (@%zu %zu B) to 0x%08x\n",
473 section, offset, sizeof(*bh) + data_size,
474 le32_to_cpu(bh->target_addr));
475 if (i2400m_brh_get_opcode(bh) == I2400M_BRH_SIGNED_JUMP) {
476 /* Secure boot needs to stop here */
477 d_printf(5, dev, "signed jump found @%zu\n", offset);
478 break;
479 }
480 if (offset + section_size == bcf_len)
481 /* Non-secure boot stops here */
482 break;
483 if (offset + section_size > bcf_len) {
484 dev_err(dev, "fw %s: bad section #%zu, "
485 "end (@%zu) beyond EOF (@%zu)\n",
486 i2400m->bus_fw_name, section,
487 offset + section_size, bcf_len);
488 ret = -EINVAL;
489 goto error_section_beyond_eof;
490 }
491 __i2400m_msleep(20);
492 ret = i2400m_bm_cmd(i2400m, bh, section_size,
493 &ack, sizeof(ack), I2400M_BM_CMD_RAW);
494 if (ret < 0) {
495 dev_err(dev, "fw %s: section #%zu (@%zu %zu B) "
496 "failed %d\n", i2400m->bus_fw_name, section,
497 offset, sizeof(*bh) + data_size, (int) ret);
498 goto error_send;
499 }
500 offset += section_size;
501 section++;
502 }
503 ret = offset;
504error_section_beyond_eof:
505error_send:
506 d_fnend(3, dev, "(i2400m %p bcf %p bcf_len %zu) = %d\n",
507 i2400m, bcf, bcf_len, (int) ret);
508 return ret;
509}
510
511
512/*
513 * Do the final steps of uploading firmware
514 *
515 * Depending on the boot mode (signed vs non-signed), different
516 * actions need to be taken.
517 */
518static
519int i2400m_dnload_finalize(struct i2400m *i2400m,
520 const struct i2400m_bcf_hdr *bcf, size_t offset)
521{
522 int ret = 0;
523 struct device *dev = i2400m_dev(i2400m);
524 struct i2400m_bootrom_header *cmd, ack;
525 struct {
526 struct i2400m_bootrom_header cmd;
527 u8 cmd_pl[0];
528 } __attribute__((packed)) *cmd_buf;
529 size_t signature_block_offset, signature_block_size;
530
531 d_fnstart(3, dev, "offset %zu\n", offset);
532 cmd = (void *) bcf + offset;
533 if (i2400m->sboot == 0) {
534 struct i2400m_bootrom_header jump_ack;
535 d_printf(3, dev, "unsecure boot, jumping to 0x%08x\n",
536 le32_to_cpu(cmd->target_addr));
537 i2400m_brh_set_opcode(cmd, I2400M_BRH_JUMP);
538 cmd->data_size = 0;
539 ret = i2400m_bm_cmd(i2400m, cmd, sizeof(*cmd),
540 &jump_ack, sizeof(jump_ack), 0);
541 } else {
542 d_printf(3, dev, "secure boot, jumping to 0x%08x\n",
543 le32_to_cpu(cmd->target_addr));
544 cmd_buf = i2400m->bm_cmd_buf;
545 memcpy(&cmd_buf->cmd, cmd, sizeof(*cmd));
546 signature_block_offset =
547 sizeof(*bcf)
548 + le32_to_cpu(bcf->key_size) * sizeof(u32)
549 + le32_to_cpu(bcf->exponent_size) * sizeof(u32);
550 signature_block_size =
551 le32_to_cpu(bcf->modulus_size) * sizeof(u32);
552 memcpy(cmd_buf->cmd_pl, (void *) bcf + signature_block_offset,
553 signature_block_size);
554 ret = i2400m_bm_cmd(i2400m, &cmd_buf->cmd,
555 sizeof(cmd_buf->cmd) + signature_block_size,
556 &ack, sizeof(ack), I2400M_BM_CMD_RAW);
557 }
558 d_fnend(3, dev, "returning %d\n", ret);
559 return ret;
560}
561
562
563/**
564 * i2400m_bootrom_init - Reboots a powered device into boot mode
565 *
566 * @i2400m: device descriptor
567 * @flags:
568 * I2400M_BRI_SOFT: a reboot notification has been seen
569 * already, so don't wait for it.
570 *
571 * I2400M_BRI_NO_REBOOT: Don't send a reboot command, but wait
572 * for a reboot barker notification. This is a one shot; if
573 * the state machine needs to send a reboot command it will.
574 *
575 * Returns:
576 *
577 * < 0 errno code on error, 0 if ok.
578 *
579 * i2400m->sboot set to 0 for unsecure boot process, 1 for secure
580 * boot process.
581 *
582 * Description:
583 *
584 * Tries hard enough to put the device in boot-mode. There are two
585 * main phases to this:
586 *
587 * a. (1) send a reboot command and (2) get a reboot barker
588 * b. (1) ack the reboot sending a reboot barker and (2) getting an
589 * ack barker in return
590 *
591 * We want to skip (a) in some cases [soft]. The state machine is
592 * horrible, but it is basically: on each phase, send what has to be
593 * sent (if any), wait for the answer and act on the answer. We might
594 * have to backtrack and retry, so we keep a max tries counter for
595 * that.
596 *
597 * If we get a timeout after sending a warm reset, we do it again.
598 */
599int i2400m_bootrom_init(struct i2400m *i2400m, enum i2400m_bri flags)
600{
601 int result;
602 struct device *dev = i2400m_dev(i2400m);
603 struct i2400m_bootrom_header *cmd;
604 struct i2400m_bootrom_header ack;
605 int count = I2400M_BOOT_RETRIES;
606 int ack_timeout_cnt = 1;
607
608 BUILD_BUG_ON(sizeof(*cmd) != sizeof(i2400m_NBOOT_BARKER));
609 BUILD_BUG_ON(sizeof(ack) != sizeof(i2400m_ACK_BARKER));
610
611 d_fnstart(4, dev, "(i2400m %p flags 0x%08x)\n", i2400m, flags);
612 result = -ENOMEM;
613 cmd = i2400m->bm_cmd_buf;
614 if (flags & I2400M_BRI_SOFT)
615 goto do_reboot_ack;
616do_reboot:
617 if (--count < 0)
618 goto error_timeout;
619 d_printf(4, dev, "device reboot: reboot command [%d # left]\n",
620 count);
621 if ((flags & I2400M_BRI_NO_REBOOT) == 0)
622 i2400m->bus_reset(i2400m, I2400M_RT_WARM);
623 result = i2400m_bm_cmd(i2400m, NULL, 0, &ack, sizeof(ack),
624 I2400M_BM_CMD_RAW);
625 flags &= ~I2400M_BRI_NO_REBOOT;
626 switch (result) {
627 case -ERESTARTSYS:
628 d_printf(4, dev, "device reboot: got reboot barker\n");
629 break;
630 case -EISCONN: /* we don't know how it got here...but we follow it */
631 d_printf(4, dev, "device reboot: got ack barker - whatever\n");
632 goto do_reboot;
633 case -ETIMEDOUT: /* device has timed out, we might be in boot
634 * mode already and expecting an ack, let's try
635 * that */
636 dev_info(dev, "warm reset timed out, trying an ack\n");
637 goto do_reboot_ack;
638 case -EPROTO:
639 case -ESHUTDOWN: /* dev is gone */
640 case -EINTR: /* user cancelled */
641 goto error_dev_gone;
642 default:
643 dev_err(dev, "device reboot: error %d while waiting "
644 "for reboot barker - rebooting\n", result);
645 goto do_reboot;
646 }
647 /* At this point we ack back with 4 REBOOT barkers and expect
648 * 4 ACK barkers. This is ugly, as we send a raw command --
649 * hence the cast. _bm_cmd() will catch the reboot ack
650 * notification and report it as -EISCONN. */
651do_reboot_ack:
652 d_printf(4, dev, "device reboot ack: sending ack [%d # left]\n", count);
653 if (i2400m->sboot == 0)
654 memcpy(cmd, i2400m_NBOOT_BARKER,
655 sizeof(i2400m_NBOOT_BARKER));
656 else
657 memcpy(cmd, i2400m_SBOOT_BARKER,
658 sizeof(i2400m_SBOOT_BARKER));
659 result = i2400m_bm_cmd(i2400m, cmd, sizeof(*cmd),
660 &ack, sizeof(ack), I2400M_BM_CMD_RAW);
661 switch (result) {
662 case -ERESTARTSYS:
663 d_printf(4, dev, "reboot ack: got reboot barker - retrying\n");
664 if (--count < 0)
665 goto error_timeout;
666 goto do_reboot_ack;
667 case -EISCONN:
668 d_printf(4, dev, "reboot ack: got ack barker - good\n");
669 break;
670 case -ETIMEDOUT: /* no response, maybe it is the other type? */
671 if (ack_timeout_cnt-- >= 0) {
672 d_printf(4, dev, "reboot ack timedout: "
673 "trying the other type?\n");
674 i2400m->sboot = !i2400m->sboot;
675 goto do_reboot_ack;
676 } else {
677 dev_err(dev, "reboot ack timedout too long: "
678 "trying reboot\n");
679 goto do_reboot;
680 }
681 break;
682 case -EPROTO:
683 case -ESHUTDOWN: /* dev is gone */
684 goto error_dev_gone;
685 default:
686 dev_err(dev, "device reboot ack: error %d while waiting for "
687 "reboot ack barker - rebooting\n", result);
688 goto do_reboot;
689 }
690 d_printf(2, dev, "device reboot ack: got ack barker - boot done\n");
691 result = 0;
692exit_timeout:
693error_dev_gone:
694 d_fnend(4, dev, "(i2400m %p flags 0x%08x) = %d\n",
695 i2400m, flags, result);
696 return result;
697
698error_timeout:
699 dev_err(dev, "Timed out waiting for reboot ack, resetting\n");
700 i2400m->bus_reset(i2400m, I2400M_RT_BUS);
701 result = -ETIMEDOUT;
702 goto exit_timeout;
703}
704
705
706/*
707 * Read the MAC addr
708 *
709 * The position this function reads is fixed in device memory and
710 * always available, even without firmware.
711 *
712 * Note we specify we want to read only six bytes, but provide space
713 * for 16, as we always get it rounded up.
714 */
715int i2400m_read_mac_addr(struct i2400m *i2400m)
716{
717 int result;
718 struct device *dev = i2400m_dev(i2400m);
719 struct net_device *net_dev = i2400m->wimax_dev.net_dev;
720 struct i2400m_bootrom_header *cmd;
721 struct {
722 struct i2400m_bootrom_header ack;
723 u8 ack_pl[16];
724 } __attribute__((packed)) ack_buf;
725
726 d_fnstart(5, dev, "(i2400m %p)\n", i2400m);
727 cmd = i2400m->bm_cmd_buf;
728 cmd->command = i2400m_brh_command(I2400M_BRH_READ, 0, 1);
729 cmd->target_addr = cpu_to_le32(0x00203fe8);
730 cmd->data_size = cpu_to_le32(6);
731 result = i2400m_bm_cmd(i2400m, cmd, sizeof(*cmd),
732 &ack_buf.ack, sizeof(ack_buf), 0);
733 if (result < 0) {
734 dev_err(dev, "BM: read mac addr failed: %d\n", result);
735 goto error_read_mac;
736 }
737 d_printf(2, dev,
738 "mac addr is %02x:%02x:%02x:%02x:%02x:%02x\n",
739 ack_buf.ack_pl[0], ack_buf.ack_pl[1],
740 ack_buf.ack_pl[2], ack_buf.ack_pl[3],
741 ack_buf.ack_pl[4], ack_buf.ack_pl[5]);
742 if (i2400m->bus_bm_mac_addr_impaired == 1) {
743 ack_buf.ack_pl[0] = 0x00;
744 ack_buf.ack_pl[1] = 0x16;
745 ack_buf.ack_pl[2] = 0xd3;
746 get_random_bytes(&ack_buf.ack_pl[3], 3);
747 dev_err(dev, "BM is MAC addr impaired, faking MAC addr to "
748 "mac addr is %02x:%02x:%02x:%02x:%02x:%02x\n",
749 ack_buf.ack_pl[0], ack_buf.ack_pl[1],
750 ack_buf.ack_pl[2], ack_buf.ack_pl[3],
751 ack_buf.ack_pl[4], ack_buf.ack_pl[5]);
752 result = 0;
753 }
754 net_dev->addr_len = ETH_ALEN;
755 memcpy(net_dev->perm_addr, ack_buf.ack_pl, ETH_ALEN);
756 memcpy(net_dev->dev_addr, ack_buf.ack_pl, ETH_ALEN);
757error_read_mac:
758 d_fnend(5, dev, "(i2400m %p) = %d\n", i2400m, result);
759 return result;
760}
761
762
763/*
764 * Initialize a non signed boot
765 *
766 * This implies sending some magic values to the device's memory. Note
767 * we convert the values to little endian in the same array
768 * declaration.
769 */
770static
771int i2400m_dnload_init_nonsigned(struct i2400m *i2400m)
772{
773#define POKE(a, d) { \
774 .address = __constant_cpu_to_le32(a), \
775 .data = __constant_cpu_to_le32(d) \
776}
777 static const struct {
778 __le32 address;
779 __le32 data;
780 } i2400m_pokes[] = {
781 POKE(0x081A58, 0xA7810230),
782 POKE(0x080040, 0x00000000),
783 POKE(0x080048, 0x00000082),
784 POKE(0x08004C, 0x0000081F),
785 POKE(0x080054, 0x00000085),
786 POKE(0x080058, 0x00000180),
787 POKE(0x08005C, 0x00000018),
788 POKE(0x080060, 0x00000010),
789 POKE(0x080574, 0x00000001),
790 POKE(0x080550, 0x00000005),
791 POKE(0xAE0000, 0x00000000),
792 };
793#undef POKE
794 unsigned i;
795 int ret;
796 struct device *dev = i2400m_dev(i2400m);
797
798 dev_warn(dev, "WARNING!!! non-signed boot UNTESTED PATH!\n");
799
800 d_fnstart(5, dev, "(i2400m %p)\n", i2400m);
801 for (i = 0; i < ARRAY_SIZE(i2400m_pokes); i++) {
802 ret = i2400m_download_chunk(i2400m, &i2400m_pokes[i].data,
803 sizeof(i2400m_pokes[i].data),
804 i2400m_pokes[i].address, 1, 1);
805 if (ret < 0)
806 break;
807 }
808 d_fnend(5, dev, "(i2400m %p) = %d\n", i2400m, ret);
809 return ret;
810}
811
812
813/*
814 * Initialize the signed boot process
815 *
816 * @i2400m: device descriptor
817 *
818 * @bcf_hdr: pointer to the firmware header; assumes it is fully in
819 * memory (it has gone through basic validation).
820 *
821 * Returns: 0 if ok, < 0 errno code on error, -ERESTARTSYS if the hw
822 * rebooted.
823 *
824 * This writes the firmware BCF header to the device using the
825 * HASH_PAYLOAD_ONLY command.
826 */
827static
828int i2400m_dnload_init_signed(struct i2400m *i2400m,
829 const struct i2400m_bcf_hdr *bcf_hdr)
830{
831 int ret;
832 struct device *dev = i2400m_dev(i2400m);
833 struct {
834 struct i2400m_bootrom_header cmd;
835 struct i2400m_bcf_hdr cmd_pl;
836 } __attribute__((packed)) *cmd_buf;
837 struct i2400m_bootrom_header ack;
838
839 d_fnstart(5, dev, "(i2400m %p bcf_hdr %p)\n", i2400m, bcf_hdr);
840 cmd_buf = i2400m->bm_cmd_buf;
841 cmd_buf->cmd.command =
842 i2400m_brh_command(I2400M_BRH_HASH_PAYLOAD_ONLY, 0, 0);
843 cmd_buf->cmd.target_addr = 0;
844 cmd_buf->cmd.data_size = cpu_to_le32(sizeof(cmd_buf->cmd_pl));
845 memcpy(&cmd_buf->cmd_pl, bcf_hdr, sizeof(*bcf_hdr));
846 ret = i2400m_bm_cmd(i2400m, &cmd_buf->cmd, sizeof(*cmd_buf),
847 &ack, sizeof(ack), 0);
848 if (ret >= 0)
849 ret = 0;
850 d_fnend(5, dev, "(i2400m %p bcf_hdr %p) = %d\n", i2400m, bcf_hdr, ret);
851 return ret;
852}
853
854
855/*
856 * Initialize the firmware download at the device size
857 *
858 * Multiplex to the one that matters based on the device's mode
859 * (signed or non-signed).
860 */
861static
862int i2400m_dnload_init(struct i2400m *i2400m, const struct i2400m_bcf_hdr *bcf)
863{
864 int result;
865 struct device *dev = i2400m_dev(i2400m);
866 u32 module_id = le32_to_cpu(bcf->module_id);
867
868 if (i2400m->sboot == 0
869 && (module_id & I2400M_BCF_MOD_ID_POKES) == 0) {
870 /* non-signed boot process without pokes */
871 result = i2400m_dnload_init_nonsigned(i2400m);
872 if (result == -ERESTARTSYS)
873 return result;
874 if (result < 0)
875 dev_err(dev, "fw %s: non-signed download "
876 "initialization failed: %d\n",
877 i2400m->bus_fw_name, result);
878 } else if (i2400m->sboot == 0
879 && (module_id & I2400M_BCF_MOD_ID_POKES)) {
880 /* non-signed boot process with pokes, nothing to do */
881 result = 0;
882 } else { /* signed boot process */
883 result = i2400m_dnload_init_signed(i2400m, bcf);
884 if (result == -ERESTARTSYS)
885 return result;
886 if (result < 0)
887 dev_err(dev, "fw %s: signed boot download "
888 "initialization failed: %d\n",
889 i2400m->bus_fw_name, result);
890 }
891 return result;
892}
893
894
895/*
896 * Run quick consistency tests on the firmware file
897 *
898 * Check for the firmware being made for the i2400m device,
899 * etc...These checks are mostly informative, as the device will make
900 * them too; but the driver's response is more informative on what
901 * went wrong.
902 */
903static
904int i2400m_fw_check(struct i2400m *i2400m,
905 const struct i2400m_bcf_hdr *bcf,
906 size_t bcf_size)
907{
908 int result;
909 struct device *dev = i2400m_dev(i2400m);
910 unsigned module_type, header_len, major_version, minor_version,
911 module_id, module_vendor, date, size;
912
913 /* Check hard errors */
914 result = -EINVAL;
915 if (bcf_size < sizeof(*bcf)) { /* big enough header? */
916 dev_err(dev, "firmware %s too short: "
917 "%zu B vs %zu (at least) expected\n",
918 i2400m->bus_fw_name, bcf_size, sizeof(*bcf));
919 goto error;
920 }
921
922 module_type = bcf->module_type;
923 header_len = sizeof(u32) * le32_to_cpu(bcf->header_len);
924 major_version = le32_to_cpu(bcf->header_version) & 0xffff0000 >> 16;
925 minor_version = le32_to_cpu(bcf->header_version) & 0x0000ffff;
926 module_id = le32_to_cpu(bcf->module_id);
927 module_vendor = le32_to_cpu(bcf->module_vendor);
928 date = le32_to_cpu(bcf->date);
929 size = sizeof(u32) * le32_to_cpu(bcf->size);
930
931 if (bcf_size != size) { /* annoyingly paranoid */
932 dev_err(dev, "firmware %s: bad size, got "
933 "%zu B vs %u expected\n",
934 i2400m->bus_fw_name, bcf_size, size);
935 goto error;
936 }
937
938 d_printf(2, dev, "type 0x%x id 0x%x vendor 0x%x; header v%u.%u (%zu B) "
939 "date %08x (%zu B)\n",
940 module_type, module_id, module_vendor,
941 major_version, minor_version, (size_t) header_len,
942 date, (size_t) size);
943
944 if (module_type != 6) { /* built for the right hardware? */
945 dev_err(dev, "bad fw %s: unexpected module type 0x%x; "
946 "aborting\n", i2400m->bus_fw_name, module_type);
947 goto error;
948 }
949
950 /* Check soft-er errors */
951 result = 0;
952 if (module_vendor != 0x8086)
953 dev_err(dev, "bad fw %s? unexpected vendor 0x%04x\n",
954 i2400m->bus_fw_name, module_vendor);
955 if (date < 0x20080300)
956 dev_err(dev, "bad fw %s? build date too old %08x\n",
957 i2400m->bus_fw_name, date);
958error:
959 return result;
960}
961
962
963/*
964 * Download the firmware to the device
965 *
966 * @i2400m: device descriptor
967 * @bcf: pointer to loaded (and minimally verified for consistency)
968 * firmware
969 * @bcf_size: size of the @bcf buffer (header plus payloads)
970 *
971 * The process for doing this is described in this file's header.
972 *
973 * Note we only reinitialize boot-mode if the flags say so. Some hw
974 * iterations need it, some don't. In any case, if we loop, we always
975 * need to reinitialize the boot room, hence the flags modification.
976 */
977static
978int i2400m_fw_dnload(struct i2400m *i2400m, const struct i2400m_bcf_hdr *bcf,
979 size_t bcf_size, enum i2400m_bri flags)
980{
981 int ret = 0;
982 struct device *dev = i2400m_dev(i2400m);
983 int count = I2400M_BOOT_RETRIES;
984
985 d_fnstart(5, dev, "(i2400m %p bcf %p size %zu)\n",
986 i2400m, bcf, bcf_size);
987 i2400m->boot_mode = 1;
988hw_reboot:
989 if (count-- == 0) {
990 ret = -ERESTARTSYS;
991 dev_err(dev, "device rebooted too many times, aborting\n");
992 goto error_too_many_reboots;
993 }
994 if (flags & I2400M_BRI_MAC_REINIT) {
995 ret = i2400m_bootrom_init(i2400m, flags);
996 if (ret < 0) {
997 dev_err(dev, "bootrom init failed: %d\n", ret);
998 goto error_bootrom_init;
999 }
1000 }
1001 flags |= I2400M_BRI_MAC_REINIT;
1002
1003 /*
1004 * Initialize the download, push the bytes to the device and
1005 * then jump to the new firmware. Note @ret is passed with the
1006 * offset of the jump instruction to _dnload_finalize()
1007 */
1008 ret = i2400m_dnload_init(i2400m, bcf); /* Init device's dnload */
1009 if (ret == -ERESTARTSYS)
1010 goto error_dev_rebooted;
1011 if (ret < 0)
1012 goto error_dnload_init;
1013
1014 ret = i2400m_dnload_bcf(i2400m, bcf, bcf_size);
1015 if (ret == -ERESTARTSYS)
1016 goto error_dev_rebooted;
1017 if (ret < 0) {
1018 dev_err(dev, "fw %s: download failed: %d\n",
1019 i2400m->bus_fw_name, ret);
1020 goto error_dnload_bcf;
1021 }
1022
1023 ret = i2400m_dnload_finalize(i2400m, bcf, ret);
1024 if (ret == -ERESTARTSYS)
1025 goto error_dev_rebooted;
1026 if (ret < 0) {
1027 dev_err(dev, "fw %s: "
1028 "download finalization failed: %d\n",
1029 i2400m->bus_fw_name, ret);
1030 goto error_dnload_finalize;
1031 }
1032
1033 d_printf(2, dev, "fw %s successfully uploaded\n",
1034 i2400m->bus_fw_name);
1035 i2400m->boot_mode = 0;
1036error_dnload_finalize:
1037error_dnload_bcf:
1038error_dnload_init:
1039error_bootrom_init:
1040error_too_many_reboots:
1041 d_fnend(5, dev, "(i2400m %p bcf %p size %zu) = %d\n",
1042 i2400m, bcf, bcf_size, ret);
1043 return ret;
1044
1045error_dev_rebooted:
1046 dev_err(dev, "device rebooted, %d tries left\n", count);
1047 /* we got the notification already, no need to wait for it again */
1048 flags |= I2400M_BRI_SOFT;
1049 goto hw_reboot;
1050}
1051
1052
1053/**
1054 * i2400m_dev_bootstrap - Bring the device to a known state and upload firmware
1055 *
1056 * @i2400m: device descriptor
1057 *
1058 * Returns: >= 0 if ok, < 0 errno code on error.
1059 *
1060 * This sets up the firmware upload environment, loads the firmware
1061 * file from disk, verifies and then calls the firmware upload process
1062 * per se.
1063 *
1064 * Can be called either from probe, or after a warm reset. Can not be
1065 * called from within an interrupt. All the flow in this code is
1066 * single-threade; all I/Os are synchronous.
1067 */
1068int i2400m_dev_bootstrap(struct i2400m *i2400m, enum i2400m_bri flags)
1069{
1070 int ret = 0;
1071 struct device *dev = i2400m_dev(i2400m);
1072 const struct firmware *fw;
1073 const struct i2400m_bcf_hdr *bcf; /* Firmware data */
1074
1075 d_fnstart(5, dev, "(i2400m %p)\n", i2400m);
1076 /* Load firmware files to memory. */
1077 ret = request_firmware(&fw, i2400m->bus_fw_name, dev);
1078 if (ret) {
1079 dev_err(dev, "fw %s: request failed: %d\n",
1080 i2400m->bus_fw_name, ret);
1081 goto error_fw_req;
1082 }
1083 bcf = (void *) fw->data;
1084
1085 ret = i2400m_fw_check(i2400m, bcf, fw->size);
1086 if (ret < 0)
1087 goto error_fw_bad;
1088 ret = i2400m_fw_dnload(i2400m, bcf, fw->size, flags);
1089error_fw_bad:
1090 release_firmware(fw);
1091error_fw_req:
1092 d_fnend(5, dev, "(i2400m %p) = %d\n", i2400m, ret);
1093 return ret;
1094}
1095EXPORT_SYMBOL_GPL(i2400m_dev_bootstrap);
diff --git a/drivers/net/wimax/i2400m/i2400m-sdio.h b/drivers/net/wimax/i2400m/i2400m-sdio.h
new file mode 100644
index 000000000000..08c2fb739234
--- /dev/null
+++ b/drivers/net/wimax/i2400m/i2400m-sdio.h
@@ -0,0 +1,132 @@
1/*
2 * Intel Wireless WiMAX Connection 2400m
3 * SDIO-specific i2400m driver definitions
4 *
5 *
6 * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 *
35 * Intel Corporation <linux-wimax@intel.com>
36 * Brian Bian <brian.bian@intel.com>
37 * Dirk Brandewie <dirk.j.brandewie@intel.com>
38 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
39 * Yanir Lubetkin <yanirx.lubetkin@intel.com>
40 * - Initial implementation
41 *
42 *
43 * This driver implements the bus-specific part of the i2400m for
44 * SDIO. Check i2400m.h for a generic driver description.
45 *
46 * ARCHITECTURE
47 *
48 * This driver sits under the bus-generic i2400m driver, providing the
49 * connection to the device.
50 *
51 * When probed, all the function pointers are setup and then the
52 * bus-generic code called. The generic driver will then use the
53 * provided pointers for uploading firmware (i2400ms_bus_bm*() in
54 * sdio-fw.c) and then setting up the device (i2400ms_dev_*() in
55 * sdio.c).
56 *
57 * Once firmware is uploaded, TX functions (sdio-tx.c) are called when
58 * data is ready for transmission in the TX fifo; then the SDIO IRQ is
59 * fired and data is available (sdio-rx.c), it is sent to the generic
60 * driver for processing with i2400m_rx.
61 */
62
63#ifndef __I2400M_SDIO_H__
64#define __I2400M_SDIO_H__
65
66#include "i2400m.h"
67
68/* Host-Device interface for SDIO */
69enum {
70 I2400MS_BLK_SIZE = 256,
71 I2400MS_PL_SIZE_MAX = 0x3E00,
72
73 I2400MS_DATA_ADDR = 0x0,
74 I2400MS_INTR_STATUS_ADDR = 0x13,
75 I2400MS_INTR_CLEAR_ADDR = 0x13,
76 I2400MS_INTR_ENABLE_ADDR = 0x14,
77 I2400MS_INTR_GET_SIZE_ADDR = 0x2C,
78 /* The number of ticks to wait for the device to signal that
79 * it is ready */
80 I2400MS_INIT_SLEEP_INTERVAL = 10,
81};
82
83
84/**
85 * struct i2400ms - descriptor for a SDIO connected i2400m
86 *
87 * @i2400m: bus-generic i2400m implementation; has to be first (see
88 * it's documentation in i2400m.h).
89 *
90 * @func: pointer to our SDIO function
91 *
92 * @tx_worker: workqueue struct used to TX data when the bus-generic
93 * code signals packets are pending for transmission to the device.
94 *
95 * @tx_workqueue: workqeueue used for data TX; we don't use the
96 * system's workqueue as that might cause deadlocks with code in
97 * the bus-generic driver.
98 */
99struct i2400ms {
100 struct i2400m i2400m; /* FIRST! See doc */
101 struct sdio_func *func;
102
103 struct work_struct tx_worker;
104 struct workqueue_struct *tx_workqueue;
105 char tx_wq_name[32];
106
107 struct dentry *debugfs_dentry;
108};
109
110
111static inline
112void i2400ms_init(struct i2400ms *i2400ms)
113{
114 i2400m_init(&i2400ms->i2400m);
115}
116
117
118extern int i2400ms_rx_setup(struct i2400ms *);
119extern void i2400ms_rx_release(struct i2400ms *);
120extern ssize_t __i2400ms_rx_get_size(struct i2400ms *);
121
122extern int i2400ms_tx_setup(struct i2400ms *);
123extern void i2400ms_tx_release(struct i2400ms *);
124extern void i2400ms_bus_tx_kick(struct i2400m *);
125
126extern ssize_t i2400ms_bus_bm_cmd_send(struct i2400m *,
127 const struct i2400m_bootrom_header *,
128 size_t, int);
129extern ssize_t i2400ms_bus_bm_wait_for_ack(struct i2400m *,
130 struct i2400m_bootrom_header *,
131 size_t);
132#endif /* #ifndef __I2400M_SDIO_H__ */
diff --git a/drivers/net/wimax/i2400m/i2400m-usb.h b/drivers/net/wimax/i2400m/i2400m-usb.h
new file mode 100644
index 000000000000..6f76558b170f
--- /dev/null
+++ b/drivers/net/wimax/i2400m/i2400m-usb.h
@@ -0,0 +1,264 @@
1/*
2 * Intel Wireless WiMAX Connection 2400m
3 * USB-specific i2400m driver definitions
4 *
5 *
6 * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 *
35 * Intel Corporation <linux-wimax@intel.com>
36 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
37 * Yanir Lubetkin <yanirx.lubetkin@intel.com>
38 * - Initial implementation
39 *
40 *
41 * This driver implements the bus-specific part of the i2400m for
42 * USB. Check i2400m.h for a generic driver description.
43 *
44 * ARCHITECTURE
45 *
46 * This driver listens to notifications sent from the notification
47 * endpoint (in usb-notif.c); when data is ready to read, the code in
48 * there schedules a read from the device (usb-rx.c) and then passes
49 * the data to the generic RX code (rx.c).
50 *
51 * When the generic driver needs to send data (network or control), it
52 * queues up in the TX FIFO (tx.c) and that will notify the driver
53 * through the i2400m->bus_tx_kick() callback
54 * (usb-tx.c:i2400mu_bus_tx_kick) which will send the items in the
55 * FIFO queue.
56 *
57 * This driver, as well, implements the USB-specific ops for the generic
58 * driver to be able to setup/teardown communication with the device
59 * [i2400m_bus_dev_start() and i2400m_bus_dev_stop()], reseting the
60 * device [i2400m_bus_reset()] and performing firmware upload
61 * [i2400m_bus_bm_cmd() and i2400_bus_bm_wait_for_ack()].
62 */
63
64#ifndef __I2400M_USB_H__
65#define __I2400M_USB_H__
66
67#include "i2400m.h"
68#include <linux/kthread.h>
69
70
71/*
72 * Error Density Count: cheapo error density (over time) counter
73 *
74 * Originally by Reinette Chatre <reinette.chatre@intel.com>
75 *
76 * Embed an 'struct edc' somewhere. Each time there is a soft or
77 * retryable error, call edc_inc() and check if the error top
78 * watermark has been reached.
79 */
80enum {
81 EDC_MAX_ERRORS = 10,
82 EDC_ERROR_TIMEFRAME = HZ,
83};
84
85/* error density counter */
86struct edc {
87 unsigned long timestart;
88 u16 errorcount;
89};
90
91static inline void edc_init(struct edc *edc)
92{
93 edc->timestart = jiffies;
94}
95
96/**
97 * edc_inc - report a soft error and check if we are over the watermark
98 *
99 * @edc: pointer to error density counter.
100 * @max_err: maximum number of errors we can accept over the timeframe
101 * @timeframe: lenght of the timeframe (in jiffies).
102 *
103 * Returns: !0 1 if maximum acceptable errors per timeframe has been
104 * exceeded. 0 otherwise.
105 *
106 * This is way to determine if the number of acceptable errors per time
107 * period has been exceeded. It is not accurate as there are cases in which
108 * this scheme will not work, for example if there are periodic occurences
109 * of errors that straddle updates to the start time. This scheme is
110 * sufficient for our usage.
111 *
112 * To use, embed a 'struct edc' somewhere, initialize it with
113 * edc_init() and when an error hits:
114 *
115 * if (do_something_fails_with_a_soft_error) {
116 * if (edc_inc(&my->edc, MAX_ERRORS, MAX_TIMEFRAME))
117 * Ops, hard error, do something about it
118 * else
119 * Retry or ignore, depending on whatever
120 * }
121 */
122static inline int edc_inc(struct edc *edc, u16 max_err, u16 timeframe)
123{
124 unsigned long now;
125
126 now = jiffies;
127 if (now - edc->timestart > timeframe) {
128 edc->errorcount = 1;
129 edc->timestart = now;
130 } else if (++edc->errorcount > max_err) {
131 edc->errorcount = 0;
132 edc->timestart = now;
133 return 1;
134 }
135 return 0;
136}
137
138/* Host-Device interface for USB */
139enum {
140 I2400MU_MAX_NOTIFICATION_LEN = 256,
141 I2400MU_BLK_SIZE = 16,
142 I2400MU_PL_SIZE_MAX = 0x3EFF,
143
144 /* Endpoints */
145 I2400MU_EP_BULK_OUT = 0,
146 I2400MU_EP_NOTIFICATION,
147 I2400MU_EP_RESET_COLD,
148 I2400MU_EP_BULK_IN,
149};
150
151
152/**
153 * struct i2400mu - descriptor for a USB connected i2400m
154 *
155 * @i2400m: bus-generic i2400m implementation; has to be first (see
156 * it's documentation in i2400m.h).
157 *
158 * @usb_dev: pointer to our USB device
159 *
160 * @usb_iface: pointer to our USB interface
161 *
162 * @urb_edc: error density counter; used to keep a density-on-time tab
163 * on how many soft (retryable or ignorable) errors we get. If we
164 * go over the threshold, we consider the bus transport is failing
165 * too much and reset.
166 *
167 * @notif_urb: URB for receiving notifications from the device.
168 *
169 * @tx_kthread: thread we use for data TX. We use a thread because in
170 * order to do deep power saving and put the device to sleep, we
171 * need to call usb_autopm_*() [blocking functions].
172 *
173 * @tx_wq: waitqueue for the TX kthread to sleep when there is no data
174 * to be sent; when more data is available, it is woken up by
175 * i2400mu_bus_tx_kick().
176 *
177 * @rx_kthread: thread we use for data RX. We use a thread because in
178 * order to do deep power saving and put the device to sleep, we
179 * need to call usb_autopm_*() [blocking functions].
180 *
181 * @rx_wq: waitqueue for the RX kthread to sleep when there is no data
182 * to receive. When data is available, it is woken up by
183 * usb-notif.c:i2400mu_notification_grok().
184 *
185 * @rx_pending_count: number of rx-data-ready notifications that were
186 * still not handled by the RX kthread.
187 *
188 * @rx_size: current RX buffer size that is being used.
189 *
190 * @rx_size_acc: accumulator of the sizes of the previous read
191 * transactions.
192 *
193 * @rx_size_cnt: number of read transactions accumulated in
194 * @rx_size_acc.
195 *
196 * @do_autopm: disable(0)/enable(>0) calling the
197 * usb_autopm_get/put_interface() barriers when executing
198 * commands. See doc in i2400mu_suspend() for more information.
199 *
200 * @rx_size_auto_shrink: if true, the rx_size is shrinked
201 * automatically based on the average size of the received
202 * transactions. This allows the receive code to allocate smaller
203 * chunks of memory and thus reduce pressure on the memory
204 * allocator by not wasting so much space. By default it is
205 * enabled.
206 *
207 * @debugfs_dentry: hookup for debugfs files.
208 * These have to be in a separate directory, a child of
209 * (wimax_dev->debugfs_dentry) so they can be removed when the
210 * module unloads, as we don't keep each dentry.
211 */
212struct i2400mu {
213 struct i2400m i2400m; /* FIRST! See doc */
214
215 struct usb_device *usb_dev;
216 struct usb_interface *usb_iface;
217 struct edc urb_edc; /* Error density counter */
218
219 struct urb *notif_urb;
220 struct task_struct *tx_kthread;
221 wait_queue_head_t tx_wq;
222
223 struct task_struct *rx_kthread;
224 wait_queue_head_t rx_wq;
225 atomic_t rx_pending_count;
226 size_t rx_size, rx_size_acc, rx_size_cnt;
227 atomic_t do_autopm;
228 u8 rx_size_auto_shrink;
229
230 struct dentry *debugfs_dentry;
231};
232
233
234static inline
235void i2400mu_init(struct i2400mu *i2400mu)
236{
237 i2400m_init(&i2400mu->i2400m);
238 edc_init(&i2400mu->urb_edc);
239 init_waitqueue_head(&i2400mu->tx_wq);
240 atomic_set(&i2400mu->rx_pending_count, 0);
241 init_waitqueue_head(&i2400mu->rx_wq);
242 i2400mu->rx_size = PAGE_SIZE - sizeof(struct skb_shared_info);
243 atomic_set(&i2400mu->do_autopm, 1);
244 i2400mu->rx_size_auto_shrink = 1;
245}
246
247extern int i2400mu_notification_setup(struct i2400mu *);
248extern void i2400mu_notification_release(struct i2400mu *);
249
250extern int i2400mu_rx_setup(struct i2400mu *);
251extern void i2400mu_rx_release(struct i2400mu *);
252extern void i2400mu_rx_kick(struct i2400mu *);
253
254extern int i2400mu_tx_setup(struct i2400mu *);
255extern void i2400mu_tx_release(struct i2400mu *);
256extern void i2400mu_bus_tx_kick(struct i2400m *);
257
258extern ssize_t i2400mu_bus_bm_cmd_send(struct i2400m *,
259 const struct i2400m_bootrom_header *,
260 size_t, int);
261extern ssize_t i2400mu_bus_bm_wait_for_ack(struct i2400m *,
262 struct i2400m_bootrom_header *,
263 size_t);
264#endif /* #ifndef __I2400M_USB_H__ */
diff --git a/drivers/net/wimax/i2400m/i2400m.h b/drivers/net/wimax/i2400m/i2400m.h
new file mode 100644
index 000000000000..067c871cc226
--- /dev/null
+++ b/drivers/net/wimax/i2400m/i2400m.h
@@ -0,0 +1,755 @@
1/*
2 * Intel Wireless WiMAX Connection 2400m
3 * Declarations for bus-generic internal APIs
4 *
5 *
6 * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 *
35 * Intel Corporation <linux-wimax@intel.com>
36 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
37 * Yanir Lubetkin <yanirx.lubetkin@intel.com>
38 * - Initial implementation
39 *
40 *
41 * GENERAL DRIVER ARCHITECTURE
42 *
43 * The i2400m driver is split in the following two major parts:
44 *
45 * - bus specific driver
46 * - bus generic driver (this part)
47 *
48 * The bus specific driver sets up stuff specific to the bus the
49 * device is connected to (USB, SDIO, PCI, tam-tam...non-authoritative
50 * nor binding list) which is basically the device-model management
51 * (probe/disconnect, etc), moving data from device to kernel and
52 * back, doing the power saving details and reseting the device.
53 *
54 * For details on each bus-specific driver, see it's include file,
55 * i2400m-BUSNAME.h
56 *
57 * The bus-generic functionality break up is:
58 *
59 * - Firmware upload: fw.c - takes care of uploading firmware to the
60 * device. bus-specific driver just needs to provides a way to
61 * execute boot-mode commands and to reset the device.
62 *
63 * - RX handling: rx.c - receives data from the bus-specific code and
64 * feeds it to the network or WiMAX stack or uses it to modify
65 * the driver state. bus-specific driver only has to receive
66 * frames and pass them to this module.
67 *
68 * - TX handling: tx.c - manages the TX FIFO queue and provides means
69 * for the bus-specific TX code to pull data from the FIFO
70 * queue. bus-specific code just pulls frames from this module
71 * to sends them to the device.
72 *
73 * - netdev glue: netdev.c - interface with Linux networking
74 * stack. Pass around data frames, and configure when the
75 * device is up and running or shutdown (through ifconfig up /
76 * down). Bus-generic only.
77 *
78 * - control ops: control.c - implements various commmands for
79 * controlling the device. bus-generic only.
80 *
81 * - device model glue: driver.c - implements helpers for the
82 * device-model glue done by the bus-specific layer
83 * (setup/release the driver resources), turning the device on
84 * and off, handling the device reboots/resets and a few simple
85 * WiMAX stack ops.
86 *
87 * Code is also broken up in linux-glue / device-glue.
88 *
89 * Linux glue contains functions that deal mostly with gluing with the
90 * rest of the Linux kernel.
91 *
92 * Device-glue are functions that deal mostly with the way the device
93 * does things and talk the device's language.
94 *
95 * device-glue code is licensed BSD so other open source OSes can take
96 * it to implement their drivers.
97 *
98 *
99 * APIs AND HEADER FILES
100 *
101 * This bus generic code exports three APIs:
102 *
103 * - HDI (host-device interface) definitions common to all busses
104 * (include/linux/wimax/i2400m.h); these can be also used by user
105 * space code.
106 * - internal API for the bus-generic code
107 * - external API for the bus-specific drivers
108 *
109 *
110 * LIFE CYCLE:
111 *
112 * When the bus-specific driver probes, it allocates a network device
113 * with enough space for it's data structue, that must contain a
114 * &struct i2400m at the top.
115 *
116 * On probe, it needs to fill the i2400m members marked as [fill], as
117 * well as i2400m->wimax_dev.net_dev and call i2400m_setup(). The
118 * i2400m driver will only register with the WiMAX and network stacks;
119 * the only access done to the device is to read the MAC address so we
120 * can register a network device. This calls i2400m_dev_start() to
121 * load firmware, setup communication with the device and configure it
122 * for operation.
123 *
124 * At this point, control and data communications are possible.
125 *
126 * On disconnect/driver unload, the bus-specific disconnect function
127 * calls i2400m_release() to undo i2400m_setup(). i2400m_dev_stop()
128 * shuts the firmware down and releases resources uses to communicate
129 * with the device.
130 *
131 * While the device is up, it might reset. The bus-specific driver has
132 * to catch that situation and call i2400m_dev_reset_handle() to deal
133 * with it (reset the internal driver structures and go back to square
134 * one).
135 */
136
137#ifndef __I2400M_H__
138#define __I2400M_H__
139
140#include <linux/usb.h>
141#include <linux/netdevice.h>
142#include <linux/completion.h>
143#include <linux/rwsem.h>
144#include <asm/atomic.h>
145#include <net/wimax.h>
146#include <linux/wimax/i2400m.h>
147#include <asm/byteorder.h>
148
149/* Misc constants */
150enum {
151 /* Firmware uploading */
152 I2400M_BOOT_RETRIES = 3,
153 /* Size of the Boot Mode Command buffer */
154 I2400M_BM_CMD_BUF_SIZE = 16 * 1024,
155 I2400M_BM_ACK_BUF_SIZE = 256,
156};
157
158
159/* Firmware version we request when pulling the fw image file */
160#define I2400M_FW_VERSION "1.3"
161
162
163/**
164 * i2400m_reset_type - methods to reset a device
165 *
166 * @I2400M_RT_WARM: Reset without device disconnection, device handles
167 * are kept valid but state is back to power on, with firmware
168 * re-uploaded.
169 * @I2400M_RT_COLD: Tell the device to disconnect itself from the bus
170 * and reconnect. Renders all device handles invalid.
171 * @I2400M_RT_BUS: Tells the bus to reset the device; last measure
172 * used when both types above don't work.
173 */
174enum i2400m_reset_type {
175 I2400M_RT_WARM, /* first measure */
176 I2400M_RT_COLD, /* second measure */
177 I2400M_RT_BUS, /* call in artillery */
178};
179
180struct i2400m_reset_ctx;
181
182/**
183 * struct i2400m - descriptor for an Intel 2400m
184 *
185 * Members marked with [fill] must be filled out/initialized before
186 * calling i2400m_setup().
187 *
188 * @bus_tx_block_size: [fill] SDIO imposes a 256 block size, USB 16,
189 * so we have a tx_blk_size variable that the bus layer sets to
190 * tell the engine how much of that we need.
191 *
192 * @bus_pl_size_max: [fill] Maximum payload size.
193 *
194 * @bus_dev_start: [fill] Function called by the bus-generic code
195 * [i2400m_dev_start()] to setup the bus-specific communications
196 * to the the device. See LIFE CYCLE above.
197 *
198 * NOTE: Doesn't need to upload the firmware, as that is taken
199 * care of by the bus-generic code.
200 *
201 * @bus_dev_stop: [fill] Function called by the bus-generic code
202 * [i2400m_dev_stop()] to shutdown the bus-specific communications
203 * to the the device. See LIFE CYCLE above.
204 *
205 * This function does not need to reset the device, just tear down
206 * all the host resources created to handle communication with
207 * the device.
208 *
209 * @bus_tx_kick: [fill] Function called by the bus-generic code to let
210 * the bus-specific code know that there is data available in the
211 * TX FIFO for transmission to the device.
212 *
213 * This function cannot sleep.
214 *
215 * @bus_reset: [fill] Function called by the bus-generic code to reset
216 * the device in in various ways. Doesn't need to wait for the
217 * reset to finish.
218 *
219 * If warm or cold reset fail, this function is expected to do a
220 * bus-specific reset (eg: USB reset) to get the device to a
221 * working state (even if it implies device disconecction).
222 *
223 * Note the warm reset is used by the firmware uploader to
224 * reinitialize the device.
225 *
226 * IMPORTANT: this is called very early in the device setup
227 * process, so it cannot rely on common infrastructure being laid
228 * out.
229 *
230 * @bus_bm_cmd_send: [fill] Function called to send a boot-mode
231 * command. Flags are defined in 'enum i2400m_bm_cmd_flags'. This
232 * is synchronous and has to return 0 if ok or < 0 errno code in
233 * any error condition.
234 *
235 * @bus_bm_wait_for_ack: [fill] Function called to wait for a
236 * boot-mode notification (that can be a response to a previously
237 * issued command or an asynchronous one). Will read until all the
238 * indicated size is read or timeout. Reading more or less data
239 * than asked for is an error condition. Return 0 if ok, < 0 errno
240 * code on error.
241 *
242 * The caller to this function will check if the response is a
243 * barker that indicates the device going into reset mode.
244 *
245 * @bus_fw_name: [fill] name of the firmware image (in most cases,
246 * they are all the same for a single release, except that they
247 * have the type of the bus embedded in the name (eg:
248 * i2400m-fw-X-VERSION.sbcf, where X is the bus name).
249 *
250 * @bus_bm_mac_addr_impaired: [fill] Set to true if the device's MAC
251 * address provided in boot mode is kind of broken and needs to
252 * be re-read later on.
253 *
254 *
255 * @wimax_dev: WiMAX generic device for linkage into the kernel WiMAX
256 * stack. Due to the way a net_device is allocated, we need to
257 * force this to be the first field so that we can get from
258 * netdev_priv() the right pointer.
259 *
260 * @state: device's state (as reported by it)
261 *
262 * @state_wq: waitqueue that is woken up whenever the state changes
263 *
264 * @tx_lock: spinlock to protect TX members
265 *
266 * @tx_buf: FIFO buffer for TX; we queue data here
267 *
268 * @tx_in: FIFO index for incoming data. Note this doesn't wrap around
269 * and it is always greater than @tx_out.
270 *
271 * @tx_out: FIFO index for outgoing data
272 *
273 * @tx_msg: current TX message that is active in the FIFO for
274 * appending payloads.
275 *
276 * @tx_sequence: current sequence number for TX messages from the
277 * device to the host.
278 *
279 * @tx_msg_size: size of the current message being transmitted by the
280 * bus-specific code.
281 *
282 * @tx_pl_num: total number of payloads sent
283 *
284 * @tx_pl_max: maximum number of payloads sent in a TX message
285 *
286 * @tx_pl_min: minimum number of payloads sent in a TX message
287 *
288 * @tx_num: number of TX messages sent
289 *
290 * @tx_size_acc: number of bytes in all TX messages sent
291 * (this is different to net_dev's statistics as it also counts
292 * control messages).
293 *
294 * @tx_size_min: smallest TX message sent.
295 *
296 * @tx_size_max: biggest TX message sent.
297 *
298 * @rx_lock: spinlock to protect RX members
299 *
300 * @rx_pl_num: total number of payloads received
301 *
302 * @rx_pl_max: maximum number of payloads received in a RX message
303 *
304 * @rx_pl_min: minimum number of payloads received in a RX message
305 *
306 * @rx_num: number of RX messages received
307 *
308 * @rx_size_acc: number of bytes in all RX messages received
309 * (this is different to net_dev's statistics as it also counts
310 * control messages).
311 *
312 * @rx_size_min: smallest RX message received.
313 *
314 * @rx_size_max: buggest RX message received.
315 *
316 * @init_mutex: Mutex used for serializing the device bringup
317 * sequence; this way if the device reboots in the middle, we
318 * don't try to do a bringup again while we are tearing down the
319 * one that failed.
320 *
321 * Can't reuse @msg_mutex because from within the bringup sequence
322 * we need to send messages to the device and thus use @msg_mutex.
323 *
324 * @msg_mutex: mutex used to send control commands to the device (we
325 * only allow one at a time, per host-device interface design).
326 *
327 * @msg_completion: used to wait for an ack to a control command sent
328 * to the device.
329 *
330 * @ack_skb: used to store the actual ack to a control command if the
331 * reception of the command was successful. Otherwise, a ERR_PTR()
332 * errno code that indicates what failed with the ack reception.
333 *
334 * Only valid after @msg_completion is woken up. Only updateable
335 * if @msg_completion is armed. Only touched by
336 * i2400m_msg_to_dev().
337 *
338 * Protected by @rx_lock. In theory the command execution flow is
339 * sequential, but in case the device sends an out-of-phase or
340 * very delayed response, we need to avoid it trampling current
341 * execution.
342 *
343 * @bm_cmd_buf: boot mode command buffer for composing firmware upload
344 * commands.
345 *
346 * USB can't r/w to stack, vmalloc, etc...as well, we end up
347 * having to alloc/free a lot to compose commands, so we use these
348 * for stagging and not having to realloc all the time.
349 *
350 * This assumes the code always runs serialized. Only one thread
351 * can call i2400m_bm_cmd() at the same time.
352 *
353 * @bm_ack_buf: boot mode acknoledge buffer for staging reception of
354 * responses to commands.
355 *
356 * See @bm_cmd_buf.
357 *
358 * @work_queue: work queue for processing device reports. This
359 * workqueue cannot be used for processing TX or RX to the device,
360 * as from it we'll process device reports, which might require
361 * further communication with the device.
362 *
363 * @debugfs_dentry: hookup for debugfs files.
364 * These have to be in a separate directory, a child of
365 * (wimax_dev->debugfs_dentry) so they can be removed when the
366 * module unloads, as we don't keep each dentry.
367 */
368struct i2400m {
369 struct wimax_dev wimax_dev; /* FIRST! See doc */
370
371 unsigned updown:1; /* Network device is up or down */
372 unsigned boot_mode:1; /* is the device in boot mode? */
373 unsigned sboot:1; /* signed or unsigned fw boot */
374 unsigned ready:1; /* all probing steps done */
375 u8 trace_msg_from_user; /* echo rx msgs to 'trace' pipe */
376 /* typed u8 so debugfs/u8 can tweak */
377 enum i2400m_system_state state;
378 wait_queue_head_t state_wq; /* Woken up when on state updates */
379
380 size_t bus_tx_block_size;
381 size_t bus_pl_size_max;
382 int (*bus_dev_start)(struct i2400m *);
383 void (*bus_dev_stop)(struct i2400m *);
384 void (*bus_tx_kick)(struct i2400m *);
385 int (*bus_reset)(struct i2400m *, enum i2400m_reset_type);
386 ssize_t (*bus_bm_cmd_send)(struct i2400m *,
387 const struct i2400m_bootrom_header *,
388 size_t, int flags);
389 ssize_t (*bus_bm_wait_for_ack)(struct i2400m *,
390 struct i2400m_bootrom_header *, size_t);
391 const char *bus_fw_name;
392 unsigned bus_bm_mac_addr_impaired:1;
393
394 spinlock_t tx_lock; /* protect TX state */
395 void *tx_buf;
396 size_t tx_in, tx_out;
397 struct i2400m_msg_hdr *tx_msg;
398 size_t tx_sequence, tx_msg_size;
399 /* TX stats */
400 unsigned tx_pl_num, tx_pl_max, tx_pl_min,
401 tx_num, tx_size_acc, tx_size_min, tx_size_max;
402
403 /* RX stats */
404 spinlock_t rx_lock; /* protect RX state */
405 unsigned rx_pl_num, rx_pl_max, rx_pl_min,
406 rx_num, rx_size_acc, rx_size_min, rx_size_max;
407
408 struct mutex msg_mutex; /* serialize command execution */
409 struct completion msg_completion;
410 struct sk_buff *ack_skb; /* protected by rx_lock */
411
412 void *bm_ack_buf; /* for receiving acks over USB */
413 void *bm_cmd_buf; /* for issuing commands over USB */
414
415 struct workqueue_struct *work_queue;
416
417 struct mutex init_mutex; /* protect bringup seq */
418 struct i2400m_reset_ctx *reset_ctx; /* protected by init_mutex */
419
420 struct work_struct wake_tx_ws;
421 struct sk_buff *wake_tx_skb;
422
423 struct dentry *debugfs_dentry;
424};
425
426
427/*
428 * Initialize a 'struct i2400m' from all zeroes
429 *
430 * This is a bus-generic API call.
431 */
432static inline
433void i2400m_init(struct i2400m *i2400m)
434{
435 wimax_dev_init(&i2400m->wimax_dev);
436
437 i2400m->boot_mode = 1;
438 init_waitqueue_head(&i2400m->state_wq);
439
440 spin_lock_init(&i2400m->tx_lock);
441 i2400m->tx_pl_min = UINT_MAX;
442 i2400m->tx_size_min = UINT_MAX;
443
444 spin_lock_init(&i2400m->rx_lock);
445 i2400m->rx_pl_min = UINT_MAX;
446 i2400m->rx_size_min = UINT_MAX;
447
448 mutex_init(&i2400m->msg_mutex);
449 init_completion(&i2400m->msg_completion);
450
451 mutex_init(&i2400m->init_mutex);
452 /* wake_tx_ws is initialized in i2400m_tx_setup() */
453}
454
455
456/*
457 * Bus-generic internal APIs
458 * -------------------------
459 */
460
461static inline
462struct i2400m *wimax_dev_to_i2400m(struct wimax_dev *wimax_dev)
463{
464 return container_of(wimax_dev, struct i2400m, wimax_dev);
465}
466
467static inline
468struct i2400m *net_dev_to_i2400m(struct net_device *net_dev)
469{
470 return wimax_dev_to_i2400m(netdev_priv(net_dev));
471}
472
473/*
474 * Boot mode support
475 */
476
477/**
478 * i2400m_bm_cmd_flags - flags to i2400m_bm_cmd()
479 *
480 * @I2400M_BM_CMD_RAW: send the command block as-is, without doing any
481 * extra processing for adding CRC.
482 */
483enum i2400m_bm_cmd_flags {
484 I2400M_BM_CMD_RAW = 1 << 2,
485};
486
487/**
488 * i2400m_bri - Boot-ROM indicators
489 *
490 * Flags for i2400m_bootrom_init() and i2400m_dev_bootstrap() [which
491 * are passed from things like i2400m_setup()]. Can be combined with
492 * |.
493 *
494 * @I2400M_BRI_SOFT: The device rebooted already and a reboot
495 * barker received, proceed directly to ack the boot sequence.
496 * @I2400M_BRI_NO_REBOOT: Do not reboot the device and proceed
497 * directly to wait for a reboot barker from the device.
498 * @I2400M_BRI_MAC_REINIT: We need to reinitialize the boot
499 * rom after reading the MAC adress. This is quite a dirty hack,
500 * if you ask me -- the device requires the bootrom to be
501 * intialized after reading the MAC address.
502 */
503enum i2400m_bri {
504 I2400M_BRI_SOFT = 1 << 1,
505 I2400M_BRI_NO_REBOOT = 1 << 2,
506 I2400M_BRI_MAC_REINIT = 1 << 3,
507};
508
509extern void i2400m_bm_cmd_prepare(struct i2400m_bootrom_header *);
510extern int i2400m_dev_bootstrap(struct i2400m *, enum i2400m_bri);
511extern int i2400m_read_mac_addr(struct i2400m *);
512extern int i2400m_bootrom_init(struct i2400m *, enum i2400m_bri);
513
514/* Make/grok boot-rom header commands */
515
516static inline
517__le32 i2400m_brh_command(enum i2400m_brh_opcode opcode, unsigned use_checksum,
518 unsigned direct_access)
519{
520 return cpu_to_le32(
521 I2400M_BRH_SIGNATURE
522 | (direct_access ? I2400M_BRH_DIRECT_ACCESS : 0)
523 | I2400M_BRH_RESPONSE_REQUIRED /* response always required */
524 | (use_checksum ? I2400M_BRH_USE_CHECKSUM : 0)
525 | (opcode & I2400M_BRH_OPCODE_MASK));
526}
527
528static inline
529void i2400m_brh_set_opcode(struct i2400m_bootrom_header *hdr,
530 enum i2400m_brh_opcode opcode)
531{
532 hdr->command = cpu_to_le32(
533 (le32_to_cpu(hdr->command) & ~I2400M_BRH_OPCODE_MASK)
534 | (opcode & I2400M_BRH_OPCODE_MASK));
535}
536
537static inline
538unsigned i2400m_brh_get_opcode(const struct i2400m_bootrom_header *hdr)
539{
540 return le32_to_cpu(hdr->command) & I2400M_BRH_OPCODE_MASK;
541}
542
543static inline
544unsigned i2400m_brh_get_response(const struct i2400m_bootrom_header *hdr)
545{
546 return (le32_to_cpu(hdr->command) & I2400M_BRH_RESPONSE_MASK)
547 >> I2400M_BRH_RESPONSE_SHIFT;
548}
549
550static inline
551unsigned i2400m_brh_get_use_checksum(const struct i2400m_bootrom_header *hdr)
552{
553 return le32_to_cpu(hdr->command) & I2400M_BRH_USE_CHECKSUM;
554}
555
556static inline
557unsigned i2400m_brh_get_response_required(
558 const struct i2400m_bootrom_header *hdr)
559{
560 return le32_to_cpu(hdr->command) & I2400M_BRH_RESPONSE_REQUIRED;
561}
562
563static inline
564unsigned i2400m_brh_get_direct_access(const struct i2400m_bootrom_header *hdr)
565{
566 return le32_to_cpu(hdr->command) & I2400M_BRH_DIRECT_ACCESS;
567}
568
569static inline
570unsigned i2400m_brh_get_signature(const struct i2400m_bootrom_header *hdr)
571{
572 return (le32_to_cpu(hdr->command) & I2400M_BRH_SIGNATURE_MASK)
573 >> I2400M_BRH_SIGNATURE_SHIFT;
574}
575
576
577/*
578 * Driver / device setup and internal functions
579 */
580extern void i2400m_netdev_setup(struct net_device *net_dev);
581extern int i2400m_tx_setup(struct i2400m *);
582extern void i2400m_wake_tx_work(struct work_struct *);
583extern void i2400m_tx_release(struct i2400m *);
584
585extern void i2400m_net_rx(struct i2400m *, struct sk_buff *, unsigned,
586 const void *, int);
587enum i2400m_pt;
588extern int i2400m_tx(struct i2400m *, const void *, size_t, enum i2400m_pt);
589
590#ifdef CONFIG_DEBUG_FS
591extern int i2400m_debugfs_add(struct i2400m *);
592extern void i2400m_debugfs_rm(struct i2400m *);
593#else
594static inline int i2400m_debugfs_add(struct i2400m *i2400m)
595{
596 return 0;
597}
598static inline void i2400m_debugfs_rm(struct i2400m *i2400m) {}
599#endif
600
601/* Called by _dev_start()/_dev_stop() to initialize the device itself */
602extern int i2400m_dev_initialize(struct i2400m *);
603extern void i2400m_dev_shutdown(struct i2400m *);
604
605extern struct attribute_group i2400m_dev_attr_group;
606
607extern int i2400m_schedule_work(struct i2400m *,
608 void (*)(struct work_struct *), gfp_t);
609
610/* HDI message's payload description handling */
611
612static inline
613size_t i2400m_pld_size(const struct i2400m_pld *pld)
614{
615 return I2400M_PLD_SIZE_MASK & le32_to_cpu(pld->val);
616}
617
618static inline
619enum i2400m_pt i2400m_pld_type(const struct i2400m_pld *pld)
620{
621 return (I2400M_PLD_TYPE_MASK & le32_to_cpu(pld->val))
622 >> I2400M_PLD_TYPE_SHIFT;
623}
624
625static inline
626void i2400m_pld_set(struct i2400m_pld *pld, size_t size,
627 enum i2400m_pt type)
628{
629 pld->val = cpu_to_le32(
630 ((type << I2400M_PLD_TYPE_SHIFT) & I2400M_PLD_TYPE_MASK)
631 | (size & I2400M_PLD_SIZE_MASK));
632}
633
634
635/*
636 * API for the bus-specific drivers
637 * --------------------------------
638 */
639
640static inline
641struct i2400m *i2400m_get(struct i2400m *i2400m)
642{
643 dev_hold(i2400m->wimax_dev.net_dev);
644 return i2400m;
645}
646
647static inline
648void i2400m_put(struct i2400m *i2400m)
649{
650 dev_put(i2400m->wimax_dev.net_dev);
651}
652
653extern int i2400m_dev_reset_handle(struct i2400m *);
654
655/*
656 * _setup()/_release() are called by the probe/disconnect functions of
657 * the bus-specific drivers.
658 */
659extern int i2400m_setup(struct i2400m *, enum i2400m_bri bm_flags);
660extern void i2400m_release(struct i2400m *);
661
662extern int i2400m_rx(struct i2400m *, struct sk_buff *);
663extern struct i2400m_msg_hdr *i2400m_tx_msg_get(struct i2400m *, size_t *);
664extern void i2400m_tx_msg_sent(struct i2400m *);
665
666static const __le32 i2400m_NBOOT_BARKER[4] = {
667 __constant_cpu_to_le32(I2400M_NBOOT_BARKER),
668 __constant_cpu_to_le32(I2400M_NBOOT_BARKER),
669 __constant_cpu_to_le32(I2400M_NBOOT_BARKER),
670 __constant_cpu_to_le32(I2400M_NBOOT_BARKER)
671};
672
673static const __le32 i2400m_SBOOT_BARKER[4] = {
674 __constant_cpu_to_le32(I2400M_SBOOT_BARKER),
675 __constant_cpu_to_le32(I2400M_SBOOT_BARKER),
676 __constant_cpu_to_le32(I2400M_SBOOT_BARKER),
677 __constant_cpu_to_le32(I2400M_SBOOT_BARKER)
678};
679
680
681/*
682 * Utility functions
683 */
684
685static inline
686struct device *i2400m_dev(struct i2400m *i2400m)
687{
688 return i2400m->wimax_dev.net_dev->dev.parent;
689}
690
691/*
692 * Helper for scheduling simple work functions
693 *
694 * This struct can get any kind of payload attached (normally in the
695 * form of a struct where you pack the stuff you want to pass to the
696 * _work function).
697 */
698struct i2400m_work {
699 struct work_struct ws;
700 struct i2400m *i2400m;
701 u8 pl[0];
702};
703extern int i2400m_queue_work(struct i2400m *,
704 void (*)(struct work_struct *), gfp_t,
705 const void *, size_t);
706
707extern int i2400m_msg_check_status(const struct i2400m_l3l4_hdr *,
708 char *, size_t);
709extern int i2400m_msg_size_check(struct i2400m *,
710 const struct i2400m_l3l4_hdr *, size_t);
711extern struct sk_buff *i2400m_msg_to_dev(struct i2400m *, const void *, size_t);
712extern void i2400m_msg_to_dev_cancel_wait(struct i2400m *, int);
713extern void i2400m_msg_ack_hook(struct i2400m *,
714 const struct i2400m_l3l4_hdr *, size_t);
715extern void i2400m_report_hook(struct i2400m *,
716 const struct i2400m_l3l4_hdr *, size_t);
717extern int i2400m_cmd_enter_powersave(struct i2400m *);
718extern int i2400m_cmd_get_state(struct i2400m *);
719extern int i2400m_cmd_exit_idle(struct i2400m *);
720extern struct sk_buff *i2400m_get_device_info(struct i2400m *);
721extern int i2400m_firmware_check(struct i2400m *);
722extern int i2400m_set_init_config(struct i2400m *,
723 const struct i2400m_tlv_hdr **, size_t);
724
725static inline
726struct usb_endpoint_descriptor *usb_get_epd(struct usb_interface *iface, int ep)
727{
728 return &iface->cur_altsetting->endpoint[ep].desc;
729}
730
731extern int i2400m_op_rfkill_sw_toggle(struct wimax_dev *,
732 enum wimax_rf_state);
733extern void i2400m_report_tlv_rf_switches_status(
734 struct i2400m *, const struct i2400m_tlv_rf_switches_status *);
735
736
737/*
738 * Do a millisecond-sleep for allowing wireshark to dump all the data
739 * packets. Used only for debugging.
740 */
741static inline
742void __i2400m_msleep(unsigned ms)
743{
744#if 1
745#else
746 msleep(ms);
747#endif
748}
749
750/* Module parameters */
751
752extern int i2400m_idle_mode_disabled;
753
754
755#endif /* #ifndef __I2400M_H__ */
diff --git a/drivers/net/wimax/i2400m/netdev.c b/drivers/net/wimax/i2400m/netdev.c
new file mode 100644
index 000000000000..63fe708e8a31
--- /dev/null
+++ b/drivers/net/wimax/i2400m/netdev.c
@@ -0,0 +1,524 @@
1/*
2 * Intel Wireless WiMAX Connection 2400m
3 * Glue with the networking stack
4 *
5 *
6 * Copyright (C) 2007 Intel Corporation <linux-wimax@intel.com>
7 * Yanir Lubetkin <yanirx.lubetkin@intel.com>
8 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License version
12 * 2 as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 * 02110-1301, USA.
23 *
24 *
25 * This implements an ethernet device for the i2400m.
26 *
27 * We fake being an ethernet device to simplify the support from user
28 * space and from the other side. The world is (sadly) configured to
29 * take in only Ethernet devices...
30 *
31 * Because of this, currently there is an copy-each-rxed-packet
32 * overhead on the RX path. Each IP packet has to be reallocated to
33 * add an ethernet header (as there is no space in what we get from
34 * the device). This is a known drawback and coming versions of the
35 * device's firmware are being changed to add header space that can be
36 * used to insert the ethernet header without having to reallocate and
37 * copy.
38 *
39 * TX error handling is tricky; because we have to FIFO/queue the
40 * buffers for transmission (as the hardware likes it aggregated), we
41 * just give the skb to the TX subsystem and by the time it is
42 * transmitted, we have long forgotten about it. So we just don't care
43 * too much about it.
44 *
45 * Note that when the device is in idle mode with the basestation, we
46 * need to negotiate coming back up online. That involves negotiation
47 * and possible user space interaction. Thus, we defer to a workqueue
48 * to do all that. By default, we only queue a single packet and drop
49 * the rest, as potentially the time to go back from idle to normal is
50 * long.
51 *
52 * ROADMAP
53 *
54 * i2400m_open Called on ifconfig up
55 * i2400m_stop Called on ifconfig down
56 *
57 * i2400m_hard_start_xmit Called by the network stack to send a packet
58 * i2400m_net_wake_tx Wake up device from basestation-IDLE & TX
59 * i2400m_wake_tx_work
60 * i2400m_cmd_exit_idle
61 * i2400m_tx
62 * i2400m_net_tx TX a data frame
63 * i2400m_tx
64 *
65 * i2400m_change_mtu Called on ifconfig mtu XXX
66 *
67 * i2400m_tx_timeout Called when the device times out
68 *
69 * i2400m_net_rx Called by the RX code when a data frame is
70 * available.
71 * i2400m_netdev_setup Called to setup all the netdev stuff from
72 * alloc_netdev.
73 */
74#include <linux/if_arp.h>
75#include <linux/netdevice.h>
76#include "i2400m.h"
77
78
79#define D_SUBMODULE netdev
80#include "debug-levels.h"
81
82enum {
83/* netdev interface */
84 /*
85 * Out of NWG spec (R1_v1.2.2), 3.3.3 ASN Bearer Plane MTU Size
86 *
87 * The MTU is 1400 or less
88 */
89 I2400M_MAX_MTU = 1400,
90 I2400M_TX_TIMEOUT = HZ,
91 I2400M_TX_QLEN = 5,
92};
93
94
95static
96int i2400m_open(struct net_device *net_dev)
97{
98 int result;
99 struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
100 struct device *dev = i2400m_dev(i2400m);
101
102 d_fnstart(3, dev, "(net_dev %p [i2400m %p])\n", net_dev, i2400m);
103 if (i2400m->ready == 0) {
104 dev_err(dev, "Device is still initializing\n");
105 result = -EBUSY;
106 } else
107 result = 0;
108 d_fnend(3, dev, "(net_dev %p [i2400m %p]) = %d\n",
109 net_dev, i2400m, result);
110 return result;
111}
112
113
114/*
115 *
116 * On kernel versions where cancel_work_sync() didn't return anything,
117 * we rely on wake_tx_skb() being non-NULL.
118 */
119static
120int i2400m_stop(struct net_device *net_dev)
121{
122 struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
123 struct device *dev = i2400m_dev(i2400m);
124
125 d_fnstart(3, dev, "(net_dev %p [i2400m %p])\n", net_dev, i2400m);
126 /* See i2400m_hard_start_xmit(), references are taken there
127 * and here we release them if the work was still
128 * pending. Note we can't differentiate work not pending vs
129 * never scheduled, so the NULL check does that. */
130 if (cancel_work_sync(&i2400m->wake_tx_ws) == 0
131 && i2400m->wake_tx_skb != NULL) {
132 unsigned long flags;
133 struct sk_buff *wake_tx_skb;
134 spin_lock_irqsave(&i2400m->tx_lock, flags);
135 wake_tx_skb = i2400m->wake_tx_skb; /* compat help */
136 i2400m->wake_tx_skb = NULL; /* compat help */
137 spin_unlock_irqrestore(&i2400m->tx_lock, flags);
138 i2400m_put(i2400m);
139 kfree_skb(wake_tx_skb);
140 }
141 d_fnend(3, dev, "(net_dev %p [i2400m %p]) = 0\n", net_dev, i2400m);
142 return 0;
143}
144
145
146/*
147 * Wake up the device and transmit a held SKB, then restart the net queue
148 *
149 * When the device goes into basestation-idle mode, we need to tell it
150 * to exit that mode; it will negotiate with the base station, user
151 * space may have to intervene to rehandshake crypto and then tell us
152 * when it is ready to transmit the packet we have "queued". Still we
153 * need to give it sometime after it reports being ok.
154 *
155 * On error, there is not much we can do. If the error was on TX, we
156 * still wake the queue up to see if the next packet will be luckier.
157 *
158 * If _cmd_exit_idle() fails...well, it could be many things; most
159 * commonly it is that something else took the device out of IDLE mode
160 * (for example, the base station). In that case we get an -EILSEQ and
161 * we are just going to ignore that one. If the device is back to
162 * connected, then fine -- if it is someother state, the packet will
163 * be dropped anyway.
164 */
165void i2400m_wake_tx_work(struct work_struct *ws)
166{
167 int result;
168 struct i2400m *i2400m = container_of(ws, struct i2400m, wake_tx_ws);
169 struct device *dev = i2400m_dev(i2400m);
170 struct sk_buff *skb = i2400m->wake_tx_skb;
171 unsigned long flags;
172
173 spin_lock_irqsave(&i2400m->tx_lock, flags);
174 skb = i2400m->wake_tx_skb;
175 i2400m->wake_tx_skb = NULL;
176 spin_unlock_irqrestore(&i2400m->tx_lock, flags);
177
178 d_fnstart(3, dev, "(ws %p i2400m %p skb %p)\n", ws, i2400m, skb);
179 result = -EINVAL;
180 if (skb == NULL) {
181 dev_err(dev, "WAKE&TX: skb dissapeared!\n");
182 goto out_put;
183 }
184 result = i2400m_cmd_exit_idle(i2400m);
185 if (result == -EILSEQ)
186 result = 0;
187 if (result < 0) {
188 dev_err(dev, "WAKE&TX: device didn't get out of idle: "
189 "%d\n", result);
190 goto error;
191 }
192 result = wait_event_timeout(i2400m->state_wq,
193 i2400m->state != I2400M_SS_IDLE, 5 * HZ);
194 if (result == 0)
195 result = -ETIMEDOUT;
196 if (result < 0) {
197 dev_err(dev, "WAKE&TX: error waiting for device to exit IDLE: "
198 "%d\n", result);
199 goto error;
200 }
201 msleep(20); /* device still needs some time or it drops it */
202 result = i2400m_tx(i2400m, skb->data, skb->len, I2400M_PT_DATA);
203 netif_wake_queue(i2400m->wimax_dev.net_dev);
204error:
205 kfree_skb(skb); /* refcount transferred by _hard_start_xmit() */
206out_put:
207 i2400m_put(i2400m);
208 d_fnend(3, dev, "(ws %p i2400m %p skb %p) = void [%d]\n",
209 ws, i2400m, skb, result);
210}
211
212
213/*
214 * Prepare the data payload TX header
215 *
216 * The i2400m expects a 4 byte header in front of a data packet.
217 *
218 * Because we pretend to be an ethernet device, this packet comes with
219 * an ethernet header. Pull it and push our header.
220 */
221static
222void i2400m_tx_prep_header(struct sk_buff *skb)
223{
224 struct i2400m_pl_data_hdr *pl_hdr;
225 skb_pull(skb, ETH_HLEN);
226 pl_hdr = (struct i2400m_pl_data_hdr *) skb_push(skb, sizeof(*pl_hdr));
227 pl_hdr->reserved = 0;
228}
229
230
231/*
232 * TX an skb to an idle device
233 *
234 * When the device is in basestation-idle mode, we need to wake it up
235 * and then TX. So we queue a work_struct for doing so.
236 *
237 * We need to get an extra ref for the skb (so it is not dropped), as
238 * well as be careful not to queue more than one request (won't help
239 * at all). If more than one request comes or there are errors, we
240 * just drop the packets (see i2400m_hard_start_xmit()).
241 */
242static
243int i2400m_net_wake_tx(struct i2400m *i2400m, struct net_device *net_dev,
244 struct sk_buff *skb)
245{
246 int result;
247 struct device *dev = i2400m_dev(i2400m);
248 unsigned long flags;
249
250 d_fnstart(3, dev, "(skb %p net_dev %p)\n", skb, net_dev);
251 if (net_ratelimit()) {
252 d_printf(3, dev, "WAKE&NETTX: "
253 "skb %p sending %d bytes to radio\n",
254 skb, skb->len);
255 d_dump(4, dev, skb->data, skb->len);
256 }
257 /* We hold a ref count for i2400m and skb, so when
258 * stopping() the device, we need to cancel that work
259 * and if pending, release those resources. */
260 result = 0;
261 spin_lock_irqsave(&i2400m->tx_lock, flags);
262 if (!work_pending(&i2400m->wake_tx_ws)) {
263 netif_stop_queue(net_dev);
264 i2400m_get(i2400m);
265 i2400m->wake_tx_skb = skb_get(skb); /* transfer ref count */
266 i2400m_tx_prep_header(skb);
267 result = schedule_work(&i2400m->wake_tx_ws);
268 WARN_ON(result == 0);
269 }
270 spin_unlock_irqrestore(&i2400m->tx_lock, flags);
271 if (result == 0) {
272 /* Yes, this happens even if we stopped the
273 * queue -- blame the queue disciplines that
274 * queue without looking -- I guess there is a reason
275 * for that. */
276 if (net_ratelimit())
277 d_printf(1, dev, "NETTX: device exiting idle, "
278 "dropping skb %p, queue running %d\n",
279 skb, netif_queue_stopped(net_dev));
280 result = -EBUSY;
281 }
282 d_fnend(3, dev, "(skb %p net_dev %p) = %d\n", skb, net_dev, result);
283 return result;
284}
285
286
287/*
288 * Transmit a packet to the base station on behalf of the network stack.
289 *
290 * Returns: 0 if ok, < 0 errno code on error.
291 *
292 * We need to pull the ethernet header and add the hardware header,
293 * which is currently set to all zeroes and reserved.
294 */
295static
296int i2400m_net_tx(struct i2400m *i2400m, struct net_device *net_dev,
297 struct sk_buff *skb)
298{
299 int result;
300 struct device *dev = i2400m_dev(i2400m);
301
302 d_fnstart(3, dev, "(i2400m %p net_dev %p skb %p)\n",
303 i2400m, net_dev, skb);
304 /* FIXME: check eth hdr, only IPv4 is routed by the device as of now */
305 net_dev->trans_start = jiffies;
306 i2400m_tx_prep_header(skb);
307 d_printf(3, dev, "NETTX: skb %p sending %d bytes to radio\n",
308 skb, skb->len);
309 d_dump(4, dev, skb->data, skb->len);
310 result = i2400m_tx(i2400m, skb->data, skb->len, I2400M_PT_DATA);
311 d_fnend(3, dev, "(i2400m %p net_dev %p skb %p) = %d\n",
312 i2400m, net_dev, skb, result);
313 return result;
314}
315
316
317/*
318 * Transmit a packet to the base station on behalf of the network stack
319 *
320 *
321 * Returns: NETDEV_TX_OK (always, even in case of error)
322 *
323 * In case of error, we just drop it. Reasons:
324 *
325 * - we add a hw header to each skb, and if the network stack
326 * retries, we have no way to know if that skb has it or not.
327 *
328 * - network protocols have their own drop-recovery mechanisms
329 *
330 * - there is not much else we can do
331 *
332 * If the device is idle, we need to wake it up; that is an operation
333 * that will sleep. See i2400m_net_wake_tx() for details.
334 */
335static
336int i2400m_hard_start_xmit(struct sk_buff *skb,
337 struct net_device *net_dev)
338{
339 int result;
340 struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
341 struct device *dev = i2400m_dev(i2400m);
342
343 d_fnstart(3, dev, "(skb %p net_dev %p)\n", skb, net_dev);
344 if (i2400m->state == I2400M_SS_IDLE)
345 result = i2400m_net_wake_tx(i2400m, net_dev, skb);
346 else
347 result = i2400m_net_tx(i2400m, net_dev, skb);
348 if (result < 0)
349 net_dev->stats.tx_dropped++;
350 else {
351 net_dev->stats.tx_packets++;
352 net_dev->stats.tx_bytes += skb->len;
353 }
354 kfree_skb(skb);
355 result = NETDEV_TX_OK;
356 d_fnend(3, dev, "(skb %p net_dev %p) = %d\n", skb, net_dev, result);
357 return result;
358}
359
360
361static
362int i2400m_change_mtu(struct net_device *net_dev, int new_mtu)
363{
364 int result;
365 struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
366 struct device *dev = i2400m_dev(i2400m);
367
368 if (new_mtu >= I2400M_MAX_MTU) {
369 dev_err(dev, "Cannot change MTU to %d (max is %d)\n",
370 new_mtu, I2400M_MAX_MTU);
371 result = -EINVAL;
372 } else {
373 net_dev->mtu = new_mtu;
374 result = 0;
375 }
376 return result;
377}
378
379
380static
381void i2400m_tx_timeout(struct net_device *net_dev)
382{
383 /*
384 * We might want to kick the device
385 *
386 * There is not much we can do though, as the device requires
387 * that we send the data aggregated. By the time we receive
388 * this, there might be data pending to be sent or not...
389 */
390 net_dev->stats.tx_errors++;
391 return;
392}
393
394
395/*
396 * Create a fake ethernet header
397 *
398 * For emulating an ethernet device, every received IP header has to
399 * be prefixed with an ethernet header.
400 *
401 * What we receive has (potentially) many IP packets concatenated with
402 * no ETH_HLEN bytes prefixed. Thus there is no space for an eth
403 * header.
404 *
405 * We would have to reallocate or do ugly fragment tricks in order to
406 * add it.
407 *
408 * But what we do is use the header space of the RX transaction
409 * (*msg_hdr) as we don't need it anymore; then we'll point all the
410 * data skbs there, as they share the same backing store.
411 *
412 * We only support IPv4 for v3 firmware.
413 */
414static
415void i2400m_rx_fake_eth_header(struct net_device *net_dev,
416 void *_eth_hdr)
417{
418 struct ethhdr *eth_hdr = _eth_hdr;
419
420 memcpy(eth_hdr->h_dest, net_dev->dev_addr, sizeof(eth_hdr->h_dest));
421 memset(eth_hdr->h_source, 0, sizeof(eth_hdr->h_dest));
422 eth_hdr->h_proto = __constant_cpu_to_be16(ETH_P_IP);
423}
424
425
426/*
427 * i2400m_net_rx - pass a network packet to the stack
428 *
429 * @i2400m: device instance
430 * @skb_rx: the skb where the buffer pointed to by @buf is
431 * @i: 1 if payload is the only one
432 * @buf: pointer to the buffer containing the data
433 * @len: buffer's length
434 *
435 * We just clone the skb and set it up so that it's skb->data pointer
436 * points to "buf" and it's length.
437 *
438 * Note that if the payload is the last (or the only one) in a
439 * multi-payload message, we don't clone the SKB but just reuse it.
440 *
441 * This function is normally run from a thread context. However, we
442 * still use netif_rx() instead of netif_receive_skb() as was
443 * recommended in the mailing list. Reason is in some stress tests
444 * when sending/receiving a lot of data we seem to hit a softlock in
445 * the kernel's TCP implementation [aroudn tcp_delay_timer()]. Using
446 * netif_rx() took care of the issue.
447 *
448 * This is, of course, still open to do more research on why running
449 * with netif_receive_skb() hits this softlock. FIXME.
450 *
451 * FIXME: currently we don't do any efforts at distinguishing if what
452 * we got was an IPv4 or IPv6 header, to setup the protocol field
453 * correctly.
454 */
455void i2400m_net_rx(struct i2400m *i2400m, struct sk_buff *skb_rx,
456 unsigned i, const void *buf, int buf_len)
457{
458 struct net_device *net_dev = i2400m->wimax_dev.net_dev;
459 struct device *dev = i2400m_dev(i2400m);
460 struct sk_buff *skb;
461
462 d_fnstart(2, dev, "(i2400m %p buf %p buf_len %d)\n",
463 i2400m, buf, buf_len);
464 if (i) {
465 skb = skb_get(skb_rx);
466 d_printf(2, dev, "RX: reusing first payload skb %p\n", skb);
467 skb_pull(skb, buf - (void *) skb->data);
468 skb_trim(skb, (void *) skb_end_pointer(skb) - buf);
469 } else {
470 /* Yes, this is bad -- a lot of overhead -- see
471 * comments at the top of the file */
472 skb = __netdev_alloc_skb(net_dev, buf_len, GFP_KERNEL);
473 if (skb == NULL) {
474 dev_err(dev, "NETRX: no memory to realloc skb\n");
475 net_dev->stats.rx_dropped++;
476 goto error_skb_realloc;
477 }
478 memcpy(skb_put(skb, buf_len), buf, buf_len);
479 }
480 i2400m_rx_fake_eth_header(i2400m->wimax_dev.net_dev,
481 skb->data - ETH_HLEN);
482 skb_set_mac_header(skb, -ETH_HLEN);
483 skb->dev = i2400m->wimax_dev.net_dev;
484 skb->protocol = htons(ETH_P_IP);
485 net_dev->stats.rx_packets++;
486 net_dev->stats.rx_bytes += buf_len;
487 d_printf(3, dev, "NETRX: receiving %d bytes to network stack\n",
488 buf_len);
489 d_dump(4, dev, buf, buf_len);
490 netif_rx_ni(skb); /* see notes in function header */
491error_skb_realloc:
492 d_fnend(2, dev, "(i2400m %p buf %p buf_len %d) = void\n",
493 i2400m, buf, buf_len);
494}
495
496
497/**
498 * i2400m_netdev_setup - Setup setup @net_dev's i2400m private data
499 *
500 * Called by alloc_netdev()
501 */
502void i2400m_netdev_setup(struct net_device *net_dev)
503{
504 d_fnstart(3, NULL, "(net_dev %p)\n", net_dev);
505 ether_setup(net_dev);
506 net_dev->mtu = I2400M_MAX_MTU;
507 net_dev->tx_queue_len = I2400M_TX_QLEN;
508 net_dev->features =
509 NETIF_F_VLAN_CHALLENGED
510 | NETIF_F_HIGHDMA;
511 net_dev->flags =
512 IFF_NOARP /* i2400m is apure IP device */
513 & (~IFF_BROADCAST /* i2400m is P2P */
514 & ~IFF_MULTICAST);
515 net_dev->watchdog_timeo = I2400M_TX_TIMEOUT;
516 net_dev->open = i2400m_open;
517 net_dev->stop = i2400m_stop;
518 net_dev->hard_start_xmit = i2400m_hard_start_xmit;
519 net_dev->change_mtu = i2400m_change_mtu;
520 net_dev->tx_timeout = i2400m_tx_timeout;
521 d_fnend(3, NULL, "(net_dev %p) = void\n", net_dev);
522}
523EXPORT_SYMBOL_GPL(i2400m_netdev_setup);
524
diff --git a/drivers/net/wimax/i2400m/op-rfkill.c b/drivers/net/wimax/i2400m/op-rfkill.c
new file mode 100644
index 000000000000..487ec58cea46
--- /dev/null
+++ b/drivers/net/wimax/i2400m/op-rfkill.c
@@ -0,0 +1,207 @@
1/*
2 * Intel Wireless WiMAX Connection 2400m
3 * Implement backend for the WiMAX stack rfkill support
4 *
5 *
6 * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License version
11 * 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301, USA.
22 *
23 *
24 * The WiMAX kernel stack integrates into RF-Kill and keeps the
25 * switches's status. We just need to:
26 *
27 * - report changes in the HW RF Kill switch [with
28 * wimax_rfkill_{sw,hw}_report(), which happens when we detect those
29 * indications coming through hardware reports]. We also do it on
30 * initialization to let the stack know the intial HW state.
31 *
32 * - implement indications from the stack to change the SW RF Kill
33 * switch (coming from sysfs, the wimax stack or user space).
34 */
35#include "i2400m.h"
36#include <linux/wimax/i2400m.h>
37
38
39
40#define D_SUBMODULE rfkill
41#include "debug-levels.h"
42
43/*
44 * Return true if the i2400m radio is in the requested wimax_rf_state state
45 *
46 */
47static
48int i2400m_radio_is(struct i2400m *i2400m, enum wimax_rf_state state)
49{
50 if (state == WIMAX_RF_OFF)
51 return i2400m->state == I2400M_SS_RF_OFF
52 || i2400m->state == I2400M_SS_RF_SHUTDOWN;
53 else if (state == WIMAX_RF_ON)
54 /* state == WIMAX_RF_ON */
55 return i2400m->state != I2400M_SS_RF_OFF
56 && i2400m->state != I2400M_SS_RF_SHUTDOWN;
57 else
58 BUG();
59}
60
61
62/*
63 * WiMAX stack operation: implement SW RFKill toggling
64 *
65 * @wimax_dev: device descriptor
66 * @skb: skb where the message has been received; skb->data is
67 * expected to point to the message payload.
68 * @genl_info: passed by the generic netlink layer
69 *
70 * Generic Netlink will call this function when a message is sent from
71 * userspace to change the software RF-Kill switch status.
72 *
73 * This function will set the device's sofware RF-Kill switch state to
74 * match what is requested.
75 *
76 * NOTE: the i2400m has a strict state machine; we can only set the
77 * RF-Kill switch when it is on, the HW RF-Kill is on and the
78 * device is initialized. So we ignore errors steaming from not
79 * being in the right state (-EILSEQ).
80 */
81int i2400m_op_rfkill_sw_toggle(struct wimax_dev *wimax_dev,
82 enum wimax_rf_state state)
83{
84 int result;
85 struct i2400m *i2400m = wimax_dev_to_i2400m(wimax_dev);
86 struct device *dev = i2400m_dev(i2400m);
87 struct sk_buff *ack_skb;
88 struct {
89 struct i2400m_l3l4_hdr hdr;
90 struct i2400m_tlv_rf_operation sw_rf;
91 } __attribute__((packed)) *cmd;
92 char strerr[32];
93
94 d_fnstart(4, dev, "(wimax_dev %p state %d)\n", wimax_dev, state);
95
96 result = -ENOMEM;
97 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
98 if (cmd == NULL)
99 goto error_alloc;
100 cmd->hdr.type = cpu_to_le16(I2400M_MT_CMD_RF_CONTROL);
101 cmd->hdr.length = sizeof(cmd->sw_rf);
102 cmd->hdr.version = cpu_to_le16(I2400M_L3L4_VERSION);
103 cmd->sw_rf.hdr.type = cpu_to_le16(I2400M_TLV_RF_OPERATION);
104 cmd->sw_rf.hdr.length = cpu_to_le16(sizeof(cmd->sw_rf.status));
105 switch (state) {
106 case WIMAX_RF_OFF: /* RFKILL ON, radio OFF */
107 cmd->sw_rf.status = cpu_to_le32(2);
108 break;
109 case WIMAX_RF_ON: /* RFKILL OFF, radio ON */
110 cmd->sw_rf.status = cpu_to_le32(1);
111 break;
112 default:
113 BUG();
114 }
115
116 ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
117 result = PTR_ERR(ack_skb);
118 if (IS_ERR(ack_skb)) {
119 dev_err(dev, "Failed to issue 'RF Control' command: %d\n",
120 result);
121 goto error_msg_to_dev;
122 }
123 result = i2400m_msg_check_status(wimax_msg_data(ack_skb),
124 strerr, sizeof(strerr));
125 if (result < 0) {
126 dev_err(dev, "'RF Control' (0x%04x) command failed: %d - %s\n",
127 I2400M_MT_CMD_RF_CONTROL, result, strerr);
128 goto error_cmd;
129 }
130
131 /* Now we wait for the state to change to RADIO_OFF or RADIO_ON */
132 result = wait_event_timeout(
133 i2400m->state_wq, i2400m_radio_is(i2400m, state),
134 5 * HZ);
135 if (result == 0)
136 result = -ETIMEDOUT;
137 if (result < 0)
138 dev_err(dev, "Error waiting for device to toggle RF state: "
139 "%d\n", result);
140 result = 0;
141error_cmd:
142 kfree_skb(ack_skb);
143error_msg_to_dev:
144error_alloc:
145 d_fnend(4, dev, "(wimax_dev %p state %d) = %d\n",
146 wimax_dev, state, result);
147 return result;
148}
149
150
151/*
152 * Inform the WiMAX stack of changes in the RF Kill switches reported
153 * by the device
154 *
155 * @i2400m: device descriptor
156 * @rfss: TLV for RF Switches status; already validated
157 *
158 * NOTE: the reports on RF switch status cannot be trusted
159 * or used until the device is in a state of RADIO_OFF
160 * or greater.
161 */
162void i2400m_report_tlv_rf_switches_status(
163 struct i2400m *i2400m,
164 const struct i2400m_tlv_rf_switches_status *rfss)
165{
166 struct device *dev = i2400m_dev(i2400m);
167 enum i2400m_rf_switch_status hw, sw;
168 enum wimax_st wimax_state;
169
170 sw = le32_to_cpu(rfss->sw_rf_switch);
171 hw = le32_to_cpu(rfss->hw_rf_switch);
172
173 d_fnstart(3, dev, "(i2400m %p rfss %p [hw %u sw %u])\n",
174 i2400m, rfss, hw, sw);
175 /* We only process rw switch evens when the device has been
176 * fully initialized */
177 wimax_state = wimax_state_get(&i2400m->wimax_dev);
178 if (wimax_state < WIMAX_ST_RADIO_OFF) {
179 d_printf(3, dev, "ignoring RF switches report, state %u\n",
180 wimax_state);
181 goto out;
182 }
183 switch (sw) {
184 case I2400M_RF_SWITCH_ON: /* RF Kill disabled (radio on) */
185 wimax_report_rfkill_sw(&i2400m->wimax_dev, WIMAX_RF_ON);
186 break;
187 case I2400M_RF_SWITCH_OFF: /* RF Kill enabled (radio off) */
188 wimax_report_rfkill_sw(&i2400m->wimax_dev, WIMAX_RF_OFF);
189 break;
190 default:
191 dev_err(dev, "HW BUG? Unknown RF SW state 0x%x\n", sw);
192 }
193
194 switch (hw) {
195 case I2400M_RF_SWITCH_ON: /* RF Kill disabled (radio on) */
196 wimax_report_rfkill_hw(&i2400m->wimax_dev, WIMAX_RF_ON);
197 break;
198 case I2400M_RF_SWITCH_OFF: /* RF Kill enabled (radio off) */
199 wimax_report_rfkill_hw(&i2400m->wimax_dev, WIMAX_RF_OFF);
200 break;
201 default:
202 dev_err(dev, "HW BUG? Unknown RF HW state 0x%x\n", hw);
203 }
204out:
205 d_fnend(3, dev, "(i2400m %p rfss %p [hw %u sw %u]) = void\n",
206 i2400m, rfss, hw, sw);
207}
diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
new file mode 100644
index 000000000000..6922022710ac
--- /dev/null
+++ b/drivers/net/wimax/i2400m/rx.c
@@ -0,0 +1,534 @@
1/*
2 * Intel Wireless WiMAX Connection 2400m
3 * Handle incoming traffic and deliver it to the control or data planes
4 *
5 *
6 * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 *
35 * Intel Corporation <linux-wimax@intel.com>
36 * Yanir Lubetkin <yanirx.lubetkin@intel.com>
37 * - Initial implementation
38 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
39 * - Use skb_clone(), break up processing in chunks
40 * - Split transport/device specific
41 * - Make buffer size dynamic to exert less memory pressure
42 *
43 *
44 * This handles the RX path.
45 *
46 * We receive an RX message from the bus-specific driver, which
47 * contains one or more payloads that have potentially different
48 * destinataries (data or control paths).
49 *
50 * So we just take that payload from the transport specific code in
51 * the form of an skb, break it up in chunks (a cloned skb each in the
52 * case of network packets) and pass it to netdev or to the
53 * command/ack handler (and from there to the WiMAX stack).
54 *
55 * PROTOCOL FORMAT
56 *
57 * The format of the buffer is:
58 *
59 * HEADER (struct i2400m_msg_hdr)
60 * PAYLOAD DESCRIPTOR 0 (struct i2400m_pld)
61 * PAYLOAD DESCRIPTOR 1
62 * ...
63 * PAYLOAD DESCRIPTOR N
64 * PAYLOAD 0 (raw bytes)
65 * PAYLOAD 1
66 * ...
67 * PAYLOAD N
68 *
69 * See tx.c for a deeper description on alignment requirements and
70 * other fun facts of it.
71 *
72 * ROADMAP
73 *
74 * i2400m_rx
75 * i2400m_rx_msg_hdr_check
76 * i2400m_rx_pl_descr_check
77 * i2400m_rx_payload
78 * i2400m_net_rx
79 * i2400m_rx_ctl
80 * i2400m_msg_size_check
81 * i2400m_report_hook_work [in a workqueue]
82 * i2400m_report_hook
83 * wimax_msg_to_user
84 * i2400m_rx_ctl_ack
85 * wimax_msg_to_user_alloc
86 * i2400m_rx_trace
87 * i2400m_msg_size_check
88 * wimax_msg
89 */
90#include <linux/kernel.h>
91#include <linux/if_arp.h>
92#include <linux/netdevice.h>
93#include <linux/workqueue.h>
94#include "i2400m.h"
95
96
97#define D_SUBMODULE rx
98#include "debug-levels.h"
99
100struct i2400m_report_hook_args {
101 struct sk_buff *skb_rx;
102 const struct i2400m_l3l4_hdr *l3l4_hdr;
103 size_t size;
104};
105
106
107/*
108 * Execute i2400m_report_hook in a workqueue
109 *
110 * Unpacks arguments from the deferred call, executes it and then
111 * drops the references.
112 *
113 * Obvious NOTE: References are needed because we are a separate
114 * thread; otherwise the buffer changes under us because it is
115 * released by the original caller.
116 */
117static
118void i2400m_report_hook_work(struct work_struct *ws)
119{
120 struct i2400m_work *iw =
121 container_of(ws, struct i2400m_work, ws);
122 struct i2400m_report_hook_args *args = (void *) iw->pl;
123 i2400m_report_hook(iw->i2400m, args->l3l4_hdr, args->size);
124 kfree_skb(args->skb_rx);
125 i2400m_put(iw->i2400m);
126 kfree(iw);
127}
128
129
130/*
131 * Process an ack to a command
132 *
133 * @i2400m: device descriptor
134 * @payload: pointer to message
135 * @size: size of the message
136 *
137 * Pass the acknodledgment (in an skb) to the thread that is waiting
138 * for it in i2400m->msg_completion.
139 *
140 * We need to coordinate properly with the thread waiting for the
141 * ack. Check if it is waiting or if it is gone. We loose the spinlock
142 * to avoid allocating on atomic contexts (yeah, could use GFP_ATOMIC,
143 * but this is not so speed critical).
144 */
145static
146void i2400m_rx_ctl_ack(struct i2400m *i2400m,
147 const void *payload, size_t size)
148{
149 struct device *dev = i2400m_dev(i2400m);
150 struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
151 unsigned long flags;
152 struct sk_buff *ack_skb;
153
154 /* Anyone waiting for an answer? */
155 spin_lock_irqsave(&i2400m->rx_lock, flags);
156 if (i2400m->ack_skb != ERR_PTR(-EINPROGRESS)) {
157 dev_err(dev, "Huh? reply to command with no waiters\n");
158 goto error_no_waiter;
159 }
160 spin_unlock_irqrestore(&i2400m->rx_lock, flags);
161
162 ack_skb = wimax_msg_alloc(wimax_dev, NULL, payload, size, GFP_KERNEL);
163
164 /* Check waiter didn't time out waiting for the answer... */
165 spin_lock_irqsave(&i2400m->rx_lock, flags);
166 if (i2400m->ack_skb != ERR_PTR(-EINPROGRESS)) {
167 d_printf(1, dev, "Huh? waiter for command reply cancelled\n");
168 goto error_waiter_cancelled;
169 }
170 if (ack_skb == NULL) {
171 dev_err(dev, "CMD/GET/SET ack: cannot allocate SKB\n");
172 i2400m->ack_skb = ERR_PTR(-ENOMEM);
173 } else
174 i2400m->ack_skb = ack_skb;
175 spin_unlock_irqrestore(&i2400m->rx_lock, flags);
176 complete(&i2400m->msg_completion);
177 return;
178
179error_waiter_cancelled:
180 if (ack_skb)
181 kfree_skb(ack_skb);
182error_no_waiter:
183 spin_unlock_irqrestore(&i2400m->rx_lock, flags);
184 return;
185}
186
187
188/*
189 * Receive and process a control payload
190 *
191 * @i2400m: device descriptor
192 * @skb_rx: skb that contains the payload (for reference counting)
193 * @payload: pointer to message
194 * @size: size of the message
195 *
196 * There are two types of control RX messages: reports (asynchronous,
197 * like your every day interrupts) and 'acks' (reponses to a command,
198 * get or set request).
199 *
200 * If it is a report, we run hooks on it (to extract information for
201 * things we need to do in the driver) and then pass it over to the
202 * WiMAX stack to send it to user space.
203 *
204 * NOTE: report processing is done in a workqueue specific to the
205 * generic driver, to avoid deadlocks in the system.
206 *
207 * If it is not a report, it is an ack to a previously executed
208 * command, set or get, so wake up whoever is waiting for it from
209 * i2400m_msg_to_dev(). i2400m_rx_ctl_ack() takes care of that.
210 *
211 * Note that the sizes we pass to other functions from here are the
212 * sizes of the _l3l4_hdr + payload, not full buffer sizes, as we have
213 * verified in _msg_size_check() that they are congruent.
214 *
215 * For reports: We can't clone the original skb where the data is
216 * because we need to send this up via netlink; netlink has to add
217 * headers and we can't overwrite what's preceeding the payload...as
218 * it is another message. So we just dup them.
219 */
220static
221void i2400m_rx_ctl(struct i2400m *i2400m, struct sk_buff *skb_rx,
222 const void *payload, size_t size)
223{
224 int result;
225 struct device *dev = i2400m_dev(i2400m);
226 const struct i2400m_l3l4_hdr *l3l4_hdr = payload;
227 unsigned msg_type;
228
229 result = i2400m_msg_size_check(i2400m, l3l4_hdr, size);
230 if (result < 0) {
231 dev_err(dev, "HW BUG? device sent a bad message: %d\n",
232 result);
233 goto error_check;
234 }
235 msg_type = le16_to_cpu(l3l4_hdr->type);
236 d_printf(1, dev, "%s 0x%04x: %zu bytes\n",
237 msg_type & I2400M_MT_REPORT_MASK ? "REPORT" : "CMD/SET/GET",
238 msg_type, size);
239 d_dump(2, dev, l3l4_hdr, size);
240 if (msg_type & I2400M_MT_REPORT_MASK) {
241 /* These hooks have to be ran serialized; as well, the
242 * handling might force the execution of commands, and
243 * that might cause reentrancy issues with
244 * bus-specific subdrivers and workqueues. So we run
245 * it in a separate workqueue. */
246 struct i2400m_report_hook_args args = {
247 .skb_rx = skb_rx,
248 .l3l4_hdr = l3l4_hdr,
249 .size = size
250 };
251 if (unlikely(i2400m->ready == 0)) /* only send if up */
252 return;
253 skb_get(skb_rx);
254 i2400m_queue_work(i2400m, i2400m_report_hook_work,
255 GFP_KERNEL, &args, sizeof(args));
256 result = wimax_msg(&i2400m->wimax_dev, NULL, l3l4_hdr, size,
257 GFP_KERNEL);
258 if (result < 0)
259 dev_err(dev, "error sending report to userspace: %d\n",
260 result);
261 } else /* an ack to a CMD, GET or SET */
262 i2400m_rx_ctl_ack(i2400m, payload, size);
263error_check:
264 return;
265}
266
267
268
269
270/*
271 * Receive and send up a trace
272 *
273 * @i2400m: device descriptor
274 * @skb_rx: skb that contains the trace (for reference counting)
275 * @payload: pointer to trace message inside the skb
276 * @size: size of the message
277 *
278 * THe i2400m might produce trace information (diagnostics) and we
279 * send them through a different kernel-to-user pipe (to avoid
280 * clogging it).
281 *
282 * As in i2400m_rx_ctl(), we can't clone the original skb where the
283 * data is because we need to send this up via netlink; netlink has to
284 * add headers and we can't overwrite what's preceeding the
285 * payload...as it is another message. So we just dup them.
286 */
287static
288void i2400m_rx_trace(struct i2400m *i2400m,
289 const void *payload, size_t size)
290{
291 int result;
292 struct device *dev = i2400m_dev(i2400m);
293 struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
294 const struct i2400m_l3l4_hdr *l3l4_hdr = payload;
295 unsigned msg_type;
296
297 result = i2400m_msg_size_check(i2400m, l3l4_hdr, size);
298 if (result < 0) {
299 dev_err(dev, "HW BUG? device sent a bad trace message: %d\n",
300 result);
301 goto error_check;
302 }
303 msg_type = le16_to_cpu(l3l4_hdr->type);
304 d_printf(1, dev, "Trace %s 0x%04x: %zu bytes\n",
305 msg_type & I2400M_MT_REPORT_MASK ? "REPORT" : "CMD/SET/GET",
306 msg_type, size);
307 d_dump(2, dev, l3l4_hdr, size);
308 if (unlikely(i2400m->ready == 0)) /* only send if up */
309 return;
310 result = wimax_msg(wimax_dev, "trace", l3l4_hdr, size, GFP_KERNEL);
311 if (result < 0)
312 dev_err(dev, "error sending trace to userspace: %d\n",
313 result);
314error_check:
315 return;
316}
317
318
319/*
320 * Act on a received payload
321 *
322 * @i2400m: device instance
323 * @skb_rx: skb where the transaction was received
324 * @single: 1 if there is only one payload, 0 otherwise
325 * @pld: payload descriptor
326 * @payload: payload data
327 *
328 * Upon reception of a payload, look at its guts in the payload
329 * descriptor and decide what to do with it.
330 */
331static
332void i2400m_rx_payload(struct i2400m *i2400m, struct sk_buff *skb_rx,
333 unsigned single, const struct i2400m_pld *pld,
334 const void *payload)
335{
336 struct device *dev = i2400m_dev(i2400m);
337 size_t pl_size = i2400m_pld_size(pld);
338 enum i2400m_pt pl_type = i2400m_pld_type(pld);
339
340 switch (pl_type) {
341 case I2400M_PT_DATA:
342 d_printf(3, dev, "RX: data payload %zu bytes\n", pl_size);
343 i2400m_net_rx(i2400m, skb_rx, single, payload, pl_size);
344 break;
345 case I2400M_PT_CTRL:
346 i2400m_rx_ctl(i2400m, skb_rx, payload, pl_size);
347 break;
348 case I2400M_PT_TRACE:
349 i2400m_rx_trace(i2400m, payload, pl_size);
350 break;
351 default: /* Anything else shouldn't come to the host */
352 if (printk_ratelimit())
353 dev_err(dev, "RX: HW BUG? unexpected payload type %u\n",
354 pl_type);
355 }
356}
357
358
359/*
360 * Check a received transaction's message header
361 *
362 * @i2400m: device descriptor
363 * @msg_hdr: message header
364 * @buf_size: size of the received buffer
365 *
366 * Check that the declarations done by a RX buffer message header are
367 * sane and consistent with the amount of data that was received.
368 */
369static
370int i2400m_rx_msg_hdr_check(struct i2400m *i2400m,
371 const struct i2400m_msg_hdr *msg_hdr,
372 size_t buf_size)
373{
374 int result = -EIO;
375 struct device *dev = i2400m_dev(i2400m);
376 if (buf_size < sizeof(*msg_hdr)) {
377 dev_err(dev, "RX: HW BUG? message with short header (%zu "
378 "vs %zu bytes expected)\n", buf_size, sizeof(*msg_hdr));
379 goto error;
380 }
381 if (msg_hdr->barker != cpu_to_le32(I2400M_D2H_MSG_BARKER)) {
382 dev_err(dev, "RX: HW BUG? message received with unknown "
383 "barker 0x%08x (buf_size %zu bytes)\n",
384 le32_to_cpu(msg_hdr->barker), buf_size);
385 goto error;
386 }
387 if (msg_hdr->num_pls == 0) {
388 dev_err(dev, "RX: HW BUG? zero payload packets in message\n");
389 goto error;
390 }
391 if (le16_to_cpu(msg_hdr->num_pls) > I2400M_MAX_PLS_IN_MSG) {
392 dev_err(dev, "RX: HW BUG? message contains more payload "
393 "than maximum; ignoring.\n");
394 goto error;
395 }
396 result = 0;
397error:
398 return result;
399}
400
401
402/*
403 * Check a payload descriptor against the received data
404 *
405 * @i2400m: device descriptor
406 * @pld: payload descriptor
407 * @pl_itr: offset (in bytes) in the received buffer the payload is
408 * located
409 * @buf_size: size of the received buffer
410 *
411 * Given a payload descriptor (part of a RX buffer), check it is sane
412 * and that the data it declares fits in the buffer.
413 */
414static
415int i2400m_rx_pl_descr_check(struct i2400m *i2400m,
416 const struct i2400m_pld *pld,
417 size_t pl_itr, size_t buf_size)
418{
419 int result = -EIO;
420 struct device *dev = i2400m_dev(i2400m);
421 size_t pl_size = i2400m_pld_size(pld);
422 enum i2400m_pt pl_type = i2400m_pld_type(pld);
423
424 if (pl_size > i2400m->bus_pl_size_max) {
425 dev_err(dev, "RX: HW BUG? payload @%zu: size %zu is "
426 "bigger than maximum %zu; ignoring message\n",
427 pl_itr, pl_size, i2400m->bus_pl_size_max);
428 goto error;
429 }
430 if (pl_itr + pl_size > buf_size) { /* enough? */
431 dev_err(dev, "RX: HW BUG? payload @%zu: size %zu "
432 "goes beyond the received buffer "
433 "size (%zu bytes); ignoring message\n",
434 pl_itr, pl_size, buf_size);
435 goto error;
436 }
437 if (pl_type >= I2400M_PT_ILLEGAL) {
438 dev_err(dev, "RX: HW BUG? illegal payload type %u; "
439 "ignoring message\n", pl_type);
440 goto error;
441 }
442 result = 0;
443error:
444 return result;
445}
446
447
448/**
449 * i2400m_rx - Receive a buffer of data from the device
450 *
451 * @i2400m: device descriptor
452 * @skb: skbuff where the data has been received
453 *
454 * Parse in a buffer of data that contains an RX message sent from the
455 * device. See the file header for the format. Run all checks on the
456 * buffer header, then run over each payload's descriptors, verify
457 * their consistency and act on each payload's contents. If
458 * everything is succesful, update the device's statistics.
459 *
460 * Note: You need to set the skb to contain only the length of the
461 * received buffer; for that, use skb_trim(skb, RECEIVED_SIZE).
462 *
463 * Returns:
464 *
465 * 0 if ok, < 0 errno on error
466 *
467 * If ok, this function owns now the skb and the caller DOESN'T have
468 * to run kfree_skb() on it. However, on error, the caller still owns
469 * the skb and it is responsible for releasing it.
470 */
471int i2400m_rx(struct i2400m *i2400m, struct sk_buff *skb)
472{
473 int i, result;
474 struct device *dev = i2400m_dev(i2400m);
475 const struct i2400m_msg_hdr *msg_hdr;
476 size_t pl_itr, pl_size, skb_len;
477 unsigned long flags;
478 unsigned num_pls;
479
480 skb_len = skb->len;
481 d_fnstart(4, dev, "(i2400m %p skb %p [size %zu])\n",
482 i2400m, skb, skb_len);
483 result = -EIO;
484 msg_hdr = (void *) skb->data;
485 result = i2400m_rx_msg_hdr_check(i2400m, msg_hdr, skb->len);
486 if (result < 0)
487 goto error_msg_hdr_check;
488 result = -EIO;
489 num_pls = le16_to_cpu(msg_hdr->num_pls);
490 pl_itr = sizeof(*msg_hdr) + /* Check payload descriptor(s) */
491 num_pls * sizeof(msg_hdr->pld[0]);
492 pl_itr = ALIGN(pl_itr, I2400M_PL_PAD);
493 if (pl_itr > skb->len) { /* got all the payload descriptors? */
494 dev_err(dev, "RX: HW BUG? message too short (%u bytes) for "
495 "%u payload descriptors (%zu each, total %zu)\n",
496 skb->len, num_pls, sizeof(msg_hdr->pld[0]), pl_itr);
497 goto error_pl_descr_short;
498 }
499 /* Walk each payload payload--check we really got it */
500 for (i = 0; i < num_pls; i++) {
501 /* work around old gcc warnings */
502 pl_size = i2400m_pld_size(&msg_hdr->pld[i]);
503 result = i2400m_rx_pl_descr_check(i2400m, &msg_hdr->pld[i],
504 pl_itr, skb->len);
505 if (result < 0)
506 goto error_pl_descr_check;
507 i2400m_rx_payload(i2400m, skb, num_pls == 1, &msg_hdr->pld[i],
508 skb->data + pl_itr);
509 pl_itr += ALIGN(pl_size, I2400M_PL_PAD);
510 cond_resched(); /* Don't monopolize */
511 }
512 kfree_skb(skb);
513 /* Update device statistics */
514 spin_lock_irqsave(&i2400m->rx_lock, flags);
515 i2400m->rx_pl_num += i;
516 if (i > i2400m->rx_pl_max)
517 i2400m->rx_pl_max = i;
518 if (i < i2400m->rx_pl_min)
519 i2400m->rx_pl_min = i;
520 i2400m->rx_num++;
521 i2400m->rx_size_acc += skb->len;
522 if (skb->len < i2400m->rx_size_min)
523 i2400m->rx_size_min = skb->len;
524 if (skb->len > i2400m->rx_size_max)
525 i2400m->rx_size_max = skb->len;
526 spin_unlock_irqrestore(&i2400m->rx_lock, flags);
527error_pl_descr_check:
528error_pl_descr_short:
529error_msg_hdr_check:
530 d_fnend(4, dev, "(i2400m %p skb %p [size %zu]) = %d\n",
531 i2400m, skb, skb_len, result);
532 return result;
533}
534EXPORT_SYMBOL_GPL(i2400m_rx);
diff --git a/drivers/net/wimax/i2400m/sdio-debug-levels.h b/drivers/net/wimax/i2400m/sdio-debug-levels.h
new file mode 100644
index 000000000000..c51998741301
--- /dev/null
+++ b/drivers/net/wimax/i2400m/sdio-debug-levels.h
@@ -0,0 +1,22 @@
1/*
2 * debug levels control file for the i2400m module's
3 */
4#ifndef __debug_levels__h__
5#define __debug_levels__h__
6
7/* Maximum compile and run time debug level for all submodules */
8#define D_MODULENAME i2400m_sdio
9#define D_MASTER CONFIG_WIMAX_I2400M_DEBUG_LEVEL
10
11#include <linux/wimax/debug.h>
12
13/* List of all the enabled modules */
14enum d_module {
15 D_SUBMODULE_DECLARE(main),
16 D_SUBMODULE_DECLARE(tx),
17 D_SUBMODULE_DECLARE(rx),
18 D_SUBMODULE_DECLARE(fw)
19};
20
21
22#endif /* #ifndef __debug_levels__h__ */
diff --git a/drivers/net/wimax/i2400m/sdio-fw.c b/drivers/net/wimax/i2400m/sdio-fw.c
new file mode 100644
index 000000000000..3487205d8f50
--- /dev/null
+++ b/drivers/net/wimax/i2400m/sdio-fw.c
@@ -0,0 +1,224 @@
1/*
2 * Intel Wireless WiMAX Connection 2400m
3 * Firmware uploader's SDIO specifics
4 *
5 *
6 * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 *
35 * Intel Corporation <linux-wimax@intel.com>
36 * Yanir Lubetkin <yanirx.lubetkin@intel.com>
37 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
38 * - Initial implementation
39 *
40 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
41 * - Bus generic/specific split for USB
42 *
43 * Dirk Brandewie <dirk.j.brandewie@intel.com>
44 * - Initial implementation for SDIO
45 *
46 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
47 * - SDIO rehash for changes in the bus-driver model
48 *
49 * THE PROCEDURE
50 *
51 * See fw.c for the generic description of this procedure.
52 *
53 * This file implements only the SDIO specifics. It boils down to how
54 * to send a command and waiting for an acknowledgement from the
55 * device. We do polled reads.
56 *
57 * COMMAND EXECUTION
58 *
59 * THe generic firmware upload code will call i2400m_bus_bm_cmd_send()
60 * to send commands.
61 *
62 * The SDIO devices expects things in 256 byte blocks, so it will pad
63 * it, compute the checksum (if needed) and pass it to SDIO.
64 *
65 * ACK RECEPTION
66 *
67 * This works in polling mode -- the fw loader says when to wait for
68 * data and for that it calls i2400ms_bus_bm_wait_for_ack().
69 *
70 * This will poll the device for data until it is received. We need to
71 * receive at least as much bytes as where asked for (although it'll
72 * always be a multiple of 256 bytes).
73 */
74#include <linux/mmc/sdio_func.h>
75#include "i2400m-sdio.h"
76
77
78#define D_SUBMODULE fw
79#include "sdio-debug-levels.h"
80
81/*
82 * Send a boot-mode command to the SDIO function
83 *
84 * We use a bounce buffer (i2400m->bm_cmd_buf) because we need to
85 * touch the header if the RAW flag is not set.
86 *
87 * @flags: pass thru from i2400m_bm_cmd()
88 * @return: cmd_size if ok, < 0 errno code on error.
89 *
90 * Note the command is padded to the SDIO block size for the device.
91 */
92ssize_t i2400ms_bus_bm_cmd_send(struct i2400m *i2400m,
93 const struct i2400m_bootrom_header *_cmd,
94 size_t cmd_size, int flags)
95{
96 ssize_t result;
97 struct device *dev = i2400m_dev(i2400m);
98 struct i2400ms *i2400ms = container_of(i2400m, struct i2400ms, i2400m);
99 int opcode = _cmd == NULL ? -1 : i2400m_brh_get_opcode(_cmd);
100 struct i2400m_bootrom_header *cmd;
101 /* SDIO restriction */
102 size_t cmd_size_a = ALIGN(cmd_size, I2400MS_BLK_SIZE);
103
104 d_fnstart(5, dev, "(i2400m %p cmd %p size %zu)\n",
105 i2400m, _cmd, cmd_size);
106 result = -E2BIG;
107 if (cmd_size > I2400M_BM_CMD_BUF_SIZE)
108 goto error_too_big;
109
110 memcpy(i2400m->bm_cmd_buf, _cmd, cmd_size); /* Prep command */
111 cmd = i2400m->bm_cmd_buf;
112 if (cmd_size_a > cmd_size) /* Zero pad space */
113 memset(i2400m->bm_cmd_buf + cmd_size, 0, cmd_size_a - cmd_size);
114 if ((flags & I2400M_BM_CMD_RAW) == 0) {
115 if (WARN_ON(i2400m_brh_get_response_required(cmd) == 0))
116 dev_warn(dev, "SW BUG: response_required == 0\n");
117 i2400m_bm_cmd_prepare(cmd);
118 }
119 d_printf(4, dev, "BM cmd %d: %zu bytes (%zu padded)\n",
120 opcode, cmd_size, cmd_size_a);
121 d_dump(5, dev, cmd, cmd_size);
122
123 sdio_claim_host(i2400ms->func); /* Send & check */
124 result = sdio_memcpy_toio(i2400ms->func, I2400MS_DATA_ADDR,
125 i2400m->bm_cmd_buf, cmd_size_a);
126 sdio_release_host(i2400ms->func);
127 if (result < 0) {
128 dev_err(dev, "BM cmd %d: cannot send: %ld\n",
129 opcode, (long) result);
130 goto error_cmd_send;
131 }
132 result = cmd_size;
133error_cmd_send:
134error_too_big:
135 d_fnend(5, dev, "(i2400m %p cmd %p size %zu) = %d\n",
136 i2400m, _cmd, cmd_size, (int) result);
137 return result;
138}
139
140
141/*
142 * Read an ack from the device's boot-mode (polling)
143 *
144 * @i2400m:
145 * @_ack: pointer to where to store the read data
146 * @ack_size: how many bytes we should read
147 *
148 * Returns: < 0 errno code on error; otherwise, amount of received bytes.
149 *
150 * The ACK for a BM command is always at least sizeof(*ack) bytes, so
151 * check for that. We don't need to check for device reboots
152 *
153 * NOTE: We do an artificial timeout of 1 sec over the SDIO timeout;
154 * this way we have control over it...there is no way that I know
155 * of setting an SDIO transaction timeout.
156 */
157ssize_t i2400ms_bus_bm_wait_for_ack(struct i2400m *i2400m,
158 struct i2400m_bootrom_header *ack,
159 size_t ack_size)
160{
161 int result;
162 ssize_t rx_size;
163 u64 timeout;
164 struct i2400ms *i2400ms = container_of(i2400m, struct i2400ms, i2400m);
165 struct sdio_func *func = i2400ms->func;
166 struct device *dev = &func->dev;
167
168 BUG_ON(sizeof(*ack) > ack_size);
169
170 d_fnstart(5, dev, "(i2400m %p ack %p size %zu)\n",
171 i2400m, ack, ack_size);
172
173 timeout = get_jiffies_64() + 2 * HZ;
174 sdio_claim_host(func);
175 while (1) {
176 if (time_after64(get_jiffies_64(), timeout)) {
177 rx_size = -ETIMEDOUT;
178 dev_err(dev, "timeout waiting for ack data\n");
179 goto error_timedout;
180 }
181
182 /* Find the RX size, check if it fits or not -- it if
183 * doesn't fit, fail, as we have no way to dispose of
184 * the extra data. */
185 rx_size = __i2400ms_rx_get_size(i2400ms);
186 if (rx_size < 0)
187 goto error_rx_get_size;
188 result = -ENOSPC; /* Check it fits */
189 if (rx_size < sizeof(*ack)) {
190 rx_size = -EIO;
191 dev_err(dev, "HW BUG? received is too small (%zu vs "
192 "%zu needed)\n", sizeof(*ack), rx_size);
193 goto error_too_small;
194 }
195 if (rx_size > I2400M_BM_ACK_BUF_SIZE) {
196 dev_err(dev, "SW BUG? BM_ACK_BUF is too small (%u vs "
197 "%zu needed)\n", I2400M_BM_ACK_BUF_SIZE,
198 rx_size);
199 goto error_too_small;
200 }
201
202 /* Read it */
203 result = sdio_memcpy_fromio(func, i2400m->bm_ack_buf,
204 I2400MS_DATA_ADDR, rx_size);
205 if (result == -ETIMEDOUT || result == -ETIME)
206 continue;
207 if (result < 0) {
208 dev_err(dev, "BM SDIO receive (%zu B) failed: %d\n",
209 rx_size, result);
210 goto error_read;
211 } else
212 break;
213 }
214 rx_size = min((ssize_t)ack_size, rx_size);
215 memcpy(ack, i2400m->bm_ack_buf, rx_size);
216error_read:
217error_too_small:
218error_rx_get_size:
219error_timedout:
220 sdio_release_host(func);
221 d_fnend(5, dev, "(i2400m %p ack %p size %zu) = %ld\n",
222 i2400m, ack, ack_size, (long) rx_size);
223 return rx_size;
224}
diff --git a/drivers/net/wimax/i2400m/sdio-rx.c b/drivers/net/wimax/i2400m/sdio-rx.c
new file mode 100644
index 000000000000..a3008b904f7d
--- /dev/null
+++ b/drivers/net/wimax/i2400m/sdio-rx.c
@@ -0,0 +1,255 @@
1/*
2 * Intel Wireless WiMAX Connection 2400m
3 * SDIO RX handling
4 *
5 *
6 * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 *
35 * Intel Corporation <linux-wimax@intel.com>
36 * Dirk Brandewie <dirk.j.brandewie@intel.com>
37 * - Initial implementation
38 *
39 *
40 * This handles the RX path on SDIO.
41 *
42 * The SDIO bus driver calls the "irq" routine when data is available.
43 * This is not a traditional interrupt routine since the SDIO bus
44 * driver calls us from its irq thread context. Because of this
45 * sleeping in the SDIO RX IRQ routine is okay.
46 *
47 * From there on, we obtain the size of the data that is available,
48 * allocate an skb, copy it and then pass it to the generic driver's
49 * RX routine [i2400m_rx()].
50 *
51 * ROADMAP
52 *
53 * i2400ms_irq()
54 * i2400ms_rx()
55 * __i2400ms_rx_get_size()
56 * i2400m_rx()
57 *
58 * i2400ms_rx_setup()
59 *
60 * i2400ms_rx_release()
61 */
62#include <linux/workqueue.h>
63#include <linux/wait.h>
64#include <linux/skbuff.h>
65#include <linux/mmc/sdio.h>
66#include <linux/mmc/sdio_func.h>
67#include "i2400m-sdio.h"
68
69#define D_SUBMODULE rx
70#include "sdio-debug-levels.h"
71
72
73/*
74 * Read and return the amount of bytes available for RX
75 *
76 * The RX size has to be read like this: byte reads of three
77 * sequential locations; then glue'em together.
78 *
79 * sdio_readl() doesn't work.
80 */
81ssize_t __i2400ms_rx_get_size(struct i2400ms *i2400ms)
82{
83 int ret, cnt, val;
84 ssize_t rx_size;
85 unsigned xfer_size_addr;
86 struct sdio_func *func = i2400ms->func;
87 struct device *dev = &i2400ms->func->dev;
88
89 d_fnstart(7, dev, "(i2400ms %p)\n", i2400ms);
90 xfer_size_addr = I2400MS_INTR_GET_SIZE_ADDR;
91 rx_size = 0;
92 for (cnt = 0; cnt < 3; cnt++) {
93 val = sdio_readb(func, xfer_size_addr + cnt, &ret);
94 if (ret < 0) {
95 dev_err(dev, "RX: Can't read byte %d of RX size from "
96 "0x%08x: %d\n", cnt, xfer_size_addr + cnt, ret);
97 rx_size = ret;
98 goto error_read;
99 }
100 rx_size = rx_size << 8 | (val & 0xff);
101 }
102 d_printf(6, dev, "RX: rx_size is %ld\n", (long) rx_size);
103error_read:
104 d_fnend(7, dev, "(i2400ms %p) = %ld\n", i2400ms, (long) rx_size);
105 return rx_size;
106}
107
108
109/*
110 * Read data from the device (when in normal)
111 *
112 * Allocate an SKB of the right size, read the data in and then
113 * deliver it to the generic layer.
114 *
115 * We also check for a reboot barker. That means the device died and
116 * we have to reboot it.
117 */
118static
119void i2400ms_rx(struct i2400ms *i2400ms)
120{
121 int ret;
122 struct sdio_func *func = i2400ms->func;
123 struct device *dev = &func->dev;
124 struct i2400m *i2400m = &i2400ms->i2400m;
125 struct sk_buff *skb;
126 ssize_t rx_size;
127
128 d_fnstart(7, dev, "(i2400ms %p)\n", i2400ms);
129 rx_size = __i2400ms_rx_get_size(i2400ms);
130 if (rx_size < 0) {
131 ret = rx_size;
132 goto error_get_size;
133 }
134 ret = -ENOMEM;
135 skb = alloc_skb(rx_size, GFP_ATOMIC);
136 if (NULL == skb) {
137 dev_err(dev, "RX: unable to alloc skb\n");
138 goto error_alloc_skb;
139 }
140
141 ret = sdio_memcpy_fromio(func, skb->data,
142 I2400MS_DATA_ADDR, rx_size);
143 if (ret < 0) {
144 dev_err(dev, "RX: SDIO data read failed: %d\n", ret);
145 goto error_memcpy_fromio;
146 }
147 /* Check if device has reset */
148 if (!memcmp(skb->data, i2400m_NBOOT_BARKER,
149 sizeof(i2400m_NBOOT_BARKER))
150 || !memcmp(skb->data, i2400m_SBOOT_BARKER,
151 sizeof(i2400m_SBOOT_BARKER))) {
152 ret = i2400m_dev_reset_handle(i2400m);
153 kfree_skb(skb);
154 } else {
155 skb_put(skb, rx_size);
156 i2400m_rx(i2400m, skb);
157 }
158 d_fnend(7, dev, "(i2400ms %p) = void\n", i2400ms);
159 return;
160
161error_memcpy_fromio:
162 kfree_skb(skb);
163error_alloc_skb:
164error_get_size:
165 d_fnend(7, dev, "(i2400ms %p) = %d\n", i2400ms, ret);
166 return;
167}
168
169
170/*
171 * Process an interrupt from the SDIO card
172 *
173 * FIXME: need to process other events that are not just ready-to-read
174 *
175 * Checks there is data ready and then proceeds to read it.
176 */
177static
178void i2400ms_irq(struct sdio_func *func)
179{
180 int ret;
181 struct i2400ms *i2400ms = sdio_get_drvdata(func);
182 struct i2400m *i2400m = &i2400ms->i2400m;
183 struct device *dev = &func->dev;
184 int val;
185
186 d_fnstart(6, dev, "(i2400ms %p)\n", i2400ms);
187 val = sdio_readb(func, I2400MS_INTR_STATUS_ADDR, &ret);
188 if (ret < 0) {
189 dev_err(dev, "RX: Can't read interrupt status: %d\n", ret);
190 goto error_no_irq;
191 }
192 if (!val) {
193 dev_err(dev, "RX: BUG? got IRQ but no interrupt ready?\n");
194 goto error_no_irq;
195 }
196 sdio_writeb(func, 1, I2400MS_INTR_CLEAR_ADDR, &ret);
197 if (WARN_ON(i2400m->boot_mode != 0))
198 dev_err(dev, "RX: SW BUG? boot mode and IRQ is up?\n");
199 else
200 i2400ms_rx(i2400ms);
201error_no_irq:
202 d_fnend(6, dev, "(i2400ms %p) = void\n", i2400ms);
203 return;
204}
205
206
207/*
208 * Setup SDIO RX
209 *
210 * Hooks up the IRQ handler and then enables IRQs.
211 */
212int i2400ms_rx_setup(struct i2400ms *i2400ms)
213{
214 int result;
215 struct sdio_func *func = i2400ms->func;
216 struct device *dev = &func->dev;
217
218 d_fnstart(5, dev, "(i2400ms %p)\n", i2400ms);
219 sdio_claim_host(func);
220 result = sdio_claim_irq(func, i2400ms_irq);
221 if (result < 0) {
222 dev_err(dev, "Cannot claim IRQ: %d\n", result);
223 goto error_irq_claim;
224 }
225 result = 0;
226 sdio_writeb(func, 1, I2400MS_INTR_ENABLE_ADDR, &result);
227 if (result < 0) {
228 sdio_release_irq(func);
229 dev_err(dev, "Failed to enable interrupts %d\n", result);
230 }
231error_irq_claim:
232 sdio_release_host(func);
233 d_fnend(5, dev, "(i2400ms %p) = %d\n", i2400ms, result);
234 return result;
235}
236
237
238/*
239 * Tear down SDIO RX
240 *
241 * Disables IRQs in the device and removes the IRQ handler.
242 */
243void i2400ms_rx_release(struct i2400ms *i2400ms)
244{
245 int result;
246 struct sdio_func *func = i2400ms->func;
247 struct device *dev = &func->dev;
248
249 d_fnstart(5, dev, "(i2400ms %p)\n", i2400ms);
250 sdio_claim_host(func);
251 sdio_writeb(func, 0, I2400MS_INTR_ENABLE_ADDR, &result);
252 sdio_release_irq(func);
253 sdio_release_host(func);
254 d_fnend(5, dev, "(i2400ms %p) = %d\n", i2400ms, result);
255}
diff --git a/drivers/net/wimax/i2400m/sdio-tx.c b/drivers/net/wimax/i2400m/sdio-tx.c
new file mode 100644
index 000000000000..5105a5ebc44f
--- /dev/null
+++ b/drivers/net/wimax/i2400m/sdio-tx.c
@@ -0,0 +1,153 @@
1/*
2 * Intel Wireless WiMAX Connection 2400m
3 * SDIO TX transaction backends
4 *
5 *
6 * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 *
35 * Intel Corporation <linux-wimax@intel.com>
36 * Dirk Brandewie <dirk.j.brandewie@intel.com>
37 * - Initial implementation
38 *
39 *
40 * Takes the TX messages in the i2400m's driver TX FIFO and sends them
41 * to the device until there are no more.
42 *
43 * If we fail sending the message, we just drop it. There isn't much
44 * we can do at this point. Most of the traffic is network, which has
45 * recovery methods for dropped packets.
46 *
47 * The SDIO functions are not atomic, so we can't run from the context
48 * where i2400m->bus_tx_kick() [i2400ms_bus_tx_kick()] is being called
49 * (some times atomic). Thus, the actual TX work is deferred to a
50 * workqueue.
51 *
52 * ROADMAP
53 *
54 * i2400ms_bus_tx_kick()
55 * i2400ms_tx_submit() [through workqueue]
56 *
57 * i2400m_tx_setup()
58 *
59 * i2400m_tx_release()
60 */
61#include <linux/mmc/sdio_func.h>
62#include "i2400m-sdio.h"
63
64#define D_SUBMODULE tx
65#include "sdio-debug-levels.h"
66
67
68/*
69 * Pull TX transations from the TX FIFO and send them to the device
70 * until there are no more.
71 */
72static
73void i2400ms_tx_submit(struct work_struct *ws)
74{
75 int result;
76 struct i2400ms *i2400ms = container_of(ws, struct i2400ms, tx_worker);
77 struct i2400m *i2400m = &i2400ms->i2400m;
78 struct sdio_func *func = i2400ms->func;
79 struct device *dev = &func->dev;
80 struct i2400m_msg_hdr *tx_msg;
81 size_t tx_msg_size;
82
83 d_fnstart(4, dev, "(i2400ms %p, i2400m %p)\n", i2400ms, i2400ms);
84
85 while (NULL != (tx_msg = i2400m_tx_msg_get(i2400m, &tx_msg_size))) {
86 d_printf(2, dev, "TX: submitting %zu bytes\n", tx_msg_size);
87 d_dump(5, dev, tx_msg, tx_msg_size);
88
89 sdio_claim_host(func);
90 result = sdio_memcpy_toio(func, 0, tx_msg, tx_msg_size);
91 sdio_release_host(func);
92
93 i2400m_tx_msg_sent(i2400m);
94
95 if (result < 0) {
96 dev_err(dev, "TX: cannot submit TX; tx_msg @%zu %zu B:"
97 " %d\n", (void *) tx_msg - i2400m->tx_buf,
98 tx_msg_size, result);
99 }
100
101 d_printf(2, dev, "TX: %zub submitted\n", tx_msg_size);
102 }
103
104 d_fnend(4, dev, "(i2400ms %p) = void\n", i2400ms);
105}
106
107
108/*
109 * The generic driver notifies us that there is data ready for TX
110 *
111 * Schedule a run of i2400ms_tx_submit() to handle it.
112 */
113void i2400ms_bus_tx_kick(struct i2400m *i2400m)
114{
115 struct i2400ms *i2400ms = container_of(i2400m, struct i2400ms, i2400m);
116 struct device *dev = &i2400ms->func->dev;
117
118 d_fnstart(3, dev, "(i2400m %p) = void\n", i2400m);
119
120 /* schedule tx work, this is because tx may block, therefore
121 * it has to run in a thread context.
122 */
123 queue_work(i2400ms->tx_workqueue, &i2400ms->tx_worker);
124
125 d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
126}
127
128int i2400ms_tx_setup(struct i2400ms *i2400ms)
129{
130 int result;
131 struct device *dev = &i2400ms->func->dev;
132 struct i2400m *i2400m = &i2400ms->i2400m;
133
134 d_fnstart(5, dev, "(i2400ms %p)\n", i2400ms);
135
136 INIT_WORK(&i2400ms->tx_worker, i2400ms_tx_submit);
137 snprintf(i2400ms->tx_wq_name, sizeof(i2400ms->tx_wq_name),
138 "%s-tx", i2400m->wimax_dev.name);
139 i2400ms->tx_workqueue =
140 create_singlethread_workqueue(i2400ms->tx_wq_name);
141 if (NULL == i2400ms->tx_workqueue) {
142 dev_err(dev, "TX: failed to create workqueue\n");
143 result = -ENOMEM;
144 } else
145 result = 0;
146 d_fnend(5, dev, "(i2400ms %p) = %d\n", i2400ms, result);
147 return result;
148}
149
150void i2400ms_tx_release(struct i2400ms *i2400ms)
151{
152 destroy_workqueue(i2400ms->tx_workqueue);
153}
diff --git a/drivers/net/wimax/i2400m/sdio.c b/drivers/net/wimax/i2400m/sdio.c
new file mode 100644
index 000000000000..1bfa283bbd8a
--- /dev/null
+++ b/drivers/net/wimax/i2400m/sdio.c
@@ -0,0 +1,511 @@
1/*
2 * Intel Wireless WiMAX Connection 2400m
3 * Linux driver model glue for the SDIO device, reset & fw upload
4 *
5 *
6 * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
7 * Dirk Brandewie <dirk.j.brandewie@intel.com>
8 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
9 * Yanir Lubetkin <yanirx.lubetkin@intel.com>
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License version
13 * 2 as published by the Free Software Foundation.
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., 51 Franklin Street, Fifth Floor, Boston, MA
23 * 02110-1301, USA.
24 *
25 *
26 * See i2400m-sdio.h for a general description of this driver.
27 *
28 * This file implements driver model glue, and hook ups for the
29 * generic driver to implement the bus-specific functions (device
30 * communication setup/tear down, firmware upload and resetting).
31 *
32 * ROADMAP
33 *
34 * i2400m_probe()
35 * alloc_netdev()
36 * i2400ms_netdev_setup()
37 * i2400ms_init()
38 * i2400m_netdev_setup()
39 * i2400ms_enable_function()
40 * i2400m_setup()
41 *
42 * i2400m_remove()
43 * i2400m_release()
44 * free_netdev(net_dev)
45 *
46 * i2400ms_bus_reset() Called by i2400m->bus_reset
47 * __i2400ms_reset()
48 * __i2400ms_send_barker()
49 *
50 * i2400ms_bus_dev_start() Called by i2400m_dev_start() [who is
51 * i2400ms_tx_setup() called by i2400m_setup()]
52 * i2400ms_rx_setup()
53 *
54 * i2400ms_bus_dev_stop() Called by i2400m_dev_stop() [who is
55 * i2400ms_rx_release() is called by i2400m_release()]
56 * i2400ms_tx_release()
57 *
58 */
59
60#include <linux/debugfs.h>
61#include <linux/mmc/sdio.h>
62#include <linux/mmc/sdio_func.h>
63#include "i2400m-sdio.h"
64#include <linux/wimax/i2400m.h>
65
66#define D_SUBMODULE main
67#include "sdio-debug-levels.h"
68
69/* IOE WiMAX function timeout in seconds */
70static int ioe_timeout = 2;
71module_param(ioe_timeout, int, 0);
72
73/* Our firmware file name */
74#define I2400MS_FW_FILE_NAME "i2400m-fw-sdio-" I2400M_FW_VERSION ".sbcf"
75
76/*
77 * Enable the SDIO function
78 *
79 * Tries to enable the SDIO function; might fail if it is still not
80 * ready (in some hardware, the SDIO WiMAX function is only enabled
81 * when we ask it to explicitly doing). Tries until a timeout is
82 * reached.
83 *
84 * The reverse of this is...sdio_disable_function()
85 *
86 * Returns: 0 if the SDIO function was enabled, < 0 errno code on
87 * error (-ENODEV when it was unable to enable the function).
88 */
89static
90int i2400ms_enable_function(struct sdio_func *func)
91{
92 u64 timeout;
93 int err;
94 struct device *dev = &func->dev;
95
96 d_fnstart(3, dev, "(func %p)\n", func);
97 /* Setup timeout (FIXME: This needs to read the CIS table to
98 * get a real timeout) and then wait for the device to signal
99 * it is ready */
100 timeout = get_jiffies_64() + ioe_timeout * HZ;
101 err = -ENODEV;
102 while (err != 0 && time_before64(get_jiffies_64(), timeout)) {
103 sdio_claim_host(func);
104 err = sdio_enable_func(func);
105 if (0 == err) {
106 sdio_release_host(func);
107 d_printf(2, dev, "SDIO function enabled\n");
108 goto function_enabled;
109 }
110 d_printf(2, dev, "SDIO function failed to enable: %d\n", err);
111 sdio_disable_func(func);
112 sdio_release_host(func);
113 msleep(I2400MS_INIT_SLEEP_INTERVAL);
114 }
115 /* If timed out, device is not there yet -- get -ENODEV so
116 * the device driver core will retry later on. */
117 if (err == -ETIME) {
118 dev_err(dev, "Can't enable WiMAX function; "
119 " has the function been enabled?\n");
120 err = -ENODEV;
121 }
122function_enabled:
123 d_fnend(3, dev, "(func %p) = %d\n", func, err);
124 return err;
125}
126
127
128/*
129 * Setup driver resources needed to communicate with the device
130 *
131 * The fw needs some time to settle, and it was just uploaded,
132 * so give it a break first. I'd prefer to just wait for the device to
133 * send something, but seems the poking we do to enable SDIO stuff
134 * interferes with it, so just give it a break before starting...
135 */
136static
137int i2400ms_bus_dev_start(struct i2400m *i2400m)
138{
139 int result;
140 struct i2400ms *i2400ms = container_of(i2400m, struct i2400ms, i2400m);
141 struct sdio_func *func = i2400ms->func;
142 struct device *dev = &func->dev;
143
144 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
145 msleep(200);
146 result = i2400ms_rx_setup(i2400ms);
147 if (result < 0)
148 goto error_rx_setup;
149 result = i2400ms_tx_setup(i2400ms);
150 if (result < 0)
151 goto error_tx_setup;
152 d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
153 return result;
154
155 i2400ms_tx_release(i2400ms);
156error_tx_setup:
157 i2400ms_rx_release(i2400ms);
158error_rx_setup:
159 d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
160 return result;
161}
162
163
164static
165void i2400ms_bus_dev_stop(struct i2400m *i2400m)
166{
167 struct i2400ms *i2400ms = container_of(i2400m, struct i2400ms, i2400m);
168 struct sdio_func *func = i2400ms->func;
169 struct device *dev = &func->dev;
170
171 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
172 i2400ms_rx_release(i2400ms);
173 i2400ms_tx_release(i2400ms);
174 d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
175}
176
177
178/*
179 * Sends a barker buffer to the device
180 *
181 * This helper will allocate a kmalloced buffer and use it to transmit
182 * (then free it). Reason for this is that the SDIO host controller
183 * expects alignment (unknown exactly which) which the stack won't
184 * really provide and certain arches/host-controller combinations
185 * cannot use stack/vmalloc/text areas for DMA transfers.
186 */
187static
188int __i2400ms_send_barker(struct i2400ms *i2400ms,
189 const __le32 *barker, size_t barker_size)
190{
191 int ret;
192 struct sdio_func *func = i2400ms->func;
193 struct device *dev = &func->dev;
194 void *buffer;
195
196 ret = -ENOMEM;
197 buffer = kmalloc(I2400MS_BLK_SIZE, GFP_KERNEL);
198 if (buffer == NULL)
199 goto error_kzalloc;
200
201 memcpy(buffer, barker, barker_size);
202 sdio_claim_host(func);
203 ret = sdio_memcpy_toio(func, 0, buffer, I2400MS_BLK_SIZE);
204 sdio_release_host(func);
205
206 if (ret < 0)
207 d_printf(0, dev, "E: barker error: %d\n", ret);
208
209 kfree(buffer);
210error_kzalloc:
211 return ret;
212}
213
214
215/*
216 * Reset a device at different levels (warm, cold or bus)
217 *
218 * @i2400ms: device descriptor
219 * @reset_type: soft, warm or bus reset (I2400M_RT_WARM/SOFT/BUS)
220 *
221 * FIXME: not tested -- need to confirm expected effects
222 *
223 * Warm and cold resets get an SDIO reset if they fail (unimplemented)
224 *
225 * Warm reset:
226 *
227 * The device will be fully reset internally, but won't be
228 * disconnected from the USB bus (so no reenumeration will
229 * happen). Firmware upload will be neccessary.
230 *
231 * The device will send a reboot barker in the notification endpoint
232 * that will trigger the driver to reinitialize the state
233 * automatically from notif.c:i2400m_notification_grok() into
234 * i2400m_dev_bootstrap_delayed().
235 *
236 * Cold and bus (USB) reset:
237 *
238 * The device will be fully reset internally, disconnected from the
239 * USB bus an a reenumeration will happen. Firmware upload will be
240 * neccessary. Thus, we don't do any locking or struct
241 * reinitialization, as we are going to be fully disconnected and
242 * reenumerated.
243 *
244 * Note we need to return -ENODEV if a warm reset was requested and we
245 * had to resort to a bus reset. See i2400m_op_reset(), wimax_reset()
246 * and wimax_dev->op_reset.
247 *
248 * WARNING: no driver state saved/fixed
249 */
250static
251int i2400ms_bus_reset(struct i2400m *i2400m, enum i2400m_reset_type rt)
252{
253 int result;
254 struct i2400ms *i2400ms =
255 container_of(i2400m, struct i2400ms, i2400m);
256 struct device *dev = i2400m_dev(i2400m);
257 static const __le32 i2400m_WARM_BOOT_BARKER[4] = {
258 __constant_cpu_to_le32(I2400M_WARM_RESET_BARKER),
259 __constant_cpu_to_le32(I2400M_WARM_RESET_BARKER),
260 __constant_cpu_to_le32(I2400M_WARM_RESET_BARKER),
261 __constant_cpu_to_le32(I2400M_WARM_RESET_BARKER),
262 };
263 static const __le32 i2400m_COLD_BOOT_BARKER[4] = {
264 __constant_cpu_to_le32(I2400M_COLD_RESET_BARKER),
265 __constant_cpu_to_le32(I2400M_COLD_RESET_BARKER),
266 __constant_cpu_to_le32(I2400M_COLD_RESET_BARKER),
267 __constant_cpu_to_le32(I2400M_COLD_RESET_BARKER),
268 };
269
270 if (rt == I2400M_RT_WARM)
271 result = __i2400ms_send_barker(i2400ms, i2400m_WARM_BOOT_BARKER,
272 sizeof(i2400m_WARM_BOOT_BARKER));
273 else if (rt == I2400M_RT_COLD)
274 result = __i2400ms_send_barker(i2400ms, i2400m_COLD_BOOT_BARKER,
275 sizeof(i2400m_COLD_BOOT_BARKER));
276 else if (rt == I2400M_RT_BUS) {
277do_bus_reset:
278 dev_err(dev, "FIXME: SDIO bus reset not implemented\n");
279 result = rt == I2400M_RT_WARM ? -ENODEV : -ENOSYS;
280 } else
281 BUG();
282 if (result < 0 && rt != I2400M_RT_BUS) {
283 dev_err(dev, "%s reset failed (%d); trying SDIO reset\n",
284 rt == I2400M_RT_WARM ? "warm" : "cold", result);
285 rt = I2400M_RT_BUS;
286 goto do_bus_reset;
287 }
288 return result;
289}
290
291
292static
293void i2400ms_netdev_setup(struct net_device *net_dev)
294{
295 struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
296 struct i2400ms *i2400ms = container_of(i2400m, struct i2400ms, i2400m);
297 i2400ms_init(i2400ms);
298 i2400m_netdev_setup(net_dev);
299}
300
301
302/*
303 * Debug levels control; see debug.h
304 */
305struct d_level D_LEVEL[] = {
306 D_SUBMODULE_DEFINE(main),
307 D_SUBMODULE_DEFINE(tx),
308 D_SUBMODULE_DEFINE(rx),
309 D_SUBMODULE_DEFINE(fw),
310};
311size_t D_LEVEL_SIZE = ARRAY_SIZE(D_LEVEL);
312
313
314#define __debugfs_register(prefix, name, parent) \
315do { \
316 result = d_level_register_debugfs(prefix, name, parent); \
317 if (result < 0) \
318 goto error; \
319} while (0)
320
321
322static
323int i2400ms_debugfs_add(struct i2400ms *i2400ms)
324{
325 int result;
326 struct dentry *dentry = i2400ms->i2400m.wimax_dev.debugfs_dentry;
327
328 dentry = debugfs_create_dir("i2400m-usb", dentry);
329 result = PTR_ERR(dentry);
330 if (IS_ERR(dentry)) {
331 if (result == -ENODEV)
332 result = 0; /* No debugfs support */
333 goto error;
334 }
335 i2400ms->debugfs_dentry = dentry;
336 __debugfs_register("dl_", main, dentry);
337 __debugfs_register("dl_", tx, dentry);
338 __debugfs_register("dl_", rx, dentry);
339 __debugfs_register("dl_", fw, dentry);
340
341 return 0;
342
343error:
344 debugfs_remove_recursive(i2400ms->debugfs_dentry);
345 return result;
346}
347
348
349/*
350 * Probe a i2400m interface and register it
351 *
352 * @func: SDIO function
353 * @id: SDIO device ID
354 * @returns: 0 if ok, < 0 errno code on error.
355 *
356 * Alloc a net device, initialize the bus-specific details and then
357 * calls the bus-generic initialization routine. That will register
358 * the wimax and netdev devices, upload the firmware [using
359 * _bus_bm_*()], call _bus_dev_start() to finalize the setup of the
360 * communication with the device and then will start to talk to it to
361 * finnish setting it up.
362 *
363 * Initialization is tricky; some instances of the hw are packed with
364 * others in a way that requires a third driver that enables the WiMAX
365 * function. In those cases, we can't enable the SDIO function and
366 * we'll return with -ENODEV. When the driver that enables the WiMAX
367 * function does its thing, it has to do a bus_rescan_devices() on the
368 * SDIO bus so this driver is called again to enumerate the WiMAX
369 * function.
370 */
371static
372int i2400ms_probe(struct sdio_func *func,
373 const struct sdio_device_id *id)
374{
375 int result;
376 struct net_device *net_dev;
377 struct device *dev = &func->dev;
378 struct i2400m *i2400m;
379 struct i2400ms *i2400ms;
380
381 /* Allocate instance [calls i2400m_netdev_setup() on it]. */
382 result = -ENOMEM;
383 net_dev = alloc_netdev(sizeof(*i2400ms), "wmx%d",
384 i2400ms_netdev_setup);
385 if (net_dev == NULL) {
386 dev_err(dev, "no memory for network device instance\n");
387 goto error_alloc_netdev;
388 }
389 SET_NETDEV_DEV(net_dev, dev);
390 i2400m = net_dev_to_i2400m(net_dev);
391 i2400ms = container_of(i2400m, struct i2400ms, i2400m);
392 i2400m->wimax_dev.net_dev = net_dev;
393 i2400ms->func = func;
394 sdio_set_drvdata(func, i2400ms);
395
396 i2400m->bus_tx_block_size = I2400MS_BLK_SIZE;
397 i2400m->bus_pl_size_max = I2400MS_PL_SIZE_MAX;
398 i2400m->bus_dev_start = i2400ms_bus_dev_start;
399 i2400m->bus_dev_stop = i2400ms_bus_dev_stop;
400 i2400m->bus_tx_kick = i2400ms_bus_tx_kick;
401 i2400m->bus_reset = i2400ms_bus_reset;
402 i2400m->bus_bm_cmd_send = i2400ms_bus_bm_cmd_send;
403 i2400m->bus_bm_wait_for_ack = i2400ms_bus_bm_wait_for_ack;
404 i2400m->bus_fw_name = I2400MS_FW_FILE_NAME;
405 i2400m->bus_bm_mac_addr_impaired = 1;
406
407 result = i2400ms_enable_function(i2400ms->func);
408 if (result < 0) {
409 dev_err(dev, "Cannot enable SDIO function: %d\n", result);
410 goto error_func_enable;
411 }
412
413 sdio_claim_host(func);
414 result = sdio_set_block_size(func, I2400MS_BLK_SIZE);
415 if (result < 0) {
416 dev_err(dev, "Failed to set block size: %d\n", result);
417 goto error_set_blk_size;
418 }
419 sdio_release_host(func);
420
421 result = i2400m_setup(i2400m, I2400M_BRI_NO_REBOOT);
422 if (result < 0) {
423 dev_err(dev, "cannot setup device: %d\n", result);
424 goto error_setup;
425 }
426
427 result = i2400ms_debugfs_add(i2400ms);
428 if (result < 0) {
429 dev_err(dev, "cannot create SDIO debugfs: %d\n",
430 result);
431 goto error_debugfs_add;
432 }
433 return 0;
434
435error_debugfs_add:
436 i2400m_release(i2400m);
437error_setup:
438 sdio_set_drvdata(func, NULL);
439 sdio_claim_host(func);
440error_set_blk_size:
441 sdio_disable_func(func);
442 sdio_release_host(func);
443error_func_enable:
444 free_netdev(net_dev);
445error_alloc_netdev:
446 return result;
447}
448
449
450static
451void i2400ms_remove(struct sdio_func *func)
452{
453 struct device *dev = &func->dev;
454 struct i2400ms *i2400ms = sdio_get_drvdata(func);
455 struct i2400m *i2400m = &i2400ms->i2400m;
456 struct net_device *net_dev = i2400m->wimax_dev.net_dev;
457
458 d_fnstart(3, dev, "SDIO func %p\n", func);
459 debugfs_remove_recursive(i2400ms->debugfs_dentry);
460 i2400m_release(i2400m);
461 sdio_set_drvdata(func, NULL);
462 sdio_claim_host(func);
463 sdio_disable_func(func);
464 sdio_release_host(func);
465 free_netdev(net_dev);
466 d_fnend(3, dev, "SDIO func %p\n", func);
467}
468
469enum {
470 I2400MS_INTEL_VID = 0x89,
471};
472
473static
474const struct sdio_device_id i2400ms_sdio_ids[] = {
475 /* Intel: i2400m WiMAX over SDIO */
476 { SDIO_DEVICE(I2400MS_INTEL_VID, 0x1402) },
477 { }, /* end: all zeroes */
478};
479MODULE_DEVICE_TABLE(sdio, i2400ms_sdio_ids);
480
481
482static
483struct sdio_driver i2400m_sdio_driver = {
484 .name = KBUILD_MODNAME,
485 .probe = i2400ms_probe,
486 .remove = i2400ms_remove,
487 .id_table = i2400ms_sdio_ids,
488};
489
490
491static
492int __init i2400ms_driver_init(void)
493{
494 return sdio_register_driver(&i2400m_sdio_driver);
495}
496module_init(i2400ms_driver_init);
497
498
499static
500void __exit i2400ms_driver_exit(void)
501{
502 flush_scheduled_work(); /* for the stuff we schedule */
503 sdio_unregister_driver(&i2400m_sdio_driver);
504}
505module_exit(i2400ms_driver_exit);
506
507
508MODULE_AUTHOR("Intel Corporation <linux-wimax@intel.com>");
509MODULE_DESCRIPTION("Intel 2400M WiMAX networking for SDIO");
510MODULE_LICENSE("GPL");
511MODULE_FIRMWARE(I2400MS_FW_FILE_NAME);
diff --git a/drivers/net/wimax/i2400m/tx.c b/drivers/net/wimax/i2400m/tx.c
new file mode 100644
index 000000000000..613a88ffd651
--- /dev/null
+++ b/drivers/net/wimax/i2400m/tx.c
@@ -0,0 +1,817 @@
1/*
2 * Intel Wireless WiMAX Connection 2400m
3 * Generic (non-bus specific) TX handling
4 *
5 *
6 * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 *
35 * Intel Corporation <linux-wimax@intel.com>
36 * Yanir Lubetkin <yanirx.lubetkin@intel.com>
37 * - Initial implementation
38 *
39 * Intel Corporation <linux-wimax@intel.com>
40 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
41 * - Rewritten to use a single FIFO to lower the memory allocation
42 * pressure and optimize cache hits when copying to the queue, as
43 * well as splitting out bus-specific code.
44 *
45 *
46 * Implements data transmission to the device; this is done through a
47 * software FIFO, as data/control frames can be coalesced (while the
48 * device is reading the previous tx transaction, others accumulate).
49 *
50 * A FIFO is used because at the end it is resource-cheaper that trying
51 * to implement scatter/gather over USB. As well, most traffic is going
52 * to be download (vs upload).
53 *
54 * The format for sending/receiving data to/from the i2400m is
55 * described in detail in rx.c:PROTOCOL FORMAT. In here we implement
56 * the transmission of that. This is split between a bus-independent
57 * part that just prepares everything and a bus-specific part that
58 * does the actual transmission over the bus to the device (in the
59 * bus-specific driver).
60 *
61 *
62 * The general format of a device-host transaction is MSG-HDR, PLD1,
63 * PLD2...PLDN, PL1, PL2,...PLN, PADDING.
64 *
65 * Because we need the send payload descriptors and then payloads and
66 * because it is kind of expensive to do scatterlists in USB (one URB
67 * per node), it becomes cheaper to append all the data to a FIFO
68 * (copying to a FIFO potentially in cache is cheaper).
69 *
70 * Then the bus-specific code takes the parts of that FIFO that are
71 * written and passes them to the device.
72 *
73 * So the concepts to keep in mind there are:
74 *
75 * We use a FIFO to queue the data in a linear buffer. We first append
76 * a MSG-HDR, space for I2400M_TX_PLD_MAX payload descriptors and then
77 * go appending payloads until we run out of space or of payload
78 * descriptors. Then we append padding to make the whole transaction a
79 * multiple of i2400m->bus_tx_block_size (as defined by the bus layer).
80 *
81 * - A TX message: a combination of a message header, payload
82 * descriptors and payloads.
83 *
84 * Open: it is marked as active (i2400m->tx_msg is valid) and we
85 * can keep adding payloads to it.
86 *
87 * Closed: we are not appending more payloads to this TX message
88 * (exahusted space in the queue, too many payloads or
89 * whichever). We have appended padding so the whole message
90 * length is aligned to i2400m->bus_tx_block_size (as set by the
91 * bus/transport layer).
92 *
93 * - Most of the time we keep a TX message open to which we append
94 * payloads.
95 *
96 * - If we are going to append and there is no more space (we are at
97 * the end of the FIFO), we close the message, mark the rest of the
98 * FIFO space unusable (skip_tail), create a new message at the
99 * beginning of the FIFO (if there is space) and append the message
100 * there.
101 *
102 * This is because we need to give linear TX messages to the bus
103 * engine. So we don't write a message to the remaining FIFO space
104 * until the tail and continue at the head of it.
105 *
106 * - We overload one of the fields in the message header to use it as
107 * 'size' of the TX message, so we can iterate over them. It also
108 * contains a flag that indicates if we have to skip it or not.
109 * When we send the buffer, we update that to its real on-the-wire
110 * value.
111 *
112 * - The MSG-HDR PLD1...PLD2 stuff has to be a size multiple of 16.
113 *
114 * It follows that if MSG-HDR says we have N messages, the whole
115 * header + descriptors is 16 + 4*N; for those to be a multiple of
116 * 16, it follows that N can be 4, 8, 12, ... (32, 48, 64, 80...
117 * bytes).
118 *
119 * So if we have only 1 payload, we have to submit a header that in
120 * all truth has space for 4.
121 *
122 * The implication is that we reserve space for 12 (64 bytes); but
123 * if we fill up only (eg) 2, our header becomes 32 bytes only. So
124 * the TX engine has to shift those 32 bytes of msg header and 2
125 * payloads and padding so that right after it the payloads start
126 * and the TX engine has to know about that.
127 *
128 * It is cheaper to move the header up than the whole payloads down.
129 *
130 * We do this in i2400m_tx_close(). See 'i2400m_msg_hdr->offset'.
131 *
132 * - Each payload has to be size-padded to 16 bytes; before appending
133 * it, we just do it.
134 *
135 * - The whole message has to be padded to i2400m->bus_tx_block_size;
136 * we do this at close time. Thus, when reserving space for the
137 * payload, we always make sure there is also free space for this
138 * padding that sooner or later will happen.
139 *
140 * When we append a message, we tell the bus specific code to kick in
141 * TXs. It will TX (in parallel) until the buffer is exhausted--hence
142 * the lockin we do. The TX code will only send a TX message at the
143 * time (which remember, might contain more than one payload). Of
144 * course, when the bus-specific driver attempts to TX a message that
145 * is still open, it gets closed first.
146 *
147 * Gee, this is messy; well a picture. In the example below we have a
148 * partially full FIFO, with a closed message ready to be delivered
149 * (with a moved message header to make sure it is size-aligned to
150 * 16), TAIL room that was unusable (and thus is marked with a message
151 * header that says 'skip this') and at the head of the buffer, an
152 * imcomplete message with a couple of payloads.
153 *
154 * N ___________________________________________________
155 * | |
156 * | TAIL room |
157 * | |
158 * | msg_hdr to skip (size |= 0x80000) |
159 * |---------------------------------------------------|-------
160 * | | /|\
161 * | | |
162 * | TX message padding | |
163 * | | |
164 * | | |
165 * |- - - - - - - - - - - - - - - - - - - - - - - - - -| |
166 * | | |
167 * | payload 1 | |
168 * | | N * tx_block_size
169 * | | |
170 * |- - - - - - - - - - - - - - - - - - - - - - - - - -| |
171 * | | |
172 * | payload 1 | |
173 * | | |
174 * | | |
175 * |- - - - - - - - - - - - - - - - - - - - - - - - - -|- -|- - - -
176 * | padding 3 /|\ | | /|\
177 * | padding 2 | | | |
178 * | pld 1 32 bytes (2 * 16) | | |
179 * | pld 0 | | | |
180 * | moved msg_hdr \|/ | \|/ |
181 * |- - - - - - - - - - - - - - - - - - - - - - - - - -|- - - |
182 * | | _PLD_SIZE
183 * | unused | |
184 * | | |
185 * |- - - - - - - - - - - - - - - - - - - - - - - - - -| |
186 * | msg_hdr (size X) [this message is closed] | \|/
187 * |===================================================|========== <=== OUT
188 * | |
189 * | |
190 * | |
191 * | Free rooom |
192 * | |
193 * | |
194 * | |
195 * | |
196 * | |
197 * | |
198 * | |
199 * | |
200 * | |
201 * |===================================================|========== <=== IN
202 * | |
203 * | |
204 * | |
205 * | |
206 * | payload 1 |
207 * | |
208 * | |
209 * |- - - - - - - - - - - - - - - - - - - - - - - - - -|
210 * | |
211 * | payload 0 |
212 * | |
213 * | |
214 * |- - - - - - - - - - - - - - - - - - - - - - - - - -|
215 * | pld 11 /|\ |
216 * | ... | |
217 * | pld 1 64 bytes (2 * 16) |
218 * | pld 0 | |
219 * | msg_hdr (size X) \|/ [message is open] |
220 * 0 ---------------------------------------------------
221 *
222 *
223 * ROADMAP
224 *
225 * i2400m_tx_setup() Called by i2400m_setup
226 * i2400m_tx_release() Called by i2400m_release()
227 *
228 * i2400m_tx() Called to send data or control frames
229 * i2400m_tx_fifo_push() Allocates append-space in the FIFO
230 * i2400m_tx_new() Opens a new message in the FIFO
231 * i2400m_tx_fits() Checks if a new payload fits in the message
232 * i2400m_tx_close() Closes an open message in the FIFO
233 * i2400m_tx_skip_tail() Marks unusable FIFO tail space
234 * i2400m->bus_tx_kick()
235 *
236 * Now i2400m->bus_tx_kick() is the the bus-specific driver backend
237 * implementation; that would do:
238 *
239 * i2400m->bus_tx_kick()
240 * i2400m_tx_msg_get() Gets first message ready to go
241 * ...sends it...
242 * i2400m_tx_msg_sent() Ack the message is sent; repeat from
243 * _tx_msg_get() until it returns NULL
244 * (FIFO empty).
245 */
246#include <linux/netdevice.h>
247#include "i2400m.h"
248
249
250#define D_SUBMODULE tx
251#include "debug-levels.h"
252
253enum {
254 /**
255 * TX Buffer size
256 *
257 * Doc says maximum transaction is 16KiB. If we had 16KiB en
258 * route and 16KiB being queued, it boils down to needing
259 * 32KiB.
260 */
261 I2400M_TX_BUF_SIZE = 32768,
262 /**
263 * Message header and payload descriptors have to be 16
264 * aligned (16 + 4 * N = 16 * M). If we take that average sent
265 * packets are MTU size (~1400-~1500) it follows that we could
266 * fit at most 10-11 payloads in one transaction. To meet the
267 * alignment requirement, that means we need to leave space
268 * for 12 (64 bytes). To simplify, we leave space for that. If
269 * at the end there are less, we pad up to the nearest
270 * multiple of 16.
271 */
272 I2400M_TX_PLD_MAX = 12,
273 I2400M_TX_PLD_SIZE = sizeof(struct i2400m_msg_hdr)
274 + I2400M_TX_PLD_MAX * sizeof(struct i2400m_pld),
275 I2400M_TX_SKIP = 0x80000000,
276};
277
278#define TAIL_FULL ((void *)~(unsigned long)NULL)
279
280/*
281 * Allocate @size bytes in the TX fifo, return a pointer to it
282 *
283 * @i2400m: device descriptor
284 * @size: size of the buffer we need to allocate
285 * @padding: ensure that there is at least this many bytes of free
286 * contiguous space in the fifo. This is needed because later on
287 * we might need to add padding.
288 *
289 * Returns:
290 *
291 * Pointer to the allocated space. NULL if there is no
292 * space. TAIL_FULL if there is no space at the tail but there is at
293 * the head (Case B below).
294 *
295 * These are the two basic cases we need to keep an eye for -- it is
296 * much better explained in linux/kernel/kfifo.c, but this code
297 * basically does the same. No rocket science here.
298 *
299 * Case A Case B
300 * N ___________ ___________
301 * | tail room | | data |
302 * | | | |
303 * |<- IN ->| |<- OUT ->|
304 * | | | |
305 * | data | | room |
306 * | | | |
307 * |<- OUT ->| |<- IN ->|
308 * | | | |
309 * | head room | | data |
310 * 0 ----------- -----------
311 *
312 * We allocate only *contiguous* space.
313 *
314 * We can allocate only from 'room'. In Case B, it is simple; in case
315 * A, we only try from the tail room; if it is not enough, we just
316 * fail and return TAIL_FULL and let the caller figure out if we wants to
317 * skip the tail room and try to allocate from the head.
318 *
319 * Note:
320 *
321 * Assumes i2400m->tx_lock is taken, and we use that as a barrier
322 *
323 * The indexes keep increasing and we reset them to zero when we
324 * pop data off the queue
325 */
326static
327void *i2400m_tx_fifo_push(struct i2400m *i2400m, size_t size, size_t padding)
328{
329 struct device *dev = i2400m_dev(i2400m);
330 size_t room, tail_room, needed_size;
331 void *ptr;
332
333 needed_size = size + padding;
334 room = I2400M_TX_BUF_SIZE - (i2400m->tx_in - i2400m->tx_out);
335 if (room < needed_size) { /* this takes care of Case B */
336 d_printf(2, dev, "fifo push %zu/%zu: no space\n",
337 size, padding);
338 return NULL;
339 }
340 /* Is there space at the tail? */
341 tail_room = I2400M_TX_BUF_SIZE - i2400m->tx_in % I2400M_TX_BUF_SIZE;
342 if (tail_room < needed_size) {
343 if (i2400m->tx_out % I2400M_TX_BUF_SIZE
344 < i2400m->tx_in % I2400M_TX_BUF_SIZE) {
345 d_printf(2, dev, "fifo push %zu/%zu: tail full\n",
346 size, padding);
347 return TAIL_FULL; /* There might be head space */
348 } else {
349 d_printf(2, dev, "fifo push %zu/%zu: no head space\n",
350 size, padding);
351 return NULL; /* There is no space */
352 }
353 }
354 ptr = i2400m->tx_buf + i2400m->tx_in % I2400M_TX_BUF_SIZE;
355 d_printf(2, dev, "fifo push %zu/%zu: at @%zu\n", size, padding,
356 i2400m->tx_in % I2400M_TX_BUF_SIZE);
357 i2400m->tx_in += size;
358 return ptr;
359}
360
361
362/*
363 * Mark the tail of the FIFO buffer as 'to-skip'
364 *
365 * We should never hit the BUG_ON() because all the sizes we push to
366 * the FIFO are padded to be a multiple of 16 -- the size of *msg
367 * (I2400M_PL_PAD for the payloads, I2400M_TX_PLD_SIZE for the
368 * header).
369 *
370 * Note:
371 *
372 * Assumes i2400m->tx_lock is taken, and we use that as a barrier
373 */
374static
375void i2400m_tx_skip_tail(struct i2400m *i2400m)
376{
377 struct device *dev = i2400m_dev(i2400m);
378 size_t tx_in = i2400m->tx_in % I2400M_TX_BUF_SIZE;
379 size_t tail_room = I2400M_TX_BUF_SIZE - tx_in;
380 struct i2400m_msg_hdr *msg = i2400m->tx_buf + tx_in;
381 BUG_ON(tail_room < sizeof(*msg));
382 msg->size = tail_room | I2400M_TX_SKIP;
383 d_printf(2, dev, "skip tail: skipping %zu bytes @%zu\n",
384 tail_room, tx_in);
385 i2400m->tx_in += tail_room;
386}
387
388
389/*
390 * Check if a skb will fit in the TX queue's current active TX
391 * message (if there are still descriptors left unused).
392 *
393 * Returns:
394 * 0 if the message won't fit, 1 if it will.
395 *
396 * Note:
397 *
398 * Assumes a TX message is active (i2400m->tx_msg).
399 *
400 * Assumes i2400m->tx_lock is taken, and we use that as a barrier
401 */
402static
403unsigned i2400m_tx_fits(struct i2400m *i2400m)
404{
405 struct i2400m_msg_hdr *msg_hdr = i2400m->tx_msg;
406 return le16_to_cpu(msg_hdr->num_pls) < I2400M_TX_PLD_MAX;
407
408}
409
410
411/*
412 * Start a new TX message header in the queue.
413 *
414 * Reserve memory from the base FIFO engine and then just initialize
415 * the message header.
416 *
417 * We allocate the biggest TX message header we might need (one that'd
418 * fit I2400M_TX_PLD_MAX payloads) -- when it is closed it will be
419 * 'ironed it out' and the unneeded parts removed.
420 *
421 * NOTE:
422 *
423 * Assumes that the previous message is CLOSED (eg: either
424 * there was none or 'i2400m_tx_close()' was called on it).
425 *
426 * Assumes i2400m->tx_lock is taken, and we use that as a barrier
427 */
428static
429void i2400m_tx_new(struct i2400m *i2400m)
430{
431 struct device *dev = i2400m_dev(i2400m);
432 struct i2400m_msg_hdr *tx_msg;
433 BUG_ON(i2400m->tx_msg != NULL);
434try_head:
435 tx_msg = i2400m_tx_fifo_push(i2400m, I2400M_TX_PLD_SIZE, 0);
436 if (tx_msg == NULL)
437 goto out;
438 else if (tx_msg == TAIL_FULL) {
439 i2400m_tx_skip_tail(i2400m);
440 d_printf(2, dev, "new TX message: tail full, trying head\n");
441 goto try_head;
442 }
443 memset(tx_msg, 0, I2400M_TX_PLD_SIZE);
444 tx_msg->size = I2400M_TX_PLD_SIZE;
445out:
446 i2400m->tx_msg = tx_msg;
447 d_printf(2, dev, "new TX message: %p @%zu\n",
448 tx_msg, (void *) tx_msg - i2400m->tx_buf);
449}
450
451
452/*
453 * Finalize the current TX message header
454 *
455 * Sets the message header to be at the proper location depending on
456 * how many descriptors we have (check documentation at the file's
457 * header for more info on that).
458 *
459 * Appends padding bytes to make sure the whole TX message (counting
460 * from the 'relocated' message header) is aligned to
461 * tx_block_size. We assume the _append() code has left enough space
462 * in the FIFO for that. If there are no payloads, just pass, as it
463 * won't be transferred.
464 *
465 * The amount of padding bytes depends on how many payloads are in the
466 * TX message, as the "msg header and payload descriptors" will be
467 * shifted up in the buffer.
468 */
469static
470void i2400m_tx_close(struct i2400m *i2400m)
471{
472 struct device *dev = i2400m_dev(i2400m);
473 struct i2400m_msg_hdr *tx_msg = i2400m->tx_msg;
474 struct i2400m_msg_hdr *tx_msg_moved;
475 size_t aligned_size, padding, hdr_size;
476 void *pad_buf;
477
478 if (tx_msg->size & I2400M_TX_SKIP) /* a skipper? nothing to do */
479 goto out;
480
481 /* Relocate the message header
482 *
483 * Find the current header size, align it to 16 and if we need
484 * to move it so the tail is next to the payloads, move it and
485 * set the offset.
486 *
487 * If it moved, this header is good only for transmission; the
488 * original one (it is kept if we moved) is still used to
489 * figure out where the next TX message starts (and where the
490 * offset to the moved header is).
491 */
492 hdr_size = sizeof(*tx_msg)
493 + le16_to_cpu(tx_msg->num_pls) * sizeof(tx_msg->pld[0]);
494 hdr_size = ALIGN(hdr_size, I2400M_PL_PAD);
495 tx_msg->offset = I2400M_TX_PLD_SIZE - hdr_size;
496 tx_msg_moved = (void *) tx_msg + tx_msg->offset;
497 memmove(tx_msg_moved, tx_msg, hdr_size);
498 tx_msg_moved->size -= tx_msg->offset;
499 /*
500 * Now figure out how much we have to add to the (moved!)
501 * message so the size is a multiple of i2400m->bus_tx_block_size.
502 */
503 aligned_size = ALIGN(tx_msg_moved->size, i2400m->bus_tx_block_size);
504 padding = aligned_size - tx_msg_moved->size;
505 if (padding > 0) {
506 pad_buf = i2400m_tx_fifo_push(i2400m, padding, 0);
507 if (unlikely(WARN_ON(pad_buf == NULL
508 || pad_buf == TAIL_FULL))) {
509 /* This should not happen -- append should verify
510 * there is always space left at least to append
511 * tx_block_size */
512 dev_err(dev,
513 "SW BUG! Possible data leakage from memory the "
514 "device should not read for padding - "
515 "size %lu aligned_size %zu tx_buf %p in "
516 "%zu out %zu\n",
517 (unsigned long) tx_msg_moved->size,
518 aligned_size, i2400m->tx_buf, i2400m->tx_in,
519 i2400m->tx_out);
520 } else
521 memset(pad_buf, 0xad, padding);
522 }
523 tx_msg_moved->padding = cpu_to_le16(padding);
524 tx_msg_moved->size += padding;
525 if (tx_msg != tx_msg_moved)
526 tx_msg->size += padding;
527out:
528 i2400m->tx_msg = NULL;
529}
530
531
532/**
533 * i2400m_tx - send the data in a buffer to the device
534 *
535 * @buf: pointer to the buffer to transmit
536 *
537 * @buf_len: buffer size
538 *
539 * @pl_type: type of the payload we are sending.
540 *
541 * Returns:
542 * 0 if ok, < 0 errno code on error (-ENOSPC, if there is no more
543 * room for the message in the queue).
544 *
545 * Appends the buffer to the TX FIFO and notifies the bus-specific
546 * part of the driver that there is new data ready to transmit.
547 * Once this function returns, the buffer has been copied, so it can
548 * be reused.
549 *
550 * The steps followed to append are explained in detail in the file
551 * header.
552 *
553 * Whenever we write to a message, we increase msg->size, so it
554 * reflects exactly how big the message is. This is needed so that if
555 * we concatenate two messages before they can be sent, the code that
556 * sends the messages can find the boundaries (and it will replace the
557 * size with the real barker before sending).
558 *
559 * Note:
560 *
561 * Cold and warm reset payloads need to be sent as a single
562 * payload, so we handle that.
563 */
564int i2400m_tx(struct i2400m *i2400m, const void *buf, size_t buf_len,
565 enum i2400m_pt pl_type)
566{
567 int result = -ENOSPC;
568 struct device *dev = i2400m_dev(i2400m);
569 unsigned long flags;
570 size_t padded_len;
571 void *ptr;
572 unsigned is_singleton = pl_type == I2400M_PT_RESET_WARM
573 || pl_type == I2400M_PT_RESET_COLD;
574
575 d_fnstart(3, dev, "(i2400m %p skb %p [%zu bytes] pt %u)\n",
576 i2400m, buf, buf_len, pl_type);
577 padded_len = ALIGN(buf_len, I2400M_PL_PAD);
578 d_printf(5, dev, "padded_len %zd buf_len %zd\n", padded_len, buf_len);
579 /* If there is no current TX message, create one; if the
580 * current one is out of payload slots or we have a singleton,
581 * close it and start a new one */
582 spin_lock_irqsave(&i2400m->tx_lock, flags);
583try_new:
584 if (unlikely(i2400m->tx_msg == NULL))
585 i2400m_tx_new(i2400m);
586 else if (unlikely(!i2400m_tx_fits(i2400m)
587 || (is_singleton && i2400m->tx_msg->num_pls != 0))) {
588 d_printf(2, dev, "closing TX message (fits %u singleton "
589 "%u num_pls %u)\n", i2400m_tx_fits(i2400m),
590 is_singleton, i2400m->tx_msg->num_pls);
591 i2400m_tx_close(i2400m);
592 i2400m_tx_new(i2400m);
593 }
594 if (i2400m->tx_msg->size + padded_len > I2400M_TX_BUF_SIZE / 2) {
595 d_printf(2, dev, "TX: message too big, going new\n");
596 i2400m_tx_close(i2400m);
597 i2400m_tx_new(i2400m);
598 }
599 if (i2400m->tx_msg == NULL)
600 goto error_tx_new;
601 /* So we have a current message header; now append space for
602 * the message -- if there is not enough, try the head */
603 ptr = i2400m_tx_fifo_push(i2400m, padded_len,
604 i2400m->bus_tx_block_size);
605 if (ptr == TAIL_FULL) { /* Tail is full, try head */
606 d_printf(2, dev, "pl append: tail full\n");
607 i2400m_tx_close(i2400m);
608 i2400m_tx_skip_tail(i2400m);
609 goto try_new;
610 } else if (ptr == NULL) { /* All full */
611 result = -ENOSPC;
612 d_printf(2, dev, "pl append: all full\n");
613 } else { /* Got space, copy it, set padding */
614 struct i2400m_msg_hdr *tx_msg = i2400m->tx_msg;
615 unsigned num_pls = le16_to_cpu(tx_msg->num_pls);
616 memcpy(ptr, buf, buf_len);
617 memset(ptr + buf_len, 0xad, padded_len - buf_len);
618 i2400m_pld_set(&tx_msg->pld[num_pls], buf_len, pl_type);
619 d_printf(3, dev, "pld 0x%08x (type 0x%1x len 0x%04zx\n",
620 le32_to_cpu(tx_msg->pld[num_pls].val),
621 pl_type, buf_len);
622 tx_msg->num_pls = le16_to_cpu(num_pls+1);
623 tx_msg->size += padded_len;
624 d_printf(2, dev, "TX: appended %zu b (up to %u b) pl #%u \n",
625 padded_len, tx_msg->size, num_pls+1);
626 d_printf(2, dev,
627 "TX: appended hdr @%zu %zu b pl #%u @%zu %zu/%zu b\n",
628 (void *)tx_msg - i2400m->tx_buf, (size_t)tx_msg->size,
629 num_pls+1, ptr - i2400m->tx_buf, buf_len, padded_len);
630 result = 0;
631 if (is_singleton)
632 i2400m_tx_close(i2400m);
633 }
634error_tx_new:
635 spin_unlock_irqrestore(&i2400m->tx_lock, flags);
636 i2400m->bus_tx_kick(i2400m); /* always kick, might free up space */
637 d_fnend(3, dev, "(i2400m %p skb %p [%zu bytes] pt %u) = %d\n",
638 i2400m, buf, buf_len, pl_type, result);
639 return result;
640}
641EXPORT_SYMBOL_GPL(i2400m_tx);
642
643
644/**
645 * i2400m_tx_msg_get - Get the first TX message in the FIFO to start sending it
646 *
647 * @i2400m: device descriptors
648 * @bus_size: where to place the size of the TX message
649 *
650 * Called by the bus-specific driver to get the first TX message at
651 * the FIF that is ready for transmission.
652 *
653 * It sets the state in @i2400m to indicate the bus-specific driver is
654 * transfering that message (i2400m->tx_msg_size).
655 *
656 * Once the transfer is completed, call i2400m_tx_msg_sent().
657 *
658 * Notes:
659 *
660 * The size of the TX message to be transmitted might be smaller than
661 * that of the TX message in the FIFO (in case the header was
662 * shorter). Hence, we copy it in @bus_size, for the bus layer to
663 * use. We keep the message's size in i2400m->tx_msg_size so that
664 * when the bus later is done transferring we know how much to
665 * advance the fifo.
666 *
667 * We collect statistics here as all the data is available and we
668 * assume it is going to work [see i2400m_tx_msg_sent()].
669 */
670struct i2400m_msg_hdr *i2400m_tx_msg_get(struct i2400m *i2400m,
671 size_t *bus_size)
672{
673 struct device *dev = i2400m_dev(i2400m);
674 struct i2400m_msg_hdr *tx_msg, *tx_msg_moved;
675 unsigned long flags, pls;
676
677 d_fnstart(3, dev, "(i2400m %p bus_size %p)\n", i2400m, bus_size);
678 spin_lock_irqsave(&i2400m->tx_lock, flags);
679skip:
680 tx_msg_moved = NULL;
681 if (i2400m->tx_in == i2400m->tx_out) { /* Empty FIFO? */
682 i2400m->tx_in = 0;
683 i2400m->tx_out = 0;
684 d_printf(2, dev, "TX: FIFO empty: resetting\n");
685 goto out_unlock;
686 }
687 tx_msg = i2400m->tx_buf + i2400m->tx_out % I2400M_TX_BUF_SIZE;
688 if (tx_msg->size & I2400M_TX_SKIP) { /* skip? */
689 d_printf(2, dev, "TX: skip: msg @%zu (%zu b)\n",
690 i2400m->tx_out % I2400M_TX_BUF_SIZE,
691 (size_t) tx_msg->size & ~I2400M_TX_SKIP);
692 i2400m->tx_out += tx_msg->size & ~I2400M_TX_SKIP;
693 goto skip;
694 }
695
696 if (tx_msg->num_pls == 0) { /* No payloads? */
697 if (tx_msg == i2400m->tx_msg) { /* open, we are done */
698 d_printf(2, dev,
699 "TX: FIFO empty: open msg w/o payloads @%zu\n",
700 (void *) tx_msg - i2400m->tx_buf);
701 tx_msg = NULL;
702 goto out_unlock;
703 } else { /* closed, skip it */
704 d_printf(2, dev,
705 "TX: skip msg w/o payloads @%zu (%zu b)\n",
706 (void *) tx_msg - i2400m->tx_buf,
707 (size_t) tx_msg->size);
708 i2400m->tx_out += tx_msg->size & ~I2400M_TX_SKIP;
709 goto skip;
710 }
711 }
712 if (tx_msg == i2400m->tx_msg) /* open msg? */
713 i2400m_tx_close(i2400m);
714
715 /* Now we have a valid TX message (with payloads) to TX */
716 tx_msg_moved = (void *) tx_msg + tx_msg->offset;
717 i2400m->tx_msg_size = tx_msg->size;
718 *bus_size = tx_msg_moved->size;
719 d_printf(2, dev, "TX: pid %d msg hdr at @%zu offset +@%zu "
720 "size %zu bus_size %zu\n",
721 current->pid, (void *) tx_msg - i2400m->tx_buf,
722 (size_t) tx_msg->offset, (size_t) tx_msg->size,
723 (size_t) tx_msg_moved->size);
724 tx_msg_moved->barker = le32_to_cpu(I2400M_H2D_PREVIEW_BARKER);
725 tx_msg_moved->sequence = le32_to_cpu(i2400m->tx_sequence++);
726
727 pls = le32_to_cpu(tx_msg_moved->num_pls);
728 i2400m->tx_pl_num += pls; /* Update stats */
729 if (pls > i2400m->tx_pl_max)
730 i2400m->tx_pl_max = pls;
731 if (pls < i2400m->tx_pl_min)
732 i2400m->tx_pl_min = pls;
733 i2400m->tx_num++;
734 i2400m->tx_size_acc += *bus_size;
735 if (*bus_size < i2400m->tx_size_min)
736 i2400m->tx_size_min = *bus_size;
737 if (*bus_size > i2400m->tx_size_max)
738 i2400m->tx_size_max = *bus_size;
739out_unlock:
740 spin_unlock_irqrestore(&i2400m->tx_lock, flags);
741 d_fnstart(3, dev, "(i2400m %p bus_size %p [%zu]) = %p\n",
742 i2400m, bus_size, *bus_size, tx_msg_moved);
743 return tx_msg_moved;
744}
745EXPORT_SYMBOL_GPL(i2400m_tx_msg_get);
746
747
748/**
749 * i2400m_tx_msg_sent - indicate the transmission of a TX message
750 *
751 * @i2400m: device descriptor
752 *
753 * Called by the bus-specific driver when a message has been sent;
754 * this pops it from the FIFO; and as there is space, start the queue
755 * in case it was stopped.
756 *
757 * Should be called even if the message send failed and we are
758 * dropping this TX message.
759 */
760void i2400m_tx_msg_sent(struct i2400m *i2400m)
761{
762 unsigned n;
763 unsigned long flags;
764 struct device *dev = i2400m_dev(i2400m);
765
766 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
767 spin_lock_irqsave(&i2400m->tx_lock, flags);
768 i2400m->tx_out += i2400m->tx_msg_size;
769 d_printf(2, dev, "TX: sent %zu b\n", (size_t) i2400m->tx_msg_size);
770 i2400m->tx_msg_size = 0;
771 BUG_ON(i2400m->tx_out > i2400m->tx_in);
772 /* level them FIFO markers off */
773 n = i2400m->tx_out / I2400M_TX_BUF_SIZE;
774 i2400m->tx_out %= I2400M_TX_BUF_SIZE;
775 i2400m->tx_in -= n * I2400M_TX_BUF_SIZE;
776 netif_start_queue(i2400m->wimax_dev.net_dev);
777 spin_unlock_irqrestore(&i2400m->tx_lock, flags);
778 d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
779}
780EXPORT_SYMBOL_GPL(i2400m_tx_msg_sent);
781
782
783/**
784 * i2400m_tx_setup - Initialize the TX queue and infrastructure
785 *
786 * Make sure we reset the TX sequence to zero, as when this function
787 * is called, the firmware has been just restarted.
788 */
789int i2400m_tx_setup(struct i2400m *i2400m)
790{
791 int result;
792
793 /* Do this here only once -- can't do on
794 * i2400m_hard_start_xmit() as we'll cause race conditions if
795 * the WS was scheduled on another CPU */
796 INIT_WORK(&i2400m->wake_tx_ws, i2400m_wake_tx_work);
797
798 i2400m->tx_sequence = 0;
799 i2400m->tx_buf = kmalloc(I2400M_TX_BUF_SIZE, GFP_KERNEL);
800 if (i2400m->tx_buf == NULL)
801 result = -ENOMEM;
802 else
803 result = 0;
804 /* Huh? the bus layer has to define this... */
805 BUG_ON(i2400m->bus_tx_block_size == 0);
806 return result;
807
808}
809
810
811/**
812 * i2400m_tx_release - Tear down the TX queue and infrastructure
813 */
814void i2400m_tx_release(struct i2400m *i2400m)
815{
816 kfree(i2400m->tx_buf);
817}
diff --git a/drivers/net/wimax/i2400m/usb-debug-levels.h b/drivers/net/wimax/i2400m/usb-debug-levels.h
new file mode 100644
index 000000000000..e4358bd880be
--- /dev/null
+++ b/drivers/net/wimax/i2400m/usb-debug-levels.h
@@ -0,0 +1,42 @@
1/*
2 * Intel Wireless WiMAX Connection 2400m
3 * Debug levels control file for the i2400m-usb module
4 *
5 *
6 * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License version
11 * 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 * 02110-1301, USA.
22 */
23#ifndef __debug_levels__h__
24#define __debug_levels__h__
25
26/* Maximum compile and run time debug level for all submodules */
27#define D_MODULENAME i2400m_usb
28#define D_MASTER CONFIG_WIMAX_I2400M_DEBUG_LEVEL
29
30#include <linux/wimax/debug.h>
31
32/* List of all the enabled modules */
33enum d_module {
34 D_SUBMODULE_DECLARE(usb),
35 D_SUBMODULE_DECLARE(fw),
36 D_SUBMODULE_DECLARE(notif),
37 D_SUBMODULE_DECLARE(rx),
38 D_SUBMODULE_DECLARE(tx),
39};
40
41
42#endif /* #ifndef __debug_levels__h__ */
diff --git a/drivers/net/wimax/i2400m/usb-fw.c b/drivers/net/wimax/i2400m/usb-fw.c
new file mode 100644
index 000000000000..5ad287c228b8
--- /dev/null
+++ b/drivers/net/wimax/i2400m/usb-fw.c
@@ -0,0 +1,340 @@
1/*
2 * Intel Wireless WiMAX Connection 2400m
3 * Firmware uploader's USB specifics
4 *
5 *
6 * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 *
35 * Intel Corporation <linux-wimax@intel.com>
36 * Yanir Lubetkin <yanirx.lubetkin@intel.com>
37 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
38 * - Initial implementation
39 *
40 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
41 * - bus generic/specific split
42 *
43 * THE PROCEDURE
44 *
45 * See fw.c for the generic description of this procedure.
46 *
47 * This file implements only the USB specifics. It boils down to how
48 * to send a command and waiting for an acknowledgement from the
49 * device.
50 *
51 * This code (and process) is single threaded. It assumes it is the
52 * only thread poking around (guaranteed by fw.c).
53 *
54 * COMMAND EXECUTION
55 *
56 * A write URB is posted with the buffer to the bulk output endpoint.
57 *
58 * ACK RECEPTION
59 *
60 * We just post a URB to the notification endpoint and wait for
61 * data. We repeat until we get all the data we expect (as indicated
62 * by the call from the bus generic code).
63 *
64 * The data is not read from the bulk in endpoint for boot mode.
65 *
66 * ROADMAP
67 *
68 * i2400mu_bus_bm_cmd_send
69 * i2400m_bm_cmd_prepare...
70 * i2400mu_tx_bulk_out
71 *
72 * i2400mu_bus_bm_wait_for_ack
73 * i2400m_notif_submit
74 */
75#include <linux/usb.h>
76#include "i2400m-usb.h"
77
78
79#define D_SUBMODULE fw
80#include "usb-debug-levels.h"
81
82
83/*
84 * Synchronous write to the device
85 *
86 * Takes care of updating EDC counts and thus, handle device errors.
87 */
88static
89ssize_t i2400mu_tx_bulk_out(struct i2400mu *i2400mu, void *buf, size_t buf_size)
90{
91 int result;
92 struct device *dev = &i2400mu->usb_iface->dev;
93 int len;
94 struct usb_endpoint_descriptor *epd;
95 int pipe, do_autopm = 1;
96
97 result = usb_autopm_get_interface(i2400mu->usb_iface);
98 if (result < 0) {
99 dev_err(dev, "BM-CMD: can't get autopm: %d\n", result);
100 do_autopm = 0;
101 }
102 epd = usb_get_epd(i2400mu->usb_iface, I2400MU_EP_BULK_OUT);
103 pipe = usb_sndbulkpipe(i2400mu->usb_dev, epd->bEndpointAddress);
104retry:
105 result = usb_bulk_msg(i2400mu->usb_dev, pipe, buf, buf_size, &len, HZ);
106 switch (result) {
107 case 0:
108 if (len != buf_size) {
109 dev_err(dev, "BM-CMD: short write (%u B vs %zu "
110 "expected)\n", len, buf_size);
111 result = -EIO;
112 break;
113 }
114 result = len;
115 break;
116 case -EINVAL: /* while removing driver */
117 case -ENODEV: /* dev disconnect ... */
118 case -ENOENT: /* just ignore it */
119 case -ESHUTDOWN: /* and exit */
120 case -ECONNRESET:
121 result = -ESHUTDOWN;
122 break;
123 case -ETIMEDOUT: /* bah... */
124 break;
125 default: /* any other? */
126 if (edc_inc(&i2400mu->urb_edc,
127 EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {
128 dev_err(dev, "BM-CMD: maximum errors in "
129 "URB exceeded; resetting device\n");
130 usb_queue_reset_device(i2400mu->usb_iface);
131 result = -ENODEV;
132 break;
133 }
134 dev_err(dev, "BM-CMD: URB error %d, retrying\n",
135 result);
136 goto retry;
137 }
138 result = len;
139 if (do_autopm)
140 usb_autopm_put_interface(i2400mu->usb_iface);
141 return result;
142}
143
144
145/*
146 * Send a boot-mode command over the bulk-out pipe
147 *
148 * Command can be a raw command, which requires no preparation (and
149 * which might not even be following the command format). Checks that
150 * the right amount of data was transfered.
151 *
152 * To satisfy USB requirements (no onstack, vmalloc or in data segment
153 * buffers), we copy the command to i2400m->bm_cmd_buf and send it from
154 * there.
155 *
156 * @flags: pass thru from i2400m_bm_cmd()
157 * @return: cmd_size if ok, < 0 errno code on error.
158 */
159ssize_t i2400mu_bus_bm_cmd_send(struct i2400m *i2400m,
160 const struct i2400m_bootrom_header *_cmd,
161 size_t cmd_size, int flags)
162{
163 ssize_t result;
164 struct device *dev = i2400m_dev(i2400m);
165 struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
166 int opcode = _cmd == NULL ? -1 : i2400m_brh_get_opcode(_cmd);
167 struct i2400m_bootrom_header *cmd;
168 size_t cmd_size_a = ALIGN(cmd_size, 16); /* USB restriction */
169
170 d_fnstart(8, dev, "(i2400m %p cmd %p size %zu)\n",
171 i2400m, _cmd, cmd_size);
172 result = -E2BIG;
173 if (cmd_size > I2400M_BM_CMD_BUF_SIZE)
174 goto error_too_big;
175 memcpy(i2400m->bm_cmd_buf, _cmd, cmd_size);
176 cmd = i2400m->bm_cmd_buf;
177 if (cmd_size_a > cmd_size) /* Zero pad space */
178 memset(i2400m->bm_cmd_buf + cmd_size, 0, cmd_size_a - cmd_size);
179 if ((flags & I2400M_BM_CMD_RAW) == 0) {
180 if (WARN_ON(i2400m_brh_get_response_required(cmd) == 0))
181 dev_warn(dev, "SW BUG: response_required == 0\n");
182 i2400m_bm_cmd_prepare(cmd);
183 }
184 result = i2400mu_tx_bulk_out(i2400mu, i2400m->bm_cmd_buf, cmd_size);
185 if (result < 0) {
186 dev_err(dev, "boot-mode cmd %d: cannot send: %zd\n",
187 opcode, result);
188 goto error_cmd_send;
189 }
190 if (result != cmd_size) { /* all was transferred? */
191 dev_err(dev, "boot-mode cmd %d: incomplete transfer "
192 "(%zu vs %zu submitted)\n", opcode, result, cmd_size);
193 result = -EIO;
194 goto error_cmd_size;
195 }
196error_cmd_size:
197error_cmd_send:
198error_too_big:
199 d_fnend(8, dev, "(i2400m %p cmd %p size %zu) = %zd\n",
200 i2400m, _cmd, cmd_size, result);
201 return result;
202}
203
204
205static
206void __i2400mu_bm_notif_cb(struct urb *urb)
207{
208 complete(urb->context);
209}
210
211
212/*
213 * submit a read to the notification endpoint
214 *
215 * @i2400m: device descriptor
216 * @urb: urb to use
217 * @completion: completion varible to complete when done
218 *
219 * Data is always read to i2400m->bm_ack_buf
220 */
221static
222int i2400mu_notif_submit(struct i2400mu *i2400mu, struct urb *urb,
223 struct completion *completion)
224{
225 struct i2400m *i2400m = &i2400mu->i2400m;
226 struct usb_endpoint_descriptor *epd;
227 int pipe;
228
229 epd = usb_get_epd(i2400mu->usb_iface, I2400MU_EP_NOTIFICATION);
230 pipe = usb_rcvintpipe(i2400mu->usb_dev, epd->bEndpointAddress);
231 usb_fill_int_urb(urb, i2400mu->usb_dev, pipe,
232 i2400m->bm_ack_buf, I2400M_BM_ACK_BUF_SIZE,
233 __i2400mu_bm_notif_cb, completion,
234 epd->bInterval);
235 return usb_submit_urb(urb, GFP_KERNEL);
236}
237
238
239/*
240 * Read an ack from the notification endpoint
241 *
242 * @i2400m:
243 * @_ack: pointer to where to store the read data
244 * @ack_size: how many bytes we should read
245 *
246 * Returns: < 0 errno code on error; otherwise, amount of received bytes.
247 *
248 * Submits a notification read, appends the read data to the given ack
249 * buffer and then repeats (until @ack_size bytes have been
250 * received).
251 */
252ssize_t i2400mu_bus_bm_wait_for_ack(struct i2400m *i2400m,
253 struct i2400m_bootrom_header *_ack,
254 size_t ack_size)
255{
256 ssize_t result = -ENOMEM;
257 struct device *dev = i2400m_dev(i2400m);
258 struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
259 struct urb notif_urb;
260 void *ack = _ack;
261 size_t offset, len;
262 long val;
263 int do_autopm = 1;
264 DECLARE_COMPLETION_ONSTACK(notif_completion);
265
266 d_fnstart(8, dev, "(i2400m %p ack %p size %zu)\n",
267 i2400m, ack, ack_size);
268 BUG_ON(_ack == i2400m->bm_ack_buf);
269 result = usb_autopm_get_interface(i2400mu->usb_iface);
270 if (result < 0) {
271 dev_err(dev, "BM-ACK: can't get autopm: %d\n", (int) result);
272 do_autopm = 0;
273 }
274 usb_init_urb(&notif_urb); /* ready notifications */
275 usb_get_urb(&notif_urb);
276 offset = 0;
277 while (offset < ack_size) {
278 init_completion(&notif_completion);
279 result = i2400mu_notif_submit(i2400mu, &notif_urb,
280 &notif_completion);
281 if (result < 0)
282 goto error_notif_urb_submit;
283 val = wait_for_completion_interruptible_timeout(
284 &notif_completion, HZ);
285 if (val == 0) {
286 result = -ETIMEDOUT;
287 usb_kill_urb(&notif_urb); /* Timedout */
288 goto error_notif_wait;
289 }
290 if (val == -ERESTARTSYS) {
291 result = -EINTR; /* Interrupted */
292 usb_kill_urb(&notif_urb);
293 goto error_notif_wait;
294 }
295 result = notif_urb.status; /* How was the ack? */
296 switch (result) {
297 case 0:
298 break;
299 case -EINVAL: /* while removing driver */
300 case -ENODEV: /* dev disconnect ... */
301 case -ENOENT: /* just ignore it */
302 case -ESHUTDOWN: /* and exit */
303 case -ECONNRESET:
304 result = -ESHUTDOWN;
305 goto error_dev_gone;
306 default: /* any other? */
307 usb_kill_urb(&notif_urb); /* Timedout */
308 if (edc_inc(&i2400mu->urb_edc,
309 EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME))
310 goto error_exceeded;
311 dev_err(dev, "BM-ACK: URB error %d, "
312 "retrying\n", notif_urb.status);
313 continue; /* retry */
314 }
315 if (notif_urb.actual_length == 0) {
316 d_printf(6, dev, "ZLP received, retrying\n");
317 continue;
318 }
319 /* Got data, append it to the buffer */
320 len = min(ack_size - offset, (size_t) notif_urb.actual_length);
321 memcpy(ack + offset, i2400m->bm_ack_buf, len);
322 offset += len;
323 }
324 result = offset;
325error_notif_urb_submit:
326error_notif_wait:
327error_dev_gone:
328out:
329 if (do_autopm)
330 usb_autopm_put_interface(i2400mu->usb_iface);
331 d_fnend(8, dev, "(i2400m %p ack %p size %zu) = %zd\n",
332 i2400m, ack, ack_size, result);
333 return result;
334
335error_exceeded:
336 dev_err(dev, "bm: maximum errors in notification URB exceeded; "
337 "resetting device\n");
338 usb_queue_reset_device(i2400mu->usb_iface);
339 goto out;
340}
diff --git a/drivers/net/wimax/i2400m/usb-notif.c b/drivers/net/wimax/i2400m/usb-notif.c
new file mode 100644
index 000000000000..9702c22b2497
--- /dev/null
+++ b/drivers/net/wimax/i2400m/usb-notif.c
@@ -0,0 +1,269 @@
1/*
2 * Intel Wireless WiMAX Connection 2400m over USB
3 * Notification handling
4 *
5 *
6 * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 *
35 * Intel Corporation <linux-wimax@intel.com>
36 * Yanir Lubetkin <yanirx.lubetkin@intel.com>
37 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
38 * - Initial implementation
39 *
40 *
41 * The notification endpoint is active when the device is not in boot
42 * mode; in here we just read and get notifications; based on those,
43 * we act to either reinitialize the device after a reboot or to
44 * submit a RX request.
45 *
46 * ROADMAP
47 *
48 * i2400mu_usb_notification_setup()
49 *
50 * i2400mu_usb_notification_release()
51 *
52 * i2400mu_usb_notification_cb() Called when a URB is ready
53 * i2400mu_notif_grok()
54 * i2400m_dev_reset_handle()
55 * i2400mu_rx_kick()
56 */
57#include <linux/usb.h>
58#include "i2400m-usb.h"
59
60
61#define D_SUBMODULE notif
62#include "usb-debug-levels.h"
63
64
65static const
66__le32 i2400m_ZERO_BARKER[4] = { 0, 0, 0, 0 };
67
68
69/*
70 * Process a received notification
71 *
72 * In normal operation mode, we can only receive two types of payloads
73 * on the notification endpoint:
74 *
75 * - a reboot barker, we do a bootstrap (the device has reseted).
76 *
77 * - a block of zeroes: there is pending data in the IN endpoint
78 */
79static
80int i2400mu_notification_grok(struct i2400mu *i2400mu, const void *buf,
81 size_t buf_len)
82{
83 int ret;
84 struct device *dev = &i2400mu->usb_iface->dev;
85 struct i2400m *i2400m = &i2400mu->i2400m;
86
87 d_fnstart(4, dev, "(i2400m %p buf %p buf_len %zu)\n",
88 i2400mu, buf, buf_len);
89 ret = -EIO;
90 if (buf_len < sizeof(i2400m_NBOOT_BARKER))
91 /* Not a bug, just ignore */
92 goto error_bad_size;
93 if (!memcmp(i2400m_NBOOT_BARKER, buf, sizeof(i2400m_NBOOT_BARKER))
94 || !memcmp(i2400m_SBOOT_BARKER, buf, sizeof(i2400m_SBOOT_BARKER)))
95 ret = i2400m_dev_reset_handle(i2400m);
96 else if (!memcmp(i2400m_ZERO_BARKER, buf, sizeof(i2400m_ZERO_BARKER))) {
97 i2400mu_rx_kick(i2400mu);
98 ret = 0;
99 } else { /* Unknown or unexpected data in the notif message */
100 char prefix[64];
101 ret = -EIO;
102 dev_err(dev, "HW BUG? Unknown/unexpected data in notification "
103 "message (%zu bytes)\n", buf_len);
104 snprintf(prefix, sizeof(prefix), "%s %s: ",
105 dev_driver_string(dev) , dev->bus_id);
106 if (buf_len > 64) {
107 print_hex_dump(KERN_ERR, prefix, DUMP_PREFIX_OFFSET,
108 8, 4, buf, 64, 0);
109 printk(KERN_ERR "%s... (only first 64 bytes "
110 "dumped)\n", prefix);
111 } else
112 print_hex_dump(KERN_ERR, prefix, DUMP_PREFIX_OFFSET,
113 8, 4, buf, buf_len, 0);
114 }
115error_bad_size:
116 d_fnend(4, dev, "(i2400m %p buf %p buf_len %zu) = %d\n",
117 i2400mu, buf, buf_len, ret);
118 return ret;
119}
120
121
122/*
123 * URB callback for the notification endpoint
124 *
125 * @urb: the urb received from the notification endpoint
126 *
127 * This function will just process the USB side of the transaction,
128 * checking everything is fine, pass the processing to
129 * i2400m_notification_grok() and resubmit the URB.
130 */
131static
132void i2400mu_notification_cb(struct urb *urb)
133{
134 int ret;
135 struct i2400mu *i2400mu = urb->context;
136 struct device *dev = &i2400mu->usb_iface->dev;
137
138 d_fnstart(4, dev, "(urb %p status %d actual_length %d)\n",
139 urb, urb->status, urb->actual_length);
140 ret = urb->status;
141 switch (ret) {
142 case 0:
143 ret = i2400mu_notification_grok(i2400mu, urb->transfer_buffer,
144 urb->actual_length);
145 if (ret == -EIO && edc_inc(&i2400mu->urb_edc, EDC_MAX_ERRORS,
146 EDC_ERROR_TIMEFRAME))
147 goto error_exceeded;
148 if (ret == -ENOMEM) /* uff...power cycle? shutdown? */
149 goto error_exceeded;
150 break;
151 case -EINVAL: /* while removing driver */
152 case -ENODEV: /* dev disconnect ... */
153 case -ENOENT: /* ditto */
154 case -ESHUTDOWN: /* URB killed */
155 case -ECONNRESET: /* disconnection */
156 goto out; /* Notify around */
157 default: /* Some error? */
158 if (edc_inc(&i2400mu->urb_edc,
159 EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME))
160 goto error_exceeded;
161 dev_err(dev, "notification: URB error %d, retrying\n",
162 urb->status);
163 }
164 usb_mark_last_busy(i2400mu->usb_dev);
165 ret = usb_submit_urb(i2400mu->notif_urb, GFP_ATOMIC);
166 switch (ret) {
167 case 0:
168 case -EINVAL: /* while removing driver */
169 case -ENODEV: /* dev disconnect ... */
170 case -ENOENT: /* ditto */
171 case -ESHUTDOWN: /* URB killed */
172 case -ECONNRESET: /* disconnection */
173 break; /* just ignore */
174 default: /* Some error? */
175 dev_err(dev, "notification: cannot submit URB: %d\n", ret);
176 goto error_submit;
177 }
178 d_fnend(4, dev, "(urb %p status %d actual_length %d) = void\n",
179 urb, urb->status, urb->actual_length);
180 return;
181
182error_exceeded:
183 dev_err(dev, "maximum errors in notification URB exceeded; "
184 "resetting device\n");
185error_submit:
186 usb_queue_reset_device(i2400mu->usb_iface);
187out:
188 d_fnend(4, dev, "(urb %p status %d actual_length %d) = void\n",
189 urb, urb->status, urb->actual_length);
190 return;
191}
192
193
194/*
195 * setup the notification endpoint
196 *
197 * @i2400m: device descriptor
198 *
199 * This procedure prepares the notification urb and handler for receiving
200 * unsolicited barkers from the device.
201 */
202int i2400mu_notification_setup(struct i2400mu *i2400mu)
203{
204 struct device *dev = &i2400mu->usb_iface->dev;
205 int usb_pipe, ret = 0;
206 struct usb_endpoint_descriptor *epd;
207 char *buf;
208
209 d_fnstart(4, dev, "(i2400m %p)\n", i2400mu);
210 buf = kmalloc(I2400MU_MAX_NOTIFICATION_LEN, GFP_KERNEL | GFP_DMA);
211 if (buf == NULL) {
212 dev_err(dev, "notification: buffer allocation failed\n");
213 ret = -ENOMEM;
214 goto error_buf_alloc;
215 }
216
217 i2400mu->notif_urb = usb_alloc_urb(0, GFP_KERNEL);
218 if (!i2400mu->notif_urb) {
219 ret = -ENOMEM;
220 dev_err(dev, "notification: cannot allocate URB\n");
221 goto error_alloc_urb;
222 }
223 epd = usb_get_epd(i2400mu->usb_iface, I2400MU_EP_NOTIFICATION);
224 usb_pipe = usb_rcvintpipe(i2400mu->usb_dev, epd->bEndpointAddress);
225 usb_fill_int_urb(i2400mu->notif_urb, i2400mu->usb_dev, usb_pipe,
226 buf, I2400MU_MAX_NOTIFICATION_LEN,
227 i2400mu_notification_cb, i2400mu, epd->bInterval);
228 ret = usb_submit_urb(i2400mu->notif_urb, GFP_KERNEL);
229 if (ret != 0) {
230 dev_err(dev, "notification: cannot submit URB: %d\n", ret);
231 goto error_submit;
232 }
233 d_fnend(4, dev, "(i2400m %p) = %d\n", i2400mu, ret);
234 return ret;
235
236error_submit:
237 usb_free_urb(i2400mu->notif_urb);
238error_alloc_urb:
239 kfree(buf);
240error_buf_alloc:
241 d_fnend(4, dev, "(i2400m %p) = %d\n", i2400mu, ret);
242 return ret;
243}
244
245
246/*
247 * Tear down of the notification mechanism
248 *
249 * @i2400m: device descriptor
250 *
251 * Kill the interrupt endpoint urb, free any allocated resources.
252 *
253 * We need to check if we have done it before as for example,
254 * _suspend() call this; if after a suspend() we get a _disconnect()
255 * (as the case is when hibernating), nothing bad happens.
256 */
257void i2400mu_notification_release(struct i2400mu *i2400mu)
258{
259 struct device *dev = &i2400mu->usb_iface->dev;
260
261 d_fnstart(4, dev, "(i2400mu %p)\n", i2400mu);
262 if (i2400mu->notif_urb != NULL) {
263 usb_kill_urb(i2400mu->notif_urb);
264 kfree(i2400mu->notif_urb->transfer_buffer);
265 usb_free_urb(i2400mu->notif_urb);
266 i2400mu->notif_urb = NULL;
267 }
268 d_fnend(4, dev, "(i2400mu %p)\n", i2400mu);
269}
diff --git a/drivers/net/wimax/i2400m/usb-rx.c b/drivers/net/wimax/i2400m/usb-rx.c
new file mode 100644
index 000000000000..074cc1f89853
--- /dev/null
+++ b/drivers/net/wimax/i2400m/usb-rx.c
@@ -0,0 +1,417 @@
1/*
2 * Intel Wireless WiMAX Connection 2400m
3 * USB RX handling
4 *
5 *
6 * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 *
35 * Intel Corporation <linux-wimax@intel.com>
36 * Yanir Lubetkin <yanirx.lubetkin@intel.com>
37 * - Initial implementation
38 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
39 * - Use skb_clone(), break up processing in chunks
40 * - Split transport/device specific
41 * - Make buffer size dynamic to exert less memory pressure
42 *
43 *
44 * This handles the RX path on USB.
45 *
46 * When a notification is received that says 'there is RX data ready',
47 * we call i2400mu_rx_kick(); that wakes up the RX kthread, which
48 * reads a buffer from USB and passes it to i2400m_rx() in the generic
49 * handling code. The RX buffer has an specific format that is
50 * described in rx.c.
51 *
52 * We use a kernel thread in a loop because:
53 *
54 * - we want to be able to call the USB power management get/put
55 * functions (blocking) before each transaction.
56 *
57 * - We might get a lot of notifications and we don't want to submit
58 * a zillion reads; by serializing, we are throttling.
59 *
60 * - RX data processing can get heavy enough so that it is not
61 * appropiate for doing it in the USB callback; thus we run it in a
62 * process context.
63 *
64 * We provide a read buffer of an arbitrary size (short of a page); if
65 * the callback reports -EOVERFLOW, it means it was too small, so we
66 * just double the size and retry (being careful to append, as
67 * sometimes the device provided some data). Every now and then we
68 * check if the average packet size is smaller than the current packet
69 * size and if so, we halve it. At the end, the size of the
70 * preallocated buffer should be following the average received
71 * transaction size, adapting dynamically to it.
72 *
73 * ROADMAP
74 *
75 * i2400mu_rx_kick() Called from notif.c when we get a
76 * 'data ready' notification
77 * i2400mu_rxd() Kernel RX daemon
78 * i2400mu_rx() Receive USB data
79 * i2400m_rx() Send data to generic i2400m RX handling
80 *
81 * i2400mu_rx_setup() called from i2400mu_bus_dev_start()
82 *
83 * i2400mu_rx_release() called from i2400mu_bus_dev_stop()
84 */
85#include <linux/workqueue.h>
86#include <linux/usb.h>
87#include "i2400m-usb.h"
88
89
90#define D_SUBMODULE rx
91#include "usb-debug-levels.h"
92
93/*
94 * Dynamic RX size
95 *
96 * We can't let the rx_size be a multiple of 512 bytes (the RX
97 * endpoint's max packet size). On some USB host controllers (we
98 * haven't been able to fully characterize which), if the device is
99 * about to send (for example) X bytes and we only post a buffer to
100 * receive n*512, it will fail to mark that as babble (so that
101 * i2400mu_rx() [case -EOVERFLOW] can resize the buffer and get the
102 * rest).
103 *
104 * So on growing or shrinking, if it is a multiple of the
105 * maxpacketsize, we remove some (instead of incresing some, so in a
106 * buddy allocator we try to waste less space).
107 *
108 * Note we also need a hook for this on i2400mu_rx() -- when we do the
109 * first read, we are sure we won't hit this spot because
110 * i240mm->rx_size has been set properly. However, if we have to
111 * double because of -EOVERFLOW, when we launch the read to get the
112 * rest of the data, we *have* to make sure that also is not a
113 * multiple of the max_pkt_size.
114 */
115
116static
117size_t i2400mu_rx_size_grow(struct i2400mu *i2400mu)
118{
119 struct device *dev = &i2400mu->usb_iface->dev;
120 size_t rx_size;
121 const size_t max_pkt_size = 512;
122
123 rx_size = 2 * i2400mu->rx_size;
124 if (rx_size % max_pkt_size == 0) {
125 rx_size -= 8;
126 d_printf(1, dev,
127 "RX: expected size grew to %zu [adjusted -8] "
128 "from %zu\n",
129 rx_size, i2400mu->rx_size);
130 } else
131 d_printf(1, dev,
132 "RX: expected size grew to %zu from %zu\n",
133 rx_size, i2400mu->rx_size);
134 return rx_size;
135}
136
137
138static
139void i2400mu_rx_size_maybe_shrink(struct i2400mu *i2400mu)
140{
141 const size_t max_pkt_size = 512;
142 struct device *dev = &i2400mu->usb_iface->dev;
143
144 if (unlikely(i2400mu->rx_size_cnt >= 100
145 && i2400mu->rx_size_auto_shrink)) {
146 size_t avg_rx_size =
147 i2400mu->rx_size_acc / i2400mu->rx_size_cnt;
148 size_t new_rx_size = i2400mu->rx_size / 2;
149 if (avg_rx_size < new_rx_size) {
150 if (new_rx_size % max_pkt_size == 0) {
151 new_rx_size -= 8;
152 d_printf(1, dev,
153 "RX: expected size shrank to %zu "
154 "[adjusted -8] from %zu\n",
155 new_rx_size, i2400mu->rx_size);
156 } else
157 d_printf(1, dev,
158 "RX: expected size shrank to %zu "
159 "from %zu\n",
160 new_rx_size, i2400mu->rx_size);
161 i2400mu->rx_size = new_rx_size;
162 i2400mu->rx_size_cnt = 0;
163 i2400mu->rx_size_acc = i2400mu->rx_size;
164 }
165 }
166}
167
168/*
169 * Receive a message with payloads from the USB bus into an skb
170 *
171 * @i2400mu: USB device descriptor
172 * @rx_skb: skb where to place the received message
173 *
174 * Deals with all the USB-specifics of receiving, dynamically
175 * increasing the buffer size if so needed. Returns the payload in the
176 * skb, ready to process. On a zero-length packet, we retry.
177 *
178 * On soft USB errors, we retry (until they become too frequent and
179 * then are promoted to hard); on hard USB errors, we reset the
180 * device. On other errors (skb realloacation, we just drop it and
181 * hope for the next invocation to solve it).
182 *
183 * Returns: pointer to the skb if ok, ERR_PTR on error.
184 * NOTE: this function might realloc the skb (if it is too small),
185 * so always update with the one returned.
186 * ERR_PTR() is < 0 on error.
187 */
188static
189struct sk_buff *i2400mu_rx(struct i2400mu *i2400mu, struct sk_buff *rx_skb)
190{
191 int result = 0;
192 struct device *dev = &i2400mu->usb_iface->dev;
193 int usb_pipe, read_size, rx_size, do_autopm;
194 struct usb_endpoint_descriptor *epd;
195 const size_t max_pkt_size = 512;
196
197 d_fnstart(4, dev, "(i2400mu %p)\n", i2400mu);
198 do_autopm = atomic_read(&i2400mu->do_autopm);
199 result = do_autopm ?
200 usb_autopm_get_interface(i2400mu->usb_iface) : 0;
201 if (result < 0) {
202 dev_err(dev, "RX: can't get autopm: %d\n", result);
203 do_autopm = 0;
204 }
205 epd = usb_get_epd(i2400mu->usb_iface, I2400MU_EP_BULK_IN);
206 usb_pipe = usb_rcvbulkpipe(i2400mu->usb_dev, epd->bEndpointAddress);
207retry:
208 rx_size = skb_end_pointer(rx_skb) - rx_skb->data - rx_skb->len;
209 if (unlikely(rx_size % max_pkt_size == 0)) {
210 rx_size -= 8;
211 d_printf(1, dev, "RX: rx_size adapted to %d [-8]\n", rx_size);
212 }
213 result = usb_bulk_msg(
214 i2400mu->usb_dev, usb_pipe, rx_skb->data + rx_skb->len,
215 rx_size, &read_size, HZ);
216 usb_mark_last_busy(i2400mu->usb_dev);
217 switch (result) {
218 case 0:
219 if (read_size == 0)
220 goto retry; /* ZLP, just resubmit */
221 skb_put(rx_skb, read_size);
222 break;
223 case -EINVAL: /* while removing driver */
224 case -ENODEV: /* dev disconnect ... */
225 case -ENOENT: /* just ignore it */
226 case -ESHUTDOWN:
227 case -ECONNRESET:
228 break;
229 case -EOVERFLOW: { /* too small, reallocate */
230 struct sk_buff *new_skb;
231 rx_size = i2400mu_rx_size_grow(i2400mu);
232 if (rx_size <= (1 << 16)) /* cap it */
233 i2400mu->rx_size = rx_size;
234 else if (printk_ratelimit()) {
235 dev_err(dev, "BUG? rx_size up to %d\n", rx_size);
236 result = -EINVAL;
237 goto out;
238 }
239 skb_put(rx_skb, read_size);
240 new_skb = skb_copy_expand(rx_skb, 0, rx_size - rx_skb->len,
241 GFP_KERNEL);
242 if (new_skb == NULL) {
243 if (printk_ratelimit())
244 dev_err(dev, "RX: Can't reallocate skb to %d; "
245 "RX dropped\n", rx_size);
246 kfree(rx_skb);
247 result = 0;
248 goto out; /* drop it...*/
249 }
250 kfree_skb(rx_skb);
251 rx_skb = new_skb;
252 i2400mu->rx_size_cnt = 0;
253 i2400mu->rx_size_acc = i2400mu->rx_size;
254 d_printf(1, dev, "RX: size changed to %d, received %d, "
255 "copied %d, capacity %ld\n",
256 rx_size, read_size, rx_skb->len,
257 (long) (skb_end_pointer(new_skb) - new_skb->head));
258 goto retry;
259 }
260 /* In most cases, it happens due to the hardware scheduling a
261 * read when there was no data - unfortunately, we have no way
262 * to tell this timeout from a USB timeout. So we just ignore
263 * it. */
264 case -ETIMEDOUT:
265 dev_err(dev, "RX: timeout: %d\n", result);
266 result = 0;
267 break;
268 default: /* Any error */
269 if (edc_inc(&i2400mu->urb_edc,
270 EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME))
271 goto error_reset;
272 dev_err(dev, "RX: error receiving URB: %d, retrying\n", result);
273 goto retry;
274 }
275out:
276 if (do_autopm)
277 usb_autopm_put_interface(i2400mu->usb_iface);
278 d_fnend(4, dev, "(i2400mu %p) = %p\n", i2400mu, rx_skb);
279 return rx_skb;
280
281error_reset:
282 dev_err(dev, "RX: maximum errors in URB exceeded; "
283 "resetting device\n");
284 usb_queue_reset_device(i2400mu->usb_iface);
285 rx_skb = ERR_PTR(result);
286 goto out;
287}
288
289
290/*
291 * Kernel thread for USB reception of data
292 *
293 * This thread waits for a kick; once kicked, it will allocate an skb
294 * and receive a single message to it from USB (using
295 * i2400mu_rx()). Once received, it is passed to the generic i2400m RX
296 * code for processing.
297 *
298 * When done processing, it runs some dirty statistics to verify if
299 * the last 100 messages received were smaller than half of the
300 * current RX buffer size. In that case, the RX buffer size is
301 * halved. This will helps lowering the pressure on the memory
302 * allocator.
303 *
304 * Hard errors force the thread to exit.
305 */
306static
307int i2400mu_rxd(void *_i2400mu)
308{
309 int result = 0;
310 struct i2400mu *i2400mu = _i2400mu;
311 struct i2400m *i2400m = &i2400mu->i2400m;
312 struct device *dev = &i2400mu->usb_iface->dev;
313 struct net_device *net_dev = i2400m->wimax_dev.net_dev;
314 size_t pending;
315 int rx_size;
316 struct sk_buff *rx_skb;
317
318 d_fnstart(4, dev, "(i2400mu %p)\n", i2400mu);
319 while (1) {
320 d_printf(2, dev, "TX: waiting for messages\n");
321 pending = 0;
322 wait_event_interruptible(
323 i2400mu->rx_wq,
324 (kthread_should_stop() /* check this first! */
325 || (pending = atomic_read(&i2400mu->rx_pending_count)))
326 );
327 if (kthread_should_stop())
328 break;
329 if (pending == 0)
330 continue;
331 rx_size = i2400mu->rx_size;
332 d_printf(2, dev, "RX: reading up to %d bytes\n", rx_size);
333 rx_skb = __netdev_alloc_skb(net_dev, rx_size, GFP_KERNEL);
334 if (rx_skb == NULL) {
335 dev_err(dev, "RX: can't allocate skb [%d bytes]\n",
336 rx_size);
337 msleep(50); /* give it some time? */
338 continue;
339 }
340
341 /* Receive the message with the payloads */
342 rx_skb = i2400mu_rx(i2400mu, rx_skb);
343 result = PTR_ERR(rx_skb);
344 if (IS_ERR(rx_skb))
345 goto out;
346 atomic_dec(&i2400mu->rx_pending_count);
347 if (rx_skb->len == 0) { /* some ignorable condition */
348 kfree_skb(rx_skb);
349 continue;
350 }
351
352 /* Deliver the message to the generic i2400m code */
353 i2400mu->rx_size_cnt++;
354 i2400mu->rx_size_acc += rx_skb->len;
355 result = i2400m_rx(i2400m, rx_skb);
356 if (result == -EIO
357 && edc_inc(&i2400mu->urb_edc,
358 EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {
359 goto error_reset;
360 }
361
362 /* Maybe adjust RX buffer size */
363 i2400mu_rx_size_maybe_shrink(i2400mu);
364 }
365 result = 0;
366out:
367 d_fnend(4, dev, "(i2400mu %p) = %d\n", i2400mu, result);
368 return result;
369
370error_reset:
371 dev_err(dev, "RX: maximum errors in received buffer exceeded; "
372 "resetting device\n");
373 usb_queue_reset_device(i2400mu->usb_iface);
374 goto out;
375}
376
377
378/*
379 * Start reading from the device
380 *
381 * @i2400m: device instance
382 *
383 * Notify the RX thread that there is data pending.
384 */
385void i2400mu_rx_kick(struct i2400mu *i2400mu)
386{
387 struct i2400m *i2400m = &i2400mu->i2400m;
388 struct device *dev = &i2400mu->usb_iface->dev;
389
390 d_fnstart(3, dev, "(i2400mu %p)\n", i2400m);
391 atomic_inc(&i2400mu->rx_pending_count);
392 wake_up_all(&i2400mu->rx_wq);
393 d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
394}
395
396
397int i2400mu_rx_setup(struct i2400mu *i2400mu)
398{
399 int result = 0;
400 struct i2400m *i2400m = &i2400mu->i2400m;
401 struct device *dev = &i2400mu->usb_iface->dev;
402 struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
403
404 i2400mu->rx_kthread = kthread_run(i2400mu_rxd, i2400mu, "%s-rx",
405 wimax_dev->name);
406 if (IS_ERR(i2400mu->rx_kthread)) {
407 result = PTR_ERR(i2400mu->rx_kthread);
408 dev_err(dev, "RX: cannot start thread: %d\n", result);
409 }
410 return result;
411}
412
413void i2400mu_rx_release(struct i2400mu *i2400mu)
414{
415 kthread_stop(i2400mu->rx_kthread);
416}
417
diff --git a/drivers/net/wimax/i2400m/usb-tx.c b/drivers/net/wimax/i2400m/usb-tx.c
new file mode 100644
index 000000000000..dfd893356f49
--- /dev/null
+++ b/drivers/net/wimax/i2400m/usb-tx.c
@@ -0,0 +1,229 @@
1/*
2 * Intel Wireless WiMAX Connection 2400m
3 * USB specific TX handling
4 *
5 *
6 * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * * Neither the name of Intel Corporation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 *
35 * Intel Corporation <linux-wimax@intel.com>
36 * Yanir Lubetkin <yanirx.lubetkin@intel.com>
37 * - Initial implementation
38 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
39 * - Split transport/device specific
40 *
41 *
42 * Takes the TX messages in the i2400m's driver TX FIFO and sends them
43 * to the device until there are no more.
44 *
45 * If we fail sending the message, we just drop it. There isn't much
46 * we can do at this point. We could also retry, but the USB stack has
47 * already retried and still failed, so there is not much of a
48 * point. As well, most of the traffic is network, which has recovery
49 * methods for dropped packets.
50 *
51 * For sending we just obtain a FIFO buffer to send, send it to the
52 * USB bulk out, tell the TX FIFO code we have sent it; query for
53 * another one, etc... until done.
54 *
55 * We use a thread so we can call usb_autopm_enable() and
56 * usb_autopm_disable() for each transaction; this way when the device
57 * goes idle, it will suspend. It also has less overhead than a
58 * dedicated workqueue, as it is being used for a single task.
59 *
60 * ROADMAP
61 *
62 * i2400mu_tx_setup()
63 * i2400mu_tx_release()
64 *
65 * i2400mu_bus_tx_kick() - Called by the tx.c code when there
66 * is new data in the FIFO.
67 * i2400mu_txd()
68 * i2400m_tx_msg_get()
69 * i2400m_tx_msg_sent()
70 */
71#include "i2400m-usb.h"
72
73
74#define D_SUBMODULE tx
75#include "usb-debug-levels.h"
76
77
78/*
79 * Get the next TX message in the TX FIFO and send it to the device
80 *
81 * Note that any iteration consumes a message to be sent, no matter if
82 * it succeeds or fails (we have no real way to retry or complain).
83 *
84 * Return: 0 if ok, < 0 errno code on hard error.
85 */
86static
87int i2400mu_tx(struct i2400mu *i2400mu, struct i2400m_msg_hdr *tx_msg,
88 size_t tx_msg_size)
89{
90 int result = 0;
91 struct i2400m *i2400m = &i2400mu->i2400m;
92 struct device *dev = &i2400mu->usb_iface->dev;
93 int usb_pipe, sent_size, do_autopm;
94 struct usb_endpoint_descriptor *epd;
95
96 d_fnstart(4, dev, "(i2400mu %p)\n", i2400mu);
97 do_autopm = atomic_read(&i2400mu->do_autopm);
98 result = do_autopm ?
99 usb_autopm_get_interface(i2400mu->usb_iface) : 0;
100 if (result < 0) {
101 dev_err(dev, "TX: can't get autopm: %d\n", result);
102 do_autopm = 0;
103 }
104 epd = usb_get_epd(i2400mu->usb_iface, I2400MU_EP_BULK_OUT);
105 usb_pipe = usb_sndbulkpipe(i2400mu->usb_dev, epd->bEndpointAddress);
106retry:
107 result = usb_bulk_msg(i2400mu->usb_dev, usb_pipe,
108 tx_msg, tx_msg_size, &sent_size, HZ);
109 usb_mark_last_busy(i2400mu->usb_dev);
110 switch (result) {
111 case 0:
112 if (sent_size != tx_msg_size) { /* Too short? drop it */
113 dev_err(dev, "TX: short write (%d B vs %zu "
114 "expected)\n", sent_size, tx_msg_size);
115 result = -EIO;
116 }
117 break;
118 case -EINVAL: /* while removing driver */
119 case -ENODEV: /* dev disconnect ... */
120 case -ENOENT: /* just ignore it */
121 case -ESHUTDOWN: /* and exit */
122 case -ECONNRESET:
123 result = -ESHUTDOWN;
124 break;
125 default: /* Some error? */
126 if (edc_inc(&i2400mu->urb_edc,
127 EDC_MAX_ERRORS, EDC_ERROR_TIMEFRAME)) {
128 dev_err(dev, "TX: maximum errors in URB "
129 "exceeded; resetting device\n");
130 usb_queue_reset_device(i2400mu->usb_iface);
131 } else {
132 dev_err(dev, "TX: cannot send URB; retrying. "
133 "tx_msg @%zu %zu B [%d sent]: %d\n",
134 (void *) tx_msg - i2400m->tx_buf,
135 tx_msg_size, sent_size, result);
136 goto retry;
137 }
138 }
139 if (do_autopm)
140 usb_autopm_put_interface(i2400mu->usb_iface);
141 d_fnend(4, dev, "(i2400mu %p) = result\n", i2400mu);
142 return result;
143}
144
145
146/*
147 * Get the next TX message in the TX FIFO and send it to the device
148 *
149 * Note we exit the loop if i2400mu_tx() fails; that funtion only
150 * fails on hard error (failing to tx a buffer not being one of them,
151 * see its doc).
152 *
153 * Return: 0
154 */
155static
156int i2400mu_txd(void *_i2400mu)
157{
158 int result = 0;
159 struct i2400mu *i2400mu = _i2400mu;
160 struct i2400m *i2400m = &i2400mu->i2400m;
161 struct device *dev = &i2400mu->usb_iface->dev;
162 struct i2400m_msg_hdr *tx_msg;
163 size_t tx_msg_size;
164
165 d_fnstart(4, dev, "(i2400mu %p)\n", i2400mu);
166
167 while (1) {
168 d_printf(2, dev, "TX: waiting for messages\n");
169 tx_msg = NULL;
170 wait_event_interruptible(
171 i2400mu->tx_wq,
172 (kthread_should_stop() /* check this first! */
173 || (tx_msg = i2400m_tx_msg_get(i2400m, &tx_msg_size)))
174 );
175 if (kthread_should_stop())
176 break;
177 WARN_ON(tx_msg == NULL); /* should not happen...*/
178 d_printf(2, dev, "TX: submitting %zu bytes\n", tx_msg_size);
179 d_dump(5, dev, tx_msg, tx_msg_size);
180 /* Yeah, we ignore errors ... not much we can do */
181 i2400mu_tx(i2400mu, tx_msg, tx_msg_size);
182 i2400m_tx_msg_sent(i2400m); /* ack it, advance the FIFO */
183 if (result < 0)
184 break;
185 }
186 d_fnend(4, dev, "(i2400mu %p) = %d\n", i2400mu, result);
187 return result;
188}
189
190
191/*
192 * i2400m TX engine notifies us that there is data in the FIFO ready
193 * for TX
194 *
195 * If there is a URB in flight, don't do anything; when it finishes,
196 * it will see there is data in the FIFO and send it. Else, just
197 * submit a write.
198 */
199void i2400mu_bus_tx_kick(struct i2400m *i2400m)
200{
201 struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
202 struct device *dev = &i2400mu->usb_iface->dev;
203
204 d_fnstart(3, dev, "(i2400m %p) = void\n", i2400m);
205 wake_up_all(&i2400mu->tx_wq);
206 d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
207}
208
209
210int i2400mu_tx_setup(struct i2400mu *i2400mu)
211{
212 int result = 0;
213 struct i2400m *i2400m = &i2400mu->i2400m;
214 struct device *dev = &i2400mu->usb_iface->dev;
215 struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
216
217 i2400mu->tx_kthread = kthread_run(i2400mu_txd, i2400mu, "%s-tx",
218 wimax_dev->name);
219 if (IS_ERR(i2400mu->tx_kthread)) {
220 result = PTR_ERR(i2400mu->tx_kthread);
221 dev_err(dev, "TX: cannot start thread: %d\n", result);
222 }
223 return result;
224}
225
226void i2400mu_tx_release(struct i2400mu *i2400mu)
227{
228 kthread_stop(i2400mu->tx_kthread);
229}
diff --git a/drivers/net/wimax/i2400m/usb.c b/drivers/net/wimax/i2400m/usb.c
new file mode 100644
index 000000000000..c6d93465c7e2
--- /dev/null
+++ b/drivers/net/wimax/i2400m/usb.c
@@ -0,0 +1,597 @@
1/*
2 * Intel Wireless WiMAX Connection 2400m
3 * Linux driver model glue for USB device, reset & fw upload
4 *
5 *
6 * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com>
7 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
8 * Yanir Lubetkin <yanirx.lubetkin@intel.com>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License version
12 * 2 as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 * 02110-1301, USA.
23 *
24 *
25 * See i2400m-usb.h for a general description of this driver.
26 *
27 * This file implements driver model glue, and hook ups for the
28 * generic driver to implement the bus-specific functions (device
29 * communication setup/tear down, firmware upload and resetting).
30 *
31 * ROADMAP
32 *
33 * i2400mu_probe()
34 * alloc_netdev()...
35 * i2400mu_netdev_setup()
36 * i2400mu_init()
37 * i2400m_netdev_setup()
38 * i2400m_setup()...
39 *
40 * i2400mu_disconnect
41 * i2400m_release()
42 * free_netdev()
43 *
44 * i2400mu_suspend()
45 * i2400m_cmd_enter_powersave()
46 * i2400mu_notification_release()
47 *
48 * i2400mu_resume()
49 * i2400mu_notification_setup()
50 *
51 * i2400mu_bus_dev_start() Called by i2400m_dev_start() [who is
52 * i2400mu_tx_setup() called by i2400m_setup()]
53 * i2400mu_rx_setup()
54 * i2400mu_notification_setup()
55 *
56 * i2400mu_bus_dev_stop() Called by i2400m_dev_stop() [who is
57 * i2400mu_notification_release() called by i2400m_release()]
58 * i2400mu_rx_release()
59 * i2400mu_tx_release()
60 *
61 * i2400mu_bus_reset() Called by i2400m->bus_reset
62 * __i2400mu_reset()
63 * __i2400mu_send_barker()
64 * usb_reset_device()
65 */
66#include "i2400m-usb.h"
67#include <linux/wimax/i2400m.h>
68#include <linux/debugfs.h>
69
70
71#define D_SUBMODULE usb
72#include "usb-debug-levels.h"
73
74
75/* Our firmware file name */
76#define I2400MU_FW_FILE_NAME "i2400m-fw-usb-" I2400M_FW_VERSION ".sbcf"
77
78static
79int i2400mu_bus_dev_start(struct i2400m *i2400m)
80{
81 int result;
82 struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
83 struct device *dev = &i2400mu->usb_iface->dev;
84
85 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
86 result = i2400mu_tx_setup(i2400mu);
87 if (result < 0)
88 goto error_usb_tx_setup;
89 result = i2400mu_rx_setup(i2400mu);
90 if (result < 0)
91 goto error_usb_rx_setup;
92 result = i2400mu_notification_setup(i2400mu);
93 if (result < 0)
94 goto error_notif_setup;
95 d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
96 return result;
97
98error_notif_setup:
99 i2400mu_rx_release(i2400mu);
100error_usb_rx_setup:
101 i2400mu_tx_release(i2400mu);
102error_usb_tx_setup:
103 d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
104 return result;
105}
106
107
108static
109void i2400mu_bus_dev_stop(struct i2400m *i2400m)
110{
111 struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
112 struct device *dev = &i2400mu->usb_iface->dev;
113
114 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
115 i2400mu_notification_release(i2400mu);
116 i2400mu_rx_release(i2400mu);
117 i2400mu_tx_release(i2400mu);
118 d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
119}
120
121
122/*
123 * Sends a barker buffer to the device
124 *
125 * This helper will allocate a kmalloced buffer and use it to transmit
126 * (then free it). Reason for this is that other arches cannot use
127 * stack/vmalloc/text areas for DMA transfers.
128 *
129 * Error recovery here is simpler: anything is considered a hard error
130 * and will move the reset code to use a last-resort bus-based reset.
131 */
132static
133int __i2400mu_send_barker(struct i2400mu *i2400mu,
134 const __le32 *barker,
135 size_t barker_size,
136 unsigned endpoint)
137{
138 struct usb_endpoint_descriptor *epd = NULL;
139 int pipe, actual_len, ret;
140 struct device *dev = &i2400mu->usb_iface->dev;
141 void *buffer;
142 int do_autopm = 1;
143
144 ret = usb_autopm_get_interface(i2400mu->usb_iface);
145 if (ret < 0) {
146 dev_err(dev, "RESET: can't get autopm: %d\n", ret);
147 do_autopm = 0;
148 }
149 ret = -ENOMEM;
150 buffer = kmalloc(barker_size, GFP_KERNEL);
151 if (buffer == NULL)
152 goto error_kzalloc;
153 epd = usb_get_epd(i2400mu->usb_iface, endpoint);
154 pipe = usb_sndbulkpipe(i2400mu->usb_dev, epd->bEndpointAddress);
155 memcpy(buffer, barker, barker_size);
156 ret = usb_bulk_msg(i2400mu->usb_dev, pipe, buffer, barker_size,
157 &actual_len, HZ);
158 if (ret < 0) {
159 if (ret != -EINVAL)
160 dev_err(dev, "E: barker error: %d\n", ret);
161 } else if (actual_len != barker_size) {
162 dev_err(dev, "E: only %d bytes transmitted\n", actual_len);
163 ret = -EIO;
164 }
165 kfree(buffer);
166error_kzalloc:
167 if (do_autopm)
168 usb_autopm_put_interface(i2400mu->usb_iface);
169 return ret;
170}
171
172
173/*
174 * Reset a device at different levels (warm, cold or bus)
175 *
176 * @i2400m: device descriptor
177 * @reset_type: soft, warm or bus reset (I2400M_RT_WARM/SOFT/BUS)
178 *
179 * Warm and cold resets get a USB reset if they fail.
180 *
181 * Warm reset:
182 *
183 * The device will be fully reset internally, but won't be
184 * disconnected from the USB bus (so no reenumeration will
185 * happen). Firmware upload will be neccessary.
186 *
187 * The device will send a reboot barker in the notification endpoint
188 * that will trigger the driver to reinitialize the state
189 * automatically from notif.c:i2400m_notification_grok() into
190 * i2400m_dev_bootstrap_delayed().
191 *
192 * Cold and bus (USB) reset:
193 *
194 * The device will be fully reset internally, disconnected from the
195 * USB bus an a reenumeration will happen. Firmware upload will be
196 * neccessary. Thus, we don't do any locking or struct
197 * reinitialization, as we are going to be fully disconnected and
198 * reenumerated.
199 *
200 * Note we need to return -ENODEV if a warm reset was requested and we
201 * had to resort to a bus reset. See i2400m_op_reset(), wimax_reset()
202 * and wimax_dev->op_reset.
203 *
204 * WARNING: no driver state saved/fixed
205 */
206static
207int i2400mu_bus_reset(struct i2400m *i2400m, enum i2400m_reset_type rt)
208{
209 int result;
210 struct i2400mu *i2400mu =
211 container_of(i2400m, struct i2400mu, i2400m);
212 struct device *dev = i2400m_dev(i2400m);
213 static const __le32 i2400m_WARM_BOOT_BARKER[4] = {
214 __constant_cpu_to_le32(I2400M_WARM_RESET_BARKER),
215 __constant_cpu_to_le32(I2400M_WARM_RESET_BARKER),
216 __constant_cpu_to_le32(I2400M_WARM_RESET_BARKER),
217 __constant_cpu_to_le32(I2400M_WARM_RESET_BARKER),
218 };
219 static const __le32 i2400m_COLD_BOOT_BARKER[4] = {
220 __constant_cpu_to_le32(I2400M_COLD_RESET_BARKER),
221 __constant_cpu_to_le32(I2400M_COLD_RESET_BARKER),
222 __constant_cpu_to_le32(I2400M_COLD_RESET_BARKER),
223 __constant_cpu_to_le32(I2400M_COLD_RESET_BARKER),
224 };
225
226 d_fnstart(3, dev, "(i2400m %p rt %u)\n", i2400m, rt);
227 if (rt == I2400M_RT_WARM)
228 result = __i2400mu_send_barker(i2400mu, i2400m_WARM_BOOT_BARKER,
229 sizeof(i2400m_WARM_BOOT_BARKER),
230 I2400MU_EP_BULK_OUT);
231 else if (rt == I2400M_RT_COLD)
232 result = __i2400mu_send_barker(i2400mu, i2400m_COLD_BOOT_BARKER,
233 sizeof(i2400m_COLD_BOOT_BARKER),
234 I2400MU_EP_RESET_COLD);
235 else if (rt == I2400M_RT_BUS) {
236do_bus_reset:
237 result = usb_reset_device(i2400mu->usb_dev);
238 switch (result) {
239 case 0:
240 case -EINVAL: /* device is gone */
241 case -ENODEV:
242 case -ENOENT:
243 case -ESHUTDOWN:
244 result = rt == I2400M_RT_WARM ? -ENODEV : 0;
245 break; /* We assume the device is disconnected */
246 default:
247 dev_err(dev, "USB reset failed (%d), giving up!\n",
248 result);
249 }
250 } else
251 BUG();
252 if (result < 0
253 && result != -EINVAL /* device is gone */
254 && rt != I2400M_RT_BUS) {
255 dev_err(dev, "%s reset failed (%d); trying USB reset\n",
256 rt == I2400M_RT_WARM ? "warm" : "cold", result);
257 rt = I2400M_RT_BUS;
258 goto do_bus_reset;
259 }
260 d_fnend(3, dev, "(i2400m %p rt %u) = %d\n", i2400m, rt, result);
261 return result;
262}
263
264
265static
266void i2400mu_netdev_setup(struct net_device *net_dev)
267{
268 struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
269 struct i2400mu *i2400mu = container_of(i2400m, struct i2400mu, i2400m);
270 i2400mu_init(i2400mu);
271 i2400m_netdev_setup(net_dev);
272}
273
274
275/*
276 * Debug levels control; see debug.h
277 */
278struct d_level D_LEVEL[] = {
279 D_SUBMODULE_DEFINE(usb),
280 D_SUBMODULE_DEFINE(fw),
281 D_SUBMODULE_DEFINE(notif),
282 D_SUBMODULE_DEFINE(rx),
283 D_SUBMODULE_DEFINE(tx),
284};
285size_t D_LEVEL_SIZE = ARRAY_SIZE(D_LEVEL);
286
287
288#define __debugfs_register(prefix, name, parent) \
289do { \
290 result = d_level_register_debugfs(prefix, name, parent); \
291 if (result < 0) \
292 goto error; \
293} while (0)
294
295
296static
297int i2400mu_debugfs_add(struct i2400mu *i2400mu)
298{
299 int result;
300 struct device *dev = &i2400mu->usb_iface->dev;
301 struct dentry *dentry = i2400mu->i2400m.wimax_dev.debugfs_dentry;
302 struct dentry *fd;
303
304 dentry = debugfs_create_dir("i2400m-usb", dentry);
305 result = PTR_ERR(dentry);
306 if (IS_ERR(dentry)) {
307 if (result == -ENODEV)
308 result = 0; /* No debugfs support */
309 goto error;
310 }
311 i2400mu->debugfs_dentry = dentry;
312 __debugfs_register("dl_", usb, dentry);
313 __debugfs_register("dl_", fw, dentry);
314 __debugfs_register("dl_", notif, dentry);
315 __debugfs_register("dl_", rx, dentry);
316 __debugfs_register("dl_", tx, dentry);
317
318 /* Don't touch these if you don't know what you are doing */
319 fd = debugfs_create_u8("rx_size_auto_shrink", 0600, dentry,
320 &i2400mu->rx_size_auto_shrink);
321 result = PTR_ERR(fd);
322 if (IS_ERR(fd) && result != -ENODEV) {
323 dev_err(dev, "Can't create debugfs entry "
324 "rx_size_auto_shrink: %d\n", result);
325 goto error;
326 }
327
328 fd = debugfs_create_size_t("rx_size", 0600, dentry,
329 &i2400mu->rx_size);
330 result = PTR_ERR(fd);
331 if (IS_ERR(fd) && result != -ENODEV) {
332 dev_err(dev, "Can't create debugfs entry "
333 "rx_size: %d\n", result);
334 goto error;
335 }
336
337 return 0;
338
339error:
340 debugfs_remove_recursive(i2400mu->debugfs_dentry);
341 return result;
342}
343
344
345/*
346 * Probe a i2400m interface and register it
347 *
348 * @iface: USB interface to link to
349 * @id: USB class/subclass/protocol id
350 * @returns: 0 if ok, < 0 errno code on error.
351 *
352 * Alloc a net device, initialize the bus-specific details and then
353 * calls the bus-generic initialization routine. That will register
354 * the wimax and netdev devices, upload the firmware [using
355 * _bus_bm_*()], call _bus_dev_start() to finalize the setup of the
356 * communication with the device and then will start to talk to it to
357 * finnish setting it up.
358 */
359static
360int i2400mu_probe(struct usb_interface *iface,
361 const struct usb_device_id *id)
362{
363 int result;
364 struct net_device *net_dev;
365 struct device *dev = &iface->dev;
366 struct i2400m *i2400m;
367 struct i2400mu *i2400mu;
368 struct usb_device *usb_dev = interface_to_usbdev(iface);
369
370 if (usb_dev->speed != USB_SPEED_HIGH)
371 dev_err(dev, "device not connected as high speed\n");
372
373 /* Allocate instance [calls i2400m_netdev_setup() on it]. */
374 result = -ENOMEM;
375 net_dev = alloc_netdev(sizeof(*i2400mu), "wmx%d",
376 i2400mu_netdev_setup);
377 if (net_dev == NULL) {
378 dev_err(dev, "no memory for network device instance\n");
379 goto error_alloc_netdev;
380 }
381 SET_NETDEV_DEV(net_dev, dev);
382 i2400m = net_dev_to_i2400m(net_dev);
383 i2400mu = container_of(i2400m, struct i2400mu, i2400m);
384 i2400m->wimax_dev.net_dev = net_dev;
385 i2400mu->usb_dev = usb_get_dev(usb_dev);
386 i2400mu->usb_iface = iface;
387 usb_set_intfdata(iface, i2400mu);
388
389 i2400m->bus_tx_block_size = I2400MU_BLK_SIZE;
390 i2400m->bus_pl_size_max = I2400MU_PL_SIZE_MAX;
391 i2400m->bus_dev_start = i2400mu_bus_dev_start;
392 i2400m->bus_dev_stop = i2400mu_bus_dev_stop;
393 i2400m->bus_tx_kick = i2400mu_bus_tx_kick;
394 i2400m->bus_reset = i2400mu_bus_reset;
395 i2400m->bus_bm_cmd_send = i2400mu_bus_bm_cmd_send;
396 i2400m->bus_bm_wait_for_ack = i2400mu_bus_bm_wait_for_ack;
397 i2400m->bus_fw_name = I2400MU_FW_FILE_NAME;
398 i2400m->bus_bm_mac_addr_impaired = 0;
399
400#ifdef CONFIG_PM
401 iface->needs_remote_wakeup = 1; /* autosuspend (15s delay) */
402 device_init_wakeup(dev, 1);
403 usb_autopm_enable(i2400mu->usb_iface);
404 usb_dev->autosuspend_delay = 15 * HZ;
405 usb_dev->autosuspend_disabled = 0;
406#endif
407
408 result = i2400m_setup(i2400m, I2400M_BRI_MAC_REINIT);
409 if (result < 0) {
410 dev_err(dev, "cannot setup device: %d\n", result);
411 goto error_setup;
412 }
413 result = i2400mu_debugfs_add(i2400mu);
414 if (result < 0) {
415 dev_err(dev, "Can't register i2400mu's debugfs: %d\n", result);
416 goto error_debugfs_add;
417 }
418 return 0;
419
420error_debugfs_add:
421 i2400m_release(i2400m);
422error_setup:
423 usb_set_intfdata(iface, NULL);
424 usb_put_dev(i2400mu->usb_dev);
425 free_netdev(net_dev);
426error_alloc_netdev:
427 return result;
428}
429
430
431/*
432 * Disconect a i2400m from the system.
433 *
434 * i2400m_stop() has been called before, so al the rx and tx contexts
435 * have been taken down already. Make sure the queue is stopped,
436 * unregister netdev and i2400m, free and kill.
437 */
438static
439void i2400mu_disconnect(struct usb_interface *iface)
440{
441 struct i2400mu *i2400mu = usb_get_intfdata(iface);
442 struct i2400m *i2400m = &i2400mu->i2400m;
443 struct net_device *net_dev = i2400m->wimax_dev.net_dev;
444 struct device *dev = &iface->dev;
445
446 d_fnstart(3, dev, "(iface %p i2400m %p)\n", iface, i2400m);
447
448 debugfs_remove_recursive(i2400mu->debugfs_dentry);
449 i2400m_release(i2400m);
450 usb_set_intfdata(iface, NULL);
451 usb_put_dev(i2400mu->usb_dev);
452 free_netdev(net_dev);
453 d_fnend(3, dev, "(iface %p i2400m %p) = void\n", iface, i2400m);
454}
455
456
457/*
458 * Get the device ready for USB port or system standby and hibernation
459 *
460 * USB port and system standby are handled the same.
461 *
462 * When the system hibernates, the USB device is powered down and then
463 * up, so we don't really have to do much here, as it will be seen as
464 * a reconnect. Still for simplicity we consider this case the same as
465 * suspend, so that the device has a chance to do notify the base
466 * station (if connected).
467 *
468 * So at the end, the three cases require common handling.
469 *
470 * If at the time of this call the device's firmware is not loaded,
471 * nothing has to be done.
472 *
473 * If the firmware is loaded, we need to:
474 *
475 * - tell the device to go into host interface power save mode, wait
476 * for it to ack
477 *
478 * This is quite more interesting than it is; we need to execute a
479 * command, but this time, we don't want the code in usb-{tx,rx}.c
480 * to call the usb_autopm_get/put_interface() barriers as it'd
481 * deadlock, so we need to decrement i2400mu->do_autopm, that acts
482 * as a poor man's semaphore. Ugly, but it works.
483 *
484 * As well, the device might refuse going to sleep for whichever
485 * reason. In this case we just fail. For system suspend/hibernate,
486 * we *can't* fail. We look at usb_dev->auto_pm to see if the
487 * suspend call comes from the USB stack or from the system and act
488 * in consequence.
489 *
490 * - stop the notification endpoint polling
491 */
492static
493int i2400mu_suspend(struct usb_interface *iface, pm_message_t pm_msg)
494{
495 int result = 0;
496 struct device *dev = &iface->dev;
497 struct i2400mu *i2400mu = usb_get_intfdata(iface);
498#ifdef CONFIG_PM
499 struct usb_device *usb_dev = i2400mu->usb_dev;
500#endif
501 struct i2400m *i2400m = &i2400mu->i2400m;
502
503 d_fnstart(3, dev, "(iface %p pm_msg %u)\n", iface, pm_msg.event);
504 if (i2400m->updown == 0)
505 goto no_firmware;
506 d_printf(1, dev, "fw up, requesting standby\n");
507 atomic_dec(&i2400mu->do_autopm);
508 result = i2400m_cmd_enter_powersave(i2400m);
509 atomic_inc(&i2400mu->do_autopm);
510#ifdef CONFIG_PM
511 if (result < 0 && usb_dev->auto_pm == 0) {
512 /* System suspend, can't fail */
513 dev_err(dev, "failed to suspend, will reset on resume\n");
514 result = 0;
515 }
516#endif
517 if (result < 0)
518 goto error_enter_powersave;
519 i2400mu_notification_release(i2400mu);
520 d_printf(1, dev, "fw up, got standby\n");
521error_enter_powersave:
522no_firmware:
523 d_fnend(3, dev, "(iface %p pm_msg %u) = %d\n",
524 iface, pm_msg.event, result);
525 return result;
526}
527
528
529static
530int i2400mu_resume(struct usb_interface *iface)
531{
532 int ret = 0;
533 struct device *dev = &iface->dev;
534 struct i2400mu *i2400mu = usb_get_intfdata(iface);
535 struct i2400m *i2400m = &i2400mu->i2400m;
536
537 d_fnstart(3, dev, "(iface %p)\n", iface);
538 if (i2400m->updown == 0) {
539 d_printf(1, dev, "fw was down, no resume neeed\n");
540 goto out;
541 }
542 d_printf(1, dev, "fw was up, resuming\n");
543 i2400mu_notification_setup(i2400mu);
544 /* USB has flow control, so we don't need to give it time to
545 * come back; otherwise, we'd use something like a get-state
546 * command... */
547out:
548 d_fnend(3, dev, "(iface %p) = %d\n", iface, ret);
549 return ret;
550}
551
552
553static
554struct usb_device_id i2400mu_id_table[] = {
555 { USB_DEVICE(0x8086, 0x0181) },
556 { USB_DEVICE(0x8086, 0x1403) },
557 { USB_DEVICE(0x8086, 0x1405) },
558 { USB_DEVICE(0x8086, 0x0180) },
559 { USB_DEVICE(0x8086, 0x0182) },
560 { USB_DEVICE(0x8086, 0x1406) },
561 { USB_DEVICE(0x8086, 0x1403) },
562 { },
563};
564MODULE_DEVICE_TABLE(usb, i2400mu_id_table);
565
566
567static
568struct usb_driver i2400mu_driver = {
569 .name = KBUILD_MODNAME,
570 .suspend = i2400mu_suspend,
571 .resume = i2400mu_resume,
572 .probe = i2400mu_probe,
573 .disconnect = i2400mu_disconnect,
574 .id_table = i2400mu_id_table,
575 .supports_autosuspend = 1,
576};
577
578static
579int __init i2400mu_driver_init(void)
580{
581 return usb_register(&i2400mu_driver);
582}
583module_init(i2400mu_driver_init);
584
585
586static
587void __exit i2400mu_driver_exit(void)
588{
589 flush_scheduled_work(); /* for the stuff we schedule from sysfs.c */
590 usb_deregister(&i2400mu_driver);
591}
592module_exit(i2400mu_driver_exit);
593
594MODULE_AUTHOR("Intel Corporation <linux-wimax@intel.com>");
595MODULE_DESCRIPTION("Intel 2400M WiMAX networking for USB");
596MODULE_LICENSE("GPL");
597MODULE_FIRMWARE(I2400MU_FW_FILE_NAME);
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index ea543fcf2687..e4f9f747de88 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -111,7 +111,7 @@ config WLAN_80211
111 lets you choose drivers. 111 lets you choose drivers.
112 112
113config PCMCIA_RAYCS 113config PCMCIA_RAYCS
114 tristate "Aviator/Raytheon 2.4MHz wireless support" 114 tristate "Aviator/Raytheon 2.4GHz wireless support"
115 depends on PCMCIA && WLAN_80211 115 depends on PCMCIA && WLAN_80211
116 select WIRELESS_EXT 116 select WIRELESS_EXT
117 ---help--- 117 ---help---
diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c
index 4af2607deec0..8ef87356e083 100644
--- a/drivers/net/wireless/ath5k/base.c
+++ b/drivers/net/wireless/ath5k/base.c
@@ -2644,7 +2644,7 @@ ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
2644 if (skb_headroom(skb) < padsize) { 2644 if (skb_headroom(skb) < padsize) {
2645 ATH5K_ERR(sc, "tx hdrlen not %%4: %d not enough" 2645 ATH5K_ERR(sc, "tx hdrlen not %%4: %d not enough"
2646 " headroom to pad %d\n", hdrlen, padsize); 2646 " headroom to pad %d\n", hdrlen, padsize);
2647 return -1; 2647 return NETDEV_TX_BUSY;
2648 } 2648 }
2649 skb_push(skb, padsize); 2649 skb_push(skb, padsize);
2650 memmove(skb->data, skb->data+padsize, hdrlen); 2650 memmove(skb->data, skb->data+padsize, hdrlen);
@@ -2655,7 +2655,7 @@ ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
2655 ATH5K_ERR(sc, "no further txbuf available, dropping packet\n"); 2655 ATH5K_ERR(sc, "no further txbuf available, dropping packet\n");
2656 spin_unlock_irqrestore(&sc->txbuflock, flags); 2656 spin_unlock_irqrestore(&sc->txbuflock, flags);
2657 ieee80211_stop_queue(hw, skb_get_queue_mapping(skb)); 2657 ieee80211_stop_queue(hw, skb_get_queue_mapping(skb));
2658 return -1; 2658 return NETDEV_TX_BUSY;
2659 } 2659 }
2660 bf = list_first_entry(&sc->txbuf, struct ath5k_buf, list); 2660 bf = list_first_entry(&sc->txbuf, struct ath5k_buf, list);
2661 list_del(&bf->list); 2661 list_del(&bf->list);
@@ -2673,10 +2673,10 @@ ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
2673 sc->txbuf_len++; 2673 sc->txbuf_len++;
2674 spin_unlock_irqrestore(&sc->txbuflock, flags); 2674 spin_unlock_irqrestore(&sc->txbuflock, flags);
2675 dev_kfree_skb_any(skb); 2675 dev_kfree_skb_any(skb);
2676 return 0; 2676 return NETDEV_TX_OK;
2677 } 2677 }
2678 2678
2679 return 0; 2679 return NETDEV_TX_OK;
2680} 2680}
2681 2681
2682static int 2682static int
diff --git a/drivers/net/wireless/ath5k/dma.c b/drivers/net/wireless/ath5k/dma.c
index 7e2b1a67e5da..b65b4feb2d28 100644
--- a/drivers/net/wireless/ath5k/dma.c
+++ b/drivers/net/wireless/ath5k/dma.c
@@ -594,7 +594,7 @@ int ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask)
594 * XXX: BMISS interrupts may occur after association. 594 * XXX: BMISS interrupts may occur after association.
595 * I found this on 5210 code but it needs testing. If this is 595 * I found this on 5210 code but it needs testing. If this is
596 * true we should disable them before assoc and re-enable them 596 * true we should disable them before assoc and re-enable them
597 * after a successfull assoc + some jiffies. 597 * after a successful assoc + some jiffies.
598 interrupt_mask &= ~AR5K_INT_BMISS; 598 interrupt_mask &= ~AR5K_INT_BMISS;
599 */ 599 */
600 } 600 }
diff --git a/drivers/net/wireless/ath5k/pcu.c b/drivers/net/wireless/ath5k/pcu.c
index 0cac05c6a9ce..75eb9f43c741 100644
--- a/drivers/net/wireless/ath5k/pcu.c
+++ b/drivers/net/wireless/ath5k/pcu.c
@@ -65,7 +65,7 @@ int ath5k_hw_set_opmode(struct ath5k_hw *ah)
65 if (ah->ah_version == AR5K_AR5210) 65 if (ah->ah_version == AR5K_AR5210)
66 pcu_reg |= AR5K_STA_ID1_NO_PSPOLL; 66 pcu_reg |= AR5K_STA_ID1_NO_PSPOLL;
67 else 67 else
68 AR5K_REG_DISABLE_BITS(ah, AR5K_CFG, AR5K_CFG_ADHOC); 68 AR5K_REG_ENABLE_BITS(ah, AR5K_CFG, AR5K_CFG_IBSS);
69 break; 69 break;
70 70
71 case NL80211_IFTYPE_AP: 71 case NL80211_IFTYPE_AP:
@@ -75,7 +75,7 @@ int ath5k_hw_set_opmode(struct ath5k_hw *ah)
75 if (ah->ah_version == AR5K_AR5210) 75 if (ah->ah_version == AR5K_AR5210)
76 pcu_reg |= AR5K_STA_ID1_NO_PSPOLL; 76 pcu_reg |= AR5K_STA_ID1_NO_PSPOLL;
77 else 77 else
78 AR5K_REG_ENABLE_BITS(ah, AR5K_CFG, AR5K_CFG_ADHOC); 78 AR5K_REG_DISABLE_BITS(ah, AR5K_CFG, AR5K_CFG_IBSS);
79 break; 79 break;
80 80
81 case NL80211_IFTYPE_STATION: 81 case NL80211_IFTYPE_STATION:
diff --git a/drivers/net/wireless/ath5k/reg.h b/drivers/net/wireless/ath5k/reg.h
index 91aaeaf88199..9189ab13286c 100644
--- a/drivers/net/wireless/ath5k/reg.h
+++ b/drivers/net/wireless/ath5k/reg.h
@@ -73,7 +73,7 @@
73#define AR5K_CFG_SWRD 0x00000004 /* Byte-swap RX descriptor */ 73#define AR5K_CFG_SWRD 0x00000004 /* Byte-swap RX descriptor */
74#define AR5K_CFG_SWRB 0x00000008 /* Byte-swap RX buffer */ 74#define AR5K_CFG_SWRB 0x00000008 /* Byte-swap RX buffer */
75#define AR5K_CFG_SWRG 0x00000010 /* Byte-swap Register access */ 75#define AR5K_CFG_SWRG 0x00000010 /* Byte-swap Register access */
76#define AR5K_CFG_ADHOC 0x00000020 /* AP/Adhoc indication [5211+] */ 76#define AR5K_CFG_IBSS 0x00000020 /* 0-BSS, 1-IBSS [5211+] */
77#define AR5K_CFG_PHY_OK 0x00000100 /* [5211+] */ 77#define AR5K_CFG_PHY_OK 0x00000100 /* [5211+] */
78#define AR5K_CFG_EEBS 0x00000200 /* EEPROM is busy */ 78#define AR5K_CFG_EEBS 0x00000200 /* EEPROM is busy */
79#define AR5K_CFG_CLKGD 0x00000400 /* Clock gated (Disable dynamic clock) */ 79#define AR5K_CFG_CLKGD 0x00000400 /* Clock gated (Disable dynamic clock) */
diff --git a/drivers/net/wireless/ath9k/Kconfig b/drivers/net/wireless/ath9k/Kconfig
index c43bd321f97f..90a8dd873786 100644
--- a/drivers/net/wireless/ath9k/Kconfig
+++ b/drivers/net/wireless/ath9k/Kconfig
@@ -1,6 +1,7 @@
1config ATH9K 1config ATH9K
2 tristate "Atheros 802.11n wireless cards support" 2 tristate "Atheros 802.11n wireless cards support"
3 depends on PCI && MAC80211 && WLAN_80211 3 depends on PCI && MAC80211 && WLAN_80211
4 depends on RFKILL || RFKILL=n
4 select MAC80211_LEDS 5 select MAC80211_LEDS
5 select LEDS_CLASS 6 select LEDS_CLASS
6 select NEW_LEDS 7 select NEW_LEDS
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index 191eec50dc75..727f067aca4f 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -2164,13 +2164,13 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
2164 conf->ht.channel_type); 2164 conf->ht.channel_type);
2165 } 2165 }
2166 2166
2167 ath_update_chainmask(sc, conf->ht.enabled);
2168
2167 if (ath_set_channel(sc, &sc->sc_ah->ah_channels[pos]) < 0) { 2169 if (ath_set_channel(sc, &sc->sc_ah->ah_channels[pos]) < 0) {
2168 DPRINTF(sc, ATH_DBG_FATAL, "Unable to set channel\n"); 2170 DPRINTF(sc, ATH_DBG_FATAL, "Unable to set channel\n");
2169 mutex_unlock(&sc->mutex); 2171 mutex_unlock(&sc->mutex);
2170 return -EINVAL; 2172 return -EINVAL;
2171 } 2173 }
2172
2173 ath_update_chainmask(sc, conf->ht.enabled);
2174 } 2174 }
2175 2175
2176 if (changed & IEEE80211_CONF_CHANGE_POWER) 2176 if (changed & IEEE80211_CONF_CHANGE_POWER)
diff --git a/drivers/net/wireless/ath9k/xmit.c b/drivers/net/wireless/ath9k/xmit.c
index 3bfc3b90f256..c92f0c6e4adc 100644
--- a/drivers/net/wireless/ath9k/xmit.c
+++ b/drivers/net/wireless/ath9k/xmit.c
@@ -126,15 +126,7 @@ static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
126 tx_info->flags |= IEEE80211_TX_STAT_ACK; 126 tx_info->flags |= IEEE80211_TX_STAT_ACK;
127 } 127 }
128 128
129 tx_info->status.rates[0].count = tx_status->retries; 129 tx_info->status.rates[0].count = tx_status->retries + 1;
130 if (tx_info->status.rates[0].flags & IEEE80211_TX_RC_MCS) {
131 /* Change idx from internal table index to MCS index */
132 int idx = tx_info->status.rates[0].idx;
133 struct ath_rate_table *rate_table = sc->cur_rate_table;
134 if (idx >= 0 && idx < rate_table->rate_cnt)
135 tx_info->status.rates[0].idx =
136 rate_table->info[idx].ratecode & 0x7f;
137 }
138 130
139 hdrlen = ieee80211_get_hdrlen_from_skb(skb); 131 hdrlen = ieee80211_get_hdrlen_from_skb(skb);
140 padsize = hdrlen & 3; 132 padsize = hdrlen & 3;
@@ -264,25 +256,22 @@ static void assign_aggr_tid_seqno(struct sk_buff *skb,
264 } 256 }
265 257
266 /* Get seqno */ 258 /* Get seqno */
267 259 /* For HT capable stations, we save tidno for later use.
268 if (ieee80211_is_data(fc) && !is_pae(skb)) { 260 * We also override seqno set by upper layer with the one
269 /* For HT capable stations, we save tidno for later use. 261 * in tx aggregation state.
270 * We also override seqno set by upper layer with the one 262 *
271 * in tx aggregation state. 263 * If fragmentation is on, the sequence number is
272 * 264 * not overridden, since it has been
273 * If fragmentation is on, the sequence number is 265 * incremented by the fragmentation routine.
274 * not overridden, since it has been 266 *
275 * incremented by the fragmentation routine. 267 * FIXME: check if the fragmentation threshold exceeds
276 * 268 * IEEE80211 max.
277 * FIXME: check if the fragmentation threshold exceeds 269 */
278 * IEEE80211 max. 270 tid = ATH_AN_2_TID(an, bf->bf_tidno);
279 */ 271 hdr->seq_ctrl = cpu_to_le16(tid->seq_next <<
280 tid = ATH_AN_2_TID(an, bf->bf_tidno); 272 IEEE80211_SEQ_SEQ_SHIFT);
281 hdr->seq_ctrl = cpu_to_le16(tid->seq_next << 273 bf->bf_seqno = tid->seq_next;
282 IEEE80211_SEQ_SEQ_SHIFT); 274 INCR(tid->seq_next, IEEE80211_SEQ_MAX);
283 bf->bf_seqno = tid->seq_next;
284 INCR(tid->seq_next, IEEE80211_SEQ_MAX);
285 }
286} 275}
287 276
288static int setup_tx_flags(struct ath_softc *sc, struct sk_buff *skb, 277static int setup_tx_flags(struct ath_softc *sc, struct sk_buff *skb,
@@ -1718,11 +1707,10 @@ static int ath_tx_setup_buffer(struct ath_softc *sc, struct ath_buf *bf,
1718 1707
1719 /* Assign seqno, tidno */ 1708 /* Assign seqno, tidno */
1720 1709
1721 if (bf_isht(bf) && (sc->sc_flags & SC_OP_TXAGGR)) 1710 if (ieee80211_is_data_qos(fc) && (sc->sc_flags & SC_OP_TXAGGR))
1722 assign_aggr_tid_seqno(skb, bf); 1711 assign_aggr_tid_seqno(skb, bf);
1723 1712
1724 /* DMA setup */ 1713 /* DMA setup */
1725
1726 bf->bf_mpdu = skb; 1714 bf->bf_mpdu = skb;
1727 1715
1728 bf->bf_dmacontext = pci_map_single(sc->pdev, skb->data, 1716 bf->bf_dmacontext = pci_map_single(sc->pdev, skb->data,
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index 350157fcd080..4223672c4432 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -3836,7 +3836,7 @@ static int reset_atmel_card(struct net_device *dev)
3836 This routine is also responsible for initialising some 3836 This routine is also responsible for initialising some
3837 hardware-specific fields in the atmel_private structure, 3837 hardware-specific fields in the atmel_private structure,
3838 including a copy of the firmware's hostinfo stucture 3838 including a copy of the firmware's hostinfo stucture
3839 which is the route into the rest of the firmare datastructures. */ 3839 which is the route into the rest of the firmware datastructures. */
3840 3840
3841 struct atmel_private *priv = netdev_priv(dev); 3841 struct atmel_private *priv = netdev_priv(dev);
3842 u8 configuration; 3842 u8 configuration;
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 7b31a327b24a..c788bad10661 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -3261,7 +3261,7 @@ static int b43_switch_band(struct b43_wl *wl, struct ieee80211_channel *chan)
3261 struct b43_wldev *down_dev; 3261 struct b43_wldev *down_dev;
3262 struct b43_wldev *d; 3262 struct b43_wldev *d;
3263 int err; 3263 int err;
3264 bool gmode; 3264 bool uninitialized_var(gmode);
3265 int prev_status; 3265 int prev_status;
3266 3266
3267 /* Find a device and PHY which supports the band. */ 3267 /* Find a device and PHY which supports the band. */
diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c
index c1324e31d2f6..fb996c27a19b 100644
--- a/drivers/net/wireless/b43legacy/main.c
+++ b/drivers/net/wireless/b43legacy/main.c
@@ -2465,7 +2465,7 @@ static void b43legacy_put_phy_into_reset(struct b43legacy_wldev *dev)
2465static int b43legacy_switch_phymode(struct b43legacy_wl *wl, 2465static int b43legacy_switch_phymode(struct b43legacy_wl *wl,
2466 unsigned int new_mode) 2466 unsigned int new_mode)
2467{ 2467{
2468 struct b43legacy_wldev *up_dev; 2468 struct b43legacy_wldev *uninitialized_var(up_dev);
2469 struct b43legacy_wldev *down_dev; 2469 struct b43legacy_wldev *down_dev;
2470 int err; 2470 int err;
2471 bool gmode = 0; 2471 bool gmode = 0;
diff --git a/drivers/net/wireless/ipw2x00/ipw2100.c b/drivers/net/wireless/ipw2x00/ipw2100.c
index 1667065b86a7..823c2bf5e31e 100644
--- a/drivers/net/wireless/ipw2x00/ipw2100.c
+++ b/drivers/net/wireless/ipw2x00/ipw2100.c
@@ -1332,7 +1332,7 @@ static int ipw2100_power_cycle_adapter(struct ipw2100_priv *priv)
1332 IPW_AUX_HOST_RESET_REG_STOP_MASTER); 1332 IPW_AUX_HOST_RESET_REG_STOP_MASTER);
1333 1333
1334 /* Step 2. Wait for stop Master Assert 1334 /* Step 2. Wait for stop Master Assert
1335 * (not more then 50us, otherwise ret error */ 1335 * (not more than 50us, otherwise ret error */
1336 i = 5; 1336 i = 5;
1337 do { 1337 do {
1338 udelay(IPW_WAIT_RESET_MASTER_ASSERT_COMPLETE_DELAY); 1338 udelay(IPW_WAIT_RESET_MASTER_ASSERT_COMPLETE_DELAY);
@@ -1830,7 +1830,7 @@ static void ipw2100_down(struct ipw2100_priv *priv)
1830 cancel_delayed_work(&priv->rf_kill); 1830 cancel_delayed_work(&priv->rf_kill);
1831 } 1831 }
1832 1832
1833 /* Kill the firmare hang check timer */ 1833 /* Kill the firmware hang check timer */
1834 if (!priv->stop_hang_check) { 1834 if (!priv->stop_hang_check) {
1835 priv->stop_hang_check = 1; 1835 priv->stop_hang_check = 1;
1836 cancel_delayed_work(&priv->hang_check); 1836 cancel_delayed_work(&priv->hang_check);
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 8fdb34222c0a..45cfa1cf194a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -2219,7 +2219,7 @@ int iwl3945_txpower_set_from_eeprom(struct iwl3945_priv *priv)
2219 /* set tx power value for all OFDM rates */ 2219 /* set tx power value for all OFDM rates */
2220 for (rate_index = 0; rate_index < IWL_OFDM_RATES; 2220 for (rate_index = 0; rate_index < IWL_OFDM_RATES;
2221 rate_index++) { 2221 rate_index++) {
2222 s32 power_idx; 2222 s32 uninitialized_var(power_idx);
2223 int rc; 2223 int rc;
2224 2224
2225 /* use channel group's clip-power table, 2225 /* use channel group's clip-power table,
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h
index 52966ffbef6e..ba997204c8d4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-commands.h
@@ -255,7 +255,7 @@ struct iwl_cmd_header {
255 * 0x3) 54 Mbps 255 * 0x3) 54 Mbps
256 * 256 *
257 * Legacy CCK rate format for bits 7:0 (bit 8 must be "0", bit 9 "1"): 257 * Legacy CCK rate format for bits 7:0 (bit 8 must be "0", bit 9 "1"):
258 * 3-0: 10) 1 Mbps 258 * 6-0: 10) 1 Mbps
259 * 20) 2 Mbps 259 * 20) 2 Mbps
260 * 55) 5.5 Mbps 260 * 55) 5.5 Mbps
261 * 110) 11 Mbps 261 * 110) 11 Mbps
diff --git a/drivers/net/wireless/iwlwifi/iwl-hcmd.c b/drivers/net/wireless/iwlwifi/iwl-hcmd.c
index 01a2169cecec..8c71ad4f88c5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-hcmd.c
+++ b/drivers/net/wireless/iwlwifi/iwl-hcmd.c
@@ -51,6 +51,7 @@ const char *get_cmd_string(u8 cmd)
51 IWL_CMD(REPLY_REMOVE_STA); 51 IWL_CMD(REPLY_REMOVE_STA);
52 IWL_CMD(REPLY_REMOVE_ALL_STA); 52 IWL_CMD(REPLY_REMOVE_ALL_STA);
53 IWL_CMD(REPLY_WEPKEY); 53 IWL_CMD(REPLY_WEPKEY);
54 IWL_CMD(REPLY_3945_RX);
54 IWL_CMD(REPLY_TX); 55 IWL_CMD(REPLY_TX);
55 IWL_CMD(REPLY_RATE_SCALE); 56 IWL_CMD(REPLY_RATE_SCALE);
56 IWL_CMD(REPLY_LEDS_CMD); 57 IWL_CMD(REPLY_LEDS_CMD);
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 3dba83679444..4e0007d20030 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -1369,7 +1369,7 @@ EXPORT_SYMBOL_GPL(lbs_start_card);
1369 1369
1370void lbs_stop_card(struct lbs_private *priv) 1370void lbs_stop_card(struct lbs_private *priv)
1371{ 1371{
1372 struct net_device *dev = priv->dev; 1372 struct net_device *dev;
1373 struct cmd_ctrl_node *cmdnode; 1373 struct cmd_ctrl_node *cmdnode;
1374 unsigned long flags; 1374 unsigned long flags;
1375 1375
@@ -1377,9 +1377,10 @@ void lbs_stop_card(struct lbs_private *priv)
1377 1377
1378 if (!priv) 1378 if (!priv)
1379 goto out; 1379 goto out;
1380 dev = priv->dev;
1380 1381
1381 netif_stop_queue(priv->dev); 1382 netif_stop_queue(dev);
1382 netif_carrier_off(priv->dev); 1383 netif_carrier_off(dev);
1383 1384
1384 lbs_debugfs_remove_one(priv); 1385 lbs_debugfs_remove_one(priv);
1385 if (priv->mesh_tlv) { 1386 if (priv->mesh_tlv) {
diff --git a/drivers/net/wireless/libertas_tf/main.c b/drivers/net/wireless/libertas_tf/main.c
index d1fc305de5fe..e7289e2e7f16 100644
--- a/drivers/net/wireless/libertas_tf/main.c
+++ b/drivers/net/wireless/libertas_tf/main.c
@@ -206,7 +206,7 @@ static int lbtf_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
206 * there are no buffered multicast frames to send 206 * there are no buffered multicast frames to send
207 */ 207 */
208 ieee80211_stop_queues(priv->hw); 208 ieee80211_stop_queues(priv->hw);
209 return 0; 209 return NETDEV_TX_OK;
210} 210}
211 211
212static void lbtf_tx_work(struct work_struct *work) 212static void lbtf_tx_work(struct work_struct *work)
diff --git a/drivers/net/wireless/orinoco/orinoco.c b/drivers/net/wireless/orinoco/orinoco.c
index bc84e2792f8a..c3bb85e0251e 100644
--- a/drivers/net/wireless/orinoco/orinoco.c
+++ b/drivers/net/wireless/orinoco/orinoco.c
@@ -1610,6 +1610,16 @@ static void orinoco_rx_isr_tasklet(unsigned long data)
1610 struct orinoco_rx_data *rx_data, *temp; 1610 struct orinoco_rx_data *rx_data, *temp;
1611 struct hermes_rx_descriptor *desc; 1611 struct hermes_rx_descriptor *desc;
1612 struct sk_buff *skb; 1612 struct sk_buff *skb;
1613 unsigned long flags;
1614
1615 /* orinoco_rx requires the driver lock, and we also need to
1616 * protect priv->rx_list, so just hold the lock over the
1617 * lot.
1618 *
1619 * If orinoco_lock fails, we've unplugged the card. In this
1620 * case just abort. */
1621 if (orinoco_lock(priv, &flags) != 0)
1622 return;
1613 1623
1614 /* extract desc and skb from queue */ 1624 /* extract desc and skb from queue */
1615 list_for_each_entry_safe(rx_data, temp, &priv->rx_list, list) { 1625 list_for_each_entry_safe(rx_data, temp, &priv->rx_list, list) {
@@ -1622,6 +1632,8 @@ static void orinoco_rx_isr_tasklet(unsigned long data)
1622 1632
1623 kfree(desc); 1633 kfree(desc);
1624 } 1634 }
1635
1636 orinoco_unlock(priv, &flags);
1625} 1637}
1626 1638
1627/********************************************************************/ 1639/********************************************************************/
@@ -3645,12 +3657,22 @@ struct net_device
3645void free_orinocodev(struct net_device *dev) 3657void free_orinocodev(struct net_device *dev)
3646{ 3658{
3647 struct orinoco_private *priv = netdev_priv(dev); 3659 struct orinoco_private *priv = netdev_priv(dev);
3660 struct orinoco_rx_data *rx_data, *temp;
3648 3661
3649 /* No need to empty priv->rx_list: if the tasklet is scheduled 3662 /* If the tasklet is scheduled when we call tasklet_kill it
3650 * when we call tasklet_kill it will run one final time, 3663 * will run one final time. However the tasklet will only
3651 * emptying the list */ 3664 * drain priv->rx_list if the hw is still available. */
3652 tasklet_kill(&priv->rx_tasklet); 3665 tasklet_kill(&priv->rx_tasklet);
3653 3666
3667 /* Explicitly drain priv->rx_list */
3668 list_for_each_entry_safe(rx_data, temp, &priv->rx_list, list) {
3669 list_del(&rx_data->list);
3670
3671 dev_kfree_skb(rx_data->skb);
3672 kfree(rx_data->desc);
3673 kfree(rx_data);
3674 }
3675
3654 unregister_pm_notifier(&priv->pm_notifier); 3676 unregister_pm_notifier(&priv->pm_notifier);
3655 orinoco_uncache_fw(priv); 3677 orinoco_uncache_fw(priv);
3656 3678
diff --git a/drivers/net/wireless/orinoco/orinoco_cs.c b/drivers/net/wireless/orinoco/orinoco_cs.c
index f127602670ec..0b32215d3f5d 100644
--- a/drivers/net/wireless/orinoco/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco/orinoco_cs.c
@@ -435,6 +435,7 @@ static struct pcmcia_device_id orinoco_cs_ids[] = {
435 PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002), /* Samsung SWL2000-N 11Mb/s WLAN Card */ 435 PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002), /* Samsung SWL2000-N 11Mb/s WLAN Card */
436 PCMCIA_DEVICE_MANF_CARD(0x0261, 0x0002), /* AirWay 802.11 Adapter (PCMCIA) */ 436 PCMCIA_DEVICE_MANF_CARD(0x0261, 0x0002), /* AirWay 802.11 Adapter (PCMCIA) */
437 PCMCIA_DEVICE_MANF_CARD(0x0268, 0x0001), /* ARtem Onair */ 437 PCMCIA_DEVICE_MANF_CARD(0x0268, 0x0001), /* ARtem Onair */
438 PCMCIA_DEVICE_MANF_CARD(0x0268, 0x0003), /* ARtem Onair Comcard 11 */
438 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0305), /* Buffalo WLI-PCM-S11 */ 439 PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0305), /* Buffalo WLI-PCM-S11 */
439 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612), /* Linksys WPC11 Version 2.5 */ 440 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612), /* Linksys WPC11 Version 2.5 */
440 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613), /* Linksys WPC11 Version 3 */ 441 PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613), /* Linksys WPC11 Version 3 */
diff --git a/drivers/net/wireless/p54/p54common.c b/drivers/net/wireless/p54/p54common.c
index 82354b974a04..c6a370fa9bcb 100644
--- a/drivers/net/wireless/p54/p54common.c
+++ b/drivers/net/wireless/p54/p54common.c
@@ -138,6 +138,7 @@ int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw)
138 u8 *fw_version = NULL; 138 u8 *fw_version = NULL;
139 size_t len; 139 size_t len;
140 int i; 140 int i;
141 int maxlen;
141 142
142 if (priv->rx_start) 143 if (priv->rx_start)
143 return 0; 144 return 0;
@@ -195,6 +196,16 @@ int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw)
195 else 196 else
196 priv->rx_mtu = (size_t) 197 priv->rx_mtu = (size_t)
197 0x620 - priv->tx_hdr_len; 198 0x620 - priv->tx_hdr_len;
199 maxlen = priv->tx_hdr_len + /* USB devices */
200 sizeof(struct p54_rx_data) +
201 4 + /* rx alignment */
202 IEEE80211_MAX_FRAG_THRESHOLD;
203 if (priv->rx_mtu > maxlen && PAGE_SIZE == 4096) {
204 printk(KERN_INFO "p54: rx_mtu reduced from %d "
205 "to %d\n", priv->rx_mtu,
206 maxlen);
207 priv->rx_mtu = maxlen;
208 }
198 break; 209 break;
199 } 210 }
200 case BR_CODE_EXPOSED_IF: 211 case BR_CODE_EXPOSED_IF:
@@ -575,6 +586,7 @@ static int p54_rx_data(struct ieee80211_hw *dev, struct sk_buff *skb)
575 u16 freq = le16_to_cpu(hdr->freq); 586 u16 freq = le16_to_cpu(hdr->freq);
576 size_t header_len = sizeof(*hdr); 587 size_t header_len = sizeof(*hdr);
577 u32 tsf32; 588 u32 tsf32;
589 u8 rate = hdr->rate & 0xf;
578 590
579 /* 591 /*
580 * If the device is in a unspecified state we have to 592 * If the device is in a unspecified state we have to
@@ -603,8 +615,11 @@ static int p54_rx_data(struct ieee80211_hw *dev, struct sk_buff *skb)
603 rx_status.qual = (100 * hdr->rssi) / 127; 615 rx_status.qual = (100 * hdr->rssi) / 127;
604 if (hdr->rate & 0x10) 616 if (hdr->rate & 0x10)
605 rx_status.flag |= RX_FLAG_SHORTPRE; 617 rx_status.flag |= RX_FLAG_SHORTPRE;
606 rx_status.rate_idx = (dev->conf.channel->band == IEEE80211_BAND_2GHZ ? 618 if (dev->conf.channel->band == IEEE80211_BAND_5GHZ)
607 hdr->rate : (hdr->rate - 4)) & 0xf; 619 rx_status.rate_idx = (rate < 4) ? 0 : rate - 4;
620 else
621 rx_status.rate_idx = rate;
622
608 rx_status.freq = freq; 623 rx_status.freq = freq;
609 rx_status.band = dev->conf.channel->band; 624 rx_status.band = dev->conf.channel->band;
610 rx_status.antenna = hdr->antenna; 625 rx_status.antenna = hdr->antenna;
@@ -798,6 +813,16 @@ static void p54_rx_frame_sent(struct ieee80211_hw *dev, struct sk_buff *skb)
798 info->flags |= IEEE80211_TX_STAT_TX_FILTERED; 813 info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
799 info->status.ack_signal = p54_rssi_to_dbm(dev, 814 info->status.ack_signal = p54_rssi_to_dbm(dev,
800 (int)payload->ack_rssi); 815 (int)payload->ack_rssi);
816
817 if (entry_data->key_type == P54_CRYPTO_TKIPMICHAEL) {
818 u8 *iv = (u8 *)(entry_data->align + pad +
819 entry_data->crypt_offset);
820
821 /* Restore the original TKIP IV. */
822 iv[2] = iv[0];
823 iv[0] = iv[1];
824 iv[1] = (iv[0] | 0x20) & 0x7f; /* WEPSeed - 8.3.2.2 */
825 }
801 skb_pull(entry, sizeof(*hdr) + pad + sizeof(*entry_data)); 826 skb_pull(entry, sizeof(*hdr) + pad + sizeof(*entry_data));
802 ieee80211_tx_status_irqsafe(dev, entry); 827 ieee80211_tx_status_irqsafe(dev, entry);
803 goto out; 828 goto out;
@@ -1383,7 +1408,6 @@ static int p54_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
1383 hdr->tries = ridx; 1408 hdr->tries = ridx;
1384 txhdr->rts_rate_idx = 0; 1409 txhdr->rts_rate_idx = 0;
1385 if (info->control.hw_key) { 1410 if (info->control.hw_key) {
1386 crypt_offset += info->control.hw_key->iv_len;
1387 txhdr->key_type = p54_convert_algo(info->control.hw_key->alg); 1411 txhdr->key_type = p54_convert_algo(info->control.hw_key->alg);
1388 txhdr->key_len = min((u8)16, info->control.hw_key->keylen); 1412 txhdr->key_len = min((u8)16, info->control.hw_key->keylen);
1389 memcpy(txhdr->key, info->control.hw_key->key, txhdr->key_len); 1413 memcpy(txhdr->key, info->control.hw_key->key, txhdr->key_len);
@@ -1397,6 +1421,8 @@ static int p54_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
1397 } 1421 }
1398 /* reserve some space for ICV */ 1422 /* reserve some space for ICV */
1399 len += info->control.hw_key->icv_len; 1423 len += info->control.hw_key->icv_len;
1424 memset(skb_put(skb, info->control.hw_key->icv_len), 0,
1425 info->control.hw_key->icv_len);
1400 } else { 1426 } else {
1401 txhdr->key_type = 0; 1427 txhdr->key_type = 0;
1402 txhdr->key_len = 0; 1428 txhdr->key_len = 0;
@@ -1824,7 +1850,7 @@ static void p54_remove_interface(struct ieee80211_hw *dev,
1824 1850
1825static int p54_config(struct ieee80211_hw *dev, u32 changed) 1851static int p54_config(struct ieee80211_hw *dev, u32 changed)
1826{ 1852{
1827 int ret; 1853 int ret = 0;
1828 struct p54_common *priv = dev->priv; 1854 struct p54_common *priv = dev->priv;
1829 struct ieee80211_conf *conf = &dev->conf; 1855 struct ieee80211_conf *conf = &dev->conf;
1830 1856
diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c
index c44a200059d2..6a6a72f6f82c 100644
--- a/drivers/net/wireless/p54/p54usb.c
+++ b/drivers/net/wireless/p54/p54usb.c
@@ -56,6 +56,7 @@ static struct usb_device_id p54u_table[] __devinitdata = {
56 {USB_DEVICE(0x050d, 0x7050)}, /* Belkin F5D7050 ver 1000 */ 56 {USB_DEVICE(0x050d, 0x7050)}, /* Belkin F5D7050 ver 1000 */
57 {USB_DEVICE(0x0572, 0x2000)}, /* Cohiba Proto board */ 57 {USB_DEVICE(0x0572, 0x2000)}, /* Cohiba Proto board */
58 {USB_DEVICE(0x0572, 0x2002)}, /* Cohiba Proto board */ 58 {USB_DEVICE(0x0572, 0x2002)}, /* Cohiba Proto board */
59 {USB_DEVICE(0x06b9, 0x0121)}, /* Thomson SpeedTouch 121g */
59 {USB_DEVICE(0x0707, 0xee13)}, /* SMC 2862W-G version 2 */ 60 {USB_DEVICE(0x0707, 0xee13)}, /* SMC 2862W-G version 2 */
60 {USB_DEVICE(0x083a, 0x4521)}, /* Siemens Gigaset USB Adapter 54 version 2 */ 61 {USB_DEVICE(0x083a, 0x4521)}, /* Siemens Gigaset USB Adapter 54 version 2 */
61 {USB_DEVICE(0x0846, 0x4240)}, /* Netgear WG111 (v2) */ 62 {USB_DEVICE(0x0846, 0x4240)}, /* Netgear WG111 (v2) */
@@ -284,6 +285,7 @@ static void p54u_tx_lm87(struct ieee80211_hw *dev, struct sk_buff *skb)
284 usb_fill_bulk_urb(data_urb, priv->udev, 285 usb_fill_bulk_urb(data_urb, priv->udev,
285 usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA), 286 usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA),
286 skb->data, skb->len, p54u_tx_cb, skb); 287 skb->data, skb->len, p54u_tx_cb, skb);
288 data_urb->transfer_flags |= URB_ZERO_PACKET;
287 289
288 usb_anchor_urb(data_urb, &priv->submitted); 290 usb_anchor_urb(data_urb, &priv->submitted);
289 if (usb_submit_urb(data_urb, GFP_ATOMIC)) { 291 if (usb_submit_urb(data_urb, GFP_ATOMIC)) {
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index 30028e2422fc..af6b5847be5c 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -38,7 +38,7 @@
38/* 38/*
39 * Allow hardware encryption to be disabled. 39 * Allow hardware encryption to be disabled.
40 */ 40 */
41static int modparam_nohwcrypt = 1; 41static int modparam_nohwcrypt = 0;
42module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO); 42module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO);
43MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption."); 43MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption.");
44 44
@@ -376,11 +376,11 @@ static int rt2500usb_config_key(struct rt2x00_dev *rt2x00dev,
376 376
377 /* 377 /*
378 * The driver does not support the IV/EIV generation 378 * The driver does not support the IV/EIV generation
379 * in hardware. However it doesn't support the IV/EIV 379 * in hardware. However it demands the data to be provided
380 * inside the ieee80211 frame either, but requires it 380 * both seperately as well as inside the frame.
381 * to be provided seperately for the descriptor. 381 * We already provided the CONFIG_CRYPTO_COPY_IV to rt2x00lib
382 * rt2x00lib will cut the IV/EIV data out of all frames 382 * to ensure rt2x00lib will not strip the data from the
383 * given to us by mac80211, but we must tell mac80211 383 * frame after the copy, now we must tell mac80211
384 * to generate the IV/EIV data. 384 * to generate the IV/EIV data.
385 */ 385 */
386 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; 386 key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
@@ -1181,7 +1181,7 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1181 test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags)); 1181 test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags));
1182 rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs); 1182 rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs);
1183 rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skb->len); 1183 rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skb->len);
1184 rt2x00_set_field32(&word, TXD_W0_CIPHER, txdesc->cipher); 1184 rt2x00_set_field32(&word, TXD_W0_CIPHER, !!txdesc->cipher);
1185 rt2x00_set_field32(&word, TXD_W0_KEY_ID, txdesc->key_idx); 1185 rt2x00_set_field32(&word, TXD_W0_KEY_ID, txdesc->key_idx);
1186 rt2x00_desc_write(txd, 0, word); 1186 rt2x00_desc_write(txd, 0, word);
1187} 1187}
@@ -1334,14 +1334,7 @@ static void rt2500usb_fill_rxdone(struct queue_entry *entry,
1334 1334
1335 /* ICV is located at the end of frame */ 1335 /* ICV is located at the end of frame */
1336 1336
1337 /* 1337 rxdesc->flags |= RX_FLAG_MMIC_STRIPPED;
1338 * Hardware has stripped IV/EIV data from 802.11 frame during
1339 * decryption. It has provided the data seperately but rt2x00lib
1340 * should decide if it should be reinserted.
1341 */
1342 rxdesc->flags |= RX_FLAG_IV_STRIPPED;
1343 if (rxdesc->cipher != CIPHER_TKIP)
1344 rxdesc->flags |= RX_FLAG_MMIC_STRIPPED;
1345 if (rxdesc->cipher_status == RX_CRYPTO_SUCCESS) 1338 if (rxdesc->cipher_status == RX_CRYPTO_SUCCESS)
1346 rxdesc->flags |= RX_FLAG_DECRYPTED; 1339 rxdesc->flags |= RX_FLAG_DECRYPTED;
1347 else if (rxdesc->cipher_status == RX_CRYPTO_FAIL_MIC) 1340 else if (rxdesc->cipher_status == RX_CRYPTO_FAIL_MIC)
diff --git a/drivers/net/wireless/rt2x00/rt2x00crypto.c b/drivers/net/wireless/rt2x00/rt2x00crypto.c
index 37ad0d2fb64c..aee9cba13eb3 100644
--- a/drivers/net/wireless/rt2x00/rt2x00crypto.c
+++ b/drivers/net/wireless/rt2x00/rt2x00crypto.c
@@ -184,8 +184,8 @@ void rt2x00crypto_rx_insert_iv(struct sk_buff *skb, unsigned int align,
184 * Make room for new data, note that we increase both 184 * Make room for new data, note that we increase both
185 * headsize and tailsize when required. The tailsize is 185 * headsize and tailsize when required. The tailsize is
186 * only needed when ICV data needs to be inserted and 186 * only needed when ICV data needs to be inserted and
187 * the padding is smaller then the ICV data. 187 * the padding is smaller than the ICV data.
188 * When alignment requirements is greater then the 188 * When alignment requirements is greater than the
189 * ICV data we must trim the skb to the correct size 189 * ICV data we must trim the skb to the correct size
190 * because we need to remove the extra bytes. 190 * because we need to remove the extra bytes.
191 */ 191 */
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 6d92542fcf0d..87c0f2c83077 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -807,13 +807,11 @@ static void rt2x00lib_rate(struct ieee80211_rate *entry,
807{ 807{
808 entry->flags = 0; 808 entry->flags = 0;
809 entry->bitrate = rate->bitrate; 809 entry->bitrate = rate->bitrate;
810 entry->hw_value = rt2x00_create_rate_hw_value(index, 0); 810 entry->hw_value =index;
811 entry->hw_value_short = entry->hw_value; 811 entry->hw_value_short = index;
812 812
813 if (rate->flags & DEV_RATE_SHORT_PREAMBLE) { 813 if (rate->flags & DEV_RATE_SHORT_PREAMBLE)
814 entry->flags |= IEEE80211_RATE_SHORT_PREAMBLE; 814 entry->flags |= IEEE80211_RATE_SHORT_PREAMBLE;
815 entry->hw_value_short |= rt2x00_create_rate_hw_value(index, 1);
816 }
817} 815}
818 816
819static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev, 817static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev,
diff --git a/drivers/net/wireless/rt2x00/rt2x00leds.c b/drivers/net/wireless/rt2x00/rt2x00leds.c
index 68f4e0fc35b9..a0cd35b6beb5 100644
--- a/drivers/net/wireless/rt2x00/rt2x00leds.c
+++ b/drivers/net/wireless/rt2x00/rt2x00leds.c
@@ -97,7 +97,7 @@ void rt2x00leds_led_assoc(struct rt2x00_dev *rt2x00dev, bool enabled)
97 97
98void rt2x00leds_led_radio(struct rt2x00_dev *rt2x00dev, bool enabled) 98void rt2x00leds_led_radio(struct rt2x00_dev *rt2x00dev, bool enabled)
99{ 99{
100 if (rt2x00dev->led_radio.type == LED_TYPE_ASSOC) 100 if (rt2x00dev->led_radio.type == LED_TYPE_RADIO)
101 rt2x00led_led_simple(&rt2x00dev->led_radio, enabled); 101 rt2x00led_led_simple(&rt2x00dev->led_radio, enabled);
102} 102}
103 103
diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h
index 03024327767b..86cd26fbf769 100644
--- a/drivers/net/wireless/rt2x00/rt2x00lib.h
+++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
@@ -52,22 +52,11 @@ struct rt2x00_rate {
52 52
53extern const struct rt2x00_rate rt2x00_supported_rates[12]; 53extern const struct rt2x00_rate rt2x00_supported_rates[12];
54 54
55static inline u16 rt2x00_create_rate_hw_value(const u16 index,
56 const u16 short_preamble)
57{
58 return (short_preamble << 8) | (index & 0xff);
59}
60
61static inline const struct rt2x00_rate *rt2x00_get_rate(const u16 hw_value) 55static inline const struct rt2x00_rate *rt2x00_get_rate(const u16 hw_value)
62{ 56{
63 return &rt2x00_supported_rates[hw_value & 0xff]; 57 return &rt2x00_supported_rates[hw_value & 0xff];
64} 58}
65 59
66static inline int rt2x00_get_rate_preamble(const u16 hw_value)
67{
68 return (hw_value & 0xff00);
69}
70
71/* 60/*
72 * Radio control handlers. 61 * Radio control handlers.
73 */ 62 */
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
index eaec6bd93ed5..746a8f36b931 100644
--- a/drivers/net/wireless/rt2x00/rt2x00queue.c
+++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
@@ -313,7 +313,7 @@ static void rt2x00queue_create_tx_descriptor(struct queue_entry *entry,
313 * When preamble is enabled we should set the 313 * When preamble is enabled we should set the
314 * preamble bit for the signal. 314 * preamble bit for the signal.
315 */ 315 */
316 if (rt2x00_get_rate_preamble(rate->hw_value)) 316 if (rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
317 txdesc->signal |= 0x08; 317 txdesc->signal |= 0x08;
318 } 318 }
319} 319}
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c
index 83df312ac56f..0b29d767a258 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.c
@@ -434,11 +434,11 @@ static int rt2x00usb_find_endpoints(struct rt2x00_dev *rt2x00dev)
434 434
435 if (usb_endpoint_is_bulk_in(ep_desc)) { 435 if (usb_endpoint_is_bulk_in(ep_desc)) {
436 rt2x00usb_assign_endpoint(rt2x00dev->rx, ep_desc); 436 rt2x00usb_assign_endpoint(rt2x00dev->rx, ep_desc);
437 } else if (usb_endpoint_is_bulk_out(ep_desc)) { 437 } else if (usb_endpoint_is_bulk_out(ep_desc) &&
438 (queue != queue_end(rt2x00dev))) {
438 rt2x00usb_assign_endpoint(queue, ep_desc); 439 rt2x00usb_assign_endpoint(queue, ep_desc);
440 queue = queue_next(queue);
439 441
440 if (queue != queue_end(rt2x00dev))
441 queue = queue_next(queue);
442 tx_ep_desc = ep_desc; 442 tx_ep_desc = ep_desc;
443 } 443 }
444 } 444 }
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index d638a8a59370..96a8d69f8790 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -2321,6 +2321,7 @@ static struct usb_device_id rt73usb_device_table[] = {
2321 /* Linksys */ 2321 /* Linksys */
2322 { USB_DEVICE(0x13b1, 0x0020), USB_DEVICE_DATA(&rt73usb_ops) }, 2322 { USB_DEVICE(0x13b1, 0x0020), USB_DEVICE_DATA(&rt73usb_ops) },
2323 { USB_DEVICE(0x13b1, 0x0023), USB_DEVICE_DATA(&rt73usb_ops) }, 2323 { USB_DEVICE(0x13b1, 0x0023), USB_DEVICE_DATA(&rt73usb_ops) },
2324 { USB_DEVICE(0x13b1, 0x0028), USB_DEVICE_DATA(&rt73usb_ops) },
2324 /* MSI */ 2325 /* MSI */
2325 { USB_DEVICE(0x0db0, 0x6877), USB_DEVICE_DATA(&rt73usb_ops) }, 2326 { USB_DEVICE(0x0db0, 0x6877), USB_DEVICE_DATA(&rt73usb_ops) },
2326 { USB_DEVICE(0x0db0, 0x6874), USB_DEVICE_DATA(&rt73usb_ops) }, 2327 { USB_DEVICE(0x0db0, 0x6874), USB_DEVICE_DATA(&rt73usb_ops) },
diff --git a/drivers/net/wireless/rtl818x/rtl8180_dev.c b/drivers/net/wireless/rtl818x/rtl8180_dev.c
index 5f887fb137a9..387c133ec0f2 100644
--- a/drivers/net/wireless/rtl818x/rtl8180_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8180_dev.c
@@ -897,6 +897,7 @@ static int __devinit rtl8180_probe(struct pci_dev *pdev,
897 dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | 897 dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
898 IEEE80211_HW_RX_INCLUDES_FCS | 898 IEEE80211_HW_RX_INCLUDES_FCS |
899 IEEE80211_HW_SIGNAL_UNSPEC; 899 IEEE80211_HW_SIGNAL_UNSPEC;
900 dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
900 dev->queues = 1; 901 dev->queues = 1;
901 dev->max_signal = 65; 902 dev->max_signal = 65;
902 903
diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index 00ce3ef39abe..6ad6bac37706 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -213,7 +213,7 @@ static int rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
213 urb = usb_alloc_urb(0, GFP_ATOMIC); 213 urb = usb_alloc_urb(0, GFP_ATOMIC);
214 if (!urb) { 214 if (!urb) {
215 kfree_skb(skb); 215 kfree_skb(skb);
216 return -ENOMEM; 216 return NETDEV_TX_OK;
217 } 217 }
218 218
219 flags = skb->len; 219 flags = skb->len;
@@ -281,7 +281,7 @@ static int rtl8187_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
281 } 281 }
282 usb_free_urb(urb); 282 usb_free_urb(urb);
283 283
284 return rc; 284 return NETDEV_TX_OK;
285} 285}
286 286
287static void rtl8187_rx_cb(struct urb *urb) 287static void rtl8187_rx_cb(struct urb *urb)
@@ -1471,6 +1471,7 @@ static void __devexit rtl8187_disconnect(struct usb_interface *intf)
1471 ieee80211_unregister_hw(dev); 1471 ieee80211_unregister_hw(dev);
1472 1472
1473 priv = dev->priv; 1473 priv = dev->priv;
1474 usb_reset_device(priv->udev);
1474 usb_put_dev(interface_to_usbdev(intf)); 1475 usb_put_dev(interface_to_usbdev(intf));
1475 ieee80211_free_hw(dev); 1476 ieee80211_free_hw(dev);
1476} 1477}
diff --git a/drivers/net/wireless/strip.c b/drivers/net/wireless/strip.c
index dd0de3a9ed4e..7015f2480550 100644
--- a/drivers/net/wireless/strip.c
+++ b/drivers/net/wireless/strip.c
@@ -236,7 +236,7 @@ struct strip {
236 unsigned long tx_errors; /* Planned stuff */ 236 unsigned long tx_errors; /* Planned stuff */
237 unsigned long rx_dropped; /* No memory for skb */ 237 unsigned long rx_dropped; /* No memory for skb */
238 unsigned long tx_dropped; /* When MTU change */ 238 unsigned long tx_dropped; /* When MTU change */
239 unsigned long rx_over_errors; /* Frame bigger then STRIP buf. */ 239 unsigned long rx_over_errors; /* Frame bigger than STRIP buf. */
240 240
241 unsigned long pps_timer; /* Timer to determine pps */ 241 unsigned long pps_timer; /* Timer to determine pps */
242 unsigned long rx_pps_count; /* Counter to determine pps */ 242 unsigned long rx_pps_count; /* Counter to determine pps */
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index 9caa96a13586..a611ad857983 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -287,7 +287,7 @@ static void zd_op_stop(struct ieee80211_hw *hw)
287 * @skb - a sk-buffer 287 * @skb - a sk-buffer
288 * @flags: extra flags to set in the TX status info 288 * @flags: extra flags to set in the TX status info
289 * @ackssi: ACK signal strength 289 * @ackssi: ACK signal strength
290 * @success - True for successfull transmission of the frame 290 * @success - True for successful transmission of the frame
291 * 291 *
292 * This information calls ieee80211_tx_status_irqsafe() if required by the 292 * This information calls ieee80211_tx_status_irqsafe() if required by the
293 * control information. It copies the control information into the status 293 * control information. It copies the control information into the status
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 761635be9104..cd6184ee08ee 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1105,6 +1105,16 @@ static void xennet_uninit(struct net_device *dev)
1105 gnttab_free_grant_references(np->gref_rx_head); 1105 gnttab_free_grant_references(np->gref_rx_head);
1106} 1106}
1107 1107
1108static const struct net_device_ops xennet_netdev_ops = {
1109 .ndo_open = xennet_open,
1110 .ndo_uninit = xennet_uninit,
1111 .ndo_stop = xennet_close,
1112 .ndo_start_xmit = xennet_start_xmit,
1113 .ndo_change_mtu = xennet_change_mtu,
1114 .ndo_set_mac_address = eth_mac_addr,
1115 .ndo_validate_addr = eth_validate_addr,
1116};
1117
1108static struct net_device * __devinit xennet_create_dev(struct xenbus_device *dev) 1118static struct net_device * __devinit xennet_create_dev(struct xenbus_device *dev)
1109{ 1119{
1110 int i, err; 1120 int i, err;
@@ -1161,12 +1171,9 @@ static struct net_device * __devinit xennet_create_dev(struct xenbus_device *dev
1161 goto exit_free_tx; 1171 goto exit_free_tx;
1162 } 1172 }
1163 1173
1164 netdev->open = xennet_open; 1174 netdev->netdev_ops = &xennet_netdev_ops;
1165 netdev->hard_start_xmit = xennet_start_xmit; 1175
1166 netdev->stop = xennet_close;
1167 netif_napi_add(netdev, &np->napi, xennet_poll, 64); 1176 netif_napi_add(netdev, &np->napi, xennet_poll, 64);
1168 netdev->uninit = xennet_uninit;
1169 netdev->change_mtu = xennet_change_mtu;
1170 netdev->features = NETIF_F_IP_CSUM; 1177 netdev->features = NETIF_F_IP_CSUM;
1171 1178
1172 SET_ETHTOOL_OPS(netdev, &xennet_ethtool_ops); 1179 SET_ETHTOOL_OPS(netdev, &xennet_ethtool_ops);
diff --git a/drivers/net/yellowfin.c b/drivers/net/yellowfin.c
index cf9712922778..2f1645dcb8c8 100644
--- a/drivers/net/yellowfin.c
+++ b/drivers/net/yellowfin.c
@@ -362,6 +362,7 @@ static const struct net_device_ops netdev_ops = {
362 .ndo_set_multicast_list = set_rx_mode, 362 .ndo_set_multicast_list = set_rx_mode,
363 .ndo_change_mtu = eth_change_mtu, 363 .ndo_change_mtu = eth_change_mtu,
364 .ndo_validate_addr = eth_validate_addr, 364 .ndo_validate_addr = eth_validate_addr,
365 .ndo_set_mac_address = eth_mac_addr,
365 .ndo_do_ioctl = netdev_ioctl, 366 .ndo_do_ioctl = netdev_ioctl,
366 .ndo_tx_timeout = yellowfin_tx_timeout, 367 .ndo_tx_timeout = yellowfin_tx_timeout,
367}; 368};
diff --git a/drivers/net/zorro8390.c b/drivers/net/zorro8390.c
index affd904deafc..37c84e3b8be0 100644
--- a/drivers/net/zorro8390.c
+++ b/drivers/net/zorro8390.c
@@ -147,6 +147,7 @@ static const struct net_device_ops zorro8390_netdev_ops = {
147 .ndo_get_stats = ei_get_stats, 147 .ndo_get_stats = ei_get_stats,
148 .ndo_set_multicast_list = ei_set_multicast_list, 148 .ndo_set_multicast_list = ei_set_multicast_list,
149 .ndo_validate_addr = eth_validate_addr, 149 .ndo_validate_addr = eth_validate_addr,
150 .ndo_set_mac_address = eth_mac_addr,
150 .ndo_change_mtu = eth_change_mtu, 151 .ndo_change_mtu = eth_change_mtu,
151#ifdef CONFIG_NET_POLL_CONTROLLER 152#ifdef CONFIG_NET_POLL_CONTROLLER
152 .ndo_poll_controller = ei_poll, 153 .ndo_poll_controller = ei_poll,
diff --git a/drivers/of/of_i2c.c b/drivers/of/of_i2c.c
index e1b0ad6e918f..fa65a2b2ae2e 100644
--- a/drivers/of/of_i2c.c
+++ b/drivers/of/of_i2c.c
@@ -66,4 +66,23 @@ void of_register_i2c_devices(struct i2c_adapter *adap,
66} 66}
67EXPORT_SYMBOL(of_register_i2c_devices); 67EXPORT_SYMBOL(of_register_i2c_devices);
68 68
69static int of_dev_node_match(struct device *dev, void *data)
70{
71 return dev_archdata_get_node(&dev->archdata) == data;
72}
73
74/* must call put_device() when done with returned i2c_client device */
75struct i2c_client *of_find_i2c_device_by_node(struct device_node *node)
76{
77 struct device *dev;
78
79 dev = bus_find_device(&i2c_bus_type, NULL, node,
80 of_dev_node_match);
81 if (!dev)
82 return NULL;
83
84 return to_i2c_client(dev);
85}
86EXPORT_SYMBOL(of_find_i2c_device_by_node);
87
69MODULE_LICENSE("GPL"); 88MODULE_LICENSE("GPL");
diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
index 65e8294a9e29..9da5a4b81133 100644
--- a/drivers/oprofile/buffer_sync.c
+++ b/drivers/oprofile/buffer_sync.c
@@ -1,11 +1,12 @@
1/** 1/**
2 * @file buffer_sync.c 2 * @file buffer_sync.c
3 * 3 *
4 * @remark Copyright 2002 OProfile authors 4 * @remark Copyright 2002-2009 OProfile authors
5 * @remark Read the file COPYING 5 * @remark Read the file COPYING
6 * 6 *
7 * @author John Levon <levon@movementarian.org> 7 * @author John Levon <levon@movementarian.org>
8 * @author Barry Kasindorf 8 * @author Barry Kasindorf
9 * @author Robert Richter <robert.richter@amd.com>
9 * 10 *
10 * This is the core of the buffer management. Each 11 * This is the core of the buffer management. Each
11 * CPU buffer is processed and entered into the 12 * CPU buffer is processed and entered into the
@@ -315,88 +316,73 @@ static void add_trace_begin(void)
315 add_event_entry(TRACE_BEGIN_CODE); 316 add_event_entry(TRACE_BEGIN_CODE);
316} 317}
317 318
318#ifdef CONFIG_OPROFILE_IBS 319static void add_data(struct op_entry *entry, struct mm_struct *mm)
319
320#define IBS_FETCH_CODE_SIZE 2
321#define IBS_OP_CODE_SIZE 5
322
323/*
324 * Add IBS fetch and op entries to event buffer
325 */
326static void add_ibs_begin(int cpu, int code, struct mm_struct *mm)
327{ 320{
328 unsigned long rip; 321 unsigned long code, pc, val;
329 int i, count; 322 unsigned long cookie;
330 unsigned long ibs_cookie = 0;
331 off_t offset; 323 off_t offset;
332 struct op_sample *sample;
333
334 sample = cpu_buffer_read_entry(cpu);
335 if (!sample)
336 goto Error;
337 rip = sample->eip;
338 324
339#ifdef __LP64__ 325 if (!op_cpu_buffer_get_data(entry, &code))
340 rip += sample->event << 32; 326 return;
341#endif 327 if (!op_cpu_buffer_get_data(entry, &pc))
328 return;
329 if (!op_cpu_buffer_get_size(entry))
330 return;
342 331
343 if (mm) { 332 if (mm) {
344 ibs_cookie = lookup_dcookie(mm, rip, &offset); 333 cookie = lookup_dcookie(mm, pc, &offset);
345 334
346 if (ibs_cookie == NO_COOKIE) 335 if (cookie == NO_COOKIE)
347 offset = rip; 336 offset = pc;
348 if (ibs_cookie == INVALID_COOKIE) { 337 if (cookie == INVALID_COOKIE) {
349 atomic_inc(&oprofile_stats.sample_lost_no_mapping); 338 atomic_inc(&oprofile_stats.sample_lost_no_mapping);
350 offset = rip; 339 offset = pc;
351 } 340 }
352 if (ibs_cookie != last_cookie) { 341 if (cookie != last_cookie) {
353 add_cookie_switch(ibs_cookie); 342 add_cookie_switch(cookie);
354 last_cookie = ibs_cookie; 343 last_cookie = cookie;
355 } 344 }
356 } else 345 } else
357 offset = rip; 346 offset = pc;
358 347
359 add_event_entry(ESCAPE_CODE); 348 add_event_entry(ESCAPE_CODE);
360 add_event_entry(code); 349 add_event_entry(code);
361 add_event_entry(offset); /* Offset from Dcookie */ 350 add_event_entry(offset); /* Offset from Dcookie */
362 351
363 /* we send the Dcookie offset, but send the raw Linear Add also*/ 352 while (op_cpu_buffer_get_data(entry, &val))
364 add_event_entry(sample->eip); 353 add_event_entry(val);
365 add_event_entry(sample->event);
366
367 if (code == IBS_FETCH_CODE)
368 count = IBS_FETCH_CODE_SIZE; /*IBS FETCH is 2 int64s*/
369 else
370 count = IBS_OP_CODE_SIZE; /*IBS OP is 5 int64s*/
371
372 for (i = 0; i < count; i++) {
373 sample = cpu_buffer_read_entry(cpu);
374 if (!sample)
375 goto Error;
376 add_event_entry(sample->eip);
377 add_event_entry(sample->event);
378 }
379
380 return;
381
382Error:
383 return;
384} 354}
385 355
386#endif 356static inline void add_sample_entry(unsigned long offset, unsigned long event)
387
388static void add_sample_entry(unsigned long offset, unsigned long event)
389{ 357{
390 add_event_entry(offset); 358 add_event_entry(offset);
391 add_event_entry(event); 359 add_event_entry(event);
392} 360}
393 361
394 362
395static int add_us_sample(struct mm_struct *mm, struct op_sample *s) 363/*
364 * Add a sample to the global event buffer. If possible the
365 * sample is converted into a persistent dentry/offset pair
366 * for later lookup from userspace. Return 0 on failure.
367 */
368static int
369add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
396{ 370{
397 unsigned long cookie; 371 unsigned long cookie;
398 off_t offset; 372 off_t offset;
399 373
374 if (in_kernel) {
375 add_sample_entry(s->eip, s->event);
376 return 1;
377 }
378
379 /* add userspace sample */
380
381 if (!mm) {
382 atomic_inc(&oprofile_stats.sample_lost_no_mm);
383 return 0;
384 }
385
400 cookie = lookup_dcookie(mm, s->eip, &offset); 386 cookie = lookup_dcookie(mm, s->eip, &offset);
401 387
402 if (cookie == INVALID_COOKIE) { 388 if (cookie == INVALID_COOKIE) {
@@ -415,25 +401,6 @@ static int add_us_sample(struct mm_struct *mm, struct op_sample *s)
415} 401}
416 402
417 403
418/* Add a sample to the global event buffer. If possible the
419 * sample is converted into a persistent dentry/offset pair
420 * for later lookup from userspace.
421 */
422static int
423add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
424{
425 if (in_kernel) {
426 add_sample_entry(s->eip, s->event);
427 return 1;
428 } else if (mm) {
429 return add_us_sample(mm, s);
430 } else {
431 atomic_inc(&oprofile_stats.sample_lost_no_mm);
432 }
433 return 0;
434}
435
436
437static void release_mm(struct mm_struct *mm) 404static void release_mm(struct mm_struct *mm)
438{ 405{
439 if (!mm) 406 if (!mm)
@@ -526,66 +493,69 @@ void sync_buffer(int cpu)
526{ 493{
527 struct mm_struct *mm = NULL; 494 struct mm_struct *mm = NULL;
528 struct mm_struct *oldmm; 495 struct mm_struct *oldmm;
496 unsigned long val;
529 struct task_struct *new; 497 struct task_struct *new;
530 unsigned long cookie = 0; 498 unsigned long cookie = 0;
531 int in_kernel = 1; 499 int in_kernel = 1;
532 sync_buffer_state state = sb_buffer_start; 500 sync_buffer_state state = sb_buffer_start;
533 unsigned int i; 501 unsigned int i;
534 unsigned long available; 502 unsigned long available;
503 unsigned long flags;
504 struct op_entry entry;
505 struct op_sample *sample;
535 506
536 mutex_lock(&buffer_mutex); 507 mutex_lock(&buffer_mutex);
537 508
538 add_cpu_switch(cpu); 509 add_cpu_switch(cpu);
539 510
540 cpu_buffer_reset(cpu); 511 op_cpu_buffer_reset(cpu);
541 available = cpu_buffer_entries(cpu); 512 available = op_cpu_buffer_entries(cpu);
542 513
543 for (i = 0; i < available; ++i) { 514 for (i = 0; i < available; ++i) {
544 struct op_sample *s = cpu_buffer_read_entry(cpu); 515 sample = op_cpu_buffer_read_entry(&entry, cpu);
545 if (!s) 516 if (!sample)
546 break; 517 break;
547 518
548 if (is_code(s->eip)) { 519 if (is_code(sample->eip)) {
549 switch (s->event) { 520 flags = sample->event;
550 case 0: 521 if (flags & TRACE_BEGIN) {
551 case CPU_IS_KERNEL: 522 state = sb_bt_start;
523 add_trace_begin();
524 }
525 if (flags & KERNEL_CTX_SWITCH) {
552 /* kernel/userspace switch */ 526 /* kernel/userspace switch */
553 in_kernel = s->event; 527 in_kernel = flags & IS_KERNEL;
554 if (state == sb_buffer_start) 528 if (state == sb_buffer_start)
555 state = sb_sample_start; 529 state = sb_sample_start;
556 add_kernel_ctx_switch(s->event); 530 add_kernel_ctx_switch(flags & IS_KERNEL);
557 break; 531 }
558 case CPU_TRACE_BEGIN: 532 if (flags & USER_CTX_SWITCH
559 state = sb_bt_start; 533 && op_cpu_buffer_get_data(&entry, &val)) {
560 add_trace_begin();
561 break;
562#ifdef CONFIG_OPROFILE_IBS
563 case IBS_FETCH_BEGIN:
564 state = sb_bt_start;
565 add_ibs_begin(cpu, IBS_FETCH_CODE, mm);
566 break;
567 case IBS_OP_BEGIN:
568 state = sb_bt_start;
569 add_ibs_begin(cpu, IBS_OP_CODE, mm);
570 break;
571#endif
572 default:
573 /* userspace context switch */ 534 /* userspace context switch */
535 new = (struct task_struct *)val;
574 oldmm = mm; 536 oldmm = mm;
575 new = (struct task_struct *)s->event;
576 release_mm(oldmm); 537 release_mm(oldmm);
577 mm = take_tasks_mm(new); 538 mm = take_tasks_mm(new);
578 if (mm != oldmm) 539 if (mm != oldmm)
579 cookie = get_exec_dcookie(mm); 540 cookie = get_exec_dcookie(mm);
580 add_user_ctx_switch(new, cookie); 541 add_user_ctx_switch(new, cookie);
581 break;
582 }
583 } else if (state >= sb_bt_start &&
584 !add_sample(mm, s, in_kernel)) {
585 if (state == sb_bt_start) {
586 state = sb_bt_ignore;
587 atomic_inc(&oprofile_stats.bt_lost_no_mapping);
588 } 542 }
543 if (op_cpu_buffer_get_size(&entry))
544 add_data(&entry, mm);
545 continue;
546 }
547
548 if (state < sb_bt_start)
549 /* ignore sample */
550 continue;
551
552 if (add_sample(mm, sample, in_kernel))
553 continue;
554
555 /* ignore backtraces if failed to add a sample */
556 if (state == sb_bt_start) {
557 state = sb_bt_ignore;
558 atomic_inc(&oprofile_stats.bt_lost_no_mapping);
589 } 559 }
590 } 560 }
591 release_mm(mm); 561 release_mm(mm);
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c
index 61090969158f..2e03b6d796d3 100644
--- a/drivers/oprofile/cpu_buffer.c
+++ b/drivers/oprofile/cpu_buffer.c
@@ -1,11 +1,12 @@
1/** 1/**
2 * @file cpu_buffer.c 2 * @file cpu_buffer.c
3 * 3 *
4 * @remark Copyright 2002 OProfile authors 4 * @remark Copyright 2002-2009 OProfile authors
5 * @remark Read the file COPYING 5 * @remark Read the file COPYING
6 * 6 *
7 * @author John Levon <levon@movementarian.org> 7 * @author John Levon <levon@movementarian.org>
8 * @author Barry Kasindorf <barry.kasindorf@amd.com> 8 * @author Barry Kasindorf <barry.kasindorf@amd.com>
9 * @author Robert Richter <robert.richter@amd.com>
9 * 10 *
10 * Each CPU has a local buffer that stores PC value/event 11 * Each CPU has a local buffer that stores PC value/event
11 * pairs. We also log context switches when we notice them. 12 * pairs. We also log context switches when we notice them.
@@ -45,8 +46,8 @@
45 * can be changed to a single buffer solution when the ring buffer 46 * can be changed to a single buffer solution when the ring buffer
46 * access is implemented as non-locking atomic code. 47 * access is implemented as non-locking atomic code.
47 */ 48 */
48struct ring_buffer *op_ring_buffer_read; 49static struct ring_buffer *op_ring_buffer_read;
49struct ring_buffer *op_ring_buffer_write; 50static struct ring_buffer *op_ring_buffer_write;
50DEFINE_PER_CPU(struct oprofile_cpu_buffer, cpu_buffer); 51DEFINE_PER_CPU(struct oprofile_cpu_buffer, cpu_buffer);
51 52
52static void wq_sync_buffer(struct work_struct *work); 53static void wq_sync_buffer(struct work_struct *work);
@@ -54,19 +55,9 @@ static void wq_sync_buffer(struct work_struct *work);
54#define DEFAULT_TIMER_EXPIRE (HZ / 10) 55#define DEFAULT_TIMER_EXPIRE (HZ / 10)
55static int work_enabled; 56static int work_enabled;
56 57
57void free_cpu_buffers(void)
58{
59 if (op_ring_buffer_read)
60 ring_buffer_free(op_ring_buffer_read);
61 op_ring_buffer_read = NULL;
62 if (op_ring_buffer_write)
63 ring_buffer_free(op_ring_buffer_write);
64 op_ring_buffer_write = NULL;
65}
66
67unsigned long oprofile_get_cpu_buffer_size(void) 58unsigned long oprofile_get_cpu_buffer_size(void)
68{ 59{
69 return fs_cpu_buffer_size; 60 return oprofile_cpu_buffer_size;
70} 61}
71 62
72void oprofile_cpu_buffer_inc_smpl_lost(void) 63void oprofile_cpu_buffer_inc_smpl_lost(void)
@@ -77,11 +68,21 @@ void oprofile_cpu_buffer_inc_smpl_lost(void)
77 cpu_buf->sample_lost_overflow++; 68 cpu_buf->sample_lost_overflow++;
78} 69}
79 70
71void free_cpu_buffers(void)
72{
73 if (op_ring_buffer_read)
74 ring_buffer_free(op_ring_buffer_read);
75 op_ring_buffer_read = NULL;
76 if (op_ring_buffer_write)
77 ring_buffer_free(op_ring_buffer_write);
78 op_ring_buffer_write = NULL;
79}
80
80int alloc_cpu_buffers(void) 81int alloc_cpu_buffers(void)
81{ 82{
82 int i; 83 int i;
83 84
84 unsigned long buffer_size = fs_cpu_buffer_size; 85 unsigned long buffer_size = oprofile_cpu_buffer_size;
85 86
86 op_ring_buffer_read = ring_buffer_alloc(buffer_size, OP_BUFFER_FLAGS); 87 op_ring_buffer_read = ring_buffer_alloc(buffer_size, OP_BUFFER_FLAGS);
87 if (!op_ring_buffer_read) 88 if (!op_ring_buffer_read)
@@ -97,8 +98,6 @@ int alloc_cpu_buffers(void)
97 b->last_is_kernel = -1; 98 b->last_is_kernel = -1;
98 b->tracing = 0; 99 b->tracing = 0;
99 b->buffer_size = buffer_size; 100 b->buffer_size = buffer_size;
100 b->tail_pos = 0;
101 b->head_pos = 0;
102 b->sample_received = 0; 101 b->sample_received = 0;
103 b->sample_lost_overflow = 0; 102 b->sample_lost_overflow = 0;
104 b->backtrace_aborted = 0; 103 b->backtrace_aborted = 0;
@@ -145,47 +144,156 @@ void end_cpu_work(void)
145 flush_scheduled_work(); 144 flush_scheduled_work();
146} 145}
147 146
148static inline int 147/*
149add_sample(struct oprofile_cpu_buffer *cpu_buf, 148 * This function prepares the cpu buffer to write a sample.
150 unsigned long pc, unsigned long event) 149 *
150 * Struct op_entry is used during operations on the ring buffer while
151 * struct op_sample contains the data that is stored in the ring
152 * buffer. Struct entry can be uninitialized. The function reserves a
153 * data array that is specified by size. Use
154 * op_cpu_buffer_write_commit() after preparing the sample. In case of
155 * errors a null pointer is returned, otherwise the pointer to the
156 * sample.
157 *
158 */
159struct op_sample
160*op_cpu_buffer_write_reserve(struct op_entry *entry, unsigned long size)
161{
162 entry->event = ring_buffer_lock_reserve
163 (op_ring_buffer_write, sizeof(struct op_sample) +
164 size * sizeof(entry->sample->data[0]), &entry->irq_flags);
165 if (entry->event)
166 entry->sample = ring_buffer_event_data(entry->event);
167 else
168 entry->sample = NULL;
169
170 if (!entry->sample)
171 return NULL;
172
173 entry->size = size;
174 entry->data = entry->sample->data;
175
176 return entry->sample;
177}
178
179int op_cpu_buffer_write_commit(struct op_entry *entry)
180{
181 return ring_buffer_unlock_commit(op_ring_buffer_write, entry->event,
182 entry->irq_flags);
183}
184
185struct op_sample *op_cpu_buffer_read_entry(struct op_entry *entry, int cpu)
186{
187 struct ring_buffer_event *e;
188 e = ring_buffer_consume(op_ring_buffer_read, cpu, NULL);
189 if (e)
190 goto event;
191 if (ring_buffer_swap_cpu(op_ring_buffer_read,
192 op_ring_buffer_write,
193 cpu))
194 return NULL;
195 e = ring_buffer_consume(op_ring_buffer_read, cpu, NULL);
196 if (e)
197 goto event;
198 return NULL;
199
200event:
201 entry->event = e;
202 entry->sample = ring_buffer_event_data(e);
203 entry->size = (ring_buffer_event_length(e) - sizeof(struct op_sample))
204 / sizeof(entry->sample->data[0]);
205 entry->data = entry->sample->data;
206 return entry->sample;
207}
208
209unsigned long op_cpu_buffer_entries(int cpu)
210{
211 return ring_buffer_entries_cpu(op_ring_buffer_read, cpu)
212 + ring_buffer_entries_cpu(op_ring_buffer_write, cpu);
213}
214
215static int
216op_add_code(struct oprofile_cpu_buffer *cpu_buf, unsigned long backtrace,
217 int is_kernel, struct task_struct *task)
151{ 218{
152 struct op_entry entry; 219 struct op_entry entry;
153 int ret; 220 struct op_sample *sample;
221 unsigned long flags;
222 int size;
223
224 flags = 0;
225
226 if (backtrace)
227 flags |= TRACE_BEGIN;
228
229 /* notice a switch from user->kernel or vice versa */
230 is_kernel = !!is_kernel;
231 if (cpu_buf->last_is_kernel != is_kernel) {
232 cpu_buf->last_is_kernel = is_kernel;
233 flags |= KERNEL_CTX_SWITCH;
234 if (is_kernel)
235 flags |= IS_KERNEL;
236 }
237
238 /* notice a task switch */
239 if (cpu_buf->last_task != task) {
240 cpu_buf->last_task = task;
241 flags |= USER_CTX_SWITCH;
242 }
243
244 if (!flags)
245 /* nothing to do */
246 return 0;
247
248 if (flags & USER_CTX_SWITCH)
249 size = 1;
250 else
251 size = 0;
252
253 sample = op_cpu_buffer_write_reserve(&entry, size);
254 if (!sample)
255 return -ENOMEM;
154 256
155 ret = cpu_buffer_write_entry(&entry); 257 sample->eip = ESCAPE_CODE;
156 if (ret) 258 sample->event = flags;
157 return ret;
158 259
159 entry.sample->eip = pc; 260 if (size)
160 entry.sample->event = event; 261 op_cpu_buffer_add_data(&entry, (unsigned long)task);
161 262
162 ret = cpu_buffer_write_commit(&entry); 263 op_cpu_buffer_write_commit(&entry);
163 if (ret)
164 return ret;
165 264
166 return 0; 265 return 0;
167} 266}
168 267
169static inline int 268static inline int
170add_code(struct oprofile_cpu_buffer *buffer, unsigned long value) 269op_add_sample(struct oprofile_cpu_buffer *cpu_buf,
270 unsigned long pc, unsigned long event)
171{ 271{
172 return add_sample(buffer, ESCAPE_CODE, value); 272 struct op_entry entry;
273 struct op_sample *sample;
274
275 sample = op_cpu_buffer_write_reserve(&entry, 0);
276 if (!sample)
277 return -ENOMEM;
278
279 sample->eip = pc;
280 sample->event = event;
281
282 return op_cpu_buffer_write_commit(&entry);
173} 283}
174 284
175/* This must be safe from any context. It's safe writing here 285/*
176 * because of the head/tail separation of the writer and reader 286 * This must be safe from any context.
177 * of the CPU buffer.
178 * 287 *
179 * is_kernel is needed because on some architectures you cannot 288 * is_kernel is needed because on some architectures you cannot
180 * tell if you are in kernel or user space simply by looking at 289 * tell if you are in kernel or user space simply by looking at
181 * pc. We tag this in the buffer by generating kernel enter/exit 290 * pc. We tag this in the buffer by generating kernel enter/exit
182 * events whenever is_kernel changes 291 * events whenever is_kernel changes
183 */ 292 */
184static int log_sample(struct oprofile_cpu_buffer *cpu_buf, unsigned long pc, 293static int
185 int is_kernel, unsigned long event) 294log_sample(struct oprofile_cpu_buffer *cpu_buf, unsigned long pc,
295 unsigned long backtrace, int is_kernel, unsigned long event)
186{ 296{
187 struct task_struct *task;
188
189 cpu_buf->sample_received++; 297 cpu_buf->sample_received++;
190 298
191 if (pc == ESCAPE_CODE) { 299 if (pc == ESCAPE_CODE) {
@@ -193,25 +301,10 @@ static int log_sample(struct oprofile_cpu_buffer *cpu_buf, unsigned long pc,
193 return 0; 301 return 0;
194 } 302 }
195 303
196 is_kernel = !!is_kernel; 304 if (op_add_code(cpu_buf, backtrace, is_kernel, current))
197 305 goto fail;
198 task = current;
199
200 /* notice a switch from user->kernel or vice versa */
201 if (cpu_buf->last_is_kernel != is_kernel) {
202 cpu_buf->last_is_kernel = is_kernel;
203 if (add_code(cpu_buf, is_kernel))
204 goto fail;
205 }
206
207 /* notice a task switch */
208 if (cpu_buf->last_task != task) {
209 cpu_buf->last_task = task;
210 if (add_code(cpu_buf, (unsigned long)task))
211 goto fail;
212 }
213 306
214 if (add_sample(cpu_buf, pc, event)) 307 if (op_add_sample(cpu_buf, pc, event))
215 goto fail; 308 goto fail;
216 309
217 return 1; 310 return 1;
@@ -221,109 +314,102 @@ fail:
221 return 0; 314 return 0;
222} 315}
223 316
224static int oprofile_begin_trace(struct oprofile_cpu_buffer *cpu_buf) 317static inline void oprofile_begin_trace(struct oprofile_cpu_buffer *cpu_buf)
225{ 318{
226 add_code(cpu_buf, CPU_TRACE_BEGIN);
227 cpu_buf->tracing = 1; 319 cpu_buf->tracing = 1;
228 return 1;
229} 320}
230 321
231static void oprofile_end_trace(struct oprofile_cpu_buffer *cpu_buf) 322static inline void oprofile_end_trace(struct oprofile_cpu_buffer *cpu_buf)
232{ 323{
233 cpu_buf->tracing = 0; 324 cpu_buf->tracing = 0;
234} 325}
235 326
236void oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs, 327static inline void
237 unsigned long event, int is_kernel) 328__oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs,
329 unsigned long event, int is_kernel)
238{ 330{
239 struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(cpu_buffer); 331 struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(cpu_buffer);
240 332 unsigned long backtrace = oprofile_backtrace_depth;
241 if (!backtrace_depth) {
242 log_sample(cpu_buf, pc, is_kernel, event);
243 return;
244 }
245
246 if (!oprofile_begin_trace(cpu_buf))
247 return;
248 333
249 /* 334 /*
250 * if log_sample() fail we can't backtrace since we lost the 335 * if log_sample() fail we can't backtrace since we lost the
251 * source of this event 336 * source of this event
252 */ 337 */
253 if (log_sample(cpu_buf, pc, is_kernel, event)) 338 if (!log_sample(cpu_buf, pc, backtrace, is_kernel, event))
254 oprofile_ops.backtrace(regs, backtrace_depth); 339 /* failed */
340 return;
341
342 if (!backtrace)
343 return;
344
345 oprofile_begin_trace(cpu_buf);
346 oprofile_ops.backtrace(regs, backtrace);
255 oprofile_end_trace(cpu_buf); 347 oprofile_end_trace(cpu_buf);
256} 348}
257 349
350void oprofile_add_ext_sample(unsigned long pc, struct pt_regs * const regs,
351 unsigned long event, int is_kernel)
352{
353 __oprofile_add_ext_sample(pc, regs, event, is_kernel);
354}
355
258void oprofile_add_sample(struct pt_regs * const regs, unsigned long event) 356void oprofile_add_sample(struct pt_regs * const regs, unsigned long event)
259{ 357{
260 int is_kernel = !user_mode(regs); 358 int is_kernel = !user_mode(regs);
261 unsigned long pc = profile_pc(regs); 359 unsigned long pc = profile_pc(regs);
262 360
263 oprofile_add_ext_sample(pc, regs, event, is_kernel); 361 __oprofile_add_ext_sample(pc, regs, event, is_kernel);
264} 362}
265 363
266#ifdef CONFIG_OPROFILE_IBS 364/*
267 365 * Add samples with data to the ring buffer.
268#define MAX_IBS_SAMPLE_SIZE 14 366 *
269 367 * Use oprofile_add_data(&entry, val) to add data and
270void oprofile_add_ibs_sample(struct pt_regs * const regs, 368 * oprofile_write_commit(&entry) to commit the sample.
271 unsigned int * const ibs_sample, int ibs_code) 369 */
370void
371oprofile_write_reserve(struct op_entry *entry, struct pt_regs * const regs,
372 unsigned long pc, int code, int size)
272{ 373{
374 struct op_sample *sample;
273 int is_kernel = !user_mode(regs); 375 int is_kernel = !user_mode(regs);
274 struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(cpu_buffer); 376 struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(cpu_buffer);
275 struct task_struct *task;
276 int fail = 0;
277 377
278 cpu_buf->sample_received++; 378 cpu_buf->sample_received++;
279 379
280 /* notice a switch from user->kernel or vice versa */ 380 /* no backtraces for samples with data */
281 if (cpu_buf->last_is_kernel != is_kernel) { 381 if (op_add_code(cpu_buf, 0, is_kernel, current))
282 if (add_code(cpu_buf, is_kernel)) 382 goto fail;
283 goto fail;
284 cpu_buf->last_is_kernel = is_kernel;
285 }
286
287 /* notice a task switch */
288 if (!is_kernel) {
289 task = current;
290 if (cpu_buf->last_task != task) {
291 if (add_code(cpu_buf, (unsigned long)task))
292 goto fail;
293 cpu_buf->last_task = task;
294 }
295 }
296
297 fail = fail || add_code(cpu_buf, ibs_code);
298 fail = fail || add_sample(cpu_buf, ibs_sample[0], ibs_sample[1]);
299 fail = fail || add_sample(cpu_buf, ibs_sample[2], ibs_sample[3]);
300 fail = fail || add_sample(cpu_buf, ibs_sample[4], ibs_sample[5]);
301
302 if (ibs_code == IBS_OP_BEGIN) {
303 fail = fail || add_sample(cpu_buf, ibs_sample[6], ibs_sample[7]);
304 fail = fail || add_sample(cpu_buf, ibs_sample[8], ibs_sample[9]);
305 fail = fail || add_sample(cpu_buf, ibs_sample[10], ibs_sample[11]);
306 }
307 383
308 if (fail) 384 sample = op_cpu_buffer_write_reserve(entry, size + 2);
385 if (!sample)
309 goto fail; 386 goto fail;
387 sample->eip = ESCAPE_CODE;
388 sample->event = 0; /* no flags */
310 389
311 if (backtrace_depth) 390 op_cpu_buffer_add_data(entry, code);
312 oprofile_ops.backtrace(regs, backtrace_depth); 391 op_cpu_buffer_add_data(entry, pc);
313 392
314 return; 393 return;
315 394
316fail: 395fail:
317 cpu_buf->sample_lost_overflow++; 396 cpu_buf->sample_lost_overflow++;
318 return;
319} 397}
320 398
321#endif 399int oprofile_add_data(struct op_entry *entry, unsigned long val)
400{
401 return op_cpu_buffer_add_data(entry, val);
402}
403
404int oprofile_write_commit(struct op_entry *entry)
405{
406 return op_cpu_buffer_write_commit(entry);
407}
322 408
323void oprofile_add_pc(unsigned long pc, int is_kernel, unsigned long event) 409void oprofile_add_pc(unsigned long pc, int is_kernel, unsigned long event)
324{ 410{
325 struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(cpu_buffer); 411 struct oprofile_cpu_buffer *cpu_buf = &__get_cpu_var(cpu_buffer);
326 log_sample(cpu_buf, pc, is_kernel, event); 412 log_sample(cpu_buf, pc, 0, is_kernel, event);
327} 413}
328 414
329void oprofile_add_trace(unsigned long pc) 415void oprofile_add_trace(unsigned long pc)
@@ -340,7 +426,7 @@ void oprofile_add_trace(unsigned long pc)
340 if (pc == ESCAPE_CODE) 426 if (pc == ESCAPE_CODE)
341 goto fail; 427 goto fail;
342 428
343 if (add_sample(cpu_buf, pc, 0)) 429 if (op_add_sample(cpu_buf, pc, 0))
344 goto fail; 430 goto fail;
345 431
346 return; 432 return;
diff --git a/drivers/oprofile/cpu_buffer.h b/drivers/oprofile/cpu_buffer.h
index aacb0f0bc566..63f81c44846a 100644
--- a/drivers/oprofile/cpu_buffer.h
+++ b/drivers/oprofile/cpu_buffer.h
@@ -1,10 +1,11 @@
1/** 1/**
2 * @file cpu_buffer.h 2 * @file cpu_buffer.h
3 * 3 *
4 * @remark Copyright 2002 OProfile authors 4 * @remark Copyright 2002-2009 OProfile authors
5 * @remark Read the file COPYING 5 * @remark Read the file COPYING
6 * 6 *
7 * @author John Levon <levon@movementarian.org> 7 * @author John Levon <levon@movementarian.org>
8 * @author Robert Richter <robert.richter@amd.com>
8 */ 9 */
9 10
10#ifndef OPROFILE_CPU_BUFFER_H 11#ifndef OPROFILE_CPU_BUFFER_H
@@ -31,17 +32,12 @@ void end_cpu_work(void);
31struct op_sample { 32struct op_sample {
32 unsigned long eip; 33 unsigned long eip;
33 unsigned long event; 34 unsigned long event;
35 unsigned long data[0];
34}; 36};
35 37
36struct op_entry { 38struct op_entry;
37 struct ring_buffer_event *event;
38 struct op_sample *sample;
39 unsigned long irq_flags;
40};
41 39
42struct oprofile_cpu_buffer { 40struct oprofile_cpu_buffer {
43 volatile unsigned long head_pos;
44 volatile unsigned long tail_pos;
45 unsigned long buffer_size; 41 unsigned long buffer_size;
46 struct task_struct *last_task; 42 struct task_struct *last_task;
47 int last_is_kernel; 43 int last_is_kernel;
@@ -54,8 +50,6 @@ struct oprofile_cpu_buffer {
54 struct delayed_work work; 50 struct delayed_work work;
55}; 51};
56 52
57extern struct ring_buffer *op_ring_buffer_read;
58extern struct ring_buffer *op_ring_buffer_write;
59DECLARE_PER_CPU(struct oprofile_cpu_buffer, cpu_buffer); 53DECLARE_PER_CPU(struct oprofile_cpu_buffer, cpu_buffer);
60 54
61/* 55/*
@@ -64,7 +58,7 @@ DECLARE_PER_CPU(struct oprofile_cpu_buffer, cpu_buffer);
64 * reset these to invalid values; the next sample collected will 58 * reset these to invalid values; the next sample collected will
65 * populate the buffer with proper values to initialize the buffer 59 * populate the buffer with proper values to initialize the buffer
66 */ 60 */
67static inline void cpu_buffer_reset(int cpu) 61static inline void op_cpu_buffer_reset(int cpu)
68{ 62{
69 struct oprofile_cpu_buffer *cpu_buf = &per_cpu(cpu_buffer, cpu); 63 struct oprofile_cpu_buffer *cpu_buf = &per_cpu(cpu_buffer, cpu);
70 64
@@ -72,55 +66,48 @@ static inline void cpu_buffer_reset(int cpu)
72 cpu_buf->last_task = NULL; 66 cpu_buf->last_task = NULL;
73} 67}
74 68
75static inline int cpu_buffer_write_entry(struct op_entry *entry) 69struct op_sample
76{ 70*op_cpu_buffer_write_reserve(struct op_entry *entry, unsigned long size);
77 entry->event = ring_buffer_lock_reserve(op_ring_buffer_write, 71int op_cpu_buffer_write_commit(struct op_entry *entry);
78 sizeof(struct op_sample), 72struct op_sample *op_cpu_buffer_read_entry(struct op_entry *entry, int cpu);
79 &entry->irq_flags); 73unsigned long op_cpu_buffer_entries(int cpu);
80 if (entry->event)
81 entry->sample = ring_buffer_event_data(entry->event);
82 else
83 entry->sample = NULL;
84
85 if (!entry->sample)
86 return -ENOMEM;
87
88 return 0;
89}
90 74
91static inline int cpu_buffer_write_commit(struct op_entry *entry) 75/* returns the remaining free size of data in the entry */
76static inline
77int op_cpu_buffer_add_data(struct op_entry *entry, unsigned long val)
92{ 78{
93 return ring_buffer_unlock_commit(op_ring_buffer_write, entry->event, 79 if (!entry->size)
94 entry->irq_flags); 80 return 0;
81 *entry->data = val;
82 entry->size--;
83 entry->data++;
84 return entry->size;
95} 85}
96 86
97static inline struct op_sample *cpu_buffer_read_entry(int cpu) 87/* returns the size of data in the entry */
88static inline
89int op_cpu_buffer_get_size(struct op_entry *entry)
98{ 90{
99 struct ring_buffer_event *e; 91 return entry->size;
100 e = ring_buffer_consume(op_ring_buffer_read, cpu, NULL);
101 if (e)
102 return ring_buffer_event_data(e);
103 if (ring_buffer_swap_cpu(op_ring_buffer_read,
104 op_ring_buffer_write,
105 cpu))
106 return NULL;
107 e = ring_buffer_consume(op_ring_buffer_read, cpu, NULL);
108 if (e)
109 return ring_buffer_event_data(e);
110 return NULL;
111} 92}
112 93
113/* "acquire" as many cpu buffer slots as we can */ 94/* returns 0 if empty or the size of data including the current value */
114static inline unsigned long cpu_buffer_entries(int cpu) 95static inline
96int op_cpu_buffer_get_data(struct op_entry *entry, unsigned long *val)
115{ 97{
116 return ring_buffer_entries_cpu(op_ring_buffer_read, cpu) 98 int size = entry->size;
117 + ring_buffer_entries_cpu(op_ring_buffer_write, cpu); 99 if (!size)
100 return 0;
101 *val = *entry->data;
102 entry->size--;
103 entry->data++;
104 return size;
118} 105}
119 106
120/* transient events for the CPU buffer -> event buffer */ 107/* extra data flags */
121#define CPU_IS_KERNEL 1 108#define KERNEL_CTX_SWITCH (1UL << 0)
122#define CPU_TRACE_BEGIN 2 109#define IS_KERNEL (1UL << 1)
123#define IBS_FETCH_BEGIN 3 110#define TRACE_BEGIN (1UL << 2)
124#define IBS_OP_BEGIN 4 111#define USER_CTX_SWITCH (1UL << 3)
125 112
126#endif /* OPROFILE_CPU_BUFFER_H */ 113#endif /* OPROFILE_CPU_BUFFER_H */
diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
index 191a3202cecc..2b7ae366ceb1 100644
--- a/drivers/oprofile/event_buffer.c
+++ b/drivers/oprofile/event_buffer.c
@@ -73,8 +73,8 @@ int alloc_event_buffer(void)
73 unsigned long flags; 73 unsigned long flags;
74 74
75 spin_lock_irqsave(&oprofilefs_lock, flags); 75 spin_lock_irqsave(&oprofilefs_lock, flags);
76 buffer_size = fs_buffer_size; 76 buffer_size = oprofile_buffer_size;
77 buffer_watershed = fs_buffer_watershed; 77 buffer_watershed = oprofile_buffer_watershed;
78 spin_unlock_irqrestore(&oprofilefs_lock, flags); 78 spin_unlock_irqrestore(&oprofilefs_lock, flags);
79 79
80 if (buffer_watershed >= buffer_size) 80 if (buffer_watershed >= buffer_size)
diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
index cd375907f26f..3cffce90f82a 100644
--- a/drivers/oprofile/oprof.c
+++ b/drivers/oprofile/oprof.c
@@ -23,7 +23,7 @@
23struct oprofile_operations oprofile_ops; 23struct oprofile_operations oprofile_ops;
24 24
25unsigned long oprofile_started; 25unsigned long oprofile_started;
26unsigned long backtrace_depth; 26unsigned long oprofile_backtrace_depth;
27static unsigned long is_setup; 27static unsigned long is_setup;
28static DEFINE_MUTEX(start_mutex); 28static DEFINE_MUTEX(start_mutex);
29 29
@@ -172,7 +172,7 @@ int oprofile_set_backtrace(unsigned long val)
172 goto out; 172 goto out;
173 } 173 }
174 174
175 backtrace_depth = val; 175 oprofile_backtrace_depth = val;
176 176
177out: 177out:
178 mutex_unlock(&start_mutex); 178 mutex_unlock(&start_mutex);
diff --git a/drivers/oprofile/oprof.h b/drivers/oprofile/oprof.h
index 5df0c21a608f..c288d3c24b50 100644
--- a/drivers/oprofile/oprof.h
+++ b/drivers/oprofile/oprof.h
@@ -21,12 +21,12 @@ void oprofile_stop(void);
21 21
22struct oprofile_operations; 22struct oprofile_operations;
23 23
24extern unsigned long fs_buffer_size; 24extern unsigned long oprofile_buffer_size;
25extern unsigned long fs_cpu_buffer_size; 25extern unsigned long oprofile_cpu_buffer_size;
26extern unsigned long fs_buffer_watershed; 26extern unsigned long oprofile_buffer_watershed;
27extern struct oprofile_operations oprofile_ops; 27extern struct oprofile_operations oprofile_ops;
28extern unsigned long oprofile_started; 28extern unsigned long oprofile_started;
29extern unsigned long backtrace_depth; 29extern unsigned long oprofile_backtrace_depth;
30 30
31struct super_block; 31struct super_block;
32struct dentry; 32struct dentry;
diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
index d8201998b0b7..5d36ffc30dd5 100644
--- a/drivers/oprofile/oprofile_files.c
+++ b/drivers/oprofile/oprofile_files.c
@@ -14,17 +14,18 @@
14#include "oprofile_stats.h" 14#include "oprofile_stats.h"
15#include "oprof.h" 15#include "oprof.h"
16 16
17#define FS_BUFFER_SIZE_DEFAULT 131072 17#define BUFFER_SIZE_DEFAULT 131072
18#define FS_CPU_BUFFER_SIZE_DEFAULT 8192 18#define CPU_BUFFER_SIZE_DEFAULT 8192
19#define FS_BUFFER_WATERSHED_DEFAULT 32768 /* FIXME: tune */ 19#define BUFFER_WATERSHED_DEFAULT 32768 /* FIXME: tune */
20 20
21unsigned long fs_buffer_size; 21unsigned long oprofile_buffer_size;
22unsigned long fs_cpu_buffer_size; 22unsigned long oprofile_cpu_buffer_size;
23unsigned long fs_buffer_watershed; 23unsigned long oprofile_buffer_watershed;
24 24
25static ssize_t depth_read(struct file *file, char __user *buf, size_t count, loff_t *offset) 25static ssize_t depth_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
26{ 26{
27 return oprofilefs_ulong_to_user(backtrace_depth, buf, count, offset); 27 return oprofilefs_ulong_to_user(oprofile_backtrace_depth, buf, count,
28 offset);
28} 29}
29 30
30 31
@@ -125,16 +126,16 @@ static const struct file_operations dump_fops = {
125void oprofile_create_files(struct super_block *sb, struct dentry *root) 126void oprofile_create_files(struct super_block *sb, struct dentry *root)
126{ 127{
127 /* reinitialize default values */ 128 /* reinitialize default values */
128 fs_buffer_size = FS_BUFFER_SIZE_DEFAULT; 129 oprofile_buffer_size = BUFFER_SIZE_DEFAULT;
129 fs_cpu_buffer_size = FS_CPU_BUFFER_SIZE_DEFAULT; 130 oprofile_cpu_buffer_size = CPU_BUFFER_SIZE_DEFAULT;
130 fs_buffer_watershed = FS_BUFFER_WATERSHED_DEFAULT; 131 oprofile_buffer_watershed = BUFFER_WATERSHED_DEFAULT;
131 132
132 oprofilefs_create_file(sb, root, "enable", &enable_fops); 133 oprofilefs_create_file(sb, root, "enable", &enable_fops);
133 oprofilefs_create_file_perm(sb, root, "dump", &dump_fops, 0666); 134 oprofilefs_create_file_perm(sb, root, "dump", &dump_fops, 0666);
134 oprofilefs_create_file(sb, root, "buffer", &event_buffer_fops); 135 oprofilefs_create_file(sb, root, "buffer", &event_buffer_fops);
135 oprofilefs_create_ulong(sb, root, "buffer_size", &fs_buffer_size); 136 oprofilefs_create_ulong(sb, root, "buffer_size", &oprofile_buffer_size);
136 oprofilefs_create_ulong(sb, root, "buffer_watershed", &fs_buffer_watershed); 137 oprofilefs_create_ulong(sb, root, "buffer_watershed", &oprofile_buffer_watershed);
137 oprofilefs_create_ulong(sb, root, "cpu_buffer_size", &fs_cpu_buffer_size); 138 oprofilefs_create_ulong(sb, root, "cpu_buffer_size", &oprofile_cpu_buffer_size);
138 oprofilefs_create_file(sb, root, "cpu_type", &cpu_type_fops); 139 oprofilefs_create_file(sb, root, "cpu_type", &cpu_type_fops);
139 oprofilefs_create_file(sb, root, "backtrace_depth", &depth_fops); 140 oprofilefs_create_file(sb, root, "backtrace_depth", &depth_fops);
140 oprofilefs_create_file(sb, root, "pointer_size", &pointer_size_fops); 141 oprofilefs_create_file(sb, root, "pointer_size", &pointer_size_fops);
diff --git a/drivers/parisc/asp.c b/drivers/parisc/asp.c
index 821369135369..7931133526c4 100644
--- a/drivers/parisc/asp.c
+++ b/drivers/parisc/asp.c
@@ -71,8 +71,7 @@ static void asp_choose_irq(struct parisc_device *dev, void *ctrl)
71 */ 71 */
72#define ASP_INTERRUPT_ADDR 0xf0800000 72#define ASP_INTERRUPT_ADDR 0xf0800000
73 73
74int __init 74static int __init asp_init_chip(struct parisc_device *dev)
75asp_init_chip(struct parisc_device *dev)
76{ 75{
77 struct gsc_irq gsc_irq; 76 struct gsc_irq gsc_irq;
78 int ret; 77 int ret;
diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c
index dcc1e9958d2f..cd4dd7ed2c06 100644
--- a/drivers/parisc/ccio-dma.c
+++ b/drivers/parisc/ccio-dma.c
@@ -555,7 +555,7 @@ static u32 hint_lookup[] = {
555 * (Load Coherence Index) instruction. The 8 bits used for the virtual 555 * (Load Coherence Index) instruction. The 8 bits used for the virtual
556 * index are bits 12:19 of the value returned by LCI. 556 * index are bits 12:19 of the value returned by LCI.
557 */ 557 */
558void CCIO_INLINE 558static void CCIO_INLINE
559ccio_io_pdir_entry(u64 *pdir_ptr, space_t sid, unsigned long vba, 559ccio_io_pdir_entry(u64 *pdir_ptr, space_t sid, unsigned long vba,
560 unsigned long hints) 560 unsigned long hints)
561{ 561{
@@ -1578,8 +1578,6 @@ static int __init ccio_probe(struct parisc_device *dev)
1578 1578
1579 ioc_count++; 1579 ioc_count++;
1580 1580
1581 parisc_vmerge_boundary = IOVP_SIZE;
1582 parisc_vmerge_max_size = BITS_PER_LONG * IOVP_SIZE;
1583 parisc_has_iommu(); 1581 parisc_has_iommu();
1584 return 0; 1582 return 0;
1585} 1583}
diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index 3bc54b30c3a1..d539d9df88e7 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -287,7 +287,7 @@ DINO_PORT_OUT(b, 8, 3)
287DINO_PORT_OUT(w, 16, 2) 287DINO_PORT_OUT(w, 16, 2)
288DINO_PORT_OUT(l, 32, 0) 288DINO_PORT_OUT(l, 32, 0)
289 289
290struct pci_port_ops dino_port_ops = { 290static struct pci_port_ops dino_port_ops = {
291 .inb = dino_in8, 291 .inb = dino_in8,
292 .inw = dino_in16, 292 .inw = dino_in16,
293 .inl = dino_in32, 293 .inl = dino_in32,
@@ -547,7 +547,7 @@ dino_card_fixup(struct pci_dev *dev)
547 ** The additional "-1" adjusts for skewing the IRQ<->slot. 547 ** The additional "-1" adjusts for skewing the IRQ<->slot.
548 */ 548 */
549 dino_cfg_read(dev->bus, dev->devfn, PCI_INTERRUPT_PIN, 1, &irq_pin); 549 dino_cfg_read(dev->bus, dev->devfn, PCI_INTERRUPT_PIN, 1, &irq_pin);
550 dev->irq = (irq_pin + PCI_SLOT(dev->devfn) - 1) % 4 ; 550 dev->irq = pci_swizzle_interrupt_pin(dev, irq_pin) - 1;
551 551
552 /* Shouldn't really need to do this but it's in case someone tries 552 /* Shouldn't really need to do this but it's in case someone tries
553 ** to bypass PCI services and look at the card themselves. 553 ** to bypass PCI services and look at the card themselves.
@@ -672,7 +672,7 @@ dino_fixup_bus(struct pci_bus *bus)
672 672
673 dino_cfg_read(dev->bus, dev->devfn, 673 dino_cfg_read(dev->bus, dev->devfn,
674 PCI_INTERRUPT_PIN, 1, &irq_pin); 674 PCI_INTERRUPT_PIN, 1, &irq_pin);
675 irq_pin = (irq_pin + PCI_SLOT(dev->devfn) - 1) % 4 ; 675 irq_pin = pci_swizzle_interrupt_pin(dev, irq_pin) - 1;
676 printk(KERN_WARNING "Device %s has undefined IRQ, " 676 printk(KERN_WARNING "Device %s has undefined IRQ, "
677 "setting to %d\n", pci_name(dev), irq_pin); 677 "setting to %d\n", pci_name(dev), irq_pin);
678 dino_cfg_write(dev->bus, dev->devfn, 678 dino_cfg_write(dev->bus, dev->devfn,
@@ -690,7 +690,7 @@ dino_fixup_bus(struct pci_bus *bus)
690} 690}
691 691
692 692
693struct pci_bios_ops dino_bios_ops = { 693static struct pci_bios_ops dino_bios_ops = {
694 .init = dino_bios_init, 694 .init = dino_bios_init,
695 .fixup_bus = dino_fixup_bus 695 .fixup_bus = dino_fixup_bus
696}; 696};
diff --git a/drivers/parisc/hppb.c b/drivers/parisc/hppb.c
index 65eee67aa2ae..13856415b432 100644
--- a/drivers/parisc/hppb.c
+++ b/drivers/parisc/hppb.c
@@ -29,7 +29,7 @@ struct hppb_card {
29 struct hppb_card *next; 29 struct hppb_card *next;
30}; 30};
31 31
32struct hppb_card hppb_card_head = { 32static struct hppb_card hppb_card_head = {
33 .hpa = 0, 33 .hpa = 0,
34 .next = NULL, 34 .next = NULL,
35}; 35};
diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c
index 9dedbbd218c3..0797659ee016 100644
--- a/drivers/parisc/iosapic.c
+++ b/drivers/parisc/iosapic.c
@@ -519,8 +519,7 @@ iosapic_xlate_pin(struct iosapic_info *isi, struct pci_dev *pcidev)
519 ** 519 **
520 ** Advantage is it's really easy to implement. 520 ** Advantage is it's really easy to implement.
521 */ 521 */
522 intr_pin = ((intr_pin-1)+PCI_SLOT(pcidev->devfn)) % 4; 522 intr_pin = pci_swizzle_interrupt_pin(pcidev, intr_pin);
523 intr_pin++; /* convert back to INTA-D (1-4) */
524#endif /* PCI_BRIDGE_FUNCS */ 523#endif /* PCI_BRIDGE_FUNCS */
525 524
526 /* 525 /*
diff --git a/drivers/parisc/lasi.c b/drivers/parisc/lasi.c
index bee510098ce8..e65727ca9fc0 100644
--- a/drivers/parisc/lasi.c
+++ b/drivers/parisc/lasi.c
@@ -107,7 +107,7 @@ lasi_init_irq(struct gsc_asic *this_lasi)
107 107
108#else 108#else
109 109
110void __init lasi_led_init(unsigned long lasi_hpa) 110static void __init lasi_led_init(unsigned long lasi_hpa)
111{ 111{
112 unsigned long datareg; 112 unsigned long datareg;
113 113
@@ -163,8 +163,7 @@ static void lasi_power_off(void)
163 gsc_writel(0x02, datareg); 163 gsc_writel(0x02, datareg);
164} 164}
165 165
166int __init 166static int __init lasi_init_chip(struct parisc_device *dev)
167lasi_init_chip(struct parisc_device *dev)
168{ 167{
169 extern void (*chassis_power_off)(void); 168 extern void (*chassis_power_off)(void);
170 struct gsc_asic *lasi; 169 struct gsc_asic *lasi;
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index a28c8946deaa..d8233de8c75d 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -824,7 +824,7 @@ lba_fixup_bus(struct pci_bus *bus)
824} 824}
825 825
826 826
827struct pci_bios_ops lba_bios_ops = { 827static struct pci_bios_ops lba_bios_ops = {
828 .init = lba_bios_init, 828 .init = lba_bios_init,
829 .fixup_bus = lba_fixup_bus, 829 .fixup_bus = lba_fixup_bus,
830}; 830};
diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
index bc73b96346ff..3fac8f81d59d 100644
--- a/drivers/parisc/sba_iommu.c
+++ b/drivers/parisc/sba_iommu.c
@@ -561,7 +561,7 @@ typedef unsigned long space_t;
561 * IOMMU uses little endian for the pdir. 561 * IOMMU uses little endian for the pdir.
562 */ 562 */
563 563
564void SBA_INLINE 564static void SBA_INLINE
565sba_io_pdir_entry(u64 *pdir_ptr, space_t sid, unsigned long vba, 565sba_io_pdir_entry(u64 *pdir_ptr, space_t sid, unsigned long vba,
566 unsigned long hint) 566 unsigned long hint)
567{ 567{
@@ -1874,7 +1874,7 @@ static struct parisc_device_id sba_tbl[] = {
1874 { 0, } 1874 { 0, }
1875}; 1875};
1876 1876
1877int sba_driver_callback(struct parisc_device *); 1877static int sba_driver_callback(struct parisc_device *);
1878 1878
1879static struct parisc_driver sba_driver = { 1879static struct parisc_driver sba_driver = {
1880 .name = MODULE_NAME, 1880 .name = MODULE_NAME,
@@ -1887,8 +1887,7 @@ static struct parisc_driver sba_driver = {
1887** If so, initialize the chip and tell other partners in crime they 1887** If so, initialize the chip and tell other partners in crime they
1888** have work to do. 1888** have work to do.
1889*/ 1889*/
1890int 1890static int sba_driver_callback(struct parisc_device *dev)
1891sba_driver_callback(struct parisc_device *dev)
1892{ 1891{
1893 struct sba_device *sba_dev; 1892 struct sba_device *sba_dev;
1894 u32 func_class; 1893 u32 func_class;
@@ -1979,8 +1978,6 @@ sba_driver_callback(struct parisc_device *dev)
1979 proc_create("sba_iommu-bitmap", 0, root, &sba_proc_bitmap_fops); 1978 proc_create("sba_iommu-bitmap", 0, root, &sba_proc_bitmap_fops);
1980#endif 1979#endif
1981 1980
1982 parisc_vmerge_boundary = IOVP_SIZE;
1983 parisc_vmerge_max_size = IOVP_SIZE * BITS_PER_LONG;
1984 parisc_has_iommu(); 1981 parisc_has_iommu();
1985 return 0; 1982 return 0;
1986} 1983}
diff --git a/drivers/parisc/superio.c b/drivers/parisc/superio.c
index 1e93c837514f..4fa3bb2ddfe4 100644
--- a/drivers/parisc/superio.c
+++ b/drivers/parisc/superio.c
@@ -405,7 +405,6 @@ static void __init superio_serial_init(void)
405 serial_port.type = PORT_16550A; 405 serial_port.type = PORT_16550A;
406 serial_port.uartclk = 115200*16; 406 serial_port.uartclk = 115200*16;
407 serial_port.fifosize = 16; 407 serial_port.fifosize = 16;
408 spin_lock_init(&serial_port.lock);
409 408
410 /* serial port #1 */ 409 /* serial port #1 */
411 serial_port.iobase = sio_dev.sp1_base; 410 serial_port.iobase = sio_dev.sp1_base;
diff --git a/drivers/parisc/wax.c b/drivers/parisc/wax.c
index 892a83bbe73d..da9d5ad1353c 100644
--- a/drivers/parisc/wax.c
+++ b/drivers/parisc/wax.c
@@ -68,8 +68,7 @@ wax_init_irq(struct gsc_asic *wax)
68// gsc_writel(0xFFFFFFFF, base+0x2000); /* RS232-B on Wax */ 68// gsc_writel(0xFFFFFFFF, base+0x2000); /* RS232-B on Wax */
69} 69}
70 70
71int __init 71static int __init wax_init_chip(struct parisc_device *dev)
72wax_init_chip(struct parisc_device *dev)
73{ 72{
74 struct gsc_asic *wax; 73 struct gsc_asic *wax;
75 struct parisc_device *parent; 74 struct parisc_device *parent;
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
index e1ca42591ac4..2a4501dd2515 100644
--- a/drivers/pci/Kconfig
+++ b/drivers/pci/Kconfig
@@ -42,6 +42,15 @@ config PCI_DEBUG
42 42
43 When in doubt, say N. 43 When in doubt, say N.
44 44
45config PCI_STUB
46 tristate "PCI Stub driver"
47 depends on PCI
48 help
49 Say Y or M here if you want be able to reserve a PCI device
50 when it is going to be assigned to a guest operating system.
51
52 When in doubt, say N.
53
45config HT_IRQ 54config HT_IRQ
46 bool "Interrupts on hypertransport devices" 55 bool "Interrupts on hypertransport devices"
47 default y 56 default y
diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile
index af3bfe22847b..3d07ce24f6a8 100644
--- a/drivers/pci/Makefile
+++ b/drivers/pci/Makefile
@@ -53,6 +53,8 @@ obj-$(CONFIG_HOTPLUG) += setup-bus.o
53 53
54obj-$(CONFIG_PCI_SYSCALL) += syscall.o 54obj-$(CONFIG_PCI_SYSCALL) += syscall.o
55 55
56obj-$(CONFIG_PCI_STUB) += pci-stub.o
57
56ifeq ($(CONFIG_PCI_DEBUG),y) 58ifeq ($(CONFIG_PCI_DEBUG),y)
57EXTRA_CFLAGS += -DDEBUG 59EXTRA_CFLAGS += -DDEBUG
58endif 60endif
diff --git a/drivers/pci/access.c b/drivers/pci/access.c
index 39bb96b413ef..381444794778 100644
--- a/drivers/pci/access.c
+++ b/drivers/pci/access.c
@@ -66,6 +66,39 @@ EXPORT_SYMBOL(pci_bus_write_config_byte);
66EXPORT_SYMBOL(pci_bus_write_config_word); 66EXPORT_SYMBOL(pci_bus_write_config_word);
67EXPORT_SYMBOL(pci_bus_write_config_dword); 67EXPORT_SYMBOL(pci_bus_write_config_dword);
68 68
69
70/**
71 * pci_read_vpd - Read one entry from Vital Product Data
72 * @dev: pci device struct
73 * @pos: offset in vpd space
74 * @count: number of bytes to read
75 * @buf: pointer to where to store result
76 *
77 */
78ssize_t pci_read_vpd(struct pci_dev *dev, loff_t pos, size_t count, void *buf)
79{
80 if (!dev->vpd || !dev->vpd->ops)
81 return -ENODEV;
82 return dev->vpd->ops->read(dev, pos, count, buf);
83}
84EXPORT_SYMBOL(pci_read_vpd);
85
86/**
87 * pci_write_vpd - Write entry to Vital Product Data
88 * @dev: pci device struct
89 * @pos: offset in vpd space
90 * @count: number of bytes to read
91 * @val: value to write
92 *
93 */
94ssize_t pci_write_vpd(struct pci_dev *dev, loff_t pos, size_t count, const void *buf)
95{
96 if (!dev->vpd || !dev->vpd->ops)
97 return -ENODEV;
98 return dev->vpd->ops->write(dev, pos, count, buf);
99}
100EXPORT_SYMBOL(pci_write_vpd);
101
69/* 102/*
70 * The following routines are to prevent the user from accessing PCI config 103 * The following routines are to prevent the user from accessing PCI config
71 * space when it's unsafe to do so. Some devices require this during BIST and 104 * space when it's unsafe to do so. Some devices require this during BIST and
@@ -133,125 +166,145 @@ PCI_USER_WRITE_CONFIG(dword, u32)
133 166
134struct pci_vpd_pci22 { 167struct pci_vpd_pci22 {
135 struct pci_vpd base; 168 struct pci_vpd base;
136 spinlock_t lock; /* controls access to hardware and the flags */ 169 struct mutex lock;
137 u8 cap; 170 u16 flag;
138 bool busy; 171 bool busy;
139 bool flag; /* value of F bit to wait for */ 172 u8 cap;
140}; 173};
141 174
142/* Wait for last operation to complete */ 175/*
176 * Wait for last operation to complete.
177 * This code has to spin since there is no other notification from the PCI
178 * hardware. Since the VPD is often implemented by serial attachment to an
179 * EEPROM, it may take many milliseconds to complete.
180 */
143static int pci_vpd_pci22_wait(struct pci_dev *dev) 181static int pci_vpd_pci22_wait(struct pci_dev *dev)
144{ 182{
145 struct pci_vpd_pci22 *vpd = 183 struct pci_vpd_pci22 *vpd =
146 container_of(dev->vpd, struct pci_vpd_pci22, base); 184 container_of(dev->vpd, struct pci_vpd_pci22, base);
147 u16 flag, status; 185 unsigned long timeout = jiffies + HZ/20 + 2;
148 int wait; 186 u16 status;
149 int ret; 187 int ret;
150 188
151 if (!vpd->busy) 189 if (!vpd->busy)
152 return 0; 190 return 0;
153 191
154 flag = vpd->flag ? PCI_VPD_ADDR_F : 0;
155 wait = vpd->flag ? 10 : 1000; /* read: 100 us; write: 10 ms */
156 for (;;) { 192 for (;;) {
157 ret = pci_user_read_config_word(dev, 193 ret = pci_user_read_config_word(dev, vpd->cap + PCI_VPD_ADDR,
158 vpd->cap + PCI_VPD_ADDR,
159 &status); 194 &status);
160 if (ret < 0) 195 if (ret)
161 return ret; 196 return ret;
162 if ((status & PCI_VPD_ADDR_F) == flag) { 197
198 if ((status & PCI_VPD_ADDR_F) == vpd->flag) {
163 vpd->busy = false; 199 vpd->busy = false;
164 return 0; 200 return 0;
165 } 201 }
166 if (wait-- == 0) 202
203 if (time_after(jiffies, timeout))
167 return -ETIMEDOUT; 204 return -ETIMEDOUT;
168 udelay(10); 205 if (fatal_signal_pending(current))
206 return -EINTR;
207 if (!cond_resched())
208 udelay(10);
169 } 209 }
170} 210}
171 211
172static int pci_vpd_pci22_read(struct pci_dev *dev, int pos, int size, 212static ssize_t pci_vpd_pci22_read(struct pci_dev *dev, loff_t pos, size_t count,
173 char *buf) 213 void *arg)
174{ 214{
175 struct pci_vpd_pci22 *vpd = 215 struct pci_vpd_pci22 *vpd =
176 container_of(dev->vpd, struct pci_vpd_pci22, base); 216 container_of(dev->vpd, struct pci_vpd_pci22, base);
177 u32 val;
178 int ret; 217 int ret;
179 int begin, end, i; 218 loff_t end = pos + count;
219 u8 *buf = arg;
180 220
181 if (pos < 0 || pos > vpd->base.len || size > vpd->base.len - pos) 221 if (pos < 0 || pos > vpd->base.len || end > vpd->base.len)
182 return -EINVAL; 222 return -EINVAL;
183 if (size == 0)
184 return 0;
185 223
186 spin_lock_irq(&vpd->lock); 224 if (mutex_lock_killable(&vpd->lock))
187 ret = pci_vpd_pci22_wait(dev); 225 return -EINTR;
188 if (ret < 0) 226
189 goto out;
190 ret = pci_user_write_config_word(dev, vpd->cap + PCI_VPD_ADDR,
191 pos & ~3);
192 if (ret < 0)
193 goto out;
194 vpd->busy = true;
195 vpd->flag = 1;
196 ret = pci_vpd_pci22_wait(dev); 227 ret = pci_vpd_pci22_wait(dev);
197 if (ret < 0) 228 if (ret < 0)
198 goto out; 229 goto out;
199 ret = pci_user_read_config_dword(dev, vpd->cap + PCI_VPD_DATA, 230
200 &val); 231 while (pos < end) {
201out: 232 u32 val;
202 spin_unlock_irq(&vpd->lock); 233 unsigned int i, skip;
203 if (ret < 0) 234
204 return ret; 235 ret = pci_user_write_config_word(dev, vpd->cap + PCI_VPD_ADDR,
205 236 pos & ~3);
206 /* Convert to bytes */ 237 if (ret < 0)
207 begin = pos & 3; 238 break;
208 end = min(4, begin + size); 239 vpd->busy = true;
209 for (i = 0; i < end; ++i) { 240 vpd->flag = PCI_VPD_ADDR_F;
210 if (i >= begin) 241 ret = pci_vpd_pci22_wait(dev);
211 *buf++ = val; 242 if (ret < 0)
212 val >>= 8; 243 break;
244
245 ret = pci_user_read_config_dword(dev, vpd->cap + PCI_VPD_DATA, &val);
246 if (ret < 0)
247 break;
248
249 skip = pos & 3;
250 for (i = 0; i < sizeof(u32); i++) {
251 if (i >= skip) {
252 *buf++ = val;
253 if (++pos == end)
254 break;
255 }
256 val >>= 8;
257 }
213 } 258 }
214 return end - begin; 259out:
260 mutex_unlock(&vpd->lock);
261 return ret ? ret : count;
215} 262}
216 263
217static int pci_vpd_pci22_write(struct pci_dev *dev, int pos, int size, 264static ssize_t pci_vpd_pci22_write(struct pci_dev *dev, loff_t pos, size_t count,
218 const char *buf) 265 const void *arg)
219{ 266{
220 struct pci_vpd_pci22 *vpd = 267 struct pci_vpd_pci22 *vpd =
221 container_of(dev->vpd, struct pci_vpd_pci22, base); 268 container_of(dev->vpd, struct pci_vpd_pci22, base);
222 u32 val; 269 const u8 *buf = arg;
223 int ret; 270 loff_t end = pos + count;
271 int ret = 0;
224 272
225 if (pos < 0 || pos > vpd->base.len || pos & 3 || 273 if (pos < 0 || (pos & 3) || (count & 3) || end > vpd->base.len)
226 size > vpd->base.len - pos || size < 4)
227 return -EINVAL; 274 return -EINVAL;
228 275
229 val = (u8) *buf++; 276 if (mutex_lock_killable(&vpd->lock))
230 val |= ((u8) *buf++) << 8; 277 return -EINTR;
231 val |= ((u8) *buf++) << 16;
232 val |= ((u32)(u8) *buf++) << 24;
233 278
234 spin_lock_irq(&vpd->lock);
235 ret = pci_vpd_pci22_wait(dev); 279 ret = pci_vpd_pci22_wait(dev);
236 if (ret < 0) 280 if (ret < 0)
237 goto out; 281 goto out;
238 ret = pci_user_write_config_dword(dev, vpd->cap + PCI_VPD_DATA,
239 val);
240 if (ret < 0)
241 goto out;
242 ret = pci_user_write_config_word(dev, vpd->cap + PCI_VPD_ADDR,
243 pos | PCI_VPD_ADDR_F);
244 if (ret < 0)
245 goto out;
246 vpd->busy = true;
247 vpd->flag = 0;
248 ret = pci_vpd_pci22_wait(dev);
249out:
250 spin_unlock_irq(&vpd->lock);
251 if (ret < 0)
252 return ret;
253 282
254 return 4; 283 while (pos < end) {
284 u32 val;
285
286 val = *buf++;
287 val |= *buf++ << 8;
288 val |= *buf++ << 16;
289 val |= *buf++ << 24;
290
291 ret = pci_user_write_config_dword(dev, vpd->cap + PCI_VPD_DATA, val);
292 if (ret < 0)
293 break;
294 ret = pci_user_write_config_word(dev, vpd->cap + PCI_VPD_ADDR,
295 pos | PCI_VPD_ADDR_F);
296 if (ret < 0)
297 break;
298
299 vpd->busy = true;
300 vpd->flag = 0;
301 ret = pci_vpd_pci22_wait(dev);
302
303 pos += sizeof(u32);
304 }
305out:
306 mutex_unlock(&vpd->lock);
307 return ret ? ret : count;
255} 308}
256 309
257static void pci_vpd_pci22_release(struct pci_dev *dev) 310static void pci_vpd_pci22_release(struct pci_dev *dev)
@@ -259,7 +312,7 @@ static void pci_vpd_pci22_release(struct pci_dev *dev)
259 kfree(container_of(dev->vpd, struct pci_vpd_pci22, base)); 312 kfree(container_of(dev->vpd, struct pci_vpd_pci22, base));
260} 313}
261 314
262static struct pci_vpd_ops pci_vpd_pci22_ops = { 315static const struct pci_vpd_ops pci_vpd_pci22_ops = {
263 .read = pci_vpd_pci22_read, 316 .read = pci_vpd_pci22_read,
264 .write = pci_vpd_pci22_write, 317 .write = pci_vpd_pci22_write,
265 .release = pci_vpd_pci22_release, 318 .release = pci_vpd_pci22_release,
@@ -279,7 +332,7 @@ int pci_vpd_pci22_init(struct pci_dev *dev)
279 332
280 vpd->base.len = PCI_VPD_PCI22_SIZE; 333 vpd->base.len = PCI_VPD_PCI22_SIZE;
281 vpd->base.ops = &pci_vpd_pci22_ops; 334 vpd->base.ops = &pci_vpd_pci22_ops;
282 spin_lock_init(&vpd->lock); 335 mutex_init(&vpd->lock);
283 vpd->cap = cap; 336 vpd->cap = cap;
284 vpd->busy = false; 337 vpd->busy = false;
285 dev->vpd = &vpd->base; 338 dev->vpd = &vpd->base;
@@ -287,6 +340,29 @@ int pci_vpd_pci22_init(struct pci_dev *dev)
287} 340}
288 341
289/** 342/**
343 * pci_vpd_truncate - Set available Vital Product Data size
344 * @dev: pci device struct
345 * @size: available memory in bytes
346 *
347 * Adjust size of available VPD area.
348 */
349int pci_vpd_truncate(struct pci_dev *dev, size_t size)
350{
351 if (!dev->vpd)
352 return -EINVAL;
353
354 /* limited by the access method */
355 if (size > dev->vpd->len)
356 return -EINVAL;
357
358 dev->vpd->len = size;
359 dev->vpd->attr->size = size;
360
361 return 0;
362}
363EXPORT_SYMBOL(pci_vpd_truncate);
364
365/**
290 * pci_block_user_cfg_access - Block userspace PCI config reads/writes 366 * pci_block_user_cfg_access - Block userspace PCI config reads/writes
291 * @dev: pci device struct 367 * @dev: pci device struct
292 * 368 *
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 999cc4088b59..52b54f053be0 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -71,7 +71,7 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
71} 71}
72 72
73/** 73/**
74 * add a single device 74 * pci_bus_add_device - add a single device
75 * @dev: device to add 75 * @dev: device to add
76 * 76 *
77 * This adds a single pci device to the global 77 * This adds a single pci device to the global
@@ -91,6 +91,37 @@ int pci_bus_add_device(struct pci_dev *dev)
91} 91}
92 92
93/** 93/**
94 * pci_bus_add_child - add a child bus
95 * @bus: bus to add
96 *
97 * This adds sysfs entries for a single bus
98 */
99int pci_bus_add_child(struct pci_bus *bus)
100{
101 int retval;
102
103 if (bus->bridge)
104 bus->dev.parent = bus->bridge;
105
106 retval = device_register(&bus->dev);
107 if (retval)
108 return retval;
109
110 bus->is_added = 1;
111
112 retval = device_create_file(&bus->dev, &dev_attr_cpuaffinity);
113 if (retval)
114 return retval;
115
116 retval = device_create_file(&bus->dev, &dev_attr_cpulistaffinity);
117
118 /* Create legacy_io and legacy_mem files for this bus */
119 pci_create_legacy_files(bus);
120
121 return retval;
122}
123
124/**
94 * pci_bus_add_devices - insert newly discovered PCI devices 125 * pci_bus_add_devices - insert newly discovered PCI devices
95 * @bus: bus to check for new devices 126 * @bus: bus to check for new devices
96 * 127 *
@@ -105,7 +136,7 @@ int pci_bus_add_device(struct pci_dev *dev)
105void pci_bus_add_devices(struct pci_bus *bus) 136void pci_bus_add_devices(struct pci_bus *bus)
106{ 137{
107 struct pci_dev *dev; 138 struct pci_dev *dev;
108 struct pci_bus *child_bus; 139 struct pci_bus *child;
109 int retval; 140 int retval;
110 141
111 list_for_each_entry(dev, &bus->devices, bus_list) { 142 list_for_each_entry(dev, &bus->devices, bus_list) {
@@ -120,45 +151,29 @@ void pci_bus_add_devices(struct pci_bus *bus)
120 list_for_each_entry(dev, &bus->devices, bus_list) { 151 list_for_each_entry(dev, &bus->devices, bus_list) {
121 BUG_ON(!dev->is_added); 152 BUG_ON(!dev->is_added);
122 153
154 child = dev->subordinate;
123 /* 155 /*
124 * If there is an unattached subordinate bus, attach 156 * If there is an unattached subordinate bus, attach
125 * it and then scan for unattached PCI devices. 157 * it and then scan for unattached PCI devices.
126 */ 158 */
127 if (dev->subordinate) { 159 if (!child)
128 if (list_empty(&dev->subordinate->node)) { 160 continue;
129 down_write(&pci_bus_sem); 161 if (list_empty(&child->node)) {
130 list_add_tail(&dev->subordinate->node, 162 down_write(&pci_bus_sem);
131 &dev->bus->children); 163 list_add_tail(&child->node, &dev->bus->children);
132 up_write(&pci_bus_sem); 164 up_write(&pci_bus_sem);
133 }
134 pci_bus_add_devices(dev->subordinate);
135
136 /* register the bus with sysfs as the parent is now
137 * properly registered. */
138 child_bus = dev->subordinate;
139 if (child_bus->is_added)
140 continue;
141 child_bus->dev.parent = child_bus->bridge;
142 retval = device_register(&child_bus->dev);
143 if (retval)
144 dev_err(&dev->dev, "Error registering pci_bus,"
145 " continuing...\n");
146 else {
147 child_bus->is_added = 1;
148 retval = device_create_file(&child_bus->dev,
149 &dev_attr_cpuaffinity);
150 }
151 if (retval)
152 dev_err(&dev->dev, "Error creating cpuaffinity"
153 " file, continuing...\n");
154
155 retval = device_create_file(&child_bus->dev,
156 &dev_attr_cpulistaffinity);
157 if (retval)
158 dev_err(&dev->dev,
159 "Error creating cpulistaffinity"
160 " file, continuing...\n");
161 } 165 }
166 pci_bus_add_devices(child);
167
168 /*
169 * register the bus with sysfs as the parent is now
170 * properly registered.
171 */
172 if (child->is_added)
173 continue;
174 retval = pci_bus_add_child(child);
175 if (retval)
176 dev_err(&dev->dev, "Error adding bus, continuing\n");
162 } 177 }
163} 178}
164 179
diff --git a/drivers/pci/hotplug/Makefile b/drivers/pci/hotplug/Makefile
index 9bdbe1a6688f..e31fb91652ce 100644
--- a/drivers/pci/hotplug/Makefile
+++ b/drivers/pci/hotplug/Makefile
@@ -55,6 +55,9 @@ pciehp-objs := pciehp_core.o \
55 pciehp_ctrl.o \ 55 pciehp_ctrl.o \
56 pciehp_pci.o \ 56 pciehp_pci.o \
57 pciehp_hpc.o 57 pciehp_hpc.o
58ifdef CONFIG_ACPI
59pciehp-objs += pciehp_acpi.o
60endif
58 61
59shpchp-objs := shpchp_core.o \ 62shpchp-objs := shpchp_core.o \
60 shpchp_ctrl.o \ 63 shpchp_ctrl.o \
diff --git a/drivers/pci/hotplug/acpi_pcihp.c b/drivers/pci/hotplug/acpi_pcihp.c
index e17ef54f0efc..1c1141801060 100644
--- a/drivers/pci/hotplug/acpi_pcihp.c
+++ b/drivers/pci/hotplug/acpi_pcihp.c
@@ -33,7 +33,6 @@
33#include <linux/pci-acpi.h> 33#include <linux/pci-acpi.h>
34#include <acpi/acpi.h> 34#include <acpi/acpi.h>
35#include <acpi/acpi_bus.h> 35#include <acpi/acpi_bus.h>
36#include <acpi/actypes.h>
37 36
38#define MY_NAME "acpi_pcihp" 37#define MY_NAME "acpi_pcihp"
39 38
@@ -501,5 +500,74 @@ int acpi_root_bridge(acpi_handle handle)
501} 500}
502EXPORT_SYMBOL_GPL(acpi_root_bridge); 501EXPORT_SYMBOL_GPL(acpi_root_bridge);
503 502
503
504static int is_ejectable(acpi_handle handle)
505{
506 acpi_status status;
507 acpi_handle tmp;
508 unsigned long long removable;
509 status = acpi_get_handle(handle, "_ADR", &tmp);
510 if (ACPI_FAILURE(status))
511 return 0;
512 status = acpi_get_handle(handle, "_EJ0", &tmp);
513 if (ACPI_SUCCESS(status))
514 return 1;
515 status = acpi_evaluate_integer(handle, "_RMV", NULL, &removable);
516 if (ACPI_SUCCESS(status) && removable)
517 return 1;
518 return 0;
519}
520
521/**
522 * acpi_pcihp_check_ejectable - check if handle is ejectable ACPI PCI slot
523 * @pbus: the PCI bus of the PCI slot corresponding to 'handle'
524 * @handle: ACPI handle to check
525 *
526 * Return 1 if handle is ejectable PCI slot, 0 otherwise.
527 */
528int acpi_pci_check_ejectable(struct pci_bus *pbus, acpi_handle handle)
529{
530 acpi_handle bridge_handle, parent_handle;
531
532 if (!(bridge_handle = acpi_pci_get_bridge_handle(pbus)))
533 return 0;
534 if ((ACPI_FAILURE(acpi_get_parent(handle, &parent_handle))))
535 return 0;
536 if (bridge_handle != parent_handle)
537 return 0;
538 return is_ejectable(handle);
539}
540EXPORT_SYMBOL_GPL(acpi_pci_check_ejectable);
541
542static acpi_status
543check_hotplug(acpi_handle handle, u32 lvl, void *context, void **rv)
544{
545 int *found = (int *)context;
546 if (is_ejectable(handle)) {
547 *found = 1;
548 return AE_CTRL_TERMINATE;
549 }
550 return AE_OK;
551}
552
553/**
554 * acpi_pci_detect_ejectable - check if the PCI bus has ejectable slots
555 * @pbus - PCI bus to scan
556 *
557 * Returns 1 if the PCI bus has ACPI based ejectable slots, 0 otherwise.
558 */
559int acpi_pci_detect_ejectable(struct pci_bus *pbus)
560{
561 acpi_handle handle;
562 int found = 0;
563
564 if (!(handle = acpi_pci_get_bridge_handle(pbus)))
565 return 0;
566 acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1,
567 check_hotplug, (void *)&found, NULL);
568 return found;
569}
570EXPORT_SYMBOL_GPL(acpi_pci_detect_ejectable);
571
504module_param(debug_acpi, bool, 0644); 572module_param(debug_acpi, bool, 0644);
505MODULE_PARM_DESC(debug_acpi, "Debugging mode for ACPI enabled or not"); 573MODULE_PARM_DESC(debug_acpi, "Debugging mode for ACPI enabled or not");
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index 9bcb6cbd5aa9..4fc168b70095 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -44,7 +44,7 @@
44 do { \ 44 do { \
45 if (acpiphp_debug) \ 45 if (acpiphp_debug) \
46 printk(KERN_DEBUG "%s: " format, \ 46 printk(KERN_DEBUG "%s: " format, \
47 MY_NAME , ## arg); \ 47 MY_NAME , ## arg); \
48 } while (0) 48 } while (0)
49#define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME , ## arg) 49#define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME , ## arg)
50#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) 50#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 3affc6472e65..803d9ddd6e75 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -46,6 +46,7 @@
46#include <linux/kernel.h> 46#include <linux/kernel.h>
47#include <linux/pci.h> 47#include <linux/pci.h>
48#include <linux/pci_hotplug.h> 48#include <linux/pci_hotplug.h>
49#include <linux/pci-acpi.h>
49#include <linux/mutex.h> 50#include <linux/mutex.h>
50 51
51#include "../pci.h" 52#include "../pci.h"
@@ -62,61 +63,6 @@ static void acpiphp_sanitize_bus(struct pci_bus *bus);
62static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus); 63static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus);
63static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context); 64static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context);
64 65
65
66/*
67 * initialization & terminatation routines
68 */
69
70/**
71 * is_ejectable - determine if a slot is ejectable
72 * @handle: handle to acpi namespace
73 *
74 * Ejectable slot should satisfy at least these conditions:
75 *
76 * 1. has _ADR method
77 * 2. has _EJ0 method
78 *
79 * optionally
80 *
81 * 1. has _STA method
82 * 2. has _PS0 method
83 * 3. has _PS3 method
84 * 4. ..
85 */
86static int is_ejectable(acpi_handle handle)
87{
88 acpi_status status;
89 acpi_handle tmp;
90
91 status = acpi_get_handle(handle, "_ADR", &tmp);
92 if (ACPI_FAILURE(status)) {
93 return 0;
94 }
95
96 status = acpi_get_handle(handle, "_EJ0", &tmp);
97 if (ACPI_FAILURE(status)) {
98 return 0;
99 }
100
101 return 1;
102}
103
104
105/* callback routine to check for the existence of ejectable slots */
106static acpi_status
107is_ejectable_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
108{
109 int *count = (int *)context;
110
111 if (is_ejectable(handle)) {
112 (*count)++;
113 /* only one ejectable slot is enough */
114 return AE_CTRL_TERMINATE;
115 } else {
116 return AE_OK;
117 }
118}
119
120/* callback routine to check for the existence of a pci dock device */ 66/* callback routine to check for the existence of a pci dock device */
121static acpi_status 67static acpi_status
122is_pci_dock_device(acpi_handle handle, u32 lvl, void *context, void **rv) 68is_pci_dock_device(acpi_handle handle, u32 lvl, void *context, void **rv)
@@ -131,9 +77,6 @@ is_pci_dock_device(acpi_handle handle, u32 lvl, void *context, void **rv)
131 } 77 }
132} 78}
133 79
134
135
136
137/* 80/*
138 * the _DCK method can do funny things... and sometimes not 81 * the _DCK method can do funny things... and sometimes not
139 * hah-hah funny. 82 * hah-hah funny.
@@ -160,9 +103,9 @@ static int post_dock_fixups(struct notifier_block *nb, unsigned long val,
160 103
161 if (((buses >> 8) & 0xff) != bus->secondary) { 104 if (((buses >> 8) & 0xff) != bus->secondary) {
162 buses = (buses & 0xff000000) 105 buses = (buses & 0xff000000)
163 | ((unsigned int)(bus->primary) << 0) 106 | ((unsigned int)(bus->primary) << 0)
164 | ((unsigned int)(bus->secondary) << 8) 107 | ((unsigned int)(bus->secondary) << 8)
165 | ((unsigned int)(bus->subordinate) << 16); 108 | ((unsigned int)(bus->subordinate) << 16);
166 pci_write_config_dword(bus->self, PCI_PRIMARY_BUS, buses); 109 pci_write_config_dword(bus->self, PCI_PRIMARY_BUS, buses);
167 } 110 }
168 return NOTIFY_OK; 111 return NOTIFY_OK;
@@ -184,17 +127,12 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
184 acpi_status status = AE_OK; 127 acpi_status status = AE_OK;
185 unsigned long long adr, sun; 128 unsigned long long adr, sun;
186 int device, function, retval; 129 int device, function, retval;
130 struct pci_bus *pbus = bridge->pci_bus;
187 131
188 status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr); 132 if (!acpi_pci_check_ejectable(pbus, handle) && !is_dock_device(handle))
189
190 if (ACPI_FAILURE(status))
191 return AE_OK;
192
193 status = acpi_get_handle(handle, "_EJ0", &tmp);
194
195 if (ACPI_FAILURE(status) && !(is_dock_device(handle)))
196 return AE_OK; 133 return AE_OK;
197 134
135 acpi_evaluate_integer(handle, "_ADR", NULL, &adr);
198 device = (adr >> 16) & 0xffff; 136 device = (adr >> 16) & 0xffff;
199 function = adr & 0xffff; 137 function = adr & 0xffff;
200 138
@@ -205,7 +143,8 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
205 INIT_LIST_HEAD(&newfunc->sibling); 143 INIT_LIST_HEAD(&newfunc->sibling);
206 newfunc->handle = handle; 144 newfunc->handle = handle;
207 newfunc->function = function; 145 newfunc->function = function;
208 if (ACPI_SUCCESS(status)) 146
147 if (ACPI_SUCCESS(acpi_get_handle(handle, "_EJ0", &tmp)))
209 newfunc->flags = FUNC_HAS_EJ0; 148 newfunc->flags = FUNC_HAS_EJ0;
210 149
211 if (ACPI_SUCCESS(acpi_get_handle(handle, "_STA", &tmp))) 150 if (ACPI_SUCCESS(acpi_get_handle(handle, "_STA", &tmp)))
@@ -256,8 +195,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
256 bridge->nr_slots++; 195 bridge->nr_slots++;
257 196
258 dbg("found ACPI PCI Hotplug slot %llu at PCI %04x:%02x:%02x\n", 197 dbg("found ACPI PCI Hotplug slot %llu at PCI %04x:%02x:%02x\n",
259 slot->sun, pci_domain_nr(bridge->pci_bus), 198 slot->sun, pci_domain_nr(pbus), pbus->number, device);
260 bridge->pci_bus->number, slot->device);
261 retval = acpiphp_register_hotplug_slot(slot); 199 retval = acpiphp_register_hotplug_slot(slot);
262 if (retval) { 200 if (retval) {
263 if (retval == -EBUSY) 201 if (retval == -EBUSY)
@@ -274,8 +212,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
274 list_add_tail(&newfunc->sibling, &slot->funcs); 212 list_add_tail(&newfunc->sibling, &slot->funcs);
275 213
276 /* associate corresponding pci_dev */ 214 /* associate corresponding pci_dev */
277 newfunc->pci_dev = pci_get_slot(bridge->pci_bus, 215 newfunc->pci_dev = pci_get_slot(pbus, PCI_DEVFN(device, function));
278 PCI_DEVFN(device, function));
279 if (newfunc->pci_dev) { 216 if (newfunc->pci_dev) {
280 slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON); 217 slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON);
281 } 218 }
@@ -324,27 +261,17 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
324 261
325 262
326/* see if it's worth looking at this bridge */ 263/* see if it's worth looking at this bridge */
327static int detect_ejectable_slots(acpi_handle *bridge_handle) 264static int detect_ejectable_slots(struct pci_bus *pbus)
328{ 265{
329 acpi_status status; 266 int found = acpi_pci_detect_ejectable(pbus);
330 int count; 267 if (!found) {
331 268 acpi_handle bridge_handle = acpi_pci_get_bridge_handle(pbus);
332 count = 0; 269 if (!bridge_handle)
333 270 return 0;
334 /* only check slots defined directly below bridge object */ 271 acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle, (u32)1,
335 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle, (u32)1, 272 is_pci_dock_device, (void *)&found, NULL);
336 is_ejectable_slot, (void *)&count, NULL); 273 }
337 274 return found;
338 /*
339 * we also need to add this bridge if there is a dock bridge or
340 * other pci device on a dock station (removable)
341 */
342 if (!count)
343 status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle,
344 (u32)1, is_pci_dock_device, (void *)&count,
345 NULL);
346
347 return count;
348} 275}
349 276
350 277
@@ -554,7 +481,7 @@ find_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv)
554 goto out; 481 goto out;
555 482
556 /* check if this bridge has ejectable slots */ 483 /* check if this bridge has ejectable slots */
557 if ((detect_ejectable_slots(handle) > 0)) { 484 if ((detect_ejectable_slots(dev->subordinate) > 0)) {
558 dbg("found PCI-to-PCI bridge at PCI %s\n", pci_name(dev)); 485 dbg("found PCI-to-PCI bridge at PCI %s\n", pci_name(dev));
559 add_p2p_bridge(handle, dev); 486 add_p2p_bridge(handle, dev);
560 } 487 }
@@ -615,7 +542,7 @@ static int add_bridge(acpi_handle handle)
615 } 542 }
616 543
617 /* check if this bridge has ejectable slots */ 544 /* check if this bridge has ejectable slots */
618 if (detect_ejectable_slots(handle) > 0) { 545 if (detect_ejectable_slots(pci_bus) > 0) {
619 dbg("found PCI host-bus bridge with hot-pluggable slots\n"); 546 dbg("found PCI host-bus bridge with hot-pluggable slots\n");
620 add_host_bridge(handle, pci_bus); 547 add_host_bridge(handle, pci_bus);
621 } 548 }
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
index 881fdd2b7313..5befa7e379b7 100644
--- a/drivers/pci/hotplug/acpiphp_ibm.c
+++ b/drivers/pci/hotplug/acpiphp_ibm.c
@@ -271,7 +271,7 @@ static void ibm_handle_events(acpi_handle handle, u32 event, void *context)
271 dbg("%s: generationg bus event\n", __func__); 271 dbg("%s: generationg bus event\n", __func__);
272 acpi_bus_generate_proc_event(note->device, note->event, detail); 272 acpi_bus_generate_proc_event(note->device, note->event, detail);
273 acpi_bus_generate_netlink_event(note->device->pnp.device_class, 273 acpi_bus_generate_netlink_event(note->device->pnp.device_class,
274 note->device->dev.bus_id, 274 dev_name(&note->device->dev),
275 note->event, detail); 275 note->event, detail);
276 } else 276 } else
277 note->event = event; 277 note->event = event;
diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c
index a60a25290995..cc227a8c4b11 100644
--- a/drivers/pci/hotplug/cpqphp_ctrl.c
+++ b/drivers/pci/hotplug/cpqphp_ctrl.c
@@ -1954,7 +1954,7 @@ void cpqhp_pushbutton_thread(unsigned long slot)
1954 return ; 1954 return ;
1955 } 1955 }
1956 1956
1957 if (func != NULL && ctrl != NULL) { 1957 if (ctrl != NULL) {
1958 if (cpqhp_process_SI(ctrl, func) != 0) { 1958 if (cpqhp_process_SI(ctrl, func) != 0) {
1959 amber_LED_on(ctrl, hp_slot); 1959 amber_LED_on(ctrl, hp_slot);
1960 green_LED_off(ctrl, hp_slot); 1960 green_LED_off(ctrl, hp_slot);
@@ -2604,7 +2604,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2604 for (cloop = 0; cloop < 4; cloop++) { 2604 for (cloop = 0; cloop < 4; cloop++) {
2605 if (irqs.valid_INT & (0x01 << cloop)) { 2605 if (irqs.valid_INT & (0x01 << cloop)) {
2606 rc = cpqhp_set_irq(func->bus, func->device, 2606 rc = cpqhp_set_irq(func->bus, func->device,
2607 0x0A + cloop, irqs.interrupt[cloop]); 2607 cloop + 1, irqs.interrupt[cloop]);
2608 if (rc) 2608 if (rc)
2609 goto free_and_out; 2609 goto free_and_out;
2610 } 2610 }
@@ -2945,7 +2945,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
2945 } 2945 }
2946 2946
2947 if (!behind_bridge) { 2947 if (!behind_bridge) {
2948 rc = cpqhp_set_irq(func->bus, func->device, temp_byte + 0x09, IRQ); 2948 rc = cpqhp_set_irq(func->bus, func->device, temp_byte, IRQ);
2949 if (rc) 2949 if (rc)
2950 return 1; 2950 return 1;
2951 } else { 2951 } else {
diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_pci.c
index df146be9d2e9..6c0ed0fcb8ee 100644
--- a/drivers/pci/hotplug/cpqphp_pci.c
+++ b/drivers/pci/hotplug/cpqphp_pci.c
@@ -171,7 +171,7 @@ int cpqhp_set_irq (u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num)
171 fakebus->number = bus_num; 171 fakebus->number = bus_num;
172 dbg("%s: dev %d, bus %d, pin %d, num %d\n", 172 dbg("%s: dev %d, bus %d, pin %d, num %d\n",
173 __func__, dev_num, bus_num, int_pin, irq_num); 173 __func__, dev_num, bus_num, int_pin, irq_num);
174 rc = pcibios_set_irq_routing(fakedev, int_pin - 0x0a, irq_num); 174 rc = pcibios_set_irq_routing(fakedev, int_pin - 1, irq_num);
175 kfree(fakedev); 175 kfree(fakedev);
176 kfree(fakebus); 176 kfree(fakebus);
177 dbg("%s: rc %d\n", __func__, rc); 177 dbg("%s: rc %d\n", __func__, rc);
diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c
index 3a2637a00934..b0e7de9e536d 100644
--- a/drivers/pci/hotplug/fakephp.c
+++ b/drivers/pci/hotplug/fakephp.c
@@ -324,6 +324,7 @@ static int disable_slot(struct hotplug_slot *slot)
324 324
325 if (test_and_set_bit(0, &dslot->removed)) { 325 if (test_and_set_bit(0, &dslot->removed)) {
326 dbg("Slot already scheduled for removal\n"); 326 dbg("Slot already scheduled for removal\n");
327 pci_dev_put(dev);
327 return -ENODEV; 328 return -ENODEV;
328 } 329 }
329 330
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index b2801a7ee37f..db85284ffb62 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -217,14 +217,25 @@ struct hpc_ops {
217#ifdef CONFIG_ACPI 217#ifdef CONFIG_ACPI
218#include <acpi/acpi.h> 218#include <acpi/acpi.h>
219#include <acpi/acpi_bus.h> 219#include <acpi/acpi_bus.h>
220#include <acpi/actypes.h>
221#include <linux/pci-acpi.h> 220#include <linux/pci-acpi.h>
222 221
222extern void __init pciehp_acpi_slot_detection_init(void);
223extern int pciehp_acpi_slot_detection_check(struct pci_dev *dev);
224
225static inline void pciehp_firmware_init(void)
226{
227 pciehp_acpi_slot_detection_init();
228}
229
223static inline int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev) 230static inline int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev)
224{ 231{
232 int retval;
225 u32 flags = (OSC_PCI_EXPRESS_NATIVE_HP_CONTROL | 233 u32 flags = (OSC_PCI_EXPRESS_NATIVE_HP_CONTROL |
226 OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL); 234 OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
227 return acpi_get_hp_hw_control_from_firmware(dev, flags); 235 retval = acpi_get_hp_hw_control_from_firmware(dev, flags);
236 if (retval)
237 return retval;
238 return pciehp_acpi_slot_detection_check(dev);
228} 239}
229 240
230static inline int pciehp_get_hp_params_from_firmware(struct pci_dev *dev, 241static inline int pciehp_get_hp_params_from_firmware(struct pci_dev *dev,
@@ -235,6 +246,7 @@ static inline int pciehp_get_hp_params_from_firmware(struct pci_dev *dev,
235 return 0; 246 return 0;
236} 247}
237#else 248#else
249#define pciehp_firmware_init() do {} while (0)
238#define pciehp_get_hp_hw_control_from_firmware(dev) 0 250#define pciehp_get_hp_hw_control_from_firmware(dev) 0
239#define pciehp_get_hp_params_from_firmware(dev, hpp) (-ENODEV) 251#define pciehp_get_hp_params_from_firmware(dev, hpp) (-ENODEV)
240#endif /* CONFIG_ACPI */ 252#endif /* CONFIG_ACPI */
diff --git a/drivers/pci/hotplug/pciehp_acpi.c b/drivers/pci/hotplug/pciehp_acpi.c
new file mode 100644
index 000000000000..438d795f9fe3
--- /dev/null
+++ b/drivers/pci/hotplug/pciehp_acpi.c
@@ -0,0 +1,141 @@
1/*
2 * ACPI related functions for PCI Express Hot Plug driver.
3 *
4 * Copyright (C) 2008 Kenji Kaneshige
5 * Copyright (C) 2008 Fujitsu Limited.
6 *
7 * All rights reserved.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or (at
12 * your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
17 * NON INFRINGEMENT. See the GNU General Public License for more
18 * details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 */
25
26#include <linux/acpi.h>
27#include <linux/pci.h>
28#include <linux/pci_hotplug.h>
29#include "pciehp.h"
30
31#define PCIEHP_DETECT_PCIE (0)
32#define PCIEHP_DETECT_ACPI (1)
33#define PCIEHP_DETECT_AUTO (2)
34#define PCIEHP_DETECT_DEFAULT PCIEHP_DETECT_AUTO
35
36static int slot_detection_mode;
37static char *pciehp_detect_mode;
38module_param(pciehp_detect_mode, charp, 0444);
39MODULE_PARM_DESC(pciehp_detect_mode,
40 "Slot detection mode: pcie, acpi, auto\n"
41 " pcie - Use PCIe based slot detection\n"
42 " acpi - Use ACPI for slot detection\n"
43 " auto(default) - Auto select mode. Use acpi option if duplicate\n"
44 " slot ids are found. Otherwise, use pcie option\n");
45
46int pciehp_acpi_slot_detection_check(struct pci_dev *dev)
47{
48 if (slot_detection_mode != PCIEHP_DETECT_ACPI)
49 return 0;
50 if (acpi_pci_detect_ejectable(dev->subordinate))
51 return 0;
52 return -ENODEV;
53}
54
55static int __init parse_detect_mode(void)
56{
57 if (!pciehp_detect_mode)
58 return PCIEHP_DETECT_DEFAULT;
59 if (!strcmp(pciehp_detect_mode, "pcie"))
60 return PCIEHP_DETECT_PCIE;
61 if (!strcmp(pciehp_detect_mode, "acpi"))
62 return PCIEHP_DETECT_ACPI;
63 if (!strcmp(pciehp_detect_mode, "auto"))
64 return PCIEHP_DETECT_AUTO;
65 warn("bad specifier '%s' for pciehp_detect_mode. Use default\n",
66 pciehp_detect_mode);
67 return PCIEHP_DETECT_DEFAULT;
68}
69
70static struct pcie_port_service_id __initdata port_pci_ids[] = {
71 {
72 .vendor = PCI_ANY_ID,
73 .device = PCI_ANY_ID,
74 .port_type = PCIE_ANY_PORT,
75 .service_type = PCIE_PORT_SERVICE_HP,
76 .driver_data = 0,
77 }, { /* end: all zeroes */ }
78};
79
80static int __initdata dup_slot_id;
81static int __initdata acpi_slot_detected;
82static struct list_head __initdata dummy_slots = LIST_HEAD_INIT(dummy_slots);
83
84/* Dummy driver for dumplicate name detection */
85static int __init dummy_probe(struct pcie_device *dev,
86 const struct pcie_port_service_id *id)
87{
88 int pos;
89 u32 slot_cap;
90 struct slot *slot, *tmp;
91 struct pci_dev *pdev = dev->port;
92 struct pci_bus *pbus = pdev->subordinate;
93 if (!(slot = kzalloc(sizeof(*slot), GFP_KERNEL)))
94 return -ENOMEM;
95 /* Note: pciehp_detect_mode != PCIEHP_DETECT_ACPI here */
96 if (pciehp_get_hp_hw_control_from_firmware(pdev))
97 return -ENODEV;
98 if (!(pos = pci_find_capability(pdev, PCI_CAP_ID_EXP)))
99 return -ENODEV;
100 pci_read_config_dword(pdev, pos + PCI_EXP_SLTCAP, &slot_cap);
101 slot->number = slot_cap >> 19;
102 list_for_each_entry(tmp, &dummy_slots, slot_list) {
103 if (tmp->number == slot->number)
104 dup_slot_id++;
105 }
106 list_add_tail(&slot->slot_list, &dummy_slots);
107 if (!acpi_slot_detected && acpi_pci_detect_ejectable(pbus))
108 acpi_slot_detected = 1;
109 return -ENODEV; /* dummy driver always returns error */
110}
111
112static struct pcie_port_service_driver __initdata dummy_driver = {
113 .name = "pciehp_dummy",
114 .id_table = port_pci_ids,
115 .probe = dummy_probe,
116};
117
118static int __init select_detection_mode(void)
119{
120 struct slot *slot, *tmp;
121 pcie_port_service_register(&dummy_driver);
122 pcie_port_service_unregister(&dummy_driver);
123 list_for_each_entry_safe(slot, tmp, &dummy_slots, slot_list) {
124 list_del(&slot->slot_list);
125 kfree(slot);
126 }
127 if (acpi_slot_detected && dup_slot_id)
128 return PCIEHP_DETECT_ACPI;
129 return PCIEHP_DETECT_PCIE;
130}
131
132void __init pciehp_acpi_slot_detection_init(void)
133{
134 slot_detection_mode = parse_detect_mode();
135 if (slot_detection_mode != PCIEHP_DETECT_AUTO)
136 goto out;
137 slot_detection_mode = select_detection_mode();
138out:
139 if (slot_detection_mode == PCIEHP_DETECT_ACPI)
140 info("Using ACPI for slot detection.\n");
141}
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 39cf248d24e3..5482d4ed8256 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -522,6 +522,7 @@ static int __init pcied_init(void)
522{ 522{
523 int retval = 0; 523 int retval = 0;
524 524
525 pciehp_firmware_init();
525 retval = pcie_port_service_register(&hpdriver_portdrv); 526 retval = pcie_port_service_register(&hpdriver_portdrv);
526 dbg("pcie_port_service_register = %d\n", retval); 527 dbg("pcie_port_service_register = %d\n", retval);
527 info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); 528 info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index fead63c6b49e..ff4034502d24 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -178,15 +178,14 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot)
178 "Issue of Slot Power Off command failed\n"); 178 "Issue of Slot Power Off command failed\n");
179 return; 179 return;
180 } 180 }
181 /*
182 * After turning power off, we must wait for at least 1 second
183 * before taking any action that relies on power having been
184 * removed from the slot/adapter.
185 */
186 msleep(1000);
181 } 187 }
182 188
183 /*
184 * After turning power off, we must wait for at least 1 second
185 * before taking any action that relies on power having been
186 * removed from the slot/adapter.
187 */
188 msleep(1000);
189
190 if (PWR_LED(ctrl)) 189 if (PWR_LED(ctrl))
191 pslot->hpc_ops->green_led_off(pslot); 190 pslot->hpc_ops->green_led_off(pslot);
192 191
@@ -286,15 +285,14 @@ static int remove_board(struct slot *p_slot)
286 "Issue of Slot Disable command failed\n"); 285 "Issue of Slot Disable command failed\n");
287 return retval; 286 return retval;
288 } 287 }
288 /*
289 * After turning power off, we must wait for at least 1 second
290 * before taking any action that relies on power having been
291 * removed from the slot/adapter.
292 */
293 msleep(1000);
289 } 294 }
290 295
291 /*
292 * After turning power off, we must wait for at least 1 second
293 * before taking any action that relies on power having been
294 * removed from the slot/adapter.
295 */
296 msleep(1000);
297
298 if (PWR_LED(ctrl)) 296 if (PWR_LED(ctrl))
299 /* turn off Green LED */ 297 /* turn off Green LED */
300 p_slot->hpc_ops->green_led_off(p_slot); 298 p_slot->hpc_ops->green_led_off(p_slot);
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index b643ca13e4f1..71a8012886b0 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -42,42 +42,6 @@
42 42
43static atomic_t pciehp_num_controllers = ATOMIC_INIT(0); 43static atomic_t pciehp_num_controllers = ATOMIC_INIT(0);
44 44
45struct ctrl_reg {
46 u8 cap_id;
47 u8 nxt_ptr;
48 u16 cap_reg;
49 u32 dev_cap;
50 u16 dev_ctrl;
51 u16 dev_status;
52 u32 lnk_cap;
53 u16 lnk_ctrl;
54 u16 lnk_status;
55 u32 slot_cap;
56 u16 slot_ctrl;
57 u16 slot_status;
58 u16 root_ctrl;
59 u16 rsvp;
60 u32 root_status;
61} __attribute__ ((packed));
62
63/* offsets to the controller registers based on the above structure layout */
64enum ctrl_offsets {
65 PCIECAPID = offsetof(struct ctrl_reg, cap_id),
66 NXTCAPPTR = offsetof(struct ctrl_reg, nxt_ptr),
67 CAPREG = offsetof(struct ctrl_reg, cap_reg),
68 DEVCAP = offsetof(struct ctrl_reg, dev_cap),
69 DEVCTRL = offsetof(struct ctrl_reg, dev_ctrl),
70 DEVSTATUS = offsetof(struct ctrl_reg, dev_status),
71 LNKCAP = offsetof(struct ctrl_reg, lnk_cap),
72 LNKCTRL = offsetof(struct ctrl_reg, lnk_ctrl),
73 LNKSTATUS = offsetof(struct ctrl_reg, lnk_status),
74 SLOTCAP = offsetof(struct ctrl_reg, slot_cap),
75 SLOTCTRL = offsetof(struct ctrl_reg, slot_ctrl),
76 SLOTSTATUS = offsetof(struct ctrl_reg, slot_status),
77 ROOTCTRL = offsetof(struct ctrl_reg, root_ctrl),
78 ROOTSTATUS = offsetof(struct ctrl_reg, root_status),
79};
80
81static inline int pciehp_readw(struct controller *ctrl, int reg, u16 *value) 45static inline int pciehp_readw(struct controller *ctrl, int reg, u16 *value)
82{ 46{
83 struct pci_dev *dev = ctrl->pci_dev; 47 struct pci_dev *dev = ctrl->pci_dev;
@@ -102,95 +66,9 @@ static inline int pciehp_writel(struct controller *ctrl, int reg, u32 value)
102 return pci_write_config_dword(dev, ctrl->cap_base + reg, value); 66 return pci_write_config_dword(dev, ctrl->cap_base + reg, value);
103} 67}
104 68
105/* Field definitions in PCI Express Capabilities Register */
106#define CAP_VER 0x000F
107#define DEV_PORT_TYPE 0x00F0
108#define SLOT_IMPL 0x0100
109#define MSG_NUM 0x3E00
110
111/* Device or Port Type */
112#define NAT_ENDPT 0x00
113#define LEG_ENDPT 0x01
114#define ROOT_PORT 0x04
115#define UP_STREAM 0x05
116#define DN_STREAM 0x06
117#define PCIE_PCI_BRDG 0x07
118#define PCI_PCIE_BRDG 0x10
119
120/* Field definitions in Device Capabilities Register */
121#define DATTN_BUTTN_PRSN 0x1000
122#define DATTN_LED_PRSN 0x2000
123#define DPWR_LED_PRSN 0x4000
124
125/* Field definitions in Link Capabilities Register */
126#define MAX_LNK_SPEED 0x000F
127#define MAX_LNK_WIDTH 0x03F0
128#define LINK_ACTIVE_REPORTING 0x00100000
129
130/* Link Width Encoding */
131#define LNK_X1 0x01
132#define LNK_X2 0x02
133#define LNK_X4 0x04
134#define LNK_X8 0x08
135#define LNK_X12 0x0C
136#define LNK_X16 0x10
137#define LNK_X32 0x20
138
139/*Field definitions of Link Status Register */
140#define LNK_SPEED 0x000F
141#define NEG_LINK_WD 0x03F0
142#define LNK_TRN_ERR 0x0400
143#define LNK_TRN 0x0800
144#define SLOT_CLK_CONF 0x1000
145#define LINK_ACTIVE 0x2000
146
147/* Field definitions in Slot Capabilities Register */
148#define ATTN_BUTTN_PRSN 0x00000001
149#define PWR_CTRL_PRSN 0x00000002
150#define MRL_SENS_PRSN 0x00000004
151#define ATTN_LED_PRSN 0x00000008
152#define PWR_LED_PRSN 0x00000010
153#define HP_SUPR_RM_SUP 0x00000020
154#define HP_CAP 0x00000040
155#define SLOT_PWR_VALUE 0x000003F8
156#define SLOT_PWR_LIMIT 0x00000C00
157#define PSN 0xFFF80000 /* PSN: Physical Slot Number */
158
159/* Field definitions in Slot Control Register */
160#define ATTN_BUTTN_ENABLE 0x0001
161#define PWR_FAULT_DETECT_ENABLE 0x0002
162#define MRL_DETECT_ENABLE 0x0004
163#define PRSN_DETECT_ENABLE 0x0008
164#define CMD_CMPL_INTR_ENABLE 0x0010
165#define HP_INTR_ENABLE 0x0020
166#define ATTN_LED_CTRL 0x00C0
167#define PWR_LED_CTRL 0x0300
168#define PWR_CTRL 0x0400
169#define EMI_CTRL 0x0800
170
171/* Attention indicator and Power indicator states */
172#define LED_ON 0x01
173#define LED_BLINK 0x10
174#define LED_OFF 0x11
175
176/* Power Control Command */ 69/* Power Control Command */
177#define POWER_ON 0 70#define POWER_ON 0
178#define POWER_OFF 0x0400 71#define POWER_OFF PCI_EXP_SLTCTL_PCC
179
180/* EMI Status defines */
181#define EMI_DISENGAGED 0
182#define EMI_ENGAGED 1
183
184/* Field definitions in Slot Status Register */
185#define ATTN_BUTTN_PRESSED 0x0001
186#define PWR_FAULT_DETECTED 0x0002
187#define MRL_SENS_CHANGED 0x0004
188#define PRSN_DETECT_CHANGED 0x0008
189#define CMD_COMPLETED 0x0010
190#define MRL_STATE 0x0020
191#define PRSN_STATE 0x0040
192#define EMI_STATE 0x0080
193#define EMI_STATUS_BIT 7
194 72
195static irqreturn_t pcie_isr(int irq, void *dev_id); 73static irqreturn_t pcie_isr(int irq, void *dev_id);
196static void start_int_poll_timer(struct controller *ctrl, int sec); 74static void start_int_poll_timer(struct controller *ctrl, int sec);
@@ -253,22 +131,20 @@ static inline void pciehp_free_irq(struct controller *ctrl)
253static int pcie_poll_cmd(struct controller *ctrl) 131static int pcie_poll_cmd(struct controller *ctrl)
254{ 132{
255 u16 slot_status; 133 u16 slot_status;
256 int timeout = 1000; 134 int err, timeout = 1000;
257 135
258 if (!pciehp_readw(ctrl, SLOTSTATUS, &slot_status)) { 136 err = pciehp_readw(ctrl, PCI_EXP_SLTSTA, &slot_status);
259 if (slot_status & CMD_COMPLETED) { 137 if (!err && (slot_status & PCI_EXP_SLTSTA_CC)) {
260 pciehp_writew(ctrl, SLOTSTATUS, CMD_COMPLETED); 138 pciehp_writew(ctrl, PCI_EXP_SLTSTA, PCI_EXP_SLTSTA_CC);
261 return 1; 139 return 1;
262 }
263 } 140 }
264 while (timeout > 0) { 141 while (timeout > 0) {
265 msleep(10); 142 msleep(10);
266 timeout -= 10; 143 timeout -= 10;
267 if (!pciehp_readw(ctrl, SLOTSTATUS, &slot_status)) { 144 err = pciehp_readw(ctrl, PCI_EXP_SLTSTA, &slot_status);
268 if (slot_status & CMD_COMPLETED) { 145 if (!err && (slot_status & PCI_EXP_SLTSTA_CC)) {
269 pciehp_writew(ctrl, SLOTSTATUS, CMD_COMPLETED); 146 pciehp_writew(ctrl, PCI_EXP_SLTSTA, PCI_EXP_SLTSTA_CC);
270 return 1; 147 return 1;
271 }
272 } 148 }
273 } 149 }
274 return 0; /* timeout */ 150 return 0; /* timeout */
@@ -302,14 +178,14 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask)
302 178
303 mutex_lock(&ctrl->ctrl_lock); 179 mutex_lock(&ctrl->ctrl_lock);
304 180
305 retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); 181 retval = pciehp_readw(ctrl, PCI_EXP_SLTSTA, &slot_status);
306 if (retval) { 182 if (retval) {
307 ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n", 183 ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n",
308 __func__); 184 __func__);
309 goto out; 185 goto out;
310 } 186 }
311 187
312 if (slot_status & CMD_COMPLETED) { 188 if (slot_status & PCI_EXP_SLTSTA_CC) {
313 if (!ctrl->no_cmd_complete) { 189 if (!ctrl->no_cmd_complete) {
314 /* 190 /*
315 * After 1 sec and CMD_COMPLETED still not set, just 191 * After 1 sec and CMD_COMPLETED still not set, just
@@ -332,7 +208,7 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask)
332 } 208 }
333 } 209 }
334 210
335 retval = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl); 211 retval = pciehp_readw(ctrl, PCI_EXP_SLTCTL, &slot_ctrl);
336 if (retval) { 212 if (retval) {
337 ctrl_err(ctrl, "%s: Cannot read SLOTCTRL register\n", __func__); 213 ctrl_err(ctrl, "%s: Cannot read SLOTCTRL register\n", __func__);
338 goto out; 214 goto out;
@@ -342,7 +218,7 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask)
342 slot_ctrl |= (cmd & mask); 218 slot_ctrl |= (cmd & mask);
343 ctrl->cmd_busy = 1; 219 ctrl->cmd_busy = 1;
344 smp_mb(); 220 smp_mb();
345 retval = pciehp_writew(ctrl, SLOTCTRL, slot_ctrl); 221 retval = pciehp_writew(ctrl, PCI_EXP_SLTCTL, slot_ctrl);
346 if (retval) 222 if (retval)
347 ctrl_err(ctrl, "Cannot write to SLOTCTRL register\n"); 223 ctrl_err(ctrl, "Cannot write to SLOTCTRL register\n");
348 224
@@ -356,8 +232,8 @@ static int pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask)
356 * completed interrupt is not enabled, we need to poll 232 * completed interrupt is not enabled, we need to poll
357 * command completed event. 233 * command completed event.
358 */ 234 */
359 if (!(slot_ctrl & HP_INTR_ENABLE) || 235 if (!(slot_ctrl & PCI_EXP_SLTCTL_HPIE) ||
360 !(slot_ctrl & CMD_CMPL_INTR_ENABLE)) 236 !(slot_ctrl & PCI_EXP_SLTCTL_CCIE))
361 poll = 1; 237 poll = 1;
362 pcie_wait_cmd(ctrl, poll); 238 pcie_wait_cmd(ctrl, poll);
363 } 239 }
@@ -370,9 +246,9 @@ static inline int check_link_active(struct controller *ctrl)
370{ 246{
371 u16 link_status; 247 u16 link_status;
372 248
373 if (pciehp_readw(ctrl, LNKSTATUS, &link_status)) 249 if (pciehp_readw(ctrl, PCI_EXP_LNKSTA, &link_status))
374 return 0; 250 return 0;
375 return !!(link_status & LINK_ACTIVE); 251 return !!(link_status & PCI_EXP_LNKSTA_DLLLA);
376} 252}
377 253
378static void pcie_wait_link_active(struct controller *ctrl) 254static void pcie_wait_link_active(struct controller *ctrl)
@@ -412,15 +288,15 @@ static int hpc_check_lnk_status(struct controller *ctrl)
412 } else 288 } else
413 msleep(1000); 289 msleep(1000);
414 290
415 retval = pciehp_readw(ctrl, LNKSTATUS, &lnk_status); 291 retval = pciehp_readw(ctrl, PCI_EXP_LNKSTA, &lnk_status);
416 if (retval) { 292 if (retval) {
417 ctrl_err(ctrl, "Cannot read LNKSTATUS register\n"); 293 ctrl_err(ctrl, "Cannot read LNKSTATUS register\n");
418 return retval; 294 return retval;
419 } 295 }
420 296
421 ctrl_dbg(ctrl, "%s: lnk_status = %x\n", __func__, lnk_status); 297 ctrl_dbg(ctrl, "%s: lnk_status = %x\n", __func__, lnk_status);
422 if ( (lnk_status & LNK_TRN) || (lnk_status & LNK_TRN_ERR) || 298 if ((lnk_status & PCI_EXP_LNKSTA_LT) ||
423 !(lnk_status & NEG_LINK_WD)) { 299 !(lnk_status & PCI_EXP_LNKSTA_NLW)) {
424 ctrl_err(ctrl, "Link Training Error occurs \n"); 300 ctrl_err(ctrl, "Link Training Error occurs \n");
425 retval = -1; 301 retval = -1;
426 return retval; 302 return retval;
@@ -436,16 +312,16 @@ static int hpc_get_attention_status(struct slot *slot, u8 *status)
436 u8 atten_led_state; 312 u8 atten_led_state;
437 int retval = 0; 313 int retval = 0;
438 314
439 retval = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl); 315 retval = pciehp_readw(ctrl, PCI_EXP_SLTCTL, &slot_ctrl);
440 if (retval) { 316 if (retval) {
441 ctrl_err(ctrl, "%s: Cannot read SLOTCTRL register\n", __func__); 317 ctrl_err(ctrl, "%s: Cannot read SLOTCTRL register\n", __func__);
442 return retval; 318 return retval;
443 } 319 }
444 320
445 ctrl_dbg(ctrl, "%s: SLOTCTRL %x, value read %x\n", 321 ctrl_dbg(ctrl, "%s: SLOTCTRL %x, value read %x\n",
446 __func__, ctrl->cap_base + SLOTCTRL, slot_ctrl); 322 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_ctrl);
447 323
448 atten_led_state = (slot_ctrl & ATTN_LED_CTRL) >> 6; 324 atten_led_state = (slot_ctrl & PCI_EXP_SLTCTL_AIC) >> 6;
449 325
450 switch (atten_led_state) { 326 switch (atten_led_state) {
451 case 0: 327 case 0:
@@ -475,15 +351,15 @@ static int hpc_get_power_status(struct slot *slot, u8 *status)
475 u8 pwr_state; 351 u8 pwr_state;
476 int retval = 0; 352 int retval = 0;
477 353
478 retval = pciehp_readw(ctrl, SLOTCTRL, &slot_ctrl); 354 retval = pciehp_readw(ctrl, PCI_EXP_SLTCTL, &slot_ctrl);
479 if (retval) { 355 if (retval) {
480 ctrl_err(ctrl, "%s: Cannot read SLOTCTRL register\n", __func__); 356 ctrl_err(ctrl, "%s: Cannot read SLOTCTRL register\n", __func__);
481 return retval; 357 return retval;
482 } 358 }
483 ctrl_dbg(ctrl, "%s: SLOTCTRL %x value read %x\n", 359 ctrl_dbg(ctrl, "%s: SLOTCTRL %x value read %x\n",
484 __func__, ctrl->cap_base + SLOTCTRL, slot_ctrl); 360 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_ctrl);
485 361
486 pwr_state = (slot_ctrl & PWR_CTRL) >> 10; 362 pwr_state = (slot_ctrl & PCI_EXP_SLTCTL_PCC) >> 10;
487 363
488 switch (pwr_state) { 364 switch (pwr_state) {
489 case 0: 365 case 0:
@@ -504,17 +380,15 @@ static int hpc_get_latch_status(struct slot *slot, u8 *status)
504{ 380{
505 struct controller *ctrl = slot->ctrl; 381 struct controller *ctrl = slot->ctrl;
506 u16 slot_status; 382 u16 slot_status;
507 int retval = 0; 383 int retval;
508 384
509 retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); 385 retval = pciehp_readw(ctrl, PCI_EXP_SLTSTA, &slot_status);
510 if (retval) { 386 if (retval) {
511 ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n", 387 ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n",
512 __func__); 388 __func__);
513 return retval; 389 return retval;
514 } 390 }
515 391 *status = !!(slot_status & PCI_EXP_SLTSTA_MRLSS);
516 *status = (((slot_status & MRL_STATE) >> 5) == 0) ? 0 : 1;
517
518 return 0; 392 return 0;
519} 393}
520 394
@@ -522,18 +396,15 @@ static int hpc_get_adapter_status(struct slot *slot, u8 *status)
522{ 396{
523 struct controller *ctrl = slot->ctrl; 397 struct controller *ctrl = slot->ctrl;
524 u16 slot_status; 398 u16 slot_status;
525 u8 card_state; 399 int retval;
526 int retval = 0;
527 400
528 retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); 401 retval = pciehp_readw(ctrl, PCI_EXP_SLTSTA, &slot_status);
529 if (retval) { 402 if (retval) {
530 ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n", 403 ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n",
531 __func__); 404 __func__);
532 return retval; 405 return retval;
533 } 406 }
534 card_state = (u8)((slot_status & PRSN_STATE) >> 6); 407 *status = !!(slot_status & PCI_EXP_SLTSTA_PDS);
535 *status = (card_state == 1) ? 1 : 0;
536
537 return 0; 408 return 0;
538} 409}
539 410
@@ -541,32 +412,28 @@ static int hpc_query_power_fault(struct slot *slot)
541{ 412{
542 struct controller *ctrl = slot->ctrl; 413 struct controller *ctrl = slot->ctrl;
543 u16 slot_status; 414 u16 slot_status;
544 u8 pwr_fault; 415 int retval;
545 int retval = 0;
546 416
547 retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); 417 retval = pciehp_readw(ctrl, PCI_EXP_SLTSTA, &slot_status);
548 if (retval) { 418 if (retval) {
549 ctrl_err(ctrl, "Cannot check for power fault\n"); 419 ctrl_err(ctrl, "Cannot check for power fault\n");
550 return retval; 420 return retval;
551 } 421 }
552 pwr_fault = (u8)((slot_status & PWR_FAULT_DETECTED) >> 1); 422 return !!(slot_status & PCI_EXP_SLTSTA_PFD);
553
554 return pwr_fault;
555} 423}
556 424
557static int hpc_get_emi_status(struct slot *slot, u8 *status) 425static int hpc_get_emi_status(struct slot *slot, u8 *status)
558{ 426{
559 struct controller *ctrl = slot->ctrl; 427 struct controller *ctrl = slot->ctrl;
560 u16 slot_status; 428 u16 slot_status;
561 int retval = 0; 429 int retval;
562 430
563 retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); 431 retval = pciehp_readw(ctrl, PCI_EXP_SLTSTA, &slot_status);
564 if (retval) { 432 if (retval) {
565 ctrl_err(ctrl, "Cannot check EMI status\n"); 433 ctrl_err(ctrl, "Cannot check EMI status\n");
566 return retval; 434 return retval;
567 } 435 }
568 *status = (slot_status & EMI_STATE) >> EMI_STATUS_BIT; 436 *status = !!(slot_status & PCI_EXP_SLTSTA_EIS);
569
570 return retval; 437 return retval;
571} 438}
572 439
@@ -576,8 +443,8 @@ static int hpc_toggle_emi(struct slot *slot)
576 u16 cmd_mask; 443 u16 cmd_mask;
577 int rc; 444 int rc;
578 445
579 slot_cmd = EMI_CTRL; 446 slot_cmd = PCI_EXP_SLTCTL_EIC;
580 cmd_mask = EMI_CTRL; 447 cmd_mask = PCI_EXP_SLTCTL_EIC;
581 rc = pcie_write_cmd(slot->ctrl, slot_cmd, cmd_mask); 448 rc = pcie_write_cmd(slot->ctrl, slot_cmd, cmd_mask);
582 slot->last_emi_toggle = get_seconds(); 449 slot->last_emi_toggle = get_seconds();
583 450
@@ -591,7 +458,7 @@ static int hpc_set_attention_status(struct slot *slot, u8 value)
591 u16 cmd_mask; 458 u16 cmd_mask;
592 int rc; 459 int rc;
593 460
594 cmd_mask = ATTN_LED_CTRL; 461 cmd_mask = PCI_EXP_SLTCTL_AIC;
595 switch (value) { 462 switch (value) {
596 case 0 : /* turn off */ 463 case 0 : /* turn off */
597 slot_cmd = 0x00C0; 464 slot_cmd = 0x00C0;
@@ -607,7 +474,7 @@ static int hpc_set_attention_status(struct slot *slot, u8 value)
607 } 474 }
608 rc = pcie_write_cmd(ctrl, slot_cmd, cmd_mask); 475 rc = pcie_write_cmd(ctrl, slot_cmd, cmd_mask);
609 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", 476 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n",
610 __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); 477 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd);
611 478
612 return rc; 479 return rc;
613} 480}
@@ -619,10 +486,10 @@ static void hpc_set_green_led_on(struct slot *slot)
619 u16 cmd_mask; 486 u16 cmd_mask;
620 487
621 slot_cmd = 0x0100; 488 slot_cmd = 0x0100;
622 cmd_mask = PWR_LED_CTRL; 489 cmd_mask = PCI_EXP_SLTCTL_PIC;
623 pcie_write_cmd(ctrl, slot_cmd, cmd_mask); 490 pcie_write_cmd(ctrl, slot_cmd, cmd_mask);
624 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", 491 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n",
625 __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); 492 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd);
626} 493}
627 494
628static void hpc_set_green_led_off(struct slot *slot) 495static void hpc_set_green_led_off(struct slot *slot)
@@ -632,10 +499,10 @@ static void hpc_set_green_led_off(struct slot *slot)
632 u16 cmd_mask; 499 u16 cmd_mask;
633 500
634 slot_cmd = 0x0300; 501 slot_cmd = 0x0300;
635 cmd_mask = PWR_LED_CTRL; 502 cmd_mask = PCI_EXP_SLTCTL_PIC;
636 pcie_write_cmd(ctrl, slot_cmd, cmd_mask); 503 pcie_write_cmd(ctrl, slot_cmd, cmd_mask);
637 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", 504 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n",
638 __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); 505 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd);
639} 506}
640 507
641static void hpc_set_green_led_blink(struct slot *slot) 508static void hpc_set_green_led_blink(struct slot *slot)
@@ -645,10 +512,10 @@ static void hpc_set_green_led_blink(struct slot *slot)
645 u16 cmd_mask; 512 u16 cmd_mask;
646 513
647 slot_cmd = 0x0200; 514 slot_cmd = 0x0200;
648 cmd_mask = PWR_LED_CTRL; 515 cmd_mask = PCI_EXP_SLTCTL_PIC;
649 pcie_write_cmd(ctrl, slot_cmd, cmd_mask); 516 pcie_write_cmd(ctrl, slot_cmd, cmd_mask);
650 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", 517 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n",
651 __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); 518 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd);
652} 519}
653 520
654static int hpc_power_on_slot(struct slot * slot) 521static int hpc_power_on_slot(struct slot * slot)
@@ -662,15 +529,15 @@ static int hpc_power_on_slot(struct slot * slot)
662 ctrl_dbg(ctrl, "%s: slot->hp_slot %x\n", __func__, slot->hp_slot); 529 ctrl_dbg(ctrl, "%s: slot->hp_slot %x\n", __func__, slot->hp_slot);
663 530
664 /* Clear sticky power-fault bit from previous power failures */ 531 /* Clear sticky power-fault bit from previous power failures */
665 retval = pciehp_readw(ctrl, SLOTSTATUS, &slot_status); 532 retval = pciehp_readw(ctrl, PCI_EXP_SLTSTA, &slot_status);
666 if (retval) { 533 if (retval) {
667 ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n", 534 ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS register\n",
668 __func__); 535 __func__);
669 return retval; 536 return retval;
670 } 537 }
671 slot_status &= PWR_FAULT_DETECTED; 538 slot_status &= PCI_EXP_SLTSTA_PFD;
672 if (slot_status) { 539 if (slot_status) {
673 retval = pciehp_writew(ctrl, SLOTSTATUS, slot_status); 540 retval = pciehp_writew(ctrl, PCI_EXP_SLTSTA, slot_status);
674 if (retval) { 541 if (retval) {
675 ctrl_err(ctrl, 542 ctrl_err(ctrl,
676 "%s: Cannot write to SLOTSTATUS register\n", 543 "%s: Cannot write to SLOTSTATUS register\n",
@@ -680,13 +547,13 @@ static int hpc_power_on_slot(struct slot * slot)
680 } 547 }
681 548
682 slot_cmd = POWER_ON; 549 slot_cmd = POWER_ON;
683 cmd_mask = PWR_CTRL; 550 cmd_mask = PCI_EXP_SLTCTL_PCC;
684 /* Enable detection that we turned off at slot power-off time */ 551 /* Enable detection that we turned off at slot power-off time */
685 if (!pciehp_poll_mode) { 552 if (!pciehp_poll_mode) {
686 slot_cmd |= (PWR_FAULT_DETECT_ENABLE | MRL_DETECT_ENABLE | 553 slot_cmd |= (PCI_EXP_SLTCTL_PFDE | PCI_EXP_SLTCTL_MRLSCE |
687 PRSN_DETECT_ENABLE); 554 PCI_EXP_SLTCTL_PDCE);
688 cmd_mask |= (PWR_FAULT_DETECT_ENABLE | MRL_DETECT_ENABLE | 555 cmd_mask |= (PCI_EXP_SLTCTL_PFDE | PCI_EXP_SLTCTL_MRLSCE |
689 PRSN_DETECT_ENABLE); 556 PCI_EXP_SLTCTL_PDCE);
690 } 557 }
691 558
692 retval = pcie_write_cmd(ctrl, slot_cmd, cmd_mask); 559 retval = pcie_write_cmd(ctrl, slot_cmd, cmd_mask);
@@ -696,7 +563,7 @@ static int hpc_power_on_slot(struct slot * slot)
696 return -1; 563 return -1;
697 } 564 }
698 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", 565 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n",
699 __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); 566 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd);
700 567
701 return retval; 568 return retval;
702} 569}
@@ -753,7 +620,7 @@ static int hpc_power_off_slot(struct slot * slot)
753 changed = pcie_mask_bad_dllp(ctrl); 620 changed = pcie_mask_bad_dllp(ctrl);
754 621
755 slot_cmd = POWER_OFF; 622 slot_cmd = POWER_OFF;
756 cmd_mask = PWR_CTRL; 623 cmd_mask = PCI_EXP_SLTCTL_PCC;
757 /* 624 /*
758 * If we get MRL or presence detect interrupts now, the isr 625 * If we get MRL or presence detect interrupts now, the isr
759 * will notice the sticky power-fault bit too and issue power 626 * will notice the sticky power-fault bit too and issue power
@@ -762,10 +629,10 @@ static int hpc_power_off_slot(struct slot * slot)
762 * till the slot is powered on again. 629 * till the slot is powered on again.
763 */ 630 */
764 if (!pciehp_poll_mode) { 631 if (!pciehp_poll_mode) {
765 slot_cmd &= ~(PWR_FAULT_DETECT_ENABLE | MRL_DETECT_ENABLE | 632 slot_cmd &= ~(PCI_EXP_SLTCTL_PFDE | PCI_EXP_SLTCTL_MRLSCE |
766 PRSN_DETECT_ENABLE); 633 PCI_EXP_SLTCTL_PDCE);
767 cmd_mask |= (PWR_FAULT_DETECT_ENABLE | MRL_DETECT_ENABLE | 634 cmd_mask |= (PCI_EXP_SLTCTL_PFDE | PCI_EXP_SLTCTL_MRLSCE |
768 PRSN_DETECT_ENABLE); 635 PCI_EXP_SLTCTL_PDCE);
769 } 636 }
770 637
771 retval = pcie_write_cmd(ctrl, slot_cmd, cmd_mask); 638 retval = pcie_write_cmd(ctrl, slot_cmd, cmd_mask);
@@ -775,7 +642,7 @@ static int hpc_power_off_slot(struct slot * slot)
775 goto out; 642 goto out;
776 } 643 }
777 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n", 644 ctrl_dbg(ctrl, "%s: SLOTCTRL %x write cmd %x\n",
778 __func__, ctrl->cap_base + SLOTCTRL, slot_cmd); 645 __func__, ctrl->cap_base + PCI_EXP_SLTCTL, slot_cmd);
779 out: 646 out:
780 if (changed) 647 if (changed)
781 pcie_unmask_bad_dllp(ctrl); 648 pcie_unmask_bad_dllp(ctrl);
@@ -796,19 +663,19 @@ static irqreturn_t pcie_isr(int irq, void *dev_id)
796 */ 663 */
797 intr_loc = 0; 664 intr_loc = 0;
798 do { 665 do {
799 if (pciehp_readw(ctrl, SLOTSTATUS, &detected)) { 666 if (pciehp_readw(ctrl, PCI_EXP_SLTSTA, &detected)) {
800 ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS\n", 667 ctrl_err(ctrl, "%s: Cannot read SLOTSTATUS\n",
801 __func__); 668 __func__);
802 return IRQ_NONE; 669 return IRQ_NONE;
803 } 670 }
804 671
805 detected &= (ATTN_BUTTN_PRESSED | PWR_FAULT_DETECTED | 672 detected &= (PCI_EXP_SLTSTA_ABP | PCI_EXP_SLTSTA_PFD |
806 MRL_SENS_CHANGED | PRSN_DETECT_CHANGED | 673 PCI_EXP_SLTSTA_MRLSC | PCI_EXP_SLTSTA_PDC |
807 CMD_COMPLETED); 674 PCI_EXP_SLTSTA_CC);
808 intr_loc |= detected; 675 intr_loc |= detected;
809 if (!intr_loc) 676 if (!intr_loc)
810 return IRQ_NONE; 677 return IRQ_NONE;
811 if (detected && pciehp_writew(ctrl, SLOTSTATUS, detected)) { 678 if (detected && pciehp_writew(ctrl, PCI_EXP_SLTSTA, detected)) {
812 ctrl_err(ctrl, "%s: Cannot write to SLOTSTATUS\n", 679 ctrl_err(ctrl, "%s: Cannot write to SLOTSTATUS\n",
813 __func__); 680 __func__);
814 return IRQ_NONE; 681 return IRQ_NONE;
@@ -818,31 +685,31 @@ static irqreturn_t pcie_isr(int irq, void *dev_id)
818 ctrl_dbg(ctrl, "%s: intr_loc %x\n", __func__, intr_loc); 685 ctrl_dbg(ctrl, "%s: intr_loc %x\n", __func__, intr_loc);
819 686
820 /* Check Command Complete Interrupt Pending */ 687 /* Check Command Complete Interrupt Pending */
821 if (intr_loc & CMD_COMPLETED) { 688 if (intr_loc & PCI_EXP_SLTSTA_CC) {
822 ctrl->cmd_busy = 0; 689 ctrl->cmd_busy = 0;
823 smp_mb(); 690 smp_mb();
824 wake_up(&ctrl->queue); 691 wake_up(&ctrl->queue);
825 } 692 }
826 693
827 if (!(intr_loc & ~CMD_COMPLETED)) 694 if (!(intr_loc & ~PCI_EXP_SLTSTA_CC))
828 return IRQ_HANDLED; 695 return IRQ_HANDLED;
829 696
830 p_slot = pciehp_find_slot(ctrl, ctrl->slot_device_offset); 697 p_slot = pciehp_find_slot(ctrl, ctrl->slot_device_offset);
831 698
832 /* Check MRL Sensor Changed */ 699 /* Check MRL Sensor Changed */
833 if (intr_loc & MRL_SENS_CHANGED) 700 if (intr_loc & PCI_EXP_SLTSTA_MRLSC)
834 pciehp_handle_switch_change(p_slot); 701 pciehp_handle_switch_change(p_slot);
835 702
836 /* Check Attention Button Pressed */ 703 /* Check Attention Button Pressed */
837 if (intr_loc & ATTN_BUTTN_PRESSED) 704 if (intr_loc & PCI_EXP_SLTSTA_ABP)
838 pciehp_handle_attention_button(p_slot); 705 pciehp_handle_attention_button(p_slot);
839 706
840 /* Check Presence Detect Changed */ 707 /* Check Presence Detect Changed */
841 if (intr_loc & PRSN_DETECT_CHANGED) 708 if (intr_loc & PCI_EXP_SLTSTA_PDC)
842 pciehp_handle_presence_change(p_slot); 709 pciehp_handle_presence_change(p_slot);
843 710
844 /* Check Power Fault Detected */ 711 /* Check Power Fault Detected */
845 if (intr_loc & PWR_FAULT_DETECTED) 712 if (intr_loc & PCI_EXP_SLTSTA_PFD)
846 pciehp_handle_power_fault(p_slot); 713 pciehp_handle_power_fault(p_slot);
847 714
848 return IRQ_HANDLED; 715 return IRQ_HANDLED;
@@ -855,7 +722,7 @@ static int hpc_get_max_lnk_speed(struct slot *slot, enum pci_bus_speed *value)
855 u32 lnk_cap; 722 u32 lnk_cap;
856 int retval = 0; 723 int retval = 0;
857 724
858 retval = pciehp_readl(ctrl, LNKCAP, &lnk_cap); 725 retval = pciehp_readl(ctrl, PCI_EXP_LNKCAP, &lnk_cap);
859 if (retval) { 726 if (retval) {
860 ctrl_err(ctrl, "%s: Cannot read LNKCAP register\n", __func__); 727 ctrl_err(ctrl, "%s: Cannot read LNKCAP register\n", __func__);
861 return retval; 728 return retval;
@@ -884,13 +751,13 @@ static int hpc_get_max_lnk_width(struct slot *slot,
884 u32 lnk_cap; 751 u32 lnk_cap;
885 int retval = 0; 752 int retval = 0;
886 753
887 retval = pciehp_readl(ctrl, LNKCAP, &lnk_cap); 754 retval = pciehp_readl(ctrl, PCI_EXP_LNKCAP, &lnk_cap);
888 if (retval) { 755 if (retval) {
889 ctrl_err(ctrl, "%s: Cannot read LNKCAP register\n", __func__); 756 ctrl_err(ctrl, "%s: Cannot read LNKCAP register\n", __func__);
890 return retval; 757 return retval;
891 } 758 }
892 759
893 switch ((lnk_cap & 0x03F0) >> 4){ 760 switch ((lnk_cap & PCI_EXP_LNKSTA_NLW) >> 4){
894 case 0: 761 case 0:
895 lnk_wdth = PCIE_LNK_WIDTH_RESRV; 762 lnk_wdth = PCIE_LNK_WIDTH_RESRV;
896 break; 763 break;
@@ -933,14 +800,14 @@ static int hpc_get_cur_lnk_speed(struct slot *slot, enum pci_bus_speed *value)
933 int retval = 0; 800 int retval = 0;
934 u16 lnk_status; 801 u16 lnk_status;
935 802
936 retval = pciehp_readw(ctrl, LNKSTATUS, &lnk_status); 803 retval = pciehp_readw(ctrl, PCI_EXP_LNKSTA, &lnk_status);
937 if (retval) { 804 if (retval) {
938 ctrl_err(ctrl, "%s: Cannot read LNKSTATUS register\n", 805 ctrl_err(ctrl, "%s: Cannot read LNKSTATUS register\n",
939 __func__); 806 __func__);
940 return retval; 807 return retval;
941 } 808 }
942 809
943 switch (lnk_status & 0x0F) { 810 switch (lnk_status & PCI_EXP_LNKSTA_CLS) {
944 case 1: 811 case 1:
945 lnk_speed = PCIE_2PT5GB; 812 lnk_speed = PCIE_2PT5GB;
946 break; 813 break;
@@ -963,14 +830,14 @@ static int hpc_get_cur_lnk_width(struct slot *slot,
963 int retval = 0; 830 int retval = 0;
964 u16 lnk_status; 831 u16 lnk_status;
965 832
966 retval = pciehp_readw(ctrl, LNKSTATUS, &lnk_status); 833 retval = pciehp_readw(ctrl, PCI_EXP_LNKSTA, &lnk_status);
967 if (retval) { 834 if (retval) {
968 ctrl_err(ctrl, "%s: Cannot read LNKSTATUS register\n", 835 ctrl_err(ctrl, "%s: Cannot read LNKSTATUS register\n",
969 __func__); 836 __func__);
970 return retval; 837 return retval;
971 } 838 }
972 839
973 switch ((lnk_status & 0x03F0) >> 4){ 840 switch ((lnk_status & PCI_EXP_LNKSTA_NLW) >> 4){
974 case 0: 841 case 0:
975 lnk_wdth = PCIE_LNK_WIDTH_RESRV; 842 lnk_wdth = PCIE_LNK_WIDTH_RESRV;
976 break; 843 break;
@@ -1036,18 +903,19 @@ int pcie_enable_notification(struct controller *ctrl)
1036{ 903{
1037 u16 cmd, mask; 904 u16 cmd, mask;
1038 905
1039 cmd = PRSN_DETECT_ENABLE; 906 cmd = PCI_EXP_SLTCTL_PDCE;
1040 if (ATTN_BUTTN(ctrl)) 907 if (ATTN_BUTTN(ctrl))
1041 cmd |= ATTN_BUTTN_ENABLE; 908 cmd |= PCI_EXP_SLTCTL_ABPE;
1042 if (POWER_CTRL(ctrl)) 909 if (POWER_CTRL(ctrl))
1043 cmd |= PWR_FAULT_DETECT_ENABLE; 910 cmd |= PCI_EXP_SLTCTL_PFDE;
1044 if (MRL_SENS(ctrl)) 911 if (MRL_SENS(ctrl))
1045 cmd |= MRL_DETECT_ENABLE; 912 cmd |= PCI_EXP_SLTCTL_MRLSCE;
1046 if (!pciehp_poll_mode) 913 if (!pciehp_poll_mode)
1047 cmd |= HP_INTR_ENABLE | CMD_CMPL_INTR_ENABLE; 914 cmd |= PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_CCIE;
1048 915
1049 mask = PRSN_DETECT_ENABLE | ATTN_BUTTN_ENABLE | MRL_DETECT_ENABLE | 916 mask = (PCI_EXP_SLTCTL_PDCE | PCI_EXP_SLTCTL_ABPE |
1050 PWR_FAULT_DETECT_ENABLE | HP_INTR_ENABLE | CMD_CMPL_INTR_ENABLE; 917 PCI_EXP_SLTCTL_MRLSCE | PCI_EXP_SLTCTL_PFDE |
918 PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_CCIE);
1051 919
1052 if (pcie_write_cmd(ctrl, cmd, mask)) { 920 if (pcie_write_cmd(ctrl, cmd, mask)) {
1053 ctrl_err(ctrl, "Cannot enable software notification\n"); 921 ctrl_err(ctrl, "Cannot enable software notification\n");
@@ -1059,8 +927,9 @@ int pcie_enable_notification(struct controller *ctrl)
1059static void pcie_disable_notification(struct controller *ctrl) 927static void pcie_disable_notification(struct controller *ctrl)
1060{ 928{
1061 u16 mask; 929 u16 mask;
1062 mask = PRSN_DETECT_ENABLE | ATTN_BUTTN_ENABLE | MRL_DETECT_ENABLE | 930 mask = (PCI_EXP_SLTCTL_PDCE | PCI_EXP_SLTCTL_ABPE |
1063 PWR_FAULT_DETECT_ENABLE | HP_INTR_ENABLE | CMD_CMPL_INTR_ENABLE; 931 PCI_EXP_SLTCTL_MRLSCE | PCI_EXP_SLTCTL_PFDE |
932 PCI_EXP_SLTCTL_HPIE | PCI_EXP_SLTCTL_CCIE);
1064 if (pcie_write_cmd(ctrl, 0, mask)) 933 if (pcie_write_cmd(ctrl, 0, mask))
1065 ctrl_warn(ctrl, "Cannot disable software notification\n"); 934 ctrl_warn(ctrl, "Cannot disable software notification\n");
1066} 935}
@@ -1157,9 +1026,9 @@ static inline void dbg_ctrl(struct controller *ctrl)
1157 EMI(ctrl) ? "yes" : "no"); 1026 EMI(ctrl) ? "yes" : "no");
1158 ctrl_info(ctrl, " Command Completed : %3s\n", 1027 ctrl_info(ctrl, " Command Completed : %3s\n",
1159 NO_CMD_CMPL(ctrl) ? "no" : "yes"); 1028 NO_CMD_CMPL(ctrl) ? "no" : "yes");
1160 pciehp_readw(ctrl, SLOTSTATUS, &reg16); 1029 pciehp_readw(ctrl, PCI_EXP_SLTSTA, &reg16);
1161 ctrl_info(ctrl, "Slot Status : 0x%04x\n", reg16); 1030 ctrl_info(ctrl, "Slot Status : 0x%04x\n", reg16);
1162 pciehp_readw(ctrl, SLOTCTRL, &reg16); 1031 pciehp_readw(ctrl, PCI_EXP_SLTCTL, &reg16);
1163 ctrl_info(ctrl, "Slot Control : 0x%04x\n", reg16); 1032 ctrl_info(ctrl, "Slot Control : 0x%04x\n", reg16);
1164} 1033}
1165 1034
@@ -1183,7 +1052,7 @@ struct controller *pcie_init(struct pcie_device *dev)
1183 ctrl_err(ctrl, "Cannot find PCI Express capability\n"); 1052 ctrl_err(ctrl, "Cannot find PCI Express capability\n");
1184 goto abort_ctrl; 1053 goto abort_ctrl;
1185 } 1054 }
1186 if (pciehp_readl(ctrl, SLOTCAP, &slot_cap)) { 1055 if (pciehp_readl(ctrl, PCI_EXP_SLTCAP, &slot_cap)) {
1187 ctrl_err(ctrl, "Cannot read SLOTCAP register\n"); 1056 ctrl_err(ctrl, "Cannot read SLOTCAP register\n");
1188 goto abort_ctrl; 1057 goto abort_ctrl;
1189 } 1058 }
@@ -1208,17 +1077,17 @@ struct controller *pcie_init(struct pcie_device *dev)
1208 ctrl->no_cmd_complete = 1; 1077 ctrl->no_cmd_complete = 1;
1209 1078
1210 /* Check if Data Link Layer Link Active Reporting is implemented */ 1079 /* Check if Data Link Layer Link Active Reporting is implemented */
1211 if (pciehp_readl(ctrl, LNKCAP, &link_cap)) { 1080 if (pciehp_readl(ctrl, PCI_EXP_LNKCAP, &link_cap)) {
1212 ctrl_err(ctrl, "%s: Cannot read LNKCAP register\n", __func__); 1081 ctrl_err(ctrl, "%s: Cannot read LNKCAP register\n", __func__);
1213 goto abort_ctrl; 1082 goto abort_ctrl;
1214 } 1083 }
1215 if (link_cap & LINK_ACTIVE_REPORTING) { 1084 if (link_cap & PCI_EXP_LNKCAP_DLLLARC) {
1216 ctrl_dbg(ctrl, "Link Active Reporting supported\n"); 1085 ctrl_dbg(ctrl, "Link Active Reporting supported\n");
1217 ctrl->link_active_reporting = 1; 1086 ctrl->link_active_reporting = 1;
1218 } 1087 }
1219 1088
1220 /* Clear all remaining event bits in Slot Status register */ 1089 /* Clear all remaining event bits in Slot Status register */
1221 if (pciehp_writew(ctrl, SLOTSTATUS, 0x1f)) 1090 if (pciehp_writew(ctrl, PCI_EXP_SLTSTA, 0x1f))
1222 goto abort_ctrl; 1091 goto abort_ctrl;
1223 1092
1224 /* Disable sotfware notification */ 1093 /* Disable sotfware notification */
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 235fb7a5a8a5..3dfecb20d5e7 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -438,7 +438,8 @@ static struct intel_iommu *device_to_iommu(u8 bus, u8 devfn)
438 continue; 438 continue;
439 439
440 for (i = 0; i < drhd->devices_cnt; i++) 440 for (i = 0; i < drhd->devices_cnt; i++)
441 if (drhd->devices[i]->bus->number == bus && 441 if (drhd->devices[i] &&
442 drhd->devices[i]->bus->number == bus &&
442 drhd->devices[i]->devfn == devfn) 443 drhd->devices[i]->devfn == devfn)
443 return drhd->iommu; 444 return drhd->iommu;
444 445
diff --git a/drivers/pci/irq.c b/drivers/pci/irq.c
index 6441dfa969a3..de01174aff06 100644
--- a/drivers/pci/irq.c
+++ b/drivers/pci/irq.c
@@ -15,7 +15,7 @@ static void pci_note_irq_problem(struct pci_dev *pdev, const char *reason)
15 15
16 dev_printk(KERN_ERR, &pdev->dev, 16 dev_printk(KERN_ERR, &pdev->dev,
17 "Potentially misrouted IRQ (Bridge %s %04x:%04x)\n", 17 "Potentially misrouted IRQ (Bridge %s %04x:%04x)\n",
18 parent->dev.bus_id, parent->vendor, parent->device); 18 dev_name(&parent->dev), parent->vendor, parent->device);
19 dev_printk(KERN_ERR, &pdev->dev, "%s\n", reason); 19 dev_printk(KERN_ERR, &pdev->dev, "%s\n", reason);
20 dev_printk(KERN_ERR, &pdev->dev, "Please report to linux-kernel@vger.kernel.org\n"); 20 dev_printk(KERN_ERR, &pdev->dev, "Please report to linux-kernel@vger.kernel.org\n");
21 WARN_ON(1); 21 WARN_ON(1);
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 11a51f8ed3b3..b4a90badd0a6 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -776,28 +776,19 @@ void pci_no_msi(void)
776 pci_msi_enable = 0; 776 pci_msi_enable = 0;
777} 777}
778 778
779void pci_msi_init_pci_dev(struct pci_dev *dev) 779/**
780{ 780 * pci_msi_enabled - is MSI enabled?
781 INIT_LIST_HEAD(&dev->msi_list); 781 *
782} 782 * Returns true if MSI has not been disabled by the command-line option
783 783 * pci=nomsi.
784#ifdef CONFIG_ACPI 784 **/
785#include <linux/acpi.h> 785int pci_msi_enabled(void)
786#include <linux/pci-acpi.h>
787static void __devinit msi_acpi_init(void)
788{ 786{
789 if (acpi_pci_disabled) 787 return pci_msi_enable;
790 return;
791 pci_osc_support_set(OSC_MSI_SUPPORT);
792 pcie_osc_support_set(OSC_MSI_SUPPORT);
793} 788}
794#else 789EXPORT_SYMBOL(pci_msi_enabled);
795static inline void msi_acpi_init(void) { }
796#endif /* CONFIG_ACPI */
797 790
798void __devinit msi_init(void) 791void pci_msi_init_pci_dev(struct pci_dev *dev)
799{ 792{
800 if (!pci_msi_enable) 793 INIT_LIST_HEAD(&dev->msi_list);
801 return;
802 msi_acpi_init();
803} 794}
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index ae5ec76dca77..deea8a187eb8 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -13,8 +13,6 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/pci-aspm.h> 14#include <linux/pci-aspm.h>
15#include <acpi/acpi.h> 15#include <acpi/acpi.h>
16#include <acpi/acnamesp.h>
17#include <acpi/acresrc.h>
18#include <acpi/acpi_bus.h> 16#include <acpi/acpi_bus.h>
19 17
20#include <linux/pci-acpi.h> 18#include <linux/pci-acpi.h>
@@ -24,13 +22,14 @@ struct acpi_osc_data {
24 acpi_handle handle; 22 acpi_handle handle;
25 u32 support_set; 23 u32 support_set;
26 u32 control_set; 24 u32 control_set;
25 u32 control_query;
26 int is_queried;
27 struct list_head sibiling; 27 struct list_head sibiling;
28}; 28};
29static LIST_HEAD(acpi_osc_data_list); 29static LIST_HEAD(acpi_osc_data_list);
30 30
31struct acpi_osc_args { 31struct acpi_osc_args {
32 u32 capbuf[3]; 32 u32 capbuf[3];
33 u32 ctrl_result;
34}; 33};
35 34
36static DEFINE_MUTEX(pci_acpi_lock); 35static DEFINE_MUTEX(pci_acpi_lock);
@@ -56,7 +55,7 @@ static u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40,
56 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66}; 55 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66};
57 56
58static acpi_status acpi_run_osc(acpi_handle handle, 57static acpi_status acpi_run_osc(acpi_handle handle,
59 struct acpi_osc_args *osc_args) 58 struct acpi_osc_args *osc_args, u32 *retval)
60{ 59{
61 acpi_status status; 60 acpi_status status;
62 struct acpi_object_list input; 61 struct acpi_object_list input;
@@ -112,8 +111,7 @@ static acpi_status acpi_run_osc(acpi_handle handle,
112 goto out_kfree; 111 goto out_kfree;
113 } 112 }
114out_success: 113out_success:
115 osc_args->ctrl_result = 114 *retval = *((u32 *)(out_obj->buffer.pointer + 8));
116 *((u32 *)(out_obj->buffer.pointer + 8));
117 status = AE_OK; 115 status = AE_OK;
118 116
119out_kfree: 117out_kfree:
@@ -121,11 +119,10 @@ out_kfree:
121 return status; 119 return status;
122} 120}
123 121
124static acpi_status __acpi_query_osc(u32 flags, struct acpi_osc_data *osc_data, 122static acpi_status __acpi_query_osc(u32 flags, struct acpi_osc_data *osc_data)
125 u32 *result)
126{ 123{
127 acpi_status status; 124 acpi_status status;
128 u32 support_set; 125 u32 support_set, result;
129 struct acpi_osc_args osc_args; 126 struct acpi_osc_args osc_args;
130 127
131 /* do _OSC query for all possible controls */ 128 /* do _OSC query for all possible controls */
@@ -134,56 +131,45 @@ static acpi_status __acpi_query_osc(u32 flags, struct acpi_osc_data *osc_data,
134 osc_args.capbuf[OSC_SUPPORT_TYPE] = support_set; 131 osc_args.capbuf[OSC_SUPPORT_TYPE] = support_set;
135 osc_args.capbuf[OSC_CONTROL_TYPE] = OSC_CONTROL_MASKS; 132 osc_args.capbuf[OSC_CONTROL_TYPE] = OSC_CONTROL_MASKS;
136 133
137 status = acpi_run_osc(osc_data->handle, &osc_args); 134 status = acpi_run_osc(osc_data->handle, &osc_args, &result);
138 if (ACPI_SUCCESS(status)) { 135 if (ACPI_SUCCESS(status)) {
139 osc_data->support_set = support_set; 136 osc_data->support_set = support_set;
140 *result = osc_args.ctrl_result; 137 osc_data->control_query = result;
138 osc_data->is_queried = 1;
141 } 139 }
142 140
143 return status; 141 return status;
144} 142}
145 143
146static acpi_status acpi_query_osc(acpi_handle handle, 144/*
147 u32 level, void *context, void **retval) 145 * pci_acpi_osc_support: Invoke _OSC indicating support for the given feature
146 * @flags: Bitmask of flags to support
147 *
148 * See the ACPI spec for the definition of the flags
149 */
150int pci_acpi_osc_support(acpi_handle handle, u32 flags)
148{ 151{
149 acpi_status status; 152 acpi_status status;
150 struct acpi_osc_data *osc_data;
151 u32 flags = (unsigned long)context, dummy;
152 acpi_handle tmp; 153 acpi_handle tmp;
154 struct acpi_osc_data *osc_data;
155 int rc = 0;
153 156
154 status = acpi_get_handle(handle, "_OSC", &tmp); 157 status = acpi_get_handle(handle, "_OSC", &tmp);
155 if (ACPI_FAILURE(status)) 158 if (ACPI_FAILURE(status))
156 return AE_OK; 159 return -ENOTTY;
157 160
158 mutex_lock(&pci_acpi_lock); 161 mutex_lock(&pci_acpi_lock);
159 osc_data = acpi_get_osc_data(handle); 162 osc_data = acpi_get_osc_data(handle);
160 if (!osc_data) { 163 if (!osc_data) {
161 printk(KERN_ERR "acpi osc data array is full\n"); 164 printk(KERN_ERR "acpi osc data array is full\n");
165 rc = -ENOMEM;
162 goto out; 166 goto out;
163 } 167 }
164 168
165 __acpi_query_osc(flags, osc_data, &dummy); 169 __acpi_query_osc(flags, osc_data);
166out: 170out:
167 mutex_unlock(&pci_acpi_lock); 171 mutex_unlock(&pci_acpi_lock);
168 return AE_OK; 172 return rc;
169}
170
171/**
172 * __pci_osc_support_set - register OS support to Firmware
173 * @flags: OS support bits
174 * @hid: hardware ID
175 *
176 * Update OS support fields and doing a _OSC Query to obtain an update
177 * from Firmware on supported control bits.
178 **/
179acpi_status __pci_osc_support_set(u32 flags, const char *hid)
180{
181 if (!(flags & OSC_SUPPORT_MASKS))
182 return AE_TYPE;
183
184 acpi_get_devices(hid, acpi_query_osc,
185 (void *)(unsigned long)flags, NULL);
186 return AE_OK;
187} 173}
188 174
189/** 175/**
@@ -196,7 +182,7 @@ acpi_status __pci_osc_support_set(u32 flags, const char *hid)
196acpi_status pci_osc_control_set(acpi_handle handle, u32 flags) 182acpi_status pci_osc_control_set(acpi_handle handle, u32 flags)
197{ 183{
198 acpi_status status; 184 acpi_status status;
199 u32 ctrlset, control_set, result; 185 u32 control_req, control_set, result;
200 acpi_handle tmp; 186 acpi_handle tmp;
201 struct acpi_osc_data *osc_data; 187 struct acpi_osc_data *osc_data;
202 struct acpi_osc_args osc_args; 188 struct acpi_osc_args osc_args;
@@ -213,28 +199,34 @@ acpi_status pci_osc_control_set(acpi_handle handle, u32 flags)
213 goto out; 199 goto out;
214 } 200 }
215 201
216 ctrlset = (flags & OSC_CONTROL_MASKS); 202 control_req = (flags & OSC_CONTROL_MASKS);
217 if (!ctrlset) { 203 if (!control_req) {
218 status = AE_TYPE; 204 status = AE_TYPE;
219 goto out; 205 goto out;
220 } 206 }
221 207
222 status = __acpi_query_osc(osc_data->support_set, osc_data, &result); 208 /* No need to evaluate _OSC if the control was already granted. */
223 if (ACPI_FAILURE(status)) 209 if ((osc_data->control_set & control_req) == control_req)
224 goto out; 210 goto out;
225 211
226 if ((result & ctrlset) != ctrlset) { 212 if (!osc_data->is_queried) {
213 status = __acpi_query_osc(osc_data->support_set, osc_data);
214 if (ACPI_FAILURE(status))
215 goto out;
216 }
217
218 if ((osc_data->control_query & control_req) != control_req) {
227 status = AE_SUPPORT; 219 status = AE_SUPPORT;
228 goto out; 220 goto out;
229 } 221 }
230 222
231 control_set = osc_data->control_set | ctrlset; 223 control_set = osc_data->control_set | control_req;
232 osc_args.capbuf[OSC_QUERY_TYPE] = 0; 224 osc_args.capbuf[OSC_QUERY_TYPE] = 0;
233 osc_args.capbuf[OSC_SUPPORT_TYPE] = osc_data->support_set; 225 osc_args.capbuf[OSC_SUPPORT_TYPE] = osc_data->support_set;
234 osc_args.capbuf[OSC_CONTROL_TYPE] = control_set; 226 osc_args.capbuf[OSC_CONTROL_TYPE] = control_set;
235 status = acpi_run_osc(handle, &osc_args); 227 status = acpi_run_osc(handle, &osc_args, &result);
236 if (ACPI_SUCCESS(status)) 228 if (ACPI_SUCCESS(status))
237 osc_data->control_set = control_set; 229 osc_data->control_set = result;
238out: 230out:
239 mutex_unlock(&pci_acpi_lock); 231 mutex_unlock(&pci_acpi_lock);
240 return status; 232 return status;
@@ -375,7 +367,7 @@ static int acpi_pci_find_root_bridge(struct device *dev, acpi_handle *handle)
375 * The string should be the same as root bridge's name 367 * The string should be the same as root bridge's name
376 * Please look at 'pci_scan_bus_parented' 368 * Please look at 'pci_scan_bus_parented'
377 */ 369 */
378 num = sscanf(dev->bus_id, "pci%04x:%02x", &seg, &bus); 370 num = sscanf(dev_name(dev), "pci%04x:%02x", &seg, &bus);
379 if (num != 2) 371 if (num != 2)
380 return -ENODEV; 372 return -ENODEV;
381 *handle = acpi_get_pci_rootbridge_handle(seg, bus); 373 *handle = acpi_get_pci_rootbridge_handle(seg, bus);
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 99d867bcf22a..c697f2680856 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -16,6 +16,7 @@
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/sched.h> 18#include <linux/sched.h>
19#include <linux/cpu.h>
19#include "pci.h" 20#include "pci.h"
20 21
21/* 22/*
@@ -48,7 +49,7 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count)
48 subdevice=PCI_ANY_ID, class=0, class_mask=0; 49 subdevice=PCI_ANY_ID, class=0, class_mask=0;
49 unsigned long driver_data=0; 50 unsigned long driver_data=0;
50 int fields=0; 51 int fields=0;
51 int retval; 52 int retval=0;
52 53
53 fields = sscanf(buf, "%x %x %x %x %x %x %lx", 54 fields = sscanf(buf, "%x %x %x %x %x %x %lx",
54 &vendor, &device, &subvendor, &subdevice, 55 &vendor, &device, &subvendor, &subdevice,
@@ -58,16 +59,18 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count)
58 59
59 /* Only accept driver_data values that match an existing id_table 60 /* Only accept driver_data values that match an existing id_table
60 entry */ 61 entry */
61 retval = -EINVAL; 62 if (ids) {
62 while (ids->vendor || ids->subvendor || ids->class_mask) { 63 retval = -EINVAL;
63 if (driver_data == ids->driver_data) { 64 while (ids->vendor || ids->subvendor || ids->class_mask) {
64 retval = 0; 65 if (driver_data == ids->driver_data) {
65 break; 66 retval = 0;
67 break;
68 }
69 ids++;
66 } 70 }
67 ids++; 71 if (retval) /* No match */
72 return retval;
68 } 73 }
69 if (retval) /* No match */
70 return retval;
71 74
72 dynid = kzalloc(sizeof(*dynid), GFP_KERNEL); 75 dynid = kzalloc(sizeof(*dynid), GFP_KERNEL);
73 if (!dynid) 76 if (!dynid)
@@ -183,32 +186,43 @@ static const struct pci_device_id *pci_match_device(struct pci_driver *drv,
183 return pci_match_id(drv->id_table, dev); 186 return pci_match_id(drv->id_table, dev);
184} 187}
185 188
189struct drv_dev_and_id {
190 struct pci_driver *drv;
191 struct pci_dev *dev;
192 const struct pci_device_id *id;
193};
194
195static long local_pci_probe(void *_ddi)
196{
197 struct drv_dev_and_id *ddi = _ddi;
198
199 return ddi->drv->probe(ddi->dev, ddi->id);
200}
201
186static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev, 202static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
187 const struct pci_device_id *id) 203 const struct pci_device_id *id)
188{ 204{
189 int error; 205 int error, node;
190#ifdef CONFIG_NUMA 206 struct drv_dev_and_id ddi = { drv, dev, id };
191 /* Execute driver initialization on node where the
192 device's bus is attached to. This way the driver likely
193 allocates its local memory on the right node without
194 any need to change it. */
195 struct mempolicy *oldpol;
196 cpumask_t oldmask = current->cpus_allowed;
197 int node = dev_to_node(&dev->dev);
198 207
208 /* Execute driver initialization on node where the device's
209 bus is attached to. This way the driver likely allocates
210 its local memory on the right node without any need to
211 change it. */
212 node = dev_to_node(&dev->dev);
199 if (node >= 0) { 213 if (node >= 0) {
214 int cpu;
200 node_to_cpumask_ptr(nodecpumask, node); 215 node_to_cpumask_ptr(nodecpumask, node);
201 set_cpus_allowed_ptr(current, nodecpumask); 216
202 } 217 get_online_cpus();
203 /* And set default memory allocation policy */ 218 cpu = cpumask_any_and(nodecpumask, cpu_online_mask);
204 oldpol = current->mempolicy; 219 if (cpu < nr_cpu_ids)
205 current->mempolicy = NULL; /* fall back to system default policy */ 220 error = work_on_cpu(cpu, local_pci_probe, &ddi);
206#endif 221 else
207 error = drv->probe(dev, id); 222 error = local_pci_probe(&ddi);
208#ifdef CONFIG_NUMA 223 put_online_cpus();
209 set_cpus_allowed_ptr(current, &oldmask); 224 } else
210 current->mempolicy = oldpol; 225 error = local_pci_probe(&ddi);
211#endif
212 return error; 226 return error;
213} 227}
214 228
@@ -300,21 +314,12 @@ static void pci_device_shutdown(struct device *dev)
300 314
301#ifdef CONFIG_PM_SLEEP 315#ifdef CONFIG_PM_SLEEP
302 316
303static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev)
304{
305 struct pci_driver *drv = pci_dev->driver;
306
307 return drv && (drv->suspend || drv->suspend_late || drv->resume
308 || drv->resume_early);
309}
310
311/* 317/*
312 * Default "suspend" method for devices that have no driver provided suspend, 318 * Default "suspend" method for devices that have no driver provided suspend,
313 * or not even a driver at all. 319 * or not even a driver at all (second part).
314 */ 320 */
315static void pci_default_pm_suspend(struct pci_dev *pci_dev) 321static void pci_pm_set_unknown_state(struct pci_dev *pci_dev)
316{ 322{
317 pci_save_state(pci_dev);
318 /* 323 /*
319 * mark its power state as "unknown", since we don't know if 324 * mark its power state as "unknown", since we don't know if
320 * e.g. the BIOS will change its device state when we suspend. 325 * e.g. the BIOS will change its device state when we suspend.
@@ -325,19 +330,9 @@ static void pci_default_pm_suspend(struct pci_dev *pci_dev)
325 330
326/* 331/*
327 * Default "resume" method for devices that have no driver provided resume, 332 * Default "resume" method for devices that have no driver provided resume,
328 * or not even a driver at all (first part).
329 */
330static void pci_default_pm_resume_early(struct pci_dev *pci_dev)
331{
332 /* restore the PCI config space */
333 pci_restore_state(pci_dev);
334}
335
336/*
337 * Default "resume" method for devices that have no driver provided resume,
338 * or not even a driver at all (second part). 333 * or not even a driver at all (second part).
339 */ 334 */
340static int pci_default_pm_resume_late(struct pci_dev *pci_dev) 335static int pci_pm_reenable_device(struct pci_dev *pci_dev)
341{ 336{
342 int retval; 337 int retval;
343 338
@@ -363,8 +358,16 @@ static int pci_legacy_suspend(struct device *dev, pm_message_t state)
363 i = drv->suspend(pci_dev, state); 358 i = drv->suspend(pci_dev, state);
364 suspend_report_result(drv->suspend, i); 359 suspend_report_result(drv->suspend, i);
365 } else { 360 } else {
366 pci_default_pm_suspend(pci_dev); 361 pci_save_state(pci_dev);
362 /*
363 * This is for compatibility with existing code with legacy PM
364 * support.
365 */
366 pci_pm_set_unknown_state(pci_dev);
367 } 367 }
368
369 pci_fixup_device(pci_fixup_suspend, pci_dev);
370
368 return i; 371 return i;
369} 372}
370 373
@@ -381,32 +384,130 @@ static int pci_legacy_suspend_late(struct device *dev, pm_message_t state)
381 return i; 384 return i;
382} 385}
383 386
387static int pci_legacy_resume_early(struct device *dev)
388{
389 int error = 0;
390 struct pci_dev * pci_dev = to_pci_dev(dev);
391 struct pci_driver * drv = pci_dev->driver;
392
393 pci_fixup_device(pci_fixup_resume_early, pci_dev);
394
395 if (drv && drv->resume_early)
396 error = drv->resume_early(pci_dev);
397 return error;
398}
399
384static int pci_legacy_resume(struct device *dev) 400static int pci_legacy_resume(struct device *dev)
385{ 401{
386 int error; 402 int error;
387 struct pci_dev * pci_dev = to_pci_dev(dev); 403 struct pci_dev * pci_dev = to_pci_dev(dev);
388 struct pci_driver * drv = pci_dev->driver; 404 struct pci_driver * drv = pci_dev->driver;
389 405
406 pci_fixup_device(pci_fixup_resume, pci_dev);
407
390 if (drv && drv->resume) { 408 if (drv && drv->resume) {
391 error = drv->resume(pci_dev); 409 error = drv->resume(pci_dev);
392 } else { 410 } else {
393 pci_default_pm_resume_early(pci_dev); 411 /* restore the PCI config space */
394 error = pci_default_pm_resume_late(pci_dev); 412 pci_restore_state(pci_dev);
413 error = pci_pm_reenable_device(pci_dev);
395 } 414 }
396 return error; 415 return error;
397} 416}
398 417
399static int pci_legacy_resume_early(struct device *dev) 418/* Auxiliary functions used by the new power management framework */
419
420static int pci_restore_standard_config(struct pci_dev *pci_dev)
400{ 421{
422 struct pci_dev *parent = pci_dev->bus->self;
401 int error = 0; 423 int error = 0;
402 struct pci_dev * pci_dev = to_pci_dev(dev);
403 struct pci_driver * drv = pci_dev->driver;
404 424
405 if (drv && drv->resume_early) 425 /* Check if the device's bus is operational */
406 error = drv->resume_early(pci_dev); 426 if (!parent || parent->current_state == PCI_D0) {
427 pci_restore_state(pci_dev);
428 pci_update_current_state(pci_dev, PCI_D0);
429 } else {
430 dev_warn(&pci_dev->dev, "unable to restore config, "
431 "bridge %s in low power state D%d\n", pci_name(parent),
432 parent->current_state);
433 pci_dev->current_state = PCI_UNKNOWN;
434 error = -EAGAIN;
435 }
436
407 return error; 437 return error;
408} 438}
409 439
440static bool pci_is_bridge(struct pci_dev *pci_dev)
441{
442 return !!(pci_dev->subordinate);
443}
444
445static void pci_pm_default_resume_noirq(struct pci_dev *pci_dev)
446{
447 if (pci_restore_standard_config(pci_dev))
448 pci_fixup_device(pci_fixup_resume_early, pci_dev);
449}
450
451static int pci_pm_default_resume(struct pci_dev *pci_dev)
452{
453 /*
454 * pci_restore_standard_config() should have been called once already,
455 * but it would have failed if the device's parent bridge had not been
456 * in power state D0 at that time. Check it and try again if necessary.
457 */
458 if (pci_dev->current_state == PCI_UNKNOWN) {
459 int error = pci_restore_standard_config(pci_dev);
460 if (error)
461 return error;
462 }
463
464 pci_fixup_device(pci_fixup_resume, pci_dev);
465
466 if (!pci_is_bridge(pci_dev))
467 pci_enable_wake(pci_dev, PCI_D0, false);
468
469 return pci_pm_reenable_device(pci_dev);
470}
471
472static void pci_pm_default_suspend_generic(struct pci_dev *pci_dev)
473{
474 /* If device is enabled at this point, disable it */
475 pci_disable_enabled_device(pci_dev);
476 /*
477 * Save state with interrupts enabled, because in principle the bus the
478 * device is on may be put into a low power state after this code runs.
479 */
480 pci_save_state(pci_dev);
481}
482
483static void pci_pm_default_suspend(struct pci_dev *pci_dev)
484{
485 pci_pm_default_suspend_generic(pci_dev);
486
487 if (!pci_is_bridge(pci_dev))
488 pci_prepare_to_sleep(pci_dev);
489
490 pci_fixup_device(pci_fixup_suspend, pci_dev);
491}
492
493static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev)
494{
495 struct pci_driver *drv = pci_dev->driver;
496 bool ret = drv && (drv->suspend || drv->suspend_late || drv->resume
497 || drv->resume_early);
498
499 /*
500 * Legacy PM support is used by default, so warn if the new framework is
501 * supported as well. Drivers are supposed to support either the
502 * former, or the latter, but not both at the same time.
503 */
504 WARN_ON(ret && drv->driver.pm);
505
506 return ret;
507}
508
509/* New power management framework */
510
410static int pci_pm_prepare(struct device *dev) 511static int pci_pm_prepare(struct device *dev)
411{ 512{
412 struct device_driver *drv = dev->driver; 513 struct device_driver *drv = dev->driver;
@@ -434,15 +535,16 @@ static int pci_pm_suspend(struct device *dev)
434 struct device_driver *drv = dev->driver; 535 struct device_driver *drv = dev->driver;
435 int error = 0; 536 int error = 0;
436 537
437 if (drv && drv->pm) { 538 if (pci_has_legacy_pm_support(pci_dev))
438 if (drv->pm->suspend) { 539 return pci_legacy_suspend(dev, PMSG_SUSPEND);
439 error = drv->pm->suspend(dev); 540
440 suspend_report_result(drv->pm->suspend, error); 541 if (drv && drv->pm && drv->pm->suspend) {
441 } 542 error = drv->pm->suspend(dev);
442 } else if (pci_has_legacy_pm_support(pci_dev)) { 543 suspend_report_result(drv->pm->suspend, error);
443 error = pci_legacy_suspend(dev, PMSG_SUSPEND);
444 } 544 }
445 pci_fixup_device(pci_fixup_suspend, pci_dev); 545
546 if (!error)
547 pci_pm_default_suspend(pci_dev);
446 548
447 return error; 549 return error;
448} 550}
@@ -453,56 +555,50 @@ static int pci_pm_suspend_noirq(struct device *dev)
453 struct device_driver *drv = dev->driver; 555 struct device_driver *drv = dev->driver;
454 int error = 0; 556 int error = 0;
455 557
456 if (drv && drv->pm) { 558 if (pci_has_legacy_pm_support(pci_dev))
457 if (drv->pm->suspend_noirq) { 559 return pci_legacy_suspend_late(dev, PMSG_SUSPEND);
458 error = drv->pm->suspend_noirq(dev); 560
459 suspend_report_result(drv->pm->suspend_noirq, error); 561 if (drv && drv->pm && drv->pm->suspend_noirq) {
460 } 562 error = drv->pm->suspend_noirq(dev);
461 } else if (pci_has_legacy_pm_support(pci_dev)) { 563 suspend_report_result(drv->pm->suspend_noirq, error);
462 error = pci_legacy_suspend_late(dev, PMSG_SUSPEND);
463 } else {
464 pci_default_pm_suspend(pci_dev);
465 } 564 }
466 565
566 if (!error)
567 pci_pm_set_unknown_state(pci_dev);
568
467 return error; 569 return error;
468} 570}
469 571
470static int pci_pm_resume(struct device *dev) 572static int pci_pm_resume_noirq(struct device *dev)
471{ 573{
472 struct pci_dev *pci_dev = to_pci_dev(dev); 574 struct pci_dev *pci_dev = to_pci_dev(dev);
473 struct device_driver *drv = dev->driver; 575 struct device_driver *drv = dev->driver;
474 int error = 0; 576 int error = 0;
475 577
476 pci_fixup_device(pci_fixup_resume, pci_dev); 578 if (pci_has_legacy_pm_support(pci_dev))
579 return pci_legacy_resume_early(dev);
477 580
478 if (drv && drv->pm) { 581 pci_pm_default_resume_noirq(pci_dev);
479 if (drv->pm->resume) 582
480 error = drv->pm->resume(dev); 583 if (drv && drv->pm && drv->pm->resume_noirq)
481 } else if (pci_has_legacy_pm_support(pci_dev)) { 584 error = drv->pm->resume_noirq(dev);
482 error = pci_legacy_resume(dev);
483 } else {
484 error = pci_default_pm_resume_late(pci_dev);
485 }
486 585
487 return error; 586 return error;
488} 587}
489 588
490static int pci_pm_resume_noirq(struct device *dev) 589static int pci_pm_resume(struct device *dev)
491{ 590{
492 struct pci_dev *pci_dev = to_pci_dev(dev); 591 struct pci_dev *pci_dev = to_pci_dev(dev);
493 struct device_driver *drv = dev->driver; 592 struct device_driver *drv = dev->driver;
494 int error = 0; 593 int error = 0;
495 594
496 pci_fixup_device(pci_fixup_resume_early, to_pci_dev(dev)); 595 if (pci_has_legacy_pm_support(pci_dev))
596 return pci_legacy_resume(dev);
497 597
498 if (drv && drv->pm) { 598 error = pci_pm_default_resume(pci_dev);
499 if (drv->pm->resume_noirq) 599
500 error = drv->pm->resume_noirq(dev); 600 if (!error && drv && drv->pm && drv->pm->resume)
501 } else if (pci_has_legacy_pm_support(pci_dev)) { 601 error = drv->pm->resume(dev);
502 error = pci_legacy_resume_early(dev);
503 } else {
504 pci_default_pm_resume_early(pci_dev);
505 }
506 602
507 return error; 603 return error;
508} 604}
@@ -524,16 +620,17 @@ static int pci_pm_freeze(struct device *dev)
524 struct device_driver *drv = dev->driver; 620 struct device_driver *drv = dev->driver;
525 int error = 0; 621 int error = 0;
526 622
527 if (drv && drv->pm) { 623 if (pci_has_legacy_pm_support(pci_dev))
528 if (drv->pm->freeze) { 624 return pci_legacy_suspend(dev, PMSG_FREEZE);
529 error = drv->pm->freeze(dev); 625
530 suspend_report_result(drv->pm->freeze, error); 626 if (drv && drv->pm && drv->pm->freeze) {
531 } 627 error = drv->pm->freeze(dev);
532 } else if (pci_has_legacy_pm_support(pci_dev)) { 628 suspend_report_result(drv->pm->freeze, error);
533 error = pci_legacy_suspend(dev, PMSG_FREEZE);
534 pci_fixup_device(pci_fixup_suspend, pci_dev);
535 } 629 }
536 630
631 if (!error)
632 pci_pm_default_suspend_generic(pci_dev);
633
537 return error; 634 return error;
538} 635}
539 636
@@ -543,50 +640,50 @@ static int pci_pm_freeze_noirq(struct device *dev)
543 struct device_driver *drv = dev->driver; 640 struct device_driver *drv = dev->driver;
544 int error = 0; 641 int error = 0;
545 642
546 if (drv && drv->pm) { 643 if (pci_has_legacy_pm_support(pci_dev))
547 if (drv->pm->freeze_noirq) { 644 return pci_legacy_suspend_late(dev, PMSG_FREEZE);
548 error = drv->pm->freeze_noirq(dev); 645
549 suspend_report_result(drv->pm->freeze_noirq, error); 646 if (drv && drv->pm && drv->pm->freeze_noirq) {
550 } 647 error = drv->pm->freeze_noirq(dev);
551 } else if (pci_has_legacy_pm_support(pci_dev)) { 648 suspend_report_result(drv->pm->freeze_noirq, error);
552 error = pci_legacy_suspend_late(dev, PMSG_FREEZE);
553 } else {
554 pci_default_pm_suspend(pci_dev);
555 } 649 }
556 650
651 if (!error)
652 pci_pm_set_unknown_state(pci_dev);
653
557 return error; 654 return error;
558} 655}
559 656
560static int pci_pm_thaw(struct device *dev) 657static int pci_pm_thaw_noirq(struct device *dev)
561{ 658{
562 struct pci_dev *pci_dev = to_pci_dev(dev); 659 struct pci_dev *pci_dev = to_pci_dev(dev);
563 struct device_driver *drv = dev->driver; 660 struct device_driver *drv = dev->driver;
564 int error = 0; 661 int error = 0;
565 662
566 if (drv && drv->pm) { 663 if (pci_has_legacy_pm_support(pci_dev))
567 if (drv->pm->thaw) 664 return pci_legacy_resume_early(dev);
568 error = drv->pm->thaw(dev); 665
569 } else if (pci_has_legacy_pm_support(pci_dev)) { 666 pci_update_current_state(pci_dev, PCI_D0);
570 pci_fixup_device(pci_fixup_resume, pci_dev); 667
571 error = pci_legacy_resume(dev); 668 if (drv && drv->pm && drv->pm->thaw_noirq)
572 } 669 error = drv->pm->thaw_noirq(dev);
573 670
574 return error; 671 return error;
575} 672}
576 673
577static int pci_pm_thaw_noirq(struct device *dev) 674static int pci_pm_thaw(struct device *dev)
578{ 675{
579 struct pci_dev *pci_dev = to_pci_dev(dev); 676 struct pci_dev *pci_dev = to_pci_dev(dev);
580 struct device_driver *drv = dev->driver; 677 struct device_driver *drv = dev->driver;
581 int error = 0; 678 int error = 0;
582 679
583 if (drv && drv->pm) { 680 if (pci_has_legacy_pm_support(pci_dev))
584 if (drv->pm->thaw_noirq) 681 return pci_legacy_resume(dev);
585 error = drv->pm->thaw_noirq(dev); 682
586 } else if (pci_has_legacy_pm_support(pci_dev)) { 683 pci_pm_reenable_device(pci_dev);
587 pci_fixup_device(pci_fixup_resume_early, to_pci_dev(dev)); 684
588 error = pci_legacy_resume_early(dev); 685 if (drv && drv->pm && drv->pm->thaw)
589 } 686 error = drv->pm->thaw(dev);
590 687
591 return error; 688 return error;
592} 689}
@@ -597,17 +694,17 @@ static int pci_pm_poweroff(struct device *dev)
597 struct device_driver *drv = dev->driver; 694 struct device_driver *drv = dev->driver;
598 int error = 0; 695 int error = 0;
599 696
600 pci_fixup_device(pci_fixup_suspend, pci_dev); 697 if (pci_has_legacy_pm_support(pci_dev))
698 return pci_legacy_suspend(dev, PMSG_HIBERNATE);
601 699
602 if (drv && drv->pm) { 700 if (drv && drv->pm && drv->pm->poweroff) {
603 if (drv->pm->poweroff) { 701 error = drv->pm->poweroff(dev);
604 error = drv->pm->poweroff(dev); 702 suspend_report_result(drv->pm->poweroff, error);
605 suspend_report_result(drv->pm->poweroff, error);
606 }
607 } else if (pci_has_legacy_pm_support(pci_dev)) {
608 error = pci_legacy_suspend(dev, PMSG_HIBERNATE);
609 } 703 }
610 704
705 if (!error)
706 pci_pm_default_suspend(pci_dev);
707
611 return error; 708 return error;
612} 709}
613 710
@@ -616,54 +713,47 @@ static int pci_pm_poweroff_noirq(struct device *dev)
616 struct device_driver *drv = dev->driver; 713 struct device_driver *drv = dev->driver;
617 int error = 0; 714 int error = 0;
618 715
619 if (drv && drv->pm) { 716 if (pci_has_legacy_pm_support(to_pci_dev(dev)))
620 if (drv->pm->poweroff_noirq) { 717 return pci_legacy_suspend_late(dev, PMSG_HIBERNATE);
621 error = drv->pm->poweroff_noirq(dev); 718
622 suspend_report_result(drv->pm->poweroff_noirq, error); 719 if (drv && drv->pm && drv->pm->poweroff_noirq) {
623 } 720 error = drv->pm->poweroff_noirq(dev);
624 } else if (pci_has_legacy_pm_support(to_pci_dev(dev))) { 721 suspend_report_result(drv->pm->poweroff_noirq, error);
625 error = pci_legacy_suspend_late(dev, PMSG_HIBERNATE);
626 } 722 }
627 723
628 return error; 724 return error;
629} 725}
630 726
631static int pci_pm_restore(struct device *dev) 727static int pci_pm_restore_noirq(struct device *dev)
632{ 728{
633 struct pci_dev *pci_dev = to_pci_dev(dev); 729 struct pci_dev *pci_dev = to_pci_dev(dev);
634 struct device_driver *drv = dev->driver; 730 struct device_driver *drv = dev->driver;
635 int error = 0; 731 int error = 0;
636 732
637 if (drv && drv->pm) { 733 if (pci_has_legacy_pm_support(pci_dev))
638 if (drv->pm->restore) 734 return pci_legacy_resume_early(dev);
639 error = drv->pm->restore(dev); 735
640 } else if (pci_has_legacy_pm_support(pci_dev)) { 736 pci_pm_default_resume_noirq(pci_dev);
641 error = pci_legacy_resume(dev); 737
642 } else { 738 if (drv && drv->pm && drv->pm->restore_noirq)
643 error = pci_default_pm_resume_late(pci_dev); 739 error = drv->pm->restore_noirq(dev);
644 }
645 pci_fixup_device(pci_fixup_resume, pci_dev);
646 740
647 return error; 741 return error;
648} 742}
649 743
650static int pci_pm_restore_noirq(struct device *dev) 744static int pci_pm_restore(struct device *dev)
651{ 745{
652 struct pci_dev *pci_dev = to_pci_dev(dev); 746 struct pci_dev *pci_dev = to_pci_dev(dev);
653 struct device_driver *drv = dev->driver; 747 struct device_driver *drv = dev->driver;
654 int error = 0; 748 int error = 0;
655 749
656 pci_fixup_device(pci_fixup_resume, pci_dev); 750 if (pci_has_legacy_pm_support(pci_dev))
751 return pci_legacy_resume(dev);
657 752
658 if (drv && drv->pm) { 753 error = pci_pm_default_resume(pci_dev);
659 if (drv->pm->restore_noirq) 754
660 error = drv->pm->restore_noirq(dev); 755 if (!error && drv && drv->pm && drv->pm->restore)
661 } else if (pci_has_legacy_pm_support(pci_dev)) { 756 error = drv->pm->restore(dev);
662 error = pci_legacy_resume_early(dev);
663 } else {
664 pci_default_pm_resume_early(pci_dev);
665 }
666 pci_fixup_device(pci_fixup_resume_early, pci_dev);
667 757
668 return error; 758 return error;
669} 759}
diff --git a/drivers/pci/pci-stub.c b/drivers/pci/pci-stub.c
new file mode 100644
index 000000000000..74fbec0bf6cb
--- /dev/null
+++ b/drivers/pci/pci-stub.c
@@ -0,0 +1,47 @@
1/* pci-stub - simple stub driver to reserve a pci device
2 *
3 * Copyright (C) 2008 Red Hat, Inc.
4 * Author:
5 * Chris Wright
6 *
7 * This work is licensed under the terms of the GNU GPL, version 2.
8 *
9 * Usage is simple, allocate a new id to the stub driver and bind the
10 * device to it. For example:
11 *
12 * # echo "8086 10f5" > /sys/bus/pci/drivers/pci-stub/new_id
13 * # echo -n 0000:00:19.0 > /sys/bus/pci/drivers/e1000e/unbind
14 * # echo -n 0000:00:19.0 > /sys/bus/pci/drivers/pci-stub/bind
15 * # ls -l /sys/bus/pci/devices/0000:00:19.0/driver
16 * .../0000:00:19.0/driver -> ../../../bus/pci/drivers/pci-stub
17 */
18
19#include <linux/module.h>
20#include <linux/pci.h>
21
22static int pci_stub_probe(struct pci_dev *dev, const struct pci_device_id *id)
23{
24 return 0;
25}
26
27static struct pci_driver stub_driver = {
28 .name = "pci-stub",
29 .id_table = NULL, /* only dynamic id's */
30 .probe = pci_stub_probe,
31};
32
33static int __init pci_stub_init(void)
34{
35 return pci_register_driver(&stub_driver);
36}
37
38static void __exit pci_stub_exit(void)
39{
40 pci_unregister_driver(&stub_driver);
41}
42
43module_init(pci_stub_init);
44module_exit(pci_stub_exit);
45
46MODULE_LICENSE("GPL");
47MODULE_AUTHOR("Chris Wright <chrisw@sous-sol.org>");
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index c88485860a0a..db7ec14fa719 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -58,23 +58,24 @@ static ssize_t broken_parity_status_store(struct device *dev,
58 const char *buf, size_t count) 58 const char *buf, size_t count)
59{ 59{
60 struct pci_dev *pdev = to_pci_dev(dev); 60 struct pci_dev *pdev = to_pci_dev(dev);
61 ssize_t consumed = -EINVAL; 61 unsigned long val;
62 62
63 if ((count > 0) && (*buf == '0' || *buf == '1')) { 63 if (strict_strtoul(buf, 0, &val) < 0)
64 pdev->broken_parity_status = *buf == '1' ? 1 : 0; 64 return -EINVAL;
65 consumed = count; 65
66 } 66 pdev->broken_parity_status = !!val;
67 return consumed; 67
68 return count;
68} 69}
69 70
70static ssize_t local_cpus_show(struct device *dev, 71static ssize_t local_cpus_show(struct device *dev,
71 struct device_attribute *attr, char *buf) 72 struct device_attribute *attr, char *buf)
72{ 73{
73 cpumask_t mask; 74 const struct cpumask *mask;
74 int len; 75 int len;
75 76
76 mask = pcibus_to_cpumask(to_pci_dev(dev)->bus); 77 mask = cpumask_of_pcibus(to_pci_dev(dev)->bus);
77 len = cpumask_scnprintf(buf, PAGE_SIZE-2, &mask); 78 len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask);
78 buf[len++] = '\n'; 79 buf[len++] = '\n';
79 buf[len] = '\0'; 80 buf[len] = '\0';
80 return len; 81 return len;
@@ -84,11 +85,11 @@ static ssize_t local_cpus_show(struct device *dev,
84static ssize_t local_cpulist_show(struct device *dev, 85static ssize_t local_cpulist_show(struct device *dev,
85 struct device_attribute *attr, char *buf) 86 struct device_attribute *attr, char *buf)
86{ 87{
87 cpumask_t mask; 88 const struct cpumask *mask;
88 int len; 89 int len;
89 90
90 mask = pcibus_to_cpumask(to_pci_dev(dev)->bus); 91 mask = cpumask_of_pcibus(to_pci_dev(dev)->bus);
91 len = cpulist_scnprintf(buf, PAGE_SIZE-2, &mask); 92 len = cpulist_scnprintf(buf, PAGE_SIZE-2, mask);
92 buf[len++] = '\n'; 93 buf[len++] = '\n';
93 buf[len] = '\0'; 94 buf[len] = '\0';
94 return len; 95 return len;
@@ -101,11 +102,13 @@ resource_show(struct device * dev, struct device_attribute *attr, char * buf)
101 struct pci_dev * pci_dev = to_pci_dev(dev); 102 struct pci_dev * pci_dev = to_pci_dev(dev);
102 char * str = buf; 103 char * str = buf;
103 int i; 104 int i;
104 int max = 7; 105 int max;
105 resource_size_t start, end; 106 resource_size_t start, end;
106 107
107 if (pci_dev->subordinate) 108 if (pci_dev->subordinate)
108 max = DEVICE_COUNT_RESOURCE; 109 max = DEVICE_COUNT_RESOURCE;
110 else
111 max = PCI_BRIDGE_RESOURCES;
109 112
110 for (i = 0; i < max; i++) { 113 for (i = 0; i < max; i++) {
111 struct resource *res = &pci_dev->resource[i]; 114 struct resource *res = &pci_dev->resource[i];
@@ -133,19 +136,23 @@ static ssize_t is_enabled_store(struct device *dev,
133 struct device_attribute *attr, const char *buf, 136 struct device_attribute *attr, const char *buf,
134 size_t count) 137 size_t count)
135{ 138{
136 ssize_t result = -EINVAL;
137 struct pci_dev *pdev = to_pci_dev(dev); 139 struct pci_dev *pdev = to_pci_dev(dev);
140 unsigned long val;
141 ssize_t result = strict_strtoul(buf, 0, &val);
142
143 if (result < 0)
144 return result;
138 145
139 /* this can crash the machine when done on the "wrong" device */ 146 /* this can crash the machine when done on the "wrong" device */
140 if (!capable(CAP_SYS_ADMIN)) 147 if (!capable(CAP_SYS_ADMIN))
141 return count; 148 return -EPERM;
142 149
143 if (*buf == '0') { 150 if (!val) {
144 if (atomic_read(&pdev->enable_cnt) != 0) 151 if (atomic_read(&pdev->enable_cnt) != 0)
145 pci_disable_device(pdev); 152 pci_disable_device(pdev);
146 else 153 else
147 result = -EIO; 154 result = -EIO;
148 } else if (*buf == '1') 155 } else
149 result = pci_enable_device(pdev); 156 result = pci_enable_device(pdev);
150 157
151 return result < 0 ? result : count; 158 return result < 0 ? result : count;
@@ -185,25 +192,28 @@ msi_bus_store(struct device *dev, struct device_attribute *attr,
185 const char *buf, size_t count) 192 const char *buf, size_t count)
186{ 193{
187 struct pci_dev *pdev = to_pci_dev(dev); 194 struct pci_dev *pdev = to_pci_dev(dev);
195 unsigned long val;
196
197 if (strict_strtoul(buf, 0, &val) < 0)
198 return -EINVAL;
188 199
189 /* bad things may happen if the no_msi flag is changed 200 /* bad things may happen if the no_msi flag is changed
190 * while some drivers are loaded */ 201 * while some drivers are loaded */
191 if (!capable(CAP_SYS_ADMIN)) 202 if (!capable(CAP_SYS_ADMIN))
192 return count; 203 return -EPERM;
193 204
205 /* Maybe pci devices without subordinate busses shouldn't even have this
206 * attribute in the first place? */
194 if (!pdev->subordinate) 207 if (!pdev->subordinate)
195 return count; 208 return count;
196 209
197 if (*buf == '0') { 210 /* Is the flag going to change, or keep the value it already had? */
198 pdev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; 211 if (!(pdev->subordinate->bus_flags & PCI_BUS_FLAGS_NO_MSI) ^
199 dev_warn(&pdev->dev, "forced subordinate bus to not support MSI," 212 !!val) {
200 " bad things could happen.\n"); 213 pdev->subordinate->bus_flags ^= PCI_BUS_FLAGS_NO_MSI;
201 }
202 214
203 if (*buf == '1') { 215 dev_warn(&pdev->dev, "forced subordinate bus to%s support MSI,"
204 pdev->subordinate->bus_flags &= ~PCI_BUS_FLAGS_NO_MSI; 216 " bad things could happen\n", val ? "" : " not");
205 dev_warn(&pdev->dev, "forced subordinate bus to support MSI,"
206 " bad things could happen.\n");
207 } 217 }
208 218
209 return count; 219 return count;
@@ -361,55 +371,33 @@ pci_write_config(struct kobject *kobj, struct bin_attribute *bin_attr,
361} 371}
362 372
363static ssize_t 373static ssize_t
364pci_read_vpd(struct kobject *kobj, struct bin_attribute *bin_attr, 374read_vpd_attr(struct kobject *kobj, struct bin_attribute *bin_attr,
365 char *buf, loff_t off, size_t count) 375 char *buf, loff_t off, size_t count)
366{ 376{
367 struct pci_dev *dev = 377 struct pci_dev *dev =
368 to_pci_dev(container_of(kobj, struct device, kobj)); 378 to_pci_dev(container_of(kobj, struct device, kobj));
369 int end;
370 int ret;
371 379
372 if (off > bin_attr->size) 380 if (off > bin_attr->size)
373 count = 0; 381 count = 0;
374 else if (count > bin_attr->size - off) 382 else if (count > bin_attr->size - off)
375 count = bin_attr->size - off; 383 count = bin_attr->size - off;
376 end = off + count;
377
378 while (off < end) {
379 ret = dev->vpd->ops->read(dev, off, end - off, buf);
380 if (ret < 0)
381 return ret;
382 buf += ret;
383 off += ret;
384 }
385 384
386 return count; 385 return pci_read_vpd(dev, off, count, buf);
387} 386}
388 387
389static ssize_t 388static ssize_t
390pci_write_vpd(struct kobject *kobj, struct bin_attribute *bin_attr, 389write_vpd_attr(struct kobject *kobj, struct bin_attribute *bin_attr,
391 char *buf, loff_t off, size_t count) 390 char *buf, loff_t off, size_t count)
392{ 391{
393 struct pci_dev *dev = 392 struct pci_dev *dev =
394 to_pci_dev(container_of(kobj, struct device, kobj)); 393 to_pci_dev(container_of(kobj, struct device, kobj));
395 int end;
396 int ret;
397 394
398 if (off > bin_attr->size) 395 if (off > bin_attr->size)
399 count = 0; 396 count = 0;
400 else if (count > bin_attr->size - off) 397 else if (count > bin_attr->size - off)
401 count = bin_attr->size - off; 398 count = bin_attr->size - off;
402 end = off + count;
403
404 while (off < end) {
405 ret = dev->vpd->ops->write(dev, off, end - off, buf);
406 if (ret < 0)
407 return ret;
408 buf += ret;
409 off += ret;
410 }
411 399
412 return count; 400 return pci_write_vpd(dev, off, count, buf);
413} 401}
414 402
415#ifdef HAVE_PCI_LEGACY 403#ifdef HAVE_PCI_LEGACY
@@ -569,7 +557,7 @@ void pci_remove_legacy_files(struct pci_bus *b)
569 557
570#ifdef HAVE_PCI_MMAP 558#ifdef HAVE_PCI_MMAP
571 559
572static int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vma) 560int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vma)
573{ 561{
574 unsigned long nr, start, size; 562 unsigned long nr, start, size;
575 563
@@ -620,6 +608,9 @@ pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr,
620 vma->vm_pgoff += start >> PAGE_SHIFT; 608 vma->vm_pgoff += start >> PAGE_SHIFT;
621 mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io; 609 mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io;
622 610
611 if (res->flags & IORESOURCE_MEM && iomem_is_exclusive(start))
612 return -EINVAL;
613
623 return pci_mmap_page_range(pdev, vma, mmap_type, write_combine); 614 return pci_mmap_page_range(pdev, vma, mmap_type, write_combine);
624} 615}
625 616
@@ -832,8 +823,8 @@ static int pci_create_capabilities_sysfs(struct pci_dev *dev)
832 attr->size = dev->vpd->len; 823 attr->size = dev->vpd->len;
833 attr->attr.name = "vpd"; 824 attr->attr.name = "vpd";
834 attr->attr.mode = S_IRUSR | S_IWUSR; 825 attr->attr.mode = S_IRUSR | S_IWUSR;
835 attr->read = pci_read_vpd; 826 attr->read = read_vpd_attr;
836 attr->write = pci_write_vpd; 827 attr->write = write_vpd_attr;
837 retval = sysfs_create_bin_file(&dev->dev.kobj, attr); 828 retval = sysfs_create_bin_file(&dev->dev.kobj, attr);
838 if (retval) { 829 if (retval) {
839 kfree(dev->vpd->attr); 830 kfree(dev->vpd->attr);
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 061d1ee0046a..e491fdedf705 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -56,6 +56,22 @@ unsigned char pci_bus_max_busnr(struct pci_bus* bus)
56} 56}
57EXPORT_SYMBOL_GPL(pci_bus_max_busnr); 57EXPORT_SYMBOL_GPL(pci_bus_max_busnr);
58 58
59#ifdef CONFIG_HAS_IOMEM
60void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar)
61{
62 /*
63 * Make sure the BAR is actually a memory resource, not an IO resource
64 */
65 if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) {
66 WARN_ON(1);
67 return NULL;
68 }
69 return ioremap_nocache(pci_resource_start(pdev, bar),
70 pci_resource_len(pdev, bar));
71}
72EXPORT_SYMBOL_GPL(pci_ioremap_bar);
73#endif
74
59#if 0 75#if 0
60/** 76/**
61 * pci_max_busnr - returns maximum PCI bus number 77 * pci_max_busnr - returns maximum PCI bus number
@@ -360,25 +376,10 @@ pci_find_parent_resource(const struct pci_dev *dev, struct resource *res)
360static void 376static void
361pci_restore_bars(struct pci_dev *dev) 377pci_restore_bars(struct pci_dev *dev)
362{ 378{
363 int i, numres; 379 int i;
364
365 switch (dev->hdr_type) {
366 case PCI_HEADER_TYPE_NORMAL:
367 numres = 6;
368 break;
369 case PCI_HEADER_TYPE_BRIDGE:
370 numres = 2;
371 break;
372 case PCI_HEADER_TYPE_CARDBUS:
373 numres = 1;
374 break;
375 default:
376 /* Should never get here, but just in case... */
377 return;
378 }
379 380
380 for (i = 0; i < numres; i ++) 381 for (i = 0; i < PCI_BRIDGE_RESOURCES; i++)
381 pci_update_resource(dev, &dev->resource[i], i); 382 pci_update_resource(dev, i);
382} 383}
383 384
384static struct pci_platform_pm_ops *pci_platform_pm; 385static struct pci_platform_pm_ops *pci_platform_pm;
@@ -524,14 +525,17 @@ pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state)
524 * pci_update_current_state - Read PCI power state of given device from its 525 * pci_update_current_state - Read PCI power state of given device from its
525 * PCI PM registers and cache it 526 * PCI PM registers and cache it
526 * @dev: PCI device to handle. 527 * @dev: PCI device to handle.
528 * @state: State to cache in case the device doesn't have the PM capability
527 */ 529 */
528static void pci_update_current_state(struct pci_dev *dev) 530void pci_update_current_state(struct pci_dev *dev, pci_power_t state)
529{ 531{
530 if (dev->pm_cap) { 532 if (dev->pm_cap) {
531 u16 pmcsr; 533 u16 pmcsr;
532 534
533 pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); 535 pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
534 dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK); 536 dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
537 } else {
538 dev->current_state = state;
535 } 539 }
536} 540}
537 541
@@ -574,7 +578,7 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
574 */ 578 */
575 int ret = platform_pci_set_power_state(dev, PCI_D0); 579 int ret = platform_pci_set_power_state(dev, PCI_D0);
576 if (!ret) 580 if (!ret)
577 pci_update_current_state(dev); 581 pci_update_current_state(dev, PCI_D0);
578 } 582 }
579 /* This device is quirked not to be put into D3, so 583 /* This device is quirked not to be put into D3, so
580 don't put it in D3 */ 584 don't put it in D3 */
@@ -587,7 +591,7 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
587 /* Allow the platform to finalize the transition */ 591 /* Allow the platform to finalize the transition */
588 int ret = platform_pci_set_power_state(dev, state); 592 int ret = platform_pci_set_power_state(dev, state);
589 if (!ret) { 593 if (!ret) {
590 pci_update_current_state(dev); 594 pci_update_current_state(dev, state);
591 error = 0; 595 error = 0;
592 } 596 }
593 } 597 }
@@ -640,19 +644,14 @@ static int pci_save_pcie_state(struct pci_dev *dev)
640 int pos, i = 0; 644 int pos, i = 0;
641 struct pci_cap_saved_state *save_state; 645 struct pci_cap_saved_state *save_state;
642 u16 *cap; 646 u16 *cap;
643 int found = 0;
644 647
645 pos = pci_find_capability(dev, PCI_CAP_ID_EXP); 648 pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
646 if (pos <= 0) 649 if (pos <= 0)
647 return 0; 650 return 0;
648 651
649 save_state = pci_find_saved_cap(dev, PCI_CAP_ID_EXP); 652 save_state = pci_find_saved_cap(dev, PCI_CAP_ID_EXP);
650 if (!save_state)
651 save_state = kzalloc(sizeof(*save_state) + sizeof(u16) * 4, GFP_KERNEL);
652 else
653 found = 1;
654 if (!save_state) { 653 if (!save_state) {
655 dev_err(&dev->dev, "out of memory in pci_save_pcie_state\n"); 654 dev_err(&dev->dev, "buffer not found in %s\n", __FUNCTION__);
656 return -ENOMEM; 655 return -ENOMEM;
657 } 656 }
658 cap = (u16 *)&save_state->data[0]; 657 cap = (u16 *)&save_state->data[0];
@@ -661,9 +660,7 @@ static int pci_save_pcie_state(struct pci_dev *dev)
661 pci_read_config_word(dev, pos + PCI_EXP_LNKCTL, &cap[i++]); 660 pci_read_config_word(dev, pos + PCI_EXP_LNKCTL, &cap[i++]);
662 pci_read_config_word(dev, pos + PCI_EXP_SLTCTL, &cap[i++]); 661 pci_read_config_word(dev, pos + PCI_EXP_SLTCTL, &cap[i++]);
663 pci_read_config_word(dev, pos + PCI_EXP_RTCTL, &cap[i++]); 662 pci_read_config_word(dev, pos + PCI_EXP_RTCTL, &cap[i++]);
664 save_state->cap_nr = PCI_CAP_ID_EXP; 663
665 if (!found)
666 pci_add_saved_cap(dev, save_state);
667 return 0; 664 return 0;
668} 665}
669 666
@@ -688,30 +685,21 @@ static void pci_restore_pcie_state(struct pci_dev *dev)
688 685
689static int pci_save_pcix_state(struct pci_dev *dev) 686static int pci_save_pcix_state(struct pci_dev *dev)
690{ 687{
691 int pos, i = 0; 688 int pos;
692 struct pci_cap_saved_state *save_state; 689 struct pci_cap_saved_state *save_state;
693 u16 *cap;
694 int found = 0;
695 690
696 pos = pci_find_capability(dev, PCI_CAP_ID_PCIX); 691 pos = pci_find_capability(dev, PCI_CAP_ID_PCIX);
697 if (pos <= 0) 692 if (pos <= 0)
698 return 0; 693 return 0;
699 694
700 save_state = pci_find_saved_cap(dev, PCI_CAP_ID_PCIX); 695 save_state = pci_find_saved_cap(dev, PCI_CAP_ID_PCIX);
701 if (!save_state)
702 save_state = kzalloc(sizeof(*save_state) + sizeof(u16), GFP_KERNEL);
703 else
704 found = 1;
705 if (!save_state) { 696 if (!save_state) {
706 dev_err(&dev->dev, "out of memory in pci_save_pcie_state\n"); 697 dev_err(&dev->dev, "buffer not found in %s\n", __FUNCTION__);
707 return -ENOMEM; 698 return -ENOMEM;
708 } 699 }
709 cap = (u16 *)&save_state->data[0];
710 700
711 pci_read_config_word(dev, pos + PCI_X_CMD, &cap[i++]); 701 pci_read_config_word(dev, pos + PCI_X_CMD, (u16 *)save_state->data);
712 save_state->cap_nr = PCI_CAP_ID_PCIX; 702
713 if (!found)
714 pci_add_saved_cap(dev, save_state);
715 return 0; 703 return 0;
716} 704}
717 705
@@ -982,6 +970,32 @@ void pcim_pin_device(struct pci_dev *pdev)
982 */ 970 */
983void __attribute__ ((weak)) pcibios_disable_device (struct pci_dev *dev) {} 971void __attribute__ ((weak)) pcibios_disable_device (struct pci_dev *dev) {}
984 972
973static void do_pci_disable_device(struct pci_dev *dev)
974{
975 u16 pci_command;
976
977 pci_read_config_word(dev, PCI_COMMAND, &pci_command);
978 if (pci_command & PCI_COMMAND_MASTER) {
979 pci_command &= ~PCI_COMMAND_MASTER;
980 pci_write_config_word(dev, PCI_COMMAND, pci_command);
981 }
982
983 pcibios_disable_device(dev);
984}
985
986/**
987 * pci_disable_enabled_device - Disable device without updating enable_cnt
988 * @dev: PCI device to disable
989 *
990 * NOTE: This function is a backend of PCI power management routines and is
991 * not supposed to be called drivers.
992 */
993void pci_disable_enabled_device(struct pci_dev *dev)
994{
995 if (atomic_read(&dev->enable_cnt))
996 do_pci_disable_device(dev);
997}
998
985/** 999/**
986 * pci_disable_device - Disable PCI device after use 1000 * pci_disable_device - Disable PCI device after use
987 * @dev: PCI device to be disabled 1001 * @dev: PCI device to be disabled
@@ -996,7 +1010,6 @@ void
996pci_disable_device(struct pci_dev *dev) 1010pci_disable_device(struct pci_dev *dev)
997{ 1011{
998 struct pci_devres *dr; 1012 struct pci_devres *dr;
999 u16 pci_command;
1000 1013
1001 dr = find_pci_dr(dev); 1014 dr = find_pci_dr(dev);
1002 if (dr) 1015 if (dr)
@@ -1005,14 +1018,9 @@ pci_disable_device(struct pci_dev *dev)
1005 if (atomic_sub_return(1, &dev->enable_cnt) != 0) 1018 if (atomic_sub_return(1, &dev->enable_cnt) != 0)
1006 return; 1019 return;
1007 1020
1008 pci_read_config_word(dev, PCI_COMMAND, &pci_command); 1021 do_pci_disable_device(dev);
1009 if (pci_command & PCI_COMMAND_MASTER) {
1010 pci_command &= ~PCI_COMMAND_MASTER;
1011 pci_write_config_word(dev, PCI_COMMAND, pci_command);
1012 }
1013 dev->is_busmaster = 0;
1014 1022
1015 pcibios_disable_device(dev); 1023 dev->is_busmaster = 0;
1016} 1024}
1017 1025
1018/** 1026/**
@@ -1107,7 +1115,7 @@ int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable)
1107 int error = 0; 1115 int error = 0;
1108 bool pme_done = false; 1116 bool pme_done = false;
1109 1117
1110 if (!device_may_wakeup(&dev->dev)) 1118 if (enable && !device_may_wakeup(&dev->dev))
1111 return -EINVAL; 1119 return -EINVAL;
1112 1120
1113 /* 1121 /*
@@ -1301,6 +1309,71 @@ void pci_pm_init(struct pci_dev *dev)
1301} 1309}
1302 1310
1303/** 1311/**
1312 * platform_pci_wakeup_init - init platform wakeup if present
1313 * @dev: PCI device
1314 *
1315 * Some devices don't have PCI PM caps but can still generate wakeup
1316 * events through platform methods (like ACPI events). If @dev supports
1317 * platform wakeup events, set the device flag to indicate as much. This
1318 * may be redundant if the device also supports PCI PM caps, but double
1319 * initialization should be safe in that case.
1320 */
1321void platform_pci_wakeup_init(struct pci_dev *dev)
1322{
1323 if (!platform_pci_can_wakeup(dev))
1324 return;
1325
1326 device_set_wakeup_capable(&dev->dev, true);
1327 device_set_wakeup_enable(&dev->dev, false);
1328 platform_pci_sleep_wake(dev, false);
1329}
1330
1331/**
1332 * pci_add_save_buffer - allocate buffer for saving given capability registers
1333 * @dev: the PCI device
1334 * @cap: the capability to allocate the buffer for
1335 * @size: requested size of the buffer
1336 */
1337static int pci_add_cap_save_buffer(
1338 struct pci_dev *dev, char cap, unsigned int size)
1339{
1340 int pos;
1341 struct pci_cap_saved_state *save_state;
1342
1343 pos = pci_find_capability(dev, cap);
1344 if (pos <= 0)
1345 return 0;
1346
1347 save_state = kzalloc(sizeof(*save_state) + size, GFP_KERNEL);
1348 if (!save_state)
1349 return -ENOMEM;
1350
1351 save_state->cap_nr = cap;
1352 pci_add_saved_cap(dev, save_state);
1353
1354 return 0;
1355}
1356
1357/**
1358 * pci_allocate_cap_save_buffers - allocate buffers for saving capabilities
1359 * @dev: the PCI device
1360 */
1361void pci_allocate_cap_save_buffers(struct pci_dev *dev)
1362{
1363 int error;
1364
1365 error = pci_add_cap_save_buffer(dev, PCI_CAP_ID_EXP, 4 * sizeof(u16));
1366 if (error)
1367 dev_err(&dev->dev,
1368 "unable to preallocate PCI Express save buffer\n");
1369
1370 error = pci_add_cap_save_buffer(dev, PCI_CAP_ID_PCIX, sizeof(u16));
1371 if (error)
1372 dev_err(&dev->dev,
1373 "unable to preallocate PCI-X save buffer\n");
1374}
1375
1376/**
1304 * pci_enable_ari - enable ARI forwarding if hardware support it 1377 * pci_enable_ari - enable ARI forwarding if hardware support it
1305 * @dev: the PCI device 1378 * @dev: the PCI device
1306 */ 1379 */
@@ -1337,6 +1410,20 @@ void pci_enable_ari(struct pci_dev *dev)
1337 bridge->ari_enabled = 1; 1410 bridge->ari_enabled = 1;
1338} 1411}
1339 1412
1413/**
1414 * pci_swizzle_interrupt_pin - swizzle INTx for device behind bridge
1415 * @dev: the PCI device
1416 * @pin: the INTx pin (1=INTA, 2=INTB, 3=INTD, 4=INTD)
1417 *
1418 * Perform INTx swizzling for a device behind one level of bridge. This is
1419 * required by section 9.1 of the PCI-to-PCI bridge specification for devices
1420 * behind bridges on add-in cards.
1421 */
1422u8 pci_swizzle_interrupt_pin(struct pci_dev *dev, u8 pin)
1423{
1424 return (((pin - 1) + PCI_SLOT(dev->devfn)) % 4) + 1;
1425}
1426
1340int 1427int
1341pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge) 1428pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge)
1342{ 1429{
@@ -1345,9 +1432,9 @@ pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge)
1345 pin = dev->pin; 1432 pin = dev->pin;
1346 if (!pin) 1433 if (!pin)
1347 return -1; 1434 return -1;
1348 pin--; 1435
1349 while (dev->bus->self) { 1436 while (dev->bus->self) {
1350 pin = (pin + PCI_SLOT(dev->devfn)) % 4; 1437 pin = pci_swizzle_interrupt_pin(dev, pin);
1351 dev = dev->bus->self; 1438 dev = dev->bus->self;
1352 } 1439 }
1353 *bridge = dev; 1440 *bridge = dev;
@@ -1355,6 +1442,26 @@ pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge)
1355} 1442}
1356 1443
1357/** 1444/**
1445 * pci_common_swizzle - swizzle INTx all the way to root bridge
1446 * @dev: the PCI device
1447 * @pinp: pointer to the INTx pin value (1=INTA, 2=INTB, 3=INTD, 4=INTD)
1448 *
1449 * Perform INTx swizzling for a device. This traverses through all PCI-to-PCI
1450 * bridges all the way up to a PCI root bus.
1451 */
1452u8 pci_common_swizzle(struct pci_dev *dev, u8 *pinp)
1453{
1454 u8 pin = *pinp;
1455
1456 while (dev->bus->self) {
1457 pin = pci_swizzle_interrupt_pin(dev, pin);
1458 dev = dev->bus->self;
1459 }
1460 *pinp = pin;
1461 return PCI_SLOT(dev->devfn);
1462}
1463
1464/**
1358 * pci_release_region - Release a PCI bar 1465 * pci_release_region - Release a PCI bar
1359 * @pdev: PCI device whose resources were previously reserved by pci_request_region 1466 * @pdev: PCI device whose resources were previously reserved by pci_request_region
1360 * @bar: BAR to release 1467 * @bar: BAR to release
@@ -1395,7 +1502,8 @@ void pci_release_region(struct pci_dev *pdev, int bar)
1395 * Returns 0 on success, or %EBUSY on error. A warning 1502 * Returns 0 on success, or %EBUSY on error. A warning
1396 * message is also printed on failure. 1503 * message is also printed on failure.
1397 */ 1504 */
1398int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name) 1505static int __pci_request_region(struct pci_dev *pdev, int bar, const char *res_name,
1506 int exclusive)
1399{ 1507{
1400 struct pci_devres *dr; 1508 struct pci_devres *dr;
1401 1509
@@ -1408,8 +1516,9 @@ int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name)
1408 goto err_out; 1516 goto err_out;
1409 } 1517 }
1410 else if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) { 1518 else if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) {
1411 if (!request_mem_region(pci_resource_start(pdev, bar), 1519 if (!__request_mem_region(pci_resource_start(pdev, bar),
1412 pci_resource_len(pdev, bar), res_name)) 1520 pci_resource_len(pdev, bar), res_name,
1521 exclusive))
1413 goto err_out; 1522 goto err_out;
1414 } 1523 }
1415 1524
@@ -1428,6 +1537,47 @@ err_out:
1428} 1537}
1429 1538
1430/** 1539/**
1540 * pci_request_region - Reserved PCI I/O and memory resource
1541 * @pdev: PCI device whose resources are to be reserved
1542 * @bar: BAR to be reserved
1543 * @res_name: Name to be associated with resource.
1544 *
1545 * Mark the PCI region associated with PCI device @pdev BR @bar as
1546 * being reserved by owner @res_name. Do not access any
1547 * address inside the PCI regions unless this call returns
1548 * successfully.
1549 *
1550 * Returns 0 on success, or %EBUSY on error. A warning
1551 * message is also printed on failure.
1552 */
1553int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name)
1554{
1555 return __pci_request_region(pdev, bar, res_name, 0);
1556}
1557
1558/**
1559 * pci_request_region_exclusive - Reserved PCI I/O and memory resource
1560 * @pdev: PCI device whose resources are to be reserved
1561 * @bar: BAR to be reserved
1562 * @res_name: Name to be associated with resource.
1563 *
1564 * Mark the PCI region associated with PCI device @pdev BR @bar as
1565 * being reserved by owner @res_name. Do not access any
1566 * address inside the PCI regions unless this call returns
1567 * successfully.
1568 *
1569 * Returns 0 on success, or %EBUSY on error. A warning
1570 * message is also printed on failure.
1571 *
1572 * The key difference that _exclusive makes it that userspace is
1573 * explicitly not allowed to map the resource via /dev/mem or
1574 * sysfs.
1575 */
1576int pci_request_region_exclusive(struct pci_dev *pdev, int bar, const char *res_name)
1577{
1578 return __pci_request_region(pdev, bar, res_name, IORESOURCE_EXCLUSIVE);
1579}
1580/**
1431 * pci_release_selected_regions - Release selected PCI I/O and memory resources 1581 * pci_release_selected_regions - Release selected PCI I/O and memory resources
1432 * @pdev: PCI device whose resources were previously reserved 1582 * @pdev: PCI device whose resources were previously reserved
1433 * @bars: Bitmask of BARs to be released 1583 * @bars: Bitmask of BARs to be released
@@ -1444,20 +1594,14 @@ void pci_release_selected_regions(struct pci_dev *pdev, int bars)
1444 pci_release_region(pdev, i); 1594 pci_release_region(pdev, i);
1445} 1595}
1446 1596
1447/** 1597int __pci_request_selected_regions(struct pci_dev *pdev, int bars,
1448 * pci_request_selected_regions - Reserve selected PCI I/O and memory resources 1598 const char *res_name, int excl)
1449 * @pdev: PCI device whose resources are to be reserved
1450 * @bars: Bitmask of BARs to be requested
1451 * @res_name: Name to be associated with resource
1452 */
1453int pci_request_selected_regions(struct pci_dev *pdev, int bars,
1454 const char *res_name)
1455{ 1599{
1456 int i; 1600 int i;
1457 1601
1458 for (i = 0; i < 6; i++) 1602 for (i = 0; i < 6; i++)
1459 if (bars & (1 << i)) 1603 if (bars & (1 << i))
1460 if(pci_request_region(pdev, i, res_name)) 1604 if (__pci_request_region(pdev, i, res_name, excl))
1461 goto err_out; 1605 goto err_out;
1462 return 0; 1606 return 0;
1463 1607
@@ -1469,6 +1613,26 @@ err_out:
1469 return -EBUSY; 1613 return -EBUSY;
1470} 1614}
1471 1615
1616
1617/**
1618 * pci_request_selected_regions - Reserve selected PCI I/O and memory resources
1619 * @pdev: PCI device whose resources are to be reserved
1620 * @bars: Bitmask of BARs to be requested
1621 * @res_name: Name to be associated with resource
1622 */
1623int pci_request_selected_regions(struct pci_dev *pdev, int bars,
1624 const char *res_name)
1625{
1626 return __pci_request_selected_regions(pdev, bars, res_name, 0);
1627}
1628
1629int pci_request_selected_regions_exclusive(struct pci_dev *pdev,
1630 int bars, const char *res_name)
1631{
1632 return __pci_request_selected_regions(pdev, bars, res_name,
1633 IORESOURCE_EXCLUSIVE);
1634}
1635
1472/** 1636/**
1473 * pci_release_regions - Release reserved PCI I/O and memory resources 1637 * pci_release_regions - Release reserved PCI I/O and memory resources
1474 * @pdev: PCI device whose resources were previously reserved by pci_request_regions 1638 * @pdev: PCI device whose resources were previously reserved by pci_request_regions
@@ -1502,27 +1666,66 @@ int pci_request_regions(struct pci_dev *pdev, const char *res_name)
1502} 1666}
1503 1667
1504/** 1668/**
1669 * pci_request_regions_exclusive - Reserved PCI I/O and memory resources
1670 * @pdev: PCI device whose resources are to be reserved
1671 * @res_name: Name to be associated with resource.
1672 *
1673 * Mark all PCI regions associated with PCI device @pdev as
1674 * being reserved by owner @res_name. Do not access any
1675 * address inside the PCI regions unless this call returns
1676 * successfully.
1677 *
1678 * pci_request_regions_exclusive() will mark the region so that
1679 * /dev/mem and the sysfs MMIO access will not be allowed.
1680 *
1681 * Returns 0 on success, or %EBUSY on error. A warning
1682 * message is also printed on failure.
1683 */
1684int pci_request_regions_exclusive(struct pci_dev *pdev, const char *res_name)
1685{
1686 return pci_request_selected_regions_exclusive(pdev,
1687 ((1 << 6) - 1), res_name);
1688}
1689
1690static void __pci_set_master(struct pci_dev *dev, bool enable)
1691{
1692 u16 old_cmd, cmd;
1693
1694 pci_read_config_word(dev, PCI_COMMAND, &old_cmd);
1695 if (enable)
1696 cmd = old_cmd | PCI_COMMAND_MASTER;
1697 else
1698 cmd = old_cmd & ~PCI_COMMAND_MASTER;
1699 if (cmd != old_cmd) {
1700 dev_dbg(&dev->dev, "%s bus mastering\n",
1701 enable ? "enabling" : "disabling");
1702 pci_write_config_word(dev, PCI_COMMAND, cmd);
1703 }
1704 dev->is_busmaster = enable;
1705}
1706
1707/**
1505 * pci_set_master - enables bus-mastering for device dev 1708 * pci_set_master - enables bus-mastering for device dev
1506 * @dev: the PCI device to enable 1709 * @dev: the PCI device to enable
1507 * 1710 *
1508 * Enables bus-mastering on the device and calls pcibios_set_master() 1711 * Enables bus-mastering on the device and calls pcibios_set_master()
1509 * to do the needed arch specific settings. 1712 * to do the needed arch specific settings.
1510 */ 1713 */
1511void 1714void pci_set_master(struct pci_dev *dev)
1512pci_set_master(struct pci_dev *dev)
1513{ 1715{
1514 u16 cmd; 1716 __pci_set_master(dev, true);
1515
1516 pci_read_config_word(dev, PCI_COMMAND, &cmd);
1517 if (! (cmd & PCI_COMMAND_MASTER)) {
1518 dev_dbg(&dev->dev, "enabling bus mastering\n");
1519 cmd |= PCI_COMMAND_MASTER;
1520 pci_write_config_word(dev, PCI_COMMAND, cmd);
1521 }
1522 dev->is_busmaster = 1;
1523 pcibios_set_master(dev); 1717 pcibios_set_master(dev);
1524} 1718}
1525 1719
1720/**
1721 * pci_clear_master - disables bus-mastering for device dev
1722 * @dev: the PCI device to disable
1723 */
1724void pci_clear_master(struct pci_dev *dev)
1725{
1726 __pci_set_master(dev, false);
1727}
1728
1526#ifdef PCI_DISABLE_MWI 1729#ifdef PCI_DISABLE_MWI
1527int pci_set_mwi(struct pci_dev *dev) 1730int pci_set_mwi(struct pci_dev *dev)
1528{ 1731{
@@ -1751,24 +1954,7 @@ int pci_set_dma_seg_boundary(struct pci_dev *dev, unsigned long mask)
1751EXPORT_SYMBOL(pci_set_dma_seg_boundary); 1954EXPORT_SYMBOL(pci_set_dma_seg_boundary);
1752#endif 1955#endif
1753 1956
1754/** 1957static int __pcie_flr(struct pci_dev *dev, int probe)
1755 * pci_execute_reset_function() - Reset a PCI device function
1756 * @dev: Device function to reset
1757 *
1758 * Some devices allow an individual function to be reset without affecting
1759 * other functions in the same device. The PCI device must be responsive
1760 * to PCI config space in order to use this function.
1761 *
1762 * The device function is presumed to be unused when this function is called.
1763 * Resetting the device will make the contents of PCI configuration space
1764 * random, so any caller of this must be prepared to reinitialise the
1765 * device including MSI, bus mastering, BARs, decoding IO and memory spaces,
1766 * etc.
1767 *
1768 * Returns 0 if the device function was successfully reset or -ENOTTY if the
1769 * device doesn't support resetting a single function.
1770 */
1771int pci_execute_reset_function(struct pci_dev *dev)
1772{ 1958{
1773 u16 status; 1959 u16 status;
1774 u32 cap; 1960 u32 cap;
@@ -1780,6 +1966,9 @@ int pci_execute_reset_function(struct pci_dev *dev)
1780 if (!(cap & PCI_EXP_DEVCAP_FLR)) 1966 if (!(cap & PCI_EXP_DEVCAP_FLR))
1781 return -ENOTTY; 1967 return -ENOTTY;
1782 1968
1969 if (probe)
1970 return 0;
1971
1783 pci_block_user_cfg_access(dev); 1972 pci_block_user_cfg_access(dev);
1784 1973
1785 /* Wait for Transaction Pending bit clean */ 1974 /* Wait for Transaction Pending bit clean */
@@ -1802,6 +1991,80 @@ int pci_execute_reset_function(struct pci_dev *dev)
1802 pci_unblock_user_cfg_access(dev); 1991 pci_unblock_user_cfg_access(dev);
1803 return 0; 1992 return 0;
1804} 1993}
1994
1995static int __pci_af_flr(struct pci_dev *dev, int probe)
1996{
1997 int cappos = pci_find_capability(dev, PCI_CAP_ID_AF);
1998 u8 status;
1999 u8 cap;
2000
2001 if (!cappos)
2002 return -ENOTTY;
2003 pci_read_config_byte(dev, cappos + PCI_AF_CAP, &cap);
2004 if (!(cap & PCI_AF_CAP_TP) || !(cap & PCI_AF_CAP_FLR))
2005 return -ENOTTY;
2006
2007 if (probe)
2008 return 0;
2009
2010 pci_block_user_cfg_access(dev);
2011
2012 /* Wait for Transaction Pending bit clean */
2013 msleep(100);
2014 pci_read_config_byte(dev, cappos + PCI_AF_STATUS, &status);
2015 if (status & PCI_AF_STATUS_TP) {
2016 dev_info(&dev->dev, "Busy after 100ms while trying to"
2017 " reset; sleeping for 1 second\n");
2018 ssleep(1);
2019 pci_read_config_byte(dev,
2020 cappos + PCI_AF_STATUS, &status);
2021 if (status & PCI_AF_STATUS_TP)
2022 dev_info(&dev->dev, "Still busy after 1s; "
2023 "proceeding with reset anyway\n");
2024 }
2025 pci_write_config_byte(dev, cappos + PCI_AF_CTRL, PCI_AF_CTRL_FLR);
2026 mdelay(100);
2027
2028 pci_unblock_user_cfg_access(dev);
2029 return 0;
2030}
2031
2032static int __pci_reset_function(struct pci_dev *pdev, int probe)
2033{
2034 int res;
2035
2036 res = __pcie_flr(pdev, probe);
2037 if (res != -ENOTTY)
2038 return res;
2039
2040 res = __pci_af_flr(pdev, probe);
2041 if (res != -ENOTTY)
2042 return res;
2043
2044 return res;
2045}
2046
2047/**
2048 * pci_execute_reset_function() - Reset a PCI device function
2049 * @dev: Device function to reset
2050 *
2051 * Some devices allow an individual function to be reset without affecting
2052 * other functions in the same device. The PCI device must be responsive
2053 * to PCI config space in order to use this function.
2054 *
2055 * The device function is presumed to be unused when this function is called.
2056 * Resetting the device will make the contents of PCI configuration space
2057 * random, so any caller of this must be prepared to reinitialise the
2058 * device including MSI, bus mastering, BARs, decoding IO and memory spaces,
2059 * etc.
2060 *
2061 * Returns 0 if the device function was successfully reset or -ENOTTY if the
2062 * device doesn't support resetting a single function.
2063 */
2064int pci_execute_reset_function(struct pci_dev *dev)
2065{
2066 return __pci_reset_function(dev, 0);
2067}
1805EXPORT_SYMBOL_GPL(pci_execute_reset_function); 2068EXPORT_SYMBOL_GPL(pci_execute_reset_function);
1806 2069
1807/** 2070/**
@@ -1822,15 +2085,10 @@ EXPORT_SYMBOL_GPL(pci_execute_reset_function);
1822 */ 2085 */
1823int pci_reset_function(struct pci_dev *dev) 2086int pci_reset_function(struct pci_dev *dev)
1824{ 2087{
1825 u32 cap; 2088 int r = __pci_reset_function(dev, 1);
1826 int exppos = pci_find_capability(dev, PCI_CAP_ID_EXP);
1827 int r;
1828 2089
1829 if (!exppos) 2090 if (r < 0)
1830 return -ENOTTY; 2091 return r;
1831 pci_read_config_dword(dev, exppos + PCI_EXP_DEVCAP, &cap);
1832 if (!(cap & PCI_EXP_DEVCAP_FLR))
1833 return -ENOTTY;
1834 2092
1835 if (!dev->msi_enabled && !dev->msix_enabled && dev->irq != 0) 2093 if (!dev->msi_enabled && !dev->msix_enabled && dev->irq != 0)
1836 disable_irq(dev->irq); 2094 disable_irq(dev->irq);
@@ -2022,6 +2280,28 @@ int pci_select_bars(struct pci_dev *dev, unsigned long flags)
2022 return bars; 2280 return bars;
2023} 2281}
2024 2282
2283/**
2284 * pci_resource_bar - get position of the BAR associated with a resource
2285 * @dev: the PCI device
2286 * @resno: the resource number
2287 * @type: the BAR type to be filled in
2288 *
2289 * Returns BAR position in config space, or 0 if the BAR is invalid.
2290 */
2291int pci_resource_bar(struct pci_dev *dev, int resno, enum pci_bar_type *type)
2292{
2293 if (resno < PCI_ROM_RESOURCE) {
2294 *type = pci_bar_unknown;
2295 return PCI_BASE_ADDRESS_0 + 4 * resno;
2296 } else if (resno == PCI_ROM_RESOURCE) {
2297 *type = pci_bar_mem32;
2298 return dev->rom_base_reg;
2299 }
2300
2301 dev_err(&dev->dev, "BAR: invalid resource #%d\n", resno);
2302 return 0;
2303}
2304
2025static void __devinit pci_no_domains(void) 2305static void __devinit pci_no_domains(void)
2026{ 2306{
2027#ifdef CONFIG_PCI_DOMAINS 2307#ifdef CONFIG_PCI_DOMAINS
@@ -2029,6 +2309,19 @@ static void __devinit pci_no_domains(void)
2029#endif 2309#endif
2030} 2310}
2031 2311
2312/**
2313 * pci_ext_cfg_enabled - can we access extended PCI config space?
2314 * @dev: The PCI device of the root bridge.
2315 *
2316 * Returns 1 if we can access PCI extended config space (offsets
2317 * greater than 0xff). This is the default implementation. Architecture
2318 * implementations can override this.
2319 */
2320int __attribute__ ((weak)) pci_ext_cfg_avail(struct pci_dev *dev)
2321{
2322 return 1;
2323}
2324
2032static int __devinit pci_init(void) 2325static int __devinit pci_init(void)
2033{ 2326{
2034 struct pci_dev *dev = NULL; 2327 struct pci_dev *dev = NULL;
@@ -2037,8 +2330,6 @@ static int __devinit pci_init(void)
2037 pci_fixup_device(pci_fixup_final, dev); 2330 pci_fixup_device(pci_fixup_final, dev);
2038 } 2331 }
2039 2332
2040 msi_init();
2041
2042 return 0; 2333 return 0;
2043} 2334}
2044 2335
@@ -2083,11 +2374,15 @@ EXPORT_SYMBOL(pci_find_capability);
2083EXPORT_SYMBOL(pci_bus_find_capability); 2374EXPORT_SYMBOL(pci_bus_find_capability);
2084EXPORT_SYMBOL(pci_release_regions); 2375EXPORT_SYMBOL(pci_release_regions);
2085EXPORT_SYMBOL(pci_request_regions); 2376EXPORT_SYMBOL(pci_request_regions);
2377EXPORT_SYMBOL(pci_request_regions_exclusive);
2086EXPORT_SYMBOL(pci_release_region); 2378EXPORT_SYMBOL(pci_release_region);
2087EXPORT_SYMBOL(pci_request_region); 2379EXPORT_SYMBOL(pci_request_region);
2380EXPORT_SYMBOL(pci_request_region_exclusive);
2088EXPORT_SYMBOL(pci_release_selected_regions); 2381EXPORT_SYMBOL(pci_release_selected_regions);
2089EXPORT_SYMBOL(pci_request_selected_regions); 2382EXPORT_SYMBOL(pci_request_selected_regions);
2383EXPORT_SYMBOL(pci_request_selected_regions_exclusive);
2090EXPORT_SYMBOL(pci_set_master); 2384EXPORT_SYMBOL(pci_set_master);
2385EXPORT_SYMBOL(pci_clear_master);
2091EXPORT_SYMBOL(pci_set_mwi); 2386EXPORT_SYMBOL(pci_set_mwi);
2092EXPORT_SYMBOL(pci_try_set_mwi); 2387EXPORT_SYMBOL(pci_try_set_mwi);
2093EXPORT_SYMBOL(pci_clear_mwi); 2388EXPORT_SYMBOL(pci_clear_mwi);
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 9de87e9f98f5..1351bb4addde 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -10,6 +10,10 @@ extern int pci_uevent(struct device *dev, struct kobj_uevent_env *env);
10extern int pci_create_sysfs_dev_files(struct pci_dev *pdev); 10extern int pci_create_sysfs_dev_files(struct pci_dev *pdev);
11extern void pci_remove_sysfs_dev_files(struct pci_dev *pdev); 11extern void pci_remove_sysfs_dev_files(struct pci_dev *pdev);
12extern void pci_cleanup_rom(struct pci_dev *dev); 12extern void pci_cleanup_rom(struct pci_dev *dev);
13#ifdef HAVE_PCI_MMAP
14extern int pci_mmap_fits(struct pci_dev *pdev, int resno,
15 struct vm_area_struct *vma);
16#endif
13 17
14/** 18/**
15 * Firmware PM callbacks 19 * Firmware PM callbacks
@@ -40,7 +44,11 @@ struct pci_platform_pm_ops {
40}; 44};
41 45
42extern int pci_set_platform_pm(struct pci_platform_pm_ops *ops); 46extern int pci_set_platform_pm(struct pci_platform_pm_ops *ops);
47extern void pci_update_current_state(struct pci_dev *dev, pci_power_t state);
48extern void pci_disable_enabled_device(struct pci_dev *dev);
43extern void pci_pm_init(struct pci_dev *dev); 49extern void pci_pm_init(struct pci_dev *dev);
50extern void platform_pci_wakeup_init(struct pci_dev *dev);
51extern void pci_allocate_cap_save_buffers(struct pci_dev *dev);
44 52
45extern int pci_user_read_config_byte(struct pci_dev *dev, int where, u8 *val); 53extern int pci_user_read_config_byte(struct pci_dev *dev, int where, u8 *val);
46extern int pci_user_read_config_word(struct pci_dev *dev, int where, u16 *val); 54extern int pci_user_read_config_word(struct pci_dev *dev, int where, u16 *val);
@@ -50,14 +58,14 @@ extern int pci_user_write_config_word(struct pci_dev *dev, int where, u16 val);
50extern int pci_user_write_config_dword(struct pci_dev *dev, int where, u32 val); 58extern int pci_user_write_config_dword(struct pci_dev *dev, int where, u32 val);
51 59
52struct pci_vpd_ops { 60struct pci_vpd_ops {
53 int (*read)(struct pci_dev *dev, int pos, int size, char *buf); 61 ssize_t (*read)(struct pci_dev *dev, loff_t pos, size_t count, void *buf);
54 int (*write)(struct pci_dev *dev, int pos, int size, const char *buf); 62 ssize_t (*write)(struct pci_dev *dev, loff_t pos, size_t count, const void *buf);
55 void (*release)(struct pci_dev *dev); 63 void (*release)(struct pci_dev *dev);
56}; 64};
57 65
58struct pci_vpd { 66struct pci_vpd {
59 unsigned int len; 67 unsigned int len;
60 struct pci_vpd_ops *ops; 68 const struct pci_vpd_ops *ops;
61 struct bin_attribute *attr; /* descriptor for sysfs VPD entry */ 69 struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
62}; 70};
63 71
@@ -98,11 +106,9 @@ extern unsigned int pci_pm_d3_delay;
98#ifdef CONFIG_PCI_MSI 106#ifdef CONFIG_PCI_MSI
99void pci_no_msi(void); 107void pci_no_msi(void);
100extern void pci_msi_init_pci_dev(struct pci_dev *dev); 108extern void pci_msi_init_pci_dev(struct pci_dev *dev);
101extern void __devinit msi_init(void);
102#else 109#else
103static inline void pci_no_msi(void) { } 110static inline void pci_no_msi(void) { }
104static inline void pci_msi_init_pci_dev(struct pci_dev *dev) { } 111static inline void pci_msi_init_pci_dev(struct pci_dev *dev) { }
105static inline void msi_init(void) { }
106#endif 112#endif
107 113
108#ifdef CONFIG_PCIEAER 114#ifdef CONFIG_PCIEAER
@@ -159,16 +165,28 @@ struct pci_slot_attribute {
159}; 165};
160#define to_pci_slot_attr(s) container_of(s, struct pci_slot_attribute, attr) 166#define to_pci_slot_attr(s) container_of(s, struct pci_slot_attribute, attr)
161 167
168enum pci_bar_type {
169 pci_bar_unknown, /* Standard PCI BAR probe */
170 pci_bar_io, /* An io port BAR */
171 pci_bar_mem32, /* A 32-bit memory BAR */
172 pci_bar_mem64, /* A 64-bit memory BAR */
173};
174
175extern int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
176 struct resource *res, unsigned int reg);
177extern int pci_resource_bar(struct pci_dev *dev, int resno,
178 enum pci_bar_type *type);
179extern int pci_bus_add_child(struct pci_bus *bus);
162extern void pci_enable_ari(struct pci_dev *dev); 180extern void pci_enable_ari(struct pci_dev *dev);
163/** 181/**
164 * pci_ari_enabled - query ARI forwarding status 182 * pci_ari_enabled - query ARI forwarding status
165 * @dev: the PCI device 183 * @bus: the PCI bus
166 * 184 *
167 * Returns 1 if ARI forwarding is enabled, or 0 if not enabled; 185 * Returns 1 if ARI forwarding is enabled, or 0 if not enabled;
168 */ 186 */
169static inline int pci_ari_enabled(struct pci_dev *dev) 187static inline int pci_ari_enabled(struct pci_bus *bus)
170{ 188{
171 return dev->ari_enabled; 189 return bus->self && bus->self->ari_enabled;
172} 190}
173 191
174#endif /* DRIVERS_PCI_H */ 192#endif /* DRIVERS_PCI_H */
diff --git a/drivers/pci/pcie/aer/aerdrv_acpi.c b/drivers/pci/pcie/aer/aerdrv_acpi.c
index 6dd7b13e9808..ebce26c37049 100644
--- a/drivers/pci/pcie/aer/aerdrv_acpi.c
+++ b/drivers/pci/pcie/aer/aerdrv_acpi.c
@@ -38,7 +38,6 @@ int aer_osc_setup(struct pcie_device *pciedev)
38 38
39 handle = acpi_find_root_bridge_handle(pdev); 39 handle = acpi_find_root_bridge_handle(pdev);
40 if (handle) { 40 if (handle) {
41 pcie_osc_support_set(OSC_EXT_PCI_CONFIG_SUPPORT);
42 status = pci_osc_control_set(handle, 41 status = pci_osc_control_set(handle,
43 OSC_PCI_EXPRESS_AER_CONTROL | 42 OSC_PCI_EXPRESS_AER_CONTROL |
44 OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL); 43 OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
diff --git a/drivers/pci/pcie/aer/aerdrv_errprint.c b/drivers/pci/pcie/aer/aerdrv_errprint.c
index 3933d4f30e8c..0fc29ae80df8 100644
--- a/drivers/pci/pcie/aer/aerdrv_errprint.c
+++ b/drivers/pci/pcie/aer/aerdrv_errprint.c
@@ -233,7 +233,7 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
233 233
234 if (info->flags & AER_TLP_HEADER_VALID_FLAG) { 234 if (info->flags & AER_TLP_HEADER_VALID_FLAG) {
235 unsigned char *tlp = (unsigned char *) &info->tlp; 235 unsigned char *tlp = (unsigned char *) &info->tlp;
236 printk("%sTLB Header:\n", loglevel); 236 printk("%sTLP Header:\n", loglevel);
237 printk("%s%02x%02x%02x%02x %02x%02x%02x%02x" 237 printk("%s%02x%02x%02x%02x %02x%02x%02x%02x"
238 " %02x%02x%02x%02x %02x%02x%02x%02x\n", 238 " %02x%02x%02x%02x %02x%02x%02x%02x\n",
239 loglevel, 239 loglevel,
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index 9aad608bcf3f..586b6f75910d 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -17,6 +17,7 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/jiffies.h> 19#include <linux/jiffies.h>
20#include <linux/delay.h>
20#include <linux/pci-aspm.h> 21#include <linux/pci-aspm.h>
21#include "../pci.h" 22#include "../pci.h"
22 23
@@ -33,6 +34,11 @@ struct endpoint_state {
33struct pcie_link_state { 34struct pcie_link_state {
34 struct list_head sibiling; 35 struct list_head sibiling;
35 struct pci_dev *pdev; 36 struct pci_dev *pdev;
37 bool downstream_has_switch;
38
39 struct pcie_link_state *parent;
40 struct list_head children;
41 struct list_head link;
36 42
37 /* ASPM state */ 43 /* ASPM state */
38 unsigned int support_state; 44 unsigned int support_state;
@@ -70,6 +76,8 @@ static const char *policy_str[] = {
70 [POLICY_POWERSAVE] = "powersave" 76 [POLICY_POWERSAVE] = "powersave"
71}; 77};
72 78
79#define LINK_RETRAIN_TIMEOUT HZ
80
73static int policy_to_aspm_state(struct pci_dev *pdev) 81static int policy_to_aspm_state(struct pci_dev *pdev)
74{ 82{
75 struct pcie_link_state *link_state = pdev->link_state; 83 struct pcie_link_state *link_state = pdev->link_state;
@@ -125,7 +133,7 @@ static void pcie_set_clock_pm(struct pci_dev *pdev, int enable)
125 link_state->clk_pm_enabled = !!enable; 133 link_state->clk_pm_enabled = !!enable;
126} 134}
127 135
128static void pcie_check_clock_pm(struct pci_dev *pdev) 136static void pcie_check_clock_pm(struct pci_dev *pdev, int blacklist)
129{ 137{
130 int pos; 138 int pos;
131 u32 reg32; 139 u32 reg32;
@@ -149,10 +157,26 @@ static void pcie_check_clock_pm(struct pci_dev *pdev)
149 if (!(reg16 & PCI_EXP_LNKCTL_CLKREQ_EN)) 157 if (!(reg16 & PCI_EXP_LNKCTL_CLKREQ_EN))
150 enabled = 0; 158 enabled = 0;
151 } 159 }
152 link_state->clk_pm_capable = capable;
153 link_state->clk_pm_enabled = enabled; 160 link_state->clk_pm_enabled = enabled;
154 link_state->bios_clk_state = enabled; 161 link_state->bios_clk_state = enabled;
155 pcie_set_clock_pm(pdev, policy_to_clkpm_state(pdev)); 162 if (!blacklist) {
163 link_state->clk_pm_capable = capable;
164 pcie_set_clock_pm(pdev, policy_to_clkpm_state(pdev));
165 } else {
166 link_state->clk_pm_capable = 0;
167 pcie_set_clock_pm(pdev, 0);
168 }
169}
170
171static bool pcie_aspm_downstream_has_switch(struct pci_dev *pdev)
172{
173 struct pci_dev *child_dev;
174
175 list_for_each_entry(child_dev, &pdev->subordinate->devices, bus_list) {
176 if (child_dev->pcie_type == PCI_EXP_TYPE_UPSTREAM)
177 return true;
178 }
179 return false;
156} 180}
157 181
158/* 182/*
@@ -217,16 +241,18 @@ static void pcie_aspm_configure_common_clock(struct pci_dev *pdev)
217 pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16); 241 pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16);
218 242
219 /* Wait for link training end */ 243 /* Wait for link training end */
220 /* break out after waiting for 1 second */ 244 /* break out after waiting for timeout */
221 start_jiffies = jiffies; 245 start_jiffies = jiffies;
222 while ((jiffies - start_jiffies) < HZ) { 246 for (;;) {
223 pci_read_config_word(pdev, pos + PCI_EXP_LNKSTA, &reg16); 247 pci_read_config_word(pdev, pos + PCI_EXP_LNKSTA, &reg16);
224 if (!(reg16 & PCI_EXP_LNKSTA_LT)) 248 if (!(reg16 & PCI_EXP_LNKSTA_LT))
225 break; 249 break;
226 cpu_relax(); 250 if (time_after(jiffies, start_jiffies + LINK_RETRAIN_TIMEOUT))
251 break;
252 msleep(1);
227 } 253 }
228 /* training failed -> recover */ 254 /* training failed -> recover */
229 if ((jiffies - start_jiffies) >= HZ) { 255 if (reg16 & PCI_EXP_LNKSTA_LT) {
230 dev_printk (KERN_ERR, &pdev->dev, "ASPM: Could not configure" 256 dev_printk (KERN_ERR, &pdev->dev, "ASPM: Could not configure"
231 " common clock\n"); 257 " common clock\n");
232 i = 0; 258 i = 0;
@@ -419,9 +445,9 @@ static unsigned int pcie_aspm_check_state(struct pci_dev *pdev,
419{ 445{
420 struct pci_dev *child_dev; 446 struct pci_dev *child_dev;
421 447
422 /* If no child, disable the link */ 448 /* If no child, ignore the link */
423 if (list_empty(&pdev->subordinate->devices)) 449 if (list_empty(&pdev->subordinate->devices))
424 return 0; 450 return state;
425 list_for_each_entry(child_dev, &pdev->subordinate->devices, bus_list) { 451 list_for_each_entry(child_dev, &pdev->subordinate->devices, bus_list) {
426 if (child_dev->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) { 452 if (child_dev->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) {
427 /* 453 /*
@@ -462,6 +488,9 @@ static void __pcie_aspm_config_link(struct pci_dev *pdev, unsigned int state)
462 int valid = 1; 488 int valid = 1;
463 struct pcie_link_state *link_state = pdev->link_state; 489 struct pcie_link_state *link_state = pdev->link_state;
464 490
491 /* If no child, disable the link */
492 if (list_empty(&pdev->subordinate->devices))
493 state = 0;
465 /* 494 /*
466 * if the downstream component has pci bridge function, don't do ASPM 495 * if the downstream component has pci bridge function, don't do ASPM
467 * now 496 * now
@@ -493,20 +522,52 @@ static void __pcie_aspm_config_link(struct pci_dev *pdev, unsigned int state)
493 link_state->enabled_state = state; 522 link_state->enabled_state = state;
494} 523}
495 524
525static struct pcie_link_state *get_root_port_link(struct pcie_link_state *link)
526{
527 struct pcie_link_state *root_port_link = link;
528 while (root_port_link->parent)
529 root_port_link = root_port_link->parent;
530 return root_port_link;
531}
532
533/* check the whole hierarchy, and configure each link in the hierarchy */
496static void __pcie_aspm_configure_link_state(struct pci_dev *pdev, 534static void __pcie_aspm_configure_link_state(struct pci_dev *pdev,
497 unsigned int state) 535 unsigned int state)
498{ 536{
499 struct pcie_link_state *link_state = pdev->link_state; 537 struct pcie_link_state *link_state = pdev->link_state;
538 struct pcie_link_state *root_port_link = get_root_port_link(link_state);
539 struct pcie_link_state *leaf;
500 540
501 if (link_state->support_state == 0)
502 return;
503 state &= PCIE_LINK_STATE_L0S|PCIE_LINK_STATE_L1; 541 state &= PCIE_LINK_STATE_L0S|PCIE_LINK_STATE_L1;
504 542
505 /* state 0 means disabling aspm */ 543 /* check all links who have specific root port link */
506 state = pcie_aspm_check_state(pdev, state); 544 list_for_each_entry(leaf, &link_list, sibiling) {
545 if (!list_empty(&leaf->children) ||
546 get_root_port_link(leaf) != root_port_link)
547 continue;
548 state = pcie_aspm_check_state(leaf->pdev, state);
549 }
550 /* check root port link too in case it hasn't children */
551 state = pcie_aspm_check_state(root_port_link->pdev, state);
552
507 if (link_state->enabled_state == state) 553 if (link_state->enabled_state == state)
508 return; 554 return;
509 __pcie_aspm_config_link(pdev, state); 555
556 /*
557 * we must change the hierarchy. See comments in
558 * __pcie_aspm_config_link for the order
559 **/
560 if (state & PCIE_LINK_STATE_L1) {
561 list_for_each_entry(leaf, &link_list, sibiling) {
562 if (get_root_port_link(leaf) == root_port_link)
563 __pcie_aspm_config_link(leaf->pdev, state);
564 }
565 } else {
566 list_for_each_entry_reverse(leaf, &link_list, sibiling) {
567 if (get_root_port_link(leaf) == root_port_link)
568 __pcie_aspm_config_link(leaf->pdev, state);
569 }
570 }
510} 571}
511 572
512/* 573/*
@@ -570,6 +631,7 @@ void pcie_aspm_init_link_state(struct pci_dev *pdev)
570 unsigned int state; 631 unsigned int state;
571 struct pcie_link_state *link_state; 632 struct pcie_link_state *link_state;
572 int error = 0; 633 int error = 0;
634 int blacklist;
573 635
574 if (aspm_disabled || !pdev->is_pcie || pdev->link_state) 636 if (aspm_disabled || !pdev->is_pcie || pdev->link_state)
575 return; 637 return;
@@ -580,29 +642,58 @@ void pcie_aspm_init_link_state(struct pci_dev *pdev)
580 if (list_empty(&pdev->subordinate->devices)) 642 if (list_empty(&pdev->subordinate->devices))
581 goto out; 643 goto out;
582 644
583 if (pcie_aspm_sanity_check(pdev)) 645 blacklist = !!pcie_aspm_sanity_check(pdev);
584 goto out;
585 646
586 mutex_lock(&aspm_lock); 647 mutex_lock(&aspm_lock);
587 648
588 link_state = kzalloc(sizeof(*link_state), GFP_KERNEL); 649 link_state = kzalloc(sizeof(*link_state), GFP_KERNEL);
589 if (!link_state) 650 if (!link_state)
590 goto unlock_out; 651 goto unlock_out;
591 pdev->link_state = link_state;
592 652
593 pcie_aspm_configure_common_clock(pdev); 653 link_state->downstream_has_switch = pcie_aspm_downstream_has_switch(pdev);
654 INIT_LIST_HEAD(&link_state->children);
655 INIT_LIST_HEAD(&link_state->link);
656 if (pdev->bus->self) {/* this is a switch */
657 struct pcie_link_state *parent_link_state;
594 658
595 pcie_aspm_cap_init(pdev); 659 parent_link_state = pdev->bus->parent->self->link_state;
660 if (!parent_link_state) {
661 kfree(link_state);
662 goto unlock_out;
663 }
664 list_add(&link_state->link, &parent_link_state->children);
665 link_state->parent = parent_link_state;
666 }
596 667
597 /* config link state to avoid BIOS error */ 668 pdev->link_state = link_state;
598 state = pcie_aspm_check_state(pdev, policy_to_aspm_state(pdev));
599 __pcie_aspm_config_link(pdev, state);
600 669
601 pcie_check_clock_pm(pdev); 670 if (!blacklist) {
671 pcie_aspm_configure_common_clock(pdev);
672 pcie_aspm_cap_init(pdev);
673 } else {
674 link_state->enabled_state = PCIE_LINK_STATE_L0S|PCIE_LINK_STATE_L1;
675 link_state->bios_aspm_state = 0;
676 /* Set support state to 0, so we will disable ASPM later */
677 link_state->support_state = 0;
678 }
602 679
603 link_state->pdev = pdev; 680 link_state->pdev = pdev;
604 list_add(&link_state->sibiling, &link_list); 681 list_add(&link_state->sibiling, &link_list);
605 682
683 if (link_state->downstream_has_switch) {
684 /*
685 * If link has switch, delay the link config. The leaf link
686 * initialization will config the whole hierarchy. but we must
687 * make sure BIOS doesn't set unsupported link state
688 **/
689 state = pcie_aspm_check_state(pdev, link_state->bios_aspm_state);
690 __pcie_aspm_config_link(pdev, state);
691 } else
692 __pcie_aspm_configure_link_state(pdev,
693 policy_to_aspm_state(pdev));
694
695 pcie_check_clock_pm(pdev, blacklist);
696
606unlock_out: 697unlock_out:
607 if (error) 698 if (error)
608 free_link_state(pdev); 699 free_link_state(pdev);
@@ -635,6 +726,7 @@ void pcie_aspm_exit_link_state(struct pci_dev *pdev)
635 /* All functions are removed, so just disable ASPM for the link */ 726 /* All functions are removed, so just disable ASPM for the link */
636 __pcie_aspm_config_one_dev(parent, 0); 727 __pcie_aspm_config_one_dev(parent, 0);
637 list_del(&link_state->sibiling); 728 list_del(&link_state->sibiling);
729 list_del(&link_state->link);
638 /* Clock PM is for endpoint device */ 730 /* Clock PM is for endpoint device */
639 731
640 free_link_state(parent); 732 free_link_state(parent);
@@ -857,24 +949,15 @@ void pcie_no_aspm(void)
857 aspm_disabled = 1; 949 aspm_disabled = 1;
858} 950}
859 951
860#ifdef CONFIG_ACPI 952/**
861#include <acpi/acpi_bus.h> 953 * pcie_aspm_enabled - is PCIe ASPM enabled?
862#include <linux/pci-acpi.h> 954 *
863static void pcie_aspm_platform_init(void) 955 * Returns true if ASPM has not been disabled by the command-line option
864{ 956 * pcie_aspm=off.
865 pcie_osc_support_set(OSC_ACTIVE_STATE_PWR_SUPPORT| 957 **/
866 OSC_CLOCK_PWR_CAPABILITY_SUPPORT); 958int pcie_aspm_enabled(void)
867}
868#else
869static inline void pcie_aspm_platform_init(void) { }
870#endif
871
872static int __init pcie_aspm_init(void)
873{ 959{
874 if (aspm_disabled) 960 return !aspm_disabled;
875 return 0;
876 pcie_aspm_platform_init();
877 return 0;
878} 961}
962EXPORT_SYMBOL(pcie_aspm_enabled);
879 963
880fs_initcall(pcie_aspm_init);
diff --git a/drivers/pci/pcie/portdrv_bus.c b/drivers/pci/pcie/portdrv_bus.c
index 359fe5568df1..eec89b767f9f 100644
--- a/drivers/pci/pcie/portdrv_bus.c
+++ b/drivers/pci/pcie/portdrv_bus.c
@@ -16,14 +16,10 @@
16#include "portdrv.h" 16#include "portdrv.h"
17 17
18static int pcie_port_bus_match(struct device *dev, struct device_driver *drv); 18static int pcie_port_bus_match(struct device *dev, struct device_driver *drv);
19static int pcie_port_bus_suspend(struct device *dev, pm_message_t state);
20static int pcie_port_bus_resume(struct device *dev);
21 19
22struct bus_type pcie_port_bus_type = { 20struct bus_type pcie_port_bus_type = {
23 .name = "pci_express", 21 .name = "pci_express",
24 .match = pcie_port_bus_match, 22 .match = pcie_port_bus_match,
25 .suspend = pcie_port_bus_suspend,
26 .resume = pcie_port_bus_resume,
27}; 23};
28EXPORT_SYMBOL_GPL(pcie_port_bus_type); 24EXPORT_SYMBOL_GPL(pcie_port_bus_type);
29 25
@@ -49,32 +45,12 @@ static int pcie_port_bus_match(struct device *dev, struct device_driver *drv)
49 return 1; 45 return 1;
50} 46}
51 47
52static int pcie_port_bus_suspend(struct device *dev, pm_message_t state) 48int pcie_port_bus_register(void)
53{ 49{
54 struct pcie_device *pciedev; 50 return bus_register(&pcie_port_bus_type);
55 struct pcie_port_service_driver *driver;
56
57 if (!dev || !dev->driver)
58 return 0;
59
60 pciedev = to_pcie_device(dev);
61 driver = to_service_driver(dev->driver);
62 if (driver && driver->suspend)
63 driver->suspend(pciedev, state);
64 return 0;
65} 51}
66 52
67static int pcie_port_bus_resume(struct device *dev) 53void pcie_port_bus_unregister(void)
68{ 54{
69 struct pcie_device *pciedev; 55 bus_unregister(&pcie_port_bus_type);
70 struct pcie_port_service_driver *driver;
71
72 if (!dev || !dev->driver)
73 return 0;
74
75 pciedev = to_pcie_device(dev);
76 driver = to_service_driver(dev->driver);
77 if (driver && driver->resume)
78 driver->resume(pciedev);
79 return 0;
80} 56}
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index 2e091e014829..8b3f8c18032f 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -19,91 +19,15 @@
19 19
20extern int pcie_mch_quirk; /* MSI-quirk Indicator */ 20extern int pcie_mch_quirk; /* MSI-quirk Indicator */
21 21
22static int pcie_port_probe_service(struct device *dev) 22/**
23{ 23 * release_pcie_device - free PCI Express port service device structure
24 struct pcie_device *pciedev; 24 * @dev: Port service device to release
25 struct pcie_port_service_driver *driver; 25 *
26 int status; 26 * Invoked automatically when device is being removed in response to
27 27 * device_unregister(dev). Release all resources being claimed.
28 if (!dev || !dev->driver)
29 return -ENODEV;
30
31 driver = to_service_driver(dev->driver);
32 if (!driver || !driver->probe)
33 return -ENODEV;
34
35 pciedev = to_pcie_device(dev);
36 status = driver->probe(pciedev, driver->id_table);
37 if (!status) {
38 dev_printk(KERN_DEBUG, dev, "service driver %s loaded\n",
39 driver->name);
40 get_device(dev);
41 }
42 return status;
43}
44
45static int pcie_port_remove_service(struct device *dev)
46{
47 struct pcie_device *pciedev;
48 struct pcie_port_service_driver *driver;
49
50 if (!dev || !dev->driver)
51 return 0;
52
53 pciedev = to_pcie_device(dev);
54 driver = to_service_driver(dev->driver);
55 if (driver && driver->remove) {
56 dev_printk(KERN_DEBUG, dev, "unloading service driver %s\n",
57 driver->name);
58 driver->remove(pciedev);
59 put_device(dev);
60 }
61 return 0;
62}
63
64static void pcie_port_shutdown_service(struct device *dev) {}
65
66static int pcie_port_suspend_service(struct device *dev, pm_message_t state)
67{
68 struct pcie_device *pciedev;
69 struct pcie_port_service_driver *driver;
70
71 if (!dev || !dev->driver)
72 return 0;
73
74 pciedev = to_pcie_device(dev);
75 driver = to_service_driver(dev->driver);
76 if (driver && driver->suspend)
77 driver->suspend(pciedev, state);
78 return 0;
79}
80
81static int pcie_port_resume_service(struct device *dev)
82{
83 struct pcie_device *pciedev;
84 struct pcie_port_service_driver *driver;
85
86 if (!dev || !dev->driver)
87 return 0;
88
89 pciedev = to_pcie_device(dev);
90 driver = to_service_driver(dev->driver);
91
92 if (driver && driver->resume)
93 driver->resume(pciedev);
94 return 0;
95}
96
97/*
98 * release_pcie_device
99 *
100 * Being invoked automatically when device is being removed
101 * in response to device_unregister(dev) call.
102 * Release all resources being claimed.
103 */ 28 */
104static void release_pcie_device(struct device *dev) 29static void release_pcie_device(struct device *dev)
105{ 30{
106 dev_printk(KERN_DEBUG, dev, "free port service\n");
107 kfree(to_pcie_device(dev)); 31 kfree(to_pcie_device(dev));
108} 32}
109 33
@@ -128,7 +52,16 @@ static int is_msi_quirked(struct pci_dev *dev)
128 } 52 }
129 return quirk; 53 return quirk;
130} 54}
131 55
56/**
57 * assign_interrupt_mode - choose interrupt mode for PCI Express port services
58 * (INTx, MSI-X, MSI) and set up vectors
59 * @dev: PCI Express port to handle
60 * @vectors: Array of interrupt vectors to populate
61 * @mask: Bitmask of port capabilities returned by get_port_device_capability()
62 *
63 * Return value: Interrupt mode associated with the port
64 */
132static int assign_interrupt_mode(struct pci_dev *dev, int *vectors, int mask) 65static int assign_interrupt_mode(struct pci_dev *dev, int *vectors, int mask)
133{ 66{
134 int i, pos, nvec, status = -EINVAL; 67 int i, pos, nvec, status = -EINVAL;
@@ -150,7 +83,6 @@ static int assign_interrupt_mode(struct pci_dev *dev, int *vectors, int mask)
150 if (pos) { 83 if (pos) {
151 struct msix_entry msix_entries[PCIE_PORT_DEVICE_MAXSERVICES] = 84 struct msix_entry msix_entries[PCIE_PORT_DEVICE_MAXSERVICES] =
152 {{0, 0}, {0, 1}, {0, 2}, {0, 3}}; 85 {{0, 0}, {0, 1}, {0, 2}, {0, 3}};
153 dev_info(&dev->dev, "found MSI-X capability\n");
154 status = pci_enable_msix(dev, msix_entries, nvec); 86 status = pci_enable_msix(dev, msix_entries, nvec);
155 if (!status) { 87 if (!status) {
156 int j = 0; 88 int j = 0;
@@ -165,7 +97,6 @@ static int assign_interrupt_mode(struct pci_dev *dev, int *vectors, int mask)
165 if (status) { 97 if (status) {
166 pos = pci_find_capability(dev, PCI_CAP_ID_MSI); 98 pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
167 if (pos) { 99 if (pos) {
168 dev_info(&dev->dev, "found MSI capability\n");
169 status = pci_enable_msi(dev); 100 status = pci_enable_msi(dev);
170 if (!status) { 101 if (!status) {
171 interrupt_mode = PCIE_PORT_MSI_MODE; 102 interrupt_mode = PCIE_PORT_MSI_MODE;
@@ -177,6 +108,16 @@ static int assign_interrupt_mode(struct pci_dev *dev, int *vectors, int mask)
177 return interrupt_mode; 108 return interrupt_mode;
178} 109}
179 110
111/**
112 * get_port_device_capability - discover capabilities of a PCI Express port
113 * @dev: PCI Express port to examine
114 *
115 * The capabilities are read from the port's PCI Express configuration registers
116 * as described in PCI Express Base Specification 1.0a sections 7.8.2, 7.8.9 and
117 * 7.9 - 7.11.
118 *
119 * Return value: Bitmask of discovered port capabilities
120 */
180static int get_port_device_capability(struct pci_dev *dev) 121static int get_port_device_capability(struct pci_dev *dev)
181{ 122{
182 int services = 0, pos; 123 int services = 0, pos;
@@ -204,6 +145,15 @@ static int get_port_device_capability(struct pci_dev *dev)
204 return services; 145 return services;
205} 146}
206 147
148/**
149 * pcie_device_init - initialize PCI Express port service device
150 * @dev: Port service device to initialize
151 * @parent: PCI Express port to associate the service device with
152 * @port_type: Type of the port
153 * @service_type: Type of service to associate with the service device
154 * @irq: Interrupt vector to associate with the service device
155 * @irq_mode: Interrupt mode of the service (INTx, MSI-X, MSI)
156 */
207static void pcie_device_init(struct pci_dev *parent, struct pcie_device *dev, 157static void pcie_device_init(struct pci_dev *parent, struct pcie_device *dev,
208 int port_type, int service_type, int irq, int irq_mode) 158 int port_type, int service_type, int irq, int irq_mode)
209{ 159{
@@ -224,11 +174,19 @@ static void pcie_device_init(struct pci_dev *parent, struct pcie_device *dev,
224 device->driver = NULL; 174 device->driver = NULL;
225 device->driver_data = NULL; 175 device->driver_data = NULL;
226 device->release = release_pcie_device; /* callback to free pcie dev */ 176 device->release = release_pcie_device; /* callback to free pcie dev */
227 snprintf(device->bus_id, sizeof(device->bus_id), "%s:pcie%02x", 177 dev_set_name(device, "%s:pcie%02x",
228 pci_name(parent), get_descriptor_id(port_type, service_type)); 178 pci_name(parent), get_descriptor_id(port_type, service_type));
229 device->parent = &parent->dev; 179 device->parent = &parent->dev;
230} 180}
231 181
182/**
183 * alloc_pcie_device - allocate PCI Express port service device structure
184 * @parent: PCI Express port to associate the service device with
185 * @port_type: Type of the port
186 * @service_type: Type of service to associate with the service device
187 * @irq: Interrupt vector to associate with the service device
188 * @irq_mode: Interrupt mode of the service (INTx, MSI-X, MSI)
189 */
232static struct pcie_device* alloc_pcie_device(struct pci_dev *parent, 190static struct pcie_device* alloc_pcie_device(struct pci_dev *parent,
233 int port_type, int service_type, int irq, int irq_mode) 191 int port_type, int service_type, int irq, int irq_mode)
234{ 192{
@@ -239,10 +197,13 @@ static struct pcie_device* alloc_pcie_device(struct pci_dev *parent,
239 return NULL; 197 return NULL;
240 198
241 pcie_device_init(parent, device, port_type, service_type, irq,irq_mode); 199 pcie_device_init(parent, device, port_type, service_type, irq,irq_mode);
242 dev_printk(KERN_DEBUG, &device->device, "allocate port service\n");
243 return device; 200 return device;
244} 201}
245 202
203/**
204 * pcie_port_device_probe - check if device is a PCI Express port
205 * @dev: Device to check
206 */
246int pcie_port_device_probe(struct pci_dev *dev) 207int pcie_port_device_probe(struct pci_dev *dev)
247{ 208{
248 int pos, type; 209 int pos, type;
@@ -260,6 +221,13 @@ int pcie_port_device_probe(struct pci_dev *dev)
260 return -ENODEV; 221 return -ENODEV;
261} 222}
262 223
224/**
225 * pcie_port_device_register - register PCI Express port
226 * @dev: PCI Express port to register
227 *
228 * Allocate the port extension structure and register services associated with
229 * the port.
230 */
263int pcie_port_device_register(struct pci_dev *dev) 231int pcie_port_device_register(struct pci_dev *dev)
264{ 232{
265 struct pcie_port_device_ext *p_ext; 233 struct pcie_port_device_ext *p_ext;
@@ -323,6 +291,11 @@ static int suspend_iter(struct device *dev, void *data)
323 return 0; 291 return 0;
324} 292}
325 293
294/**
295 * pcie_port_device_suspend - suspend port services associated with a PCIe port
296 * @dev: PCI Express port to handle
297 * @state: Representation of system power management transition in progress
298 */
326int pcie_port_device_suspend(struct pci_dev *dev, pm_message_t state) 299int pcie_port_device_suspend(struct pci_dev *dev, pm_message_t state)
327{ 300{
328 return device_for_each_child(&dev->dev, &state, suspend_iter); 301 return device_for_each_child(&dev->dev, &state, suspend_iter);
@@ -341,6 +314,10 @@ static int resume_iter(struct device *dev, void *data)
341 return 0; 314 return 0;
342} 315}
343 316
317/**
318 * pcie_port_device_suspend - resume port services associated with a PCIe port
319 * @dev: PCI Express port to handle
320 */
344int pcie_port_device_resume(struct pci_dev *dev) 321int pcie_port_device_resume(struct pci_dev *dev)
345{ 322{
346 return device_for_each_child(&dev->dev, NULL, resume_iter); 323 return device_for_each_child(&dev->dev, NULL, resume_iter);
@@ -363,6 +340,13 @@ static int remove_iter(struct device *dev, void *data)
363 return 0; 340 return 0;
364} 341}
365 342
343/**
344 * pcie_port_device_remove - unregister PCI Express port service devices
345 * @dev: PCI Express port the service devices to unregister are associated with
346 *
347 * Remove PCI Express port service devices associated with given port and
348 * disable MSI-X or MSI for the port.
349 */
366void pcie_port_device_remove(struct pci_dev *dev) 350void pcie_port_device_remove(struct pci_dev *dev)
367{ 351{
368 struct device *device; 352 struct device *device;
@@ -386,16 +370,80 @@ void pcie_port_device_remove(struct pci_dev *dev)
386 pci_disable_msi(dev); 370 pci_disable_msi(dev);
387} 371}
388 372
389int pcie_port_bus_register(void) 373/**
374 * pcie_port_probe_service - probe driver for given PCI Express port service
375 * @dev: PCI Express port service device to probe against
376 *
377 * If PCI Express port service driver is registered with
378 * pcie_port_service_register(), this function will be called by the driver core
379 * whenever match is found between the driver and a port service device.
380 */
381static int pcie_port_probe_service(struct device *dev)
390{ 382{
391 return bus_register(&pcie_port_bus_type); 383 struct pcie_device *pciedev;
384 struct pcie_port_service_driver *driver;
385 int status;
386
387 if (!dev || !dev->driver)
388 return -ENODEV;
389
390 driver = to_service_driver(dev->driver);
391 if (!driver || !driver->probe)
392 return -ENODEV;
393
394 pciedev = to_pcie_device(dev);
395 status = driver->probe(pciedev, driver->id_table);
396 if (!status) {
397 dev_printk(KERN_DEBUG, dev, "service driver %s loaded\n",
398 driver->name);
399 get_device(dev);
400 }
401 return status;
392} 402}
393 403
394void pcie_port_bus_unregister(void) 404/**
405 * pcie_port_remove_service - detach driver from given PCI Express port service
406 * @dev: PCI Express port service device to handle
407 *
408 * If PCI Express port service driver is registered with
409 * pcie_port_service_register(), this function will be called by the driver core
410 * when device_unregister() is called for the port service device associated
411 * with the driver.
412 */
413static int pcie_port_remove_service(struct device *dev)
395{ 414{
396 bus_unregister(&pcie_port_bus_type); 415 struct pcie_device *pciedev;
416 struct pcie_port_service_driver *driver;
417
418 if (!dev || !dev->driver)
419 return 0;
420
421 pciedev = to_pcie_device(dev);
422 driver = to_service_driver(dev->driver);
423 if (driver && driver->remove) {
424 dev_printk(KERN_DEBUG, dev, "unloading service driver %s\n",
425 driver->name);
426 driver->remove(pciedev);
427 put_device(dev);
428 }
429 return 0;
397} 430}
398 431
432/**
433 * pcie_port_shutdown_service - shut down given PCI Express port service
434 * @dev: PCI Express port service device to handle
435 *
436 * If PCI Express port service driver is registered with
437 * pcie_port_service_register(), this function will be called by the driver core
438 * when device_shutdown() is called for the port service device associated
439 * with the driver.
440 */
441static void pcie_port_shutdown_service(struct device *dev) {}
442
443/**
444 * pcie_port_service_register - register PCI Express port service driver
445 * @new: PCI Express port service driver to register
446 */
399int pcie_port_service_register(struct pcie_port_service_driver *new) 447int pcie_port_service_register(struct pcie_port_service_driver *new)
400{ 448{
401 new->driver.name = (char *)new->name; 449 new->driver.name = (char *)new->name;
@@ -403,15 +451,17 @@ int pcie_port_service_register(struct pcie_port_service_driver *new)
403 new->driver.probe = pcie_port_probe_service; 451 new->driver.probe = pcie_port_probe_service;
404 new->driver.remove = pcie_port_remove_service; 452 new->driver.remove = pcie_port_remove_service;
405 new->driver.shutdown = pcie_port_shutdown_service; 453 new->driver.shutdown = pcie_port_shutdown_service;
406 new->driver.suspend = pcie_port_suspend_service;
407 new->driver.resume = pcie_port_resume_service;
408 454
409 return driver_register(&new->driver); 455 return driver_register(&new->driver);
410} 456}
411 457
412void pcie_port_service_unregister(struct pcie_port_service_driver *new) 458/**
459 * pcie_port_service_unregister - unregister PCI Express port service driver
460 * @drv: PCI Express port service driver to unregister
461 */
462void pcie_port_service_unregister(struct pcie_port_service_driver *drv)
413{ 463{
414 driver_unregister(&new->driver); 464 driver_unregister(&drv->driver);
415} 465}
416 466
417EXPORT_SYMBOL(pcie_port_service_register); 467EXPORT_SYMBOL(pcie_port_service_register);
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
index 584422da8d8b..99a914a027f8 100644
--- a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -41,7 +41,6 @@ static int pcie_portdrv_restore_config(struct pci_dev *dev)
41{ 41{
42 int retval; 42 int retval;
43 43
44 pci_restore_state(dev);
45 retval = pci_enable_device(dev); 44 retval = pci_enable_device(dev);
46 if (retval) 45 if (retval)
47 return retval; 46 return retval;
@@ -52,11 +51,18 @@ static int pcie_portdrv_restore_config(struct pci_dev *dev)
52#ifdef CONFIG_PM 51#ifdef CONFIG_PM
53static int pcie_portdrv_suspend(struct pci_dev *dev, pm_message_t state) 52static int pcie_portdrv_suspend(struct pci_dev *dev, pm_message_t state)
54{ 53{
55 int ret = pcie_port_device_suspend(dev, state); 54 return pcie_port_device_suspend(dev, state);
56 55
57 if (!ret) 56}
58 ret = pcie_portdrv_save_config(dev); 57
59 return ret; 58static int pcie_portdrv_suspend_late(struct pci_dev *dev, pm_message_t state)
59{
60 return pci_save_state(dev);
61}
62
63static int pcie_portdrv_resume_early(struct pci_dev *dev)
64{
65 return pci_restore_state(dev);
60} 66}
61 67
62static int pcie_portdrv_resume(struct pci_dev *dev) 68static int pcie_portdrv_resume(struct pci_dev *dev)
@@ -66,6 +72,8 @@ static int pcie_portdrv_resume(struct pci_dev *dev)
66} 72}
67#else 73#else
68#define pcie_portdrv_suspend NULL 74#define pcie_portdrv_suspend NULL
75#define pcie_portdrv_suspend_late NULL
76#define pcie_portdrv_resume_early NULL
69#define pcie_portdrv_resume NULL 77#define pcie_portdrv_resume NULL
70#endif 78#endif
71 79
@@ -221,6 +229,7 @@ static pci_ers_result_t pcie_portdrv_slot_reset(struct pci_dev *dev)
221 229
222 /* If fatal, restore cfg space for possible link reset at upstream */ 230 /* If fatal, restore cfg space for possible link reset at upstream */
223 if (dev->error_state == pci_channel_io_frozen) { 231 if (dev->error_state == pci_channel_io_frozen) {
232 pci_restore_state(dev);
224 pcie_portdrv_restore_config(dev); 233 pcie_portdrv_restore_config(dev);
225 pci_enable_pcie_error_reporting(dev); 234 pci_enable_pcie_error_reporting(dev);
226 } 235 }
@@ -283,6 +292,8 @@ static struct pci_driver pcie_portdriver = {
283 .remove = pcie_portdrv_remove, 292 .remove = pcie_portdrv_remove,
284 293
285 .suspend = pcie_portdrv_suspend, 294 .suspend = pcie_portdrv_suspend,
295 .suspend_late = pcie_portdrv_suspend_late,
296 .resume_early = pcie_portdrv_resume_early,
286 .resume = pcie_portdrv_resume, 297 .resume = pcie_portdrv_resume,
287 298
288 .err_handler = &pcie_portdrv_err_handler, 299 .err_handler = &pcie_portdrv_err_handler,
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 5b3f5937ecf5..55ec44a27e89 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -51,12 +51,12 @@ static ssize_t pci_bus_show_cpuaffinity(struct device *dev,
51 char *buf) 51 char *buf)
52{ 52{
53 int ret; 53 int ret;
54 cpumask_t cpumask; 54 const struct cpumask *cpumask;
55 55
56 cpumask = pcibus_to_cpumask(to_pci_bus(dev)); 56 cpumask = cpumask_of_pcibus(to_pci_bus(dev));
57 ret = type? 57 ret = type?
58 cpulist_scnprintf(buf, PAGE_SIZE-2, &cpumask) : 58 cpulist_scnprintf(buf, PAGE_SIZE-2, cpumask) :
59 cpumask_scnprintf(buf, PAGE_SIZE-2, &cpumask); 59 cpumask_scnprintf(buf, PAGE_SIZE-2, cpumask);
60 buf[ret++] = '\n'; 60 buf[ret++] = '\n';
61 buf[ret] = '\0'; 61 buf[ret] = '\0';
62 return ret; 62 return ret;
@@ -135,13 +135,6 @@ static u64 pci_size(u64 base, u64 maxbase, u64 mask)
135 return size; 135 return size;
136} 136}
137 137
138enum pci_bar_type {
139 pci_bar_unknown, /* Standard PCI BAR probe */
140 pci_bar_io, /* An io port BAR */
141 pci_bar_mem32, /* A 32-bit memory BAR */
142 pci_bar_mem64, /* A 64-bit memory BAR */
143};
144
145static inline enum pci_bar_type decode_bar(struct resource *res, u32 bar) 138static inline enum pci_bar_type decode_bar(struct resource *res, u32 bar)
146{ 139{
147 if ((bar & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_IO) { 140 if ((bar & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_IO) {
@@ -156,11 +149,16 @@ static inline enum pci_bar_type decode_bar(struct resource *res, u32 bar)
156 return pci_bar_mem32; 149 return pci_bar_mem32;
157} 150}
158 151
159/* 152/**
160 * If the type is not unknown, we assume that the lowest bit is 'enable'. 153 * pci_read_base - read a PCI BAR
161 * Returns 1 if the BAR was 64-bit and 0 if it was 32-bit. 154 * @dev: the PCI device
155 * @type: type of the BAR
156 * @res: resource buffer to be filled in
157 * @pos: BAR position in the config space
158 *
159 * Returns 1 if the BAR is 64-bit, or 0 if 32-bit.
162 */ 160 */
163static int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, 161int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
164 struct resource *res, unsigned int pos) 162 struct resource *res, unsigned int pos)
165{ 163{
166 u32 l, sz, mask; 164 u32 l, sz, mask;
@@ -400,19 +398,17 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
400 if (!child) 398 if (!child)
401 return NULL; 399 return NULL;
402 400
403 child->self = bridge;
404 child->parent = parent; 401 child->parent = parent;
405 child->ops = parent->ops; 402 child->ops = parent->ops;
406 child->sysdata = parent->sysdata; 403 child->sysdata = parent->sysdata;
407 child->bus_flags = parent->bus_flags; 404 child->bus_flags = parent->bus_flags;
408 child->bridge = get_device(&bridge->dev);
409 405
410 /* initialize some portions of the bus device, but don't register it 406 /* initialize some portions of the bus device, but don't register it
411 * now as the parent is not properly set up yet. This device will get 407 * now as the parent is not properly set up yet. This device will get
412 * registered later in pci_bus_add_devices() 408 * registered later in pci_bus_add_devices()
413 */ 409 */
414 child->dev.class = &pcibus_class; 410 child->dev.class = &pcibus_class;
415 sprintf(child->dev.bus_id, "%04x:%02x", pci_domain_nr(child), busnr); 411 dev_set_name(&child->dev, "%04x:%02x", pci_domain_nr(child), busnr);
416 412
417 /* 413 /*
418 * Set up the primary, secondary and subordinate 414 * Set up the primary, secondary and subordinate
@@ -422,8 +418,14 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
422 child->primary = parent->secondary; 418 child->primary = parent->secondary;
423 child->subordinate = 0xff; 419 child->subordinate = 0xff;
424 420
421 if (!bridge)
422 return child;
423
424 child->self = bridge;
425 child->bridge = get_device(&bridge->dev);
426
425 /* Set up default resource pointers and names.. */ 427 /* Set up default resource pointers and names.. */
426 for (i = 0; i < 4; i++) { 428 for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++) {
427 child->resource[i] = &bridge->resource[PCI_BRIDGE_RESOURCES+i]; 429 child->resource[i] = &bridge->resource[PCI_BRIDGE_RESOURCES+i];
428 child->resource[i]->name = child->name; 430 child->resource[i]->name = child->name;
429 } 431 }
@@ -958,8 +960,12 @@ static void pci_init_capabilities(struct pci_dev *dev)
958 /* MSI/MSI-X list */ 960 /* MSI/MSI-X list */
959 pci_msi_init_pci_dev(dev); 961 pci_msi_init_pci_dev(dev);
960 962
963 /* Buffers for saving PCIe and PCI-X capabilities */
964 pci_allocate_cap_save_buffers(dev);
965
961 /* Power Management */ 966 /* Power Management */
962 pci_pm_init(dev); 967 pci_pm_init(dev);
968 platform_pci_wakeup_init(dev);
963 969
964 /* Vital Product Data */ 970 /* Vital Product Data */
965 pci_vpd_pci22_init(dev); 971 pci_vpd_pci22_init(dev);
@@ -1130,7 +1136,7 @@ struct pci_bus * pci_create_bus(struct device *parent,
1130 memset(dev, 0, sizeof(*dev)); 1136 memset(dev, 0, sizeof(*dev));
1131 dev->parent = parent; 1137 dev->parent = parent;
1132 dev->release = pci_release_bus_bridge_dev; 1138 dev->release = pci_release_bus_bridge_dev;
1133 sprintf(dev->bus_id, "pci%04x:%02x", pci_domain_nr(b), bus); 1139 dev_set_name(dev, "pci%04x:%02x", pci_domain_nr(b), bus);
1134 error = device_register(dev); 1140 error = device_register(dev);
1135 if (error) 1141 if (error)
1136 goto dev_reg_err; 1142 goto dev_reg_err;
@@ -1141,7 +1147,7 @@ struct pci_bus * pci_create_bus(struct device *parent,
1141 1147
1142 b->dev.class = &pcibus_class; 1148 b->dev.class = &pcibus_class;
1143 b->dev.parent = b->bridge; 1149 b->dev.parent = b->bridge;
1144 sprintf(b->dev.bus_id, "%04x:%02x", pci_domain_nr(b), bus); 1150 dev_set_name(&b->dev, "%04x:%02x", pci_domain_nr(b), bus);
1145 error = device_register(&b->dev); 1151 error = device_register(&b->dev);
1146 if (error) 1152 if (error)
1147 goto class_dev_reg_err; 1153 goto class_dev_reg_err;
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index e1098c302c45..593bb844b8db 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -252,11 +252,20 @@ static int proc_bus_pci_mmap(struct file *file, struct vm_area_struct *vma)
252 const struct proc_dir_entry *dp = PDE(inode); 252 const struct proc_dir_entry *dp = PDE(inode);
253 struct pci_dev *dev = dp->data; 253 struct pci_dev *dev = dp->data;
254 struct pci_filp_private *fpriv = file->private_data; 254 struct pci_filp_private *fpriv = file->private_data;
255 int ret; 255 int i, ret;
256 256
257 if (!capable(CAP_SYS_RAWIO)) 257 if (!capable(CAP_SYS_RAWIO))
258 return -EPERM; 258 return -EPERM;
259 259
260 /* Make sure the caller is mapping a real resource for this device */
261 for (i = 0; i < PCI_ROM_RESOURCE; i++) {
262 if (pci_mmap_fits(dev, i, vma))
263 break;
264 }
265
266 if (i >= PCI_ROM_RESOURCE)
267 return -ENODEV;
268
260 ret = pci_mmap_page_range(dev, vma, 269 ret = pci_mmap_page_range(dev, vma,
261 fpriv->mmap_state, 270 fpriv->mmap_state,
262 fpriv->write_combine); 271 fpriv->write_combine);
@@ -352,15 +361,16 @@ static int show_device(struct seq_file *m, void *v)
352 dev->vendor, 361 dev->vendor,
353 dev->device, 362 dev->device,
354 dev->irq); 363 dev->irq);
355 /* Here should be 7 and not PCI_NUM_RESOURCES as we need to preserve compatibility */ 364
356 for (i=0; i<7; i++) { 365 /* only print standard and ROM resources to preserve compatibility */
366 for (i = 0; i <= PCI_ROM_RESOURCE; i++) {
357 resource_size_t start, end; 367 resource_size_t start, end;
358 pci_resource_to_user(dev, i, &dev->resource[i], &start, &end); 368 pci_resource_to_user(dev, i, &dev->resource[i], &start, &end);
359 seq_printf(m, "\t%16llx", 369 seq_printf(m, "\t%16llx",
360 (unsigned long long)(start | 370 (unsigned long long)(start |
361 (dev->resource[i].flags & PCI_REGION_FLAG_MASK))); 371 (dev->resource[i].flags & PCI_REGION_FLAG_MASK)));
362 } 372 }
363 for (i=0; i<7; i++) { 373 for (i = 0; i <= PCI_ROM_RESOURCE; i++) {
364 resource_size_t start, end; 374 resource_size_t start, end;
365 pci_resource_to_user(dev, i, &dev->resource[i], &start, &end); 375 pci_resource_to_user(dev, i, &dev->resource[i], &start, &end);
366 seq_printf(m, "\t%16llx", 376 seq_printf(m, "\t%16llx",
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index ce0985615133..baad093aafe3 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -56,7 +56,7 @@ static void quirk_passive_release(struct pci_dev *dev)
56 while ((d = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371SB_0, d))) { 56 while ((d = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371SB_0, d))) {
57 pci_read_config_byte(d, 0x82, &dlc); 57 pci_read_config_byte(d, 0x82, &dlc);
58 if (!(dlc & 1<<1)) { 58 if (!(dlc & 1<<1)) {
59 dev_err(&d->dev, "PIIX3: Enabling Passive Release\n"); 59 dev_info(&d->dev, "PIIX3: Enabling Passive Release\n");
60 dlc |= 1<<1; 60 dlc |= 1<<1;
61 pci_write_config_byte(d, 0x82, dlc); 61 pci_write_config_byte(d, 0x82, dlc);
62 } 62 }
@@ -449,7 +449,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12,
449DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, quirk_ich4_lpc_acpi); 449DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, quirk_ich4_lpc_acpi);
450DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_1, quirk_ich4_lpc_acpi); 450DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_1, quirk_ich4_lpc_acpi);
451 451
452static void __devinit quirk_ich6_lpc_acpi(struct pci_dev *dev) 452static void __devinit ich6_lpc_acpi_gpio(struct pci_dev *dev)
453{ 453{
454 u32 region; 454 u32 region;
455 455
@@ -459,20 +459,95 @@ static void __devinit quirk_ich6_lpc_acpi(struct pci_dev *dev)
459 pci_read_config_dword(dev, 0x48, &region); 459 pci_read_config_dword(dev, 0x48, &region);
460 quirk_io_region(dev, region, 64, PCI_BRIDGE_RESOURCES+1, "ICH6 GPIO"); 460 quirk_io_region(dev, region, 64, PCI_BRIDGE_RESOURCES+1, "ICH6 GPIO");
461} 461}
462DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_0, quirk_ich6_lpc_acpi); 462
463DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, quirk_ich6_lpc_acpi); 463static void __devinit ich6_lpc_generic_decode(struct pci_dev *dev, unsigned reg, const char *name, int dynsize)
464DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0, quirk_ich6_lpc_acpi); 464{
465DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1, quirk_ich6_lpc_acpi); 465 u32 val;
466DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_31, quirk_ich6_lpc_acpi); 466 u32 size, base;
467DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_0, quirk_ich6_lpc_acpi); 467
468DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_2, quirk_ich6_lpc_acpi); 468 pci_read_config_dword(dev, reg, &val);
469DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_3, quirk_ich6_lpc_acpi); 469
470DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_1, quirk_ich6_lpc_acpi); 470 /* Enabled? */
471DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_4, quirk_ich6_lpc_acpi); 471 if (!(val & 1))
472DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_2, quirk_ich6_lpc_acpi); 472 return;
473DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_4, quirk_ich6_lpc_acpi); 473 base = val & 0xfffc;
474DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_7, quirk_ich6_lpc_acpi); 474 if (dynsize) {
475DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_8, quirk_ich6_lpc_acpi); 475 /*
476 * This is not correct. It is 16, 32 or 64 bytes depending on
477 * register D31:F0:ADh bits 5:4.
478 *
479 * But this gets us at least _part_ of it.
480 */
481 size = 16;
482 } else {
483 size = 128;
484 }
485 base &= ~(size-1);
486
487 /* Just print it out for now. We should reserve it after more debugging */
488 dev_info(&dev->dev, "%s PIO at %04x-%04x\n", name, base, base+size-1);
489}
490
491static void __devinit quirk_ich6_lpc(struct pci_dev *dev)
492{
493 /* Shared ACPI/GPIO decode with all ICH6+ */
494 ich6_lpc_acpi_gpio(dev);
495
496 /* ICH6-specific generic IO decode */
497 ich6_lpc_generic_decode(dev, 0x84, "LPC Generic IO decode 1", 0);
498 ich6_lpc_generic_decode(dev, 0x88, "LPC Generic IO decode 2", 1);
499}
500DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_0, quirk_ich6_lpc);
501DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, quirk_ich6_lpc);
502
503static void __devinit ich7_lpc_generic_decode(struct pci_dev *dev, unsigned reg, const char *name)
504{
505 u32 val;
506 u32 mask, base;
507
508 pci_read_config_dword(dev, reg, &val);
509
510 /* Enabled? */
511 if (!(val & 1))
512 return;
513
514 /*
515 * IO base in bits 15:2, mask in bits 23:18, both
516 * are dword-based
517 */
518 base = val & 0xfffc;
519 mask = (val >> 16) & 0xfc;
520 mask |= 3;
521
522 /* Just print it out for now. We should reserve it after more debugging */
523 dev_info(&dev->dev, "%s PIO at %04x (mask %04x)\n", name, base, mask);
524}
525
526/* ICH7-10 has the same common LPC generic IO decode registers */
527static void __devinit quirk_ich7_lpc(struct pci_dev *dev)
528{
529 /* We share the common ACPI/DPIO decode with ICH6 */
530 ich6_lpc_acpi_gpio(dev);
531
532 /* And have 4 ICH7+ generic decodes */
533 ich7_lpc_generic_decode(dev, 0x84, "ICH7 LPC Generic IO decode 1");
534 ich7_lpc_generic_decode(dev, 0x88, "ICH7 LPC Generic IO decode 2");
535 ich7_lpc_generic_decode(dev, 0x8c, "ICH7 LPC Generic IO decode 3");
536 ich7_lpc_generic_decode(dev, 0x90, "ICH7 LPC Generic IO decode 4");
537}
538DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0, quirk_ich7_lpc);
539DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1, quirk_ich7_lpc);
540DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_31, quirk_ich7_lpc);
541DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_0, quirk_ich7_lpc);
542DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_2, quirk_ich7_lpc);
543DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_3, quirk_ich7_lpc);
544DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_1, quirk_ich7_lpc);
545DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_4, quirk_ich7_lpc);
546DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_2, quirk_ich7_lpc);
547DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_4, quirk_ich7_lpc);
548DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_7, quirk_ich7_lpc);
549DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_8, quirk_ich7_lpc);
550DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH10_1, quirk_ich7_lpc);
476 551
477/* 552/*
478 * VIA ACPI: One IO region pointed to by longword at 553 * VIA ACPI: One IO region pointed to by longword at
@@ -2074,11 +2149,12 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x4375,
2074 2149
2075#endif /* CONFIG_PCI_MSI */ 2150#endif /* CONFIG_PCI_MSI */
2076 2151
2077static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, struct pci_fixup *end) 2152static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f,
2153 struct pci_fixup *end)
2078{ 2154{
2079 while (f < end) { 2155 while (f < end) {
2080 if ((f->vendor == dev->vendor || f->vendor == (u16) PCI_ANY_ID) && 2156 if ((f->vendor == dev->vendor || f->vendor == (u16) PCI_ANY_ID) &&
2081 (f->device == dev->device || f->device == (u16) PCI_ANY_ID)) { 2157 (f->device == dev->device || f->device == (u16) PCI_ANY_ID)) {
2082 dev_dbg(&dev->dev, "calling %pF\n", f->hook); 2158 dev_dbg(&dev->dev, "calling %pF\n", f->hook);
2083 f->hook(dev); 2159 f->hook(dev);
2084 } 2160 }
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index ea979f2bc6db..704608945780 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -536,9 +536,8 @@ static void pci_bus_dump_res(struct pci_bus *bus)
536 if (!res) 536 if (!res)
537 continue; 537 continue;
538 538
539 printk(KERN_INFO "bus: %02x index %x %s: %pR\n", 539 dev_printk(KERN_DEBUG, &bus->dev, "resource %d %s %pR\n", i,
540 bus->number, i, 540 (res->flags & IORESOURCE_IO) ? "io: " : "mem:", res);
541 (res->flags & IORESOURCE_IO) ? "io port" : "mmio", res);
542 } 541 }
543} 542}
544 543
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 2dbd96cce2d8..32e8d88a4619 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -26,11 +26,13 @@
26#include "pci.h" 26#include "pci.h"
27 27
28 28
29void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno) 29void pci_update_resource(struct pci_dev *dev, int resno)
30{ 30{
31 struct pci_bus_region region; 31 struct pci_bus_region region;
32 u32 new, check, mask; 32 u32 new, check, mask;
33 int reg; 33 int reg;
34 enum pci_bar_type type;
35 struct resource *res = dev->resource + resno;
34 36
35 /* 37 /*
36 * Ignore resources for unimplemented BARs and unused resource slots 38 * Ignore resources for unimplemented BARs and unused resource slots
@@ -61,17 +63,13 @@ void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno)
61 else 63 else
62 mask = (u32)PCI_BASE_ADDRESS_MEM_MASK; 64 mask = (u32)PCI_BASE_ADDRESS_MEM_MASK;
63 65
64 if (resno < 6) { 66 reg = pci_resource_bar(dev, resno, &type);
65 reg = PCI_BASE_ADDRESS_0 + 4 * resno; 67 if (!reg)
66 } else if (resno == PCI_ROM_RESOURCE) { 68 return;
69 if (type != pci_bar_unknown) {
67 if (!(res->flags & IORESOURCE_ROM_ENABLE)) 70 if (!(res->flags & IORESOURCE_ROM_ENABLE))
68 return; 71 return;
69 new |= PCI_ROM_ADDRESS_ENABLE; 72 new |= PCI_ROM_ADDRESS_ENABLE;
70 reg = dev->rom_base_reg;
71 } else {
72 /* Hmm, non-standard resource. */
73
74 return; /* kill uninitialised var warning */
75 } 73 }
76 74
77 pci_write_config_dword(dev, reg, new); 75 pci_write_config_dword(dev, reg, new);
@@ -134,7 +132,7 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
134 132
135 align = resource_alignment(res); 133 align = resource_alignment(res);
136 if (!align) { 134 if (!align) {
137 dev_err(&dev->dev, "BAR %d: can't allocate resource (bogus " 135 dev_info(&dev->dev, "BAR %d: can't allocate resource (bogus "
138 "alignment) %pR flags %#lx\n", 136 "alignment) %pR flags %#lx\n",
139 resno, res, res->flags); 137 resno, res, res->flags);
140 return -EINVAL; 138 return -EINVAL;
@@ -157,12 +155,12 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
157 } 155 }
158 156
159 if (ret) { 157 if (ret) {
160 dev_err(&dev->dev, "BAR %d: can't allocate %s resource %pR\n", 158 dev_info(&dev->dev, "BAR %d: can't allocate %s resource %pR\n",
161 resno, res->flags & IORESOURCE_IO ? "I/O" : "mem", res); 159 resno, res->flags & IORESOURCE_IO ? "I/O" : "mem", res);
162 } else { 160 } else {
163 res->flags &= ~IORESOURCE_STARTALIGN; 161 res->flags &= ~IORESOURCE_STARTALIGN;
164 if (resno < PCI_BRIDGE_RESOURCES) 162 if (resno < PCI_BRIDGE_RESOURCES)
165 pci_update_resource(dev, res, resno); 163 pci_update_resource(dev, resno);
166 } 164 }
167 165
168 return ret; 166 return ret;
@@ -197,7 +195,7 @@ int pci_assign_resource_fixed(struct pci_dev *dev, int resno)
197 dev_err(&dev->dev, "BAR %d: can't allocate %s resource %pR\n", 195 dev_err(&dev->dev, "BAR %d: can't allocate %s resource %pR\n",
198 resno, res->flags & IORESOURCE_IO ? "I/O" : "mem", res); 196 resno, res->flags & IORESOURCE_IO ? "I/O" : "mem", res);
199 } else if (resno < PCI_BRIDGE_RESOURCES) { 197 } else if (resno < PCI_BRIDGE_RESOURCES) {
200 pci_update_resource(dev, res, resno); 198 pci_update_resource(dev, resno);
201 } 199 }
202 200
203 return ret; 201 return ret;
diff --git a/drivers/pci/syscall.c b/drivers/pci/syscall.c
index 645d7a60e412..ec22284eed30 100644
--- a/drivers/pci/syscall.c
+++ b/drivers/pci/syscall.c
@@ -14,10 +14,8 @@
14#include <asm/uaccess.h> 14#include <asm/uaccess.h>
15#include "pci.h" 15#include "pci.h"
16 16
17asmlinkage long 17SYSCALL_DEFINE5(pciconfig_read, unsigned long, bus, unsigned long, dfn,
18sys_pciconfig_read(unsigned long bus, unsigned long dfn, 18 unsigned long, off, unsigned long, len, void __user *, buf)
19 unsigned long off, unsigned long len,
20 void __user *buf)
21{ 19{
22 struct pci_dev *dev; 20 struct pci_dev *dev;
23 u8 byte; 21 u8 byte;
@@ -86,10 +84,8 @@ error:
86 return err; 84 return err;
87} 85}
88 86
89asmlinkage long 87SYSCALL_DEFINE5(pciconfig_write, unsigned long, bus, unsigned long, dfn,
90sys_pciconfig_write(unsigned long bus, unsigned long dfn, 88 unsigned long, off, unsigned long, len, void __user *, buf)
91 unsigned long off, unsigned long len,
92 void __user *buf)
93{ 89{
94 struct pci_dev *dev; 90 struct pci_dev *dev;
95 u8 byte; 91 u8 byte;
diff --git a/drivers/pcmcia/electra_cf.c b/drivers/pcmcia/electra_cf.c
index a34284b1482a..d187ba4c5e0e 100644
--- a/drivers/pcmcia/electra_cf.c
+++ b/drivers/pcmcia/electra_cf.c
@@ -297,7 +297,7 @@ static int __devinit electra_cf_probe(struct of_device *ofdev,
297 goto fail3; 297 goto fail3;
298 } 298 }
299 299
300 dev_info(device, "at mem 0x%lx io 0x%lx irq %d\n", 300 dev_info(device, "at mem 0x%lx io 0x%llx irq %d\n",
301 cf->mem_phys, io.start, cf->irq); 301 cf->mem_phys, io.start, cf->irq);
302 302
303 cf->active = 1; 303 cf->active = 1;
diff --git a/drivers/platform/Kconfig b/drivers/platform/Kconfig
new file mode 100644
index 000000000000..9652c3fe7f5e
--- /dev/null
+++ b/drivers/platform/Kconfig
@@ -0,0 +1,5 @@
1# drivers/platform/Kconfig
2
3if X86
4source "drivers/platform/x86/Kconfig"
5endif
diff --git a/drivers/platform/Makefile b/drivers/platform/Makefile
new file mode 100644
index 000000000000..782953ae4c03
--- /dev/null
+++ b/drivers/platform/Makefile
@@ -0,0 +1,5 @@
1#
2# Makefile for linux/drivers/platform
3#
4
5obj-$(CONFIG_X86) += x86/
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
new file mode 100644
index 000000000000..1a266d4ab5f1
--- /dev/null
+++ b/drivers/platform/x86/Kconfig
@@ -0,0 +1,398 @@
1#
2# X86 Platform Specific Drivers
3#
4
5menuconfig X86_PLATFORM_DEVICES
6 bool "X86 Platform Specific Device Drivers"
7 default y
8 ---help---
9 Say Y here to get to see options for device drivers for various
10 x86 platforms, including vendor-specific laptop extension drivers.
11 This option alone does not add any kernel code.
12
13 If you say N, all options in this submenu will be skipped and disabled.
14
15if X86_PLATFORM_DEVICES
16
17config ACER_WMI
18 tristate "Acer WMI Laptop Extras (EXPERIMENTAL)"
19 depends on EXPERIMENTAL
20 depends on ACPI
21 depends on LEDS_CLASS
22 depends on NEW_LEDS
23 depends on BACKLIGHT_CLASS_DEVICE
24 depends on SERIO_I8042
25 depends on RFKILL
26 select ACPI_WMI
27 ---help---
28 This is a driver for newer Acer (and Wistron) laptops. It adds
29 wireless radio and bluetooth control, and on some laptops,
30 exposes the mail LED and LCD backlight.
31
32 For more information about this driver see
33 <file:Documentation/laptops/acer-wmi.txt>
34
35 If you have an ACPI-WMI compatible Acer/ Wistron laptop, say Y or M
36 here.
37
38config ASUS_LAPTOP
39 tristate "Asus Laptop Extras (EXPERIMENTAL)"
40 depends on ACPI
41 depends on EXPERIMENTAL && !ACPI_ASUS
42 depends on LEDS_CLASS
43 depends on NEW_LEDS
44 depends on BACKLIGHT_CLASS_DEVICE
45 ---help---
46 This is the new Linux driver for Asus laptops. It may also support some
47 MEDION, JVC or VICTOR laptops. It makes all the extra buttons generate
48 standard ACPI events that go through /proc/acpi/events. It also adds
49 support for video output switching, LCD backlight control, Bluetooth and
50 Wlan control, and most importantly, allows you to blink those fancy LEDs.
51
52 For more information and a userspace daemon for handling the extra
53 buttons see <http://acpi4asus.sf.net/>.
54
55 If you have an ACPI-compatible ASUS laptop, say Y or M here.
56
57config DELL_LAPTOP
58 tristate "Dell Laptop Extras (EXPERIMENTAL)"
59 depends on X86
60 depends on DCDBAS
61 depends on EXPERIMENTAL
62 depends on BACKLIGHT_CLASS_DEVICE
63 depends on RFKILL
64 default n
65 ---help---
66 This driver adds support for rfkill and backlight control to Dell
67 laptops.
68
69config FUJITSU_LAPTOP
70 tristate "Fujitsu Laptop Extras"
71 depends on ACPI
72 depends on INPUT
73 depends on BACKLIGHT_CLASS_DEVICE
74 ---help---
75 This is a driver for laptops built by Fujitsu:
76
77 * P2xxx/P5xxx/S6xxx/S7xxx series Lifebooks
78 * Possibly other Fujitsu laptop models
79 * Tested with S6410 and S7020
80
81 It adds support for LCD brightness control and some hotkeys.
82
83 If you have a Fujitsu laptop, say Y or M here.
84
85config FUJITSU_LAPTOP_DEBUG
86 bool "Verbose debug mode for Fujitsu Laptop Extras"
87 depends on FUJITSU_LAPTOP
88 default n
89 ---help---
90 Enables extra debug output from the fujitsu extras driver, at the
91 expense of a slight increase in driver size.
92
93 If you are not sure, say N here.
94
95config TC1100_WMI
96 tristate "HP Compaq TC1100 Tablet WMI Extras (EXPERIMENTAL)"
97 depends on !X86_64
98 depends on EXPERIMENTAL
99 depends on ACPI
100 select ACPI_WMI
101 ---help---
102 This is a driver for the WMI extensions (wireless and bluetooth power
103 control) of the HP Compaq TC1100 tablet.
104
105config HP_WMI
106 tristate "HP WMI extras"
107 depends on ACPI_WMI
108 depends on INPUT
109 depends on RFKILL
110 help
111 Say Y here if you want to support WMI-based hotkeys on HP laptops and
112 to read data from WMI such as docking or ambient light sensor state.
113
114 To compile this driver as a module, choose M here: the module will
115 be called hp-wmi.
116
117config MSI_LAPTOP
118 tristate "MSI Laptop Extras"
119 depends on ACPI
120 depends on BACKLIGHT_CLASS_DEVICE
121 ---help---
122 This is a driver for laptops built by MSI (MICRO-STAR
123 INTERNATIONAL):
124
125 MSI MegaBook S270 (MS-1013)
126 Cytron/TCM/Medion/Tchibo MD96100/SAM2000
127
128 It adds support for Bluetooth, WLAN and LCD brightness control.
129
130 More information about this driver is available at
131 <http://0pointer.de/lennart/tchibo.html>.
132
133 If you have an MSI S270 laptop, say Y or M here.
134
135config PANASONIC_LAPTOP
136 tristate "Panasonic Laptop Extras"
137 depends on INPUT && ACPI
138 depends on BACKLIGHT_CLASS_DEVICE
139 ---help---
140 This driver adds support for access to backlight control and hotkeys
141 on Panasonic Let's Note laptops.
142
143 If you have a Panasonic Let's note laptop (such as the R1(N variant),
144 R2, R3, R5, T2, W2 and Y2 series), say Y.
145
146config COMPAL_LAPTOP
147 tristate "Compal Laptop Extras"
148 depends on ACPI
149 depends on BACKLIGHT_CLASS_DEVICE
150 ---help---
151 This is a driver for laptops built by Compal:
152
153 Compal FL90/IFL90
154 Compal FL91/IFL91
155 Compal FL92/JFL92
156 Compal FT00/IFT00
157
158 It adds support for Bluetooth, WLAN and LCD brightness control.
159
160 If you have an Compal FL9x/IFL9x/FT00 laptop, say Y or M here.
161
162config SONY_LAPTOP
163 tristate "Sony Laptop Extras"
164 depends on ACPI
165 select BACKLIGHT_CLASS_DEVICE
166 depends on INPUT
167 ---help---
168 This mini-driver drives the SNC and SPIC devices present in the ACPI
169 BIOS of the Sony Vaio laptops.
170
171 It gives access to some extra laptop functionalities like Bluetooth,
172 screen brightness control, Fn keys and allows powering on/off some
173 devices.
174
175 Read <file:Documentation/laptops/sony-laptop.txt> for more information.
176
177config SONYPI_COMPAT
178 bool "Sonypi compatibility"
179 depends on SONY_LAPTOP
180 ---help---
181 Build the sonypi driver compatibility code into the sony-laptop driver.
182
183config THINKPAD_ACPI
184 tristate "ThinkPad ACPI Laptop Extras"
185 depends on ACPI
186 select BACKLIGHT_LCD_SUPPORT
187 select BACKLIGHT_CLASS_DEVICE
188 select HWMON
189 select NVRAM
190 select INPUT
191 select NEW_LEDS
192 select LEDS_CLASS
193 select NET
194 select RFKILL
195 ---help---
196 This is a driver for the IBM and Lenovo ThinkPad laptops. It adds
197 support for Fn-Fx key combinations, Bluetooth control, video
198 output switching, ThinkLight control, UltraBay eject and more.
199 For more information about this driver see
200 <file:Documentation/laptops/thinkpad-acpi.txt> and
201 <http://ibm-acpi.sf.net/> .
202
203 This driver was formerly known as ibm-acpi.
204
205 If you have an IBM or Lenovo ThinkPad laptop, say Y or M here.
206
207config THINKPAD_ACPI_DEBUGFACILITIES
208 bool "Maintainer debug facilities"
209 depends on THINKPAD_ACPI
210 default n
211 ---help---
212 Enables extra stuff in the thinkpad-acpi which is completely useless
213 for normal use. Read the driver source to find out what it does.
214
215 Say N here, unless you were told by a kernel maintainer to do
216 otherwise.
217
218config THINKPAD_ACPI_DEBUG
219 bool "Verbose debug mode"
220 depends on THINKPAD_ACPI
221 default n
222 ---help---
223 Enables extra debugging information, at the expense of a slightly
224 increase in driver size.
225
226 If you are not sure, say N here.
227
228config THINKPAD_ACPI_DOCK
229 bool "Legacy Docking Station Support"
230 depends on THINKPAD_ACPI
231 depends on ACPI_DOCK=n
232 default n
233 ---help---
234 Allows the thinkpad_acpi driver to handle docking station events.
235 This support was made obsolete by the generic ACPI docking station
236 support (CONFIG_ACPI_DOCK). It will allow locking and removing the
237 laptop from the docking station, but will not properly connect PCI
238 devices.
239
240 If you are not sure, say N here.
241
242config THINKPAD_ACPI_BAY
243 bool "Legacy Removable Bay Support"
244 depends on THINKPAD_ACPI
245 default y
246 ---help---
247 Allows the thinkpad_acpi driver to handle removable bays. It will
248 electrically disable the device in the bay, and also generate
249 notifications when the bay lever is ejected or inserted.
250
251 If you are not sure, say Y here.
252
253config THINKPAD_ACPI_VIDEO
254 bool "Video output control support"
255 depends on THINKPAD_ACPI
256 default y
257 ---help---
258 Allows the thinkpad_acpi driver to provide an interface to control
259 the various video output ports.
260
261 This feature often won't work well, depending on ThinkPad model,
262 display state, video output devices in use, whether there is a X
263 server running, phase of the moon, and the current mood of
264 Schroedinger's cat. If you can use X.org's RandR to control
265 your ThinkPad's video output ports instead of this feature,
266 don't think twice: do it and say N here to save some memory.
267
268 If you are not sure, say Y here.
269
270config THINKPAD_ACPI_HOTKEY_POLL
271 bool "Support NVRAM polling for hot keys"
272 depends on THINKPAD_ACPI
273 default y
274 ---help---
275 Some thinkpad models benefit from NVRAM polling to detect a few of
276 the hot key press events. If you know your ThinkPad model does not
277 need to do NVRAM polling to support any of the hot keys you use,
278 unselecting this option will save about 1kB of memory.
279
280 ThinkPads T40 and newer, R52 and newer, and X31 and newer are
281 unlikely to need NVRAM polling in their latest BIOS versions.
282
283 NVRAM polling can detect at most the following keys: ThinkPad/Access
284 IBM, Zoom, Switch Display (fn+F7), ThinkLight, Volume up/down/mute,
285 Brightness up/down, Display Expand (fn+F8), Hibernate (fn+F12).
286
287 If you are not sure, say Y here. The driver enables polling only if
288 it is strictly necessary to do so.
289
290config INTEL_MENLOW
291 tristate "Thermal Management driver for Intel menlow platform"
292 depends on ACPI_THERMAL
293 select THERMAL
294 ---help---
295 ACPI thermal management enhancement driver on
296 Intel Menlow platform.
297
298 If unsure, say N.
299
300config EEEPC_LAPTOP
301 tristate "Eee PC Hotkey Driver (EXPERIMENTAL)"
302 depends on ACPI
303 depends on EXPERIMENTAL
304 select BACKLIGHT_CLASS_DEVICE
305 select HWMON
306 select RFKILL
307 ---help---
308 This driver supports the Fn-Fx keys on Eee PC laptops.
309 It also adds the ability to switch camera/wlan on/off.
310
311 If you have an Eee PC laptop, say Y or M here.
312
313
314config ACPI_WMI
315 tristate "WMI (EXPERIMENTAL)"
316 depends on ACPI
317 depends on EXPERIMENTAL
318 help
319 This driver adds support for the ACPI-WMI (Windows Management
320 Instrumentation) mapper device (PNP0C14) found on some systems.
321
322 ACPI-WMI is a proprietary extension to ACPI to expose parts of the
323 ACPI firmware to userspace - this is done through various vendor
324 defined methods and data blocks in a PNP0C14 device, which are then
325 made available for userspace to call.
326
327 The implementation of this in Linux currently only exposes this to
328 other kernel space drivers.
329
330 This driver is a required dependency to build the firmware specific
331 drivers needed on many machines, including Acer and HP laptops.
332
333 It is safe to enable this driver even if your DSDT doesn't define
334 any ACPI-WMI devices.
335
336config ACPI_ASUS
337 tristate "ASUS/Medion Laptop Extras"
338 depends on ACPI
339 select BACKLIGHT_CLASS_DEVICE
340 ---help---
341 This driver provides support for extra features of ACPI-compatible
342 ASUS laptops. As some of Medion laptops are made by ASUS, it may also
343 support some Medion laptops (such as 9675 for example). It makes all
344 the extra buttons generate standard ACPI events that go through
345 /proc/acpi/events, and (on some models) adds support for changing the
346 display brightness and output, switching the LCD backlight on and off,
347 and most importantly, allows you to blink those fancy LEDs intended
348 for reporting mail and wireless status.
349
350 Note: display switching code is currently considered EXPERIMENTAL,
351 toying with these values may even lock your machine.
352
353 All settings are changed via /proc/acpi/asus directory entries. Owner
354 and group for these entries can be set with asus_uid and asus_gid
355 parameters.
356
357 More information and a userspace daemon for handling the extra buttons
358 at <http://sourceforge.net/projects/acpi4asus/>.
359
360 If you have an ACPI-compatible ASUS laptop, say Y or M here. This
361 driver is still under development, so if your laptop is unsupported or
362 something works not quite as expected, please use the mailing list
363 available on the above page (acpi4asus-user@lists.sourceforge.net).
364
365 NOTE: This driver is deprecated and will probably be removed soon,
366 use asus-laptop instead.
367
368config ACPI_TOSHIBA
369 tristate "Toshiba Laptop Extras"
370 depends on ACPI
371 depends on INPUT
372 select INPUT_POLLDEV
373 select NET
374 select RFKILL
375 select BACKLIGHT_CLASS_DEVICE
376 ---help---
377 This driver adds support for access to certain system settings
378 on "legacy free" Toshiba laptops. These laptops can be recognized by
379 their lack of a BIOS setup menu and APM support.
380
381 On these machines, all system configuration is handled through the
382 ACPI. This driver is required for access to controls not covered
383 by the general ACPI drivers, such as LCD brightness, video output,
384 etc.
385
386 This driver differs from the non-ACPI Toshiba laptop driver (located
387 under "Processor type and features") in several aspects.
388 Configuration is accessed by reading and writing text files in the
389 /proc tree instead of by program interface to /dev. Furthermore, no
390 power management functions are exposed, as those are handled by the
391 general ACPI drivers.
392
393 More information about this driver is available at
394 <http://memebeam.org/toys/ToshibaAcpiDriver>.
395
396 If you have a legacy free Toshiba laptop (such as the Libretto L1
397 series), say Y.
398endif # X86_PLATFORM_DEVICES
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
new file mode 100644
index 000000000000..e29065120be9
--- /dev/null
+++ b/drivers/platform/x86/Makefile
@@ -0,0 +1,20 @@
1#
2# Makefile for linux/drivers/platform/x86
3# x86 Platform-Specific Drivers
4#
5obj-$(CONFIG_ASUS_LAPTOP) += asus-laptop.o
6obj-$(CONFIG_EEEPC_LAPTOP) += eeepc-laptop.o
7obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o
8obj-$(CONFIG_COMPAL_LAPTOP) += compal-laptop.o
9obj-$(CONFIG_DELL_LAPTOP) += dell-laptop.o
10obj-$(CONFIG_ACER_WMI) += acer-wmi.o
11obj-$(CONFIG_HP_WMI) += hp-wmi.o
12obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o
13obj-$(CONFIG_SONY_LAPTOP) += sony-laptop.o
14obj-$(CONFIG_THINKPAD_ACPI) += thinkpad_acpi.o
15obj-$(CONFIG_FUJITSU_LAPTOP) += fujitsu-laptop.o
16obj-$(CONFIG_PANASONIC_LAPTOP) += panasonic-laptop.o
17obj-$(CONFIG_INTEL_MENLOW) += intel_menlow.o
18obj-$(CONFIG_ACPI_WMI) += wmi.o
19obj-$(CONFIG_ACPI_ASUS) += asus_acpi.o
20obj-$(CONFIG_ACPI_TOSHIBA) += toshiba_acpi.o
diff --git a/drivers/misc/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index 94c9f911824e..94c9f911824e 100644
--- a/drivers/misc/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
diff --git a/drivers/misc/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index 8fb8b3591048..8fb8b3591048 100644
--- a/drivers/misc/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
diff --git a/drivers/acpi/asus_acpi.c b/drivers/platform/x86/asus_acpi.c
index 1e74988c7b2d..1e74988c7b2d 100644
--- a/drivers/acpi/asus_acpi.c
+++ b/drivers/platform/x86/asus_acpi.c
diff --git a/drivers/misc/compal-laptop.c b/drivers/platform/x86/compal-laptop.c
index 11003bba10d3..11003bba10d3 100644
--- a/drivers/misc/compal-laptop.c
+++ b/drivers/platform/x86/compal-laptop.c
diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c
new file mode 100644
index 000000000000..16e11c2ee19a
--- /dev/null
+++ b/drivers/platform/x86/dell-laptop.c
@@ -0,0 +1,436 @@
1/*
2 * Driver for Dell laptop extras
3 *
4 * Copyright (c) Red Hat <mjg@redhat.com>
5 *
6 * Based on documentation in the libsmbios package, Copyright (C) 2005 Dell
7 * Inc.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#include <linux/module.h>
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/platform_device.h>
18#include <linux/backlight.h>
19#include <linux/err.h>
20#include <linux/dmi.h>
21#include <linux/io.h>
22#include <linux/rfkill.h>
23#include <linux/power_supply.h>
24#include <linux/acpi.h>
25#include "../../firmware/dcdbas.h"
26
27#define BRIGHTNESS_TOKEN 0x7d
28
29/* This structure will be modified by the firmware when we enter
30 * system management mode, hence the volatiles */
31
32struct calling_interface_buffer {
33 u16 class;
34 u16 select;
35 volatile u32 input[4];
36 volatile u32 output[4];
37} __packed;
38
39struct calling_interface_token {
40 u16 tokenID;
41 u16 location;
42 union {
43 u16 value;
44 u16 stringlength;
45 };
46};
47
48struct calling_interface_structure {
49 struct dmi_header header;
50 u16 cmdIOAddress;
51 u8 cmdIOCode;
52 u32 supportedCmds;
53 struct calling_interface_token tokens[];
54} __packed;
55
56static int da_command_address;
57static int da_command_code;
58static int da_num_tokens;
59static struct calling_interface_token *da_tokens;
60
61static struct backlight_device *dell_backlight_device;
62static struct rfkill *wifi_rfkill;
63static struct rfkill *bluetooth_rfkill;
64static struct rfkill *wwan_rfkill;
65
66static const struct dmi_system_id __initdata dell_device_table[] = {
67 {
68 .ident = "Dell laptop",
69 .matches = {
70 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
71 DMI_MATCH(DMI_CHASSIS_TYPE, "8"),
72 },
73 },
74 { }
75};
76
77static void parse_da_table(const struct dmi_header *dm)
78{
79 /* Final token is a terminator, so we don't want to copy it */
80 int tokens = (dm->length-11)/sizeof(struct calling_interface_token)-1;
81 struct calling_interface_structure *table =
82 container_of(dm, struct calling_interface_structure, header);
83
84 /* 4 bytes of table header, plus 7 bytes of Dell header, plus at least
85 6 bytes of entry */
86
87 if (dm->length < 17)
88 return;
89
90 da_command_address = table->cmdIOAddress;
91 da_command_code = table->cmdIOCode;
92
93 da_tokens = krealloc(da_tokens, (da_num_tokens + tokens) *
94 sizeof(struct calling_interface_token),
95 GFP_KERNEL);
96
97 if (!da_tokens)
98 return;
99
100 memcpy(da_tokens+da_num_tokens, table->tokens,
101 sizeof(struct calling_interface_token) * tokens);
102
103 da_num_tokens += tokens;
104}
105
106static void find_tokens(const struct dmi_header *dm)
107{
108 switch (dm->type) {
109 case 0xd4: /* Indexed IO */
110 break;
111 case 0xd5: /* Protected Area Type 1 */
112 break;
113 case 0xd6: /* Protected Area Type 2 */
114 break;
115 case 0xda: /* Calling interface */
116 parse_da_table(dm);
117 break;
118 }
119}
120
121static int find_token_location(int tokenid)
122{
123 int i;
124 for (i = 0; i < da_num_tokens; i++) {
125 if (da_tokens[i].tokenID == tokenid)
126 return da_tokens[i].location;
127 }
128
129 return -1;
130}
131
132static struct calling_interface_buffer *
133dell_send_request(struct calling_interface_buffer *buffer, int class,
134 int select)
135{
136 struct smi_cmd command;
137
138 command.magic = SMI_CMD_MAGIC;
139 command.command_address = da_command_address;
140 command.command_code = da_command_code;
141 command.ebx = virt_to_phys(buffer);
142 command.ecx = 0x42534931;
143
144 buffer->class = class;
145 buffer->select = select;
146
147 dcdbas_smi_request(&command);
148
149 return buffer;
150}
151
152/* Derived from information in DellWirelessCtl.cpp:
153 Class 17, select 11 is radio control. It returns an array of 32-bit values.
154
155 result[0]: return code
156 result[1]:
157 Bit 0: Hardware switch supported
158 Bit 1: Wifi locator supported
159 Bit 2: Wifi is supported
160 Bit 3: Bluetooth is supported
161 Bit 4: WWAN is supported
162 Bit 5: Wireless keyboard supported
163 Bits 6-7: Reserved
164 Bit 8: Wifi is installed
165 Bit 9: Bluetooth is installed
166 Bit 10: WWAN is installed
167 Bits 11-15: Reserved
168 Bit 16: Hardware switch is on
169 Bit 17: Wifi is blocked
170 Bit 18: Bluetooth is blocked
171 Bit 19: WWAN is blocked
172 Bits 20-31: Reserved
173 result[2]: NVRAM size in bytes
174 result[3]: NVRAM format version number
175*/
176
177static int dell_rfkill_set(int radio, enum rfkill_state state)
178{
179 struct calling_interface_buffer buffer;
180 int disable = (state == RFKILL_STATE_UNBLOCKED) ? 0 : 1;
181
182 memset(&buffer, 0, sizeof(struct calling_interface_buffer));
183 buffer.input[0] = (1 | (radio<<8) | (disable << 16));
184 dell_send_request(&buffer, 17, 11);
185
186 return 0;
187}
188
189static int dell_wifi_set(void *data, enum rfkill_state state)
190{
191 return dell_rfkill_set(1, state);
192}
193
194static int dell_bluetooth_set(void *data, enum rfkill_state state)
195{
196 return dell_rfkill_set(2, state);
197}
198
199static int dell_wwan_set(void *data, enum rfkill_state state)
200{
201 return dell_rfkill_set(3, state);
202}
203
204static int dell_rfkill_get(int bit, enum rfkill_state *state)
205{
206 struct calling_interface_buffer buffer;
207 int status;
208 int new_state = RFKILL_STATE_HARD_BLOCKED;
209
210 memset(&buffer, 0, sizeof(struct calling_interface_buffer));
211 dell_send_request(&buffer, 17, 11);
212 status = buffer.output[1];
213
214 if (status & (1<<16))
215 new_state = RFKILL_STATE_SOFT_BLOCKED;
216
217 if (status & (1<<bit))
218 *state = new_state;
219 else
220 *state = RFKILL_STATE_UNBLOCKED;
221
222 return 0;
223}
224
225static int dell_wifi_get(void *data, enum rfkill_state *state)
226{
227 return dell_rfkill_get(17, state);
228}
229
230static int dell_bluetooth_get(void *data, enum rfkill_state *state)
231{
232 return dell_rfkill_get(18, state);
233}
234
235static int dell_wwan_get(void *data, enum rfkill_state *state)
236{
237 return dell_rfkill_get(19, state);
238}
239
240static int dell_setup_rfkill(void)
241{
242 struct calling_interface_buffer buffer;
243 int status;
244 int ret;
245
246 memset(&buffer, 0, sizeof(struct calling_interface_buffer));
247 dell_send_request(&buffer, 17, 11);
248 status = buffer.output[1];
249
250 if ((status & (1<<2|1<<8)) == (1<<2|1<<8)) {
251 wifi_rfkill = rfkill_allocate(NULL, RFKILL_TYPE_WLAN);
252 if (!wifi_rfkill)
253 goto err_wifi;
254 wifi_rfkill->name = "dell-wifi";
255 wifi_rfkill->toggle_radio = dell_wifi_set;
256 wifi_rfkill->get_state = dell_wifi_get;
257 ret = rfkill_register(wifi_rfkill);
258 if (ret)
259 goto err_wifi;
260 }
261
262 if ((status & (1<<3|1<<9)) == (1<<3|1<<9)) {
263 bluetooth_rfkill = rfkill_allocate(NULL, RFKILL_TYPE_BLUETOOTH);
264 if (!bluetooth_rfkill)
265 goto err_bluetooth;
266 bluetooth_rfkill->name = "dell-bluetooth";
267 bluetooth_rfkill->toggle_radio = dell_bluetooth_set;
268 bluetooth_rfkill->get_state = dell_bluetooth_get;
269 ret = rfkill_register(bluetooth_rfkill);
270 if (ret)
271 goto err_bluetooth;
272 }
273
274 if ((status & (1<<4|1<<10)) == (1<<4|1<<10)) {
275 wwan_rfkill = rfkill_allocate(NULL, RFKILL_TYPE_WWAN);
276 if (!wwan_rfkill)
277 goto err_wwan;
278 wwan_rfkill->name = "dell-wwan";
279 wwan_rfkill->toggle_radio = dell_wwan_set;
280 wwan_rfkill->get_state = dell_wwan_get;
281 ret = rfkill_register(wwan_rfkill);
282 if (ret)
283 goto err_wwan;
284 }
285
286 return 0;
287err_wwan:
288 if (wwan_rfkill)
289 rfkill_free(wwan_rfkill);
290 if (bluetooth_rfkill) {
291 rfkill_unregister(bluetooth_rfkill);
292 bluetooth_rfkill = NULL;
293 }
294err_bluetooth:
295 if (bluetooth_rfkill)
296 rfkill_free(bluetooth_rfkill);
297 if (wifi_rfkill) {
298 rfkill_unregister(wifi_rfkill);
299 wifi_rfkill = NULL;
300 }
301err_wifi:
302 if (wifi_rfkill)
303 rfkill_free(wifi_rfkill);
304
305 return ret;
306}
307
308static int dell_send_intensity(struct backlight_device *bd)
309{
310 struct calling_interface_buffer buffer;
311
312 memset(&buffer, 0, sizeof(struct calling_interface_buffer));
313 buffer.input[0] = find_token_location(BRIGHTNESS_TOKEN);
314 buffer.input[1] = bd->props.brightness;
315
316 if (buffer.input[0] == -1)
317 return -ENODEV;
318
319 if (power_supply_is_system_supplied() > 0)
320 dell_send_request(&buffer, 1, 2);
321 else
322 dell_send_request(&buffer, 1, 1);
323
324 return 0;
325}
326
327static int dell_get_intensity(struct backlight_device *bd)
328{
329 struct calling_interface_buffer buffer;
330
331 memset(&buffer, 0, sizeof(struct calling_interface_buffer));
332 buffer.input[0] = find_token_location(BRIGHTNESS_TOKEN);
333
334 if (buffer.input[0] == -1)
335 return -ENODEV;
336
337 if (power_supply_is_system_supplied() > 0)
338 dell_send_request(&buffer, 0, 2);
339 else
340 dell_send_request(&buffer, 0, 1);
341
342 return buffer.output[1];
343}
344
345static struct backlight_ops dell_ops = {
346 .get_brightness = dell_get_intensity,
347 .update_status = dell_send_intensity,
348};
349
350static int __init dell_init(void)
351{
352 struct calling_interface_buffer buffer;
353 int max_intensity = 0;
354 int ret;
355
356 if (!dmi_check_system(dell_device_table))
357 return -ENODEV;
358
359 dmi_walk(find_tokens);
360
361 if (!da_tokens) {
362 printk(KERN_INFO "dell-laptop: Unable to find dmi tokens\n");
363 return -ENODEV;
364 }
365
366 ret = dell_setup_rfkill();
367
368 if (ret) {
369 printk(KERN_WARNING "dell-laptop: Unable to setup rfkill\n");
370 goto out;
371 }
372
373#ifdef CONFIG_ACPI
374 /* In the event of an ACPI backlight being available, don't
375 * register the platform controller.
376 */
377 if (acpi_video_backlight_support())
378 return 0;
379#endif
380
381 memset(&buffer, 0, sizeof(struct calling_interface_buffer));
382 buffer.input[0] = find_token_location(BRIGHTNESS_TOKEN);
383
384 if (buffer.input[0] != -1) {
385 dell_send_request(&buffer, 0, 2);
386 max_intensity = buffer.output[3];
387 }
388
389 if (max_intensity) {
390 dell_backlight_device = backlight_device_register(
391 "dell_backlight",
392 NULL, NULL,
393 &dell_ops);
394
395 if (IS_ERR(dell_backlight_device)) {
396 ret = PTR_ERR(dell_backlight_device);
397 dell_backlight_device = NULL;
398 goto out;
399 }
400
401 dell_backlight_device->props.max_brightness = max_intensity;
402 dell_backlight_device->props.brightness =
403 dell_get_intensity(dell_backlight_device);
404 backlight_update_status(dell_backlight_device);
405 }
406
407 return 0;
408out:
409 if (wifi_rfkill)
410 rfkill_unregister(wifi_rfkill);
411 if (bluetooth_rfkill)
412 rfkill_unregister(bluetooth_rfkill);
413 if (wwan_rfkill)
414 rfkill_unregister(wwan_rfkill);
415 kfree(da_tokens);
416 return ret;
417}
418
419static void __exit dell_exit(void)
420{
421 backlight_device_unregister(dell_backlight_device);
422 if (wifi_rfkill)
423 rfkill_unregister(wifi_rfkill);
424 if (bluetooth_rfkill)
425 rfkill_unregister(bluetooth_rfkill);
426 if (wwan_rfkill)
427 rfkill_unregister(wwan_rfkill);
428}
429
430module_init(dell_init);
431module_exit(dell_exit);
432
433MODULE_AUTHOR("Matthew Garrett <mjg@redhat.com>");
434MODULE_DESCRIPTION("Dell laptop driver");
435MODULE_LICENSE("GPL");
436MODULE_ALIAS("dmi:*svnDellInc.:*:ct8:*");
diff --git a/drivers/misc/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 02fe2b8b8939..9d93cb971e59 100644
--- a/drivers/misc/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -90,7 +90,7 @@ enum {
90}; 90};
91 91
92static const char *cm_getv[] = { 92static const char *cm_getv[] = {
93 "WLDG", NULL, NULL, NULL, 93 "WLDG", "BTHG", NULL, NULL,
94 "CAMG", NULL, NULL, NULL, 94 "CAMG", NULL, NULL, NULL,
95 NULL, "PBLG", NULL, NULL, 95 NULL, "PBLG", NULL, NULL,
96 "CFVG", NULL, NULL, NULL, 96 "CFVG", NULL, NULL, NULL,
@@ -99,7 +99,7 @@ static const char *cm_getv[] = {
99}; 99};
100 100
101static const char *cm_setv[] = { 101static const char *cm_setv[] = {
102 "WLDS", NULL, NULL, NULL, 102 "WLDS", "BTHS", NULL, NULL,
103 "CAMS", NULL, NULL, NULL, 103 "CAMS", NULL, NULL, NULL,
104 "SDSP", "PBLS", "HDPS", NULL, 104 "SDSP", "PBLS", "HDPS", NULL,
105 "CFVS", NULL, NULL, NULL, 105 "CFVS", NULL, NULL, NULL,
diff --git a/drivers/misc/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index a7dd3e9fb79d..65dc41540c62 100644
--- a/drivers/misc/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -3,6 +3,7 @@
3/* 3/*
4 Copyright (C) 2007,2008 Jonathan Woithe <jwoithe@physics.adelaide.edu.au> 4 Copyright (C) 2007,2008 Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
5 Copyright (C) 2008 Peter Gruber <nokos@gmx.net> 5 Copyright (C) 2008 Peter Gruber <nokos@gmx.net>
6 Copyright (C) 2008 Tony Vroon <tony@linx.net>
6 Based on earlier work: 7 Based on earlier work:
7 Copyright (C) 2003 Shane Spencer <shane@bogomip.com> 8 Copyright (C) 2003 Shane Spencer <shane@bogomip.com>
8 Adrian Yee <brewt-fujitsu@brewt.org> 9 Adrian Yee <brewt-fujitsu@brewt.org>
@@ -65,8 +66,11 @@
65#include <linux/kfifo.h> 66#include <linux/kfifo.h>
66#include <linux/video_output.h> 67#include <linux/video_output.h>
67#include <linux/platform_device.h> 68#include <linux/platform_device.h>
69#ifdef CONFIG_LEDS_CLASS
70#include <linux/leds.h>
71#endif
68 72
69#define FUJITSU_DRIVER_VERSION "0.4.3" 73#define FUJITSU_DRIVER_VERSION "0.5.0"
70 74
71#define FUJITSU_LCD_N_LEVELS 8 75#define FUJITSU_LCD_N_LEVELS 8
72 76
@@ -83,6 +87,24 @@
83#define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x86 87#define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x86
84#define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x87 88#define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x87
85 89
90/* FUNC interface - command values */
91#define FUNC_RFKILL 0x1000
92#define FUNC_LEDS 0x1001
93#define FUNC_BUTTONS 0x1002
94#define FUNC_BACKLIGHT 0x1004
95
96/* FUNC interface - responses */
97#define UNSUPPORTED_CMD 0x80000000
98
99#ifdef CONFIG_LEDS_CLASS
100/* FUNC interface - LED control */
101#define FUNC_LED_OFF 0x1
102#define FUNC_LED_ON 0x30001
103#define KEYBOARD_LAMPS 0x100
104#define LOGOLAMP_POWERON 0x2000
105#define LOGOLAMP_ALWAYS 0x4000
106#endif
107
86/* Hotkey details */ 108/* Hotkey details */
87#define KEY1_CODE 0x410 /* codes for the keys in the GIRB register */ 109#define KEY1_CODE 0x410 /* codes for the keys in the GIRB register */
88#define KEY2_CODE 0x411 110#define KEY2_CODE 0x411
@@ -133,7 +155,6 @@ struct fujitsu_t {
133 155
134static struct fujitsu_t *fujitsu; 156static struct fujitsu_t *fujitsu;
135static int use_alt_lcd_levels = -1; 157static int use_alt_lcd_levels = -1;
136static int disable_brightness_keys = -1;
137static int disable_brightness_adjust = -1; 158static int disable_brightness_adjust = -1;
138 159
139/* Device used to access other hotkeys on the laptop */ 160/* Device used to access other hotkeys on the laptop */
@@ -145,8 +166,9 @@ struct fujitsu_hotkey_t {
145 struct platform_device *pf_device; 166 struct platform_device *pf_device;
146 struct kfifo *fifo; 167 struct kfifo *fifo;
147 spinlock_t fifo_lock; 168 spinlock_t fifo_lock;
148 169 int rfkill_state;
149 unsigned int irb; /* info about the pressed buttons */ 170 int logolamp_registered;
171 int kblamps_registered;
150}; 172};
151 173
152static struct fujitsu_hotkey_t *fujitsu_hotkey; 174static struct fujitsu_hotkey_t *fujitsu_hotkey;
@@ -154,12 +176,139 @@ static struct fujitsu_hotkey_t *fujitsu_hotkey;
154static void acpi_fujitsu_hotkey_notify(acpi_handle handle, u32 event, 176static void acpi_fujitsu_hotkey_notify(acpi_handle handle, u32 event,
155 void *data); 177 void *data);
156 178
179#ifdef CONFIG_LEDS_CLASS
180static enum led_brightness logolamp_get(struct led_classdev *cdev);
181static void logolamp_set(struct led_classdev *cdev,
182 enum led_brightness brightness);
183
184struct led_classdev logolamp_led = {
185 .name = "fujitsu::logolamp",
186 .brightness_get = logolamp_get,
187 .brightness_set = logolamp_set
188};
189
190static enum led_brightness kblamps_get(struct led_classdev *cdev);
191static void kblamps_set(struct led_classdev *cdev,
192 enum led_brightness brightness);
193
194struct led_classdev kblamps_led = {
195 .name = "fujitsu::kblamps",
196 .brightness_get = kblamps_get,
197 .brightness_set = kblamps_set
198};
199#endif
200
157#ifdef CONFIG_FUJITSU_LAPTOP_DEBUG 201#ifdef CONFIG_FUJITSU_LAPTOP_DEBUG
158static u32 dbg_level = 0x03; 202static u32 dbg_level = 0x03;
159#endif 203#endif
160 204
161static void acpi_fujitsu_notify(acpi_handle handle, u32 event, void *data); 205static void acpi_fujitsu_notify(acpi_handle handle, u32 event, void *data);
162 206
207/* Fujitsu ACPI interface function */
208
209static int call_fext_func(int cmd, int arg0, int arg1, int arg2)
210{
211 acpi_status status = AE_OK;
212 union acpi_object params[4] = {
213 { .type = ACPI_TYPE_INTEGER },
214 { .type = ACPI_TYPE_INTEGER },
215 { .type = ACPI_TYPE_INTEGER },
216 { .type = ACPI_TYPE_INTEGER }
217 };
218 struct acpi_object_list arg_list = { 4, &params[0] };
219 struct acpi_buffer output;
220 union acpi_object out_obj;
221 acpi_handle handle = NULL;
222
223 status = acpi_get_handle(fujitsu_hotkey->acpi_handle, "FUNC", &handle);
224 if (ACPI_FAILURE(status)) {
225 vdbg_printk(FUJLAPTOP_DBG_ERROR,
226 "FUNC interface is not present\n");
227 return -ENODEV;
228 }
229
230 params[0].integer.value = cmd;
231 params[1].integer.value = arg0;
232 params[2].integer.value = arg1;
233 params[3].integer.value = arg2;
234
235 output.length = sizeof(out_obj);
236 output.pointer = &out_obj;
237
238 status = acpi_evaluate_object(handle, NULL, &arg_list, &output);
239 if (ACPI_FAILURE(status)) {
240 vdbg_printk(FUJLAPTOP_DBG_WARN,
241 "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) call failed\n",
242 cmd, arg0, arg1, arg2);
243 return -ENODEV;
244 }
245
246 if (out_obj.type != ACPI_TYPE_INTEGER) {
247 vdbg_printk(FUJLAPTOP_DBG_WARN,
248 "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) did not "
249 "return an integer\n",
250 cmd, arg0, arg1, arg2);
251 return -ENODEV;
252 }
253
254 vdbg_printk(FUJLAPTOP_DBG_TRACE,
255 "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) returned 0x%x\n",
256 cmd, arg0, arg1, arg2, (int)out_obj.integer.value);
257 return out_obj.integer.value;
258}
259
260#ifdef CONFIG_LEDS_CLASS
261/* LED class callbacks */
262
263static void logolamp_set(struct led_classdev *cdev,
264 enum led_brightness brightness)
265{
266 if (brightness >= LED_FULL) {
267 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON);
268 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_ON);
269 } else if (brightness >= LED_HALF) {
270 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_ON);
271 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_ALWAYS, FUNC_LED_OFF);
272 } else {
273 call_fext_func(FUNC_LEDS, 0x1, LOGOLAMP_POWERON, FUNC_LED_OFF);
274 }
275}
276
277static void kblamps_set(struct led_classdev *cdev,
278 enum led_brightness brightness)
279{
280 if (brightness >= LED_FULL)
281 call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_ON);
282 else
283 call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_OFF);
284}
285
286static enum led_brightness logolamp_get(struct led_classdev *cdev)
287{
288 enum led_brightness brightness = LED_OFF;
289 int poweron, always;
290
291 poweron = call_fext_func(FUNC_LEDS, 0x2, LOGOLAMP_POWERON, 0x0);
292 if (poweron == FUNC_LED_ON) {
293 brightness = LED_HALF;
294 always = call_fext_func(FUNC_LEDS, 0x2, LOGOLAMP_ALWAYS, 0x0);
295 if (always == FUNC_LED_ON)
296 brightness = LED_FULL;
297 }
298 return brightness;
299}
300
301static enum led_brightness kblamps_get(struct led_classdev *cdev)
302{
303 enum led_brightness brightness = LED_OFF;
304
305 if (call_fext_func(FUNC_LEDS, 0x2, KEYBOARD_LAMPS, 0x0) == FUNC_LED_ON)
306 brightness = LED_FULL;
307
308 return brightness;
309}
310#endif
311
163/* Hardware access for LCD brightness control */ 312/* Hardware access for LCD brightness control */
164 313
165static int set_lcd_level(int level) 314static int set_lcd_level(int level)
@@ -263,44 +412,34 @@ static int get_max_brightness(void)
263 return fujitsu->max_brightness; 412 return fujitsu->max_brightness;
264} 413}
265 414
266static int get_lcd_level_alt(void)
267{
268 unsigned long long state = 0;
269 acpi_status status = AE_OK;
270
271 vdbg_printk(FUJLAPTOP_DBG_TRACE, "get lcd level via GBLS\n");
272
273 status =
274 acpi_evaluate_integer(fujitsu->acpi_handle, "GBLS", NULL, &state);
275 if (status < 0)
276 return status;
277
278 fujitsu->brightness_level = state & 0x0fffffff;
279
280 if (state & 0x80000000)
281 fujitsu->brightness_changed = 1;
282 else
283 fujitsu->brightness_changed = 0;
284
285 return fujitsu->brightness_level;
286}
287
288/* Backlight device stuff */ 415/* Backlight device stuff */
289 416
290static int bl_get_brightness(struct backlight_device *b) 417static int bl_get_brightness(struct backlight_device *b)
291{ 418{
292 if (use_alt_lcd_levels) 419 return get_lcd_level();
293 return get_lcd_level_alt();
294 else
295 return get_lcd_level();
296} 420}
297 421
298static int bl_update_status(struct backlight_device *b) 422static int bl_update_status(struct backlight_device *b)
299{ 423{
424 int ret;
425 if (b->props.power == 4)
426 ret = call_fext_func(FUNC_BACKLIGHT, 0x1, 0x4, 0x3);
427 else
428 ret = call_fext_func(FUNC_BACKLIGHT, 0x1, 0x4, 0x0);
429 if (ret != 0)
430 vdbg_printk(FUJLAPTOP_DBG_ERROR,
431 "Unable to adjust backlight power, error code %i\n",
432 ret);
433
300 if (use_alt_lcd_levels) 434 if (use_alt_lcd_levels)
301 return set_lcd_level_alt(b->props.brightness); 435 ret = set_lcd_level_alt(b->props.brightness);
302 else 436 else
303 return set_lcd_level(b->props.brightness); 437 ret = set_lcd_level(b->props.brightness);
438 if (ret != 0)
439 vdbg_printk(FUJLAPTOP_DBG_ERROR,
440 "Unable to adjust LCD brightness, error code %i\n",
441 ret);
442 return ret;
304} 443}
305 444
306static struct backlight_ops fujitsubl_ops = { 445static struct backlight_ops fujitsubl_ops = {
@@ -344,10 +483,7 @@ static ssize_t show_lcd_level(struct device *dev,
344 483
345 int ret; 484 int ret;
346 485
347 if (use_alt_lcd_levels) 486 ret = get_lcd_level();
348 ret = get_lcd_level_alt();
349 else
350 ret = get_lcd_level();
351 if (ret < 0) 487 if (ret < 0)
352 return ret; 488 return ret;
353 489
@@ -372,52 +508,71 @@ static ssize_t store_lcd_level(struct device *dev,
372 if (ret < 0) 508 if (ret < 0)
373 return ret; 509 return ret;
374 510
375 if (use_alt_lcd_levels) 511 ret = get_lcd_level();
376 ret = get_lcd_level_alt();
377 else
378 ret = get_lcd_level();
379 if (ret < 0) 512 if (ret < 0)
380 return ret; 513 return ret;
381 514
382 return count; 515 return count;
383} 516}
384 517
385/* Hardware access for hotkey device */ 518static ssize_t
386 519ignore_store(struct device *dev,
387static int get_irb(void) 520 struct device_attribute *attr, const char *buf, size_t count)
388{ 521{
389 unsigned long long state = 0; 522 return count;
390 acpi_status status = AE_OK; 523}
391
392 vdbg_printk(FUJLAPTOP_DBG_TRACE, "Get irb\n");
393
394 status =
395 acpi_evaluate_integer(fujitsu_hotkey->acpi_handle, "GIRB", NULL,
396 &state);
397 if (status < 0)
398 return status;
399 524
400 fujitsu_hotkey->irb = state; 525static ssize_t
526show_lid_state(struct device *dev,
527 struct device_attribute *attr, char *buf)
528{
529 if (fujitsu_hotkey->rfkill_state == UNSUPPORTED_CMD)
530 return sprintf(buf, "unknown\n");
531 if (fujitsu_hotkey->rfkill_state & 0x100)
532 return sprintf(buf, "open\n");
533 else
534 return sprintf(buf, "closed\n");
535}
401 536
402 return fujitsu_hotkey->irb; 537static ssize_t
538show_dock_state(struct device *dev,
539 struct device_attribute *attr, char *buf)
540{
541 if (fujitsu_hotkey->rfkill_state == UNSUPPORTED_CMD)
542 return sprintf(buf, "unknown\n");
543 if (fujitsu_hotkey->rfkill_state & 0x200)
544 return sprintf(buf, "docked\n");
545 else
546 return sprintf(buf, "undocked\n");
403} 547}
404 548
405static ssize_t 549static ssize_t
406ignore_store(struct device *dev, 550show_radios_state(struct device *dev,
407 struct device_attribute *attr, const char *buf, size_t count) 551 struct device_attribute *attr, char *buf)
408{ 552{
409 return count; 553 if (fujitsu_hotkey->rfkill_state == UNSUPPORTED_CMD)
554 return sprintf(buf, "unknown\n");
555 if (fujitsu_hotkey->rfkill_state & 0x20)
556 return sprintf(buf, "on\n");
557 else
558 return sprintf(buf, "killed\n");
410} 559}
411 560
412static DEVICE_ATTR(max_brightness, 0444, show_max_brightness, ignore_store); 561static DEVICE_ATTR(max_brightness, 0444, show_max_brightness, ignore_store);
413static DEVICE_ATTR(brightness_changed, 0444, show_brightness_changed, 562static DEVICE_ATTR(brightness_changed, 0444, show_brightness_changed,
414 ignore_store); 563 ignore_store);
415static DEVICE_ATTR(lcd_level, 0644, show_lcd_level, store_lcd_level); 564static DEVICE_ATTR(lcd_level, 0644, show_lcd_level, store_lcd_level);
565static DEVICE_ATTR(lid, 0444, show_lid_state, ignore_store);
566static DEVICE_ATTR(dock, 0444, show_dock_state, ignore_store);
567static DEVICE_ATTR(radios, 0444, show_radios_state, ignore_store);
416 568
417static struct attribute *fujitsupf_attributes[] = { 569static struct attribute *fujitsupf_attributes[] = {
418 &dev_attr_brightness_changed.attr, 570 &dev_attr_brightness_changed.attr,
419 &dev_attr_max_brightness.attr, 571 &dev_attr_max_brightness.attr,
420 &dev_attr_lcd_level.attr, 572 &dev_attr_lcd_level.attr,
573 &dev_attr_lid.attr,
574 &dev_attr_dock.attr,
575 &dev_attr_radios.attr,
421 NULL 576 NULL
422}; 577};
423 578
@@ -435,24 +590,16 @@ static struct platform_driver fujitsupf_driver = {
435static void dmi_check_cb_common(const struct dmi_system_id *id) 590static void dmi_check_cb_common(const struct dmi_system_id *id)
436{ 591{
437 acpi_handle handle; 592 acpi_handle handle;
438 int have_blnf;
439 printk(KERN_INFO "fujitsu-laptop: Identified laptop model '%s'.\n", 593 printk(KERN_INFO "fujitsu-laptop: Identified laptop model '%s'.\n",
440 id->ident); 594 id->ident);
441 have_blnf = ACPI_SUCCESS
442 (acpi_get_handle(NULL, "\\_SB.PCI0.GFX0.LCD.BLNF", &handle));
443 if (use_alt_lcd_levels == -1) { 595 if (use_alt_lcd_levels == -1) {
444 vdbg_printk(FUJLAPTOP_DBG_TRACE, "auto-detecting usealt\n"); 596 if (ACPI_SUCCESS(acpi_get_handle(NULL,
445 use_alt_lcd_levels = 1; 597 "\\_SB.PCI0.LPCB.FJEX.SBL2", &handle)))
446 } 598 use_alt_lcd_levels = 1;
447 if (disable_brightness_keys == -1) { 599 else
448 vdbg_printk(FUJLAPTOP_DBG_TRACE, 600 use_alt_lcd_levels = 0;
449 "auto-detecting disable_keys\n"); 601 vdbg_printk(FUJLAPTOP_DBG_TRACE, "auto-detected usealt as "
450 disable_brightness_keys = have_blnf ? 1 : 0; 602 "%i\n", use_alt_lcd_levels);
451 }
452 if (disable_brightness_adjust == -1) {
453 vdbg_printk(FUJLAPTOP_DBG_TRACE,
454 "auto-detecting disable_adjust\n");
455 disable_brightness_adjust = have_blnf ? 0 : 1;
456 } 603 }
457} 604}
458 605
@@ -581,19 +728,14 @@ static int acpi_fujitsu_add(struct acpi_device *device)
581 728
582 /* do config (detect defaults) */ 729 /* do config (detect defaults) */
583 use_alt_lcd_levels = use_alt_lcd_levels == 1 ? 1 : 0; 730 use_alt_lcd_levels = use_alt_lcd_levels == 1 ? 1 : 0;
584 disable_brightness_keys = disable_brightness_keys == 1 ? 1 : 0;
585 disable_brightness_adjust = disable_brightness_adjust == 1 ? 1 : 0; 731 disable_brightness_adjust = disable_brightness_adjust == 1 ? 1 : 0;
586 vdbg_printk(FUJLAPTOP_DBG_INFO, 732 vdbg_printk(FUJLAPTOP_DBG_INFO,
587 "config: [alt interface: %d], [key disable: %d], [adjust disable: %d]\n", 733 "config: [alt interface: %d], [adjust disable: %d]\n",
588 use_alt_lcd_levels, disable_brightness_keys, 734 use_alt_lcd_levels, disable_brightness_adjust);
589 disable_brightness_adjust);
590 735
591 if (get_max_brightness() <= 0) 736 if (get_max_brightness() <= 0)
592 fujitsu->max_brightness = FUJITSU_LCD_N_LEVELS; 737 fujitsu->max_brightness = FUJITSU_LCD_N_LEVELS;
593 if (use_alt_lcd_levels) 738 get_lcd_level();
594 get_lcd_level_alt();
595 else
596 get_lcd_level();
597 739
598 return result; 740 return result;
599 741
@@ -644,43 +786,23 @@ static void acpi_fujitsu_notify(acpi_handle handle, u32 event, void *data)
644 case ACPI_FUJITSU_NOTIFY_CODE1: 786 case ACPI_FUJITSU_NOTIFY_CODE1:
645 keycode = 0; 787 keycode = 0;
646 oldb = fujitsu->brightness_level; 788 oldb = fujitsu->brightness_level;
647 get_lcd_level(); /* the alt version always yields changed */ 789 get_lcd_level();
648 newb = fujitsu->brightness_level; 790 newb = fujitsu->brightness_level;
649 791
650 vdbg_printk(FUJLAPTOP_DBG_TRACE, 792 vdbg_printk(FUJLAPTOP_DBG_TRACE,
651 "brightness button event [%i -> %i (%i)]\n", 793 "brightness button event [%i -> %i (%i)]\n",
652 oldb, newb, fujitsu->brightness_changed); 794 oldb, newb, fujitsu->brightness_changed);
653 795
654 if (oldb == newb && fujitsu->brightness_changed) { 796 if (oldb < newb) {
655 keycode = 0;
656 if (disable_brightness_keys != 1) {
657 if (oldb == 0) {
658 acpi_bus_generate_proc_event
659 (fujitsu->dev,
660 ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS,
661 0);
662 keycode = KEY_BRIGHTNESSDOWN;
663 } else if (oldb ==
664 (fujitsu->max_brightness) - 1) {
665 acpi_bus_generate_proc_event
666 (fujitsu->dev,
667 ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS,
668 0);
669 keycode = KEY_BRIGHTNESSUP;
670 }
671 }
672 } else if (oldb < newb) {
673 if (disable_brightness_adjust != 1) { 797 if (disable_brightness_adjust != 1) {
674 if (use_alt_lcd_levels) 798 if (use_alt_lcd_levels)
675 set_lcd_level_alt(newb); 799 set_lcd_level_alt(newb);
676 else 800 else
677 set_lcd_level(newb); 801 set_lcd_level(newb);
678 } 802 }
679 if (disable_brightness_keys != 1) { 803 acpi_bus_generate_proc_event(fujitsu->dev,
680 acpi_bus_generate_proc_event(fujitsu->dev, 804 ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS, 0);
681 ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS, 0); 805 keycode = KEY_BRIGHTNESSUP;
682 keycode = KEY_BRIGHTNESSUP;
683 }
684 } else if (oldb > newb) { 806 } else if (oldb > newb) {
685 if (disable_brightness_adjust != 1) { 807 if (disable_brightness_adjust != 1) {
686 if (use_alt_lcd_levels) 808 if (use_alt_lcd_levels)
@@ -688,13 +810,9 @@ static void acpi_fujitsu_notify(acpi_handle handle, u32 event, void *data)
688 else 810 else
689 set_lcd_level(newb); 811 set_lcd_level(newb);
690 } 812 }
691 if (disable_brightness_keys != 1) { 813 acpi_bus_generate_proc_event(fujitsu->dev,
692 acpi_bus_generate_proc_event(fujitsu->dev, 814 ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS, 0);
693 ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS, 0); 815 keycode = KEY_BRIGHTNESSDOWN;
694 keycode = KEY_BRIGHTNESSDOWN;
695 }
696 } else {
697 keycode = KEY_UNKNOWN;
698 } 816 }
699 break; 817 break;
700 default: 818 default:
@@ -771,7 +889,8 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
771 input->id.bustype = BUS_HOST; 889 input->id.bustype = BUS_HOST;
772 input->id.product = 0x06; 890 input->id.product = 0x06;
773 input->dev.parent = &device->dev; 891 input->dev.parent = &device->dev;
774 input->evbit[0] = BIT(EV_KEY); 892
893 set_bit(EV_KEY, input->evbit);
775 set_bit(fujitsu->keycode1, input->keybit); 894 set_bit(fujitsu->keycode1, input->keybit);
776 set_bit(fujitsu->keycode2, input->keybit); 895 set_bit(fujitsu->keycode2, input->keybit);
777 set_bit(fujitsu->keycode3, input->keybit); 896 set_bit(fujitsu->keycode3, input->keybit);
@@ -803,10 +922,44 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
803 printk(KERN_ERR "_INI Method failed\n"); 922 printk(KERN_ERR "_INI Method failed\n");
804 } 923 }
805 924
806 i = 0; /* Discard hotkey ringbuffer */ 925 i = 0;
807 while (get_irb() != 0 && (i++) < MAX_HOTKEY_RINGBUFFER_SIZE) ; 926 while (call_fext_func(FUNC_BUTTONS, 0x1, 0x0, 0x0) != 0
927 && (i++) < MAX_HOTKEY_RINGBUFFER_SIZE)
928 ; /* No action, result is discarded */
808 vdbg_printk(FUJLAPTOP_DBG_INFO, "Discarded %i ringbuffer entries\n", i); 929 vdbg_printk(FUJLAPTOP_DBG_INFO, "Discarded %i ringbuffer entries\n", i);
809 930
931 fujitsu_hotkey->rfkill_state =
932 call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0);
933
934 /* Suspect this is a keymap of the application panel, print it */
935 printk(KERN_INFO "fujitsu-laptop: BTNI: [0x%x]\n",
936 call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0));
937
938 #ifdef CONFIG_LEDS_CLASS
939 if (call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & LOGOLAMP_POWERON) {
940 result = led_classdev_register(&fujitsu->pf_device->dev,
941 &logolamp_led);
942 if (result == 0) {
943 fujitsu_hotkey->logolamp_registered = 1;
944 } else {
945 printk(KERN_ERR "fujitsu-laptop: Could not register "
946 "LED handler for logo lamp, error %i\n", result);
947 }
948 }
949
950 if ((call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & KEYBOARD_LAMPS) &&
951 (call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0) == 0x0)) {
952 result = led_classdev_register(&fujitsu->pf_device->dev,
953 &kblamps_led);
954 if (result == 0) {
955 fujitsu_hotkey->kblamps_registered = 1;
956 } else {
957 printk(KERN_ERR "fujitsu-laptop: Could not register "
958 "LED handler for keyboard lamps, error %i\n", result);
959 }
960 }
961 #endif
962
810 return result; 963 return result;
811 964
812end: 965end:
@@ -852,16 +1005,15 @@ static void acpi_fujitsu_hotkey_notify(acpi_handle handle, u32 event,
852 1005
853 input = fujitsu_hotkey->input; 1006 input = fujitsu_hotkey->input;
854 1007
855 vdbg_printk(FUJLAPTOP_DBG_TRACE, "Hotkey event\n"); 1008 fujitsu_hotkey->rfkill_state =
1009 call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0);
856 1010
857 switch (event) { 1011 switch (event) {
858 case ACPI_FUJITSU_NOTIFY_CODE1: 1012 case ACPI_FUJITSU_NOTIFY_CODE1:
859 i = 0; 1013 i = 0;
860 while ((irb = get_irb()) != 0 1014 while ((irb =
861 && (i++) < MAX_HOTKEY_RINGBUFFER_SIZE) { 1015 call_fext_func(FUNC_BUTTONS, 0x1, 0x0, 0x0)) != 0
862 vdbg_printk(FUJLAPTOP_DBG_TRACE, "GIRB result [%x]\n", 1016 && (i++) < MAX_HOTKEY_RINGBUFFER_SIZE) {
863 irb);
864
865 switch (irb & 0x4ff) { 1017 switch (irb & 0x4ff) {
866 case KEY1_CODE: 1018 case KEY1_CODE:
867 keycode = fujitsu->keycode1; 1019 keycode = fujitsu->keycode1;
@@ -1035,6 +1187,15 @@ static int __init fujitsu_init(void)
1035 goto fail_hotkey1; 1187 goto fail_hotkey1;
1036 } 1188 }
1037 1189
1190 /* Sync backlight power status (needs FUJ02E3 device, hence deferred) */
1191
1192 if (!acpi_video_backlight_support()) {
1193 if (call_fext_func(FUNC_BACKLIGHT, 0x2, 0x4, 0x0) == 3)
1194 fujitsu->bl_device->props.power = 4;
1195 else
1196 fujitsu->bl_device->props.power = 0;
1197 }
1198
1038 printk(KERN_INFO "fujitsu-laptop: driver " FUJITSU_DRIVER_VERSION 1199 printk(KERN_INFO "fujitsu-laptop: driver " FUJITSU_DRIVER_VERSION
1039 " successfully loaded.\n"); 1200 " successfully loaded.\n");
1040 1201
@@ -1074,6 +1235,14 @@ fail_acpi:
1074 1235
1075static void __exit fujitsu_cleanup(void) 1236static void __exit fujitsu_cleanup(void)
1076{ 1237{
1238 #ifdef CONFIG_LEDS_CLASS
1239 if (fujitsu_hotkey->logolamp_registered != 0)
1240 led_classdev_unregister(&logolamp_led);
1241
1242 if (fujitsu_hotkey->kblamps_registered != 0)
1243 led_classdev_unregister(&kblamps_led);
1244 #endif
1245
1077 sysfs_remove_group(&fujitsu->pf_device->dev.kobj, 1246 sysfs_remove_group(&fujitsu->pf_device->dev.kobj,
1078 &fujitsupf_attribute_group); 1247 &fujitsupf_attribute_group);
1079 platform_device_unregister(fujitsu->pf_device); 1248 platform_device_unregister(fujitsu->pf_device);
@@ -1098,9 +1267,6 @@ module_exit(fujitsu_cleanup);
1098module_param(use_alt_lcd_levels, uint, 0644); 1267module_param(use_alt_lcd_levels, uint, 0644);
1099MODULE_PARM_DESC(use_alt_lcd_levels, 1268MODULE_PARM_DESC(use_alt_lcd_levels,
1100 "Use alternative interface for lcd_levels (needed for Lifebook s6410)."); 1269 "Use alternative interface for lcd_levels (needed for Lifebook s6410).");
1101module_param(disable_brightness_keys, uint, 0644);
1102MODULE_PARM_DESC(disable_brightness_keys,
1103 "Disable brightness keys (eg. if they are already handled by the generic ACPI_VIDEO device).");
1104module_param(disable_brightness_adjust, uint, 0644); 1270module_param(disable_brightness_adjust, uint, 0644);
1105MODULE_PARM_DESC(disable_brightness_adjust, "Disable brightness adjustment ."); 1271MODULE_PARM_DESC(disable_brightness_adjust, "Disable brightness adjustment .");
1106#ifdef CONFIG_FUJITSU_LAPTOP_DEBUG 1272#ifdef CONFIG_FUJITSU_LAPTOP_DEBUG
@@ -1108,12 +1274,13 @@ module_param_named(debug, dbg_level, uint, 0644);
1108MODULE_PARM_DESC(debug, "Sets debug level bit-mask"); 1274MODULE_PARM_DESC(debug, "Sets debug level bit-mask");
1109#endif 1275#endif
1110 1276
1111MODULE_AUTHOR("Jonathan Woithe, Peter Gruber"); 1277MODULE_AUTHOR("Jonathan Woithe, Peter Gruber, Tony Vroon");
1112MODULE_DESCRIPTION("Fujitsu laptop extras support"); 1278MODULE_DESCRIPTION("Fujitsu laptop extras support");
1113MODULE_VERSION(FUJITSU_DRIVER_VERSION); 1279MODULE_VERSION(FUJITSU_DRIVER_VERSION);
1114MODULE_LICENSE("GPL"); 1280MODULE_LICENSE("GPL");
1115 1281
1116MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1D3:*:cvrS6410:*"); 1282MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1D3:*:cvrS6410:*");
1283MODULE_ALIAS("dmi:*:svnFUJITSUSIEMENS:*:pvr:rvnFUJITSU:rnFJNB1E6:*:cvrS6420:*");
1117MODULE_ALIAS("dmi:*:svnFUJITSU:*:pvr:rvnFUJITSU:rnFJNB19C:*:cvrS7020:*"); 1284MODULE_ALIAS("dmi:*:svnFUJITSU:*:pvr:rvnFUJITSU:rnFJNB19C:*:cvrS7020:*");
1118 1285
1119static struct pnp_device_id pnp_ids[] = { 1286static struct pnp_device_id pnp_ids[] = {
diff --git a/drivers/misc/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index 4b7c24c519c3..7c789f0a94d7 100644
--- a/drivers/misc/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -428,7 +428,9 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
428 wifi_rfkill->state = hp_wmi_wifi_state(); 428 wifi_rfkill->state = hp_wmi_wifi_state();
429 wifi_rfkill->toggle_radio = hp_wmi_wifi_set; 429 wifi_rfkill->toggle_radio = hp_wmi_wifi_set;
430 wifi_rfkill->user_claim_unsupported = 1; 430 wifi_rfkill->user_claim_unsupported = 1;
431 rfkill_register(wifi_rfkill); 431 err = rfkill_register(wifi_rfkill);
432 if (err)
433 goto add_sysfs_error;
432 } 434 }
433 435
434 if (wireless & 0x2) { 436 if (wireless & 0x2) {
@@ -438,7 +440,8 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
438 bluetooth_rfkill->state = hp_wmi_bluetooth_state(); 440 bluetooth_rfkill->state = hp_wmi_bluetooth_state();
439 bluetooth_rfkill->toggle_radio = hp_wmi_bluetooth_set; 441 bluetooth_rfkill->toggle_radio = hp_wmi_bluetooth_set;
440 bluetooth_rfkill->user_claim_unsupported = 1; 442 bluetooth_rfkill->user_claim_unsupported = 1;
441 rfkill_register(bluetooth_rfkill); 443 err = rfkill_register(bluetooth_rfkill);
444 goto register_bluetooth_error;
442 } 445 }
443 446
444 if (wireless & 0x4) { 447 if (wireless & 0x4) {
@@ -447,10 +450,16 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
447 wwan_rfkill->state = hp_wmi_wwan_state(); 450 wwan_rfkill->state = hp_wmi_wwan_state();
448 wwan_rfkill->toggle_radio = hp_wmi_wwan_set; 451 wwan_rfkill->toggle_radio = hp_wmi_wwan_set;
449 wwan_rfkill->user_claim_unsupported = 1; 452 wwan_rfkill->user_claim_unsupported = 1;
450 rfkill_register(wwan_rfkill); 453 err = rfkill_register(wwan_rfkill);
454 if (err)
455 goto register_wwan_err;
451 } 456 }
452 457
453 return 0; 458 return 0;
459register_wwan_err:
460 rfkill_unregister(bluetooth_rfkill);
461register_bluetooth_error:
462 rfkill_unregister(wifi_rfkill);
454add_sysfs_error: 463add_sysfs_error:
455 cleanup_sysfs(device); 464 cleanup_sysfs(device);
456 return err; 465 return err;
diff --git a/drivers/misc/intel_menlow.c b/drivers/platform/x86/intel_menlow.c
index 27b7662955bb..27b7662955bb 100644
--- a/drivers/misc/intel_menlow.c
+++ b/drivers/platform/x86/intel_menlow.c
diff --git a/drivers/misc/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
index 759763d18e4c..759763d18e4c 100644
--- a/drivers/misc/msi-laptop.c
+++ b/drivers/platform/x86/msi-laptop.c
diff --git a/drivers/misc/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c
index 4a1bc64485d5..f30db367c82e 100644
--- a/drivers/misc/panasonic-laptop.c
+++ b/drivers/platform/x86/panasonic-laptop.c
@@ -241,8 +241,6 @@ static int acpi_pcc_write_sset(struct pcc_acpi *pcc, int func, int val)
241 }; 241 };
242 acpi_status status = AE_OK; 242 acpi_status status = AE_OK;
243 243
244 ACPI_FUNCTION_TRACE("acpi_pcc_write_sset");
245
246 status = acpi_evaluate_object(pcc->handle, METHOD_HKEY_SSET, 244 status = acpi_evaluate_object(pcc->handle, METHOD_HKEY_SSET,
247 &params, NULL); 245 &params, NULL);
248 246
@@ -254,8 +252,6 @@ static inline int acpi_pcc_get_sqty(struct acpi_device *device)
254 unsigned long long s; 252 unsigned long long s;
255 acpi_status status; 253 acpi_status status;
256 254
257 ACPI_FUNCTION_TRACE("acpi_pcc_get_sqty");
258
259 status = acpi_evaluate_integer(device->handle, METHOD_HKEY_SQTY, 255 status = acpi_evaluate_integer(device->handle, METHOD_HKEY_SQTY,
260 NULL, &s); 256 NULL, &s);
261 if (ACPI_SUCCESS(status)) 257 if (ACPI_SUCCESS(status))
@@ -274,8 +270,6 @@ static int acpi_pcc_retrieve_biosdata(struct pcc_acpi *pcc, u32 *sinf)
274 union acpi_object *hkey = NULL; 270 union acpi_object *hkey = NULL;
275 int i; 271 int i;
276 272
277 ACPI_FUNCTION_TRACE("acpi_pcc_retrieve_biosdata");
278
279 status = acpi_evaluate_object(pcc->handle, METHOD_HKEY_SINF, 0, 273 status = acpi_evaluate_object(pcc->handle, METHOD_HKEY_SINF, 0,
280 &buffer); 274 &buffer);
281 if (ACPI_FAILURE(status)) { 275 if (ACPI_FAILURE(status)) {
@@ -501,8 +495,6 @@ static void acpi_pcc_generate_keyinput(struct pcc_acpi *pcc)
501 int key_code, hkey_num; 495 int key_code, hkey_num;
502 unsigned long long result; 496 unsigned long long result;
503 497
504 ACPI_FUNCTION_TRACE("acpi_pcc_generate_keyinput");
505
506 rc = acpi_evaluate_integer(pcc->handle, METHOD_HKEY_QUERY, 498 rc = acpi_evaluate_integer(pcc->handle, METHOD_HKEY_QUERY,
507 NULL, &result); 499 NULL, &result);
508 if (!ACPI_SUCCESS(rc)) { 500 if (!ACPI_SUCCESS(rc)) {
@@ -538,8 +530,6 @@ static void acpi_pcc_hotkey_notify(acpi_handle handle, u32 event, void *data)
538{ 530{
539 struct pcc_acpi *pcc = (struct pcc_acpi *) data; 531 struct pcc_acpi *pcc = (struct pcc_acpi *) data;
540 532
541 ACPI_FUNCTION_TRACE("acpi_pcc_hotkey_notify");
542
543 switch (event) { 533 switch (event) {
544 case HKEY_NOTIFY: 534 case HKEY_NOTIFY:
545 acpi_pcc_generate_keyinput(pcc); 535 acpi_pcc_generate_keyinput(pcc);
@@ -554,8 +544,6 @@ static int acpi_pcc_init_input(struct pcc_acpi *pcc)
554{ 544{
555 int i, rc; 545 int i, rc;
556 546
557 ACPI_FUNCTION_TRACE("acpi_pcc_init_input");
558
559 pcc->input_dev = input_allocate_device(); 547 pcc->input_dev = input_allocate_device();
560 if (!pcc->input_dev) { 548 if (!pcc->input_dev) {
561 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 549 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
@@ -597,8 +585,6 @@ static int acpi_pcc_hotkey_resume(struct acpi_device *device)
597 struct pcc_acpi *pcc = acpi_driver_data(device); 585 struct pcc_acpi *pcc = acpi_driver_data(device);
598 acpi_status status = AE_OK; 586 acpi_status status = AE_OK;
599 587
600 ACPI_FUNCTION_TRACE("acpi_pcc_hotkey_resume");
601
602 if (device == NULL || pcc == NULL) 588 if (device == NULL || pcc == NULL)
603 return -EINVAL; 589 return -EINVAL;
604 590
@@ -616,8 +602,6 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
616 struct pcc_acpi *pcc; 602 struct pcc_acpi *pcc;
617 int num_sifr, result; 603 int num_sifr, result;
618 604
619 ACPI_FUNCTION_TRACE("acpi_pcc_hotkey_add");
620
621 if (!device) 605 if (!device)
622 return -EINVAL; 606 return -EINVAL;
623 607
@@ -714,8 +698,6 @@ static int __init acpi_pcc_init(void)
714{ 698{
715 int result = 0; 699 int result = 0;
716 700
717 ACPI_FUNCTION_TRACE("acpi_pcc_init");
718
719 if (acpi_disabled) 701 if (acpi_disabled)
720 return -ENODEV; 702 return -ENODEV;
721 703
@@ -733,8 +715,6 @@ static int acpi_pcc_hotkey_remove(struct acpi_device *device, int type)
733{ 715{
734 struct pcc_acpi *pcc = acpi_driver_data(device); 716 struct pcc_acpi *pcc = acpi_driver_data(device);
735 717
736 ACPI_FUNCTION_TRACE("acpi_pcc_hotkey_remove");
737
738 if (!device || !pcc) 718 if (!device || !pcc)
739 return -EINVAL; 719 return -EINVAL;
740 720
@@ -757,8 +737,6 @@ static int acpi_pcc_hotkey_remove(struct acpi_device *device, int type)
757 737
758static void __exit acpi_pcc_exit(void) 738static void __exit acpi_pcc_exit(void)
759{ 739{
760 ACPI_FUNCTION_TRACE("acpi_pcc_exit");
761
762 acpi_bus_unregister_driver(&acpi_pcc_driver); 740 acpi_bus_unregister_driver(&acpi_pcc_driver);
763} 741}
764 742
diff --git a/drivers/misc/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 571b211608d1..537959d07148 100644
--- a/drivers/misc/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -935,14 +935,17 @@ static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)
935static acpi_status sony_walk_callback(acpi_handle handle, u32 level, 935static acpi_status sony_walk_callback(acpi_handle handle, u32 level,
936 void *context, void **return_value) 936 void *context, void **return_value)
937{ 937{
938 struct acpi_namespace_node *node; 938 struct acpi_device_info *info;
939 union acpi_operand_object *operand; 939 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
940 940
941 node = (struct acpi_namespace_node *)handle; 941 if (ACPI_SUCCESS(acpi_get_object_info(handle, &buffer))) {
942 operand = (union acpi_operand_object *)node->object; 942 info = buffer.pointer;
943 943
944 printk(KERN_WARNING DRV_PFX "method: name: %4.4s, args %X\n", node->name.ascii, 944 printk(KERN_WARNING DRV_PFX "method: name: %4.4s, args %X\n",
945 (u32) operand->method.param_count); 945 (char *)&info->name, info->param_count);
946
947 kfree(buffer.pointer);
948 }
946 949
947 return AE_OK; 950 return AE_OK;
948} 951}
diff --git a/drivers/misc/tc1100-wmi.c b/drivers/platform/x86/tc1100-wmi.c
index f25e4c974dcf..b4a4aa9ee482 100644
--- a/drivers/misc/tc1100-wmi.c
+++ b/drivers/platform/x86/tc1100-wmi.c
@@ -30,7 +30,6 @@
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/types.h> 31#include <linux/types.h>
32#include <acpi/acpi.h> 32#include <acpi/acpi.h>
33#include <acpi/actypes.h>
34#include <acpi/acpi_bus.h> 33#include <acpi/acpi_bus.h>
35#include <acpi/acpi_drivers.h> 34#include <acpi/acpi_drivers.h>
36#include <linux/platform_device.h> 35#include <linux/platform_device.h>
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 899766e16fa8..bcbc05107ba8 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -21,7 +21,7 @@
21 * 02110-1301, USA. 21 * 02110-1301, USA.
22 */ 22 */
23 23
24#define TPACPI_VERSION "0.21" 24#define TPACPI_VERSION "0.22"
25#define TPACPI_SYSFS_VERSION 0x020200 25#define TPACPI_SYSFS_VERSION 0x020200
26 26
27/* 27/*
@@ -76,7 +76,6 @@
76#include <linux/workqueue.h> 76#include <linux/workqueue.h>
77 77
78#include <acpi/acpi_drivers.h> 78#include <acpi/acpi_drivers.h>
79#include <acpi/acnamesp.h>
80 79
81#include <linux/pci_ids.h> 80#include <linux/pci_ids.h>
82 81
@@ -123,6 +122,27 @@ enum {
123#define TPACPI_HKEY_INPUT_PRODUCT 0x5054 /* "TP" */ 122#define TPACPI_HKEY_INPUT_PRODUCT 0x5054 /* "TP" */
124#define TPACPI_HKEY_INPUT_VERSION 0x4101 123#define TPACPI_HKEY_INPUT_VERSION 0x4101
125 124
125/* ACPI \WGSV commands */
126enum {
127 TP_ACPI_WGSV_GET_STATE = 0x01, /* Get state information */
128 TP_ACPI_WGSV_PWR_ON_ON_RESUME = 0x02, /* Resume WWAN powered on */
129 TP_ACPI_WGSV_PWR_OFF_ON_RESUME = 0x03, /* Resume WWAN powered off */
130 TP_ACPI_WGSV_SAVE_STATE = 0x04, /* Save state for S4/S5 */
131};
132
133/* TP_ACPI_WGSV_GET_STATE bits */
134enum {
135 TP_ACPI_WGSV_STATE_WWANEXIST = 0x0001, /* WWAN hw available */
136 TP_ACPI_WGSV_STATE_WWANPWR = 0x0002, /* WWAN radio enabled */
137 TP_ACPI_WGSV_STATE_WWANPWRRES = 0x0004, /* WWAN state at resume */
138 TP_ACPI_WGSV_STATE_WWANBIOSOFF = 0x0008, /* WWAN disabled in BIOS */
139 TP_ACPI_WGSV_STATE_BLTHEXIST = 0x0001, /* BLTH hw available */
140 TP_ACPI_WGSV_STATE_BLTHPWR = 0x0002, /* BLTH radio enabled */
141 TP_ACPI_WGSV_STATE_BLTHPWRRES = 0x0004, /* BLTH state at resume */
142 TP_ACPI_WGSV_STATE_BLTHBIOSOFF = 0x0008, /* BLTH disabled in BIOS */
143 TP_ACPI_WGSV_STATE_UWBEXIST = 0x0010, /* UWB hw available */
144 TP_ACPI_WGSV_STATE_UWBPWR = 0x0020, /* UWB radio enabled */
145};
126 146
127/**************************************************************************** 147/****************************************************************************
128 * Main driver 148 * Main driver
@@ -149,14 +169,17 @@ enum {
149enum { 169enum {
150 TPACPI_RFK_BLUETOOTH_SW_ID = 0, 170 TPACPI_RFK_BLUETOOTH_SW_ID = 0,
151 TPACPI_RFK_WWAN_SW_ID, 171 TPACPI_RFK_WWAN_SW_ID,
172 TPACPI_RFK_UWB_SW_ID,
152}; 173};
153 174
154/* Debugging */ 175/* Debugging */
155#define TPACPI_LOG TPACPI_FILE ": " 176#define TPACPI_LOG TPACPI_FILE ": "
156#define TPACPI_ERR KERN_ERR TPACPI_LOG 177#define TPACPI_ALERT KERN_ALERT TPACPI_LOG
157#define TPACPI_NOTICE KERN_NOTICE TPACPI_LOG 178#define TPACPI_CRIT KERN_CRIT TPACPI_LOG
158#define TPACPI_INFO KERN_INFO TPACPI_LOG 179#define TPACPI_ERR KERN_ERR TPACPI_LOG
159#define TPACPI_DEBUG KERN_DEBUG TPACPI_LOG 180#define TPACPI_NOTICE KERN_NOTICE TPACPI_LOG
181#define TPACPI_INFO KERN_INFO TPACPI_LOG
182#define TPACPI_DEBUG KERN_DEBUG TPACPI_LOG
160 183
161#define TPACPI_DBG_ALL 0xffff 184#define TPACPI_DBG_ALL 0xffff
162#define TPACPI_DBG_INIT 0x0001 185#define TPACPI_DBG_INIT 0x0001
@@ -202,6 +225,7 @@ struct ibm_struct {
202 void (*exit) (void); 225 void (*exit) (void);
203 void (*resume) (void); 226 void (*resume) (void);
204 void (*suspend) (pm_message_t state); 227 void (*suspend) (pm_message_t state);
228 void (*shutdown) (void);
205 229
206 struct list_head all_drivers; 230 struct list_head all_drivers;
207 231
@@ -240,6 +264,7 @@ static struct {
240 u32 bright_16levels:1; 264 u32 bright_16levels:1;
241 u32 bright_acpimode:1; 265 u32 bright_acpimode:1;
242 u32 wan:1; 266 u32 wan:1;
267 u32 uwb:1;
243 u32 fan_ctrl_status_undef:1; 268 u32 fan_ctrl_status_undef:1;
244 u32 input_device_registered:1; 269 u32 input_device_registered:1;
245 u32 platform_drv_registered:1; 270 u32 platform_drv_registered:1;
@@ -289,6 +314,18 @@ struct tpacpi_led_classdev {
289 unsigned int led; 314 unsigned int led;
290}; 315};
291 316
317#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
318static int dbg_wlswemul;
319static int tpacpi_wlsw_emulstate;
320static int dbg_bluetoothemul;
321static int tpacpi_bluetooth_emulstate;
322static int dbg_wwanemul;
323static int tpacpi_wwan_emulstate;
324static int dbg_uwbemul;
325static int tpacpi_uwb_emulstate;
326#endif
327
328
292/**************************************************************************** 329/****************************************************************************
293 **************************************************************************** 330 ****************************************************************************
294 * 331 *
@@ -729,6 +766,18 @@ static int tpacpi_resume_handler(struct platform_device *pdev)
729 return 0; 766 return 0;
730} 767}
731 768
769static void tpacpi_shutdown_handler(struct platform_device *pdev)
770{
771 struct ibm_struct *ibm, *itmp;
772
773 list_for_each_entry_safe(ibm, itmp,
774 &tpacpi_all_drivers,
775 all_drivers) {
776 if (ibm->shutdown)
777 (ibm->shutdown)();
778 }
779}
780
732static struct platform_driver tpacpi_pdriver = { 781static struct platform_driver tpacpi_pdriver = {
733 .driver = { 782 .driver = {
734 .name = TPACPI_DRVR_NAME, 783 .name = TPACPI_DRVR_NAME,
@@ -736,6 +785,7 @@ static struct platform_driver tpacpi_pdriver = {
736 }, 785 },
737 .suspend = tpacpi_suspend_handler, 786 .suspend = tpacpi_suspend_handler,
738 .resume = tpacpi_resume_handler, 787 .resume = tpacpi_resume_handler,
788 .shutdown = tpacpi_shutdown_handler,
739}; 789};
740 790
741static struct platform_driver tpacpi_hwmon_pdriver = { 791static struct platform_driver tpacpi_hwmon_pdriver = {
@@ -923,11 +973,27 @@ static int __init tpacpi_new_rfkill(const unsigned int id,
923 struct rfkill **rfk, 973 struct rfkill **rfk,
924 const enum rfkill_type rfktype, 974 const enum rfkill_type rfktype,
925 const char *name, 975 const char *name,
976 const bool set_default,
926 int (*toggle_radio)(void *, enum rfkill_state), 977 int (*toggle_radio)(void *, enum rfkill_state),
927 int (*get_state)(void *, enum rfkill_state *)) 978 int (*get_state)(void *, enum rfkill_state *))
928{ 979{
929 int res; 980 int res;
930 enum rfkill_state initial_state; 981 enum rfkill_state initial_state = RFKILL_STATE_SOFT_BLOCKED;
982
983 res = get_state(NULL, &initial_state);
984 if (res < 0) {
985 printk(TPACPI_ERR
986 "failed to read initial state for %s, error %d; "
987 "will turn radio off\n", name, res);
988 } else if (set_default) {
989 /* try to set the initial state as the default for the rfkill
990 * type, since we ask the firmware to preserve it across S5 in
991 * NVRAM */
992 rfkill_set_default(rfktype,
993 (initial_state == RFKILL_STATE_UNBLOCKED) ?
994 RFKILL_STATE_UNBLOCKED :
995 RFKILL_STATE_SOFT_BLOCKED);
996 }
931 997
932 *rfk = rfkill_allocate(&tpacpi_pdev->dev, rfktype); 998 *rfk = rfkill_allocate(&tpacpi_pdev->dev, rfktype);
933 if (!*rfk) { 999 if (!*rfk) {
@@ -939,9 +1005,7 @@ static int __init tpacpi_new_rfkill(const unsigned int id,
939 (*rfk)->name = name; 1005 (*rfk)->name = name;
940 (*rfk)->get_state = get_state; 1006 (*rfk)->get_state = get_state;
941 (*rfk)->toggle_radio = toggle_radio; 1007 (*rfk)->toggle_radio = toggle_radio;
942 1008 (*rfk)->state = initial_state;
943 if (!get_state(NULL, &initial_state))
944 (*rfk)->state = initial_state;
945 1009
946 res = rfkill_register(*rfk); 1010 res = rfkill_register(*rfk);
947 if (res < 0) { 1011 if (res < 0) {
@@ -1007,6 +1071,119 @@ static DRIVER_ATTR(version, S_IRUGO,
1007 1071
1008/* --------------------------------------------------------------------- */ 1072/* --------------------------------------------------------------------- */
1009 1073
1074#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
1075
1076static void tpacpi_send_radiosw_update(void);
1077
1078/* wlsw_emulstate ------------------------------------------------------ */
1079static ssize_t tpacpi_driver_wlsw_emulstate_show(struct device_driver *drv,
1080 char *buf)
1081{
1082 return snprintf(buf, PAGE_SIZE, "%d\n", !!tpacpi_wlsw_emulstate);
1083}
1084
1085static ssize_t tpacpi_driver_wlsw_emulstate_store(struct device_driver *drv,
1086 const char *buf, size_t count)
1087{
1088 unsigned long t;
1089
1090 if (parse_strtoul(buf, 1, &t))
1091 return -EINVAL;
1092
1093 if (tpacpi_wlsw_emulstate != t) {
1094 tpacpi_wlsw_emulstate = !!t;
1095 tpacpi_send_radiosw_update();
1096 } else
1097 tpacpi_wlsw_emulstate = !!t;
1098
1099 return count;
1100}
1101
1102static DRIVER_ATTR(wlsw_emulstate, S_IWUSR | S_IRUGO,
1103 tpacpi_driver_wlsw_emulstate_show,
1104 tpacpi_driver_wlsw_emulstate_store);
1105
1106/* bluetooth_emulstate ------------------------------------------------- */
1107static ssize_t tpacpi_driver_bluetooth_emulstate_show(
1108 struct device_driver *drv,
1109 char *buf)
1110{
1111 return snprintf(buf, PAGE_SIZE, "%d\n", !!tpacpi_bluetooth_emulstate);
1112}
1113
1114static ssize_t tpacpi_driver_bluetooth_emulstate_store(
1115 struct device_driver *drv,
1116 const char *buf, size_t count)
1117{
1118 unsigned long t;
1119
1120 if (parse_strtoul(buf, 1, &t))
1121 return -EINVAL;
1122
1123 tpacpi_bluetooth_emulstate = !!t;
1124
1125 return count;
1126}
1127
1128static DRIVER_ATTR(bluetooth_emulstate, S_IWUSR | S_IRUGO,
1129 tpacpi_driver_bluetooth_emulstate_show,
1130 tpacpi_driver_bluetooth_emulstate_store);
1131
1132/* wwan_emulstate ------------------------------------------------- */
1133static ssize_t tpacpi_driver_wwan_emulstate_show(
1134 struct device_driver *drv,
1135 char *buf)
1136{
1137 return snprintf(buf, PAGE_SIZE, "%d\n", !!tpacpi_wwan_emulstate);
1138}
1139
1140static ssize_t tpacpi_driver_wwan_emulstate_store(
1141 struct device_driver *drv,
1142 const char *buf, size_t count)
1143{
1144 unsigned long t;
1145
1146 if (parse_strtoul(buf, 1, &t))
1147 return -EINVAL;
1148
1149 tpacpi_wwan_emulstate = !!t;
1150
1151 return count;
1152}
1153
1154static DRIVER_ATTR(wwan_emulstate, S_IWUSR | S_IRUGO,
1155 tpacpi_driver_wwan_emulstate_show,
1156 tpacpi_driver_wwan_emulstate_store);
1157
1158/* uwb_emulstate ------------------------------------------------- */
1159static ssize_t tpacpi_driver_uwb_emulstate_show(
1160 struct device_driver *drv,
1161 char *buf)
1162{
1163 return snprintf(buf, PAGE_SIZE, "%d\n", !!tpacpi_uwb_emulstate);
1164}
1165
1166static ssize_t tpacpi_driver_uwb_emulstate_store(
1167 struct device_driver *drv,
1168 const char *buf, size_t count)
1169{
1170 unsigned long t;
1171
1172 if (parse_strtoul(buf, 1, &t))
1173 return -EINVAL;
1174
1175 tpacpi_uwb_emulstate = !!t;
1176
1177 return count;
1178}
1179
1180static DRIVER_ATTR(uwb_emulstate, S_IWUSR | S_IRUGO,
1181 tpacpi_driver_uwb_emulstate_show,
1182 tpacpi_driver_uwb_emulstate_store);
1183#endif
1184
1185/* --------------------------------------------------------------------- */
1186
1010static struct driver_attribute *tpacpi_driver_attributes[] = { 1187static struct driver_attribute *tpacpi_driver_attributes[] = {
1011 &driver_attr_debug_level, &driver_attr_version, 1188 &driver_attr_debug_level, &driver_attr_version,
1012 &driver_attr_interface_version, 1189 &driver_attr_interface_version,
@@ -1023,6 +1200,17 @@ static int __init tpacpi_create_driver_attributes(struct device_driver *drv)
1023 i++; 1200 i++;
1024 } 1201 }
1025 1202
1203#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
1204 if (!res && dbg_wlswemul)
1205 res = driver_create_file(drv, &driver_attr_wlsw_emulstate);
1206 if (!res && dbg_bluetoothemul)
1207 res = driver_create_file(drv, &driver_attr_bluetooth_emulstate);
1208 if (!res && dbg_wwanemul)
1209 res = driver_create_file(drv, &driver_attr_wwan_emulstate);
1210 if (!res && dbg_uwbemul)
1211 res = driver_create_file(drv, &driver_attr_uwb_emulstate);
1212#endif
1213
1026 return res; 1214 return res;
1027} 1215}
1028 1216
@@ -1032,6 +1220,13 @@ static void tpacpi_remove_driver_attributes(struct device_driver *drv)
1032 1220
1033 for (i = 0; i < ARRAY_SIZE(tpacpi_driver_attributes); i++) 1221 for (i = 0; i < ARRAY_SIZE(tpacpi_driver_attributes); i++)
1034 driver_remove_file(drv, tpacpi_driver_attributes[i]); 1222 driver_remove_file(drv, tpacpi_driver_attributes[i]);
1223
1224#ifdef THINKPAD_ACPI_DEBUGFACILITIES
1225 driver_remove_file(drv, &driver_attr_wlsw_emulstate);
1226 driver_remove_file(drv, &driver_attr_bluetooth_emulstate);
1227 driver_remove_file(drv, &driver_attr_wwan_emulstate);
1228 driver_remove_file(drv, &driver_attr_uwb_emulstate);
1229#endif
1035} 1230}
1036 1231
1037/**************************************************************************** 1232/****************************************************************************
@@ -1217,6 +1412,12 @@ static struct attribute_set *hotkey_dev_attributes;
1217 1412
1218static int hotkey_get_wlsw(int *status) 1413static int hotkey_get_wlsw(int *status)
1219{ 1414{
1415#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
1416 if (dbg_wlswemul) {
1417 *status = !!tpacpi_wlsw_emulstate;
1418 return 0;
1419 }
1420#endif
1220 if (!acpi_evalf(hkey_handle, status, "WLSW", "d")) 1421 if (!acpi_evalf(hkey_handle, status, "WLSW", "d"))
1221 return -EIO; 1422 return -EIO;
1222 return 0; 1423 return 0;
@@ -1679,7 +1880,7 @@ static ssize_t hotkey_mask_show(struct device *dev,
1679{ 1880{
1680 int res; 1881 int res;
1681 1882
1682 if (mutex_lock_interruptible(&hotkey_mutex)) 1883 if (mutex_lock_killable(&hotkey_mutex))
1683 return -ERESTARTSYS; 1884 return -ERESTARTSYS;
1684 res = hotkey_mask_get(); 1885 res = hotkey_mask_get();
1685 mutex_unlock(&hotkey_mutex); 1886 mutex_unlock(&hotkey_mutex);
@@ -1698,7 +1899,7 @@ static ssize_t hotkey_mask_store(struct device *dev,
1698 if (parse_strtoul(buf, 0xffffffffUL, &t)) 1899 if (parse_strtoul(buf, 0xffffffffUL, &t))
1699 return -EINVAL; 1900 return -EINVAL;
1700 1901
1701 if (mutex_lock_interruptible(&hotkey_mutex)) 1902 if (mutex_lock_killable(&hotkey_mutex))
1702 return -ERESTARTSYS; 1903 return -ERESTARTSYS;
1703 1904
1704 res = hotkey_mask_set(t); 1905 res = hotkey_mask_set(t);
@@ -1784,7 +1985,7 @@ static ssize_t hotkey_source_mask_store(struct device *dev,
1784 ((t & ~TPACPI_HKEY_NVRAM_KNOWN_MASK) != 0)) 1985 ((t & ~TPACPI_HKEY_NVRAM_KNOWN_MASK) != 0))
1785 return -EINVAL; 1986 return -EINVAL;
1786 1987
1787 if (mutex_lock_interruptible(&hotkey_mutex)) 1988 if (mutex_lock_killable(&hotkey_mutex))
1788 return -ERESTARTSYS; 1989 return -ERESTARTSYS;
1789 1990
1790 HOTKEY_CONFIG_CRITICAL_START 1991 HOTKEY_CONFIG_CRITICAL_START
@@ -1819,7 +2020,7 @@ static ssize_t hotkey_poll_freq_store(struct device *dev,
1819 if (parse_strtoul(buf, 25, &t)) 2020 if (parse_strtoul(buf, 25, &t))
1820 return -EINVAL; 2021 return -EINVAL;
1821 2022
1822 if (mutex_lock_interruptible(&hotkey_mutex)) 2023 if (mutex_lock_killable(&hotkey_mutex))
1823 return -ERESTARTSYS; 2024 return -ERESTARTSYS;
1824 2025
1825 hotkey_poll_freq = t; 2026 hotkey_poll_freq = t;
@@ -1959,6 +2160,7 @@ static struct attribute *hotkey_mask_attributes[] __initdata = {
1959 2160
1960static void bluetooth_update_rfk(void); 2161static void bluetooth_update_rfk(void);
1961static void wan_update_rfk(void); 2162static void wan_update_rfk(void);
2163static void uwb_update_rfk(void);
1962static void tpacpi_send_radiosw_update(void) 2164static void tpacpi_send_radiosw_update(void)
1963{ 2165{
1964 int wlsw; 2166 int wlsw;
@@ -1968,6 +2170,8 @@ static void tpacpi_send_radiosw_update(void)
1968 bluetooth_update_rfk(); 2170 bluetooth_update_rfk();
1969 if (tp_features.wan) 2171 if (tp_features.wan)
1970 wan_update_rfk(); 2172 wan_update_rfk();
2173 if (tp_features.uwb)
2174 uwb_update_rfk();
1971 2175
1972 if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&wlsw)) { 2176 if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&wlsw)) {
1973 mutex_lock(&tpacpi_inputdev_send_mutex); 2177 mutex_lock(&tpacpi_inputdev_send_mutex);
@@ -2223,6 +2427,13 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
2223 hotkey_source_mask, hotkey_poll_freq); 2427 hotkey_source_mask, hotkey_poll_freq);
2224#endif 2428#endif
2225 2429
2430#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
2431 if (dbg_wlswemul) {
2432 tp_features.hotkey_wlsw = 1;
2433 printk(TPACPI_INFO
2434 "radio switch emulation enabled\n");
2435 } else
2436#endif
2226 /* Not all thinkpads have a hardware radio switch */ 2437 /* Not all thinkpads have a hardware radio switch */
2227 if (acpi_evalf(hkey_handle, &status, "WLSW", "qd")) { 2438 if (acpi_evalf(hkey_handle, &status, "WLSW", "qd")) {
2228 tp_features.hotkey_wlsw = 1; 2439 tp_features.hotkey_wlsw = 1;
@@ -2362,13 +2573,154 @@ err_exit:
2362 return (res < 0)? res : 1; 2573 return (res < 0)? res : 1;
2363} 2574}
2364 2575
2576static bool hotkey_notify_hotkey(const u32 hkey,
2577 bool *send_acpi_ev,
2578 bool *ignore_acpi_ev)
2579{
2580 /* 0x1000-0x1FFF: key presses */
2581 unsigned int scancode = hkey & 0xfff;
2582 *send_acpi_ev = true;
2583 *ignore_acpi_ev = false;
2584
2585 if (scancode > 0 && scancode < 0x21) {
2586 scancode--;
2587 if (!(hotkey_source_mask & (1 << scancode))) {
2588 tpacpi_input_send_key(scancode);
2589 *send_acpi_ev = false;
2590 } else {
2591 *ignore_acpi_ev = true;
2592 }
2593 return true;
2594 }
2595 return false;
2596}
2597
2598static bool hotkey_notify_wakeup(const u32 hkey,
2599 bool *send_acpi_ev,
2600 bool *ignore_acpi_ev)
2601{
2602 /* 0x2000-0x2FFF: Wakeup reason */
2603 *send_acpi_ev = true;
2604 *ignore_acpi_ev = false;
2605
2606 switch (hkey) {
2607 case 0x2304: /* suspend, undock */
2608 case 0x2404: /* hibernation, undock */
2609 hotkey_wakeup_reason = TP_ACPI_WAKEUP_UNDOCK;
2610 *ignore_acpi_ev = true;
2611 break;
2612
2613 case 0x2305: /* suspend, bay eject */
2614 case 0x2405: /* hibernation, bay eject */
2615 hotkey_wakeup_reason = TP_ACPI_WAKEUP_BAYEJ;
2616 *ignore_acpi_ev = true;
2617 break;
2618
2619 case 0x2313: /* Battery on critical low level (S3) */
2620 case 0x2413: /* Battery on critical low level (S4) */
2621 printk(TPACPI_ALERT
2622 "EMERGENCY WAKEUP: battery almost empty\n");
2623 /* how to auto-heal: */
2624 /* 2313: woke up from S3, go to S4/S5 */
2625 /* 2413: woke up from S4, go to S5 */
2626 break;
2627
2628 default:
2629 return false;
2630 }
2631
2632 if (hotkey_wakeup_reason != TP_ACPI_WAKEUP_NONE) {
2633 printk(TPACPI_INFO
2634 "woke up due to a hot-unplug "
2635 "request...\n");
2636 hotkey_wakeup_reason_notify_change();
2637 }
2638 return true;
2639}
2640
2641static bool hotkey_notify_usrevent(const u32 hkey,
2642 bool *send_acpi_ev,
2643 bool *ignore_acpi_ev)
2644{
2645 /* 0x5000-0x5FFF: human interface helpers */
2646 *send_acpi_ev = true;
2647 *ignore_acpi_ev = false;
2648
2649 switch (hkey) {
2650 case 0x5010: /* Lenovo new BIOS: brightness changed */
2651 case 0x500b: /* X61t: tablet pen inserted into bay */
2652 case 0x500c: /* X61t: tablet pen removed from bay */
2653 return true;
2654
2655 case 0x5009: /* X41t-X61t: swivel up (tablet mode) */
2656 case 0x500a: /* X41t-X61t: swivel down (normal mode) */
2657 tpacpi_input_send_tabletsw();
2658 hotkey_tablet_mode_notify_change();
2659 *send_acpi_ev = false;
2660 return true;
2661
2662 case 0x5001:
2663 case 0x5002:
2664 /* LID switch events. Do not propagate */
2665 *ignore_acpi_ev = true;
2666 return true;
2667
2668 default:
2669 return false;
2670 }
2671}
2672
2673static bool hotkey_notify_thermal(const u32 hkey,
2674 bool *send_acpi_ev,
2675 bool *ignore_acpi_ev)
2676{
2677 /* 0x6000-0x6FFF: thermal alarms */
2678 *send_acpi_ev = true;
2679 *ignore_acpi_ev = false;
2680
2681 switch (hkey) {
2682 case 0x6011:
2683 printk(TPACPI_CRIT
2684 "THERMAL ALARM: battery is too hot!\n");
2685 /* recommended action: warn user through gui */
2686 return true;
2687 case 0x6012:
2688 printk(TPACPI_ALERT
2689 "THERMAL EMERGENCY: battery is extremely hot!\n");
2690 /* recommended action: immediate sleep/hibernate */
2691 return true;
2692 case 0x6021:
2693 printk(TPACPI_CRIT
2694 "THERMAL ALARM: "
2695 "a sensor reports something is too hot!\n");
2696 /* recommended action: warn user through gui, that */
2697 /* some internal component is too hot */
2698 return true;
2699 case 0x6022:
2700 printk(TPACPI_ALERT
2701 "THERMAL EMERGENCY: "
2702 "a sensor reports something is extremely hot!\n");
2703 /* recommended action: immediate sleep/hibernate */
2704 return true;
2705 case 0x6030:
2706 printk(TPACPI_INFO
2707 "EC reports that Thermal Table has changed\n");
2708 /* recommended action: do nothing, we don't have
2709 * Lenovo ATM information */
2710 return true;
2711 default:
2712 printk(TPACPI_ALERT
2713 "THERMAL ALERT: unknown thermal alarm received\n");
2714 return false;
2715 }
2716}
2717
2365static void hotkey_notify(struct ibm_struct *ibm, u32 event) 2718static void hotkey_notify(struct ibm_struct *ibm, u32 event)
2366{ 2719{
2367 u32 hkey; 2720 u32 hkey;
2368 unsigned int scancode; 2721 bool send_acpi_ev;
2369 int send_acpi_ev; 2722 bool ignore_acpi_ev;
2370 int ignore_acpi_ev; 2723 bool known_ev;
2371 int unk_ev;
2372 2724
2373 if (event != 0x80) { 2725 if (event != 0x80) {
2374 printk(TPACPI_ERR 2726 printk(TPACPI_ERR
@@ -2376,7 +2728,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
2376 /* forward it to userspace, maybe it knows how to handle it */ 2728 /* forward it to userspace, maybe it knows how to handle it */
2377 acpi_bus_generate_netlink_event( 2729 acpi_bus_generate_netlink_event(
2378 ibm->acpi->device->pnp.device_class, 2730 ibm->acpi->device->pnp.device_class,
2379 ibm->acpi->device->dev.bus_id, 2731 dev_name(&ibm->acpi->device->dev),
2380 event, 0); 2732 event, 0);
2381 return; 2733 return;
2382 } 2734 }
@@ -2392,107 +2744,72 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
2392 return; 2744 return;
2393 } 2745 }
2394 2746
2395 send_acpi_ev = 1; 2747 send_acpi_ev = true;
2396 ignore_acpi_ev = 0; 2748 ignore_acpi_ev = false;
2397 unk_ev = 0;
2398 2749
2399 switch (hkey >> 12) { 2750 switch (hkey >> 12) {
2400 case 1: 2751 case 1:
2401 /* 0x1000-0x1FFF: key presses */ 2752 /* 0x1000-0x1FFF: key presses */
2402 scancode = hkey & 0xfff; 2753 known_ev = hotkey_notify_hotkey(hkey, &send_acpi_ev,
2403 if (scancode > 0 && scancode < 0x21) { 2754 &ignore_acpi_ev);
2404 scancode--;
2405 if (!(hotkey_source_mask & (1 << scancode))) {
2406 tpacpi_input_send_key(scancode);
2407 send_acpi_ev = 0;
2408 } else {
2409 ignore_acpi_ev = 1;
2410 }
2411 } else {
2412 unk_ev = 1;
2413 }
2414 break; 2755 break;
2415 case 2: 2756 case 2:
2416 /* Wakeup reason */ 2757 /* 0x2000-0x2FFF: Wakeup reason */
2417 switch (hkey) { 2758 known_ev = hotkey_notify_wakeup(hkey, &send_acpi_ev,
2418 case 0x2304: /* suspend, undock */ 2759 &ignore_acpi_ev);
2419 case 0x2404: /* hibernation, undock */
2420 hotkey_wakeup_reason = TP_ACPI_WAKEUP_UNDOCK;
2421 ignore_acpi_ev = 1;
2422 break;
2423 case 0x2305: /* suspend, bay eject */
2424 case 0x2405: /* hibernation, bay eject */
2425 hotkey_wakeup_reason = TP_ACPI_WAKEUP_BAYEJ;
2426 ignore_acpi_ev = 1;
2427 break;
2428 default:
2429 unk_ev = 1;
2430 }
2431 if (hotkey_wakeup_reason != TP_ACPI_WAKEUP_NONE) {
2432 printk(TPACPI_INFO
2433 "woke up due to a hot-unplug "
2434 "request...\n");
2435 hotkey_wakeup_reason_notify_change();
2436 }
2437 break; 2760 break;
2438 case 3: 2761 case 3:
2439 /* bay-related wakeups */ 2762 /* 0x3000-0x3FFF: bay-related wakeups */
2440 if (hkey == 0x3003) { 2763 if (hkey == 0x3003) {
2441 hotkey_autosleep_ack = 1; 2764 hotkey_autosleep_ack = 1;
2442 printk(TPACPI_INFO 2765 printk(TPACPI_INFO
2443 "bay ejected\n"); 2766 "bay ejected\n");
2444 hotkey_wakeup_hotunplug_complete_notify_change(); 2767 hotkey_wakeup_hotunplug_complete_notify_change();
2768 known_ev = true;
2445 } else { 2769 } else {
2446 unk_ev = 1; 2770 known_ev = false;
2447 } 2771 }
2448 break; 2772 break;
2449 case 4: 2773 case 4:
2450 /* dock-related wakeups */ 2774 /* 0x4000-0x4FFF: dock-related wakeups */
2451 if (hkey == 0x4003) { 2775 if (hkey == 0x4003) {
2452 hotkey_autosleep_ack = 1; 2776 hotkey_autosleep_ack = 1;
2453 printk(TPACPI_INFO 2777 printk(TPACPI_INFO
2454 "undocked\n"); 2778 "undocked\n");
2455 hotkey_wakeup_hotunplug_complete_notify_change(); 2779 hotkey_wakeup_hotunplug_complete_notify_change();
2780 known_ev = true;
2456 } else { 2781 } else {
2457 unk_ev = 1; 2782 known_ev = false;
2458 } 2783 }
2459 break; 2784 break;
2460 case 5: 2785 case 5:
2461 /* 0x5000-0x5FFF: human interface helpers */ 2786 /* 0x5000-0x5FFF: human interface helpers */
2462 switch (hkey) { 2787 known_ev = hotkey_notify_usrevent(hkey, &send_acpi_ev,
2463 case 0x5010: /* Lenovo new BIOS: brightness changed */ 2788 &ignore_acpi_ev);
2464 case 0x500b: /* X61t: tablet pen inserted into bay */ 2789 break;
2465 case 0x500c: /* X61t: tablet pen removed from bay */ 2790 case 6:
2466 break; 2791 /* 0x6000-0x6FFF: thermal alarms */
2467 case 0x5009: /* X41t-X61t: swivel up (tablet mode) */ 2792 known_ev = hotkey_notify_thermal(hkey, &send_acpi_ev,
2468 case 0x500a: /* X41t-X61t: swivel down (normal mode) */ 2793 &ignore_acpi_ev);
2469 tpacpi_input_send_tabletsw();
2470 hotkey_tablet_mode_notify_change();
2471 send_acpi_ev = 0;
2472 break;
2473 case 0x5001:
2474 case 0x5002:
2475 /* LID switch events. Do not propagate */
2476 ignore_acpi_ev = 1;
2477 break;
2478 default:
2479 unk_ev = 1;
2480 }
2481 break; 2794 break;
2482 case 7: 2795 case 7:
2483 /* 0x7000-0x7FFF: misc */ 2796 /* 0x7000-0x7FFF: misc */
2484 if (tp_features.hotkey_wlsw && hkey == 0x7000) { 2797 if (tp_features.hotkey_wlsw && hkey == 0x7000) {
2485 tpacpi_send_radiosw_update(); 2798 tpacpi_send_radiosw_update();
2486 send_acpi_ev = 0; 2799 send_acpi_ev = 0;
2800 known_ev = true;
2487 break; 2801 break;
2488 } 2802 }
2489 /* fallthrough to default */ 2803 /* fallthrough to default */
2490 default: 2804 default:
2491 unk_ev = 1; 2805 known_ev = false;
2492 } 2806 }
2493 if (unk_ev) { 2807 if (!known_ev) {
2494 printk(TPACPI_NOTICE 2808 printk(TPACPI_NOTICE
2495 "unhandled HKEY event 0x%04x\n", hkey); 2809 "unhandled HKEY event 0x%04x\n", hkey);
2810 printk(TPACPI_NOTICE
2811 "please report the conditions when this "
2812 "event happened to %s\n", TPACPI_MAIL);
2496 } 2813 }
2497 2814
2498 /* Legacy events */ 2815 /* Legacy events */
@@ -2506,7 +2823,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
2506 if (!ignore_acpi_ev && send_acpi_ev) { 2823 if (!ignore_acpi_ev && send_acpi_ev) {
2507 acpi_bus_generate_netlink_event( 2824 acpi_bus_generate_netlink_event(
2508 ibm->acpi->device->pnp.device_class, 2825 ibm->acpi->device->pnp.device_class,
2509 ibm->acpi->device->dev.bus_id, 2826 dev_name(&ibm->acpi->device->dev),
2510 event, hkey); 2827 event, hkey);
2511 } 2828 }
2512 } 2829 }
@@ -2545,7 +2862,7 @@ static int hotkey_read(char *p)
2545 return len; 2862 return len;
2546 } 2863 }
2547 2864
2548 if (mutex_lock_interruptible(&hotkey_mutex)) 2865 if (mutex_lock_killable(&hotkey_mutex))
2549 return -ERESTARTSYS; 2866 return -ERESTARTSYS;
2550 res = hotkey_status_get(&status); 2867 res = hotkey_status_get(&status);
2551 if (!res) 2868 if (!res)
@@ -2576,7 +2893,7 @@ static int hotkey_write(char *buf)
2576 if (!tp_features.hotkey) 2893 if (!tp_features.hotkey)
2577 return -ENODEV; 2894 return -ENODEV;
2578 2895
2579 if (mutex_lock_interruptible(&hotkey_mutex)) 2896 if (mutex_lock_killable(&hotkey_mutex))
2580 return -ERESTARTSYS; 2897 return -ERESTARTSYS;
2581 2898
2582 status = -1; 2899 status = -1;
@@ -2641,11 +2958,28 @@ enum {
2641 /* ACPI GBDC/SBDC bits */ 2958 /* ACPI GBDC/SBDC bits */
2642 TP_ACPI_BLUETOOTH_HWPRESENT = 0x01, /* Bluetooth hw available */ 2959 TP_ACPI_BLUETOOTH_HWPRESENT = 0x01, /* Bluetooth hw available */
2643 TP_ACPI_BLUETOOTH_RADIOSSW = 0x02, /* Bluetooth radio enabled */ 2960 TP_ACPI_BLUETOOTH_RADIOSSW = 0x02, /* Bluetooth radio enabled */
2644 TP_ACPI_BLUETOOTH_UNK = 0x04, /* unknown function */ 2961 TP_ACPI_BLUETOOTH_RESUMECTRL = 0x04, /* Bluetooth state at resume:
2962 off / last state */
2963};
2964
2965enum {
2966 /* ACPI \BLTH commands */
2967 TP_ACPI_BLTH_GET_ULTRAPORT_ID = 0x00, /* Get Ultraport BT ID */
2968 TP_ACPI_BLTH_GET_PWR_ON_RESUME = 0x01, /* Get power-on-resume state */
2969 TP_ACPI_BLTH_PWR_ON_ON_RESUME = 0x02, /* Resume powered on */
2970 TP_ACPI_BLTH_PWR_OFF_ON_RESUME = 0x03, /* Resume powered off */
2971 TP_ACPI_BLTH_SAVE_STATE = 0x05, /* Save state for S4/S5 */
2645}; 2972};
2646 2973
2647static struct rfkill *tpacpi_bluetooth_rfkill; 2974static struct rfkill *tpacpi_bluetooth_rfkill;
2648 2975
2976static void bluetooth_suspend(pm_message_t state)
2977{
2978 /* Try to make sure radio will resume powered off */
2979 acpi_evalf(NULL, NULL, "\\BLTH", "vd",
2980 TP_ACPI_BLTH_PWR_OFF_ON_RESUME);
2981}
2982
2649static int bluetooth_get_radiosw(void) 2983static int bluetooth_get_radiosw(void)
2650{ 2984{
2651 int status; 2985 int status;
@@ -2657,6 +2991,12 @@ static int bluetooth_get_radiosw(void)
2657 if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&status) && !status) 2991 if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&status) && !status)
2658 return RFKILL_STATE_HARD_BLOCKED; 2992 return RFKILL_STATE_HARD_BLOCKED;
2659 2993
2994#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
2995 if (dbg_bluetoothemul)
2996 return (tpacpi_bluetooth_emulstate) ?
2997 RFKILL_STATE_UNBLOCKED : RFKILL_STATE_SOFT_BLOCKED;
2998#endif
2999
2660 if (!acpi_evalf(hkey_handle, &status, "GBDC", "d")) 3000 if (!acpi_evalf(hkey_handle, &status, "GBDC", "d"))
2661 return -EIO; 3001 return -EIO;
2662 3002
@@ -2690,12 +3030,20 @@ static int bluetooth_set_radiosw(int radio_on, int update_rfk)
2690 && radio_on) 3030 && radio_on)
2691 return -EPERM; 3031 return -EPERM;
2692 3032
2693 if (!acpi_evalf(hkey_handle, &status, "GBDC", "d")) 3033#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
2694 return -EIO; 3034 if (dbg_bluetoothemul) {
3035 tpacpi_bluetooth_emulstate = !!radio_on;
3036 if (update_rfk)
3037 bluetooth_update_rfk();
3038 return 0;
3039 }
3040#endif
3041
3042 /* We make sure to keep TP_ACPI_BLUETOOTH_RESUMECTRL off */
2695 if (radio_on) 3043 if (radio_on)
2696 status |= TP_ACPI_BLUETOOTH_RADIOSSW; 3044 status = TP_ACPI_BLUETOOTH_RADIOSSW;
2697 else 3045 else
2698 status &= ~TP_ACPI_BLUETOOTH_RADIOSSW; 3046 status = 0;
2699 if (!acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status)) 3047 if (!acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status))
2700 return -EIO; 3048 return -EIO;
2701 3049
@@ -2766,8 +3114,19 @@ static int tpacpi_bluetooth_rfk_set(void *data, enum rfkill_state state)
2766 return bluetooth_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0); 3114 return bluetooth_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0);
2767} 3115}
2768 3116
3117static void bluetooth_shutdown(void)
3118{
3119 /* Order firmware to save current state to NVRAM */
3120 if (!acpi_evalf(NULL, NULL, "\\BLTH", "vd",
3121 TP_ACPI_BLTH_SAVE_STATE))
3122 printk(TPACPI_NOTICE
3123 "failed to save bluetooth state to NVRAM\n");
3124}
3125
2769static void bluetooth_exit(void) 3126static void bluetooth_exit(void)
2770{ 3127{
3128 bluetooth_shutdown();
3129
2771 if (tpacpi_bluetooth_rfkill) 3130 if (tpacpi_bluetooth_rfkill)
2772 rfkill_unregister(tpacpi_bluetooth_rfkill); 3131 rfkill_unregister(tpacpi_bluetooth_rfkill);
2773 3132
@@ -2793,6 +3152,13 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm)
2793 str_supported(tp_features.bluetooth), 3152 str_supported(tp_features.bluetooth),
2794 status); 3153 status);
2795 3154
3155#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
3156 if (dbg_bluetoothemul) {
3157 tp_features.bluetooth = 1;
3158 printk(TPACPI_INFO
3159 "bluetooth switch emulation enabled\n");
3160 } else
3161#endif
2796 if (tp_features.bluetooth && 3162 if (tp_features.bluetooth &&
2797 !(status & TP_ACPI_BLUETOOTH_HWPRESENT)) { 3163 !(status & TP_ACPI_BLUETOOTH_HWPRESENT)) {
2798 /* no bluetooth hardware present in system */ 3164 /* no bluetooth hardware present in system */
@@ -2813,6 +3179,7 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm)
2813 &tpacpi_bluetooth_rfkill, 3179 &tpacpi_bluetooth_rfkill,
2814 RFKILL_TYPE_BLUETOOTH, 3180 RFKILL_TYPE_BLUETOOTH,
2815 "tpacpi_bluetooth_sw", 3181 "tpacpi_bluetooth_sw",
3182 true,
2816 tpacpi_bluetooth_rfk_set, 3183 tpacpi_bluetooth_rfk_set,
2817 tpacpi_bluetooth_rfk_get); 3184 tpacpi_bluetooth_rfk_get);
2818 if (res) { 3185 if (res) {
@@ -2865,6 +3232,8 @@ static struct ibm_struct bluetooth_driver_data = {
2865 .read = bluetooth_read, 3232 .read = bluetooth_read,
2866 .write = bluetooth_write, 3233 .write = bluetooth_write,
2867 .exit = bluetooth_exit, 3234 .exit = bluetooth_exit,
3235 .suspend = bluetooth_suspend,
3236 .shutdown = bluetooth_shutdown,
2868}; 3237};
2869 3238
2870/************************************************************************* 3239/*************************************************************************
@@ -2875,11 +3244,19 @@ enum {
2875 /* ACPI GWAN/SWAN bits */ 3244 /* ACPI GWAN/SWAN bits */
2876 TP_ACPI_WANCARD_HWPRESENT = 0x01, /* Wan hw available */ 3245 TP_ACPI_WANCARD_HWPRESENT = 0x01, /* Wan hw available */
2877 TP_ACPI_WANCARD_RADIOSSW = 0x02, /* Wan radio enabled */ 3246 TP_ACPI_WANCARD_RADIOSSW = 0x02, /* Wan radio enabled */
2878 TP_ACPI_WANCARD_UNK = 0x04, /* unknown function */ 3247 TP_ACPI_WANCARD_RESUMECTRL = 0x04, /* Wan state at resume:
3248 off / last state */
2879}; 3249};
2880 3250
2881static struct rfkill *tpacpi_wan_rfkill; 3251static struct rfkill *tpacpi_wan_rfkill;
2882 3252
3253static void wan_suspend(pm_message_t state)
3254{
3255 /* Try to make sure radio will resume powered off */
3256 acpi_evalf(NULL, NULL, "\\WGSV", "qvd",
3257 TP_ACPI_WGSV_PWR_OFF_ON_RESUME);
3258}
3259
2883static int wan_get_radiosw(void) 3260static int wan_get_radiosw(void)
2884{ 3261{
2885 int status; 3262 int status;
@@ -2891,6 +3268,12 @@ static int wan_get_radiosw(void)
2891 if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&status) && !status) 3268 if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&status) && !status)
2892 return RFKILL_STATE_HARD_BLOCKED; 3269 return RFKILL_STATE_HARD_BLOCKED;
2893 3270
3271#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
3272 if (dbg_wwanemul)
3273 return (tpacpi_wwan_emulstate) ?
3274 RFKILL_STATE_UNBLOCKED : RFKILL_STATE_SOFT_BLOCKED;
3275#endif
3276
2894 if (!acpi_evalf(hkey_handle, &status, "GWAN", "d")) 3277 if (!acpi_evalf(hkey_handle, &status, "GWAN", "d"))
2895 return -EIO; 3278 return -EIO;
2896 3279
@@ -2924,12 +3307,20 @@ static int wan_set_radiosw(int radio_on, int update_rfk)
2924 && radio_on) 3307 && radio_on)
2925 return -EPERM; 3308 return -EPERM;
2926 3309
2927 if (!acpi_evalf(hkey_handle, &status, "GWAN", "d")) 3310#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
2928 return -EIO; 3311 if (dbg_wwanemul) {
3312 tpacpi_wwan_emulstate = !!radio_on;
3313 if (update_rfk)
3314 wan_update_rfk();
3315 return 0;
3316 }
3317#endif
3318
3319 /* We make sure to keep TP_ACPI_WANCARD_RESUMECTRL off */
2929 if (radio_on) 3320 if (radio_on)
2930 status |= TP_ACPI_WANCARD_RADIOSSW; 3321 status = TP_ACPI_WANCARD_RADIOSSW;
2931 else 3322 else
2932 status &= ~TP_ACPI_WANCARD_RADIOSSW; 3323 status = 0;
2933 if (!acpi_evalf(hkey_handle, NULL, "SWAN", "vd", status)) 3324 if (!acpi_evalf(hkey_handle, NULL, "SWAN", "vd", status))
2934 return -EIO; 3325 return -EIO;
2935 3326
@@ -3000,8 +3391,19 @@ static int tpacpi_wan_rfk_set(void *data, enum rfkill_state state)
3000 return wan_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0); 3391 return wan_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0);
3001} 3392}
3002 3393
3394static void wan_shutdown(void)
3395{
3396 /* Order firmware to save current state to NVRAM */
3397 if (!acpi_evalf(NULL, NULL, "\\WGSV", "vd",
3398 TP_ACPI_WGSV_SAVE_STATE))
3399 printk(TPACPI_NOTICE
3400 "failed to save WWAN state to NVRAM\n");
3401}
3402
3003static void wan_exit(void) 3403static void wan_exit(void)
3004{ 3404{
3405 wan_shutdown();
3406
3005 if (tpacpi_wan_rfkill) 3407 if (tpacpi_wan_rfkill)
3006 rfkill_unregister(tpacpi_wan_rfkill); 3408 rfkill_unregister(tpacpi_wan_rfkill);
3007 3409
@@ -3025,6 +3427,13 @@ static int __init wan_init(struct ibm_init_struct *iibm)
3025 str_supported(tp_features.wan), 3427 str_supported(tp_features.wan),
3026 status); 3428 status);
3027 3429
3430#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
3431 if (dbg_wwanemul) {
3432 tp_features.wan = 1;
3433 printk(TPACPI_INFO
3434 "wwan switch emulation enabled\n");
3435 } else
3436#endif
3028 if (tp_features.wan && 3437 if (tp_features.wan &&
3029 !(status & TP_ACPI_WANCARD_HWPRESENT)) { 3438 !(status & TP_ACPI_WANCARD_HWPRESENT)) {
3030 /* no wan hardware present in system */ 3439 /* no wan hardware present in system */
@@ -3045,6 +3454,7 @@ static int __init wan_init(struct ibm_init_struct *iibm)
3045 &tpacpi_wan_rfkill, 3454 &tpacpi_wan_rfkill,
3046 RFKILL_TYPE_WWAN, 3455 RFKILL_TYPE_WWAN,
3047 "tpacpi_wwan_sw", 3456 "tpacpi_wwan_sw",
3457 true,
3048 tpacpi_wan_rfk_set, 3458 tpacpi_wan_rfk_set,
3049 tpacpi_wan_rfk_get); 3459 tpacpi_wan_rfk_get);
3050 if (res) { 3460 if (res) {
@@ -3097,6 +3507,164 @@ static struct ibm_struct wan_driver_data = {
3097 .read = wan_read, 3507 .read = wan_read,
3098 .write = wan_write, 3508 .write = wan_write,
3099 .exit = wan_exit, 3509 .exit = wan_exit,
3510 .suspend = wan_suspend,
3511 .shutdown = wan_shutdown,
3512};
3513
3514/*************************************************************************
3515 * UWB subdriver
3516 */
3517
3518enum {
3519 /* ACPI GUWB/SUWB bits */
3520 TP_ACPI_UWB_HWPRESENT = 0x01, /* UWB hw available */
3521 TP_ACPI_UWB_RADIOSSW = 0x02, /* UWB radio enabled */
3522};
3523
3524static struct rfkill *tpacpi_uwb_rfkill;
3525
3526static int uwb_get_radiosw(void)
3527{
3528 int status;
3529
3530 if (!tp_features.uwb)
3531 return -ENODEV;
3532
3533 /* WLSW overrides UWB in firmware/hardware, reflect that */
3534 if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&status) && !status)
3535 return RFKILL_STATE_HARD_BLOCKED;
3536
3537#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
3538 if (dbg_uwbemul)
3539 return (tpacpi_uwb_emulstate) ?
3540 RFKILL_STATE_UNBLOCKED : RFKILL_STATE_SOFT_BLOCKED;
3541#endif
3542
3543 if (!acpi_evalf(hkey_handle, &status, "GUWB", "d"))
3544 return -EIO;
3545
3546 return ((status & TP_ACPI_UWB_RADIOSSW) != 0) ?
3547 RFKILL_STATE_UNBLOCKED : RFKILL_STATE_SOFT_BLOCKED;
3548}
3549
3550static void uwb_update_rfk(void)
3551{
3552 int status;
3553
3554 if (!tpacpi_uwb_rfkill)
3555 return;
3556
3557 status = uwb_get_radiosw();
3558 if (status < 0)
3559 return;
3560 rfkill_force_state(tpacpi_uwb_rfkill, status);
3561}
3562
3563static int uwb_set_radiosw(int radio_on, int update_rfk)
3564{
3565 int status;
3566
3567 if (!tp_features.uwb)
3568 return -ENODEV;
3569
3570 /* WLSW overrides UWB in firmware/hardware, but there is no
3571 * reason to risk weird behaviour. */
3572 if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&status) && !status
3573 && radio_on)
3574 return -EPERM;
3575
3576#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
3577 if (dbg_uwbemul) {
3578 tpacpi_uwb_emulstate = !!radio_on;
3579 if (update_rfk)
3580 uwb_update_rfk();
3581 return 0;
3582 }
3583#endif
3584
3585 status = (radio_on) ? TP_ACPI_UWB_RADIOSSW : 0;
3586 if (!acpi_evalf(hkey_handle, NULL, "SUWB", "vd", status))
3587 return -EIO;
3588
3589 if (update_rfk)
3590 uwb_update_rfk();
3591
3592 return 0;
3593}
3594
3595/* --------------------------------------------------------------------- */
3596
3597static int tpacpi_uwb_rfk_get(void *data, enum rfkill_state *state)
3598{
3599 int uwbs = uwb_get_radiosw();
3600
3601 if (uwbs < 0)
3602 return uwbs;
3603
3604 *state = uwbs;
3605 return 0;
3606}
3607
3608static int tpacpi_uwb_rfk_set(void *data, enum rfkill_state state)
3609{
3610 return uwb_set_radiosw((state == RFKILL_STATE_UNBLOCKED), 0);
3611}
3612
3613static void uwb_exit(void)
3614{
3615 if (tpacpi_uwb_rfkill)
3616 rfkill_unregister(tpacpi_uwb_rfkill);
3617}
3618
3619static int __init uwb_init(struct ibm_init_struct *iibm)
3620{
3621 int res;
3622 int status = 0;
3623
3624 vdbg_printk(TPACPI_DBG_INIT, "initializing uwb subdriver\n");
3625
3626 TPACPI_ACPIHANDLE_INIT(hkey);
3627
3628 tp_features.uwb = hkey_handle &&
3629 acpi_evalf(hkey_handle, &status, "GUWB", "qd");
3630
3631 vdbg_printk(TPACPI_DBG_INIT, "uwb is %s, status 0x%02x\n",
3632 str_supported(tp_features.uwb),
3633 status);
3634
3635#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
3636 if (dbg_uwbemul) {
3637 tp_features.uwb = 1;
3638 printk(TPACPI_INFO
3639 "uwb switch emulation enabled\n");
3640 } else
3641#endif
3642 if (tp_features.uwb &&
3643 !(status & TP_ACPI_UWB_HWPRESENT)) {
3644 /* no uwb hardware present in system */
3645 tp_features.uwb = 0;
3646 dbg_printk(TPACPI_DBG_INIT,
3647 "uwb hardware not installed\n");
3648 }
3649
3650 if (!tp_features.uwb)
3651 return 1;
3652
3653 res = tpacpi_new_rfkill(TPACPI_RFK_UWB_SW_ID,
3654 &tpacpi_uwb_rfkill,
3655 RFKILL_TYPE_UWB,
3656 "tpacpi_uwb_sw",
3657 false,
3658 tpacpi_uwb_rfk_set,
3659 tpacpi_uwb_rfk_get);
3660
3661 return res;
3662}
3663
3664static struct ibm_struct uwb_driver_data = {
3665 .name = "uwb",
3666 .exit = uwb_exit,
3667 .flags.experimental = 1,
3100}; 3668};
3101 3669
3102/************************************************************************* 3670/*************************************************************************
@@ -3725,7 +4293,7 @@ static void dock_notify(struct ibm_struct *ibm, u32 event)
3725 } 4293 }
3726 acpi_bus_generate_proc_event(ibm->acpi->device, event, data); 4294 acpi_bus_generate_proc_event(ibm->acpi->device, event, data);
3727 acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class, 4295 acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
3728 ibm->acpi->device->dev.bus_id, 4296 dev_name(&ibm->acpi->device->dev),
3729 event, data); 4297 event, data);
3730} 4298}
3731 4299
@@ -3827,7 +4395,7 @@ static void bay_notify(struct ibm_struct *ibm, u32 event)
3827{ 4395{
3828 acpi_bus_generate_proc_event(ibm->acpi->device, event, 0); 4396 acpi_bus_generate_proc_event(ibm->acpi->device, event, 0);
3829 acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class, 4397 acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
3830 ibm->acpi->device->dev.bus_id, 4398 dev_name(&ibm->acpi->device->dev),
3831 event, 0); 4399 event, 0);
3832} 4400}
3833 4401
@@ -4851,7 +5419,7 @@ static int brightness_set(int value)
4851 value < 0) 5419 value < 0)
4852 return -EINVAL; 5420 return -EINVAL;
4853 5421
4854 res = mutex_lock_interruptible(&brightness_mutex); 5422 res = mutex_lock_killable(&brightness_mutex);
4855 if (res < 0) 5423 if (res < 0)
4856 return res; 5424 return res;
4857 5425
@@ -5335,6 +5903,60 @@ TPACPI_HANDLE(sfan, ec, "SFAN", /* 570 */
5335 ); /* all others */ 5903 ); /* all others */
5336 5904
5337/* 5905/*
5906 * Unitialized HFSP quirk: ACPI DSDT and EC fail to initialize the
5907 * HFSP register at boot, so it contains 0x07 but the Thinkpad could
5908 * be in auto mode (0x80).
5909 *
5910 * This is corrected by any write to HFSP either by the driver, or
5911 * by the firmware.
5912 *
5913 * We assume 0x07 really means auto mode while this quirk is active,
5914 * as this is far more likely than the ThinkPad being in level 7,
5915 * which is only used by the firmware during thermal emergencies.
5916 */
5917
5918static void fan_quirk1_detect(void)
5919{
5920 /* In some ThinkPads, neither the EC nor the ACPI
5921 * DSDT initialize the HFSP register, and it ends up
5922 * being initially set to 0x07 when it *could* be
5923 * either 0x07 or 0x80.
5924 *
5925 * Enable for TP-1Y (T43), TP-78 (R51e),
5926 * TP-76 (R52), TP-70 (T43, R52), which are known
5927 * to be buggy. */
5928 if (fan_control_initial_status == 0x07) {
5929 switch (thinkpad_id.ec_model) {
5930 case 0x5931: /* TP-1Y */
5931 case 0x3837: /* TP-78 */
5932 case 0x3637: /* TP-76 */
5933 case 0x3037: /* TP-70 */
5934 printk(TPACPI_NOTICE
5935 "fan_init: initial fan status is unknown, "
5936 "assuming it is in auto mode\n");
5937 tp_features.fan_ctrl_status_undef = 1;
5938 ;;
5939 }
5940 }
5941}
5942
5943static void fan_quirk1_handle(u8 *fan_status)
5944{
5945 if (unlikely(tp_features.fan_ctrl_status_undef)) {
5946 if (*fan_status != fan_control_initial_status) {
5947 /* something changed the HFSP regisnter since
5948 * driver init time, so it is not undefined
5949 * anymore */
5950 tp_features.fan_ctrl_status_undef = 0;
5951 } else {
5952 /* Return most likely status. In fact, it
5953 * might be the only possible status */
5954 *fan_status = TP_EC_FAN_AUTO;
5955 }
5956 }
5957}
5958
5959/*
5338 * Call with fan_mutex held 5960 * Call with fan_mutex held
5339 */ 5961 */
5340static void fan_update_desired_level(u8 status) 5962static void fan_update_desired_level(u8 status)
@@ -5372,8 +5994,10 @@ static int fan_get_status(u8 *status)
5372 if (unlikely(!acpi_ec_read(fan_status_offset, &s))) 5994 if (unlikely(!acpi_ec_read(fan_status_offset, &s)))
5373 return -EIO; 5995 return -EIO;
5374 5996
5375 if (likely(status)) 5997 if (likely(status)) {
5376 *status = s; 5998 *status = s;
5999 fan_quirk1_handle(status);
6000 }
5377 6001
5378 break; 6002 break;
5379 6003
@@ -5389,7 +6013,7 @@ static int fan_get_status_safe(u8 *status)
5389 int rc; 6013 int rc;
5390 u8 s; 6014 u8 s;
5391 6015
5392 if (mutex_lock_interruptible(&fan_mutex)) 6016 if (mutex_lock_killable(&fan_mutex))
5393 return -ERESTARTSYS; 6017 return -ERESTARTSYS;
5394 rc = fan_get_status(&s); 6018 rc = fan_get_status(&s);
5395 if (!rc) 6019 if (!rc)
@@ -5472,7 +6096,7 @@ static int fan_set_level_safe(int level)
5472 if (!fan_control_allowed) 6096 if (!fan_control_allowed)
5473 return -EPERM; 6097 return -EPERM;
5474 6098
5475 if (mutex_lock_interruptible(&fan_mutex)) 6099 if (mutex_lock_killable(&fan_mutex))
5476 return -ERESTARTSYS; 6100 return -ERESTARTSYS;
5477 6101
5478 if (level == TPACPI_FAN_LAST_LEVEL) 6102 if (level == TPACPI_FAN_LAST_LEVEL)
@@ -5494,7 +6118,7 @@ static int fan_set_enable(void)
5494 if (!fan_control_allowed) 6118 if (!fan_control_allowed)
5495 return -EPERM; 6119 return -EPERM;
5496 6120
5497 if (mutex_lock_interruptible(&fan_mutex)) 6121 if (mutex_lock_killable(&fan_mutex))
5498 return -ERESTARTSYS; 6122 return -ERESTARTSYS;
5499 6123
5500 switch (fan_control_access_mode) { 6124 switch (fan_control_access_mode) {
@@ -5549,7 +6173,7 @@ static int fan_set_disable(void)
5549 if (!fan_control_allowed) 6173 if (!fan_control_allowed)
5550 return -EPERM; 6174 return -EPERM;
5551 6175
5552 if (mutex_lock_interruptible(&fan_mutex)) 6176 if (mutex_lock_killable(&fan_mutex))
5553 return -ERESTARTSYS; 6177 return -ERESTARTSYS;
5554 6178
5555 rc = 0; 6179 rc = 0;
@@ -5587,7 +6211,7 @@ static int fan_set_speed(int speed)
5587 if (!fan_control_allowed) 6211 if (!fan_control_allowed)
5588 return -EPERM; 6212 return -EPERM;
5589 6213
5590 if (mutex_lock_interruptible(&fan_mutex)) 6214 if (mutex_lock_killable(&fan_mutex))
5591 return -ERESTARTSYS; 6215 return -ERESTARTSYS;
5592 6216
5593 rc = 0; 6217 rc = 0;
@@ -5683,16 +6307,6 @@ static ssize_t fan_pwm1_enable_show(struct device *dev,
5683 if (res) 6307 if (res)
5684 return res; 6308 return res;
5685 6309
5686 if (unlikely(tp_features.fan_ctrl_status_undef)) {
5687 if (status != fan_control_initial_status) {
5688 tp_features.fan_ctrl_status_undef = 0;
5689 } else {
5690 /* Return most likely status. In fact, it
5691 * might be the only possible status */
5692 status = TP_EC_FAN_AUTO;
5693 }
5694 }
5695
5696 if (status & TP_EC_FAN_FULLSPEED) { 6310 if (status & TP_EC_FAN_FULLSPEED) {
5697 mode = 0; 6311 mode = 0;
5698 } else if (status & TP_EC_FAN_AUTO) { 6312 } else if (status & TP_EC_FAN_AUTO) {
@@ -5757,14 +6371,6 @@ static ssize_t fan_pwm1_show(struct device *dev,
5757 if (res) 6371 if (res)
5758 return res; 6372 return res;
5759 6373
5760 if (unlikely(tp_features.fan_ctrl_status_undef)) {
5761 if (status != fan_control_initial_status) {
5762 tp_features.fan_ctrl_status_undef = 0;
5763 } else {
5764 status = TP_EC_FAN_AUTO;
5765 }
5766 }
5767
5768 if ((status & 6374 if ((status &
5769 (TP_EC_FAN_AUTO | TP_EC_FAN_FULLSPEED)) != 0) 6375 (TP_EC_FAN_AUTO | TP_EC_FAN_FULLSPEED)) != 0)
5770 status = fan_control_desired_level; 6376 status = fan_control_desired_level;
@@ -5789,7 +6395,7 @@ static ssize_t fan_pwm1_store(struct device *dev,
5789 /* scale down from 0-255 to 0-7 */ 6395 /* scale down from 0-255 to 0-7 */
5790 newlevel = (s >> 5) & 0x07; 6396 newlevel = (s >> 5) & 0x07;
5791 6397
5792 if (mutex_lock_interruptible(&fan_mutex)) 6398 if (mutex_lock_killable(&fan_mutex))
5793 return -ERESTARTSYS; 6399 return -ERESTARTSYS;
5794 6400
5795 rc = fan_get_status(&status); 6401 rc = fan_get_status(&status);
@@ -5896,29 +6502,7 @@ static int __init fan_init(struct ibm_init_struct *iibm)
5896 if (likely(acpi_ec_read(fan_status_offset, 6502 if (likely(acpi_ec_read(fan_status_offset,
5897 &fan_control_initial_status))) { 6503 &fan_control_initial_status))) {
5898 fan_status_access_mode = TPACPI_FAN_RD_TPEC; 6504 fan_status_access_mode = TPACPI_FAN_RD_TPEC;
5899 6505 fan_quirk1_detect();
5900 /* In some ThinkPads, neither the EC nor the ACPI
5901 * DSDT initialize the fan status, and it ends up
5902 * being set to 0x07 when it *could* be either
5903 * 0x07 or 0x80.
5904 *
5905 * Enable for TP-1Y (T43), TP-78 (R51e),
5906 * TP-76 (R52), TP-70 (T43, R52), which are known
5907 * to be buggy. */
5908 if (fan_control_initial_status == 0x07) {
5909 switch (thinkpad_id.ec_model) {
5910 case 0x5931: /* TP-1Y */
5911 case 0x3837: /* TP-78 */
5912 case 0x3637: /* TP-76 */
5913 case 0x3037: /* TP-70 */
5914 printk(TPACPI_NOTICE
5915 "fan_init: initial fan status "
5916 "is unknown, assuming it is "
5917 "in auto mode\n");
5918 tp_features.fan_ctrl_status_undef = 1;
5919 ;;
5920 }
5921 }
5922 } else { 6506 } else {
5923 printk(TPACPI_ERR 6507 printk(TPACPI_ERR
5924 "ThinkPad ACPI EC access misbehaving, " 6508 "ThinkPad ACPI EC access misbehaving, "
@@ -6107,15 +6691,6 @@ static int fan_read(char *p)
6107 if (rc < 0) 6691 if (rc < 0)
6108 return rc; 6692 return rc;
6109 6693
6110 if (unlikely(tp_features.fan_ctrl_status_undef)) {
6111 if (status != fan_control_initial_status)
6112 tp_features.fan_ctrl_status_undef = 0;
6113 else
6114 /* Return most likely status. In fact, it
6115 * might be the only possible status */
6116 status = TP_EC_FAN_AUTO;
6117 }
6118
6119 len += sprintf(p + len, "status:\t\t%s\n", 6694 len += sprintf(p + len, "status:\t\t%s\n",
6120 (status != 0) ? "enabled" : "disabled"); 6695 (status != 0) ? "enabled" : "disabled");
6121 6696
@@ -6564,6 +7139,10 @@ static struct ibm_init_struct ibms_init[] __initdata = {
6564 .init = wan_init, 7139 .init = wan_init,
6565 .data = &wan_driver_data, 7140 .data = &wan_driver_data,
6566 }, 7141 },
7142 {
7143 .init = uwb_init,
7144 .data = &uwb_driver_data,
7145 },
6567#ifdef CONFIG_THINKPAD_ACPI_VIDEO 7146#ifdef CONFIG_THINKPAD_ACPI_VIDEO
6568 { 7147 {
6569 .init = video_init, 7148 .init = video_init,
@@ -6702,6 +7281,32 @@ TPACPI_PARAM(brightness);
6702TPACPI_PARAM(volume); 7281TPACPI_PARAM(volume);
6703TPACPI_PARAM(fan); 7282TPACPI_PARAM(fan);
6704 7283
7284#ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
7285module_param(dbg_wlswemul, uint, 0);
7286MODULE_PARM_DESC(dbg_wlswemul, "Enables WLSW emulation");
7287module_param_named(wlsw_state, tpacpi_wlsw_emulstate, bool, 0);
7288MODULE_PARM_DESC(wlsw_state,
7289 "Initial state of the emulated WLSW switch");
7290
7291module_param(dbg_bluetoothemul, uint, 0);
7292MODULE_PARM_DESC(dbg_bluetoothemul, "Enables bluetooth switch emulation");
7293module_param_named(bluetooth_state, tpacpi_bluetooth_emulstate, bool, 0);
7294MODULE_PARM_DESC(bluetooth_state,
7295 "Initial state of the emulated bluetooth switch");
7296
7297module_param(dbg_wwanemul, uint, 0);
7298MODULE_PARM_DESC(dbg_wwanemul, "Enables WWAN switch emulation");
7299module_param_named(wwan_state, tpacpi_wwan_emulstate, bool, 0);
7300MODULE_PARM_DESC(wwan_state,
7301 "Initial state of the emulated WWAN switch");
7302
7303module_param(dbg_uwbemul, uint, 0);
7304MODULE_PARM_DESC(dbg_uwbemul, "Enables UWB switch emulation");
7305module_param_named(uwb_state, tpacpi_uwb_emulstate, bool, 0);
7306MODULE_PARM_DESC(uwb_state,
7307 "Initial state of the emulated UWB switch");
7308#endif
7309
6705static void thinkpad_acpi_module_exit(void) 7310static void thinkpad_acpi_module_exit(void)
6706{ 7311{
6707 struct ibm_struct *ibm, *itmp; 7312 struct ibm_struct *ibm, *itmp;
diff --git a/drivers/acpi/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 40e60fc2e596..40e60fc2e596 100644
--- a/drivers/acpi/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
diff --git a/drivers/acpi/wmi.c b/drivers/platform/x86/wmi.c
index 8a8b377712c9..8a8b377712c9 100644
--- a/drivers/acpi/wmi.c
+++ b/drivers/platform/x86/wmi.c
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 383e47c392a4..2834846a185d 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -23,7 +23,6 @@
23#include <linux/pnp.h> 23#include <linux/pnp.h>
24#include <linux/mod_devicetable.h> 24#include <linux/mod_devicetable.h>
25#include <acpi/acpi_bus.h> 25#include <acpi/acpi_bus.h>
26#include <acpi/actypes.h>
27 26
28#include "../base.h" 27#include "../base.h"
29#include "pnpacpi.h" 28#include "pnpacpi.h"
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 668472405a57..33da1127992a 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -82,4 +82,10 @@ config BATTERY_DA9030
82 Say Y here to enable support for batteries charger integrated into 82 Say Y here to enable support for batteries charger integrated into
83 DA9030 PMIC. 83 DA9030 PMIC.
84 84
85config CHARGER_PCF50633
86 tristate "NXP PCF50633 MBC"
87 depends on MFD_PCF50633
88 help
89 Say Y to include support for NXP PCF50633 Main Battery Charger.
90
85endif # POWER_SUPPLY 91endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index eebb15505a40..2fcf41d13e5c 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -25,3 +25,4 @@ obj-$(CONFIG_BATTERY_TOSA) += tosa_battery.o
25obj-$(CONFIG_BATTERY_WM97XX) += wm97xx_battery.o 25obj-$(CONFIG_BATTERY_WM97XX) += wm97xx_battery.o
26obj-$(CONFIG_BATTERY_BQ27x00) += bq27x00_battery.o 26obj-$(CONFIG_BATTERY_BQ27x00) += bq27x00_battery.o
27obj-$(CONFIG_BATTERY_DA9030) += da9030_battery.o 27obj-$(CONFIG_BATTERY_DA9030) += da9030_battery.o
28obj-$(CONFIG_CHARGER_PCF50633) += pcf50633-charger.o \ No newline at end of file
diff --git a/drivers/power/pcf50633-charger.c b/drivers/power/pcf50633-charger.c
new file mode 100644
index 000000000000..e988ec130fcd
--- /dev/null
+++ b/drivers/power/pcf50633-charger.c
@@ -0,0 +1,358 @@
1/* NXP PCF50633 Main Battery Charger Driver
2 *
3 * (C) 2006-2008 by Openmoko, Inc.
4 * Author: Balaji Rao <balajirrao@openmoko.org>
5 * All rights reserved.
6 *
7 * Broken down from monstrous PCF50633 driver mainly by
8 * Harald Welte, Andy Green and Werner Almesberger
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/init.h>
20#include <linux/types.h>
21#include <linux/device.h>
22#include <linux/sysfs.h>
23#include <linux/platform_device.h>
24#include <linux/power_supply.h>
25
26#include <linux/mfd/pcf50633/core.h>
27#include <linux/mfd/pcf50633/mbc.h>
28
29struct pcf50633_mbc {
30 struct pcf50633 *pcf;
31
32 int adapter_active;
33 int adapter_online;
34 int usb_active;
35 int usb_online;
36
37 struct power_supply usb;
38 struct power_supply adapter;
39};
40
41int pcf50633_mbc_usb_curlim_set(struct pcf50633 *pcf, int ma)
42{
43 struct pcf50633_mbc *mbc = platform_get_drvdata(pcf->mbc_pdev);
44 int ret = 0;
45 u8 bits;
46
47 if (ma >= 1000)
48 bits = PCF50633_MBCC7_USB_1000mA;
49 else if (ma >= 500)
50 bits = PCF50633_MBCC7_USB_500mA;
51 else if (ma >= 100)
52 bits = PCF50633_MBCC7_USB_100mA;
53 else
54 bits = PCF50633_MBCC7_USB_SUSPEND;
55
56 ret = pcf50633_reg_set_bit_mask(pcf, PCF50633_REG_MBCC7,
57 PCF50633_MBCC7_USB_MASK, bits);
58 if (ret)
59 dev_err(pcf->dev, "error setting usb curlim to %d mA\n", ma);
60 else
61 dev_info(pcf->dev, "usb curlim to %d mA\n", ma);
62
63 power_supply_changed(&mbc->usb);
64
65 return ret;
66}
67EXPORT_SYMBOL_GPL(pcf50633_mbc_usb_curlim_set);
68
69int pcf50633_mbc_get_status(struct pcf50633 *pcf)
70{
71 struct pcf50633_mbc *mbc = platform_get_drvdata(pcf->mbc_pdev);
72 int status = 0;
73
74 if (mbc->usb_online)
75 status |= PCF50633_MBC_USB_ONLINE;
76 if (mbc->usb_active)
77 status |= PCF50633_MBC_USB_ACTIVE;
78 if (mbc->adapter_online)
79 status |= PCF50633_MBC_ADAPTER_ONLINE;
80 if (mbc->adapter_active)
81 status |= PCF50633_MBC_ADAPTER_ACTIVE;
82
83 return status;
84}
85EXPORT_SYMBOL_GPL(pcf50633_mbc_get_status);
86
87void pcf50633_mbc_set_status(struct pcf50633 *pcf, int what, int status)
88{
89 struct pcf50633_mbc *mbc = platform_get_drvdata(pcf->mbc_pdev);
90
91 if (what & PCF50633_MBC_USB_ONLINE)
92 mbc->usb_online = !!status;
93 if (what & PCF50633_MBC_USB_ACTIVE)
94 mbc->usb_active = !!status;
95 if (what & PCF50633_MBC_ADAPTER_ONLINE)
96 mbc->adapter_online = !!status;
97 if (what & PCF50633_MBC_ADAPTER_ACTIVE)
98 mbc->adapter_active = !!status;
99}
100EXPORT_SYMBOL_GPL(pcf50633_mbc_set_status);
101
102static ssize_t
103show_chgmode(struct device *dev, struct device_attribute *attr, char *buf)
104{
105 struct pcf50633_mbc *mbc = dev_get_drvdata(dev);
106
107 u8 mbcs2 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS2);
108 u8 chgmod = (mbcs2 & PCF50633_MBCS2_MBC_MASK);
109
110 return sprintf(buf, "%d\n", chgmod);
111}
112static DEVICE_ATTR(chgmode, S_IRUGO, show_chgmode, NULL);
113
114static ssize_t
115show_usblim(struct device *dev, struct device_attribute *attr, char *buf)
116{
117 struct pcf50633_mbc *mbc = dev_get_drvdata(dev);
118 u8 usblim = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCC7) &
119 PCF50633_MBCC7_USB_MASK;
120 unsigned int ma;
121
122 if (usblim == PCF50633_MBCC7_USB_1000mA)
123 ma = 1000;
124 else if (usblim == PCF50633_MBCC7_USB_500mA)
125 ma = 500;
126 else if (usblim == PCF50633_MBCC7_USB_100mA)
127 ma = 100;
128 else
129 ma = 0;
130
131 return sprintf(buf, "%u\n", ma);
132}
133
134static ssize_t set_usblim(struct device *dev,
135 struct device_attribute *attr, const char *buf, size_t count)
136{
137 struct pcf50633_mbc *mbc = dev_get_drvdata(dev);
138 unsigned long ma;
139 int ret;
140
141 ret = strict_strtoul(buf, 10, &ma);
142 if (ret)
143 return -EINVAL;
144
145 pcf50633_mbc_usb_curlim_set(mbc->pcf, ma);
146
147 return count;
148}
149
150static DEVICE_ATTR(usb_curlim, S_IRUGO | S_IWUSR, show_usblim, set_usblim);
151
152static struct attribute *pcf50633_mbc_sysfs_entries[] = {
153 &dev_attr_chgmode.attr,
154 &dev_attr_usb_curlim.attr,
155 NULL,
156};
157
158static struct attribute_group mbc_attr_group = {
159 .name = NULL, /* put in device directory */
160 .attrs = pcf50633_mbc_sysfs_entries,
161};
162
163static void
164pcf50633_mbc_irq_handler(int irq, void *data)
165{
166 struct pcf50633_mbc *mbc = data;
167
168 /* USB */
169 if (irq == PCF50633_IRQ_USBINS) {
170 mbc->usb_online = 1;
171 } else if (irq == PCF50633_IRQ_USBREM) {
172 mbc->usb_online = 0;
173 mbc->usb_active = 0;
174 pcf50633_mbc_usb_curlim_set(mbc->pcf, 0);
175 }
176
177 /* Adapter */
178 if (irq == PCF50633_IRQ_ADPINS) {
179 mbc->adapter_online = 1;
180 mbc->adapter_active = 1;
181 } else if (irq == PCF50633_IRQ_ADPREM) {
182 mbc->adapter_online = 0;
183 mbc->adapter_active = 0;
184 }
185
186 if (irq == PCF50633_IRQ_BATFULL) {
187 mbc->usb_active = 0;
188 mbc->adapter_active = 0;
189 }
190
191 power_supply_changed(&mbc->usb);
192 power_supply_changed(&mbc->adapter);
193
194 if (mbc->pcf->pdata->mbc_event_callback)
195 mbc->pcf->pdata->mbc_event_callback(mbc->pcf, irq);
196}
197
198static int adapter_get_property(struct power_supply *psy,
199 enum power_supply_property psp,
200 union power_supply_propval *val)
201{
202 struct pcf50633_mbc *mbc = container_of(psy, struct pcf50633_mbc, usb);
203 int ret = 0;
204
205 switch (psp) {
206 case POWER_SUPPLY_PROP_ONLINE:
207 val->intval = mbc->adapter_online;
208 break;
209 default:
210 ret = -EINVAL;
211 break;
212 }
213 return ret;
214}
215
216static int usb_get_property(struct power_supply *psy,
217 enum power_supply_property psp,
218 union power_supply_propval *val)
219{
220 struct pcf50633_mbc *mbc = container_of(psy, struct pcf50633_mbc, usb);
221 int ret = 0;
222
223 switch (psp) {
224 case POWER_SUPPLY_PROP_ONLINE:
225 val->intval = mbc->usb_online;
226 break;
227 default:
228 ret = -EINVAL;
229 break;
230 }
231 return ret;
232}
233
234static enum power_supply_property power_props[] = {
235 POWER_SUPPLY_PROP_ONLINE,
236};
237
238static const u8 mbc_irq_handlers[] = {
239 PCF50633_IRQ_ADPINS,
240 PCF50633_IRQ_ADPREM,
241 PCF50633_IRQ_USBINS,
242 PCF50633_IRQ_USBREM,
243 PCF50633_IRQ_BATFULL,
244 PCF50633_IRQ_CHGHALT,
245 PCF50633_IRQ_THLIMON,
246 PCF50633_IRQ_THLIMOFF,
247 PCF50633_IRQ_USBLIMON,
248 PCF50633_IRQ_USBLIMOFF,
249 PCF50633_IRQ_LOWSYS,
250 PCF50633_IRQ_LOWBAT,
251};
252
253static int __devinit pcf50633_mbc_probe(struct platform_device *pdev)
254{
255 struct pcf50633_mbc *mbc;
256 struct pcf50633_subdev_pdata *pdata = pdev->dev.platform_data;
257 int ret;
258 int i;
259 u8 mbcs1;
260
261 mbc = kzalloc(sizeof(*mbc), GFP_KERNEL);
262 if (!mbc)
263 return -ENOMEM;
264
265 platform_set_drvdata(pdev, mbc);
266 mbc->pcf = pdata->pcf;
267
268 /* Set up IRQ handlers */
269 for (i = 0; i < ARRAY_SIZE(mbc_irq_handlers); i++)
270 pcf50633_register_irq(mbc->pcf, mbc_irq_handlers[i],
271 pcf50633_mbc_irq_handler, mbc);
272
273 /* Create power supplies */
274 mbc->adapter.name = "adapter";
275 mbc->adapter.type = POWER_SUPPLY_TYPE_MAINS;
276 mbc->adapter.properties = power_props;
277 mbc->adapter.num_properties = ARRAY_SIZE(power_props);
278 mbc->adapter.get_property = &adapter_get_property;
279 mbc->adapter.supplied_to = mbc->pcf->pdata->batteries;
280 mbc->adapter.num_supplicants = mbc->pcf->pdata->num_batteries;
281
282 mbc->usb.name = "usb";
283 mbc->usb.type = POWER_SUPPLY_TYPE_USB;
284 mbc->usb.properties = power_props;
285 mbc->usb.num_properties = ARRAY_SIZE(power_props);
286 mbc->usb.get_property = usb_get_property;
287 mbc->usb.supplied_to = mbc->pcf->pdata->batteries;
288 mbc->usb.num_supplicants = mbc->pcf->pdata->num_batteries;
289
290 ret = power_supply_register(&pdev->dev, &mbc->adapter);
291 if (ret) {
292 dev_err(mbc->pcf->dev, "failed to register adapter\n");
293 kfree(mbc);
294 return ret;
295 }
296
297 ret = power_supply_register(&pdev->dev, &mbc->usb);
298 if (ret) {
299 dev_err(mbc->pcf->dev, "failed to register usb\n");
300 power_supply_unregister(&mbc->adapter);
301 kfree(mbc);
302 return ret;
303 }
304
305 ret = sysfs_create_group(&pdev->dev.kobj, &mbc_attr_group);
306 if (ret)
307 dev_err(mbc->pcf->dev, "failed to create sysfs entries\n");
308
309 mbcs1 = pcf50633_reg_read(mbc->pcf, PCF50633_REG_MBCS1);
310 if (mbcs1 & PCF50633_MBCS1_USBPRES)
311 pcf50633_mbc_irq_handler(PCF50633_IRQ_USBINS, mbc);
312 if (mbcs1 & PCF50633_MBCS1_ADAPTPRES)
313 pcf50633_mbc_irq_handler(PCF50633_IRQ_ADPINS, mbc);
314
315 return 0;
316}
317
318static int __devexit pcf50633_mbc_remove(struct platform_device *pdev)
319{
320 struct pcf50633_mbc *mbc = platform_get_drvdata(pdev);
321 int i;
322
323 /* Remove IRQ handlers */
324 for (i = 0; i < ARRAY_SIZE(mbc_irq_handlers); i++)
325 pcf50633_free_irq(mbc->pcf, mbc_irq_handlers[i]);
326
327 power_supply_unregister(&mbc->usb);
328 power_supply_unregister(&mbc->adapter);
329
330 kfree(mbc);
331
332 return 0;
333}
334
335static struct platform_driver pcf50633_mbc_driver = {
336 .driver = {
337 .name = "pcf50633-mbc",
338 },
339 .probe = pcf50633_mbc_probe,
340 .remove = __devexit_p(pcf50633_mbc_remove),
341};
342
343static int __init pcf50633_mbc_init(void)
344{
345 return platform_driver_register(&pcf50633_mbc_driver);
346}
347module_init(pcf50633_mbc_init);
348
349static void __exit pcf50633_mbc_exit(void)
350{
351 platform_driver_unregister(&pcf50633_mbc_driver);
352}
353module_exit(pcf50633_mbc_exit);
354
355MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>");
356MODULE_DESCRIPTION("PCF50633 mbc driver");
357MODULE_LICENSE("GPL");
358MODULE_ALIAS("platform:pcf50633-mbc");
diff --git a/drivers/ps3/ps3-lpm.c b/drivers/ps3/ps3-lpm.c
index 204158cf7a55..fe96793e3f08 100644
--- a/drivers/ps3/ps3-lpm.c
+++ b/drivers/ps3/ps3-lpm.c
@@ -732,7 +732,7 @@ static u64 pm_signal_group_to_ps3_lv1_signal_group(u64 group)
732 case 8: 732 case 8:
733 return pm_translate_signal_group_number_on_island8(subgroup); 733 return pm_translate_signal_group_number_on_island8(subgroup);
734 default: 734 default:
735 dev_dbg(sbd_core(), "%s:%u: island not found: %lu\n", __func__, 735 dev_dbg(sbd_core(), "%s:%u: island not found: %llu\n", __func__,
736 __LINE__, group); 736 __LINE__, group);
737 BUG(); 737 BUG();
738 break; 738 break;
@@ -765,7 +765,7 @@ static int __ps3_set_signal(u64 lv1_signal_group, u64 bus_select,
765 signal_select, attr1, attr2, attr3); 765 signal_select, attr1, attr2, attr3);
766 if (ret) 766 if (ret)
767 dev_err(sbd_core(), 767 dev_err(sbd_core(),
768 "%s:%u: error:%d 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx\n", 768 "%s:%u: error:%d 0x%llx 0x%llx 0x%llx 0x%llx 0x%llx 0x%llx\n",
769 __func__, __LINE__, ret, lv1_signal_group, bus_select, 769 __func__, __LINE__, ret, lv1_signal_group, bus_select,
770 signal_select, attr1, attr2, attr3); 770 signal_select, attr1, attr2, attr3);
771 771
@@ -908,7 +908,7 @@ void ps3_disable_pm(u32 cpu)
908 908
909 lpm_priv->tb_count = tmp; 909 lpm_priv->tb_count = tmp;
910 910
911 dev_dbg(sbd_core(), "%s:%u: tb_count %lu (%lxh)\n", __func__, __LINE__, 911 dev_dbg(sbd_core(), "%s:%u: tb_count %llu (%llxh)\n", __func__, __LINE__,
912 lpm_priv->tb_count, lpm_priv->tb_count); 912 lpm_priv->tb_count, lpm_priv->tb_count);
913} 913}
914EXPORT_SYMBOL_GPL(ps3_disable_pm); 914EXPORT_SYMBOL_GPL(ps3_disable_pm);
@@ -938,7 +938,7 @@ int ps3_lpm_copy_tb(unsigned long offset, void *buf, unsigned long count,
938 if (offset >= lpm_priv->tb_count) 938 if (offset >= lpm_priv->tb_count)
939 return 0; 939 return 0;
940 940
941 count = min(count, lpm_priv->tb_count - offset); 941 count = min_t(u64, count, lpm_priv->tb_count - offset);
942 942
943 while (*bytes_copied < count) { 943 while (*bytes_copied < count) {
944 const unsigned long request = count - *bytes_copied; 944 const unsigned long request = count - *bytes_copied;
@@ -993,7 +993,7 @@ int ps3_lpm_copy_tb_to_user(unsigned long offset, void __user *buf,
993 if (offset >= lpm_priv->tb_count) 993 if (offset >= lpm_priv->tb_count)
994 return 0; 994 return 0;
995 995
996 count = min(count, lpm_priv->tb_count - offset); 996 count = min_t(u64, count, lpm_priv->tb_count - offset);
997 997
998 while (*bytes_copied < count) { 998 while (*bytes_copied < count) {
999 const unsigned long request = count - *bytes_copied; 999 const unsigned long request = count - *bytes_copied;
@@ -1013,7 +1013,7 @@ int ps3_lpm_copy_tb_to_user(unsigned long offset, void __user *buf,
1013 result = copy_to_user(buf, lpm_priv->tb_cache, tmp); 1013 result = copy_to_user(buf, lpm_priv->tb_cache, tmp);
1014 1014
1015 if (result) { 1015 if (result) {
1016 dev_dbg(sbd_core(), "%s:%u: 0x%lx bytes at 0x%p\n", 1016 dev_dbg(sbd_core(), "%s:%u: 0x%llx bytes at 0x%p\n",
1017 __func__, __LINE__, tmp, buf); 1017 __func__, __LINE__, tmp, buf);
1018 dev_err(sbd_core(), "%s:%u: copy_to_user failed: %d\n", 1018 dev_err(sbd_core(), "%s:%u: copy_to_user failed: %d\n",
1019 __func__, __LINE__, result); 1019 __func__, __LINE__, result);
@@ -1148,8 +1148,8 @@ int ps3_lpm_open(enum ps3_lpm_tb_type tb_type, void *tb_cache,
1148 lpm_priv->shadow.group_control = PS3_LPM_SHADOW_REG_INIT; 1148 lpm_priv->shadow.group_control = PS3_LPM_SHADOW_REG_INIT;
1149 lpm_priv->shadow.debug_bus_control = PS3_LPM_SHADOW_REG_INIT; 1149 lpm_priv->shadow.debug_bus_control = PS3_LPM_SHADOW_REG_INIT;
1150 1150
1151 dev_dbg(sbd_core(), "%s:%u: lpm_id 0x%lx, outlet_id 0x%lx, " 1151 dev_dbg(sbd_core(), "%s:%u: lpm_id 0x%llx, outlet_id 0x%llx, "
1152 "tb_size 0x%lx\n", __func__, __LINE__, lpm_priv->lpm_id, 1152 "tb_size 0x%llx\n", __func__, __LINE__, lpm_priv->lpm_id,
1153 lpm_priv->outlet_id, tb_size); 1153 lpm_priv->outlet_id, tb_size);
1154 1154
1155 return 0; 1155 return 0;
diff --git a/drivers/ps3/ps3-vuart.c b/drivers/ps3/ps3-vuart.c
index 90c097a7a47a..e4ad5ba5d0a3 100644
--- a/drivers/ps3/ps3-vuart.c
+++ b/drivers/ps3/ps3-vuart.c
@@ -114,7 +114,7 @@ struct ports_bmp {
114static void __maybe_unused _dump_ports_bmp( 114static void __maybe_unused _dump_ports_bmp(
115 const struct ports_bmp *bmp, const char *func, int line) 115 const struct ports_bmp *bmp, const char *func, int line)
116{ 116{
117 pr_debug("%s:%d: ports_bmp: %016lxh\n", func, line, bmp->status); 117 pr_debug("%s:%d: ports_bmp: %016llxh\n", func, line, bmp->status);
118} 118}
119 119
120#define dump_port_params(_b) _dump_port_params(_b, __func__, __LINE__) 120#define dump_port_params(_b) _dump_port_params(_b, __func__, __LINE__)
@@ -159,11 +159,13 @@ int ps3_vuart_get_triggers(struct ps3_system_bus_device *dev,
159 struct vuart_triggers *trig) 159 struct vuart_triggers *trig)
160{ 160{
161 int result; 161 int result;
162 unsigned long size; 162 u64 size;
163 unsigned long val; 163 u64 val;
164 u64 tx;
164 165
165 result = lv1_get_virtual_uart_param(dev->port_number, 166 result = lv1_get_virtual_uart_param(dev->port_number,
166 PARAM_TX_TRIGGER, &trig->tx); 167 PARAM_TX_TRIGGER, &tx);
168 trig->tx = tx;
167 169
168 if (result) { 170 if (result) {
169 dev_dbg(&dev->core, "%s:%d: tx_trigger failed: %s\n", 171 dev_dbg(&dev->core, "%s:%d: tx_trigger failed: %s\n",
@@ -201,7 +203,7 @@ int ps3_vuart_set_triggers(struct ps3_system_bus_device *dev, unsigned int tx,
201 unsigned int rx) 203 unsigned int rx)
202{ 204{
203 int result; 205 int result;
204 unsigned long size; 206 u64 size;
205 207
206 result = lv1_set_virtual_uart_param(dev->port_number, 208 result = lv1_set_virtual_uart_param(dev->port_number,
207 PARAM_TX_TRIGGER, tx); 209 PARAM_TX_TRIGGER, tx);
@@ -248,7 +250,7 @@ static int ps3_vuart_get_rx_bytes_waiting(struct ps3_system_bus_device *dev,
248 dev_dbg(&dev->core, "%s:%d: rx_bytes failed: %s\n", 250 dev_dbg(&dev->core, "%s:%d: rx_bytes failed: %s\n",
249 __func__, __LINE__, ps3_result(result)); 251 __func__, __LINE__, ps3_result(result));
250 252
251 dev_dbg(&dev->core, "%s:%d: %lxh\n", __func__, __LINE__, 253 dev_dbg(&dev->core, "%s:%d: %llxh\n", __func__, __LINE__,
252 *bytes_waiting); 254 *bytes_waiting);
253 return result; 255 return result;
254} 256}
@@ -295,7 +297,7 @@ static int ps3_vuart_get_interrupt_status(struct ps3_system_bus_device *dev,
295 297
296 *status = tmp & priv->interrupt_mask; 298 *status = tmp & priv->interrupt_mask;
297 299
298 dev_dbg(&dev->core, "%s:%d: m %lxh, s %lxh, m&s %lxh\n", 300 dev_dbg(&dev->core, "%s:%d: m %llxh, s %llxh, m&s %lxh\n",
299 __func__, __LINE__, priv->interrupt_mask, tmp, *status); 301 __func__, __LINE__, priv->interrupt_mask, tmp, *status);
300 302
301 return result; 303 return result;
@@ -363,7 +365,7 @@ int ps3_vuart_disable_interrupt_disconnect(struct ps3_system_bus_device *dev)
363 */ 365 */
364 366
365static int ps3_vuart_raw_write(struct ps3_system_bus_device *dev, 367static int ps3_vuart_raw_write(struct ps3_system_bus_device *dev,
366 const void *buf, unsigned int bytes, unsigned long *bytes_written) 368 const void *buf, unsigned int bytes, u64 *bytes_written)
367{ 369{
368 int result; 370 int result;
369 struct ps3_vuart_port_priv *priv = to_port_priv(dev); 371 struct ps3_vuart_port_priv *priv = to_port_priv(dev);
@@ -379,7 +381,7 @@ static int ps3_vuart_raw_write(struct ps3_system_bus_device *dev,
379 381
380 priv->stats.bytes_written += *bytes_written; 382 priv->stats.bytes_written += *bytes_written;
381 383
382 dev_dbg(&dev->core, "%s:%d: wrote %lxh/%xh=>%lxh\n", __func__, __LINE__, 384 dev_dbg(&dev->core, "%s:%d: wrote %llxh/%xh=>%lxh\n", __func__, __LINE__,
383 *bytes_written, bytes, priv->stats.bytes_written); 385 *bytes_written, bytes, priv->stats.bytes_written);
384 386
385 return result; 387 return result;
@@ -393,7 +395,7 @@ static int ps3_vuart_raw_write(struct ps3_system_bus_device *dev,
393 */ 395 */
394 396
395static int ps3_vuart_raw_read(struct ps3_system_bus_device *dev, void *buf, 397static int ps3_vuart_raw_read(struct ps3_system_bus_device *dev, void *buf,
396 unsigned int bytes, unsigned long *bytes_read) 398 unsigned int bytes, u64 *bytes_read)
397{ 399{
398 int result; 400 int result;
399 struct ps3_vuart_port_priv *priv = to_port_priv(dev); 401 struct ps3_vuart_port_priv *priv = to_port_priv(dev);
@@ -411,7 +413,7 @@ static int ps3_vuart_raw_read(struct ps3_system_bus_device *dev, void *buf,
411 413
412 priv->stats.bytes_read += *bytes_read; 414 priv->stats.bytes_read += *bytes_read;
413 415
414 dev_dbg(&dev->core, "%s:%d: read %lxh/%xh=>%lxh\n", __func__, __LINE__, 416 dev_dbg(&dev->core, "%s:%d: read %llxh/%xh=>%lxh\n", __func__, __LINE__,
415 *bytes_read, bytes, priv->stats.bytes_read); 417 *bytes_read, bytes, priv->stats.bytes_read);
416 418
417 return result; 419 return result;
@@ -500,7 +502,7 @@ int ps3_vuart_write(struct ps3_system_bus_device *dev, const void *buf,
500 spin_lock_irqsave(&priv->tx_list.lock, flags); 502 spin_lock_irqsave(&priv->tx_list.lock, flags);
501 503
502 if (list_empty(&priv->tx_list.head)) { 504 if (list_empty(&priv->tx_list.head)) {
503 unsigned long bytes_written; 505 u64 bytes_written;
504 506
505 result = ps3_vuart_raw_write(dev, buf, bytes, &bytes_written); 507 result = ps3_vuart_raw_write(dev, buf, bytes, &bytes_written);
506 508
@@ -592,7 +594,7 @@ static int ps3_vuart_queue_rx_bytes(struct ps3_system_bus_device *dev,
592 list_add_tail(&lb->link, &priv->rx_list.head); 594 list_add_tail(&lb->link, &priv->rx_list.head);
593 priv->rx_list.bytes_held += bytes; 595 priv->rx_list.bytes_held += bytes;
594 596
595 dev_dbg(&dev->core, "%s:%d: buf_%lu: queued %lxh bytes\n", 597 dev_dbg(&dev->core, "%s:%d: buf_%lu: queued %llxh bytes\n",
596 __func__, __LINE__, lb->dbg_number, bytes); 598 __func__, __LINE__, lb->dbg_number, bytes);
597 599
598 *bytes_queued = bytes; 600 *bytes_queued = bytes;
@@ -745,7 +747,7 @@ static int ps3_vuart_handle_interrupt_tx(struct ps3_system_bus_device *dev)
745 747
746 list_for_each_entry_safe(lb, n, &priv->tx_list.head, link) { 748 list_for_each_entry_safe(lb, n, &priv->tx_list.head, link) {
747 749
748 unsigned long bytes_written; 750 u64 bytes_written;
749 751
750 result = ps3_vuart_raw_write(dev, lb->head, lb->tail - lb->head, 752 result = ps3_vuart_raw_write(dev, lb->head, lb->tail - lb->head,
751 &bytes_written); 753 &bytes_written);
@@ -762,7 +764,7 @@ static int ps3_vuart_handle_interrupt_tx(struct ps3_system_bus_device *dev)
762 if (bytes_written < lb->tail - lb->head) { 764 if (bytes_written < lb->tail - lb->head) {
763 lb->head += bytes_written; 765 lb->head += bytes_written;
764 dev_dbg(&dev->core, 766 dev_dbg(&dev->core,
765 "%s:%d cleared buf_%lu, %lxh bytes\n", 767 "%s:%d cleared buf_%lu, %llxh bytes\n",
766 __func__, __LINE__, lb->dbg_number, 768 __func__, __LINE__, lb->dbg_number,
767 bytes_written); 769 bytes_written);
768 goto port_full; 770 goto port_full;
diff --git a/drivers/ps3/ps3stor_lib.c b/drivers/ps3/ps3stor_lib.c
index 55955f16ad91..18066d555397 100644
--- a/drivers/ps3/ps3stor_lib.c
+++ b/drivers/ps3/ps3stor_lib.c
@@ -70,7 +70,7 @@ static int ps3stor_probe_access(struct ps3_storage_device *dev)
70 __func__, __LINE__, n); 70 __func__, __LINE__, n);
71 dev->region_idx = __ffs(dev->accessible_regions); 71 dev->region_idx = __ffs(dev->accessible_regions);
72 dev_info(&dev->sbd.core, 72 dev_info(&dev->sbd.core,
73 "First accessible region has index %u start %lu size %lu\n", 73 "First accessible region has index %u start %llu size %llu\n",
74 dev->region_idx, dev->regions[dev->region_idx].start, 74 dev->region_idx, dev->regions[dev->region_idx].start,
75 dev->regions[dev->region_idx].size); 75 dev->regions[dev->region_idx].size);
76 76
@@ -220,7 +220,7 @@ u64 ps3stor_read_write_sectors(struct ps3_storage_device *dev, u64 lpar,
220 const char *op = write ? "write" : "read"; 220 const char *op = write ? "write" : "read";
221 int res; 221 int res;
222 222
223 dev_dbg(&dev->sbd.core, "%s:%u: %s %lu sectors starting at %lu\n", 223 dev_dbg(&dev->sbd.core, "%s:%u: %s %llu sectors starting at %llu\n",
224 __func__, __LINE__, op, sectors, start_sector); 224 __func__, __LINE__, op, sectors, start_sector);
225 225
226 init_completion(&dev->done); 226 init_completion(&dev->done);
@@ -238,7 +238,7 @@ u64 ps3stor_read_write_sectors(struct ps3_storage_device *dev, u64 lpar,
238 238
239 wait_for_completion(&dev->done); 239 wait_for_completion(&dev->done);
240 if (dev->lv1_status) { 240 if (dev->lv1_status) {
241 dev_dbg(&dev->sbd.core, "%s:%u: %s failed 0x%lx\n", __func__, 241 dev_dbg(&dev->sbd.core, "%s:%u: %s failed 0x%llx\n", __func__,
242 __LINE__, op, dev->lv1_status); 242 __LINE__, op, dev->lv1_status);
243 return dev->lv1_status; 243 return dev->lv1_status;
244 } 244 }
@@ -268,7 +268,7 @@ u64 ps3stor_send_command(struct ps3_storage_device *dev, u64 cmd, u64 arg1,
268{ 268{
269 int res; 269 int res;
270 270
271 dev_dbg(&dev->sbd.core, "%s:%u: send device command 0x%lx\n", __func__, 271 dev_dbg(&dev->sbd.core, "%s:%u: send device command 0x%llx\n", __func__,
272 __LINE__, cmd); 272 __LINE__, cmd);
273 273
274 init_completion(&dev->done); 274 init_completion(&dev->done);
@@ -277,19 +277,19 @@ u64 ps3stor_send_command(struct ps3_storage_device *dev, u64 cmd, u64 arg1,
277 arg2, arg3, arg4, &dev->tag); 277 arg2, arg3, arg4, &dev->tag);
278 if (res) { 278 if (res) {
279 dev_err(&dev->sbd.core, 279 dev_err(&dev->sbd.core,
280 "%s:%u: send_device_command 0x%lx failed %d\n", 280 "%s:%u: send_device_command 0x%llx failed %d\n",
281 __func__, __LINE__, cmd, res); 281 __func__, __LINE__, cmd, res);
282 return -1; 282 return -1;
283 } 283 }
284 284
285 wait_for_completion(&dev->done); 285 wait_for_completion(&dev->done);
286 if (dev->lv1_status) { 286 if (dev->lv1_status) {
287 dev_dbg(&dev->sbd.core, "%s:%u: command 0x%lx failed 0x%lx\n", 287 dev_dbg(&dev->sbd.core, "%s:%u: command 0x%llx failed 0x%llx\n",
288 __func__, __LINE__, cmd, dev->lv1_status); 288 __func__, __LINE__, cmd, dev->lv1_status);
289 return dev->lv1_status; 289 return dev->lv1_status;
290 } 290 }
291 291
292 dev_dbg(&dev->sbd.core, "%s:%u: command 0x%lx completed\n", __func__, 292 dev_dbg(&dev->sbd.core, "%s:%u: command 0x%llx completed\n", __func__,
293 __LINE__, cmd); 293 __LINE__, cmd);
294 294
295 return 0; 295 return 0;
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 39360e2a4540..e7e0cf102d6d 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -73,4 +73,11 @@ config REGULATOR_DA903X
73 Say y here to support the BUCKs and LDOs regulators found on 73 Say y here to support the BUCKs and LDOs regulators found on
74 Dialog Semiconductor DA9030/DA9034 PMIC. 74 Dialog Semiconductor DA9030/DA9034 PMIC.
75 75
76config REGULATOR_PCF50633
77 tristate "PCF50633 regulator driver"
78 depends on MFD_PCF50633
79 help
80 Say Y here to support the voltage regulators and convertors
81 on PCF50633
82
76endif 83endif
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 254d40c02ee8..61b30c6ddecc 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -11,5 +11,6 @@ obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o
11obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o 11obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o
12obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o 12obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o
13obj-$(CONFIG_REGULATOR_DA903X) += da903x.o 13obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
14obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
14 15
15ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG 16ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 02a774424e8d..f511a406fcaa 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -29,7 +29,7 @@ static DEFINE_MUTEX(regulator_list_mutex);
29static LIST_HEAD(regulator_list); 29static LIST_HEAD(regulator_list);
30static LIST_HEAD(regulator_map_list); 30static LIST_HEAD(regulator_map_list);
31 31
32/** 32/*
33 * struct regulator_dev 33 * struct regulator_dev
34 * 34 *
35 * Voltage / Current regulator class device. One for each regulator. 35 * Voltage / Current regulator class device. One for each regulator.
@@ -56,7 +56,7 @@ struct regulator_dev {
56 void *reg_data; /* regulator_dev data */ 56 void *reg_data; /* regulator_dev data */
57}; 57};
58 58
59/** 59/*
60 * struct regulator_map 60 * struct regulator_map
61 * 61 *
62 * Used to provide symbolic supply names to devices. 62 * Used to provide symbolic supply names to devices.
@@ -79,7 +79,7 @@ struct regulator {
79 int uA_load; 79 int uA_load;
80 int min_uV; 80 int min_uV;
81 int max_uV; 81 int max_uV;
82 int enabled; /* client has called enabled */ 82 int enabled; /* count of client enables */
83 char *supply_name; 83 char *supply_name;
84 struct device_attribute dev_attr; 84 struct device_attribute dev_attr;
85 struct regulator_dev *rdev; 85 struct regulator_dev *rdev;
@@ -174,6 +174,16 @@ static int regulator_check_current_limit(struct regulator_dev *rdev,
174/* operating mode constraint check */ 174/* operating mode constraint check */
175static int regulator_check_mode(struct regulator_dev *rdev, int mode) 175static int regulator_check_mode(struct regulator_dev *rdev, int mode)
176{ 176{
177 switch (mode) {
178 case REGULATOR_MODE_FAST:
179 case REGULATOR_MODE_NORMAL:
180 case REGULATOR_MODE_IDLE:
181 case REGULATOR_MODE_STANDBY:
182 break;
183 default:
184 return -EINVAL;
185 }
186
177 if (!rdev->constraints) { 187 if (!rdev->constraints) {
178 printk(KERN_ERR "%s: no constraints for %s\n", __func__, 188 printk(KERN_ERR "%s: no constraints for %s\n", __func__,
179 rdev->desc->name); 189 rdev->desc->name);
@@ -232,6 +242,7 @@ static ssize_t regulator_uV_show(struct device *dev,
232 242
233 return ret; 243 return ret;
234} 244}
245static DEVICE_ATTR(microvolts, 0444, regulator_uV_show, NULL);
235 246
236static ssize_t regulator_uA_show(struct device *dev, 247static ssize_t regulator_uA_show(struct device *dev,
237 struct device_attribute *attr, char *buf) 248 struct device_attribute *attr, char *buf)
@@ -240,6 +251,7 @@ static ssize_t regulator_uA_show(struct device *dev,
240 251
241 return sprintf(buf, "%d\n", _regulator_get_current_limit(rdev)); 252 return sprintf(buf, "%d\n", _regulator_get_current_limit(rdev));
242} 253}
254static DEVICE_ATTR(microamps, 0444, regulator_uA_show, NULL);
243 255
244static ssize_t regulator_name_show(struct device *dev, 256static ssize_t regulator_name_show(struct device *dev,
245 struct device_attribute *attr, char *buf) 257 struct device_attribute *attr, char *buf)
@@ -257,12 +269,8 @@ static ssize_t regulator_name_show(struct device *dev,
257 return sprintf(buf, "%s\n", name); 269 return sprintf(buf, "%s\n", name);
258} 270}
259 271
260static ssize_t regulator_opmode_show(struct device *dev, 272static ssize_t regulator_print_opmode(char *buf, int mode)
261 struct device_attribute *attr, char *buf)
262{ 273{
263 struct regulator_dev *rdev = dev_get_drvdata(dev);
264 int mode = _regulator_get_mode(rdev);
265
266 switch (mode) { 274 switch (mode) {
267 case REGULATOR_MODE_FAST: 275 case REGULATOR_MODE_FAST:
268 return sprintf(buf, "fast\n"); 276 return sprintf(buf, "fast\n");
@@ -276,12 +284,17 @@ static ssize_t regulator_opmode_show(struct device *dev,
276 return sprintf(buf, "unknown\n"); 284 return sprintf(buf, "unknown\n");
277} 285}
278 286
279static ssize_t regulator_state_show(struct device *dev, 287static ssize_t regulator_opmode_show(struct device *dev,
280 struct device_attribute *attr, char *buf) 288 struct device_attribute *attr, char *buf)
281{ 289{
282 struct regulator_dev *rdev = dev_get_drvdata(dev); 290 struct regulator_dev *rdev = dev_get_drvdata(dev);
283 int state = _regulator_is_enabled(rdev);
284 291
292 return regulator_print_opmode(buf, _regulator_get_mode(rdev));
293}
294static DEVICE_ATTR(opmode, 0444, regulator_opmode_show, NULL);
295
296static ssize_t regulator_print_state(char *buf, int state)
297{
285 if (state > 0) 298 if (state > 0)
286 return sprintf(buf, "enabled\n"); 299 return sprintf(buf, "enabled\n");
287 else if (state == 0) 300 else if (state == 0)
@@ -290,6 +303,15 @@ static ssize_t regulator_state_show(struct device *dev,
290 return sprintf(buf, "unknown\n"); 303 return sprintf(buf, "unknown\n");
291} 304}
292 305
306static ssize_t regulator_state_show(struct device *dev,
307 struct device_attribute *attr, char *buf)
308{
309 struct regulator_dev *rdev = dev_get_drvdata(dev);
310
311 return regulator_print_state(buf, _regulator_is_enabled(rdev));
312}
313static DEVICE_ATTR(state, 0444, regulator_state_show, NULL);
314
293static ssize_t regulator_min_uA_show(struct device *dev, 315static ssize_t regulator_min_uA_show(struct device *dev,
294 struct device_attribute *attr, char *buf) 316 struct device_attribute *attr, char *buf)
295{ 317{
@@ -300,6 +322,7 @@ static ssize_t regulator_min_uA_show(struct device *dev,
300 322
301 return sprintf(buf, "%d\n", rdev->constraints->min_uA); 323 return sprintf(buf, "%d\n", rdev->constraints->min_uA);
302} 324}
325static DEVICE_ATTR(min_microamps, 0444, regulator_min_uA_show, NULL);
303 326
304static ssize_t regulator_max_uA_show(struct device *dev, 327static ssize_t regulator_max_uA_show(struct device *dev,
305 struct device_attribute *attr, char *buf) 328 struct device_attribute *attr, char *buf)
@@ -311,6 +334,7 @@ static ssize_t regulator_max_uA_show(struct device *dev,
311 334
312 return sprintf(buf, "%d\n", rdev->constraints->max_uA); 335 return sprintf(buf, "%d\n", rdev->constraints->max_uA);
313} 336}
337static DEVICE_ATTR(max_microamps, 0444, regulator_max_uA_show, NULL);
314 338
315static ssize_t regulator_min_uV_show(struct device *dev, 339static ssize_t regulator_min_uV_show(struct device *dev,
316 struct device_attribute *attr, char *buf) 340 struct device_attribute *attr, char *buf)
@@ -322,6 +346,7 @@ static ssize_t regulator_min_uV_show(struct device *dev,
322 346
323 return sprintf(buf, "%d\n", rdev->constraints->min_uV); 347 return sprintf(buf, "%d\n", rdev->constraints->min_uV);
324} 348}
349static DEVICE_ATTR(min_microvolts, 0444, regulator_min_uV_show, NULL);
325 350
326static ssize_t regulator_max_uV_show(struct device *dev, 351static ssize_t regulator_max_uV_show(struct device *dev,
327 struct device_attribute *attr, char *buf) 352 struct device_attribute *attr, char *buf)
@@ -333,6 +358,7 @@ static ssize_t regulator_max_uV_show(struct device *dev,
333 358
334 return sprintf(buf, "%d\n", rdev->constraints->max_uV); 359 return sprintf(buf, "%d\n", rdev->constraints->max_uV);
335} 360}
361static DEVICE_ATTR(max_microvolts, 0444, regulator_max_uV_show, NULL);
336 362
337static ssize_t regulator_total_uA_show(struct device *dev, 363static ssize_t regulator_total_uA_show(struct device *dev,
338 struct device_attribute *attr, char *buf) 364 struct device_attribute *attr, char *buf)
@@ -347,6 +373,7 @@ static ssize_t regulator_total_uA_show(struct device *dev,
347 mutex_unlock(&rdev->mutex); 373 mutex_unlock(&rdev->mutex);
348 return sprintf(buf, "%d\n", uA); 374 return sprintf(buf, "%d\n", uA);
349} 375}
376static DEVICE_ATTR(requested_microamps, 0444, regulator_total_uA_show, NULL);
350 377
351static ssize_t regulator_num_users_show(struct device *dev, 378static ssize_t regulator_num_users_show(struct device *dev,
352 struct device_attribute *attr, char *buf) 379 struct device_attribute *attr, char *buf)
@@ -374,153 +401,106 @@ static ssize_t regulator_suspend_mem_uV_show(struct device *dev,
374{ 401{
375 struct regulator_dev *rdev = dev_get_drvdata(dev); 402 struct regulator_dev *rdev = dev_get_drvdata(dev);
376 403
377 if (!rdev->constraints)
378 return sprintf(buf, "not defined\n");
379 return sprintf(buf, "%d\n", rdev->constraints->state_mem.uV); 404 return sprintf(buf, "%d\n", rdev->constraints->state_mem.uV);
380} 405}
406static DEVICE_ATTR(suspend_mem_microvolts, 0444,
407 regulator_suspend_mem_uV_show, NULL);
381 408
382static ssize_t regulator_suspend_disk_uV_show(struct device *dev, 409static ssize_t regulator_suspend_disk_uV_show(struct device *dev,
383 struct device_attribute *attr, char *buf) 410 struct device_attribute *attr, char *buf)
384{ 411{
385 struct regulator_dev *rdev = dev_get_drvdata(dev); 412 struct regulator_dev *rdev = dev_get_drvdata(dev);
386 413
387 if (!rdev->constraints)
388 return sprintf(buf, "not defined\n");
389 return sprintf(buf, "%d\n", rdev->constraints->state_disk.uV); 414 return sprintf(buf, "%d\n", rdev->constraints->state_disk.uV);
390} 415}
416static DEVICE_ATTR(suspend_disk_microvolts, 0444,
417 regulator_suspend_disk_uV_show, NULL);
391 418
392static ssize_t regulator_suspend_standby_uV_show(struct device *dev, 419static ssize_t regulator_suspend_standby_uV_show(struct device *dev,
393 struct device_attribute *attr, char *buf) 420 struct device_attribute *attr, char *buf)
394{ 421{
395 struct regulator_dev *rdev = dev_get_drvdata(dev); 422 struct regulator_dev *rdev = dev_get_drvdata(dev);
396 423
397 if (!rdev->constraints)
398 return sprintf(buf, "not defined\n");
399 return sprintf(buf, "%d\n", rdev->constraints->state_standby.uV); 424 return sprintf(buf, "%d\n", rdev->constraints->state_standby.uV);
400} 425}
401 426static DEVICE_ATTR(suspend_standby_microvolts, 0444,
402static ssize_t suspend_opmode_show(struct regulator_dev *rdev, 427 regulator_suspend_standby_uV_show, NULL);
403 unsigned int mode, char *buf)
404{
405 switch (mode) {
406 case REGULATOR_MODE_FAST:
407 return sprintf(buf, "fast\n");
408 case REGULATOR_MODE_NORMAL:
409 return sprintf(buf, "normal\n");
410 case REGULATOR_MODE_IDLE:
411 return sprintf(buf, "idle\n");
412 case REGULATOR_MODE_STANDBY:
413 return sprintf(buf, "standby\n");
414 }
415 return sprintf(buf, "unknown\n");
416}
417 428
418static ssize_t regulator_suspend_mem_mode_show(struct device *dev, 429static ssize_t regulator_suspend_mem_mode_show(struct device *dev,
419 struct device_attribute *attr, char *buf) 430 struct device_attribute *attr, char *buf)
420{ 431{
421 struct regulator_dev *rdev = dev_get_drvdata(dev); 432 struct regulator_dev *rdev = dev_get_drvdata(dev);
422 433
423 if (!rdev->constraints) 434 return regulator_print_opmode(buf,
424 return sprintf(buf, "not defined\n"); 435 rdev->constraints->state_mem.mode);
425 return suspend_opmode_show(rdev,
426 rdev->constraints->state_mem.mode, buf);
427} 436}
437static DEVICE_ATTR(suspend_mem_mode, 0444,
438 regulator_suspend_mem_mode_show, NULL);
428 439
429static ssize_t regulator_suspend_disk_mode_show(struct device *dev, 440static ssize_t regulator_suspend_disk_mode_show(struct device *dev,
430 struct device_attribute *attr, char *buf) 441 struct device_attribute *attr, char *buf)
431{ 442{
432 struct regulator_dev *rdev = dev_get_drvdata(dev); 443 struct regulator_dev *rdev = dev_get_drvdata(dev);
433 444
434 if (!rdev->constraints) 445 return regulator_print_opmode(buf,
435 return sprintf(buf, "not defined\n"); 446 rdev->constraints->state_disk.mode);
436 return suspend_opmode_show(rdev,
437 rdev->constraints->state_disk.mode, buf);
438} 447}
448static DEVICE_ATTR(suspend_disk_mode, 0444,
449 regulator_suspend_disk_mode_show, NULL);
439 450
440static ssize_t regulator_suspend_standby_mode_show(struct device *dev, 451static ssize_t regulator_suspend_standby_mode_show(struct device *dev,
441 struct device_attribute *attr, char *buf) 452 struct device_attribute *attr, char *buf)
442{ 453{
443 struct regulator_dev *rdev = dev_get_drvdata(dev); 454 struct regulator_dev *rdev = dev_get_drvdata(dev);
444 455
445 if (!rdev->constraints) 456 return regulator_print_opmode(buf,
446 return sprintf(buf, "not defined\n"); 457 rdev->constraints->state_standby.mode);
447 return suspend_opmode_show(rdev,
448 rdev->constraints->state_standby.mode, buf);
449} 458}
459static DEVICE_ATTR(suspend_standby_mode, 0444,
460 regulator_suspend_standby_mode_show, NULL);
450 461
451static ssize_t regulator_suspend_mem_state_show(struct device *dev, 462static ssize_t regulator_suspend_mem_state_show(struct device *dev,
452 struct device_attribute *attr, char *buf) 463 struct device_attribute *attr, char *buf)
453{ 464{
454 struct regulator_dev *rdev = dev_get_drvdata(dev); 465 struct regulator_dev *rdev = dev_get_drvdata(dev);
455 466
456 if (!rdev->constraints) 467 return regulator_print_state(buf,
457 return sprintf(buf, "not defined\n"); 468 rdev->constraints->state_mem.enabled);
458
459 if (rdev->constraints->state_mem.enabled)
460 return sprintf(buf, "enabled\n");
461 else
462 return sprintf(buf, "disabled\n");
463} 469}
470static DEVICE_ATTR(suspend_mem_state, 0444,
471 regulator_suspend_mem_state_show, NULL);
464 472
465static ssize_t regulator_suspend_disk_state_show(struct device *dev, 473static ssize_t regulator_suspend_disk_state_show(struct device *dev,
466 struct device_attribute *attr, char *buf) 474 struct device_attribute *attr, char *buf)
467{ 475{
468 struct regulator_dev *rdev = dev_get_drvdata(dev); 476 struct regulator_dev *rdev = dev_get_drvdata(dev);
469 477
470 if (!rdev->constraints) 478 return regulator_print_state(buf,
471 return sprintf(buf, "not defined\n"); 479 rdev->constraints->state_disk.enabled);
472
473 if (rdev->constraints->state_disk.enabled)
474 return sprintf(buf, "enabled\n");
475 else
476 return sprintf(buf, "disabled\n");
477} 480}
481static DEVICE_ATTR(suspend_disk_state, 0444,
482 regulator_suspend_disk_state_show, NULL);
478 483
479static ssize_t regulator_suspend_standby_state_show(struct device *dev, 484static ssize_t regulator_suspend_standby_state_show(struct device *dev,
480 struct device_attribute *attr, char *buf) 485 struct device_attribute *attr, char *buf)
481{ 486{
482 struct regulator_dev *rdev = dev_get_drvdata(dev); 487 struct regulator_dev *rdev = dev_get_drvdata(dev);
483 488
484 if (!rdev->constraints) 489 return regulator_print_state(buf,
485 return sprintf(buf, "not defined\n"); 490 rdev->constraints->state_standby.enabled);
486
487 if (rdev->constraints->state_standby.enabled)
488 return sprintf(buf, "enabled\n");
489 else
490 return sprintf(buf, "disabled\n");
491} 491}
492static DEVICE_ATTR(suspend_standby_state, 0444,
493 regulator_suspend_standby_state_show, NULL);
492 494
495
496/*
497 * These are the only attributes are present for all regulators.
498 * Other attributes are a function of regulator functionality.
499 */
493static struct device_attribute regulator_dev_attrs[] = { 500static struct device_attribute regulator_dev_attrs[] = {
494 __ATTR(name, 0444, regulator_name_show, NULL), 501 __ATTR(name, 0444, regulator_name_show, NULL),
495 __ATTR(microvolts, 0444, regulator_uV_show, NULL),
496 __ATTR(microamps, 0444, regulator_uA_show, NULL),
497 __ATTR(opmode, 0444, regulator_opmode_show, NULL),
498 __ATTR(state, 0444, regulator_state_show, NULL),
499 __ATTR(min_microvolts, 0444, regulator_min_uV_show, NULL),
500 __ATTR(min_microamps, 0444, regulator_min_uA_show, NULL),
501 __ATTR(max_microvolts, 0444, regulator_max_uV_show, NULL),
502 __ATTR(max_microamps, 0444, regulator_max_uA_show, NULL),
503 __ATTR(requested_microamps, 0444, regulator_total_uA_show, NULL),
504 __ATTR(num_users, 0444, regulator_num_users_show, NULL), 502 __ATTR(num_users, 0444, regulator_num_users_show, NULL),
505 __ATTR(type, 0444, regulator_type_show, NULL), 503 __ATTR(type, 0444, regulator_type_show, NULL),
506 __ATTR(suspend_mem_microvolts, 0444,
507 regulator_suspend_mem_uV_show, NULL),
508 __ATTR(suspend_disk_microvolts, 0444,
509 regulator_suspend_disk_uV_show, NULL),
510 __ATTR(suspend_standby_microvolts, 0444,
511 regulator_suspend_standby_uV_show, NULL),
512 __ATTR(suspend_mem_mode, 0444,
513 regulator_suspend_mem_mode_show, NULL),
514 __ATTR(suspend_disk_mode, 0444,
515 regulator_suspend_disk_mode_show, NULL),
516 __ATTR(suspend_standby_mode, 0444,
517 regulator_suspend_standby_mode_show, NULL),
518 __ATTR(suspend_mem_state, 0444,
519 regulator_suspend_mem_state_show, NULL),
520 __ATTR(suspend_disk_state, 0444,
521 regulator_suspend_disk_state_show, NULL),
522 __ATTR(suspend_standby_state, 0444,
523 regulator_suspend_standby_state_show, NULL),
524 __ATTR_NULL, 504 __ATTR_NULL,
525}; 505};
526 506
@@ -675,7 +655,8 @@ static void print_constraints(struct regulator_dev *rdev)
675 655
676/** 656/**
677 * set_machine_constraints - sets regulator constraints 657 * set_machine_constraints - sets regulator constraints
678 * @regulator: regulator source 658 * @rdev: regulator source
659 * @constraints: constraints to apply
679 * 660 *
680 * Allows platform initialisation code to define and constrain 661 * Allows platform initialisation code to define and constrain
681 * regulator circuits e.g. valid voltage/current ranges, etc. NOTE: 662 * regulator circuits e.g. valid voltage/current ranges, etc. NOTE:
@@ -750,8 +731,8 @@ out:
750 731
751/** 732/**
752 * set_supply - set regulator supply regulator 733 * set_supply - set regulator supply regulator
753 * @regulator: regulator name 734 * @rdev: regulator name
754 * @supply: supply regulator name 735 * @supply_rdev: supply regulator name
755 * 736 *
756 * Called by platform initialisation code to set the supply regulator for this 737 * Called by platform initialisation code to set the supply regulator for this
757 * regulator. This ensures that a regulators supply will also be enabled by the 738 * regulator. This ensures that a regulators supply will also be enabled by the
@@ -778,9 +759,9 @@ out:
778 759
779/** 760/**
780 * set_consumer_device_supply: Bind a regulator to a symbolic supply 761 * set_consumer_device_supply: Bind a regulator to a symbolic supply
781 * @regulator: regulator source 762 * @rdev: regulator source
782 * @dev: device the supply applies to 763 * @consumer_dev: device the supply applies to
783 * @supply: symbolic name for supply 764 * @supply: symbolic name for supply
784 * 765 *
785 * Allows platform initialisation code to map physical regulator 766 * Allows platform initialisation code to map physical regulator
786 * sources to symbolic names for supplies for use by devices. Devices 767 * sources to symbolic names for supplies for use by devices. Devices
@@ -795,6 +776,20 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
795 if (supply == NULL) 776 if (supply == NULL)
796 return -EINVAL; 777 return -EINVAL;
797 778
779 list_for_each_entry(node, &regulator_map_list, list) {
780 if (consumer_dev != node->dev)
781 continue;
782 if (strcmp(node->supply, supply) != 0)
783 continue;
784
785 dev_dbg(consumer_dev, "%s/%s is '%s' supply; fail %s/%s\n",
786 dev_name(&node->regulator->dev),
787 node->regulator->desc->name,
788 supply,
789 dev_name(&rdev->dev), rdev->desc->name);
790 return -EBUSY;
791 }
792
798 node = kmalloc(sizeof(struct regulator_map), GFP_KERNEL); 793 node = kmalloc(sizeof(struct regulator_map), GFP_KERNEL);
799 if (node == NULL) 794 if (node == NULL)
800 return -ENOMEM; 795 return -ENOMEM;
@@ -963,16 +958,13 @@ void regulator_put(struct regulator *regulator)
963 if (regulator == NULL || IS_ERR(regulator)) 958 if (regulator == NULL || IS_ERR(regulator))
964 return; 959 return;
965 960
966 if (regulator->enabled) {
967 printk(KERN_WARNING "Releasing supply %s while enabled\n",
968 regulator->supply_name);
969 WARN_ON(regulator->enabled);
970 regulator_disable(regulator);
971 }
972
973 mutex_lock(&regulator_list_mutex); 961 mutex_lock(&regulator_list_mutex);
974 rdev = regulator->rdev; 962 rdev = regulator->rdev;
975 963
964 if (WARN(regulator->enabled, "Releasing supply %s while enabled\n",
965 regulator->supply_name))
966 _regulator_disable(rdev);
967
976 /* remove any sysfs entries */ 968 /* remove any sysfs entries */
977 if (regulator->dev) { 969 if (regulator->dev) {
978 sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name); 970 sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name);
@@ -1034,29 +1026,26 @@ static int _regulator_enable(struct regulator_dev *rdev)
1034 * regulator_enable - enable regulator output 1026 * regulator_enable - enable regulator output
1035 * @regulator: regulator source 1027 * @regulator: regulator source
1036 * 1028 *
1037 * Enable the regulator output at the predefined voltage or current value. 1029 * Request that the regulator be enabled with the regulator output at
1030 * the predefined voltage or current value. Calls to regulator_enable()
1031 * must be balanced with calls to regulator_disable().
1032 *
1038 * NOTE: the output value can be set by other drivers, boot loader or may be 1033 * NOTE: the output value can be set by other drivers, boot loader or may be
1039 * hardwired in the regulator. 1034 * hardwired in the regulator.
1040 * NOTE: calls to regulator_enable() must be balanced with calls to
1041 * regulator_disable().
1042 */ 1035 */
1043int regulator_enable(struct regulator *regulator) 1036int regulator_enable(struct regulator *regulator)
1044{ 1037{
1045 int ret; 1038 struct regulator_dev *rdev = regulator->rdev;
1046 1039 int ret = 0;
1047 if (regulator->enabled) {
1048 printk(KERN_CRIT "Regulator %s already enabled\n",
1049 regulator->supply_name);
1050 WARN_ON(regulator->enabled);
1051 return 0;
1052 }
1053 1040
1054 mutex_lock(&regulator->rdev->mutex); 1041 mutex_lock(&rdev->mutex);
1055 regulator->enabled = 1; 1042 if (regulator->enabled == 0)
1056 ret = _regulator_enable(regulator->rdev); 1043 ret = _regulator_enable(rdev);
1057 if (ret != 0) 1044 else if (regulator->enabled < 0)
1058 regulator->enabled = 0; 1045 ret = -EIO;
1059 mutex_unlock(&regulator->rdev->mutex); 1046 if (ret == 0)
1047 regulator->enabled++;
1048 mutex_unlock(&rdev->mutex);
1060 return ret; 1049 return ret;
1061} 1050}
1062EXPORT_SYMBOL_GPL(regulator_enable); 1051EXPORT_SYMBOL_GPL(regulator_enable);
@@ -1100,27 +1089,31 @@ static int _regulator_disable(struct regulator_dev *rdev)
1100 * regulator_disable - disable regulator output 1089 * regulator_disable - disable regulator output
1101 * @regulator: regulator source 1090 * @regulator: regulator source
1102 * 1091 *
1103 * Disable the regulator output voltage or current. 1092 * Disable the regulator output voltage or current. Calls to
1104 * NOTE: this will only disable the regulator output if no other consumer 1093 * regulator_enable() must be balanced with calls to
1105 * devices have it enabled.
1106 * NOTE: calls to regulator_enable() must be balanced with calls to
1107 * regulator_disable(). 1094 * regulator_disable().
1095 *
1096 * NOTE: this will only disable the regulator output if no other consumer
1097 * devices have it enabled, the regulator device supports disabling and
1098 * machine constraints permit this operation.
1108 */ 1099 */
1109int regulator_disable(struct regulator *regulator) 1100int regulator_disable(struct regulator *regulator)
1110{ 1101{
1111 int ret; 1102 struct regulator_dev *rdev = regulator->rdev;
1112 1103 int ret = 0;
1113 if (!regulator->enabled) {
1114 printk(KERN_ERR "%s: not in use by this consumer\n",
1115 __func__);
1116 return 0;
1117 }
1118 1104
1119 mutex_lock(&regulator->rdev->mutex); 1105 mutex_lock(&rdev->mutex);
1120 regulator->enabled = 0; 1106 if (regulator->enabled == 1) {
1121 regulator->uA_load = 0; 1107 ret = _regulator_disable(rdev);
1122 ret = _regulator_disable(regulator->rdev); 1108 if (ret == 0)
1123 mutex_unlock(&regulator->rdev->mutex); 1109 regulator->uA_load = 0;
1110 } else if (WARN(regulator->enabled <= 0,
1111 "unbalanced disables for supply %s\n",
1112 regulator->supply_name))
1113 ret = -EIO;
1114 if (ret == 0)
1115 regulator->enabled--;
1116 mutex_unlock(&rdev->mutex);
1124 return ret; 1117 return ret;
1125} 1118}
1126EXPORT_SYMBOL_GPL(regulator_disable); 1119EXPORT_SYMBOL_GPL(regulator_disable);
@@ -1196,7 +1189,13 @@ out:
1196 * regulator_is_enabled - is the regulator output enabled 1189 * regulator_is_enabled - is the regulator output enabled
1197 * @regulator: regulator source 1190 * @regulator: regulator source
1198 * 1191 *
1199 * Returns zero for disabled otherwise return number of enable requests. 1192 * Returns positive if the regulator driver backing the source/client
1193 * has requested that the device be enabled, zero if it hasn't, else a
1194 * negative errno code.
1195 *
1196 * Note that the device backing this regulator handle can have multiple
1197 * users, so it might be enabled even if regulator_enable() was never
1198 * called for this particular source.
1200 */ 1199 */
1201int regulator_is_enabled(struct regulator *regulator) 1200int regulator_is_enabled(struct regulator *regulator)
1202{ 1201{
@@ -1219,7 +1218,7 @@ EXPORT_SYMBOL_GPL(regulator_is_enabled);
1219 * 1218 *
1220 * NOTE: If the regulator is shared between several devices then the lowest 1219 * NOTE: If the regulator is shared between several devices then the lowest
1221 * request voltage that meets the system constraints will be used. 1220 * request voltage that meets the system constraints will be used.
1222 * NOTE: Regulator system constraints must be set for this regulator before 1221 * Regulator system constraints must be set for this regulator before
1223 * calling this function otherwise this call will fail. 1222 * calling this function otherwise this call will fail.
1224 */ 1223 */
1225int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV) 1224int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
@@ -1493,7 +1492,8 @@ int regulator_set_optimum_mode(struct regulator *regulator, int uA_load)
1493 mode = rdev->desc->ops->get_optimum_mode(rdev, 1492 mode = rdev->desc->ops->get_optimum_mode(rdev,
1494 input_uV, output_uV, 1493 input_uV, output_uV,
1495 total_uA_load); 1494 total_uA_load);
1496 if (ret <= 0) { 1495 ret = regulator_check_mode(rdev, mode);
1496 if (ret < 0) {
1497 printk(KERN_ERR "%s: failed to get optimum mode for %s @" 1497 printk(KERN_ERR "%s: failed to get optimum mode for %s @"
1498 " %d uA %d -> %d uV\n", __func__, rdev->desc->name, 1498 " %d uA %d -> %d uV\n", __func__, rdev->desc->name,
1499 total_uA_load, input_uV, output_uV); 1499 total_uA_load, input_uV, output_uV);
@@ -1501,7 +1501,7 @@ int regulator_set_optimum_mode(struct regulator *regulator, int uA_load)
1501 } 1501 }
1502 1502
1503 ret = rdev->desc->ops->set_mode(rdev, mode); 1503 ret = rdev->desc->ops->set_mode(rdev, mode);
1504 if (ret <= 0) { 1504 if (ret < 0) {
1505 printk(KERN_ERR "%s: failed to set optimum mode %x for %s\n", 1505 printk(KERN_ERR "%s: failed to set optimum mode %x for %s\n",
1506 __func__, mode, rdev->desc->name); 1506 __func__, mode, rdev->desc->name);
1507 goto out; 1507 goto out;
@@ -1516,7 +1516,7 @@ EXPORT_SYMBOL_GPL(regulator_set_optimum_mode);
1516/** 1516/**
1517 * regulator_register_notifier - register regulator event notifier 1517 * regulator_register_notifier - register regulator event notifier
1518 * @regulator: regulator source 1518 * @regulator: regulator source
1519 * @notifier_block: notifier block 1519 * @nb: notifier block
1520 * 1520 *
1521 * Register notifier block to receive regulator events. 1521 * Register notifier block to receive regulator events.
1522 */ 1522 */
@@ -1531,7 +1531,7 @@ EXPORT_SYMBOL_GPL(regulator_register_notifier);
1531/** 1531/**
1532 * regulator_unregister_notifier - unregister regulator event notifier 1532 * regulator_unregister_notifier - unregister regulator event notifier
1533 * @regulator: regulator source 1533 * @regulator: regulator source
1534 * @notifier_block: notifier block 1534 * @nb: notifier block
1535 * 1535 *
1536 * Unregister regulator event notifier block. 1536 * Unregister regulator event notifier block.
1537 */ 1537 */
@@ -1697,9 +1697,9 @@ EXPORT_SYMBOL_GPL(regulator_bulk_free);
1697 1697
1698/** 1698/**
1699 * regulator_notifier_call_chain - call regulator event notifier 1699 * regulator_notifier_call_chain - call regulator event notifier
1700 * @regulator: regulator source 1700 * @rdev: regulator source
1701 * @event: notifier block 1701 * @event: notifier block
1702 * @data: 1702 * @data: callback-specific data.
1703 * 1703 *
1704 * Called by regulator drivers to notify clients a regulator event has 1704 * Called by regulator drivers to notify clients a regulator event has
1705 * occurred. We also notify regulator clients downstream. 1705 * occurred. We also notify regulator clients downstream.
@@ -1713,10 +1713,122 @@ int regulator_notifier_call_chain(struct regulator_dev *rdev,
1713} 1713}
1714EXPORT_SYMBOL_GPL(regulator_notifier_call_chain); 1714EXPORT_SYMBOL_GPL(regulator_notifier_call_chain);
1715 1715
1716/*
1717 * To avoid cluttering sysfs (and memory) with useless state, only
1718 * create attributes that can be meaningfully displayed.
1719 */
1720static int add_regulator_attributes(struct regulator_dev *rdev)
1721{
1722 struct device *dev = &rdev->dev;
1723 struct regulator_ops *ops = rdev->desc->ops;
1724 int status = 0;
1725
1726 /* some attributes need specific methods to be displayed */
1727 if (ops->get_voltage) {
1728 status = device_create_file(dev, &dev_attr_microvolts);
1729 if (status < 0)
1730 return status;
1731 }
1732 if (ops->get_current_limit) {
1733 status = device_create_file(dev, &dev_attr_microamps);
1734 if (status < 0)
1735 return status;
1736 }
1737 if (ops->get_mode) {
1738 status = device_create_file(dev, &dev_attr_opmode);
1739 if (status < 0)
1740 return status;
1741 }
1742 if (ops->is_enabled) {
1743 status = device_create_file(dev, &dev_attr_state);
1744 if (status < 0)
1745 return status;
1746 }
1747
1748 /* some attributes are type-specific */
1749 if (rdev->desc->type == REGULATOR_CURRENT) {
1750 status = device_create_file(dev, &dev_attr_requested_microamps);
1751 if (status < 0)
1752 return status;
1753 }
1754
1755 /* all the other attributes exist to support constraints;
1756 * don't show them if there are no constraints, or if the
1757 * relevant supporting methods are missing.
1758 */
1759 if (!rdev->constraints)
1760 return status;
1761
1762 /* constraints need specific supporting methods */
1763 if (ops->set_voltage) {
1764 status = device_create_file(dev, &dev_attr_min_microvolts);
1765 if (status < 0)
1766 return status;
1767 status = device_create_file(dev, &dev_attr_max_microvolts);
1768 if (status < 0)
1769 return status;
1770 }
1771 if (ops->set_current_limit) {
1772 status = device_create_file(dev, &dev_attr_min_microamps);
1773 if (status < 0)
1774 return status;
1775 status = device_create_file(dev, &dev_attr_max_microamps);
1776 if (status < 0)
1777 return status;
1778 }
1779
1780 /* suspend mode constraints need multiple supporting methods */
1781 if (!(ops->set_suspend_enable && ops->set_suspend_disable))
1782 return status;
1783
1784 status = device_create_file(dev, &dev_attr_suspend_standby_state);
1785 if (status < 0)
1786 return status;
1787 status = device_create_file(dev, &dev_attr_suspend_mem_state);
1788 if (status < 0)
1789 return status;
1790 status = device_create_file(dev, &dev_attr_suspend_disk_state);
1791 if (status < 0)
1792 return status;
1793
1794 if (ops->set_suspend_voltage) {
1795 status = device_create_file(dev,
1796 &dev_attr_suspend_standby_microvolts);
1797 if (status < 0)
1798 return status;
1799 status = device_create_file(dev,
1800 &dev_attr_suspend_mem_microvolts);
1801 if (status < 0)
1802 return status;
1803 status = device_create_file(dev,
1804 &dev_attr_suspend_disk_microvolts);
1805 if (status < 0)
1806 return status;
1807 }
1808
1809 if (ops->set_suspend_mode) {
1810 status = device_create_file(dev,
1811 &dev_attr_suspend_standby_mode);
1812 if (status < 0)
1813 return status;
1814 status = device_create_file(dev,
1815 &dev_attr_suspend_mem_mode);
1816 if (status < 0)
1817 return status;
1818 status = device_create_file(dev,
1819 &dev_attr_suspend_disk_mode);
1820 if (status < 0)
1821 return status;
1822 }
1823
1824 return status;
1825}
1826
1716/** 1827/**
1717 * regulator_register - register regulator 1828 * regulator_register - register regulator
1718 * @regulator: regulator source 1829 * @regulator_desc: regulator to register
1719 * @reg_data: private regulator data 1830 * @dev: struct device for the regulator
1831 * @driver_data: private regulator data
1720 * 1832 *
1721 * Called by regulator drivers to register a regulator. 1833 * Called by regulator drivers to register a regulator.
1722 * Returns 0 on success. 1834 * Returns 0 on success.
@@ -1761,45 +1873,37 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
1761 /* preform any regulator specific init */ 1873 /* preform any regulator specific init */
1762 if (init_data->regulator_init) { 1874 if (init_data->regulator_init) {
1763 ret = init_data->regulator_init(rdev->reg_data); 1875 ret = init_data->regulator_init(rdev->reg_data);
1764 if (ret < 0) { 1876 if (ret < 0)
1765 kfree(rdev); 1877 goto clean;
1766 rdev = ERR_PTR(ret);
1767 goto out;
1768 }
1769 }
1770
1771 /* set regulator constraints */
1772 ret = set_machine_constraints(rdev, &init_data->constraints);
1773 if (ret < 0) {
1774 kfree(rdev);
1775 rdev = ERR_PTR(ret);
1776 goto out;
1777 } 1878 }
1778 1879
1779 /* register with sysfs */ 1880 /* register with sysfs */
1780 rdev->dev.class = &regulator_class; 1881 rdev->dev.class = &regulator_class;
1781 rdev->dev.parent = dev; 1882 rdev->dev.parent = dev;
1782 snprintf(rdev->dev.bus_id, sizeof(rdev->dev.bus_id), 1883 dev_set_name(&rdev->dev, "regulator.%d",
1783 "regulator.%d", atomic_inc_return(&regulator_no) - 1); 1884 atomic_inc_return(&regulator_no) - 1);
1784 ret = device_register(&rdev->dev); 1885 ret = device_register(&rdev->dev);
1785 if (ret != 0) { 1886 if (ret != 0)
1786 kfree(rdev); 1887 goto clean;
1787 rdev = ERR_PTR(ret);
1788 goto out;
1789 }
1790 1888
1791 dev_set_drvdata(&rdev->dev, rdev); 1889 dev_set_drvdata(&rdev->dev, rdev);
1792 1890
1891 /* set regulator constraints */
1892 ret = set_machine_constraints(rdev, &init_data->constraints);
1893 if (ret < 0)
1894 goto scrub;
1895
1896 /* add attributes supported by this regulator */
1897 ret = add_regulator_attributes(rdev);
1898 if (ret < 0)
1899 goto scrub;
1900
1793 /* set supply regulator if it exists */ 1901 /* set supply regulator if it exists */
1794 if (init_data->supply_regulator_dev) { 1902 if (init_data->supply_regulator_dev) {
1795 ret = set_supply(rdev, 1903 ret = set_supply(rdev,
1796 dev_get_drvdata(init_data->supply_regulator_dev)); 1904 dev_get_drvdata(init_data->supply_regulator_dev));
1797 if (ret < 0) { 1905 if (ret < 0)
1798 device_unregister(&rdev->dev); 1906 goto scrub;
1799 kfree(rdev);
1800 rdev = ERR_PTR(ret);
1801 goto out;
1802 }
1803 } 1907 }
1804 1908
1805 /* add consumers devices */ 1909 /* add consumers devices */
@@ -1811,10 +1915,7 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
1811 for (--i; i >= 0; i--) 1915 for (--i; i >= 0; i--)
1812 unset_consumer_device_supply(rdev, 1916 unset_consumer_device_supply(rdev,
1813 init_data->consumer_supplies[i].dev); 1917 init_data->consumer_supplies[i].dev);
1814 device_unregister(&rdev->dev); 1918 goto scrub;
1815 kfree(rdev);
1816 rdev = ERR_PTR(ret);
1817 goto out;
1818 } 1919 }
1819 } 1920 }
1820 1921
@@ -1822,12 +1923,19 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
1822out: 1923out:
1823 mutex_unlock(&regulator_list_mutex); 1924 mutex_unlock(&regulator_list_mutex);
1824 return rdev; 1925 return rdev;
1926
1927scrub:
1928 device_unregister(&rdev->dev);
1929clean:
1930 kfree(rdev);
1931 rdev = ERR_PTR(ret);
1932 goto out;
1825} 1933}
1826EXPORT_SYMBOL_GPL(regulator_register); 1934EXPORT_SYMBOL_GPL(regulator_register);
1827 1935
1828/** 1936/**
1829 * regulator_unregister - unregister regulator 1937 * regulator_unregister - unregister regulator
1830 * @regulator: regulator source 1938 * @rdev: regulator to unregister
1831 * 1939 *
1832 * Called by regulator drivers to unregister a regulator. 1940 * Called by regulator drivers to unregister a regulator.
1833 */ 1941 */
@@ -1846,7 +1954,7 @@ void regulator_unregister(struct regulator_dev *rdev)
1846EXPORT_SYMBOL_GPL(regulator_unregister); 1954EXPORT_SYMBOL_GPL(regulator_unregister);
1847 1955
1848/** 1956/**
1849 * regulator_suspend_prepare: prepare regulators for system wide suspend 1957 * regulator_suspend_prepare - prepare regulators for system wide suspend
1850 * @state: system suspend state 1958 * @state: system suspend state
1851 * 1959 *
1852 * Configure each regulator with it's suspend operating parameters for state. 1960 * Configure each regulator with it's suspend operating parameters for state.
@@ -1882,7 +1990,7 @@ EXPORT_SYMBOL_GPL(regulator_suspend_prepare);
1882 1990
1883/** 1991/**
1884 * rdev_get_drvdata - get rdev regulator driver data 1992 * rdev_get_drvdata - get rdev regulator driver data
1885 * @regulator: regulator 1993 * @rdev: regulator
1886 * 1994 *
1887 * Get rdev regulator driver private data. This call can be used in the 1995 * Get rdev regulator driver private data. This call can be used in the
1888 * regulator driver context. 1996 * regulator driver context.
@@ -1919,7 +2027,7 @@ EXPORT_SYMBOL_GPL(regulator_set_drvdata);
1919 2027
1920/** 2028/**
1921 * regulator_get_id - get regulator ID 2029 * regulator_get_id - get regulator ID
1922 * @regulator: regulator 2030 * @rdev: regulator
1923 */ 2031 */
1924int rdev_get_id(struct regulator_dev *rdev) 2032int rdev_get_id(struct regulator_dev *rdev)
1925{ 2033{
diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c
index 773b29cec8be..fe77730a7edb 100644
--- a/drivers/regulator/da903x.c
+++ b/drivers/regulator/da903x.c
@@ -102,7 +102,7 @@ static int da903x_set_ldo_voltage(struct regulator_dev *rdev,
102 uint8_t val, mask; 102 uint8_t val, mask;
103 103
104 if (check_range(info, min_uV, max_uV)) { 104 if (check_range(info, min_uV, max_uV)) {
105 pr_err("invalid voltage range (%d, %d) uV", min_uV, max_uV); 105 pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
106 return -EINVAL; 106 return -EINVAL;
107 } 107 }
108 108
@@ -159,7 +159,7 @@ static int da903x_is_enabled(struct regulator_dev *rdev)
159 if (ret) 159 if (ret)
160 return ret; 160 return ret;
161 161
162 return reg_val & (1 << info->enable_bit); 162 return !!(reg_val & (1 << info->enable_bit));
163} 163}
164 164
165/* DA9030 specific operations */ 165/* DA9030 specific operations */
@@ -172,7 +172,7 @@ static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev,
172 int ret; 172 int ret;
173 173
174 if (check_range(info, min_uV, max_uV)) { 174 if (check_range(info, min_uV, max_uV)) {
175 pr_err("invalid voltage range (%d, %d) uV", min_uV, max_uV); 175 pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
176 return -EINVAL; 176 return -EINVAL;
177 } 177 }
178 178
@@ -199,7 +199,7 @@ static int da9030_set_ldo14_voltage(struct regulator_dev *rdev,
199 int thresh; 199 int thresh;
200 200
201 if (check_range(info, min_uV, max_uV)) { 201 if (check_range(info, min_uV, max_uV)) {
202 pr_err("invalid voltage range (%d, %d) uV", min_uV, max_uV); 202 pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
203 return -EINVAL; 203 return -EINVAL;
204 } 204 }
205 205
@@ -248,7 +248,7 @@ static int da9034_set_dvc_voltage(struct regulator_dev *rdev,
248 int ret; 248 int ret;
249 249
250 if (check_range(info, min_uV, max_uV)) { 250 if (check_range(info, min_uV, max_uV)) {
251 pr_err("invalid voltage range (%d, %d) uV", min_uV, max_uV); 251 pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
252 return -EINVAL; 252 return -EINVAL;
253 } 253 }
254 254
@@ -273,7 +273,7 @@ static int da9034_set_ldo12_voltage(struct regulator_dev *rdev,
273 uint8_t val, mask; 273 uint8_t val, mask;
274 274
275 if (check_range(info, min_uV, max_uV)) { 275 if (check_range(info, min_uV, max_uV)) {
276 pr_err("invalid voltage range (%d, %d) uV", min_uV, max_uV); 276 pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
277 return -EINVAL; 277 return -EINVAL;
278 } 278 }
279 279
diff --git a/drivers/regulator/pcf50633-regulator.c b/drivers/regulator/pcf50633-regulator.c
new file mode 100644
index 000000000000..4cc85ec6e120
--- /dev/null
+++ b/drivers/regulator/pcf50633-regulator.c
@@ -0,0 +1,329 @@
1/* NXP PCF50633 PMIC Driver
2 *
3 * (C) 2006-2008 by Openmoko, Inc.
4 * Author: Balaji Rao <balajirrao@openmoko.org>
5 * All rights reserved.
6 *
7 * Broken down from monstrous PCF50633 driver mainly by
8 * Harald Welte and Andy Green and Werner Almesberger
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/init.h>
20#include <linux/device.h>
21#include <linux/err.h>
22#include <linux/platform_device.h>
23
24#include <linux/mfd/pcf50633/core.h>
25#include <linux/mfd/pcf50633/pmic.h>
26
27#define PCF50633_REGULATOR(_name, _id) \
28 { \
29 .name = _name, \
30 .id = _id, \
31 .ops = &pcf50633_regulator_ops, \
32 .type = REGULATOR_VOLTAGE, \
33 .owner = THIS_MODULE, \
34 }
35
36static const u8 pcf50633_regulator_registers[PCF50633_NUM_REGULATORS] = {
37 [PCF50633_REGULATOR_AUTO] = PCF50633_REG_AUTOOUT,
38 [PCF50633_REGULATOR_DOWN1] = PCF50633_REG_DOWN1OUT,
39 [PCF50633_REGULATOR_DOWN2] = PCF50633_REG_DOWN2OUT,
40 [PCF50633_REGULATOR_MEMLDO] = PCF50633_REG_MEMLDOOUT,
41 [PCF50633_REGULATOR_LDO1] = PCF50633_REG_LDO1OUT,
42 [PCF50633_REGULATOR_LDO2] = PCF50633_REG_LDO2OUT,
43 [PCF50633_REGULATOR_LDO3] = PCF50633_REG_LDO3OUT,
44 [PCF50633_REGULATOR_LDO4] = PCF50633_REG_LDO4OUT,
45 [PCF50633_REGULATOR_LDO5] = PCF50633_REG_LDO5OUT,
46 [PCF50633_REGULATOR_LDO6] = PCF50633_REG_LDO6OUT,
47 [PCF50633_REGULATOR_HCLDO] = PCF50633_REG_HCLDOOUT,
48};
49
50/* Bits from voltage value */
51static u8 auto_voltage_bits(unsigned int millivolts)
52{
53 if (millivolts < 1800)
54 return 0;
55 if (millivolts > 3800)
56 return 0xff;
57
58 millivolts -= 625;
59
60 return millivolts / 25;
61}
62
63static u8 down_voltage_bits(unsigned int millivolts)
64{
65 if (millivolts < 625)
66 return 0;
67 else if (millivolts > 3000)
68 return 0xff;
69
70 millivolts -= 625;
71
72 return millivolts / 25;
73}
74
75static u8 ldo_voltage_bits(unsigned int millivolts)
76{
77 if (millivolts < 900)
78 return 0;
79 else if (millivolts > 3600)
80 return 0x1f;
81
82 millivolts -= 900;
83 return millivolts / 100;
84}
85
86/* Obtain voltage value from bits */
87static unsigned int auto_voltage_value(u8 bits)
88{
89 if (bits < 0x2f)
90 return 0;
91
92 return 625 + (bits * 25);
93}
94
95
96static unsigned int down_voltage_value(u8 bits)
97{
98 return 625 + (bits * 25);
99}
100
101
102static unsigned int ldo_voltage_value(u8 bits)
103{
104 bits &= 0x1f;
105
106 return 900 + (bits * 100);
107}
108
109static int pcf50633_regulator_set_voltage(struct regulator_dev *rdev,
110 int min_uV, int max_uV)
111{
112 struct pcf50633 *pcf;
113 int regulator_id, millivolts;
114 u8 volt_bits, regnr;
115
116 pcf = rdev_get_drvdata(rdev);
117
118 regulator_id = rdev_get_id(rdev);
119 if (regulator_id >= PCF50633_NUM_REGULATORS)
120 return -EINVAL;
121
122 millivolts = min_uV / 1000;
123
124 regnr = pcf50633_regulator_registers[regulator_id];
125
126 switch (regulator_id) {
127 case PCF50633_REGULATOR_AUTO:
128 volt_bits = auto_voltage_bits(millivolts);
129 break;
130 case PCF50633_REGULATOR_DOWN1:
131 volt_bits = down_voltage_bits(millivolts);
132 break;
133 case PCF50633_REGULATOR_DOWN2:
134 volt_bits = down_voltage_bits(millivolts);
135 break;
136 case PCF50633_REGULATOR_LDO1:
137 case PCF50633_REGULATOR_LDO2:
138 case PCF50633_REGULATOR_LDO3:
139 case PCF50633_REGULATOR_LDO4:
140 case PCF50633_REGULATOR_LDO5:
141 case PCF50633_REGULATOR_LDO6:
142 case PCF50633_REGULATOR_HCLDO:
143 volt_bits = ldo_voltage_bits(millivolts);
144 break;
145 default:
146 return -EINVAL;
147 }
148
149 return pcf50633_reg_write(pcf, regnr, volt_bits);
150}
151
152static int pcf50633_regulator_get_voltage(struct regulator_dev *rdev)
153{
154 struct pcf50633 *pcf;
155 int regulator_id, millivolts, volt_bits;
156 u8 regnr;
157
158 pcf = rdev_get_drvdata(rdev);;
159
160 regulator_id = rdev_get_id(rdev);
161 if (regulator_id >= PCF50633_NUM_REGULATORS)
162 return -EINVAL;
163
164 regnr = pcf50633_regulator_registers[regulator_id];
165
166 volt_bits = pcf50633_reg_read(pcf, regnr);
167 if (volt_bits < 0)
168 return -1;
169
170 switch (regulator_id) {
171 case PCF50633_REGULATOR_AUTO:
172 millivolts = auto_voltage_value(volt_bits);
173 break;
174 case PCF50633_REGULATOR_DOWN1:
175 millivolts = down_voltage_value(volt_bits);
176 break;
177 case PCF50633_REGULATOR_DOWN2:
178 millivolts = down_voltage_value(volt_bits);
179 break;
180 case PCF50633_REGULATOR_LDO1:
181 case PCF50633_REGULATOR_LDO2:
182 case PCF50633_REGULATOR_LDO3:
183 case PCF50633_REGULATOR_LDO4:
184 case PCF50633_REGULATOR_LDO5:
185 case PCF50633_REGULATOR_LDO6:
186 case PCF50633_REGULATOR_HCLDO:
187 millivolts = ldo_voltage_value(volt_bits);
188 break;
189 default:
190 return -EINVAL;
191 }
192
193 return millivolts * 1000;
194}
195
196static int pcf50633_regulator_enable(struct regulator_dev *rdev)
197{
198 struct pcf50633 *pcf = rdev_get_drvdata(rdev);
199 int regulator_id;
200 u8 regnr;
201
202 regulator_id = rdev_get_id(rdev);
203 if (regulator_id >= PCF50633_NUM_REGULATORS)
204 return -EINVAL;
205
206 /* The *ENA register is always one after the *OUT register */
207 regnr = pcf50633_regulator_registers[regulator_id] + 1;
208
209 return pcf50633_reg_set_bit_mask(pcf, regnr, PCF50633_REGULATOR_ON,
210 PCF50633_REGULATOR_ON);
211}
212
213static int pcf50633_regulator_disable(struct regulator_dev *rdev)
214{
215 struct pcf50633 *pcf = rdev_get_drvdata(rdev);
216 int regulator_id;
217 u8 regnr;
218
219 regulator_id = rdev_get_id(rdev);
220 if (regulator_id >= PCF50633_NUM_REGULATORS)
221 return -EINVAL;
222
223 /* the *ENA register is always one after the *OUT register */
224 regnr = pcf50633_regulator_registers[regulator_id] + 1;
225
226 return pcf50633_reg_set_bit_mask(pcf, regnr,
227 PCF50633_REGULATOR_ON, 0);
228}
229
230static int pcf50633_regulator_is_enabled(struct regulator_dev *rdev)
231{
232 struct pcf50633 *pcf = rdev_get_drvdata(rdev);
233 int regulator_id = rdev_get_id(rdev);
234 u8 regnr;
235
236 regulator_id = rdev_get_id(rdev);
237 if (regulator_id >= PCF50633_NUM_REGULATORS)
238 return -EINVAL;
239
240 /* the *ENA register is always one after the *OUT register */
241 regnr = pcf50633_regulator_registers[regulator_id] + 1;
242
243 return pcf50633_reg_read(pcf, regnr) & PCF50633_REGULATOR_ON;
244}
245
246static struct regulator_ops pcf50633_regulator_ops = {
247 .set_voltage = pcf50633_regulator_set_voltage,
248 .get_voltage = pcf50633_regulator_get_voltage,
249 .enable = pcf50633_regulator_enable,
250 .disable = pcf50633_regulator_disable,
251 .is_enabled = pcf50633_regulator_is_enabled,
252};
253
254static struct regulator_desc regulators[] = {
255 [PCF50633_REGULATOR_AUTO] =
256 PCF50633_REGULATOR("auto", PCF50633_REGULATOR_AUTO),
257 [PCF50633_REGULATOR_DOWN1] =
258 PCF50633_REGULATOR("down1", PCF50633_REGULATOR_DOWN1),
259 [PCF50633_REGULATOR_DOWN2] =
260 PCF50633_REGULATOR("down2", PCF50633_REGULATOR_DOWN2),
261 [PCF50633_REGULATOR_LDO1] =
262 PCF50633_REGULATOR("ldo1", PCF50633_REGULATOR_LDO1),
263 [PCF50633_REGULATOR_LDO2] =
264 PCF50633_REGULATOR("ldo2", PCF50633_REGULATOR_LDO2),
265 [PCF50633_REGULATOR_LDO3] =
266 PCF50633_REGULATOR("ldo3", PCF50633_REGULATOR_LDO3),
267 [PCF50633_REGULATOR_LDO4] =
268 PCF50633_REGULATOR("ldo4", PCF50633_REGULATOR_LDO4),
269 [PCF50633_REGULATOR_LDO5] =
270 PCF50633_REGULATOR("ldo5", PCF50633_REGULATOR_LDO5),
271 [PCF50633_REGULATOR_LDO6] =
272 PCF50633_REGULATOR("ldo6", PCF50633_REGULATOR_LDO6),
273 [PCF50633_REGULATOR_HCLDO] =
274 PCF50633_REGULATOR("hcldo", PCF50633_REGULATOR_HCLDO),
275 [PCF50633_REGULATOR_MEMLDO] =
276 PCF50633_REGULATOR("memldo", PCF50633_REGULATOR_MEMLDO),
277};
278
279static int __devinit pcf50633_regulator_probe(struct platform_device *pdev)
280{
281 struct regulator_dev *rdev;
282 struct pcf50633 *pcf;
283
284 /* Already set by core driver */
285 pcf = platform_get_drvdata(pdev);
286
287 rdev = regulator_register(&regulators[pdev->id], &pdev->dev, pcf);
288 if (IS_ERR(rdev))
289 return PTR_ERR(rdev);
290
291 if (pcf->pdata->regulator_registered)
292 pcf->pdata->regulator_registered(pcf, pdev->id);
293
294 return 0;
295}
296
297static int __devexit pcf50633_regulator_remove(struct platform_device *pdev)
298{
299 struct regulator_dev *rdev = platform_get_drvdata(pdev);
300
301 regulator_unregister(rdev);
302
303 return 0;
304}
305
306static struct platform_driver pcf50633_regulator_driver = {
307 .driver = {
308 .name = "pcf50633-regltr",
309 },
310 .probe = pcf50633_regulator_probe,
311 .remove = __devexit_p(pcf50633_regulator_remove),
312};
313
314static int __init pcf50633_regulator_init(void)
315{
316 return platform_driver_register(&pcf50633_regulator_driver);
317}
318module_init(pcf50633_regulator_init);
319
320static void __exit pcf50633_regulator_exit(void)
321{
322 platform_driver_unregister(&pcf50633_regulator_driver);
323}
324module_exit(pcf50633_regulator_exit);
325
326MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>");
327MODULE_DESCRIPTION("PCF50633 regulator driver");
328MODULE_LICENSE("GPL");
329MODULE_ALIAS("platform:pcf50633-regulator");
diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c
index c68c496b2c49..7aa35248181b 100644
--- a/drivers/regulator/wm8350-regulator.c
+++ b/drivers/regulator/wm8350-regulator.c
@@ -1412,6 +1412,97 @@ int wm8350_register_regulator(struct wm8350 *wm8350, int reg,
1412} 1412}
1413EXPORT_SYMBOL_GPL(wm8350_register_regulator); 1413EXPORT_SYMBOL_GPL(wm8350_register_regulator);
1414 1414
1415/**
1416 * wm8350_register_led - Register a WM8350 LED output
1417 *
1418 * @param wm8350 The WM8350 device to configure.
1419 * @param lednum LED device index to create.
1420 * @param dcdc The DCDC to use for the LED.
1421 * @param isink The ISINK to use for the LED.
1422 * @param pdata Configuration for the LED.
1423 *
1424 * The WM8350 supports the use of an ISINK together with a DCDC to
1425 * provide a power-efficient LED driver. This function registers the
1426 * regulators and instantiates the platform device for a LED. The
1427 * operating modes for the LED regulators must be configured using
1428 * wm8350_isink_set_flash(), wm8350_dcdc25_set_mode() and
1429 * wm8350_dcdc_set_slot() prior to calling this function.
1430 */
1431int wm8350_register_led(struct wm8350 *wm8350, int lednum, int dcdc, int isink,
1432 struct wm8350_led_platform_data *pdata)
1433{
1434 struct wm8350_led *led;
1435 struct platform_device *pdev;
1436 int ret;
1437
1438 if (lednum > ARRAY_SIZE(wm8350->pmic.led) || lednum < 0) {
1439 dev_err(wm8350->dev, "Invalid LED index %d\n", lednum);
1440 return -ENODEV;
1441 }
1442
1443 led = &wm8350->pmic.led[lednum];
1444
1445 if (led->pdev) {
1446 dev_err(wm8350->dev, "LED %d already allocated\n", lednum);
1447 return -EINVAL;
1448 }
1449
1450 pdev = platform_device_alloc("wm8350-led", lednum);
1451 if (pdev == NULL) {
1452 dev_err(wm8350->dev, "Failed to allocate LED %d\n", lednum);
1453 return -ENOMEM;
1454 }
1455
1456 led->isink_consumer.dev = &pdev->dev;
1457 led->isink_consumer.supply = "led_isink";
1458 led->isink_init.num_consumer_supplies = 1;
1459 led->isink_init.consumer_supplies = &led->isink_consumer;
1460 led->isink_init.constraints.min_uA = 0;
1461 led->isink_init.constraints.max_uA = pdata->max_uA;
1462 led->isink_init.constraints.valid_ops_mask = REGULATOR_CHANGE_CURRENT;
1463 led->isink_init.constraints.valid_modes_mask = REGULATOR_MODE_NORMAL;
1464 ret = wm8350_register_regulator(wm8350, isink, &led->isink_init);
1465 if (ret != 0) {
1466 platform_device_put(pdev);
1467 return ret;
1468 }
1469
1470 led->dcdc_consumer.dev = &pdev->dev;
1471 led->dcdc_consumer.supply = "led_vcc";
1472 led->dcdc_init.num_consumer_supplies = 1;
1473 led->dcdc_init.consumer_supplies = &led->dcdc_consumer;
1474 led->dcdc_init.constraints.valid_modes_mask = REGULATOR_MODE_NORMAL;
1475 ret = wm8350_register_regulator(wm8350, dcdc, &led->dcdc_init);
1476 if (ret != 0) {
1477 platform_device_put(pdev);
1478 return ret;
1479 }
1480
1481 switch (isink) {
1482 case WM8350_ISINK_A:
1483 wm8350->pmic.isink_A_dcdc = dcdc;
1484 break;
1485 case WM8350_ISINK_B:
1486 wm8350->pmic.isink_B_dcdc = dcdc;
1487 break;
1488 }
1489
1490 pdev->dev.platform_data = pdata;
1491 pdev->dev.parent = wm8350->dev;
1492 ret = platform_device_add(pdev);
1493 if (ret != 0) {
1494 dev_err(wm8350->dev, "Failed to register LED %d: %d\n",
1495 lednum, ret);
1496 platform_device_put(pdev);
1497 return ret;
1498 }
1499
1500 led->pdev = pdev;
1501
1502 return 0;
1503}
1504EXPORT_SYMBOL_GPL(wm8350_register_led);
1505
1415static struct platform_driver wm8350_regulator_driver = { 1506static struct platform_driver wm8350_regulator_driver = {
1416 .probe = wm8350_regulator_probe, 1507 .probe = wm8350_regulator_probe,
1417 .remove = wm8350_regulator_remove, 1508 .remove = wm8350_regulator_remove,
diff --git a/drivers/regulator/wm8400-regulator.c b/drivers/regulator/wm8400-regulator.c
index 48b372e038a8..56e23d44ba59 100644
--- a/drivers/regulator/wm8400-regulator.c
+++ b/drivers/regulator/wm8400-regulator.c
@@ -289,7 +289,7 @@ static struct regulator_desc regulators[] = {
289 }, 289 },
290}; 290};
291 291
292static int __init wm8400_regulator_probe(struct platform_device *pdev) 292static int __devinit wm8400_regulator_probe(struct platform_device *pdev)
293{ 293{
294 struct regulator_dev *rdev; 294 struct regulator_dev *rdev;
295 295
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 4ad831de41ad..cced4d108319 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -502,6 +502,13 @@ config RTC_DRV_WM8350
502 This driver can also be built as a module. If so, the module 502 This driver can also be built as a module. If so, the module
503 will be called "rtc-wm8350". 503 will be called "rtc-wm8350".
504 504
505config RTC_DRV_PCF50633
506 depends on MFD_PCF50633
507 tristate "NXP PCF50633 RTC"
508 help
509 If you say yes here you get support for the RTC subsystem of the
510 NXP PCF50633 used in embedded systems.
511
505comment "on-CPU RTC drivers" 512comment "on-CPU RTC drivers"
506 513
507config RTC_DRV_OMAP 514config RTC_DRV_OMAP
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 9a4340d48f26..6e28021abb9d 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -74,3 +74,4 @@ obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o
74obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o 74obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o
75obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o 75obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o
76obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o 76obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o
77obj-$(CONFIG_RTC_DRV_PCF50633) += rtc-pcf50633.o
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 162330b9d1dc..7e5155e88ac7 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -86,13 +86,11 @@ enum ds_type {
86 86
87 87
88struct ds1307 { 88struct ds1307 {
89 u8 reg_addr;
90 u8 regs[11]; 89 u8 regs[11];
91 enum ds_type type; 90 enum ds_type type;
92 unsigned long flags; 91 unsigned long flags;
93#define HAS_NVRAM 0 /* bit 0 == sysfs file active */ 92#define HAS_NVRAM 0 /* bit 0 == sysfs file active */
94#define HAS_ALARM 1 /* bit 1 == irq claimed */ 93#define HAS_ALARM 1 /* bit 1 == irq claimed */
95 struct i2c_msg msg[2];
96 struct i2c_client *client; 94 struct i2c_client *client;
97 struct rtc_device *rtc; 95 struct rtc_device *rtc;
98 struct work_struct work; 96 struct work_struct work;
@@ -204,13 +202,9 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t)
204 int tmp; 202 int tmp;
205 203
206 /* read the RTC date and time registers all at once */ 204 /* read the RTC date and time registers all at once */
207 ds1307->reg_addr = 0; 205 tmp = i2c_smbus_read_i2c_block_data(ds1307->client,
208 ds1307->msg[1].flags = I2C_M_RD; 206 DS1307_REG_SECS, 7, ds1307->regs);
209 ds1307->msg[1].len = 7; 207 if (tmp != 7) {
210
211 tmp = i2c_transfer(to_i2c_adapter(ds1307->client->dev.parent),
212 ds1307->msg, 2);
213 if (tmp != 2) {
214 dev_err(dev, "%s error %d\n", "read", tmp); 208 dev_err(dev, "%s error %d\n", "read", tmp);
215 return -EIO; 209 return -EIO;
216 } 210 }
@@ -257,7 +251,6 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t)
257 t->tm_hour, t->tm_mday, 251 t->tm_hour, t->tm_mday,
258 t->tm_mon, t->tm_year, t->tm_wday); 252 t->tm_mon, t->tm_year, t->tm_wday);
259 253
260 *buf++ = 0; /* first register addr */
261 buf[DS1307_REG_SECS] = bin2bcd(t->tm_sec); 254 buf[DS1307_REG_SECS] = bin2bcd(t->tm_sec);
262 buf[DS1307_REG_MIN] = bin2bcd(t->tm_min); 255 buf[DS1307_REG_MIN] = bin2bcd(t->tm_min);
263 buf[DS1307_REG_HOUR] = bin2bcd(t->tm_hour); 256 buf[DS1307_REG_HOUR] = bin2bcd(t->tm_hour);
@@ -282,23 +275,19 @@ static int ds1307_set_time(struct device *dev, struct rtc_time *t)
282 break; 275 break;
283 } 276 }
284 277
285 ds1307->msg[1].flags = 0;
286 ds1307->msg[1].len = 8;
287
288 dev_dbg(dev, "%s: %02x %02x %02x %02x %02x %02x %02x\n", 278 dev_dbg(dev, "%s: %02x %02x %02x %02x %02x %02x %02x\n",
289 "write", buf[0], buf[1], buf[2], buf[3], 279 "write", buf[0], buf[1], buf[2], buf[3],
290 buf[4], buf[5], buf[6]); 280 buf[4], buf[5], buf[6]);
291 281
292 result = i2c_transfer(to_i2c_adapter(ds1307->client->dev.parent), 282 result = i2c_smbus_write_i2c_block_data(ds1307->client, 0, 7, buf);
293 &ds1307->msg[1], 1); 283 if (result < 0) {
294 if (result != 1) { 284 dev_err(dev, "%s error %d\n", "write", result);
295 dev_err(dev, "%s error %d\n", "write", tmp); 285 return result;
296 return -EIO;
297 } 286 }
298 return 0; 287 return 0;
299} 288}
300 289
301static int ds1307_read_alarm(struct device *dev, struct rtc_wkalrm *t) 290static int ds1337_read_alarm(struct device *dev, struct rtc_wkalrm *t)
302{ 291{
303 struct i2c_client *client = to_i2c_client(dev); 292 struct i2c_client *client = to_i2c_client(dev);
304 struct ds1307 *ds1307 = i2c_get_clientdata(client); 293 struct ds1307 *ds1307 = i2c_get_clientdata(client);
@@ -308,13 +297,9 @@ static int ds1307_read_alarm(struct device *dev, struct rtc_wkalrm *t)
308 return -EINVAL; 297 return -EINVAL;
309 298
310 /* read all ALARM1, ALARM2, and status registers at once */ 299 /* read all ALARM1, ALARM2, and status registers at once */
311 ds1307->reg_addr = DS1339_REG_ALARM1_SECS; 300 ret = i2c_smbus_read_i2c_block_data(client,
312 ds1307->msg[1].flags = I2C_M_RD; 301 DS1339_REG_ALARM1_SECS, 9, ds1307->regs);
313 ds1307->msg[1].len = 9; 302 if (ret != 9) {
314
315 ret = i2c_transfer(to_i2c_adapter(client->dev.parent),
316 ds1307->msg, 2);
317 if (ret != 2) {
318 dev_err(dev, "%s error %d\n", "alarm read", ret); 303 dev_err(dev, "%s error %d\n", "alarm read", ret);
319 return -EIO; 304 return -EIO;
320 } 305 }
@@ -353,7 +338,7 @@ static int ds1307_read_alarm(struct device *dev, struct rtc_wkalrm *t)
353 return 0; 338 return 0;
354} 339}
355 340
356static int ds1307_set_alarm(struct device *dev, struct rtc_wkalrm *t) 341static int ds1337_set_alarm(struct device *dev, struct rtc_wkalrm *t)
357{ 342{
358 struct i2c_client *client = to_i2c_client(dev); 343 struct i2c_client *client = to_i2c_client(dev);
359 struct ds1307 *ds1307 = i2c_get_clientdata(client); 344 struct ds1307 *ds1307 = i2c_get_clientdata(client);
@@ -371,13 +356,9 @@ static int ds1307_set_alarm(struct device *dev, struct rtc_wkalrm *t)
371 t->enabled, t->pending); 356 t->enabled, t->pending);
372 357
373 /* read current status of both alarms and the chip */ 358 /* read current status of both alarms and the chip */
374 ds1307->reg_addr = DS1339_REG_ALARM1_SECS; 359 ret = i2c_smbus_read_i2c_block_data(client,
375 ds1307->msg[1].flags = I2C_M_RD; 360 DS1339_REG_ALARM1_SECS, 9, buf);
376 ds1307->msg[1].len = 9; 361 if (ret != 9) {
377
378 ret = i2c_transfer(to_i2c_adapter(client->dev.parent),
379 ds1307->msg, 2);
380 if (ret != 2) {
381 dev_err(dev, "%s error %d\n", "alarm write", ret); 362 dev_err(dev, "%s error %d\n", "alarm write", ret);
382 return -EIO; 363 return -EIO;
383 } 364 }
@@ -392,7 +373,6 @@ static int ds1307_set_alarm(struct device *dev, struct rtc_wkalrm *t)
392 ds1307->regs[6], control, status); 373 ds1307->regs[6], control, status);
393 374
394 /* set ALARM1, using 24 hour and day-of-month modes */ 375 /* set ALARM1, using 24 hour and day-of-month modes */
395 *buf++ = DS1339_REG_ALARM1_SECS; /* first register addr */
396 buf[0] = bin2bcd(t->time.tm_sec); 376 buf[0] = bin2bcd(t->time.tm_sec);
397 buf[1] = bin2bcd(t->time.tm_min); 377 buf[1] = bin2bcd(t->time.tm_min);
398 buf[2] = bin2bcd(t->time.tm_hour); 378 buf[2] = bin2bcd(t->time.tm_hour);
@@ -411,14 +391,11 @@ static int ds1307_set_alarm(struct device *dev, struct rtc_wkalrm *t)
411 } 391 }
412 buf[8] = status & ~(DS1337_BIT_A1I | DS1337_BIT_A2I); 392 buf[8] = status & ~(DS1337_BIT_A1I | DS1337_BIT_A2I);
413 393
414 ds1307->msg[1].flags = 0; 394 ret = i2c_smbus_write_i2c_block_data(client,
415 ds1307->msg[1].len = 10; 395 DS1339_REG_ALARM1_SECS, 9, buf);
416 396 if (ret < 0) {
417 ret = i2c_transfer(to_i2c_adapter(client->dev.parent),
418 &ds1307->msg[1], 1);
419 if (ret != 1) {
420 dev_err(dev, "can't set alarm time\n"); 397 dev_err(dev, "can't set alarm time\n");
421 return -EIO; 398 return ret;
422 } 399 }
423 400
424 return 0; 401 return 0;
@@ -475,8 +452,8 @@ static int ds1307_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
475static const struct rtc_class_ops ds13xx_rtc_ops = { 452static const struct rtc_class_ops ds13xx_rtc_ops = {
476 .read_time = ds1307_get_time, 453 .read_time = ds1307_get_time,
477 .set_time = ds1307_set_time, 454 .set_time = ds1307_set_time,
478 .read_alarm = ds1307_read_alarm, 455 .read_alarm = ds1337_read_alarm,
479 .set_alarm = ds1307_set_alarm, 456 .set_alarm = ds1337_set_alarm,
480 .ioctl = ds1307_ioctl, 457 .ioctl = ds1307_ioctl,
481}; 458};
482 459
@@ -490,7 +467,6 @@ ds1307_nvram_read(struct kobject *kobj, struct bin_attribute *attr,
490{ 467{
491 struct i2c_client *client; 468 struct i2c_client *client;
492 struct ds1307 *ds1307; 469 struct ds1307 *ds1307;
493 struct i2c_msg msg[2];
494 int result; 470 int result;
495 471
496 client = kobj_to_i2c_client(kobj); 472 client = kobj_to_i2c_client(kobj);
@@ -503,24 +479,10 @@ ds1307_nvram_read(struct kobject *kobj, struct bin_attribute *attr,
503 if (unlikely(!count)) 479 if (unlikely(!count))
504 return count; 480 return count;
505 481
506 msg[0].addr = client->addr; 482 result = i2c_smbus_read_i2c_block_data(client, 8 + off, count, buf);
507 msg[0].flags = 0; 483 if (result < 0)
508 msg[0].len = 1;
509 msg[0].buf = buf;
510
511 buf[0] = 8 + off;
512
513 msg[1].addr = client->addr;
514 msg[1].flags = I2C_M_RD;
515 msg[1].len = count;
516 msg[1].buf = buf;
517
518 result = i2c_transfer(to_i2c_adapter(client->dev.parent), msg, 2);
519 if (result != 2) {
520 dev_err(&client->dev, "%s error %d\n", "nvram read", result); 484 dev_err(&client->dev, "%s error %d\n", "nvram read", result);
521 return -EIO; 485 return result;
522 }
523 return count;
524} 486}
525 487
526static ssize_t 488static ssize_t
@@ -528,8 +490,7 @@ ds1307_nvram_write(struct kobject *kobj, struct bin_attribute *attr,
528 char *buf, loff_t off, size_t count) 490 char *buf, loff_t off, size_t count)
529{ 491{
530 struct i2c_client *client; 492 struct i2c_client *client;
531 u8 buffer[NVRAM_SIZE + 1]; 493 int result;
532 int ret;
533 494
534 client = kobj_to_i2c_client(kobj); 495 client = kobj_to_i2c_client(kobj);
535 496
@@ -540,11 +501,12 @@ ds1307_nvram_write(struct kobject *kobj, struct bin_attribute *attr,
540 if (unlikely(!count)) 501 if (unlikely(!count))
541 return count; 502 return count;
542 503
543 buffer[0] = 8 + off; 504 result = i2c_smbus_write_i2c_block_data(client, 8 + off, count, buf);
544 memcpy(buffer + 1, buf, count); 505 if (result < 0) {
545 506 dev_err(&client->dev, "%s error %d\n", "nvram write", result);
546 ret = i2c_master_send(client, buffer, count + 1); 507 return result;
547 return (ret < 0) ? ret : (ret - 1); 508 }
509 return count;
548} 510}
549 511
550static struct bin_attribute nvram = { 512static struct bin_attribute nvram = {
@@ -571,9 +533,11 @@ static int __devinit ds1307_probe(struct i2c_client *client,
571 const struct chip_desc *chip = &chips[id->driver_data]; 533 const struct chip_desc *chip = &chips[id->driver_data];
572 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); 534 struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
573 int want_irq = false; 535 int want_irq = false;
536 unsigned char *buf;
574 537
575 if (!i2c_check_functionality(adapter, 538 if (!i2c_check_functionality(adapter,
576 I2C_FUNC_I2C | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) 539 I2C_FUNC_SMBUS_WRITE_BYTE_DATA |
540 I2C_FUNC_SMBUS_I2C_BLOCK))
577 return -EIO; 541 return -EIO;
578 542
579 if (!(ds1307 = kzalloc(sizeof(struct ds1307), GFP_KERNEL))) 543 if (!(ds1307 = kzalloc(sizeof(struct ds1307), GFP_KERNEL)))
@@ -581,18 +545,8 @@ static int __devinit ds1307_probe(struct i2c_client *client,
581 545
582 ds1307->client = client; 546 ds1307->client = client;
583 i2c_set_clientdata(client, ds1307); 547 i2c_set_clientdata(client, ds1307);
584
585 ds1307->msg[0].addr = client->addr;
586 ds1307->msg[0].flags = 0;
587 ds1307->msg[0].len = 1;
588 ds1307->msg[0].buf = &ds1307->reg_addr;
589
590 ds1307->msg[1].addr = client->addr;
591 ds1307->msg[1].flags = I2C_M_RD;
592 ds1307->msg[1].len = sizeof(ds1307->regs);
593 ds1307->msg[1].buf = ds1307->regs;
594
595 ds1307->type = id->driver_data; 548 ds1307->type = id->driver_data;
549 buf = ds1307->regs;
596 550
597 switch (ds1307->type) { 551 switch (ds1307->type) {
598 case ds_1337: 552 case ds_1337:
@@ -602,21 +556,15 @@ static int __devinit ds1307_probe(struct i2c_client *client,
602 INIT_WORK(&ds1307->work, ds1307_work); 556 INIT_WORK(&ds1307->work, ds1307_work);
603 want_irq = true; 557 want_irq = true;
604 } 558 }
605
606 ds1307->reg_addr = DS1337_REG_CONTROL;
607 ds1307->msg[1].len = 2;
608
609 /* get registers that the "rtc" read below won't read... */ 559 /* get registers that the "rtc" read below won't read... */
610 tmp = i2c_transfer(adapter, ds1307->msg, 2); 560 tmp = i2c_smbus_read_i2c_block_data(ds1307->client,
561 DS1337_REG_CONTROL, 2, buf);
611 if (tmp != 2) { 562 if (tmp != 2) {
612 pr_debug("read error %d\n", tmp); 563 pr_debug("read error %d\n", tmp);
613 err = -EIO; 564 err = -EIO;
614 goto exit_free; 565 goto exit_free;
615 } 566 }
616 567
617 ds1307->reg_addr = 0;
618 ds1307->msg[1].len = sizeof(ds1307->regs);
619
620 /* oscillator off? turn it on, so clock can tick. */ 568 /* oscillator off? turn it on, so clock can tick. */
621 if (ds1307->regs[0] & DS1337_BIT_nEOSC) 569 if (ds1307->regs[0] & DS1337_BIT_nEOSC)
622 ds1307->regs[0] &= ~DS1337_BIT_nEOSC; 570 ds1307->regs[0] &= ~DS1337_BIT_nEOSC;
@@ -647,9 +595,8 @@ static int __devinit ds1307_probe(struct i2c_client *client,
647 595
648read_rtc: 596read_rtc:
649 /* read RTC registers */ 597 /* read RTC registers */
650 598 tmp = i2c_smbus_read_i2c_block_data(ds1307->client, 0, 8, buf);
651 tmp = i2c_transfer(adapter, ds1307->msg, 2); 599 if (tmp != 8) {
652 if (tmp != 2) {
653 pr_debug("read error %d\n", tmp); 600 pr_debug("read error %d\n", tmp);
654 err = -EIO; 601 err = -EIO;
655 goto exit_free; 602 goto exit_free;
@@ -707,22 +654,6 @@ read_rtc:
707 break; 654 break;
708 } 655 }
709 656
710 tmp = ds1307->regs[DS1307_REG_SECS];
711 tmp = bcd2bin(tmp & 0x7f);
712 if (tmp > 60)
713 goto exit_bad;
714 tmp = bcd2bin(ds1307->regs[DS1307_REG_MIN] & 0x7f);
715 if (tmp > 60)
716 goto exit_bad;
717
718 tmp = bcd2bin(ds1307->regs[DS1307_REG_MDAY] & 0x3f);
719 if (tmp == 0 || tmp > 31)
720 goto exit_bad;
721
722 tmp = bcd2bin(ds1307->regs[DS1307_REG_MONTH] & 0x1f);
723 if (tmp == 0 || tmp > 12)
724 goto exit_bad;
725
726 tmp = ds1307->regs[DS1307_REG_HOUR]; 657 tmp = ds1307->regs[DS1307_REG_HOUR];
727 switch (ds1307->type) { 658 switch (ds1307->type) {
728 case ds_1340: 659 case ds_1340:
@@ -779,13 +710,6 @@ read_rtc:
779 710
780 return 0; 711 return 0;
781 712
782exit_bad:
783 dev_dbg(&client->dev, "%s: %02x %02x %02x %02x %02x %02x %02x\n",
784 "bogus register",
785 ds1307->regs[0], ds1307->regs[1],
786 ds1307->regs[2], ds1307->regs[3],
787 ds1307->regs[4], ds1307->regs[5],
788 ds1307->regs[6]);
789exit_irq: 713exit_irq:
790 if (ds1307->rtc) 714 if (ds1307->rtc)
791 rtc_device_unregister(ds1307->rtc); 715 rtc_device_unregister(ds1307->rtc);
diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c
index 23a07fe15a2c..0b6b7730c716 100644
--- a/drivers/rtc/rtc-ds1511.c
+++ b/drivers/rtc/rtc-ds1511.c
@@ -630,7 +630,7 @@ ds1511_rtc_init(void)
630 static void __exit 630 static void __exit
631ds1511_rtc_exit(void) 631ds1511_rtc_exit(void)
632{ 632{
633 return platform_driver_unregister(&ds1511_rtc_driver); 633 platform_driver_unregister(&ds1511_rtc_driver);
634} 634}
635 635
636module_init(ds1511_rtc_init); 636module_init(ds1511_rtc_init);
diff --git a/drivers/rtc/rtc-parisc.c b/drivers/rtc/rtc-parisc.c
index 346d633655e7..c6bfa6fe1a2a 100644
--- a/drivers/rtc/rtc-parisc.c
+++ b/drivers/rtc/rtc-parisc.c
@@ -34,7 +34,8 @@ static int parisc_get_time(struct device *dev, struct rtc_time *tm)
34static int parisc_set_time(struct device *dev, struct rtc_time *tm) 34static int parisc_set_time(struct device *dev, struct rtc_time *tm)
35{ 35{
36 struct parisc_rtc *p = dev_get_drvdata(dev); 36 struct parisc_rtc *p = dev_get_drvdata(dev);
37 unsigned long flags, ret; 37 unsigned long flags;
38 int ret;
38 39
39 spin_lock_irqsave(&p->lock, flags); 40 spin_lock_irqsave(&p->lock, flags);
40 ret = set_rtc_time(tm); 41 ret = set_rtc_time(tm);
diff --git a/drivers/rtc/rtc-pcf50633.c b/drivers/rtc/rtc-pcf50633.c
new file mode 100644
index 000000000000..f4dd87e29075
--- /dev/null
+++ b/drivers/rtc/rtc-pcf50633.c
@@ -0,0 +1,344 @@
1/* NXP PCF50633 RTC Driver
2 *
3 * (C) 2006-2008 by Openmoko, Inc.
4 * Author: Balaji Rao <balajirrao@openmoko.org>
5 * All rights reserved.
6 *
7 * Broken down from monstrous PCF50633 driver mainly by
8 * Harald Welte, Andy Green and Werner Almesberger
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/init.h>
20#include <linux/device.h>
21#include <linux/platform_device.h>
22#include <linux/rtc.h>
23#include <linux/bcd.h>
24#include <linux/err.h>
25
26#include <linux/mfd/pcf50633/core.h>
27
28#define PCF50633_REG_RTCSC 0x59 /* Second */
29#define PCF50633_REG_RTCMN 0x5a /* Minute */
30#define PCF50633_REG_RTCHR 0x5b /* Hour */
31#define PCF50633_REG_RTCWD 0x5c /* Weekday */
32#define PCF50633_REG_RTCDT 0x5d /* Day */
33#define PCF50633_REG_RTCMT 0x5e /* Month */
34#define PCF50633_REG_RTCYR 0x5f /* Year */
35#define PCF50633_REG_RTCSCA 0x60 /* Alarm Second */
36#define PCF50633_REG_RTCMNA 0x61 /* Alarm Minute */
37#define PCF50633_REG_RTCHRA 0x62 /* Alarm Hour */
38#define PCF50633_REG_RTCWDA 0x63 /* Alarm Weekday */
39#define PCF50633_REG_RTCDTA 0x64 /* Alarm Day */
40#define PCF50633_REG_RTCMTA 0x65 /* Alarm Month */
41#define PCF50633_REG_RTCYRA 0x66 /* Alarm Year */
42
43enum pcf50633_time_indexes {
44 PCF50633_TI_SEC,
45 PCF50633_TI_MIN,
46 PCF50633_TI_HOUR,
47 PCF50633_TI_WKDAY,
48 PCF50633_TI_DAY,
49 PCF50633_TI_MONTH,
50 PCF50633_TI_YEAR,
51 PCF50633_TI_EXTENT /* always last */
52};
53
54struct pcf50633_time {
55 u_int8_t time[PCF50633_TI_EXTENT];
56};
57
58struct pcf50633_rtc {
59 int alarm_enabled;
60 int second_enabled;
61
62 struct pcf50633 *pcf;
63 struct rtc_device *rtc_dev;
64};
65
66static void pcf2rtc_time(struct rtc_time *rtc, struct pcf50633_time *pcf)
67{
68 rtc->tm_sec = bcd2bin(pcf->time[PCF50633_TI_SEC]);
69 rtc->tm_min = bcd2bin(pcf->time[PCF50633_TI_MIN]);
70 rtc->tm_hour = bcd2bin(pcf->time[PCF50633_TI_HOUR]);
71 rtc->tm_wday = bcd2bin(pcf->time[PCF50633_TI_WKDAY]);
72 rtc->tm_mday = bcd2bin(pcf->time[PCF50633_TI_DAY]);
73 rtc->tm_mon = bcd2bin(pcf->time[PCF50633_TI_MONTH]);
74 rtc->tm_year = bcd2bin(pcf->time[PCF50633_TI_YEAR]) + 100;
75}
76
77static void rtc2pcf_time(struct pcf50633_time *pcf, struct rtc_time *rtc)
78{
79 pcf->time[PCF50633_TI_SEC] = bin2bcd(rtc->tm_sec);
80 pcf->time[PCF50633_TI_MIN] = bin2bcd(rtc->tm_min);
81 pcf->time[PCF50633_TI_HOUR] = bin2bcd(rtc->tm_hour);
82 pcf->time[PCF50633_TI_WKDAY] = bin2bcd(rtc->tm_wday);
83 pcf->time[PCF50633_TI_DAY] = bin2bcd(rtc->tm_mday);
84 pcf->time[PCF50633_TI_MONTH] = bin2bcd(rtc->tm_mon);
85 pcf->time[PCF50633_TI_YEAR] = bin2bcd(rtc->tm_year % 100);
86}
87
88static int
89pcf50633_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
90{
91 struct pcf50633_rtc *rtc = dev_get_drvdata(dev);
92 int err;
93
94 if (enabled)
95 err = pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_ALARM);
96 else
97 err = pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_ALARM);
98
99 if (err < 0)
100 return err;
101
102 rtc->alarm_enabled = enabled;
103
104 return 0;
105}
106
107static int
108pcf50633_rtc_update_irq_enable(struct device *dev, unsigned int enabled)
109{
110 struct pcf50633_rtc *rtc = dev_get_drvdata(dev);
111 int err;
112
113 if (enabled)
114 err = pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_SECOND);
115 else
116 err = pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_SECOND);
117
118 if (err < 0)
119 return err;
120
121 rtc->second_enabled = enabled;
122
123 return 0;
124}
125
126static int pcf50633_rtc_read_time(struct device *dev, struct rtc_time *tm)
127{
128 struct pcf50633_rtc *rtc;
129 struct pcf50633_time pcf_tm;
130 int ret;
131
132 rtc = dev_get_drvdata(dev);
133
134 ret = pcf50633_read_block(rtc->pcf, PCF50633_REG_RTCSC,
135 PCF50633_TI_EXTENT,
136 &pcf_tm.time[0]);
137 if (ret != PCF50633_TI_EXTENT) {
138 dev_err(dev, "Failed to read time\n");
139 return -EIO;
140 }
141
142 dev_dbg(dev, "PCF_TIME: %02x.%02x.%02x %02x:%02x:%02x\n",
143 pcf_tm.time[PCF50633_TI_DAY],
144 pcf_tm.time[PCF50633_TI_MONTH],
145 pcf_tm.time[PCF50633_TI_YEAR],
146 pcf_tm.time[PCF50633_TI_HOUR],
147 pcf_tm.time[PCF50633_TI_MIN],
148 pcf_tm.time[PCF50633_TI_SEC]);
149
150 pcf2rtc_time(tm, &pcf_tm);
151
152 dev_dbg(dev, "RTC_TIME: %u.%u.%u %u:%u:%u\n",
153 tm->tm_mday, tm->tm_mon, tm->tm_year,
154 tm->tm_hour, tm->tm_min, tm->tm_sec);
155
156 return rtc_valid_tm(tm);
157}
158
159static int pcf50633_rtc_set_time(struct device *dev, struct rtc_time *tm)
160{
161 struct pcf50633_rtc *rtc;
162 struct pcf50633_time pcf_tm;
163 int second_masked, alarm_masked, ret = 0;
164
165 rtc = dev_get_drvdata(dev);
166
167 dev_dbg(dev, "RTC_TIME: %u.%u.%u %u:%u:%u\n",
168 tm->tm_mday, tm->tm_mon, tm->tm_year,
169 tm->tm_hour, tm->tm_min, tm->tm_sec);
170
171 rtc2pcf_time(&pcf_tm, tm);
172
173 dev_dbg(dev, "PCF_TIME: %02x.%02x.%02x %02x:%02x:%02x\n",
174 pcf_tm.time[PCF50633_TI_DAY],
175 pcf_tm.time[PCF50633_TI_MONTH],
176 pcf_tm.time[PCF50633_TI_YEAR],
177 pcf_tm.time[PCF50633_TI_HOUR],
178 pcf_tm.time[PCF50633_TI_MIN],
179 pcf_tm.time[PCF50633_TI_SEC]);
180
181
182 second_masked = pcf50633_irq_mask_get(rtc->pcf, PCF50633_IRQ_SECOND);
183 alarm_masked = pcf50633_irq_mask_get(rtc->pcf, PCF50633_IRQ_ALARM);
184
185 if (!second_masked)
186 pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_SECOND);
187 if (!alarm_masked)
188 pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_ALARM);
189
190 /* Returns 0 on success */
191 ret = pcf50633_write_block(rtc->pcf, PCF50633_REG_RTCSC,
192 PCF50633_TI_EXTENT,
193 &pcf_tm.time[0]);
194
195 if (!second_masked)
196 pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_SECOND);
197 if (!alarm_masked)
198 pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_ALARM);
199
200 return ret;
201}
202
203static int pcf50633_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
204{
205 struct pcf50633_rtc *rtc;
206 struct pcf50633_time pcf_tm;
207 int ret = 0;
208
209 rtc = dev_get_drvdata(dev);
210
211 alrm->enabled = rtc->alarm_enabled;
212
213 ret = pcf50633_read_block(rtc->pcf, PCF50633_REG_RTCSCA,
214 PCF50633_TI_EXTENT, &pcf_tm.time[0]);
215 if (ret != PCF50633_TI_EXTENT) {
216 dev_err(dev, "Failed to read time\n");
217 return -EIO;
218 }
219
220 pcf2rtc_time(&alrm->time, &pcf_tm);
221
222 return rtc_valid_tm(&alrm->time);
223}
224
225static int pcf50633_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
226{
227 struct pcf50633_rtc *rtc;
228 struct pcf50633_time pcf_tm;
229 int alarm_masked, ret = 0;
230
231 rtc = dev_get_drvdata(dev);
232
233 rtc2pcf_time(&pcf_tm, &alrm->time);
234
235 /* do like mktime does and ignore tm_wday */
236 pcf_tm.time[PCF50633_TI_WKDAY] = 7;
237
238 alarm_masked = pcf50633_irq_mask_get(rtc->pcf, PCF50633_IRQ_ALARM);
239
240 /* disable alarm interrupt */
241 if (!alarm_masked)
242 pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_ALARM);
243
244 /* Returns 0 on success */
245 ret = pcf50633_write_block(rtc->pcf, PCF50633_REG_RTCSCA,
246 PCF50633_TI_EXTENT, &pcf_tm.time[0]);
247
248 if (!alarm_masked)
249 pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_ALARM);
250
251 return ret;
252}
253
254static struct rtc_class_ops pcf50633_rtc_ops = {
255 .read_time = pcf50633_rtc_read_time,
256 .set_time = pcf50633_rtc_set_time,
257 .read_alarm = pcf50633_rtc_read_alarm,
258 .set_alarm = pcf50633_rtc_set_alarm,
259 .alarm_irq_enable = pcf50633_rtc_alarm_irq_enable,
260 .update_irq_enable = pcf50633_rtc_update_irq_enable,
261};
262
263static void pcf50633_rtc_irq(int irq, void *data)
264{
265 struct pcf50633_rtc *rtc = data;
266
267 switch (irq) {
268 case PCF50633_IRQ_ALARM:
269 rtc_update_irq(rtc->rtc_dev, 1, RTC_AF | RTC_IRQF);
270 break;
271 case PCF50633_IRQ_SECOND:
272 rtc_update_irq(rtc->rtc_dev, 1, RTC_UF | RTC_IRQF);
273 break;
274 }
275}
276
277static int __devinit pcf50633_rtc_probe(struct platform_device *pdev)
278{
279 struct pcf50633_subdev_pdata *pdata;
280 struct pcf50633_rtc *rtc;
281
282
283 rtc = kzalloc(sizeof(*rtc), GFP_KERNEL);
284 if (!rtc)
285 return -ENOMEM;
286
287 pdata = pdev->dev.platform_data;
288 rtc->pcf = pdata->pcf;
289 platform_set_drvdata(pdev, rtc);
290 rtc->rtc_dev = rtc_device_register("pcf50633-rtc", &pdev->dev,
291 &pcf50633_rtc_ops, THIS_MODULE);
292
293 if (IS_ERR(rtc->rtc_dev)) {
294 kfree(rtc);
295 return PTR_ERR(rtc->rtc_dev);
296 }
297
298 pcf50633_register_irq(rtc->pcf, PCF50633_IRQ_ALARM,
299 pcf50633_rtc_irq, rtc);
300 pcf50633_register_irq(rtc->pcf, PCF50633_IRQ_SECOND,
301 pcf50633_rtc_irq, rtc);
302
303 return 0;
304}
305
306static int __devexit pcf50633_rtc_remove(struct platform_device *pdev)
307{
308 struct pcf50633_rtc *rtc;
309
310 rtc = platform_get_drvdata(pdev);
311
312 pcf50633_free_irq(rtc->pcf, PCF50633_IRQ_ALARM);
313 pcf50633_free_irq(rtc->pcf, PCF50633_IRQ_SECOND);
314
315 rtc_device_unregister(rtc->rtc_dev);
316 kfree(rtc);
317
318 return 0;
319}
320
321static struct platform_driver pcf50633_rtc_driver = {
322 .driver = {
323 .name = "pcf50633-rtc",
324 },
325 .probe = pcf50633_rtc_probe,
326 .remove = __devexit_p(pcf50633_rtc_remove),
327};
328
329static int __init pcf50633_rtc_init(void)
330{
331 return platform_driver_register(&pcf50633_rtc_driver);
332}
333module_init(pcf50633_rtc_init);
334
335static void __exit pcf50633_rtc_exit(void)
336{
337 platform_driver_unregister(&pcf50633_rtc_driver);
338}
339module_exit(pcf50633_rtc_exit);
340
341MODULE_DESCRIPTION("PCF50633 RTC driver");
342MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>");
343MODULE_LICENSE("GPL");
344
diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c
index cc7eb8767b82..bd56a033bfd0 100644
--- a/drivers/rtc/rtc-pxa.c
+++ b/drivers/rtc/rtc-pxa.c
@@ -27,6 +27,8 @@
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/io.h> 28#include <linux/io.h>
29 29
30#include <mach/hardware.h>
31
30#define TIMER_FREQ CLOCK_TICK_RATE 32#define TIMER_FREQ CLOCK_TICK_RATE
31#define RTC_DEF_DIVIDER (32768 - 1) 33#define RTC_DEF_DIVIDER (32768 - 1)
32#define RTC_DEF_TRIM 0 34#define RTC_DEF_TRIM 0
diff --git a/drivers/rtc/rtc-stk17ta8.c b/drivers/rtc/rtc-stk17ta8.c
index dc0b6224ad9b..7d1547b0070e 100644
--- a/drivers/rtc/rtc-stk17ta8.c
+++ b/drivers/rtc/rtc-stk17ta8.c
@@ -399,7 +399,7 @@ static __init int stk17ta8_init(void)
399 399
400static __exit void stk17ta8_exit(void) 400static __exit void stk17ta8_exit(void)
401{ 401{
402 return platform_driver_unregister(&stk17ta8_rtc_driver); 402 platform_driver_unregister(&stk17ta8_rtc_driver);
403} 403}
404 404
405module_init(stk17ta8_init); 405module_init(stk17ta8_init);
diff --git a/drivers/rtc/rtc-twl4030.c b/drivers/rtc/rtc-twl4030.c
index 8ce5f74ee45b..ad35f76c46b7 100644
--- a/drivers/rtc/rtc-twl4030.c
+++ b/drivers/rtc/rtc-twl4030.c
@@ -120,7 +120,7 @@ static int twl4030_rtc_write_u8(u8 data, u8 reg)
120static unsigned char rtc_irq_bits; 120static unsigned char rtc_irq_bits;
121 121
122/* 122/*
123 * Enable timer and/or alarm interrupts. 123 * Enable 1/second update and/or alarm interrupts.
124 */ 124 */
125static int set_rtc_irq_bit(unsigned char bit) 125static int set_rtc_irq_bit(unsigned char bit)
126{ 126{
@@ -128,6 +128,7 @@ static int set_rtc_irq_bit(unsigned char bit)
128 int ret; 128 int ret;
129 129
130 val = rtc_irq_bits | bit; 130 val = rtc_irq_bits | bit;
131 val &= ~BIT_RTC_INTERRUPTS_REG_EVERY_M;
131 ret = twl4030_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG); 132 ret = twl4030_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG);
132 if (ret == 0) 133 if (ret == 0)
133 rtc_irq_bits = val; 134 rtc_irq_bits = val;
@@ -136,7 +137,7 @@ static int set_rtc_irq_bit(unsigned char bit)
136} 137}
137 138
138/* 139/*
139 * Disable timer and/or alarm interrupts. 140 * Disable update and/or alarm interrupts.
140 */ 141 */
141static int mask_rtc_irq_bit(unsigned char bit) 142static int mask_rtc_irq_bit(unsigned char bit)
142{ 143{
@@ -151,7 +152,7 @@ static int mask_rtc_irq_bit(unsigned char bit)
151 return ret; 152 return ret;
152} 153}
153 154
154static inline int twl4030_rtc_alarm_irq_set_state(int enabled) 155static int twl4030_rtc_alarm_irq_enable(struct device *dev, unsigned enabled)
155{ 156{
156 int ret; 157 int ret;
157 158
@@ -163,7 +164,7 @@ static inline int twl4030_rtc_alarm_irq_set_state(int enabled)
163 return ret; 164 return ret;
164} 165}
165 166
166static inline int twl4030_rtc_irq_set_state(int enabled) 167static int twl4030_rtc_update_irq_enable(struct device *dev, unsigned enabled)
167{ 168{
168 int ret; 169 int ret;
169 170
@@ -292,7 +293,7 @@ static int twl4030_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
292 unsigned char alarm_data[ALL_TIME_REGS + 1]; 293 unsigned char alarm_data[ALL_TIME_REGS + 1];
293 int ret; 294 int ret;
294 295
295 ret = twl4030_rtc_alarm_irq_set_state(0); 296 ret = twl4030_rtc_alarm_irq_enable(dev, 0);
296 if (ret) 297 if (ret)
297 goto out; 298 goto out;
298 299
@@ -312,35 +313,11 @@ static int twl4030_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
312 } 313 }
313 314
314 if (alm->enabled) 315 if (alm->enabled)
315 ret = twl4030_rtc_alarm_irq_set_state(1); 316 ret = twl4030_rtc_alarm_irq_enable(dev, 1);
316out: 317out:
317 return ret; 318 return ret;
318} 319}
319 320
320#ifdef CONFIG_RTC_INTF_DEV
321
322static int twl4030_rtc_ioctl(struct device *dev, unsigned int cmd,
323 unsigned long arg)
324{
325 switch (cmd) {
326 case RTC_AIE_OFF:
327 return twl4030_rtc_alarm_irq_set_state(0);
328 case RTC_AIE_ON:
329 return twl4030_rtc_alarm_irq_set_state(1);
330 case RTC_UIE_OFF:
331 return twl4030_rtc_irq_set_state(0);
332 case RTC_UIE_ON:
333 return twl4030_rtc_irq_set_state(1);
334
335 default:
336 return -ENOIOCTLCMD;
337 }
338}
339
340#else
341#define twl4030_rtc_ioctl NULL
342#endif
343
344static irqreturn_t twl4030_rtc_interrupt(int irq, void *rtc) 321static irqreturn_t twl4030_rtc_interrupt(int irq, void *rtc)
345{ 322{
346 unsigned long events = 0; 323 unsigned long events = 0;
@@ -400,11 +377,12 @@ out:
400} 377}
401 378
402static struct rtc_class_ops twl4030_rtc_ops = { 379static struct rtc_class_ops twl4030_rtc_ops = {
403 .ioctl = twl4030_rtc_ioctl,
404 .read_time = twl4030_rtc_read_time, 380 .read_time = twl4030_rtc_read_time,
405 .set_time = twl4030_rtc_set_time, 381 .set_time = twl4030_rtc_set_time,
406 .read_alarm = twl4030_rtc_read_alarm, 382 .read_alarm = twl4030_rtc_read_alarm,
407 .set_alarm = twl4030_rtc_set_alarm, 383 .set_alarm = twl4030_rtc_set_alarm,
384 .alarm_irq_enable = twl4030_rtc_alarm_irq_enable,
385 .update_irq_enable = twl4030_rtc_update_irq_enable,
408}; 386};
409 387
410/*----------------------------------------------------------------------*/ 388/*----------------------------------------------------------------------*/
@@ -422,7 +400,7 @@ static int __devinit twl4030_rtc_probe(struct platform_device *pdev)
422 rtc = rtc_device_register(pdev->name, 400 rtc = rtc_device_register(pdev->name,
423 &pdev->dev, &twl4030_rtc_ops, THIS_MODULE); 401 &pdev->dev, &twl4030_rtc_ops, THIS_MODULE);
424 if (IS_ERR(rtc)) { 402 if (IS_ERR(rtc)) {
425 ret = -EINVAL; 403 ret = PTR_ERR(rtc);
426 dev_err(&pdev->dev, "can't register RTC device, err %ld\n", 404 dev_err(&pdev->dev, "can't register RTC device, err %ld\n",
427 PTR_ERR(rtc)); 405 PTR_ERR(rtc));
428 goto out0; 406 goto out0;
@@ -432,7 +410,6 @@ static int __devinit twl4030_rtc_probe(struct platform_device *pdev)
432 platform_set_drvdata(pdev, rtc); 410 platform_set_drvdata(pdev, rtc);
433 411
434 ret = twl4030_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG); 412 ret = twl4030_rtc_read_u8(&rd_reg, REG_RTC_STATUS_REG);
435
436 if (ret < 0) 413 if (ret < 0)
437 goto out1; 414 goto out1;
438 415
@@ -475,7 +452,6 @@ static int __devinit twl4030_rtc_probe(struct platform_device *pdev)
475 452
476 return ret; 453 return ret;
477 454
478
479out2: 455out2:
480 free_irq(irq, rtc); 456 free_irq(irq, rtc);
481out1: 457out1:
@@ -506,8 +482,9 @@ static int __devexit twl4030_rtc_remove(struct platform_device *pdev)
506 482
507static void twl4030_rtc_shutdown(struct platform_device *pdev) 483static void twl4030_rtc_shutdown(struct platform_device *pdev)
508{ 484{
509 mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_TIMER_M | 485 /* mask timer interrupts, but leave alarm interrupts on to enable
510 BIT_RTC_INTERRUPTS_REG_IT_ALARM_M); 486 power-on when alarm is triggered */
487 mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_TIMER_M);
511} 488}
512 489
513#ifdef CONFIG_PM 490#ifdef CONFIG_PM
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 570ae59c1d5e..bd5914994142 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -336,6 +336,9 @@ static int
336dasd_state_ready_to_online(struct dasd_device * device) 336dasd_state_ready_to_online(struct dasd_device * device)
337{ 337{
338 int rc; 338 int rc;
339 struct gendisk *disk;
340 struct disk_part_iter piter;
341 struct hd_struct *part;
339 342
340 if (device->discipline->ready_to_online) { 343 if (device->discipline->ready_to_online) {
341 rc = device->discipline->ready_to_online(device); 344 rc = device->discipline->ready_to_online(device);
@@ -343,8 +346,14 @@ dasd_state_ready_to_online(struct dasd_device * device)
343 return rc; 346 return rc;
344 } 347 }
345 device->state = DASD_STATE_ONLINE; 348 device->state = DASD_STATE_ONLINE;
346 if (device->block) 349 if (device->block) {
347 dasd_schedule_block_bh(device->block); 350 dasd_schedule_block_bh(device->block);
351 disk = device->block->bdev->bd_disk;
352 disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0);
353 while ((part = disk_part_iter_next(&piter)))
354 kobject_uevent(&part_to_dev(part)->kobj, KOBJ_CHANGE);
355 disk_part_iter_exit(&piter);
356 }
348 return 0; 357 return 0;
349} 358}
350 359
@@ -354,6 +363,9 @@ dasd_state_ready_to_online(struct dasd_device * device)
354static int dasd_state_online_to_ready(struct dasd_device *device) 363static int dasd_state_online_to_ready(struct dasd_device *device)
355{ 364{
356 int rc; 365 int rc;
366 struct gendisk *disk;
367 struct disk_part_iter piter;
368 struct hd_struct *part;
357 369
358 if (device->discipline->online_to_ready) { 370 if (device->discipline->online_to_ready) {
359 rc = device->discipline->online_to_ready(device); 371 rc = device->discipline->online_to_ready(device);
@@ -361,6 +373,13 @@ static int dasd_state_online_to_ready(struct dasd_device *device)
361 return rc; 373 return rc;
362 } 374 }
363 device->state = DASD_STATE_READY; 375 device->state = DASD_STATE_READY;
376 if (device->block) {
377 disk = device->block->bdev->bd_disk;
378 disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0);
379 while ((part = disk_part_iter_next(&piter)))
380 kobject_uevent(&part_to_dev(part)->kobj, KOBJ_CHANGE);
381 disk_part_iter_exit(&piter);
382 }
364 return 0; 383 return 0;
365} 384}
366 385
diff --git a/drivers/s390/block/dasd_3990_erp.c b/drivers/s390/block/dasd_3990_erp.c
index b8f9c00633f3..d82aad5224f0 100644
--- a/drivers/s390/block/dasd_3990_erp.c
+++ b/drivers/s390/block/dasd_3990_erp.c
@@ -2621,7 +2621,7 @@ dasd_3990_erp_action(struct dasd_ccw_req * cqr)
2621 } 2621 }
2622 } 2622 }
2623 2623
2624 /* double-check if current erp/cqr was successfull */ 2624 /* double-check if current erp/cqr was successful */
2625 if ((cqr->irb.scsw.cmd.cstat == 0x00) && 2625 if ((cqr->irb.scsw.cmd.cstat == 0x00) &&
2626 (cqr->irb.scsw.cmd.dstat == 2626 (cqr->irb.scsw.cmd.dstat ==
2627 (DEV_STAT_CHN_END | DEV_STAT_DEV_END))) { 2627 (DEV_STAT_CHN_END | DEV_STAT_DEV_END))) {
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index 2ef25731d197..300e28a531f8 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -206,6 +206,8 @@ dasd_feature_list(char *str, char **endp)
206 features |= DASD_FEATURE_USEDIAG; 206 features |= DASD_FEATURE_USEDIAG;
207 else if (len == 6 && !strncmp(str, "erplog", 6)) 207 else if (len == 6 && !strncmp(str, "erplog", 6))
208 features |= DASD_FEATURE_ERPLOG; 208 features |= DASD_FEATURE_ERPLOG;
209 else if (len == 8 && !strncmp(str, "failfast", 8))
210 features |= DASD_FEATURE_FAILFAST;
209 else { 211 else {
210 MESSAGE(KERN_WARNING, 212 MESSAGE(KERN_WARNING,
211 "unsupported feature: %*s, " 213 "unsupported feature: %*s, "
@@ -667,6 +669,51 @@ dasd_device_from_cdev(struct ccw_device *cdev)
667 */ 669 */
668 670
669/* 671/*
672 * failfast controls the behaviour, if no path is available
673 */
674static ssize_t dasd_ff_show(struct device *dev, struct device_attribute *attr,
675 char *buf)
676{
677 struct dasd_devmap *devmap;
678 int ff_flag;
679
680 devmap = dasd_find_busid(dev->bus_id);
681 if (!IS_ERR(devmap))
682 ff_flag = (devmap->features & DASD_FEATURE_FAILFAST) != 0;
683 else
684 ff_flag = (DASD_FEATURE_DEFAULT & DASD_FEATURE_FAILFAST) != 0;
685 return snprintf(buf, PAGE_SIZE, ff_flag ? "1\n" : "0\n");
686}
687
688static ssize_t dasd_ff_store(struct device *dev, struct device_attribute *attr,
689 const char *buf, size_t count)
690{
691 struct dasd_devmap *devmap;
692 int val;
693 char *endp;
694
695 devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
696 if (IS_ERR(devmap))
697 return PTR_ERR(devmap);
698
699 val = simple_strtoul(buf, &endp, 0);
700 if (((endp + 1) < (buf + count)) || (val > 1))
701 return -EINVAL;
702
703 spin_lock(&dasd_devmap_lock);
704 if (val)
705 devmap->features |= DASD_FEATURE_FAILFAST;
706 else
707 devmap->features &= ~DASD_FEATURE_FAILFAST;
708 if (devmap->device)
709 devmap->device->features = devmap->features;
710 spin_unlock(&dasd_devmap_lock);
711 return count;
712}
713
714static DEVICE_ATTR(failfast, 0644, dasd_ff_show, dasd_ff_store);
715
716/*
670 * readonly controls the readonly status of a dasd 717 * readonly controls the readonly status of a dasd
671 */ 718 */
672static ssize_t 719static ssize_t
@@ -1020,6 +1067,7 @@ static struct attribute * dasd_attrs[] = {
1020 &dev_attr_use_diag.attr, 1067 &dev_attr_use_diag.attr,
1021 &dev_attr_eer_enabled.attr, 1068 &dev_attr_eer_enabled.attr,
1022 &dev_attr_erplog.attr, 1069 &dev_attr_erplog.attr,
1070 &dev_attr_failfast.attr,
1023 NULL, 1071 NULL,
1024}; 1072};
1025 1073
diff --git a/drivers/s390/block/dasd_diag.c b/drivers/s390/block/dasd_diag.c
index 7844461a995b..ef2a56952054 100644
--- a/drivers/s390/block/dasd_diag.c
+++ b/drivers/s390/block/dasd_diag.c
@@ -544,7 +544,8 @@ static struct dasd_ccw_req *dasd_diag_build_cp(struct dasd_device *memdev,
544 } 544 }
545 cqr->retries = DIAG_MAX_RETRIES; 545 cqr->retries = DIAG_MAX_RETRIES;
546 cqr->buildclk = get_clock(); 546 cqr->buildclk = get_clock();
547 if (blk_noretry_request(req)) 547 if (blk_noretry_request(req) ||
548 block->base->features & DASD_FEATURE_FAILFAST)
548 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags); 549 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
549 cqr->startdev = memdev; 550 cqr->startdev = memdev;
550 cqr->memdev = memdev; 551 cqr->memdev = memdev;
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index bd2c52e20762..bdb87998f364 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -1700,7 +1700,8 @@ static struct dasd_ccw_req *dasd_eckd_build_cp(struct dasd_device *startdev,
1700 recid++; 1700 recid++;
1701 } 1701 }
1702 } 1702 }
1703 if (blk_noretry_request(req)) 1703 if (blk_noretry_request(req) ||
1704 block->base->features & DASD_FEATURE_FAILFAST)
1704 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags); 1705 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
1705 cqr->startdev = startdev; 1706 cqr->startdev = startdev;
1706 cqr->memdev = startdev; 1707 cqr->memdev = startdev;
diff --git a/drivers/s390/block/dasd_eer.c b/drivers/s390/block/dasd_eer.c
index 892e2878d61b..f8e05ce98621 100644
--- a/drivers/s390/block/dasd_eer.c
+++ b/drivers/s390/block/dasd_eer.c
@@ -535,8 +535,8 @@ static int dasd_eer_open(struct inode *inp, struct file *filp)
535 eerb->buffer_page_count > INT_MAX / PAGE_SIZE) { 535 eerb->buffer_page_count > INT_MAX / PAGE_SIZE) {
536 kfree(eerb); 536 kfree(eerb);
537 MESSAGE(KERN_WARNING, "can't open device since module " 537 MESSAGE(KERN_WARNING, "can't open device since module "
538 "parameter eer_pages is smaller then 1 or" 538 "parameter eer_pages is smaller than 1 or"
539 " bigger then %d", (int)(INT_MAX / PAGE_SIZE)); 539 " bigger than %d", (int)(INT_MAX / PAGE_SIZE));
540 unlock_kernel(); 540 unlock_kernel();
541 return -EINVAL; 541 return -EINVAL;
542 } 542 }
diff --git a/drivers/s390/block/dasd_fba.c b/drivers/s390/block/dasd_fba.c
index 7d442aeff3d1..f1d176021694 100644
--- a/drivers/s390/block/dasd_fba.c
+++ b/drivers/s390/block/dasd_fba.c
@@ -355,7 +355,8 @@ static struct dasd_ccw_req *dasd_fba_build_cp(struct dasd_device * memdev,
355 recid++; 355 recid++;
356 } 356 }
357 } 357 }
358 if (blk_noretry_request(req)) 358 if (blk_noretry_request(req) ||
359 block->base->features & DASD_FEATURE_FAILFAST)
359 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags); 360 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
360 cqr->startdev = memdev; 361 cqr->startdev = memdev;
361 cqr->memdev = memdev; 362 cqr->memdev = memdev;
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index 05a14536c369..4a39084d9c95 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -199,7 +199,7 @@ struct dasd_ccw_req {
199#define DASD_CQR_ERROR 0x82 /* request is completed with error */ 199#define DASD_CQR_ERROR 0x82 /* request is completed with error */
200#define DASD_CQR_CLEAR_PENDING 0x83 /* request is clear pending */ 200#define DASD_CQR_CLEAR_PENDING 0x83 /* request is clear pending */
201#define DASD_CQR_CLEARED 0x84 /* request was cleared */ 201#define DASD_CQR_CLEARED 0x84 /* request was cleared */
202#define DASD_CQR_SUCCESS 0x85 /* request was successfull */ 202#define DASD_CQR_SUCCESS 0x85 /* request was successful */
203 203
204 204
205/* per dasd_ccw_req flags */ 205/* per dasd_ccw_req flags */
diff --git a/drivers/s390/char/Kconfig b/drivers/s390/char/Kconfig
index 643033890e34..0769ced52dbd 100644
--- a/drivers/s390/char/Kconfig
+++ b/drivers/s390/char/Kconfig
@@ -100,7 +100,7 @@ comment "S/390 tape interface support"
100 100
101config S390_TAPE_BLOCK 101config S390_TAPE_BLOCK
102 bool "Support for tape block devices" 102 bool "Support for tape block devices"
103 depends on S390_TAPE 103 depends on S390_TAPE && BLOCK
104 help 104 help
105 Select this option if you want to access your channel-attached tape 105 Select this option if you want to access your channel-attached tape
106 devices using the block device interface. This interface is similar 106 devices using the block device interface. This interface is similar
diff --git a/drivers/s390/char/tape_3590.c b/drivers/s390/char/tape_3590.c
index 4005c44a404c..71605a179d65 100644
--- a/drivers/s390/char/tape_3590.c
+++ b/drivers/s390/char/tape_3590.c
@@ -801,7 +801,7 @@ tape_3590_done(struct tape_device *device, struct tape_request *request)
801static inline int 801static inline int
802tape_3590_erp_succeded(struct tape_device *device, struct tape_request *request) 802tape_3590_erp_succeded(struct tape_device *device, struct tape_request *request)
803{ 803{
804 DBF_EVENT(3, "Error Recovery successfull for %s\n", 804 DBF_EVENT(3, "Error Recovery successful for %s\n",
805 tape_op_verbose[request->op]); 805 tape_op_verbose[request->op]);
806 return tape_3590_done(device, request); 806 return tape_3590_done(device, request);
807} 807}
diff --git a/drivers/s390/char/vmlogrdr.c b/drivers/s390/char/vmlogrdr.c
index aabbeb909cc6..d8a2289fcb69 100644
--- a/drivers/s390/char/vmlogrdr.c
+++ b/drivers/s390/char/vmlogrdr.c
@@ -427,7 +427,7 @@ static int vmlogrdr_receive_data(struct vmlogrdr_priv_t *priv)
427 buffer = priv->buffer + sizeof(int); 427 buffer = priv->buffer + sizeof(int);
428 } 428 }
429 /* 429 /*
430 * If the record is bigger then our buffer, we receive only 430 * If the record is bigger than our buffer, we receive only
431 * a part of it. We can get the rest later. 431 * a part of it. We can get the rest later.
432 */ 432 */
433 if (iucv_data_count > NET_BUFFER_SIZE) 433 if (iucv_data_count > NET_BUFFER_SIZE)
@@ -437,7 +437,7 @@ static int vmlogrdr_receive_data(struct vmlogrdr_priv_t *priv)
437 0, buffer, iucv_data_count, 437 0, buffer, iucv_data_count,
438 &priv->residual_length); 438 &priv->residual_length);
439 spin_unlock_bh(&priv->priv_lock); 439 spin_unlock_bh(&priv->priv_lock);
440 /* An rc of 5 indicates that the record was bigger then 440 /* An rc of 5 indicates that the record was bigger than
441 * the buffer, which is OK for us. A 9 indicates that the 441 * the buffer, which is OK for us. A 9 indicates that the
442 * record was purged befor we could receive it. 442 * record was purged befor we could receive it.
443 */ 443 */
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c
index 06b71823f399..659f8a791656 100644
--- a/drivers/s390/cio/cio.c
+++ b/drivers/s390/cio/cio.c
@@ -379,7 +379,7 @@ int cio_commit_config(struct subchannel *sch)
379 if (ccode < 0) /* -EIO if msch gets a program check. */ 379 if (ccode < 0) /* -EIO if msch gets a program check. */
380 return ccode; 380 return ccode;
381 switch (ccode) { 381 switch (ccode) {
382 case 0: /* successfull */ 382 case 0: /* successful */
383 if (stsch(sch->schid, &schib) || 383 if (stsch(sch->schid, &schib) ||
384 !css_sch_is_valid(&schib)) 384 !css_sch_is_valid(&schib))
385 return -ENODEV; 385 return -ENODEV;
diff --git a/drivers/s390/cio/qdio_debug.c b/drivers/s390/cio/qdio_debug.c
index f8a3b6967f69..da7afb04e71f 100644
--- a/drivers/s390/cio/qdio_debug.c
+++ b/drivers/s390/cio/qdio_debug.c
@@ -169,6 +169,8 @@ static void setup_debugfs_entry(struct qdio_q *q, struct ccw_device *cdev)
169 q->nr); 169 q->nr);
170 debugfs_queues[i] = debugfs_create_file(name, S_IFREG | S_IRUGO | S_IWUSR, 170 debugfs_queues[i] = debugfs_create_file(name, S_IFREG | S_IRUGO | S_IWUSR,
171 debugfs_root, q, &debugfs_fops); 171 debugfs_root, q, &debugfs_fops);
172 if (IS_ERR(debugfs_queues[i]))
173 debugfs_queues[i] = NULL;
172} 174}
173 175
174void qdio_setup_debug_entries(struct qdio_irq *irq_ptr, struct ccw_device *cdev) 176void qdio_setup_debug_entries(struct qdio_irq *irq_ptr, struct ccw_device *cdev)
diff --git a/drivers/s390/cio/qdio_main.c b/drivers/s390/cio/qdio_main.c
index 744f928a59ea..10cb0f8726e5 100644
--- a/drivers/s390/cio/qdio_main.c
+++ b/drivers/s390/cio/qdio_main.c
@@ -114,7 +114,7 @@ static inline int qdio_check_ccq(struct qdio_q *q, unsigned int ccq)
114 * @count: count of buffers to examine 114 * @count: count of buffers to examine
115 * @auto_ack: automatically acknowledge buffers 115 * @auto_ack: automatically acknowledge buffers
116 * 116 *
117 * Returns the number of successfull extracted equal buffer states. 117 * Returns the number of successfully extracted equal buffer states.
118 * Stops processing if a state is different from the last buffers state. 118 * Stops processing if a state is different from the last buffers state.
119 */ 119 */
120static int qdio_do_eqbs(struct qdio_q *q, unsigned char *state, 120static int qdio_do_eqbs(struct qdio_q *q, unsigned char *state,
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index 591a2b3ae4cb..07ab8a5c1c46 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -916,6 +916,21 @@ static struct ethtool_ops qeth_l2_osn_ops = {
916 .get_drvinfo = qeth_core_get_drvinfo, 916 .get_drvinfo = qeth_core_get_drvinfo,
917}; 917};
918 918
919static const struct net_device_ops qeth_l2_netdev_ops = {
920 .ndo_open = qeth_l2_open,
921 .ndo_stop = qeth_l2_stop,
922 .ndo_get_stats = qeth_get_stats,
923 .ndo_start_xmit = qeth_l2_hard_start_xmit,
924 .ndo_validate_addr = eth_validate_addr,
925 .ndo_set_multicast_list = qeth_l2_set_multicast_list,
926 .ndo_do_ioctl = qeth_l2_do_ioctl,
927 .ndo_set_mac_address = qeth_l2_set_mac_address,
928 .ndo_change_mtu = qeth_change_mtu,
929 .ndo_vlan_rx_add_vid = qeth_l2_vlan_rx_add_vid,
930 .ndo_vlan_rx_kill_vid = qeth_l2_vlan_rx_kill_vid,
931 .ndo_tx_timeout = qeth_tx_timeout,
932};
933
919static int qeth_l2_setup_netdev(struct qeth_card *card) 934static int qeth_l2_setup_netdev(struct qeth_card *card)
920{ 935{
921 switch (card->info.type) { 936 switch (card->info.type) {
@@ -937,19 +952,9 @@ static int qeth_l2_setup_netdev(struct qeth_card *card)
937 return -ENODEV; 952 return -ENODEV;
938 953
939 card->dev->ml_priv = card; 954 card->dev->ml_priv = card;
940 card->dev->tx_timeout = &qeth_tx_timeout;
941 card->dev->watchdog_timeo = QETH_TX_TIMEOUT; 955 card->dev->watchdog_timeo = QETH_TX_TIMEOUT;
942 card->dev->open = qeth_l2_open;
943 card->dev->stop = qeth_l2_stop;
944 card->dev->hard_start_xmit = qeth_l2_hard_start_xmit;
945 card->dev->do_ioctl = qeth_l2_do_ioctl;
946 card->dev->get_stats = qeth_get_stats;
947 card->dev->change_mtu = qeth_change_mtu;
948 card->dev->set_multicast_list = qeth_l2_set_multicast_list;
949 card->dev->vlan_rx_kill_vid = qeth_l2_vlan_rx_kill_vid;
950 card->dev->vlan_rx_add_vid = qeth_l2_vlan_rx_add_vid;
951 card->dev->set_mac_address = qeth_l2_set_mac_address;
952 card->dev->mtu = card->info.initial_mtu; 956 card->dev->mtu = card->info.initial_mtu;
957 card->dev->netdev_ops = &qeth_l2_netdev_ops;
953 if (card->info.type != QETH_CARD_TYPE_OSN) 958 if (card->info.type != QETH_CARD_TYPE_OSN)
954 SET_ETHTOOL_OPS(card->dev, &qeth_l2_ethtool_ops); 959 SET_ETHTOOL_OPS(card->dev, &qeth_l2_ethtool_ops);
955 else 960 else
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index 4693ee4e7b98..3d04920b9bb9 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -1829,28 +1829,6 @@ static void qeth_l3_vlan_rx_register(struct net_device *dev,
1829 1829
1830static void qeth_l3_vlan_rx_add_vid(struct net_device *dev, unsigned short vid) 1830static void qeth_l3_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
1831{ 1831{
1832 struct net_device *vlandev;
1833 struct qeth_card *card = dev->ml_priv;
1834 struct in_device *in_dev;
1835
1836 if (card->info.type == QETH_CARD_TYPE_IQD)
1837 return;
1838
1839 vlandev = vlan_group_get_device(card->vlangrp, vid);
1840 vlandev->neigh_setup = qeth_l3_neigh_setup;
1841
1842 in_dev = in_dev_get(vlandev);
1843#ifdef CONFIG_SYSCTL
1844 neigh_sysctl_unregister(in_dev->arp_parms);
1845#endif
1846 neigh_parms_release(&arp_tbl, in_dev->arp_parms);
1847
1848 in_dev->arp_parms = neigh_parms_alloc(vlandev, &arp_tbl);
1849#ifdef CONFIG_SYSCTL
1850 neigh_sysctl_register(vlandev, in_dev->arp_parms, NET_IPV4,
1851 NET_IPV4_NEIGH, "ipv4", NULL, NULL);
1852#endif
1853 in_dev_put(in_dev);
1854 return; 1832 return;
1855} 1833}
1856 1834
@@ -2916,6 +2894,37 @@ qeth_l3_neigh_setup(struct net_device *dev, struct neigh_parms *np)
2916 return 0; 2894 return 0;
2917} 2895}
2918 2896
2897static const struct net_device_ops qeth_l3_netdev_ops = {
2898 .ndo_open = qeth_l3_open,
2899 .ndo_stop = qeth_l3_stop,
2900 .ndo_get_stats = qeth_get_stats,
2901 .ndo_start_xmit = qeth_l3_hard_start_xmit,
2902 .ndo_validate_addr = eth_validate_addr,
2903 .ndo_set_multicast_list = qeth_l3_set_multicast_list,
2904 .ndo_do_ioctl = qeth_l3_do_ioctl,
2905 .ndo_change_mtu = qeth_change_mtu,
2906 .ndo_vlan_rx_register = qeth_l3_vlan_rx_register,
2907 .ndo_vlan_rx_add_vid = qeth_l3_vlan_rx_add_vid,
2908 .ndo_vlan_rx_kill_vid = qeth_l3_vlan_rx_kill_vid,
2909 .ndo_tx_timeout = qeth_tx_timeout,
2910};
2911
2912static const struct net_device_ops qeth_l3_osa_netdev_ops = {
2913 .ndo_open = qeth_l3_open,
2914 .ndo_stop = qeth_l3_stop,
2915 .ndo_get_stats = qeth_get_stats,
2916 .ndo_start_xmit = qeth_l3_hard_start_xmit,
2917 .ndo_validate_addr = eth_validate_addr,
2918 .ndo_set_multicast_list = qeth_l3_set_multicast_list,
2919 .ndo_do_ioctl = qeth_l3_do_ioctl,
2920 .ndo_change_mtu = qeth_change_mtu,
2921 .ndo_vlan_rx_register = qeth_l3_vlan_rx_register,
2922 .ndo_vlan_rx_add_vid = qeth_l3_vlan_rx_add_vid,
2923 .ndo_vlan_rx_kill_vid = qeth_l3_vlan_rx_kill_vid,
2924 .ndo_tx_timeout = qeth_tx_timeout,
2925 .ndo_neigh_setup = qeth_l3_neigh_setup,
2926};
2927
2919static int qeth_l3_setup_netdev(struct qeth_card *card) 2928static int qeth_l3_setup_netdev(struct qeth_card *card)
2920{ 2929{
2921 if (card->info.type == QETH_CARD_TYPE_OSAE) { 2930 if (card->info.type == QETH_CARD_TYPE_OSAE) {
@@ -2926,11 +2935,12 @@ static int qeth_l3_setup_netdev(struct qeth_card *card)
2926#endif 2935#endif
2927 if (!card->dev) 2936 if (!card->dev)
2928 return -ENODEV; 2937 return -ENODEV;
2938 card->dev->netdev_ops = &qeth_l3_netdev_ops;
2929 } else { 2939 } else {
2930 card->dev = alloc_etherdev(0); 2940 card->dev = alloc_etherdev(0);
2931 if (!card->dev) 2941 if (!card->dev)
2932 return -ENODEV; 2942 return -ENODEV;
2933 card->dev->neigh_setup = qeth_l3_neigh_setup; 2943 card->dev->netdev_ops = &qeth_l3_osa_netdev_ops;
2934 2944
2935 /*IPv6 address autoconfiguration stuff*/ 2945 /*IPv6 address autoconfiguration stuff*/
2936 qeth_l3_get_unique_id(card); 2946 qeth_l3_get_unique_id(card);
@@ -2943,25 +2953,14 @@ static int qeth_l3_setup_netdev(struct qeth_card *card)
2943 if (!card->dev) 2953 if (!card->dev)
2944 return -ENODEV; 2954 return -ENODEV;
2945 card->dev->flags |= IFF_NOARP; 2955 card->dev->flags |= IFF_NOARP;
2956 card->dev->netdev_ops = &qeth_l3_netdev_ops;
2946 qeth_l3_iqd_read_initial_mac(card); 2957 qeth_l3_iqd_read_initial_mac(card);
2947 } else 2958 } else
2948 return -ENODEV; 2959 return -ENODEV;
2949 2960
2950 card->dev->hard_start_xmit = qeth_l3_hard_start_xmit;
2951 card->dev->ml_priv = card; 2961 card->dev->ml_priv = card;
2952 card->dev->tx_timeout = &qeth_tx_timeout;
2953 card->dev->watchdog_timeo = QETH_TX_TIMEOUT; 2962 card->dev->watchdog_timeo = QETH_TX_TIMEOUT;
2954 card->dev->open = qeth_l3_open;
2955 card->dev->stop = qeth_l3_stop;
2956 card->dev->do_ioctl = qeth_l3_do_ioctl;
2957 card->dev->get_stats = qeth_get_stats;
2958 card->dev->change_mtu = qeth_change_mtu;
2959 card->dev->set_multicast_list = qeth_l3_set_multicast_list;
2960 card->dev->vlan_rx_register = qeth_l3_vlan_rx_register;
2961 card->dev->vlan_rx_add_vid = qeth_l3_vlan_rx_add_vid;
2962 card->dev->vlan_rx_kill_vid = qeth_l3_vlan_rx_kill_vid;
2963 card->dev->mtu = card->info.initial_mtu; 2963 card->dev->mtu = card->info.initial_mtu;
2964 card->dev->set_mac_address = NULL;
2965 SET_ETHTOOL_OPS(card->dev, &qeth_l3_ethtool_ops); 2964 SET_ETHTOOL_OPS(card->dev, &qeth_l3_ethtool_ops);
2966 card->dev->features |= NETIF_F_HW_VLAN_TX | 2965 card->dev->features |= NETIF_F_HW_VLAN_TX |
2967 NETIF_F_HW_VLAN_RX | 2966 NETIF_F_HW_VLAN_RX |
diff --git a/drivers/sbus/char/display7seg.c b/drivers/sbus/char/display7seg.c
index 2550af4ae432..4431578d8c45 100644
--- a/drivers/sbus/char/display7seg.c
+++ b/drivers/sbus/char/display7seg.c
@@ -214,7 +214,7 @@ static int __devinit d7s_probe(struct of_device *op,
214 214
215 writeb(regs, p->regs); 215 writeb(regs, p->regs);
216 216
217 printk(KERN_INFO PFX "7-Segment Display%s at [%s:0x%lx] %s\n", 217 printk(KERN_INFO PFX "7-Segment Display%s at [%s:0x%llx] %s\n",
218 op->node->full_name, 218 op->node->full_name,
219 (regs & D7S_FLIP) ? " (FLIPPED)" : "", 219 (regs & D7S_FLIP) ? " (FLIPPED)" : "",
220 op->resource[0].start, 220 op->resource[0].start,
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index b7322976d2b7..256c7bec7bd7 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -884,6 +884,7 @@ config SCSI_IBMVSCSI
884 tristate "IBM Virtual SCSI support" 884 tristate "IBM Virtual SCSI support"
885 depends on PPC_PSERIES || PPC_ISERIES 885 depends on PPC_PSERIES || PPC_ISERIES
886 select SCSI_SRP_ATTRS 886 select SCSI_SRP_ATTRS
887 select VIOPATH if PPC_ISERIES
887 help 888 help
888 This is the IBM POWER Virtual SCSI Client 889 This is the IBM POWER Virtual SCSI Client
889 890
diff --git a/drivers/scsi/NCR_D700.c b/drivers/scsi/NCR_D700.c
index 9e64b21ef637..c889d8458684 100644
--- a/drivers/scsi/NCR_D700.c
+++ b/drivers/scsi/NCR_D700.c
@@ -318,7 +318,7 @@ NCR_D700_probe(struct device *dev)
318 return -ENOMEM; 318 return -ENOMEM;
319 319
320 p->dev = dev; 320 p->dev = dev;
321 snprintf(p->name, sizeof(p->name), "D700(%s)", dev->bus_id); 321 snprintf(p->name, sizeof(p->name), "D700(%s)", dev_name(dev));
322 if (request_irq(irq, NCR_D700_intr, IRQF_SHARED, p->name, p)) { 322 if (request_irq(irq, NCR_D700_intr, IRQF_SHARED, p->name, p)) {
323 printk(KERN_ERR "D700: request_irq failed\n"); 323 printk(KERN_ERR "D700: request_irq failed\n");
324 kfree(p); 324 kfree(p);
diff --git a/drivers/scsi/a100u2w.c b/drivers/scsi/a100u2w.c
index 3c298c7253ee..964769f66eac 100644
--- a/drivers/scsi/a100u2w.c
+++ b/drivers/scsi/a100u2w.c
@@ -633,7 +633,7 @@ static int orc_device_reset(struct orc_host * host, struct scsi_cmnd *cmd, unsig
633 return FAILED; 633 return FAILED;
634 } 634 }
635 635
636 /* Reset device is handled by the firmare, we fill in an SCB and 636 /* Reset device is handled by the firmware, we fill in an SCB and
637 fire it at the controller, it does the rest */ 637 fire it at the controller, it does the rest */
638 scb->opcode = ORC_BUSDEVRST; 638 scb->opcode = ORC_BUSDEVRST;
639 scb->target = target; 639 scb->target = target;
diff --git a/drivers/scsi/a2091.c b/drivers/scsi/a2091.c
index 07d572feceed..37dd47136fb1 100644
--- a/drivers/scsi/a2091.c
+++ b/drivers/scsi/a2091.c
@@ -169,10 +169,8 @@ int __init a2091_detect(struct scsi_host_template *tpnt)
169 continue; 169 continue;
170 170
171 instance = scsi_register (tpnt, sizeof (struct WD33C93_hostdata)); 171 instance = scsi_register (tpnt, sizeof (struct WD33C93_hostdata));
172 if (instance == NULL) { 172 if (instance == NULL)
173 release_mem_region(address, 256); 173 goto release;
174 continue;
175 }
176 instance->base = ZTWO_VADDR(address); 174 instance->base = ZTWO_VADDR(address);
177 instance->irq = IRQ_AMIGA_PORTS; 175 instance->irq = IRQ_AMIGA_PORTS;
178 instance->unique_id = z->slotaddr; 176 instance->unique_id = z->slotaddr;
@@ -183,10 +181,18 @@ int __init a2091_detect(struct scsi_host_template *tpnt)
183 HDATA(instance)->fast = 0; 181 HDATA(instance)->fast = 0;
184 HDATA(instance)->dma_mode = CTRL_DMA; 182 HDATA(instance)->dma_mode = CTRL_DMA;
185 wd33c93_init(instance, regs, dma_setup, dma_stop, WD33C93_FS_8_10); 183 wd33c93_init(instance, regs, dma_setup, dma_stop, WD33C93_FS_8_10);
186 request_irq(IRQ_AMIGA_PORTS, a2091_intr, IRQF_SHARED, "A2091 SCSI", 184 if (request_irq(IRQ_AMIGA_PORTS, a2091_intr, IRQF_SHARED, "A2091 SCSI",
187 instance); 185 instance))
186 goto unregister;
188 DMA(instance)->CNTR = CNTR_PDMD | CNTR_INTEN; 187 DMA(instance)->CNTR = CNTR_PDMD | CNTR_INTEN;
189 num_a2091++; 188 num_a2091++;
189 continue;
190
191unregister:
192 scsi_unregister(instance);
193 wd33c93_release();
194release:
195 release_mem_region(address, 256);
190 } 196 }
191 197
192 return num_a2091; 198 return num_a2091;
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 2f602720193e..7507d8bc57a1 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -2527,7 +2527,7 @@ static void asc_prt_scsi_host(struct Scsi_Host *s)
2527{ 2527{
2528 struct asc_board *boardp = shost_priv(s); 2528 struct asc_board *boardp = shost_priv(s);
2529 2529
2530 printk("Scsi_Host at addr 0x%p, device %s\n", s, boardp->dev->bus_id); 2530 printk("Scsi_Host at addr 0x%p, device %s\n", s, dev_name(boardp->dev));
2531 printk(" host_busy %u, host_no %d, last_reset %d,\n", 2531 printk(" host_busy %u, host_no %d, last_reset %d,\n",
2532 s->host_busy, s->host_no, (unsigned)s->last_reset); 2532 s->host_busy, s->host_no, (unsigned)s->last_reset);
2533 2533
diff --git a/drivers/scsi/aic94xx/aic94xx_tmf.c b/drivers/scsi/aic94xx/aic94xx_tmf.c
index d4640ef6d44f..78eb86fc6276 100644
--- a/drivers/scsi/aic94xx/aic94xx_tmf.c
+++ b/drivers/scsi/aic94xx/aic94xx_tmf.c
@@ -189,7 +189,7 @@ int asd_I_T_nexus_reset(struct domain_device *dev)
189 asd_clear_nexus_I_T(dev, NEXUS_PHASE_PRE); 189 asd_clear_nexus_I_T(dev, NEXUS_PHASE_PRE);
190 /* send a hard reset */ 190 /* send a hard reset */
191 ASD_DPRINTK("sending %s reset to %s\n", 191 ASD_DPRINTK("sending %s reset to %s\n",
192 reset_type ? "hard" : "soft", phy->dev.bus_id); 192 reset_type ? "hard" : "soft", dev_name(&phy->dev));
193 res = sas_phy_reset(phy, reset_type); 193 res = sas_phy_reset(phy, reset_type);
194 if (res == TMF_RESP_FUNC_COMPLETE) { 194 if (res == TMF_RESP_FUNC_COMPLETE) {
195 /* wait for the maximum settle time */ 195 /* wait for the maximum settle time */
diff --git a/drivers/scsi/cxgb3i/cxgb3i_ddp.c b/drivers/scsi/cxgb3i/cxgb3i_ddp.c
index 1a41f04264f7..08f3a09d9233 100644
--- a/drivers/scsi/cxgb3i/cxgb3i_ddp.c
+++ b/drivers/scsi/cxgb3i/cxgb3i_ddp.c
@@ -11,6 +11,7 @@
11 */ 11 */
12 12
13#include <linux/skbuff.h> 13#include <linux/skbuff.h>
14#include <linux/scatterlist.h>
14 15
15/* from cxgb3 LLD */ 16/* from cxgb3 LLD */
16#include "common.h" 17#include "common.h"
diff --git a/drivers/scsi/gvp11.c b/drivers/scsi/gvp11.c
index ca7363752401..5d1bf7e3d245 100644
--- a/drivers/scsi/gvp11.c
+++ b/drivers/scsi/gvp11.c
@@ -329,12 +329,16 @@ int __init gvp11_detect(struct scsi_host_template *tpnt)
329 (epc & GVP_SCSICLKMASK) ? WD33C93_FS_8_10 329 (epc & GVP_SCSICLKMASK) ? WD33C93_FS_8_10
330 : WD33C93_FS_12_15); 330 : WD33C93_FS_12_15);
331 331
332 request_irq(IRQ_AMIGA_PORTS, gvp11_intr, IRQF_SHARED, "GVP11 SCSI", 332 if (request_irq(IRQ_AMIGA_PORTS, gvp11_intr, IRQF_SHARED, "GVP11 SCSI",
333 instance); 333 instance))
334 goto unregister;
334 DMA(instance)->CNTR = GVP11_DMAC_INT_ENABLE; 335 DMA(instance)->CNTR = GVP11_DMAC_INT_ENABLE;
335 num_gvp11++; 336 num_gvp11++;
336 continue; 337 continue;
337 338
339unregister:
340 scsi_unregister(instance);
341 wd33c93_release();
338release: 342release:
339 release_mem_region(address, 256); 343 release_mem_region(address, 256);
340 } 344 }
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 3fdbb13e80a8..aa670a1d1513 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -388,8 +388,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
388 shost->dma_boundary = 0xffffffff; 388 shost->dma_boundary = 0xffffffff;
389 389
390 device_initialize(&shost->shost_gendev); 390 device_initialize(&shost->shost_gendev);
391 snprintf(shost->shost_gendev.bus_id, BUS_ID_SIZE, "host%d", 391 dev_set_name(&shost->shost_gendev, "host%d", shost->host_no);
392 shost->host_no);
393#ifndef CONFIG_SYSFS_DEPRECATED 392#ifndef CONFIG_SYSFS_DEPRECATED
394 shost->shost_gendev.bus = &scsi_bus_type; 393 shost->shost_gendev.bus = &scsi_bus_type;
395#endif 394#endif
@@ -398,8 +397,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
398 device_initialize(&shost->shost_dev); 397 device_initialize(&shost->shost_dev);
399 shost->shost_dev.parent = &shost->shost_gendev; 398 shost->shost_dev.parent = &shost->shost_gendev;
400 shost->shost_dev.class = &shost_class; 399 shost->shost_dev.class = &shost_class;
401 snprintf(shost->shost_dev.bus_id, BUS_ID_SIZE, "host%d", 400 dev_set_name(&shost->shost_dev, "host%d", shost->host_no);
402 shost->host_no);
403 shost->shost_dev.groups = scsi_sysfs_shost_attr_groups; 401 shost->shost_dev.groups = scsi_sysfs_shost_attr_groups;
404 402
405 shost->ehandler = kthread_run(scsi_error_handler, shost, 403 shost->ehandler = kthread_run(scsi_error_handler, shost,
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index 44f202f33101..91ef669d98f6 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -101,7 +101,7 @@ static const struct {
101 { IBMVFC_FABRIC_MAPPED, IBMVFC_UNABLE_TO_ESTABLISH, DID_ERROR, 1, 1, "unable to establish" }, 101 { IBMVFC_FABRIC_MAPPED, IBMVFC_UNABLE_TO_ESTABLISH, DID_ERROR, 1, 1, "unable to establish" },
102 { IBMVFC_FABRIC_MAPPED, IBMVFC_XPORT_FAULT, DID_OK, 1, 0, "transport fault" }, 102 { IBMVFC_FABRIC_MAPPED, IBMVFC_XPORT_FAULT, DID_OK, 1, 0, "transport fault" },
103 { IBMVFC_FABRIC_MAPPED, IBMVFC_CMD_TIMEOUT, DID_TIME_OUT, 1, 1, "command timeout" }, 103 { IBMVFC_FABRIC_MAPPED, IBMVFC_CMD_TIMEOUT, DID_TIME_OUT, 1, 1, "command timeout" },
104 { IBMVFC_FABRIC_MAPPED, IBMVFC_ENETDOWN, DID_NO_CONNECT, 1, 1, "network down" }, 104 { IBMVFC_FABRIC_MAPPED, IBMVFC_ENETDOWN, DID_TRANSPORT_DISRUPTED, 1, 1, "network down" },
105 { IBMVFC_FABRIC_MAPPED, IBMVFC_HW_FAILURE, DID_ERROR, 1, 1, "hardware failure" }, 105 { IBMVFC_FABRIC_MAPPED, IBMVFC_HW_FAILURE, DID_ERROR, 1, 1, "hardware failure" },
106 { IBMVFC_FABRIC_MAPPED, IBMVFC_LINK_DOWN_ERR, DID_REQUEUE, 0, 0, "link down" }, 106 { IBMVFC_FABRIC_MAPPED, IBMVFC_LINK_DOWN_ERR, DID_REQUEUE, 0, 0, "link down" },
107 { IBMVFC_FABRIC_MAPPED, IBMVFC_LINK_DEAD_ERR, DID_ERROR, 0, 0, "link dead" }, 107 { IBMVFC_FABRIC_MAPPED, IBMVFC_LINK_DEAD_ERR, DID_ERROR, 0, 0, "link dead" },
@@ -115,11 +115,11 @@ static const struct {
115 115
116 { IBMVFC_VIOS_FAILURE, IBMVFC_CRQ_FAILURE, DID_REQUEUE, 1, 1, "CRQ failure" }, 116 { IBMVFC_VIOS_FAILURE, IBMVFC_CRQ_FAILURE, DID_REQUEUE, 1, 1, "CRQ failure" },
117 { IBMVFC_VIOS_FAILURE, IBMVFC_SW_FAILURE, DID_ERROR, 0, 1, "software failure" }, 117 { IBMVFC_VIOS_FAILURE, IBMVFC_SW_FAILURE, DID_ERROR, 0, 1, "software failure" },
118 { IBMVFC_VIOS_FAILURE, IBMVFC_INVALID_PARAMETER, DID_ABORT, 0, 1, "invalid parameter" }, 118 { IBMVFC_VIOS_FAILURE, IBMVFC_INVALID_PARAMETER, DID_ERROR, 0, 1, "invalid parameter" },
119 { IBMVFC_VIOS_FAILURE, IBMVFC_MISSING_PARAMETER, DID_ABORT, 0, 1, "missing parameter" }, 119 { IBMVFC_VIOS_FAILURE, IBMVFC_MISSING_PARAMETER, DID_ERROR, 0, 1, "missing parameter" },
120 { IBMVFC_VIOS_FAILURE, IBMVFC_HOST_IO_BUS, DID_ERROR, 1, 1, "host I/O bus failure" }, 120 { IBMVFC_VIOS_FAILURE, IBMVFC_HOST_IO_BUS, DID_ERROR, 1, 1, "host I/O bus failure" },
121 { IBMVFC_VIOS_FAILURE, IBMVFC_TRANS_CANCELLED, DID_ABORT, 0, 1, "transaction cancelled" }, 121 { IBMVFC_VIOS_FAILURE, IBMVFC_TRANS_CANCELLED, DID_ERROR, 0, 1, "transaction cancelled" },
122 { IBMVFC_VIOS_FAILURE, IBMVFC_TRANS_CANCELLED_IMPLICIT, DID_ABORT, 0, 1, "transaction cancelled implicit" }, 122 { IBMVFC_VIOS_FAILURE, IBMVFC_TRANS_CANCELLED_IMPLICIT, DID_ERROR, 0, 1, "transaction cancelled implicit" },
123 { IBMVFC_VIOS_FAILURE, IBMVFC_INSUFFICIENT_RESOURCE, DID_REQUEUE, 1, 1, "insufficient resources" }, 123 { IBMVFC_VIOS_FAILURE, IBMVFC_INSUFFICIENT_RESOURCE, DID_REQUEUE, 1, 1, "insufficient resources" },
124 { IBMVFC_VIOS_FAILURE, IBMVFC_PLOGI_REQUIRED, DID_ERROR, 0, 1, "port login required" }, 124 { IBMVFC_VIOS_FAILURE, IBMVFC_PLOGI_REQUIRED, DID_ERROR, 0, 1, "port login required" },
125 { IBMVFC_VIOS_FAILURE, IBMVFC_COMMAND_FAILED, DID_ERROR, 1, 1, "command failed" }, 125 { IBMVFC_VIOS_FAILURE, IBMVFC_COMMAND_FAILED, DID_ERROR, 1, 1, "command failed" },
@@ -933,7 +933,7 @@ static void ibmvfc_get_host_speed(struct Scsi_Host *shost)
933 fc_host_speed(shost) = FC_PORTSPEED_16GBIT; 933 fc_host_speed(shost) = FC_PORTSPEED_16GBIT;
934 break; 934 break;
935 default: 935 default:
936 ibmvfc_log(vhost, 3, "Unknown port speed: %ld Gbit\n", 936 ibmvfc_log(vhost, 3, "Unknown port speed: %lld Gbit\n",
937 vhost->login_buf->resp.link_speed / 100); 937 vhost->login_buf->resp.link_speed / 100);
938 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; 938 fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
939 break; 939 break;
@@ -1145,10 +1145,10 @@ static void ibmvfc_set_login_info(struct ibmvfc_host *vhost)
1145 login_info->async.len = vhost->async_crq.size * sizeof(*vhost->async_crq.msgs); 1145 login_info->async.len = vhost->async_crq.size * sizeof(*vhost->async_crq.msgs);
1146 strncpy(login_info->partition_name, vhost->partition_name, IBMVFC_MAX_NAME); 1146 strncpy(login_info->partition_name, vhost->partition_name, IBMVFC_MAX_NAME);
1147 strncpy(login_info->device_name, 1147 strncpy(login_info->device_name,
1148 vhost->host->shost_gendev.bus_id, IBMVFC_MAX_NAME); 1148 dev_name(&vhost->host->shost_gendev), IBMVFC_MAX_NAME);
1149 1149
1150 location = of_get_property(of_node, "ibm,loc-code", NULL); 1150 location = of_get_property(of_node, "ibm,loc-code", NULL);
1151 location = location ? location : vhost->dev->bus_id; 1151 location = location ? location : dev_name(vhost->dev);
1152 strncpy(login_info->drc_name, location, IBMVFC_MAX_NAME); 1152 strncpy(login_info->drc_name, location, IBMVFC_MAX_NAME);
1153} 1153}
1154 1154
@@ -2149,8 +2149,8 @@ static void ibmvfc_handle_async(struct ibmvfc_async_crq *crq,
2149{ 2149{
2150 const char *desc = ibmvfc_get_ae_desc(crq->event); 2150 const char *desc = ibmvfc_get_ae_desc(crq->event);
2151 2151
2152 ibmvfc_log(vhost, 3, "%s event received. scsi_id: %lx, wwpn: %lx," 2152 ibmvfc_log(vhost, 3, "%s event received. scsi_id: %llx, wwpn: %llx,"
2153 " node_name: %lx\n", desc, crq->scsi_id, crq->wwpn, crq->node_name); 2153 " node_name: %llx\n", desc, crq->scsi_id, crq->wwpn, crq->node_name);
2154 2154
2155 switch (crq->event) { 2155 switch (crq->event) {
2156 case IBMVFC_AE_LINK_UP: 2156 case IBMVFC_AE_LINK_UP:
@@ -2184,7 +2184,7 @@ static void ibmvfc_handle_async(struct ibmvfc_async_crq *crq,
2184 ibmvfc_link_down(vhost, IBMVFC_HALTED); 2184 ibmvfc_link_down(vhost, IBMVFC_HALTED);
2185 break; 2185 break;
2186 default: 2186 default:
2187 dev_err(vhost->dev, "Unknown async event received: %ld\n", crq->event); 2187 dev_err(vhost->dev, "Unknown async event received: %lld\n", crq->event);
2188 break; 2188 break;
2189 }; 2189 };
2190} 2190}
@@ -2261,13 +2261,13 @@ static void ibmvfc_handle_crq(struct ibmvfc_crq *crq, struct ibmvfc_host *vhost)
2261 * actually sent 2261 * actually sent
2262 */ 2262 */
2263 if (unlikely(!ibmvfc_valid_event(&vhost->pool, evt))) { 2263 if (unlikely(!ibmvfc_valid_event(&vhost->pool, evt))) {
2264 dev_err(vhost->dev, "Returned correlation_token 0x%08lx is invalid!\n", 2264 dev_err(vhost->dev, "Returned correlation_token 0x%08llx is invalid!\n",
2265 crq->ioba); 2265 crq->ioba);
2266 return; 2266 return;
2267 } 2267 }
2268 2268
2269 if (unlikely(atomic_read(&evt->free))) { 2269 if (unlikely(atomic_read(&evt->free))) {
2270 dev_err(vhost->dev, "Received duplicate correlation_token 0x%08lx!\n", 2270 dev_err(vhost->dev, "Received duplicate correlation_token 0x%08llx!\n",
2271 crq->ioba); 2271 crq->ioba);
2272 return; 2272 return;
2273 } 2273 }
@@ -3259,7 +3259,7 @@ static int ibmvfc_alloc_target(struct ibmvfc_host *vhost, u64 scsi_id)
3259 3259
3260 tgt = mempool_alloc(vhost->tgt_pool, GFP_KERNEL); 3260 tgt = mempool_alloc(vhost->tgt_pool, GFP_KERNEL);
3261 if (!tgt) { 3261 if (!tgt) {
3262 dev_err(vhost->dev, "Target allocation failure for scsi id %08lx\n", 3262 dev_err(vhost->dev, "Target allocation failure for scsi id %08llx\n",
3263 scsi_id); 3263 scsi_id);
3264 return -ENOMEM; 3264 return -ENOMEM;
3265 } 3265 }
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.h b/drivers/scsi/ibmvscsi/ibmvfc.h
index babdf3db59df..87dafd0f8d44 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.h
+++ b/drivers/scsi/ibmvscsi/ibmvfc.h
@@ -691,13 +691,13 @@ struct ibmvfc_host {
691#define DBG_CMD(CMD) do { if (ibmvfc_debug) CMD; } while (0) 691#define DBG_CMD(CMD) do { if (ibmvfc_debug) CMD; } while (0)
692 692
693#define tgt_dbg(t, fmt, ...) \ 693#define tgt_dbg(t, fmt, ...) \
694 DBG_CMD(dev_info((t)->vhost->dev, "%lX: " fmt, (t)->scsi_id, ##__VA_ARGS__)) 694 DBG_CMD(dev_info((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__))
695 695
696#define tgt_info(t, fmt, ...) \ 696#define tgt_info(t, fmt, ...) \
697 dev_info((t)->vhost->dev, "%lX: " fmt, (t)->scsi_id, ##__VA_ARGS__) 697 dev_info((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__)
698 698
699#define tgt_err(t, fmt, ...) \ 699#define tgt_err(t, fmt, ...) \
700 dev_err((t)->vhost->dev, "%lX: " fmt, (t)->scsi_id, ##__VA_ARGS__) 700 dev_err((t)->vhost->dev, "%llX: " fmt, (t)->scsi_id, ##__VA_ARGS__)
701 701
702#define ibmvfc_dbg(vhost, ...) \ 702#define ibmvfc_dbg(vhost, ...) \
703 DBG_CMD(dev_info((vhost)->dev, ##__VA_ARGS__)) 703 DBG_CMD(dev_info((vhost)->dev, ##__VA_ARGS__))
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index 868d35ea01bb..74d07d137dae 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -89,6 +89,7 @@ static int max_id = 64;
89static int max_channel = 3; 89static int max_channel = 3;
90static int init_timeout = 5; 90static int init_timeout = 5;
91static int max_requests = IBMVSCSI_MAX_REQUESTS_DEFAULT; 91static int max_requests = IBMVSCSI_MAX_REQUESTS_DEFAULT;
92static int max_events = IBMVSCSI_MAX_REQUESTS_DEFAULT + 2;
92 93
93static struct scsi_transport_template *ibmvscsi_transport_template; 94static struct scsi_transport_template *ibmvscsi_transport_template;
94 95
@@ -1060,7 +1061,7 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd)
1060 } 1061 }
1061 1062
1062 sdev_printk(KERN_INFO, cmd->device, 1063 sdev_printk(KERN_INFO, cmd->device,
1063 "aborting command. lun 0x%lx, tag 0x%lx\n", 1064 "aborting command. lun 0x%llx, tag 0x%llx\n",
1064 (((u64) lun) << 48), (u64) found_evt); 1065 (((u64) lun) << 48), (u64) found_evt);
1065 1066
1066 wait_for_completion(&evt->comp); 1067 wait_for_completion(&evt->comp);
@@ -1081,7 +1082,7 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd)
1081 if (rsp_rc) { 1082 if (rsp_rc) {
1082 if (printk_ratelimit()) 1083 if (printk_ratelimit())
1083 sdev_printk(KERN_WARNING, cmd->device, 1084 sdev_printk(KERN_WARNING, cmd->device,
1084 "abort code %d for task tag 0x%lx\n", 1085 "abort code %d for task tag 0x%llx\n",
1085 rsp_rc, tsk_mgmt->task_tag); 1086 rsp_rc, tsk_mgmt->task_tag);
1086 return FAILED; 1087 return FAILED;
1087 } 1088 }
@@ -1101,12 +1102,12 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd)
1101 1102
1102 if (found_evt == NULL) { 1103 if (found_evt == NULL) {
1103 spin_unlock_irqrestore(hostdata->host->host_lock, flags); 1104 spin_unlock_irqrestore(hostdata->host->host_lock, flags);
1104 sdev_printk(KERN_INFO, cmd->device, "aborted task tag 0x%lx completed\n", 1105 sdev_printk(KERN_INFO, cmd->device, "aborted task tag 0x%llx completed\n",
1105 tsk_mgmt->task_tag); 1106 tsk_mgmt->task_tag);
1106 return SUCCESS; 1107 return SUCCESS;
1107 } 1108 }
1108 1109
1109 sdev_printk(KERN_INFO, cmd->device, "successfully aborted task tag 0x%lx\n", 1110 sdev_printk(KERN_INFO, cmd->device, "successfully aborted task tag 0x%llx\n",
1110 tsk_mgmt->task_tag); 1111 tsk_mgmt->task_tag);
1111 1112
1112 cmd->result = (DID_ABORT << 16); 1113 cmd->result = (DID_ABORT << 16);
@@ -1181,7 +1182,7 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd)
1181 return FAILED; 1182 return FAILED;
1182 } 1183 }
1183 1184
1184 sdev_printk(KERN_INFO, cmd->device, "resetting device. lun 0x%lx\n", 1185 sdev_printk(KERN_INFO, cmd->device, "resetting device. lun 0x%llx\n",
1185 (((u64) lun) << 48)); 1186 (((u64) lun) << 48));
1186 1187
1187 wait_for_completion(&evt->comp); 1188 wait_for_completion(&evt->comp);
@@ -1202,7 +1203,7 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd)
1202 if (rsp_rc) { 1203 if (rsp_rc) {
1203 if (printk_ratelimit()) 1204 if (printk_ratelimit())
1204 sdev_printk(KERN_WARNING, cmd->device, 1205 sdev_printk(KERN_WARNING, cmd->device,
1205 "reset code %d for task tag 0x%lx\n", 1206 "reset code %d for task tag 0x%llx\n",
1206 rsp_rc, tsk_mgmt->task_tag); 1207 rsp_rc, tsk_mgmt->task_tag);
1207 return FAILED; 1208 return FAILED;
1208 } 1209 }
@@ -1633,7 +1634,7 @@ static struct scsi_host_template driver_template = {
1633static unsigned long ibmvscsi_get_desired_dma(struct vio_dev *vdev) 1634static unsigned long ibmvscsi_get_desired_dma(struct vio_dev *vdev)
1634{ 1635{
1635 /* iu_storage data allocated in initialize_event_pool */ 1636 /* iu_storage data allocated in initialize_event_pool */
1636 unsigned long desired_io = max_requests * sizeof(union viosrp_iu); 1637 unsigned long desired_io = max_events * sizeof(union viosrp_iu);
1637 1638
1638 /* add io space for sg data */ 1639 /* add io space for sg data */
1639 desired_io += (IBMVSCSI_MAX_SECTORS_DEFAULT * 512 * 1640 desired_io += (IBMVSCSI_MAX_SECTORS_DEFAULT * 512 *
@@ -1657,7 +1658,6 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id)
1657 1658
1658 vdev->dev.driver_data = NULL; 1659 vdev->dev.driver_data = NULL;
1659 1660
1660 driver_template.can_queue = max_requests - 2;
1661 host = scsi_host_alloc(&driver_template, sizeof(*hostdata)); 1661 host = scsi_host_alloc(&driver_template, sizeof(*hostdata));
1662 if (!host) { 1662 if (!host) {
1663 dev_err(&vdev->dev, "couldn't allocate host data\n"); 1663 dev_err(&vdev->dev, "couldn't allocate host data\n");
@@ -1673,12 +1673,12 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id)
1673 atomic_set(&hostdata->request_limit, -1); 1673 atomic_set(&hostdata->request_limit, -1);
1674 hostdata->host->max_sectors = IBMVSCSI_MAX_SECTORS_DEFAULT; 1674 hostdata->host->max_sectors = IBMVSCSI_MAX_SECTORS_DEFAULT;
1675 1675
1676 rc = ibmvscsi_ops->init_crq_queue(&hostdata->queue, hostdata, max_requests); 1676 rc = ibmvscsi_ops->init_crq_queue(&hostdata->queue, hostdata, max_events);
1677 if (rc != 0 && rc != H_RESOURCE) { 1677 if (rc != 0 && rc != H_RESOURCE) {
1678 dev_err(&vdev->dev, "couldn't initialize crq. rc=%d\n", rc); 1678 dev_err(&vdev->dev, "couldn't initialize crq. rc=%d\n", rc);
1679 goto init_crq_failed; 1679 goto init_crq_failed;
1680 } 1680 }
1681 if (initialize_event_pool(&hostdata->pool, max_requests, hostdata) != 0) { 1681 if (initialize_event_pool(&hostdata->pool, max_events, hostdata) != 0) {
1682 dev_err(&vdev->dev, "couldn't initialize event pool\n"); 1682 dev_err(&vdev->dev, "couldn't initialize event pool\n");
1683 goto init_pool_failed; 1683 goto init_pool_failed;
1684 } 1684 }
@@ -1730,7 +1730,7 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id)
1730 add_host_failed: 1730 add_host_failed:
1731 release_event_pool(&hostdata->pool, hostdata); 1731 release_event_pool(&hostdata->pool, hostdata);
1732 init_pool_failed: 1732 init_pool_failed:
1733 ibmvscsi_ops->release_crq_queue(&hostdata->queue, hostdata, max_requests); 1733 ibmvscsi_ops->release_crq_queue(&hostdata->queue, hostdata, max_events);
1734 init_crq_failed: 1734 init_crq_failed:
1735 scsi_host_put(host); 1735 scsi_host_put(host);
1736 scsi_host_alloc_failed: 1736 scsi_host_alloc_failed:
@@ -1742,7 +1742,7 @@ static int ibmvscsi_remove(struct vio_dev *vdev)
1742 struct ibmvscsi_host_data *hostdata = vdev->dev.driver_data; 1742 struct ibmvscsi_host_data *hostdata = vdev->dev.driver_data;
1743 release_event_pool(&hostdata->pool, hostdata); 1743 release_event_pool(&hostdata->pool, hostdata);
1744 ibmvscsi_ops->release_crq_queue(&hostdata->queue, hostdata, 1744 ibmvscsi_ops->release_crq_queue(&hostdata->queue, hostdata,
1745 max_requests); 1745 max_events);
1746 1746
1747 srp_remove_host(hostdata->host); 1747 srp_remove_host(hostdata->host);
1748 scsi_remove_host(hostdata->host); 1748 scsi_remove_host(hostdata->host);
@@ -1779,6 +1779,10 @@ int __init ibmvscsi_module_init(void)
1779{ 1779{
1780 int ret; 1780 int ret;
1781 1781
1782 /* Ensure we have two requests to do error recovery */
1783 driver_template.can_queue = max_requests;
1784 max_events = max_requests + 2;
1785
1782 if (firmware_has_feature(FW_FEATURE_ISERIES)) 1786 if (firmware_has_feature(FW_FEATURE_ISERIES))
1783 ibmvscsi_ops = &iseriesvscsi_ops; 1787 ibmvscsi_ops = &iseriesvscsi_ops;
1784 else if (firmware_has_feature(FW_FEATURE_VIO)) 1788 else if (firmware_has_feature(FW_FEATURE_VIO))
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 0edfb1fa63ce..07829009a8be 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -2184,7 +2184,7 @@ static void ipr_dump_location_data(struct ipr_ioa_cfg *ioa_cfg,
2184 sizeof(struct ipr_dump_entry_header); 2184 sizeof(struct ipr_dump_entry_header);
2185 driver_dump->location_entry.hdr.data_type = IPR_DUMP_DATA_TYPE_ASCII; 2185 driver_dump->location_entry.hdr.data_type = IPR_DUMP_DATA_TYPE_ASCII;
2186 driver_dump->location_entry.hdr.id = IPR_DUMP_LOCATION_ID; 2186 driver_dump->location_entry.hdr.id = IPR_DUMP_LOCATION_ID;
2187 strcpy(driver_dump->location_entry.location, ioa_cfg->pdev->dev.bus_id); 2187 strcpy(driver_dump->location_entry.location, dev_name(&ioa_cfg->pdev->dev));
2188 driver_dump->hdr.num_entries++; 2188 driver_dump->hdr.num_entries++;
2189} 2189}
2190 2190
@@ -4912,7 +4912,7 @@ static int ipr_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
4912 if (res && ipr_is_gata(res)) { 4912 if (res && ipr_is_gata(res)) {
4913 if (cmd == HDIO_GET_IDENTITY) 4913 if (cmd == HDIO_GET_IDENTITY)
4914 return -ENOTTY; 4914 return -ENOTTY;
4915 return ata_scsi_ioctl(sdev, cmd, arg); 4915 return ata_sas_scsi_ioctl(res->sata_port->ap, sdev, cmd, arg);
4916 } 4916 }
4917 4917
4918 return -EINVAL; 4918 return -EINVAL;
diff --git a/drivers/scsi/ipr.h b/drivers/scsi/ipr.h
index 59459141b437..8f872f816fe4 100644
--- a/drivers/scsi/ipr.h
+++ b/drivers/scsi/ipr.h
@@ -1272,7 +1272,7 @@ struct ipr_dump_entry_header {
1272 1272
1273struct ipr_dump_location_entry { 1273struct ipr_dump_location_entry {
1274 struct ipr_dump_entry_header hdr; 1274 struct ipr_dump_entry_header hdr;
1275 u8 location[BUS_ID_SIZE]; 1275 u8 location[20];
1276}__attribute__((packed)); 1276}__attribute__((packed));
1277 1277
1278struct ipr_dump_trace_entry { 1278struct ipr_dump_trace_entry {
diff --git a/drivers/scsi/lasi700.c b/drivers/scsi/lasi700.c
index 3126824da36d..4a4e6954ec79 100644
--- a/drivers/scsi/lasi700.c
+++ b/drivers/scsi/lasi700.c
@@ -103,8 +103,7 @@ lasi700_probe(struct parisc_device *dev)
103 103
104 hostdata = kzalloc(sizeof(*hostdata), GFP_KERNEL); 104 hostdata = kzalloc(sizeof(*hostdata), GFP_KERNEL);
105 if (!hostdata) { 105 if (!hostdata) {
106 printk(KERN_ERR "%s: Failed to allocate host data\n", 106 dev_printk(KERN_ERR, dev, "Failed to allocate host data\n");
107 dev->dev.bus_id);
108 return -ENOMEM; 107 return -ENOMEM;
109 } 108 }
110 109
diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c
index a745f91d2928..e7705d3532c9 100644
--- a/drivers/scsi/libiscsi_tcp.c
+++ b/drivers/scsi/libiscsi_tcp.c
@@ -177,7 +177,6 @@ int iscsi_tcp_segment_done(struct iscsi_tcp_conn *tcp_conn,
177 struct iscsi_segment *segment, int recv, 177 struct iscsi_segment *segment, int recv,
178 unsigned copied) 178 unsigned copied)
179{ 179{
180 static unsigned char padbuf[ISCSI_PAD_LEN];
181 struct scatterlist sg; 180 struct scatterlist sg;
182 unsigned int pad; 181 unsigned int pad;
183 182
@@ -233,7 +232,7 @@ int iscsi_tcp_segment_done(struct iscsi_tcp_conn *tcp_conn,
233 debug_tcp("consume %d pad bytes\n", pad); 232 debug_tcp("consume %d pad bytes\n", pad);
234 segment->total_size += pad; 233 segment->total_size += pad;
235 segment->size = pad; 234 segment->size = pad;
236 segment->data = padbuf; 235 segment->data = segment->padbuf;
237 return 0; 236 return 0;
238 } 237 }
239 } 238 }
diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c
index 709a6f75ca9d..facc5bfcf7db 100644
--- a/drivers/scsi/libsas/sas_discover.c
+++ b/drivers/scsi/libsas/sas_discover.c
@@ -169,7 +169,7 @@ int sas_notify_lldd_dev_found(struct domain_device *dev)
169 if (res) { 169 if (res) {
170 printk("sas: driver on pcidev %s cannot handle " 170 printk("sas: driver on pcidev %s cannot handle "
171 "device %llx, error:%d\n", 171 "device %llx, error:%d\n",
172 sas_ha->dev->bus_id, 172 dev_name(sas_ha->dev),
173 SAS_ADDR(dev->sas_addr), res); 173 SAS_ADDR(dev->sas_addr), res);
174 } 174 }
175 } 175 }
diff --git a/drivers/scsi/libsas/sas_dump.c b/drivers/scsi/libsas/sas_dump.c
index bf34a236f946..c17c25030f1c 100644
--- a/drivers/scsi/libsas/sas_dump.c
+++ b/drivers/scsi/libsas/sas_dump.c
@@ -56,7 +56,7 @@ void sas_dprint_phye(int phyid, enum phy_event pe)
56 56
57void sas_dprint_hae(struct sas_ha_struct *sas_ha, enum ha_event he) 57void sas_dprint_hae(struct sas_ha_struct *sas_ha, enum ha_event he)
58{ 58{
59 SAS_DPRINTK("ha %s: %s event\n", sas_ha->dev->bus_id, 59 SAS_DPRINTK("ha %s: %s event\n", dev_name(sas_ha->dev),
60 sas_hae_str[he]); 60 sas_hae_str[he]);
61} 61}
62 62
diff --git a/drivers/scsi/libsas/sas_host_smp.c b/drivers/scsi/libsas/sas_host_smp.c
index 16f93123271e..d110a366c48a 100644
--- a/drivers/scsi/libsas/sas_host_smp.c
+++ b/drivers/scsi/libsas/sas_host_smp.c
@@ -199,8 +199,8 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
199 break; 199 break;
200 200
201 case SMP_DISCOVER: 201 case SMP_DISCOVER:
202 req->data_len =- 16; 202 req->data_len -= 16;
203 if (req->data_len < 0) { 203 if ((int)req->data_len < 0) {
204 req->data_len = 0; 204 req->data_len = 0;
205 error = -EINVAL; 205 error = -EINVAL;
206 goto out; 206 goto out;
@@ -215,8 +215,8 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
215 break; 215 break;
216 216
217 case SMP_REPORT_PHY_SATA: 217 case SMP_REPORT_PHY_SATA:
218 req->data_len =- 16; 218 req->data_len -= 16;
219 if (req->data_len < 0) { 219 if ((int)req->data_len < 0) {
220 req->data_len = 0; 220 req->data_len = 0;
221 error = -EINVAL; 221 error = -EINVAL;
222 goto out; 222 goto out;
@@ -238,8 +238,8 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
238 break; 238 break;
239 239
240 case SMP_PHY_CONTROL: 240 case SMP_PHY_CONTROL:
241 req->data_len =- 44; 241 req->data_len -= 44;
242 if (req->data_len < 0) { 242 if ((int)req->data_len < 0) {
243 req->data_len = 0; 243 req->data_len = 0;
244 error = -EINVAL; 244 error = -EINVAL;
245 goto out; 245 goto out;
diff --git a/drivers/scsi/libsas/sas_port.c b/drivers/scsi/libsas/sas_port.c
index 139935a121b4..e6ac59c023f1 100644
--- a/drivers/scsi/libsas/sas_port.c
+++ b/drivers/scsi/libsas/sas_port.c
@@ -113,7 +113,7 @@ static void sas_form_port(struct asd_sas_phy *phy)
113 sas_port_add_phy(port->port, phy->phy); 113 sas_port_add_phy(port->port, phy->phy);
114 114
115 SAS_DPRINTK("%s added to %s, phy_mask:0x%x (%16llx)\n", 115 SAS_DPRINTK("%s added to %s, phy_mask:0x%x (%16llx)\n",
116 phy->phy->dev.bus_id,port->port->dev.bus_id, 116 dev_name(&phy->phy->dev), dev_name(&port->port->dev),
117 port->phy_mask, 117 port->phy_mask,
118 SAS_ADDR(port->attached_sas_addr)); 118 SAS_ADDR(port->attached_sas_addr));
119 119
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index 744838780ada..1c558d3bce18 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -717,7 +717,7 @@ int sas_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
717 struct domain_device *dev = sdev_to_domain_dev(sdev); 717 struct domain_device *dev = sdev_to_domain_dev(sdev);
718 718
719 if (dev_is_sata(dev)) 719 if (dev_is_sata(dev))
720 return ata_scsi_ioctl(sdev, cmd, arg); 720 return ata_sas_scsi_ioctl(dev->sata_dev.ap, sdev, cmd, arg);
721 721
722 return -EINVAL; 722 return -EINVAL;
723} 723}
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index 8c64494444bf..311ed6dea726 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -1964,10 +1964,10 @@ lpfc_set_disctmo(struct lpfc_vport *vport)
1964 uint32_t tmo; 1964 uint32_t tmo;
1965 1965
1966 if (vport->port_state == LPFC_LOCAL_CFG_LINK) { 1966 if (vport->port_state == LPFC_LOCAL_CFG_LINK) {
1967 /* For FAN, timeout should be greater then edtov */ 1967 /* For FAN, timeout should be greater than edtov */
1968 tmo = (((phba->fc_edtov + 999) / 1000) + 1); 1968 tmo = (((phba->fc_edtov + 999) / 1000) + 1);
1969 } else { 1969 } else {
1970 /* Normal discovery timeout should be > then ELS/CT timeout 1970 /* Normal discovery timeout should be > than ELS/CT timeout
1971 * FC spec states we need 3 * ratov for CT requests 1971 * FC spec states we need 3 * ratov for CT requests
1972 */ 1972 */
1973 tmo = ((phba->fc_ratov * 3) + 3); 1973 tmo = ((phba->fc_ratov * 3) + 3);
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 4c77038c8f1c..6c867311cef1 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -1795,12 +1795,13 @@ lpfc_block_mgmt_io(struct lpfc_hba * phba)
1795int 1795int
1796lpfc_online(struct lpfc_hba *phba) 1796lpfc_online(struct lpfc_hba *phba)
1797{ 1797{
1798 struct lpfc_vport *vport = phba->pport; 1798 struct lpfc_vport *vport;
1799 struct lpfc_vport **vports; 1799 struct lpfc_vport **vports;
1800 int i; 1800 int i;
1801 1801
1802 if (!phba) 1802 if (!phba)
1803 return 0; 1803 return 0;
1804 vport = phba->pport;
1804 1805
1805 if (!(vport->fc_flag & FC_OFFLINE_MODE)) 1806 if (!(vport->fc_flag & FC_OFFLINE_MODE))
1806 return 0; 1807 return 0;
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 01dfdc8696f8..a36a120561e2 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -420,7 +420,7 @@ lpfc_sli_next_iocb_slot (struct lpfc_hba *phba, struct lpfc_sli_ring *pring)
420 if (unlikely(pring->local_getidx >= max_cmd_idx)) { 420 if (unlikely(pring->local_getidx >= max_cmd_idx)) {
421 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 421 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
422 "0315 Ring %d issue: portCmdGet %d " 422 "0315 Ring %d issue: portCmdGet %d "
423 "is bigger then cmd ring %d\n", 423 "is bigger than cmd ring %d\n",
424 pring->ringno, 424 pring->ringno,
425 pring->local_getidx, max_cmd_idx); 425 pring->local_getidx, max_cmd_idx);
426 426
@@ -1628,12 +1628,12 @@ lpfc_sli_rsp_pointers_error(struct lpfc_hba *phba, struct lpfc_sli_ring *pring)
1628{ 1628{
1629 struct lpfc_pgp *pgp = &phba->port_gp[pring->ringno]; 1629 struct lpfc_pgp *pgp = &phba->port_gp[pring->ringno];
1630 /* 1630 /*
1631 * Ring <ringno> handler: portRspPut <portRspPut> is bigger then 1631 * Ring <ringno> handler: portRspPut <portRspPut> is bigger than
1632 * rsp ring <portRspMax> 1632 * rsp ring <portRspMax>
1633 */ 1633 */
1634 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 1634 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
1635 "0312 Ring %d handler: portRspPut %d " 1635 "0312 Ring %d handler: portRspPut %d "
1636 "is bigger then rsp ring %d\n", 1636 "is bigger than rsp ring %d\n",
1637 pring->ringno, le32_to_cpu(pgp->rspPutInx), 1637 pring->ringno, le32_to_cpu(pgp->rspPutInx),
1638 pring->numRiocb); 1638 pring->numRiocb);
1639 1639
@@ -2083,12 +2083,12 @@ lpfc_sli_handle_slow_ring_event(struct lpfc_hba *phba,
2083 portRspPut = le32_to_cpu(pgp->rspPutInx); 2083 portRspPut = le32_to_cpu(pgp->rspPutInx);
2084 if (portRspPut >= portRspMax) { 2084 if (portRspPut >= portRspMax) {
2085 /* 2085 /*
2086 * Ring <ringno> handler: portRspPut <portRspPut> is bigger then 2086 * Ring <ringno> handler: portRspPut <portRspPut> is bigger than
2087 * rsp ring <portRspMax> 2087 * rsp ring <portRspMax>
2088 */ 2088 */
2089 lpfc_printf_log(phba, KERN_ERR, LOG_SLI, 2089 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
2090 "0303 Ring %d handler: portRspPut %d " 2090 "0303 Ring %d handler: portRspPut %d "
2091 "is bigger then rsp ring %d\n", 2091 "is bigger than rsp ring %d\n",
2092 pring->ringno, portRspPut, portRspMax); 2092 pring->ringno, portRspPut, portRspMax);
2093 2093
2094 phba->link_state = LPFC_HBA_ERROR; 2094 phba->link_state = LPFC_HBA_ERROR;
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 7dc62deb4087..9fdcd60c5493 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -1967,8 +1967,8 @@ megaraid_abort_and_reset(adapter_t *adapter, Scsi_Cmnd *cmd, int aor)
1967 scb->state |= aor; 1967 scb->state |= aor;
1968 1968
1969 /* 1969 /*
1970 * Check if this command has firmare owenership. If 1970 * Check if this command has firmware ownership. If
1971 * yes, we cannot reset this command. Whenever, f/w 1971 * yes, we cannot reset this command. Whenever f/w
1972 * completes this command, we will return appropriate 1972 * completes this command, we will return appropriate
1973 * status from ISR. 1973 * status from ISR.
1974 */ 1974 */
diff --git a/drivers/scsi/mvsas.c b/drivers/scsi/mvsas.c
index 1dd70d7a4947..23e5a876bb10 100644
--- a/drivers/scsi/mvsas.c
+++ b/drivers/scsi/mvsas.c
@@ -2959,7 +2959,7 @@ static int __devinit mvs_hw_init(struct mvs_info *mvi)
2959 2959
2960 /* enable auto port detection */ 2960 /* enable auto port detection */
2961 mw32(GBL_PORT_TYPE, MODE_AUTO_DET_EN); 2961 mw32(GBL_PORT_TYPE, MODE_AUTO_DET_EN);
2962 msleep(100); 2962 msleep(1100);
2963 /* init and reset phys */ 2963 /* init and reset phys */
2964 for (i = 0; i < mvi->chip->n_phy; i++) { 2964 for (i = 0; i < mvi->chip->n_phy; i++) {
2965 u32 lo = be32_to_cpu(*(u32 *)&mvi->sas_addr[4]); 2965 u32 lo = be32_to_cpu(*(u32 *)&mvi->sas_addr[4]);
diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c
index 165ff884f48e..67cde0138061 100644
--- a/drivers/scsi/pcmcia/aha152x_stub.c
+++ b/drivers/scsi/pcmcia/aha152x_stub.c
@@ -114,7 +114,7 @@ static int aha152x_probe(struct pcmcia_device *link)
114 link->io.NumPorts1 = 0x20; 114 link->io.NumPorts1 = 0x20;
115 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 115 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
116 link->io.IOAddrLines = 10; 116 link->io.IOAddrLines = 10;
117 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 117 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
118 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 118 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
119 link->conf.Attributes = CONF_ENABLE_IRQ; 119 link->conf.Attributes = CONF_ENABLE_IRQ;
120 link->conf.IntType = INT_MEMORY_AND_IO; 120 link->conf.IntType = INT_MEMORY_AND_IO;
diff --git a/drivers/scsi/ps3rom.c b/drivers/scsi/ps3rom.c
index ce48e2d0193c..ca0dd33497ec 100644
--- a/drivers/scsi/ps3rom.c
+++ b/drivers/scsi/ps3rom.c
@@ -290,11 +290,11 @@ static irqreturn_t ps3rom_interrupt(int irq, void *data)
290 290
291 if (tag != dev->tag) 291 if (tag != dev->tag)
292 dev_err(&dev->sbd.core, 292 dev_err(&dev->sbd.core,
293 "%s:%u: tag mismatch, got %lx, expected %lx\n", 293 "%s:%u: tag mismatch, got %llx, expected %llx\n",
294 __func__, __LINE__, tag, dev->tag); 294 __func__, __LINE__, tag, dev->tag);
295 295
296 if (res) { 296 if (res) {
297 dev_err(&dev->sbd.core, "%s:%u: res=%d status=0x%lx\n", 297 dev_err(&dev->sbd.core, "%s:%u: res=%d status=0x%llx\n",
298 __func__, __LINE__, res, status); 298 __func__, __LINE__, res, status);
299 return IRQ_HANDLED; 299 return IRQ_HANDLED;
300 } 300 }
@@ -364,7 +364,7 @@ static int __devinit ps3rom_probe(struct ps3_system_bus_device *_dev)
364 364
365 if (dev->blk_size != CD_FRAMESIZE) { 365 if (dev->blk_size != CD_FRAMESIZE) {
366 dev_err(&dev->sbd.core, 366 dev_err(&dev->sbd.core,
367 "%s:%u: cannot handle block size %lu\n", __func__, 367 "%s:%u: cannot handle block size %llu\n", __func__,
368 __LINE__, dev->blk_size); 368 __LINE__, dev->blk_size);
369 return -EINVAL; 369 return -EINVAL;
370 } 370 }
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index 8cb9240596ab..df09820e8916 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -128,7 +128,7 @@
128 - Integrate ql12160_set_target_parameters() with 1280 version 128 - Integrate ql12160_set_target_parameters() with 1280 version
129 - Make qla1280_setup() non static 129 - Make qla1280_setup() non static
130 - Do not call qla1280_check_for_dead_scsi_bus() on every I/O request 130 - Do not call qla1280_check_for_dead_scsi_bus() on every I/O request
131 sent to the card - this command pauses the firmare!!! 131 sent to the card - this command pauses the firmware!!!
132 Rev 3.23.15 Beta March 19, 2002, Jes Sorensen 132 Rev 3.23.15 Beta March 19, 2002, Jes Sorensen
133 - Clean up qla1280.h - remove obsolete QL_DEBUG_LEVEL_x definitions 133 - Clean up qla1280.h - remove obsolete QL_DEBUG_LEVEL_x definitions
134 - Remove a pile of pointless and confusing (srb_t **) and 134 - Remove a pile of pointless and confusing (srb_t **) and
@@ -659,7 +659,7 @@ static int qla1280_read_nvram(struct scsi_qla_host *ha)
659 /* The firmware interface is, um, interesting, in that the 659 /* The firmware interface is, um, interesting, in that the
660 * actual firmware image on the chip is little endian, thus, 660 * actual firmware image on the chip is little endian, thus,
661 * the process of taking that image to the CPU would end up 661 * the process of taking that image to the CPU would end up
662 * little endian. However, the firmare interface requires it 662 * little endian. However, the firmware interface requires it
663 * to be read a word (two bytes) at a time. 663 * to be read a word (two bytes) at a time.
664 * 664 *
665 * The net result of this would be that the word (and 665 * The net result of this would be that the word (and
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index cd53627cc761..c7acef50d5da 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -303,7 +303,7 @@ qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj,
303 else if (start == (ha->flt_region_boot * 4) || 303 else if (start == (ha->flt_region_boot * 4) ||
304 start == (ha->flt_region_fw * 4)) 304 start == (ha->flt_region_fw * 4))
305 valid = 1; 305 valid = 1;
306 else if (IS_QLA25XX(ha) && 306 else if ((IS_QLA25XX(ha) || IS_QLA81XX(ha)) &&
307 start == (ha->flt_region_vpd_nvram * 4)) 307 start == (ha->flt_region_vpd_nvram * 4))
308 valid = 1; 308 valid = 1;
309 if (!valid) { 309 if (!valid) {
@@ -815,6 +815,21 @@ qla2x00_total_isp_aborts_show(struct device *dev,
815 ha->qla_stats.total_isp_aborts); 815 ha->qla_stats.total_isp_aborts);
816} 816}
817 817
818static ssize_t
819qla2x00_mpi_version_show(struct device *dev, struct device_attribute *attr,
820 char *buf)
821{
822 scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
823 struct qla_hw_data *ha = vha->hw;
824
825 if (!IS_QLA81XX(ha))
826 return snprintf(buf, PAGE_SIZE, "\n");
827
828 return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x.%02x (%x)\n",
829 ha->mpi_version[0], ha->mpi_version[1], ha->mpi_version[2],
830 ha->mpi_version[3], ha->mpi_capabilities);
831}
832
818static DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, NULL); 833static DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, NULL);
819static DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL); 834static DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL);
820static DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL); 835static DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL);
@@ -839,6 +854,7 @@ static DEVICE_ATTR(optrom_fw_version, S_IRUGO, qla2x00_optrom_fw_version_show,
839 NULL); 854 NULL);
840static DEVICE_ATTR(total_isp_aborts, S_IRUGO, qla2x00_total_isp_aborts_show, 855static DEVICE_ATTR(total_isp_aborts, S_IRUGO, qla2x00_total_isp_aborts_show,
841 NULL); 856 NULL);
857static DEVICE_ATTR(mpi_version, S_IRUGO, qla2x00_mpi_version_show, NULL);
842 858
843struct device_attribute *qla2x00_host_attrs[] = { 859struct device_attribute *qla2x00_host_attrs[] = {
844 &dev_attr_driver_version, 860 &dev_attr_driver_version,
@@ -858,6 +874,7 @@ struct device_attribute *qla2x00_host_attrs[] = {
858 &dev_attr_optrom_fcode_version, 874 &dev_attr_optrom_fcode_version,
859 &dev_attr_optrom_fw_version, 875 &dev_attr_optrom_fw_version,
860 &dev_attr_total_isp_aborts, 876 &dev_attr_total_isp_aborts,
877 &dev_attr_mpi_version,
861 NULL, 878 NULL,
862}; 879};
863 880
@@ -892,6 +909,9 @@ qla2x00_get_host_speed(struct Scsi_Host *shost)
892 case PORT_SPEED_8GB: 909 case PORT_SPEED_8GB:
893 speed = FC_PORTSPEED_8GBIT; 910 speed = FC_PORTSPEED_8GBIT;
894 break; 911 break;
912 case PORT_SPEED_10GB:
913 speed = FC_PORTSPEED_10GBIT;
914 break;
895 } 915 }
896 fc_host_speed(shost) = speed; 916 fc_host_speed(shost) = speed;
897} 917}
@@ -1382,7 +1402,9 @@ qla2x00_init_host_attr(scsi_qla_host_t *vha)
1382 fc_host_max_npiv_vports(vha->host) = ha->max_npiv_vports; 1402 fc_host_max_npiv_vports(vha->host) = ha->max_npiv_vports;
1383 fc_host_npiv_vports_inuse(vha->host) = ha->cur_vport_count; 1403 fc_host_npiv_vports_inuse(vha->host) = ha->cur_vport_count;
1384 1404
1385 if (IS_QLA25XX(ha)) 1405 if (IS_QLA81XX(ha))
1406 speed = FC_PORTSPEED_10GBIT;
1407 else if (IS_QLA25XX(ha))
1386 speed = FC_PORTSPEED_8GBIT | FC_PORTSPEED_4GBIT | 1408 speed = FC_PORTSPEED_8GBIT | FC_PORTSPEED_4GBIT |
1387 FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT; 1409 FC_PORTSPEED_2GBIT | FC_PORTSPEED_1GBIT;
1388 else if (IS_QLA24XX_TYPE(ha)) 1410 else if (IS_QLA24XX_TYPE(ha))
diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
index 1cf77772623b..34760f8d4f17 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -310,6 +310,76 @@ qla2xxx_read_window(struct device_reg_2xxx __iomem *reg, uint32_t count,
310 *buf++ = htons(RD_REG_WORD(dmp_reg++)); 310 *buf++ = htons(RD_REG_WORD(dmp_reg++));
311} 311}
312 312
313static inline void *
314qla24xx_copy_eft(struct qla_hw_data *ha, void *ptr)
315{
316 if (!ha->eft)
317 return ptr;
318
319 memcpy(ptr, ha->eft, ntohl(ha->fw_dump->eft_size));
320 return ptr + ntohl(ha->fw_dump->eft_size);
321}
322
323static inline void *
324qla25xx_copy_fce(struct qla_hw_data *ha, void *ptr, uint32_t **last_chain)
325{
326 uint32_t cnt;
327 uint32_t *iter_reg;
328 struct qla2xxx_fce_chain *fcec = ptr;
329
330 if (!ha->fce)
331 return ptr;
332
333 *last_chain = &fcec->type;
334 fcec->type = __constant_htonl(DUMP_CHAIN_FCE);
335 fcec->chain_size = htonl(sizeof(struct qla2xxx_fce_chain) +
336 fce_calc_size(ha->fce_bufs));
337 fcec->size = htonl(fce_calc_size(ha->fce_bufs));
338 fcec->addr_l = htonl(LSD(ha->fce_dma));
339 fcec->addr_h = htonl(MSD(ha->fce_dma));
340
341 iter_reg = fcec->eregs;
342 for (cnt = 0; cnt < 8; cnt++)
343 *iter_reg++ = htonl(ha->fce_mb[cnt]);
344
345 memcpy(iter_reg, ha->fce, ntohl(fcec->size));
346
347 return iter_reg;
348}
349
350static inline void *
351qla25xx_copy_mq(struct qla_hw_data *ha, void *ptr, uint32_t **last_chain)
352{
353 uint32_t cnt, que_idx;
354 uint8_t req_cnt, rsp_cnt, que_cnt;
355 struct qla2xxx_mq_chain *mq = ptr;
356 struct device_reg_25xxmq __iomem *reg;
357
358 if (!ha->mqenable)
359 return ptr;
360
361 mq = ptr;
362 *last_chain = &mq->type;
363 mq->type = __constant_htonl(DUMP_CHAIN_MQ);
364 mq->chain_size = __constant_htonl(sizeof(struct qla2xxx_mq_chain));
365
366 req_cnt = find_first_zero_bit(ha->req_qid_map, ha->max_queues);
367 rsp_cnt = find_first_zero_bit(ha->rsp_qid_map, ha->max_queues);
368 que_cnt = req_cnt > rsp_cnt ? req_cnt : rsp_cnt;
369 mq->count = htonl(que_cnt);
370 for (cnt = 0; cnt < que_cnt; cnt++) {
371 reg = (struct device_reg_25xxmq *) ((void *)
372 ha->mqiobase + cnt * QLA_QUE_PAGE);
373 que_idx = cnt * 4;
374 mq->qregs[que_idx] = htonl(RD_REG_DWORD(&reg->req_q_in));
375 mq->qregs[que_idx+1] = htonl(RD_REG_DWORD(&reg->req_q_out));
376 mq->qregs[que_idx+2] = htonl(RD_REG_DWORD(&reg->rsp_q_in));
377 mq->qregs[que_idx+3] = htonl(RD_REG_DWORD(&reg->rsp_q_out));
378 }
379
380 return ptr + sizeof(struct qla2xxx_mq_chain);
381}
382
313/** 383/**
314 * qla2300_fw_dump() - Dumps binary data from the 2300 firmware. 384 * qla2300_fw_dump() - Dumps binary data from the 2300 firmware.
315 * @ha: HA context 385 * @ha: HA context
@@ -913,8 +983,8 @@ qla24xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
913 goto qla24xx_fw_dump_failed_0; 983 goto qla24xx_fw_dump_failed_0;
914 984
915 nxt = qla2xxx_copy_queues(ha, nxt); 985 nxt = qla2xxx_copy_queues(ha, nxt);
916 if (ha->eft) 986
917 memcpy(nxt, ha->eft, ntohl(ha->fw_dump->eft_size)); 987 qla24xx_copy_eft(ha, nxt);
918 988
919qla24xx_fw_dump_failed_0: 989qla24xx_fw_dump_failed_0:
920 if (rval != QLA_SUCCESS) { 990 if (rval != QLA_SUCCESS) {
@@ -942,19 +1012,14 @@ qla25xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
942 uint32_t risc_address; 1012 uint32_t risc_address;
943 struct qla_hw_data *ha = vha->hw; 1013 struct qla_hw_data *ha = vha->hw;
944 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; 1014 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
945 struct device_reg_25xxmq __iomem *reg25;
946 uint32_t __iomem *dmp_reg; 1015 uint32_t __iomem *dmp_reg;
947 uint32_t *iter_reg; 1016 uint32_t *iter_reg;
948 uint16_t __iomem *mbx_reg; 1017 uint16_t __iomem *mbx_reg;
949 unsigned long flags; 1018 unsigned long flags;
950 struct qla25xx_fw_dump *fw; 1019 struct qla25xx_fw_dump *fw;
951 uint32_t ext_mem_cnt; 1020 uint32_t ext_mem_cnt;
952 void *nxt; 1021 void *nxt, *nxt_chain;
953 struct qla2xxx_fce_chain *fcec; 1022 uint32_t *last_chain = NULL;
954 struct qla2xxx_mq_chain *mq = NULL;
955 uint32_t qreg_size;
956 uint8_t req_cnt, rsp_cnt, que_cnt;
957 uint32_t que_idx;
958 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); 1023 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
959 1024
960 risc_address = ext_mem_cnt = 0; 1025 risc_address = ext_mem_cnt = 0;
@@ -1001,28 +1066,6 @@ qla25xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
1001 fw->pcie_regs[2] = htonl(RD_REG_DWORD(dmp_reg)); 1066 fw->pcie_regs[2] = htonl(RD_REG_DWORD(dmp_reg));
1002 fw->pcie_regs[3] = htonl(RD_REG_DWORD(&reg->iobase_window)); 1067 fw->pcie_regs[3] = htonl(RD_REG_DWORD(&reg->iobase_window));
1003 1068
1004 /* Multi queue registers */
1005 if (ha->mqenable) {
1006 qreg_size = sizeof(struct qla2xxx_mq_chain);
1007 mq = kzalloc(qreg_size, GFP_KERNEL);
1008 if (!mq)
1009 goto qla25xx_fw_dump_failed_0;
1010 req_cnt = find_first_zero_bit(ha->req_qid_map, ha->max_queues);
1011 rsp_cnt = find_first_zero_bit(ha->rsp_qid_map, ha->max_queues);
1012 que_cnt = req_cnt > rsp_cnt ? req_cnt : rsp_cnt;
1013 mq->count = htonl(que_cnt);
1014 mq->chain_size = htonl(qreg_size);
1015 mq->type = __constant_htonl(DUMP_CHAIN_MQ);
1016 for (cnt = 0; cnt < que_cnt; cnt++) {
1017 reg25 = (struct device_reg_25xxmq *) ((void *)
1018 ha->mqiobase + cnt * QLA_QUE_PAGE);
1019 que_idx = cnt * 4;
1020 mq->qregs[que_idx] = htonl(reg25->req_q_in);
1021 mq->qregs[que_idx+1] = htonl(reg25->req_q_out);
1022 mq->qregs[que_idx+2] = htonl(reg25->rsp_q_in);
1023 mq->qregs[que_idx+3] = htonl(reg25->rsp_q_out);
1024 }
1025 }
1026 WRT_REG_DWORD(&reg->iobase_window, 0x00); 1069 WRT_REG_DWORD(&reg->iobase_window, 0x00);
1027 RD_REG_DWORD(&reg->iobase_window); 1070 RD_REG_DWORD(&reg->iobase_window);
1028 1071
@@ -1240,6 +1283,10 @@ qla25xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
1240 iter_reg = qla24xx_read_window(reg, 0x61B0, 16, iter_reg); 1283 iter_reg = qla24xx_read_window(reg, 0x61B0, 16, iter_reg);
1241 qla24xx_read_window(reg, 0x6F00, 16, iter_reg); 1284 qla24xx_read_window(reg, 0x6F00, 16, iter_reg);
1242 1285
1286 /* Multi queue registers */
1287 nxt_chain = qla25xx_copy_mq(ha, (void *)ha->fw_dump + ha->chain_offset,
1288 &last_chain);
1289
1243 rval = qla24xx_soft_reset(ha); 1290 rval = qla24xx_soft_reset(ha);
1244 if (rval != QLA_SUCCESS) 1291 if (rval != QLA_SUCCESS)
1245 goto qla25xx_fw_dump_failed_0; 1292 goto qla25xx_fw_dump_failed_0;
@@ -1249,39 +1296,341 @@ qla25xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
1249 if (rval != QLA_SUCCESS) 1296 if (rval != QLA_SUCCESS)
1250 goto qla25xx_fw_dump_failed_0; 1297 goto qla25xx_fw_dump_failed_0;
1251 1298
1252 /* Fibre Channel Trace Buffer. */
1253 nxt = qla2xxx_copy_queues(ha, nxt); 1299 nxt = qla2xxx_copy_queues(ha, nxt);
1254 if (ha->eft)
1255 memcpy(nxt, ha->eft, ntohl(ha->fw_dump->eft_size));
1256 1300
1257 /* Fibre Channel Event Buffer. */ 1301 nxt = qla24xx_copy_eft(ha, nxt);
1258 if (!ha->fce) 1302
1259 goto qla25xx_fw_dump_failed_0; 1303 /* Chain entries -- started with MQ. */
1304 qla25xx_copy_fce(ha, nxt_chain, &last_chain);
1305 if (last_chain) {
1306 ha->fw_dump->version |= __constant_htonl(DUMP_CHAIN_VARIANT);
1307 *last_chain |= __constant_htonl(DUMP_CHAIN_LAST);
1308 }
1260 1309
1261 ha->fw_dump->version |= __constant_htonl(DUMP_CHAIN_VARIANT); 1310qla25xx_fw_dump_failed_0:
1311 if (rval != QLA_SUCCESS) {
1312 qla_printk(KERN_WARNING, ha,
1313 "Failed to dump firmware (%x)!!!\n", rval);
1314 ha->fw_dumped = 0;
1262 1315
1263 if (ha->mqenable) {
1264 nxt = nxt + ntohl(ha->fw_dump->eft_size);
1265 memcpy(nxt, mq, qreg_size);
1266 kfree(mq);
1267 fcec = nxt + qreg_size;
1268 } else { 1316 } else {
1269 fcec = nxt + ntohl(ha->fw_dump->eft_size); 1317 qla_printk(KERN_INFO, ha,
1318 "Firmware dump saved to temp buffer (%ld/%p).\n",
1319 base_vha->host_no, ha->fw_dump);
1320 ha->fw_dumped = 1;
1270 } 1321 }
1271 fcec->type = __constant_htonl(DUMP_CHAIN_FCE | DUMP_CHAIN_LAST);
1272 fcec->chain_size = htonl(sizeof(struct qla2xxx_fce_chain) +
1273 fce_calc_size(ha->fce_bufs));
1274 fcec->size = htonl(fce_calc_size(ha->fce_bufs));
1275 fcec->addr_l = htonl(LSD(ha->fce_dma));
1276 fcec->addr_h = htonl(MSD(ha->fce_dma));
1277 1322
1278 iter_reg = fcec->eregs; 1323qla25xx_fw_dump_failed:
1279 for (cnt = 0; cnt < 8; cnt++) 1324 if (!hardware_locked)
1280 *iter_reg++ = htonl(ha->fce_mb[cnt]); 1325 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1326}
1281 1327
1282 memcpy(iter_reg, ha->fce, ntohl(fcec->size)); 1328void
1329qla81xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
1330{
1331 int rval;
1332 uint32_t cnt;
1333 uint32_t risc_address;
1334 struct qla_hw_data *ha = vha->hw;
1335 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1336 uint32_t __iomem *dmp_reg;
1337 uint32_t *iter_reg;
1338 uint16_t __iomem *mbx_reg;
1339 unsigned long flags;
1340 struct qla81xx_fw_dump *fw;
1341 uint32_t ext_mem_cnt;
1342 void *nxt, *nxt_chain;
1343 uint32_t *last_chain = NULL;
1344 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
1283 1345
1284qla25xx_fw_dump_failed_0: 1346 risc_address = ext_mem_cnt = 0;
1347 flags = 0;
1348
1349 if (!hardware_locked)
1350 spin_lock_irqsave(&ha->hardware_lock, flags);
1351
1352 if (!ha->fw_dump) {
1353 qla_printk(KERN_WARNING, ha,
1354 "No buffer available for dump!!!\n");
1355 goto qla81xx_fw_dump_failed;
1356 }
1357
1358 if (ha->fw_dumped) {
1359 qla_printk(KERN_WARNING, ha,
1360 "Firmware has been previously dumped (%p) -- ignoring "
1361 "request...\n", ha->fw_dump);
1362 goto qla81xx_fw_dump_failed;
1363 }
1364 fw = &ha->fw_dump->isp.isp81;
1365 qla2xxx_prep_dump(ha, ha->fw_dump);
1366
1367 fw->host_status = htonl(RD_REG_DWORD(&reg->host_status));
1368
1369 /* Pause RISC. */
1370 rval = qla24xx_pause_risc(reg);
1371 if (rval != QLA_SUCCESS)
1372 goto qla81xx_fw_dump_failed_0;
1373
1374 /* Host/Risc registers. */
1375 iter_reg = fw->host_risc_reg;
1376 iter_reg = qla24xx_read_window(reg, 0x7000, 16, iter_reg);
1377 qla24xx_read_window(reg, 0x7010, 16, iter_reg);
1378
1379 /* PCIe registers. */
1380 WRT_REG_DWORD(&reg->iobase_addr, 0x7C00);
1381 RD_REG_DWORD(&reg->iobase_addr);
1382 WRT_REG_DWORD(&reg->iobase_window, 0x01);
1383 dmp_reg = &reg->iobase_c4;
1384 fw->pcie_regs[0] = htonl(RD_REG_DWORD(dmp_reg++));
1385 fw->pcie_regs[1] = htonl(RD_REG_DWORD(dmp_reg++));
1386 fw->pcie_regs[2] = htonl(RD_REG_DWORD(dmp_reg));
1387 fw->pcie_regs[3] = htonl(RD_REG_DWORD(&reg->iobase_window));
1388
1389 WRT_REG_DWORD(&reg->iobase_window, 0x00);
1390 RD_REG_DWORD(&reg->iobase_window);
1391
1392 /* Host interface registers. */
1393 dmp_reg = &reg->flash_addr;
1394 for (cnt = 0; cnt < sizeof(fw->host_reg) / 4; cnt++)
1395 fw->host_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++));
1396
1397 /* Disable interrupts. */
1398 WRT_REG_DWORD(&reg->ictrl, 0);
1399 RD_REG_DWORD(&reg->ictrl);
1400
1401 /* Shadow registers. */
1402 WRT_REG_DWORD(&reg->iobase_addr, 0x0F70);
1403 RD_REG_DWORD(&reg->iobase_addr);
1404 WRT_REG_DWORD(&reg->iobase_select, 0xB0000000);
1405 fw->shadow_reg[0] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
1406
1407 WRT_REG_DWORD(&reg->iobase_select, 0xB0100000);
1408 fw->shadow_reg[1] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
1409
1410 WRT_REG_DWORD(&reg->iobase_select, 0xB0200000);
1411 fw->shadow_reg[2] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
1412
1413 WRT_REG_DWORD(&reg->iobase_select, 0xB0300000);
1414 fw->shadow_reg[3] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
1415
1416 WRT_REG_DWORD(&reg->iobase_select, 0xB0400000);
1417 fw->shadow_reg[4] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
1418
1419 WRT_REG_DWORD(&reg->iobase_select, 0xB0500000);
1420 fw->shadow_reg[5] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
1421
1422 WRT_REG_DWORD(&reg->iobase_select, 0xB0600000);
1423 fw->shadow_reg[6] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
1424
1425 WRT_REG_DWORD(&reg->iobase_select, 0xB0700000);
1426 fw->shadow_reg[7] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
1427
1428 WRT_REG_DWORD(&reg->iobase_select, 0xB0800000);
1429 fw->shadow_reg[8] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
1430
1431 WRT_REG_DWORD(&reg->iobase_select, 0xB0900000);
1432 fw->shadow_reg[9] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
1433
1434 WRT_REG_DWORD(&reg->iobase_select, 0xB0A00000);
1435 fw->shadow_reg[10] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
1436
1437 /* RISC I/O register. */
1438 WRT_REG_DWORD(&reg->iobase_addr, 0x0010);
1439 fw->risc_io_reg = htonl(RD_REG_DWORD(&reg->iobase_window));
1440
1441 /* Mailbox registers. */
1442 mbx_reg = &reg->mailbox0;
1443 for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++)
1444 fw->mailbox_reg[cnt] = htons(RD_REG_WORD(mbx_reg++));
1445
1446 /* Transfer sequence registers. */
1447 iter_reg = fw->xseq_gp_reg;
1448 iter_reg = qla24xx_read_window(reg, 0xBF00, 16, iter_reg);
1449 iter_reg = qla24xx_read_window(reg, 0xBF10, 16, iter_reg);
1450 iter_reg = qla24xx_read_window(reg, 0xBF20, 16, iter_reg);
1451 iter_reg = qla24xx_read_window(reg, 0xBF30, 16, iter_reg);
1452 iter_reg = qla24xx_read_window(reg, 0xBF40, 16, iter_reg);
1453 iter_reg = qla24xx_read_window(reg, 0xBF50, 16, iter_reg);
1454 iter_reg = qla24xx_read_window(reg, 0xBF60, 16, iter_reg);
1455 qla24xx_read_window(reg, 0xBF70, 16, iter_reg);
1456
1457 iter_reg = fw->xseq_0_reg;
1458 iter_reg = qla24xx_read_window(reg, 0xBFC0, 16, iter_reg);
1459 iter_reg = qla24xx_read_window(reg, 0xBFD0, 16, iter_reg);
1460 qla24xx_read_window(reg, 0xBFE0, 16, iter_reg);
1461
1462 qla24xx_read_window(reg, 0xBFF0, 16, fw->xseq_1_reg);
1463
1464 /* Receive sequence registers. */
1465 iter_reg = fw->rseq_gp_reg;
1466 iter_reg = qla24xx_read_window(reg, 0xFF00, 16, iter_reg);
1467 iter_reg = qla24xx_read_window(reg, 0xFF10, 16, iter_reg);
1468 iter_reg = qla24xx_read_window(reg, 0xFF20, 16, iter_reg);
1469 iter_reg = qla24xx_read_window(reg, 0xFF30, 16, iter_reg);
1470 iter_reg = qla24xx_read_window(reg, 0xFF40, 16, iter_reg);
1471 iter_reg = qla24xx_read_window(reg, 0xFF50, 16, iter_reg);
1472 iter_reg = qla24xx_read_window(reg, 0xFF60, 16, iter_reg);
1473 qla24xx_read_window(reg, 0xFF70, 16, iter_reg);
1474
1475 iter_reg = fw->rseq_0_reg;
1476 iter_reg = qla24xx_read_window(reg, 0xFFC0, 16, iter_reg);
1477 qla24xx_read_window(reg, 0xFFD0, 16, iter_reg);
1478
1479 qla24xx_read_window(reg, 0xFFE0, 16, fw->rseq_1_reg);
1480 qla24xx_read_window(reg, 0xFFF0, 16, fw->rseq_2_reg);
1481
1482 /* Auxiliary sequence registers. */
1483 iter_reg = fw->aseq_gp_reg;
1484 iter_reg = qla24xx_read_window(reg, 0xB000, 16, iter_reg);
1485 iter_reg = qla24xx_read_window(reg, 0xB010, 16, iter_reg);
1486 iter_reg = qla24xx_read_window(reg, 0xB020, 16, iter_reg);
1487 iter_reg = qla24xx_read_window(reg, 0xB030, 16, iter_reg);
1488 iter_reg = qla24xx_read_window(reg, 0xB040, 16, iter_reg);
1489 iter_reg = qla24xx_read_window(reg, 0xB050, 16, iter_reg);
1490 iter_reg = qla24xx_read_window(reg, 0xB060, 16, iter_reg);
1491 qla24xx_read_window(reg, 0xB070, 16, iter_reg);
1492
1493 iter_reg = fw->aseq_0_reg;
1494 iter_reg = qla24xx_read_window(reg, 0xB0C0, 16, iter_reg);
1495 qla24xx_read_window(reg, 0xB0D0, 16, iter_reg);
1496
1497 qla24xx_read_window(reg, 0xB0E0, 16, fw->aseq_1_reg);
1498 qla24xx_read_window(reg, 0xB0F0, 16, fw->aseq_2_reg);
1499
1500 /* Command DMA registers. */
1501 qla24xx_read_window(reg, 0x7100, 16, fw->cmd_dma_reg);
1502
1503 /* Queues. */
1504 iter_reg = fw->req0_dma_reg;
1505 iter_reg = qla24xx_read_window(reg, 0x7200, 8, iter_reg);
1506 dmp_reg = &reg->iobase_q;
1507 for (cnt = 0; cnt < 7; cnt++)
1508 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1509
1510 iter_reg = fw->resp0_dma_reg;
1511 iter_reg = qla24xx_read_window(reg, 0x7300, 8, iter_reg);
1512 dmp_reg = &reg->iobase_q;
1513 for (cnt = 0; cnt < 7; cnt++)
1514 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1515
1516 iter_reg = fw->req1_dma_reg;
1517 iter_reg = qla24xx_read_window(reg, 0x7400, 8, iter_reg);
1518 dmp_reg = &reg->iobase_q;
1519 for (cnt = 0; cnt < 7; cnt++)
1520 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1521
1522 /* Transmit DMA registers. */
1523 iter_reg = fw->xmt0_dma_reg;
1524 iter_reg = qla24xx_read_window(reg, 0x7600, 16, iter_reg);
1525 qla24xx_read_window(reg, 0x7610, 16, iter_reg);
1526
1527 iter_reg = fw->xmt1_dma_reg;
1528 iter_reg = qla24xx_read_window(reg, 0x7620, 16, iter_reg);
1529 qla24xx_read_window(reg, 0x7630, 16, iter_reg);
1530
1531 iter_reg = fw->xmt2_dma_reg;
1532 iter_reg = qla24xx_read_window(reg, 0x7640, 16, iter_reg);
1533 qla24xx_read_window(reg, 0x7650, 16, iter_reg);
1534
1535 iter_reg = fw->xmt3_dma_reg;
1536 iter_reg = qla24xx_read_window(reg, 0x7660, 16, iter_reg);
1537 qla24xx_read_window(reg, 0x7670, 16, iter_reg);
1538
1539 iter_reg = fw->xmt4_dma_reg;
1540 iter_reg = qla24xx_read_window(reg, 0x7680, 16, iter_reg);
1541 qla24xx_read_window(reg, 0x7690, 16, iter_reg);
1542
1543 qla24xx_read_window(reg, 0x76A0, 16, fw->xmt_data_dma_reg);
1544
1545 /* Receive DMA registers. */
1546 iter_reg = fw->rcvt0_data_dma_reg;
1547 iter_reg = qla24xx_read_window(reg, 0x7700, 16, iter_reg);
1548 qla24xx_read_window(reg, 0x7710, 16, iter_reg);
1549
1550 iter_reg = fw->rcvt1_data_dma_reg;
1551 iter_reg = qla24xx_read_window(reg, 0x7720, 16, iter_reg);
1552 qla24xx_read_window(reg, 0x7730, 16, iter_reg);
1553
1554 /* RISC registers. */
1555 iter_reg = fw->risc_gp_reg;
1556 iter_reg = qla24xx_read_window(reg, 0x0F00, 16, iter_reg);
1557 iter_reg = qla24xx_read_window(reg, 0x0F10, 16, iter_reg);
1558 iter_reg = qla24xx_read_window(reg, 0x0F20, 16, iter_reg);
1559 iter_reg = qla24xx_read_window(reg, 0x0F30, 16, iter_reg);
1560 iter_reg = qla24xx_read_window(reg, 0x0F40, 16, iter_reg);
1561 iter_reg = qla24xx_read_window(reg, 0x0F50, 16, iter_reg);
1562 iter_reg = qla24xx_read_window(reg, 0x0F60, 16, iter_reg);
1563 qla24xx_read_window(reg, 0x0F70, 16, iter_reg);
1564
1565 /* Local memory controller registers. */
1566 iter_reg = fw->lmc_reg;
1567 iter_reg = qla24xx_read_window(reg, 0x3000, 16, iter_reg);
1568 iter_reg = qla24xx_read_window(reg, 0x3010, 16, iter_reg);
1569 iter_reg = qla24xx_read_window(reg, 0x3020, 16, iter_reg);
1570 iter_reg = qla24xx_read_window(reg, 0x3030, 16, iter_reg);
1571 iter_reg = qla24xx_read_window(reg, 0x3040, 16, iter_reg);
1572 iter_reg = qla24xx_read_window(reg, 0x3050, 16, iter_reg);
1573 iter_reg = qla24xx_read_window(reg, 0x3060, 16, iter_reg);
1574 qla24xx_read_window(reg, 0x3070, 16, iter_reg);
1575
1576 /* Fibre Protocol Module registers. */
1577 iter_reg = fw->fpm_hdw_reg;
1578 iter_reg = qla24xx_read_window(reg, 0x4000, 16, iter_reg);
1579 iter_reg = qla24xx_read_window(reg, 0x4010, 16, iter_reg);
1580 iter_reg = qla24xx_read_window(reg, 0x4020, 16, iter_reg);
1581 iter_reg = qla24xx_read_window(reg, 0x4030, 16, iter_reg);
1582 iter_reg = qla24xx_read_window(reg, 0x4040, 16, iter_reg);
1583 iter_reg = qla24xx_read_window(reg, 0x4050, 16, iter_reg);
1584 iter_reg = qla24xx_read_window(reg, 0x4060, 16, iter_reg);
1585 iter_reg = qla24xx_read_window(reg, 0x4070, 16, iter_reg);
1586 iter_reg = qla24xx_read_window(reg, 0x4080, 16, iter_reg);
1587 iter_reg = qla24xx_read_window(reg, 0x4090, 16, iter_reg);
1588 iter_reg = qla24xx_read_window(reg, 0x40A0, 16, iter_reg);
1589 iter_reg = qla24xx_read_window(reg, 0x40B0, 16, iter_reg);
1590 iter_reg = qla24xx_read_window(reg, 0x40C0, 16, iter_reg);
1591 qla24xx_read_window(reg, 0x40D0, 16, iter_reg);
1592
1593 /* Frame Buffer registers. */
1594 iter_reg = fw->fb_hdw_reg;
1595 iter_reg = qla24xx_read_window(reg, 0x6000, 16, iter_reg);
1596 iter_reg = qla24xx_read_window(reg, 0x6010, 16, iter_reg);
1597 iter_reg = qla24xx_read_window(reg, 0x6020, 16, iter_reg);
1598 iter_reg = qla24xx_read_window(reg, 0x6030, 16, iter_reg);
1599 iter_reg = qla24xx_read_window(reg, 0x6040, 16, iter_reg);
1600 iter_reg = qla24xx_read_window(reg, 0x6100, 16, iter_reg);
1601 iter_reg = qla24xx_read_window(reg, 0x6130, 16, iter_reg);
1602 iter_reg = qla24xx_read_window(reg, 0x6150, 16, iter_reg);
1603 iter_reg = qla24xx_read_window(reg, 0x6170, 16, iter_reg);
1604 iter_reg = qla24xx_read_window(reg, 0x6190, 16, iter_reg);
1605 iter_reg = qla24xx_read_window(reg, 0x61B0, 16, iter_reg);
1606 iter_reg = qla24xx_read_window(reg, 0x61C0, 16, iter_reg);
1607 qla24xx_read_window(reg, 0x6F00, 16, iter_reg);
1608
1609 /* Multi queue registers */
1610 nxt_chain = qla25xx_copy_mq(ha, (void *)ha->fw_dump + ha->chain_offset,
1611 &last_chain);
1612
1613 rval = qla24xx_soft_reset(ha);
1614 if (rval != QLA_SUCCESS)
1615 goto qla81xx_fw_dump_failed_0;
1616
1617 rval = qla24xx_dump_memory(ha, fw->code_ram, sizeof(fw->code_ram),
1618 &nxt);
1619 if (rval != QLA_SUCCESS)
1620 goto qla81xx_fw_dump_failed_0;
1621
1622 nxt = qla2xxx_copy_queues(ha, nxt);
1623
1624 nxt = qla24xx_copy_eft(ha, nxt);
1625
1626 /* Chain entries -- started with MQ. */
1627 qla25xx_copy_fce(ha, nxt_chain, &last_chain);
1628 if (last_chain) {
1629 ha->fw_dump->version |= __constant_htonl(DUMP_CHAIN_VARIANT);
1630 *last_chain |= __constant_htonl(DUMP_CHAIN_LAST);
1631 }
1632
1633qla81xx_fw_dump_failed_0:
1285 if (rval != QLA_SUCCESS) { 1634 if (rval != QLA_SUCCESS) {
1286 qla_printk(KERN_WARNING, ha, 1635 qla_printk(KERN_WARNING, ha,
1287 "Failed to dump firmware (%x)!!!\n", rval); 1636 "Failed to dump firmware (%x)!!!\n", rval);
@@ -1294,10 +1643,11 @@ qla25xx_fw_dump_failed_0:
1294 ha->fw_dumped = 1; 1643 ha->fw_dumped = 1;
1295 } 1644 }
1296 1645
1297qla25xx_fw_dump_failed: 1646qla81xx_fw_dump_failed:
1298 if (!hardware_locked) 1647 if (!hardware_locked)
1299 spin_unlock_irqrestore(&ha->hardware_lock, flags); 1648 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1300} 1649}
1650
1301/****************************************************************************/ 1651/****************************************************************************/
1302/* Driver Debug Functions. */ 1652/* Driver Debug Functions. */
1303/****************************************************************************/ 1653/****************************************************************************/
diff --git a/drivers/scsi/qla2xxx/qla_dbg.h b/drivers/scsi/qla2xxx/qla_dbg.h
index c1794a70a45f..f660dd70b72e 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.h
+++ b/drivers/scsi/qla2xxx/qla_dbg.h
@@ -251,6 +251,45 @@ struct qla25xx_fw_dump {
251 uint32_t ext_mem[1]; 251 uint32_t ext_mem[1];
252}; 252};
253 253
254struct qla81xx_fw_dump {
255 uint32_t host_status;
256 uint32_t host_risc_reg[32];
257 uint32_t pcie_regs[4];
258 uint32_t host_reg[32];
259 uint32_t shadow_reg[11];
260 uint32_t risc_io_reg;
261 uint16_t mailbox_reg[32];
262 uint32_t xseq_gp_reg[128];
263 uint32_t xseq_0_reg[48];
264 uint32_t xseq_1_reg[16];
265 uint32_t rseq_gp_reg[128];
266 uint32_t rseq_0_reg[32];
267 uint32_t rseq_1_reg[16];
268 uint32_t rseq_2_reg[16];
269 uint32_t aseq_gp_reg[128];
270 uint32_t aseq_0_reg[32];
271 uint32_t aseq_1_reg[16];
272 uint32_t aseq_2_reg[16];
273 uint32_t cmd_dma_reg[16];
274 uint32_t req0_dma_reg[15];
275 uint32_t resp0_dma_reg[15];
276 uint32_t req1_dma_reg[15];
277 uint32_t xmt0_dma_reg[32];
278 uint32_t xmt1_dma_reg[32];
279 uint32_t xmt2_dma_reg[32];
280 uint32_t xmt3_dma_reg[32];
281 uint32_t xmt4_dma_reg[32];
282 uint32_t xmt_data_dma_reg[16];
283 uint32_t rcvt0_data_dma_reg[32];
284 uint32_t rcvt1_data_dma_reg[32];
285 uint32_t risc_gp_reg[128];
286 uint32_t lmc_reg[128];
287 uint32_t fpm_hdw_reg[224];
288 uint32_t fb_hdw_reg[208];
289 uint32_t code_ram[0x2000];
290 uint32_t ext_mem[1];
291};
292
254#define EFT_NUM_BUFFERS 4 293#define EFT_NUM_BUFFERS 4
255#define EFT_BYTES_PER_BUFFER 0x4000 294#define EFT_BYTES_PER_BUFFER 0x4000
256#define EFT_SIZE ((EFT_BYTES_PER_BUFFER) * (EFT_NUM_BUFFERS)) 295#define EFT_SIZE ((EFT_BYTES_PER_BUFFER) * (EFT_NUM_BUFFERS))
@@ -313,5 +352,6 @@ struct qla2xxx_fw_dump {
313 struct qla2300_fw_dump isp23; 352 struct qla2300_fw_dump isp23;
314 struct qla24xx_fw_dump isp24; 353 struct qla24xx_fw_dump isp24;
315 struct qla25xx_fw_dump isp25; 354 struct qla25xx_fw_dump isp25;
355 struct qla81xx_fw_dump isp81;
316 } isp; 356 } isp;
317}; 357};
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index a29c95204975..023ee77fb027 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -187,7 +187,6 @@ struct req_que;
187 * SCSI Request Block 187 * SCSI Request Block
188 */ 188 */
189typedef struct srb { 189typedef struct srb {
190 struct scsi_qla_host *vha; /* HA the SP is queued on */
191 struct req_que *que; 190 struct req_que *que;
192 struct fc_port *fcport; 191 struct fc_port *fcport;
193 192
@@ -2136,7 +2135,6 @@ struct qla_msix_entry {
2136/* Work events. */ 2135/* Work events. */
2137enum qla_work_type { 2136enum qla_work_type {
2138 QLA_EVT_AEN, 2137 QLA_EVT_AEN,
2139 QLA_EVT_HWE_LOG,
2140}; 2138};
2141 2139
2142 2140
@@ -2151,10 +2149,6 @@ struct qla_work_evt {
2151 enum fc_host_event_code code; 2149 enum fc_host_event_code code;
2152 u32 data; 2150 u32 data;
2153 } aen; 2151 } aen;
2154 struct {
2155 uint16_t code;
2156 uint16_t d1, d2, d3;
2157 } hwe;
2158 } u; 2152 } u;
2159}; 2153};
2160 2154
@@ -2309,6 +2303,7 @@ struct qla_hw_data {
2309#define PORT_SPEED_2GB 0x01 2303#define PORT_SPEED_2GB 0x01
2310#define PORT_SPEED_4GB 0x03 2304#define PORT_SPEED_4GB 0x03
2311#define PORT_SPEED_8GB 0x04 2305#define PORT_SPEED_8GB 0x04
2306#define PORT_SPEED_10GB 0x13
2312 uint16_t link_data_rate; /* F/W operating speed */ 2307 uint16_t link_data_rate; /* F/W operating speed */
2313 2308
2314 uint8_t current_topology; 2309 uint8_t current_topology;
@@ -2328,6 +2323,7 @@ struct qla_hw_data {
2328 2323
2329#define PCI_DEVICE_ID_QLOGIC_ISP2532 0x2532 2324#define PCI_DEVICE_ID_QLOGIC_ISP2532 0x2532
2330#define PCI_DEVICE_ID_QLOGIC_ISP8432 0x8432 2325#define PCI_DEVICE_ID_QLOGIC_ISP8432 0x8432
2326#define PCI_DEVICE_ID_QLOGIC_ISP8001 0x8001
2331 uint32_t device_type; 2327 uint32_t device_type;
2332#define DT_ISP2100 BIT_0 2328#define DT_ISP2100 BIT_0
2333#define DT_ISP2200 BIT_1 2329#define DT_ISP2200 BIT_1
@@ -2342,7 +2338,8 @@ struct qla_hw_data {
2342#define DT_ISP5432 BIT_10 2338#define DT_ISP5432 BIT_10
2343#define DT_ISP2532 BIT_11 2339#define DT_ISP2532 BIT_11
2344#define DT_ISP8432 BIT_12 2340#define DT_ISP8432 BIT_12
2345#define DT_ISP_LAST (DT_ISP8432 << 1) 2341#define DT_ISP8001 BIT_13
2342#define DT_ISP_LAST (DT_ISP8001 << 1)
2346 2343
2347#define DT_IIDMA BIT_26 2344#define DT_IIDMA BIT_26
2348#define DT_FWI2 BIT_27 2345#define DT_FWI2 BIT_27
@@ -2364,6 +2361,7 @@ struct qla_hw_data {
2364#define IS_QLA5432(ha) (DT_MASK(ha) & DT_ISP5432) 2361#define IS_QLA5432(ha) (DT_MASK(ha) & DT_ISP5432)
2365#define IS_QLA2532(ha) (DT_MASK(ha) & DT_ISP2532) 2362#define IS_QLA2532(ha) (DT_MASK(ha) & DT_ISP2532)
2366#define IS_QLA8432(ha) (DT_MASK(ha) & DT_ISP8432) 2363#define IS_QLA8432(ha) (DT_MASK(ha) & DT_ISP8432)
2364#define IS_QLA8001(ha) (DT_MASK(ha) & DT_ISP8001)
2367 2365
2368#define IS_QLA23XX(ha) (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA2322(ha) || \ 2366#define IS_QLA23XX(ha) (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA2322(ha) || \
2369 IS_QLA6312(ha) || IS_QLA6322(ha)) 2367 IS_QLA6312(ha) || IS_QLA6322(ha))
@@ -2373,8 +2371,11 @@ struct qla_hw_data {
2373#define IS_QLA84XX(ha) (IS_QLA8432(ha)) 2371#define IS_QLA84XX(ha) (IS_QLA8432(ha))
2374#define IS_QLA24XX_TYPE(ha) (IS_QLA24XX(ha) || IS_QLA54XX(ha) || \ 2372#define IS_QLA24XX_TYPE(ha) (IS_QLA24XX(ha) || IS_QLA54XX(ha) || \
2375 IS_QLA84XX(ha)) 2373 IS_QLA84XX(ha))
2374#define IS_QLA81XX(ha) (IS_QLA8001(ha))
2376#define IS_QLA2XXX_MIDTYPE(ha) (IS_QLA24XX(ha) || IS_QLA84XX(ha) || \ 2375#define IS_QLA2XXX_MIDTYPE(ha) (IS_QLA24XX(ha) || IS_QLA84XX(ha) || \
2377 IS_QLA25XX(ha)) 2376 IS_QLA25XX(ha) || IS_QLA81XX(ha))
2377#define IS_NOPOLLING_TYPE(ha) ((IS_QLA25XX(ha) || IS_QLA81XX(ha)) && \
2378 (ha)->flags.msix_enabled)
2378 2379
2379#define IS_IIDMA_CAPABLE(ha) ((ha)->device_type & DT_IIDMA) 2380#define IS_IIDMA_CAPABLE(ha) ((ha)->device_type & DT_IIDMA)
2380#define IS_FWI2_CAPABLE(ha) ((ha)->device_type & DT_FWI2) 2381#define IS_FWI2_CAPABLE(ha) ((ha)->device_type & DT_FWI2)
@@ -2472,6 +2473,9 @@ struct qla_hw_data {
2472 uint8_t fw_seriallink_options[4]; 2473 uint8_t fw_seriallink_options[4];
2473 uint16_t fw_seriallink_options24[4]; 2474 uint16_t fw_seriallink_options24[4];
2474 2475
2476 uint8_t mpi_version[4];
2477 uint32_t mpi_capabilities;
2478
2475 /* Firmware dump information. */ 2479 /* Firmware dump information. */
2476 struct qla2xxx_fw_dump *fw_dump; 2480 struct qla2xxx_fw_dump *fw_dump;
2477 uint32_t fw_dump_len; 2481 uint32_t fw_dump_len;
@@ -2480,6 +2484,7 @@ struct qla_hw_data {
2480 dma_addr_t eft_dma; 2484 dma_addr_t eft_dma;
2481 void *eft; 2485 void *eft;
2482 2486
2487 uint32_t chain_offset;
2483 struct dentry *dfs_dir; 2488 struct dentry *dfs_dir;
2484 struct dentry *dfs_fce; 2489 struct dentry *dfs_fce;
2485 dma_addr_t fce_dma; 2490 dma_addr_t fce_dma;
@@ -2489,10 +2494,6 @@ struct qla_hw_data {
2489 uint64_t fce_wr, fce_rd; 2494 uint64_t fce_wr, fce_rd;
2490 struct mutex fce_mutex; 2495 struct mutex fce_mutex;
2491 2496
2492 uint32_t hw_event_start;
2493 uint32_t hw_event_ptr;
2494 uint32_t hw_event_pause_errors;
2495
2496 uint32_t pci_attr; 2497 uint32_t pci_attr;
2497 uint16_t chip_revision; 2498 uint16_t chip_revision;
2498 2499
@@ -2522,6 +2523,12 @@ struct qla_hw_data {
2522 uint8_t fcode_revision[16]; 2523 uint8_t fcode_revision[16];
2523 uint32_t fw_revision[4]; 2524 uint32_t fw_revision[4];
2524 2525
2526 /* Offsets for flash/nvram access (set to ~0 if not used). */
2527 uint32_t flash_conf_off;
2528 uint32_t flash_data_off;
2529 uint32_t nvram_conf_off;
2530 uint32_t nvram_data_off;
2531
2525 uint32_t fdt_wrt_disable; 2532 uint32_t fdt_wrt_disable;
2526 uint32_t fdt_erase_cmd; 2533 uint32_t fdt_erase_cmd;
2527 uint32_t fdt_block_size; 2534 uint32_t fdt_block_size;
@@ -2533,7 +2540,6 @@ struct qla_hw_data {
2533 uint32_t flt_region_boot; 2540 uint32_t flt_region_boot;
2534 uint32_t flt_region_fw; 2541 uint32_t flt_region_fw;
2535 uint32_t flt_region_vpd_nvram; 2542 uint32_t flt_region_vpd_nvram;
2536 uint32_t flt_region_hw_event;
2537 uint32_t flt_region_npiv_conf; 2543 uint32_t flt_region_npiv_conf;
2538 2544
2539 /* Needed for BEACON */ 2545 /* Needed for BEACON */
@@ -2737,6 +2743,7 @@ typedef struct scsi_qla_host {
2737#define OPTROM_SIZE_2322 0x100000 2743#define OPTROM_SIZE_2322 0x100000
2738#define OPTROM_SIZE_24XX 0x100000 2744#define OPTROM_SIZE_24XX 0x100000
2739#define OPTROM_SIZE_25XX 0x200000 2745#define OPTROM_SIZE_25XX 0x200000
2746#define OPTROM_SIZE_81XX 0x400000
2740 2747
2741#include "qla_gbl.h" 2748#include "qla_gbl.h"
2742#include "qla_dbg.h" 2749#include "qla_dbg.h"
diff --git a/drivers/scsi/qla2xxx/qla_dfs.c b/drivers/scsi/qla2xxx/qla_dfs.c
index 0e366a1b44b3..c66036da7d2b 100644
--- a/drivers/scsi/qla2xxx/qla_dfs.c
+++ b/drivers/scsi/qla2xxx/qla_dfs.c
@@ -113,7 +113,8 @@ int
113qla2x00_dfs_setup(scsi_qla_host_t *vha) 113qla2x00_dfs_setup(scsi_qla_host_t *vha)
114{ 114{
115 struct qla_hw_data *ha = vha->hw; 115 struct qla_hw_data *ha = vha->hw;
116 if (!IS_QLA25XX(ha)) 116
117 if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha))
117 goto out; 118 goto out;
118 if (!ha->fce) 119 if (!ha->fce)
119 goto out; 120 goto out;
diff --git a/drivers/scsi/qla2xxx/qla_fw.h b/drivers/scsi/qla2xxx/qla_fw.h
index ee1f1e794c2d..7abb045a0410 100644
--- a/drivers/scsi/qla2xxx/qla_fw.h
+++ b/drivers/scsi/qla2xxx/qla_fw.h
@@ -1215,9 +1215,10 @@ struct qla_fdt_layout {
1215 1215
1216struct qla_flt_location { 1216struct qla_flt_location {
1217 uint8_t sig[4]; 1217 uint8_t sig[4];
1218 uint32_t start_lo; 1218 uint16_t start_lo;
1219 uint32_t start_hi; 1219 uint16_t start_hi;
1220 uint16_t unused; 1220 uint8_t version;
1221 uint8_t unused[5];
1221 uint16_t checksum; 1222 uint16_t checksum;
1222}; 1223};
1223 1224
@@ -1390,4 +1391,291 @@ struct access_chip_rsp_84xx {
1390 1391
1391 uint32_t reserved[12]; 1392 uint32_t reserved[12];
1392}; 1393};
1394
1395/* 81XX Support **************************************************************/
1396
1397#define MBA_DCBX_START 0x8016
1398#define MBA_DCBX_COMPLETE 0x8030
1399#define MBA_FCF_CONF_ERR 0x8031
1400#define MBA_DCBX_PARAM_UPDATE 0x8032
1401#define MBA_IDC_COMPLETE 0x8100
1402#define MBA_IDC_NOTIFY 0x8101
1403#define MBA_IDC_TIME_EXT 0x8102
1404
1405struct nvram_81xx {
1406 /* NVRAM header. */
1407 uint8_t id[4];
1408 uint16_t nvram_version;
1409 uint16_t reserved_0;
1410
1411 /* Firmware Initialization Control Block. */
1412 uint16_t version;
1413 uint16_t reserved_1;
1414 uint16_t frame_payload_size;
1415 uint16_t execution_throttle;
1416 uint16_t exchange_count;
1417 uint16_t reserved_2;
1418
1419 uint8_t port_name[WWN_SIZE];
1420 uint8_t node_name[WWN_SIZE];
1421
1422 uint16_t login_retry_count;
1423 uint16_t reserved_3;
1424 uint16_t interrupt_delay_timer;
1425 uint16_t login_timeout;
1426
1427 uint32_t firmware_options_1;
1428 uint32_t firmware_options_2;
1429 uint32_t firmware_options_3;
1430
1431 uint16_t reserved_4[4];
1432
1433 /* Offset 64. */
1434 uint8_t enode_mac[6];
1435 uint16_t reserved_5[5];
1436
1437 /* Offset 80. */
1438 uint16_t reserved_6[24];
1439
1440 /* Offset 128. */
1441 uint16_t reserved_7[64];
1442
1443 /*
1444 * BIT 0 = Enable spinup delay
1445 * BIT 1 = Disable BIOS
1446 * BIT 2 = Enable Memory Map BIOS
1447 * BIT 3 = Enable Selectable Boot
1448 * BIT 4 = Disable RISC code load
1449 * BIT 5 = Disable Serdes
1450 * BIT 6 = Opt boot mode
1451 * BIT 7 = Interrupt enable
1452 *
1453 * BIT 8 = EV Control enable
1454 * BIT 9 = Enable lip reset
1455 * BIT 10 = Enable lip full login
1456 * BIT 11 = Enable target reset
1457 * BIT 12 = Stop firmware
1458 * BIT 13 = Enable nodename option
1459 * BIT 14 = Default WWPN valid
1460 * BIT 15 = Enable alternate WWN
1461 *
1462 * BIT 16 = CLP LUN string
1463 * BIT 17 = CLP Target string
1464 * BIT 18 = CLP BIOS enable string
1465 * BIT 19 = CLP Serdes string
1466 * BIT 20 = CLP WWPN string
1467 * BIT 21 = CLP WWNN string
1468 * BIT 22 =
1469 * BIT 23 =
1470 * BIT 24 = Keep WWPN
1471 * BIT 25 = Temp WWPN
1472 * BIT 26-31 =
1473 */
1474 uint32_t host_p;
1475
1476 uint8_t alternate_port_name[WWN_SIZE];
1477 uint8_t alternate_node_name[WWN_SIZE];
1478
1479 uint8_t boot_port_name[WWN_SIZE];
1480 uint16_t boot_lun_number;
1481 uint16_t reserved_8;
1482
1483 uint8_t alt1_boot_port_name[WWN_SIZE];
1484 uint16_t alt1_boot_lun_number;
1485 uint16_t reserved_9;
1486
1487 uint8_t alt2_boot_port_name[WWN_SIZE];
1488 uint16_t alt2_boot_lun_number;
1489 uint16_t reserved_10;
1490
1491 uint8_t alt3_boot_port_name[WWN_SIZE];
1492 uint16_t alt3_boot_lun_number;
1493 uint16_t reserved_11;
1494
1495 /*
1496 * BIT 0 = Selective Login
1497 * BIT 1 = Alt-Boot Enable
1498 * BIT 2 = Reserved
1499 * BIT 3 = Boot Order List
1500 * BIT 4 = Reserved
1501 * BIT 5 = Selective LUN
1502 * BIT 6 = Reserved
1503 * BIT 7-31 =
1504 */
1505 uint32_t efi_parameters;
1506
1507 uint8_t reset_delay;
1508 uint8_t reserved_12;
1509 uint16_t reserved_13;
1510
1511 uint16_t boot_id_number;
1512 uint16_t reserved_14;
1513
1514 uint16_t max_luns_per_target;
1515 uint16_t reserved_15;
1516
1517 uint16_t port_down_retry_count;
1518 uint16_t link_down_timeout;
1519
1520 /* FCode parameters. */
1521 uint16_t fcode_parameter;
1522
1523 uint16_t reserved_16[3];
1524
1525 /* Offset 352. */
1526 uint8_t reserved_17[4];
1527 uint16_t reserved_18[5];
1528 uint8_t reserved_19[2];
1529 uint16_t reserved_20[8];
1530
1531 /* Offset 384. */
1532 uint8_t reserved_21[16];
1533 uint16_t reserved_22[8];
1534
1535 /* Offset 416. */
1536 uint16_t reserved_23[32];
1537
1538 /* Offset 480. */
1539 uint8_t model_name[16];
1540
1541 /* Offset 496. */
1542 uint16_t feature_mask_l;
1543 uint16_t feature_mask_h;
1544 uint16_t reserved_24[2];
1545
1546 uint16_t subsystem_vendor_id;
1547 uint16_t subsystem_device_id;
1548
1549 uint32_t checksum;
1550};
1551
1552/*
1553 * ISP Initialization Control Block.
1554 * Little endian except where noted.
1555 */
1556#define ICB_VERSION 1
1557struct init_cb_81xx {
1558 uint16_t version;
1559 uint16_t reserved_1;
1560
1561 uint16_t frame_payload_size;
1562 uint16_t execution_throttle;
1563 uint16_t exchange_count;
1564
1565 uint16_t reserved_2;
1566
1567 uint8_t port_name[WWN_SIZE]; /* Big endian. */
1568 uint8_t node_name[WWN_SIZE]; /* Big endian. */
1569
1570 uint16_t response_q_inpointer;
1571 uint16_t request_q_outpointer;
1572
1573 uint16_t login_retry_count;
1574
1575 uint16_t prio_request_q_outpointer;
1576
1577 uint16_t response_q_length;
1578 uint16_t request_q_length;
1579
1580 uint16_t reserved_3;
1581
1582 uint16_t prio_request_q_length;
1583
1584 uint32_t request_q_address[2];
1585 uint32_t response_q_address[2];
1586 uint32_t prio_request_q_address[2];
1587
1588 uint8_t reserved_4[8];
1589
1590 uint16_t atio_q_inpointer;
1591 uint16_t atio_q_length;
1592 uint32_t atio_q_address[2];
1593
1594 uint16_t interrupt_delay_timer; /* 100us increments. */
1595 uint16_t login_timeout;
1596
1597 /*
1598 * BIT 0-3 = Reserved
1599 * BIT 4 = Enable Target Mode
1600 * BIT 5 = Disable Initiator Mode
1601 * BIT 6 = Reserved
1602 * BIT 7 = Reserved
1603 *
1604 * BIT 8-13 = Reserved
1605 * BIT 14 = Node Name Option
1606 * BIT 15-31 = Reserved
1607 */
1608 uint32_t firmware_options_1;
1609
1610 /*
1611 * BIT 0 = Operation Mode bit 0
1612 * BIT 1 = Operation Mode bit 1
1613 * BIT 2 = Operation Mode bit 2
1614 * BIT 3 = Operation Mode bit 3
1615 * BIT 4-7 = Reserved
1616 *
1617 * BIT 8 = Enable Class 2
1618 * BIT 9 = Enable ACK0
1619 * BIT 10 = Reserved
1620 * BIT 11 = Enable FC-SP Security
1621 * BIT 12 = FC Tape Enable
1622 * BIT 13 = Reserved
1623 * BIT 14 = Enable Target PRLI Control
1624 * BIT 15-31 = Reserved
1625 */
1626 uint32_t firmware_options_2;
1627
1628 /*
1629 * BIT 0-3 = Reserved
1630 * BIT 4 = FCP RSP Payload bit 0
1631 * BIT 5 = FCP RSP Payload bit 1
1632 * BIT 6 = Enable Receive Out-of-Order data frame handling
1633 * BIT 7 = Reserved
1634 *
1635 * BIT 8 = Reserved
1636 * BIT 9 = Enable Out-of-Order FCP_XFER_RDY relative offset handling
1637 * BIT 10-16 = Reserved
1638 * BIT 17 = Enable multiple FCFs
1639 * BIT 18-20 = MAC addressing mode
1640 * BIT 21-25 = Ethernet data rate
1641 * BIT 26 = Enable ethernet header rx IOCB for ATIO q
1642 * BIT 27 = Enable ethernet header rx IOCB for response q
1643 * BIT 28 = SPMA selection bit 0
1644 * BIT 28 = SPMA selection bit 1
1645 * BIT 30-31 = Reserved
1646 */
1647 uint32_t firmware_options_3;
1648
1649 uint8_t reserved_5[8];
1650
1651 uint8_t enode_mac[6];
1652
1653 uint8_t reserved_6[10];
1654};
1655
1656struct mid_init_cb_81xx {
1657 struct init_cb_81xx init_cb;
1658
1659 uint16_t count;
1660 uint16_t options;
1661
1662 struct mid_conf_entry_24xx entries[MAX_MULTI_ID_FABRIC];
1663};
1664
1665#define FARX_ACCESS_FLASH_CONF_81XX 0x7FFD0000
1666#define FARX_ACCESS_FLASH_DATA_81XX 0x7F800000
1667
1668/* 81XX Flash locations -- occupies second 2MB region. */
1669#define FA_BOOT_CODE_ADDR_81 0x80000
1670#define FA_RISC_CODE_ADDR_81 0xA0000
1671#define FA_FW_AREA_ADDR_81 0xC0000
1672#define FA_VPD_NVRAM_ADDR_81 0xD0000
1673#define FA_FEATURE_ADDR_81 0xD4000
1674#define FA_FLASH_DESCR_ADDR_81 0xD8000
1675#define FA_FLASH_LAYOUT_ADDR_81 0xD8400
1676#define FA_HW_EVENT0_ADDR_81 0xDC000
1677#define FA_HW_EVENT1_ADDR_81 0xDC400
1678#define FA_NPIV_CONF0_ADDR_81 0xD1000
1679#define FA_NPIV_CONF1_ADDR_81 0xD2000
1680
1393#endif 1681#endif
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 0011e31205db..ba4913353752 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -28,8 +28,10 @@ extern void qla2x00_reset_adapter(struct scsi_qla_host *);
28extern void qla24xx_reset_adapter(struct scsi_qla_host *); 28extern void qla24xx_reset_adapter(struct scsi_qla_host *);
29extern int qla2x00_nvram_config(struct scsi_qla_host *); 29extern int qla2x00_nvram_config(struct scsi_qla_host *);
30extern int qla24xx_nvram_config(struct scsi_qla_host *); 30extern int qla24xx_nvram_config(struct scsi_qla_host *);
31extern int qla81xx_nvram_config(struct scsi_qla_host *);
31extern void qla2x00_update_fw_options(struct scsi_qla_host *); 32extern void qla2x00_update_fw_options(struct scsi_qla_host *);
32extern void qla24xx_update_fw_options(scsi_qla_host_t *); 33extern void qla24xx_update_fw_options(scsi_qla_host_t *);
34extern void qla81xx_update_fw_options(scsi_qla_host_t *);
33extern int qla2x00_load_risc(struct scsi_qla_host *, uint32_t *); 35extern int qla2x00_load_risc(struct scsi_qla_host *, uint32_t *);
34extern int qla24xx_load_risc(scsi_qla_host_t *, uint32_t *); 36extern int qla24xx_load_risc(scsi_qla_host_t *, uint32_t *);
35 37
@@ -69,8 +71,6 @@ extern int qla2x00_loop_reset(scsi_qla_host_t *);
69extern void qla2x00_abort_all_cmds(scsi_qla_host_t *, int); 71extern void qla2x00_abort_all_cmds(scsi_qla_host_t *, int);
70extern int qla2x00_post_aen_work(struct scsi_qla_host *, enum 72extern int qla2x00_post_aen_work(struct scsi_qla_host *, enum
71 fc_host_event_code, u32); 73 fc_host_event_code, u32);
72extern int qla2x00_post_hwe_work(struct scsi_qla_host *, uint16_t , uint16_t,
73 uint16_t, uint16_t);
74 74
75extern void qla2x00_abort_fcport_cmds(fc_port_t *); 75extern void qla2x00_abort_fcport_cmds(fc_port_t *);
76extern struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *, 76extern struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *,
@@ -143,7 +143,7 @@ qla2x00_execute_fw(scsi_qla_host_t *, uint32_t);
143 143
144extern void 144extern void
145qla2x00_get_fw_version(scsi_qla_host_t *, uint16_t *, 145qla2x00_get_fw_version(scsi_qla_host_t *, uint16_t *,
146 uint16_t *, uint16_t *, uint16_t *, uint32_t *); 146 uint16_t *, uint16_t *, uint16_t *, uint32_t *, uint8_t *, uint32_t *);
147 147
148extern int 148extern int
149qla2x00_get_fw_options(scsi_qla_host_t *, uint16_t *); 149qla2x00_get_fw_options(scsi_qla_host_t *, uint16_t *);
@@ -317,9 +317,6 @@ extern uint8_t *qla25xx_read_optrom_data(struct scsi_qla_host *, uint8_t *,
317extern int qla2x00_get_flash_version(scsi_qla_host_t *, void *); 317extern int qla2x00_get_flash_version(scsi_qla_host_t *, void *);
318extern int qla24xx_get_flash_version(scsi_qla_host_t *, void *); 318extern int qla24xx_get_flash_version(scsi_qla_host_t *, void *);
319 319
320extern int qla2xxx_hw_event_log(scsi_qla_host_t *, uint16_t , uint16_t,
321 uint16_t, uint16_t);
322
323extern int qla2xxx_get_flash_info(scsi_qla_host_t *); 320extern int qla2xxx_get_flash_info(scsi_qla_host_t *);
324extern int qla2xxx_get_vpd_field(scsi_qla_host_t *, char *, char *, size_t); 321extern int qla2xxx_get_vpd_field(scsi_qla_host_t *, char *, char *, size_t);
325 322
@@ -332,6 +329,7 @@ extern void qla2100_fw_dump(scsi_qla_host_t *, int);
332extern void qla2300_fw_dump(scsi_qla_host_t *, int); 329extern void qla2300_fw_dump(scsi_qla_host_t *, int);
333extern void qla24xx_fw_dump(scsi_qla_host_t *, int); 330extern void qla24xx_fw_dump(scsi_qla_host_t *, int);
334extern void qla25xx_fw_dump(scsi_qla_host_t *, int); 331extern void qla25xx_fw_dump(scsi_qla_host_t *, int);
332extern void qla81xx_fw_dump(scsi_qla_host_t *, int);
335extern void qla2x00_dump_regs(scsi_qla_host_t *); 333extern void qla2x00_dump_regs(scsi_qla_host_t *);
336extern void qla2x00_dump_buffer(uint8_t *, uint32_t); 334extern void qla2x00_dump_buffer(uint8_t *, uint32_t);
337 335
diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
index 0a6f72973996..557f58d5bf88 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -1535,7 +1535,10 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *vha)
1535 eiter = (struct ct_fdmi_port_attr *) (entries + size); 1535 eiter = (struct ct_fdmi_port_attr *) (entries + size);
1536 eiter->type = __constant_cpu_to_be16(FDMI_PORT_SUPPORT_SPEED); 1536 eiter->type = __constant_cpu_to_be16(FDMI_PORT_SUPPORT_SPEED);
1537 eiter->len = __constant_cpu_to_be16(4 + 4); 1537 eiter->len = __constant_cpu_to_be16(4 + 4);
1538 if (IS_QLA25XX(ha)) 1538 if (IS_QLA81XX(ha))
1539 eiter->a.sup_speed = __constant_cpu_to_be32(
1540 FDMI_PORT_SPEED_10GB);
1541 else if (IS_QLA25XX(ha))
1539 eiter->a.sup_speed = __constant_cpu_to_be32( 1542 eiter->a.sup_speed = __constant_cpu_to_be32(
1540 FDMI_PORT_SPEED_1GB|FDMI_PORT_SPEED_2GB| 1543 FDMI_PORT_SPEED_1GB|FDMI_PORT_SPEED_2GB|
1541 FDMI_PORT_SPEED_4GB|FDMI_PORT_SPEED_8GB); 1544 FDMI_PORT_SPEED_4GB|FDMI_PORT_SPEED_8GB);
@@ -1575,6 +1578,10 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *vha)
1575 eiter->a.cur_speed = 1578 eiter->a.cur_speed =
1576 __constant_cpu_to_be32(FDMI_PORT_SPEED_8GB); 1579 __constant_cpu_to_be32(FDMI_PORT_SPEED_8GB);
1577 break; 1580 break;
1581 case PORT_SPEED_10GB:
1582 eiter->a.cur_speed =
1583 __constant_cpu_to_be32(FDMI_PORT_SPEED_10GB);
1584 break;
1578 default: 1585 default:
1579 eiter->a.cur_speed = 1586 eiter->a.cur_speed =
1580 __constant_cpu_to_be32(FDMI_PORT_SPEED_UNKNOWN); 1587 __constant_cpu_to_be32(FDMI_PORT_SPEED_UNKNOWN);
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 52ed56ecf195..9ad4d0968e5c 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -552,10 +552,6 @@ qla24xx_reset_risc(scsi_qla_host_t *vha)
552 d2 = RD_REG_DWORD(&reg->ctrl_status); 552 d2 = RD_REG_DWORD(&reg->ctrl_status);
553 barrier(); 553 barrier();
554 } 554 }
555 if (cnt == 0 || hw_evt)
556 qla2xxx_hw_event_log(vha, HW_EVENT_RESET_ERR,
557 RD_REG_WORD(&reg->mailbox1), RD_REG_WORD(&reg->mailbox2),
558 RD_REG_WORD(&reg->mailbox3));
559 555
560 WRT_REG_DWORD(&reg->hccr, HCCRX_SET_RISC_RESET); 556 WRT_REG_DWORD(&reg->hccr, HCCRX_SET_RISC_RESET);
561 RD_REG_DWORD(&reg->hccr); 557 RD_REG_DWORD(&reg->hccr);
@@ -574,6 +570,9 @@ qla24xx_reset_risc(scsi_qla_host_t *vha)
574 } 570 }
575 571
576 spin_unlock_irqrestore(&ha->hardware_lock, flags); 572 spin_unlock_irqrestore(&ha->hardware_lock, flags);
573
574 if (IS_NOPOLLING_TYPE(ha))
575 ha->isp_ops->enable_intrs(ha);
577} 576}
578 577
579/** 578/**
@@ -779,16 +778,19 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vha)
779 mem_size = (ha->fw_memory_size - 0x11000 + 1) * 778 mem_size = (ha->fw_memory_size - 0x11000 + 1) *
780 sizeof(uint16_t); 779 sizeof(uint16_t);
781 } else if (IS_FWI2_CAPABLE(ha)) { 780 } else if (IS_FWI2_CAPABLE(ha)) {
782 fixed_size = IS_QLA25XX(ha) ? 781 if (IS_QLA81XX(ha))
783 offsetof(struct qla25xx_fw_dump, ext_mem) : 782 fixed_size = offsetof(struct qla81xx_fw_dump, ext_mem);
784 offsetof(struct qla24xx_fw_dump, ext_mem); 783 else if (IS_QLA25XX(ha))
784 fixed_size = offsetof(struct qla25xx_fw_dump, ext_mem);
785 else
786 fixed_size = offsetof(struct qla24xx_fw_dump, ext_mem);
785 mem_size = (ha->fw_memory_size - 0x100000 + 1) * 787 mem_size = (ha->fw_memory_size - 0x100000 + 1) *
786 sizeof(uint32_t); 788 sizeof(uint32_t);
787 if (ha->mqenable) 789 if (ha->mqenable)
788 mq_size = sizeof(struct qla2xxx_mq_chain); 790 mq_size = sizeof(struct qla2xxx_mq_chain);
789 791
790 /* Allocate memory for Fibre Channel Event Buffer. */ 792 /* Allocate memory for Fibre Channel Event Buffer. */
791 if (!IS_QLA25XX(ha)) 793 if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha))
792 goto try_eft; 794 goto try_eft;
793 795
794 tc = dma_alloc_coherent(&ha->pdev->dev, FCE_SIZE, &tc_dma, 796 tc = dma_alloc_coherent(&ha->pdev->dev, FCE_SIZE, &tc_dma,
@@ -851,7 +853,9 @@ cont_alloc:
851 853
852 dump_size = offsetof(struct qla2xxx_fw_dump, isp); 854 dump_size = offsetof(struct qla2xxx_fw_dump, isp);
853 dump_size += fixed_size + mem_size + req_q_size + rsp_q_size + 855 dump_size += fixed_size + mem_size + req_q_size + rsp_q_size +
854 mq_size + eft_size + fce_size; 856 eft_size;
857 ha->chain_offset = dump_size;
858 dump_size += mq_size + fce_size;
855 859
856 ha->fw_dump = vmalloc(dump_size); 860 ha->fw_dump = vmalloc(dump_size);
857 if (!ha->fw_dump) { 861 if (!ha->fw_dump) {
@@ -987,7 +991,8 @@ qla2x00_setup_chip(scsi_qla_host_t *vha)
987 &ha->fw_major_version, 991 &ha->fw_major_version,
988 &ha->fw_minor_version, 992 &ha->fw_minor_version,
989 &ha->fw_subminor_version, 993 &ha->fw_subminor_version,
990 &ha->fw_attributes, &ha->fw_memory_size); 994 &ha->fw_attributes, &ha->fw_memory_size,
995 ha->mpi_version, &ha->mpi_capabilities);
991 ha->flags.npiv_supported = 0; 996 ha->flags.npiv_supported = 0;
992 if (IS_QLA2XXX_MIDTYPE(ha) && 997 if (IS_QLA2XXX_MIDTYPE(ha) &&
993 (ha->fw_attributes & BIT_2)) { 998 (ha->fw_attributes & BIT_2)) {
@@ -1253,35 +1258,48 @@ qla2x00_init_rings(scsi_qla_host_t *vha)
1253{ 1258{
1254 int rval; 1259 int rval;
1255 unsigned long flags = 0; 1260 unsigned long flags = 0;
1256 int cnt; 1261 int cnt, que;
1257 struct qla_hw_data *ha = vha->hw; 1262 struct qla_hw_data *ha = vha->hw;
1258 struct req_que *req = ha->req_q_map[0]; 1263 struct req_que *req;
1259 struct rsp_que *rsp = ha->rsp_q_map[0]; 1264 struct rsp_que *rsp;
1265 struct scsi_qla_host *vp;
1260 struct mid_init_cb_24xx *mid_init_cb = 1266 struct mid_init_cb_24xx *mid_init_cb =
1261 (struct mid_init_cb_24xx *) ha->init_cb; 1267 (struct mid_init_cb_24xx *) ha->init_cb;
1262 1268
1263 spin_lock_irqsave(&ha->hardware_lock, flags); 1269 spin_lock_irqsave(&ha->hardware_lock, flags);
1264 1270
1265 /* Clear outstanding commands array. */ 1271 /* Clear outstanding commands array. */
1266 for (cnt = 0; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) 1272 for (que = 0; que < ha->max_queues; que++) {
1267 req->outstanding_cmds[cnt] = NULL; 1273 req = ha->req_q_map[que];
1274 if (!req)
1275 continue;
1276 for (cnt = 0; cnt < MAX_OUTSTANDING_COMMANDS; cnt++)
1277 req->outstanding_cmds[cnt] = NULL;
1268 1278
1269 req->current_outstanding_cmd = 0; 1279 req->current_outstanding_cmd = 0;
1270 1280
1271 /* Clear RSCN queue. */ 1281 /* Initialize firmware. */
1272 vha->rscn_in_ptr = 0; 1282 req->ring_ptr = req->ring;
1273 vha->rscn_out_ptr = 0; 1283 req->ring_index = 0;
1284 req->cnt = req->length;
1285 }
1274 1286
1275 /* Initialize firmware. */ 1287 for (que = 0; que < ha->max_queues; que++) {
1276 req->ring_ptr = req->ring; 1288 rsp = ha->rsp_q_map[que];
1277 req->ring_index = 0; 1289 if (!rsp)
1278 req->cnt = req->length; 1290 continue;
1279 rsp->ring_ptr = rsp->ring; 1291 rsp->ring_ptr = rsp->ring;
1280 rsp->ring_index = 0; 1292 rsp->ring_index = 0;
1281 1293
1282 /* Initialize response queue entries */ 1294 /* Initialize response queue entries */
1283 qla2x00_init_response_q_entries(rsp); 1295 qla2x00_init_response_q_entries(rsp);
1296 }
1284 1297
1298 /* Clear RSCN queue. */
1299 list_for_each_entry(vp, &ha->vp_list, list) {
1300 vp->rscn_in_ptr = 0;
1301 vp->rscn_out_ptr = 0;
1302 }
1285 ha->isp_ops->config_rings(vha); 1303 ha->isp_ops->config_rings(vha);
1286 1304
1287 spin_unlock_irqrestore(&ha->hardware_lock, flags); 1305 spin_unlock_irqrestore(&ha->hardware_lock, flags);
@@ -1665,10 +1683,6 @@ qla2x00_nvram_config(scsi_qla_host_t *vha)
1665 qla_printk(KERN_WARNING, ha, "Falling back to functioning (yet " 1683 qla_printk(KERN_WARNING, ha, "Falling back to functioning (yet "
1666 "invalid -- WWPN) defaults.\n"); 1684 "invalid -- WWPN) defaults.\n");
1667 1685
1668 if (chksum)
1669 qla2xxx_hw_event_log(vha, HW_EVENT_NVRAM_CHKSUM_ERR, 0,
1670 MSW(chksum), LSW(chksum));
1671
1672 /* 1686 /*
1673 * Set default initialization control block. 1687 * Set default initialization control block.
1674 */ 1688 */
@@ -3211,8 +3225,8 @@ qla2x00_loop_resync(scsi_qla_host_t *vha)
3211 int rval = QLA_SUCCESS; 3225 int rval = QLA_SUCCESS;
3212 uint32_t wait_time; 3226 uint32_t wait_time;
3213 struct qla_hw_data *ha = vha->hw; 3227 struct qla_hw_data *ha = vha->hw;
3214 struct req_que *req = ha->req_q_map[0]; 3228 struct req_que *req = ha->req_q_map[vha->req_ques[0]];
3215 struct rsp_que *rsp = ha->rsp_q_map[0]; 3229 struct rsp_que *rsp = req->rsp;
3216 3230
3217 atomic_set(&vha->loop_state, LOOP_UPDATE); 3231 atomic_set(&vha->loop_state, LOOP_UPDATE);
3218 clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); 3232 clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags);
@@ -3491,6 +3505,7 @@ qla25xx_init_queues(struct qla_hw_data *ha)
3491 } 3505 }
3492 req = ha->req_q_map[i]; 3506 req = ha->req_q_map[i];
3493 if (req) { 3507 if (req) {
3508 /* Clear outstanding commands array. */
3494 req->options &= ~BIT_0; 3509 req->options &= ~BIT_0;
3495 ret = qla25xx_init_req_que(base_vha, req, req->options); 3510 ret = qla25xx_init_req_que(base_vha, req, req->options);
3496 if (ret != QLA_SUCCESS) 3511 if (ret != QLA_SUCCESS)
@@ -3499,7 +3514,7 @@ qla25xx_init_queues(struct qla_hw_data *ha)
3499 req->id)); 3514 req->id));
3500 else 3515 else
3501 DEBUG2_17(printk(KERN_WARNING 3516 DEBUG2_17(printk(KERN_WARNING
3502 "%s Rsp que:%d inited\n", __func__, 3517 "%s Req que:%d inited\n", __func__,
3503 req->id)); 3518 req->id));
3504 } 3519 }
3505 } 3520 }
@@ -4150,8 +4165,8 @@ qla24xx_configure_vhba(scsi_qla_host_t *vha)
4150 uint16_t mb[MAILBOX_REGISTER_COUNT]; 4165 uint16_t mb[MAILBOX_REGISTER_COUNT];
4151 struct qla_hw_data *ha = vha->hw; 4166 struct qla_hw_data *ha = vha->hw;
4152 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); 4167 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
4153 struct req_que *req = ha->req_q_map[0]; 4168 struct req_que *req = ha->req_q_map[vha->req_ques[0]];
4154 struct rsp_que *rsp = ha->rsp_q_map[0]; 4169 struct rsp_que *rsp = req->rsp;
4155 4170
4156 if (!vha->vp_idx) 4171 if (!vha->vp_idx)
4157 return -EINVAL; 4172 return -EINVAL;
@@ -4255,3 +4270,269 @@ qla84xx_init_chip(scsi_qla_host_t *vha)
4255 return rval != QLA_SUCCESS || status[0] ? QLA_FUNCTION_FAILED: 4270 return rval != QLA_SUCCESS || status[0] ? QLA_FUNCTION_FAILED:
4256 QLA_SUCCESS; 4271 QLA_SUCCESS;
4257} 4272}
4273
4274/* 81XX Support **************************************************************/
4275
4276int
4277qla81xx_nvram_config(scsi_qla_host_t *vha)
4278{
4279 int rval;
4280 struct init_cb_81xx *icb;
4281 struct nvram_81xx *nv;
4282 uint32_t *dptr;
4283 uint8_t *dptr1, *dptr2;
4284 uint32_t chksum;
4285 uint16_t cnt;
4286 struct qla_hw_data *ha = vha->hw;
4287
4288 rval = QLA_SUCCESS;
4289 icb = (struct init_cb_81xx *)ha->init_cb;
4290 nv = ha->nvram;
4291
4292 /* Determine NVRAM starting address. */
4293 ha->nvram_size = sizeof(struct nvram_81xx);
4294 ha->nvram_base = FA_NVRAM_FUNC0_ADDR;
4295 ha->vpd_size = FA_NVRAM_VPD_SIZE;
4296 ha->vpd_base = FA_NVRAM_VPD0_ADDR;
4297 if (PCI_FUNC(ha->pdev->devfn) & 1) {
4298 ha->nvram_base = FA_NVRAM_FUNC1_ADDR;
4299 ha->vpd_base = FA_NVRAM_VPD1_ADDR;
4300 }
4301
4302 /* Get VPD data into cache */
4303 ha->vpd = ha->nvram + VPD_OFFSET;
4304 ha->isp_ops->read_nvram(vha, (uint8_t *)ha->vpd,
4305 ha->nvram_base - FA_NVRAM_FUNC0_ADDR, FA_NVRAM_VPD_SIZE * 4);
4306
4307 /* Get NVRAM data into cache and calculate checksum. */
4308 dptr = (uint32_t *)nv;
4309 ha->isp_ops->read_nvram(vha, (uint8_t *)dptr, ha->nvram_base,
4310 ha->nvram_size);
4311 for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++)
4312 chksum += le32_to_cpu(*dptr++);
4313
4314 DEBUG5(printk("scsi(%ld): Contents of NVRAM\n", ha->host_no));
4315 DEBUG5(qla2x00_dump_buffer((uint8_t *)nv, ha->nvram_size));
4316
4317 /* Bad NVRAM data, set defaults parameters. */
4318 if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' || nv->id[2] != 'P'
4319 || nv->id[3] != ' ' ||
4320 nv->nvram_version < __constant_cpu_to_le16(ICB_VERSION)) {
4321 /* Reset NVRAM data. */
4322 qla_printk(KERN_WARNING, ha, "Inconsistent NVRAM detected: "
4323 "checksum=0x%x id=%c version=0x%x.\n", chksum, nv->id[0],
4324 le16_to_cpu(nv->nvram_version));
4325 qla_printk(KERN_WARNING, ha, "Falling back to functioning (yet "
4326 "invalid -- WWPN) defaults.\n");
4327
4328 /*
4329 * Set default initialization control block.
4330 */
4331 memset(nv, 0, ha->nvram_size);
4332 nv->nvram_version = __constant_cpu_to_le16(ICB_VERSION);
4333 nv->version = __constant_cpu_to_le16(ICB_VERSION);
4334 nv->frame_payload_size = __constant_cpu_to_le16(2048);
4335 nv->execution_throttle = __constant_cpu_to_le16(0xFFFF);
4336 nv->exchange_count = __constant_cpu_to_le16(0);
4337 nv->port_name[0] = 0x21;
4338 nv->port_name[1] = 0x00 + PCI_FUNC(ha->pdev->devfn);
4339 nv->port_name[2] = 0x00;
4340 nv->port_name[3] = 0xe0;
4341 nv->port_name[4] = 0x8b;
4342 nv->port_name[5] = 0x1c;
4343 nv->port_name[6] = 0x55;
4344 nv->port_name[7] = 0x86;
4345 nv->node_name[0] = 0x20;
4346 nv->node_name[1] = 0x00;
4347 nv->node_name[2] = 0x00;
4348 nv->node_name[3] = 0xe0;
4349 nv->node_name[4] = 0x8b;
4350 nv->node_name[5] = 0x1c;
4351 nv->node_name[6] = 0x55;
4352 nv->node_name[7] = 0x86;
4353 nv->login_retry_count = __constant_cpu_to_le16(8);
4354 nv->interrupt_delay_timer = __constant_cpu_to_le16(0);
4355 nv->login_timeout = __constant_cpu_to_le16(0);
4356 nv->firmware_options_1 =
4357 __constant_cpu_to_le32(BIT_14|BIT_13|BIT_2|BIT_1);
4358 nv->firmware_options_2 = __constant_cpu_to_le32(2 << 4);
4359 nv->firmware_options_2 |= __constant_cpu_to_le32(BIT_12);
4360 nv->firmware_options_3 = __constant_cpu_to_le32(2 << 13);
4361 nv->host_p = __constant_cpu_to_le32(BIT_11|BIT_10);
4362 nv->efi_parameters = __constant_cpu_to_le32(0);
4363 nv->reset_delay = 5;
4364 nv->max_luns_per_target = __constant_cpu_to_le16(128);
4365 nv->port_down_retry_count = __constant_cpu_to_le16(30);
4366 nv->link_down_timeout = __constant_cpu_to_le16(30);
4367 nv->enode_mac[0] = 0x01;
4368 nv->enode_mac[1] = 0x02;
4369 nv->enode_mac[2] = 0x03;
4370 nv->enode_mac[3] = 0x04;
4371 nv->enode_mac[4] = 0x05;
4372 nv->enode_mac[5] = 0x06 + PCI_FUNC(ha->pdev->devfn);
4373
4374 rval = 1;
4375 }
4376
4377 /* Reset Initialization control block */
4378 memset(icb, 0, sizeof(struct init_cb_81xx));
4379
4380 /* Copy 1st segment. */
4381 dptr1 = (uint8_t *)icb;
4382 dptr2 = (uint8_t *)&nv->version;
4383 cnt = (uint8_t *)&icb->response_q_inpointer - (uint8_t *)&icb->version;
4384 while (cnt--)
4385 *dptr1++ = *dptr2++;
4386
4387 icb->login_retry_count = nv->login_retry_count;
4388
4389 /* Copy 2nd segment. */
4390 dptr1 = (uint8_t *)&icb->interrupt_delay_timer;
4391 dptr2 = (uint8_t *)&nv->interrupt_delay_timer;
4392 cnt = (uint8_t *)&icb->reserved_5 -
4393 (uint8_t *)&icb->interrupt_delay_timer;
4394 while (cnt--)
4395 *dptr1++ = *dptr2++;
4396
4397 memcpy(icb->enode_mac, nv->enode_mac, sizeof(icb->enode_mac));
4398 /* Some boards (with valid NVRAMs) still have NULL enode_mac!! */
4399 if (!memcmp(icb->enode_mac, "\0\0\0\0\0\0", sizeof(icb->enode_mac))) {
4400 icb->enode_mac[0] = 0x01;
4401 icb->enode_mac[1] = 0x02;
4402 icb->enode_mac[2] = 0x03;
4403 icb->enode_mac[3] = 0x04;
4404 icb->enode_mac[4] = 0x05;
4405 icb->enode_mac[5] = 0x06 + PCI_FUNC(ha->pdev->devfn);
4406 }
4407
4408 /*
4409 * Setup driver NVRAM options.
4410 */
4411 qla2x00_set_model_info(vha, nv->model_name, sizeof(nv->model_name),
4412 "QLE81XX");
4413
4414 /* Use alternate WWN? */
4415 if (nv->host_p & __constant_cpu_to_le32(BIT_15)) {
4416 memcpy(icb->node_name, nv->alternate_node_name, WWN_SIZE);
4417 memcpy(icb->port_name, nv->alternate_port_name, WWN_SIZE);
4418 }
4419
4420 /* Prepare nodename */
4421 if ((icb->firmware_options_1 & __constant_cpu_to_le32(BIT_14)) == 0) {
4422 /*
4423 * Firmware will apply the following mask if the nodename was
4424 * not provided.
4425 */
4426 memcpy(icb->node_name, icb->port_name, WWN_SIZE);
4427 icb->node_name[0] &= 0xF0;
4428 }
4429
4430 /* Set host adapter parameters. */
4431 ha->flags.disable_risc_code_load = 0;
4432 ha->flags.enable_lip_reset = 0;
4433 ha->flags.enable_lip_full_login =
4434 le32_to_cpu(nv->host_p) & BIT_10 ? 1: 0;
4435 ha->flags.enable_target_reset =
4436 le32_to_cpu(nv->host_p) & BIT_11 ? 1: 0;
4437 ha->flags.enable_led_scheme = 0;
4438 ha->flags.disable_serdes = le32_to_cpu(nv->host_p) & BIT_5 ? 1: 0;
4439
4440 ha->operating_mode = (le32_to_cpu(icb->firmware_options_2) &
4441 (BIT_6 | BIT_5 | BIT_4)) >> 4;
4442
4443 /* save HBA serial number */
4444 ha->serial0 = icb->port_name[5];
4445 ha->serial1 = icb->port_name[6];
4446 ha->serial2 = icb->port_name[7];
4447 memcpy(vha->node_name, icb->node_name, WWN_SIZE);
4448 memcpy(vha->port_name, icb->port_name, WWN_SIZE);
4449
4450 icb->execution_throttle = __constant_cpu_to_le16(0xFFFF);
4451
4452 ha->retry_count = le16_to_cpu(nv->login_retry_count);
4453
4454 /* Set minimum login_timeout to 4 seconds. */
4455 if (le16_to_cpu(nv->login_timeout) < ql2xlogintimeout)
4456 nv->login_timeout = cpu_to_le16(ql2xlogintimeout);
4457 if (le16_to_cpu(nv->login_timeout) < 4)
4458 nv->login_timeout = __constant_cpu_to_le16(4);
4459 ha->login_timeout = le16_to_cpu(nv->login_timeout);
4460 icb->login_timeout = nv->login_timeout;
4461
4462 /* Set minimum RATOV to 100 tenths of a second. */
4463 ha->r_a_tov = 100;
4464
4465 ha->loop_reset_delay = nv->reset_delay;
4466
4467 /* Link Down Timeout = 0:
4468 *
4469 * When Port Down timer expires we will start returning
4470 * I/O's to OS with "DID_NO_CONNECT".
4471 *
4472 * Link Down Timeout != 0:
4473 *
4474 * The driver waits for the link to come up after link down
4475 * before returning I/Os to OS with "DID_NO_CONNECT".
4476 */
4477 if (le16_to_cpu(nv->link_down_timeout) == 0) {
4478 ha->loop_down_abort_time =
4479 (LOOP_DOWN_TIME - LOOP_DOWN_TIMEOUT);
4480 } else {
4481 ha->link_down_timeout = le16_to_cpu(nv->link_down_timeout);
4482 ha->loop_down_abort_time =
4483 (LOOP_DOWN_TIME - ha->link_down_timeout);
4484 }
4485
4486 /* Need enough time to try and get the port back. */
4487 ha->port_down_retry_count = le16_to_cpu(nv->port_down_retry_count);
4488 if (qlport_down_retry)
4489 ha->port_down_retry_count = qlport_down_retry;
4490
4491 /* Set login_retry_count */
4492 ha->login_retry_count = le16_to_cpu(nv->login_retry_count);
4493 if (ha->port_down_retry_count ==
4494 le16_to_cpu(nv->port_down_retry_count) &&
4495 ha->port_down_retry_count > 3)
4496 ha->login_retry_count = ha->port_down_retry_count;
4497 else if (ha->port_down_retry_count > (int)ha->login_retry_count)
4498 ha->login_retry_count = ha->port_down_retry_count;
4499 if (ql2xloginretrycount)
4500 ha->login_retry_count = ql2xloginretrycount;
4501
4502 /* Enable ZIO. */
4503 if (!vha->flags.init_done) {
4504 ha->zio_mode = le32_to_cpu(icb->firmware_options_2) &
4505 (BIT_3 | BIT_2 | BIT_1 | BIT_0);
4506 ha->zio_timer = le16_to_cpu(icb->interrupt_delay_timer) ?
4507 le16_to_cpu(icb->interrupt_delay_timer): 2;
4508 }
4509 icb->firmware_options_2 &= __constant_cpu_to_le32(
4510 ~(BIT_3 | BIT_2 | BIT_1 | BIT_0));
4511 vha->flags.process_response_queue = 0;
4512 if (ha->zio_mode != QLA_ZIO_DISABLED) {
4513 ha->zio_mode = QLA_ZIO_MODE_6;
4514
4515 DEBUG2(printk("scsi(%ld): ZIO mode %d enabled; timer delay "
4516 "(%d us).\n", vha->host_no, ha->zio_mode,
4517 ha->zio_timer * 100));
4518 qla_printk(KERN_INFO, ha,
4519 "ZIO mode %d enabled; timer delay (%d us).\n",
4520 ha->zio_mode, ha->zio_timer * 100);
4521
4522 icb->firmware_options_2 |= cpu_to_le32(
4523 (uint32_t)ha->zio_mode);
4524 icb->interrupt_delay_timer = cpu_to_le16(ha->zio_timer);
4525 vha->flags.process_response_queue = 1;
4526 }
4527
4528 if (rval) {
4529 DEBUG2_3(printk(KERN_WARNING
4530 "scsi(%ld): NVRAM configuration failed!\n", vha->host_no));
4531 }
4532 return (rval);
4533}
4534
4535void
4536qla81xx_update_fw_options(scsi_qla_host_t *ha)
4537{
4538}
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index 5bedc9d05942..2258152b1f41 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -173,7 +173,7 @@ void qla2x00_build_scsi_iocbs_32(srb_t *sp, cmd_entry_t *cmd_pkt,
173 return; 173 return;
174 } 174 }
175 175
176 vha = sp->vha; 176 vha = sp->fcport->vha;
177 req = sp->que; 177 req = sp->que;
178 178
179 cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(sp)); 179 cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(sp));
@@ -234,7 +234,7 @@ void qla2x00_build_scsi_iocbs_64(srb_t *sp, cmd_entry_t *cmd_pkt,
234 return; 234 return;
235 } 235 }
236 236
237 vha = sp->vha; 237 vha = sp->fcport->vha;
238 req = sp->que; 238 req = sp->que;
239 239
240 cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(sp)); 240 cmd_pkt->control_flags |= cpu_to_le16(qla2x00_get_cmd_direction(sp));
@@ -294,7 +294,7 @@ qla2x00_start_scsi(srb_t *sp)
294 294
295 /* Setup device pointers. */ 295 /* Setup device pointers. */
296 ret = 0; 296 ret = 0;
297 vha = sp->vha; 297 vha = sp->fcport->vha;
298 ha = vha->hw; 298 ha = vha->hw;
299 reg = &ha->iobase->isp; 299 reg = &ha->iobase->isp;
300 cmd = sp->cmd; 300 cmd = sp->cmd;
@@ -353,7 +353,6 @@ qla2x00_start_scsi(srb_t *sp)
353 /* Build command packet */ 353 /* Build command packet */
354 req->current_outstanding_cmd = handle; 354 req->current_outstanding_cmd = handle;
355 req->outstanding_cmds[handle] = sp; 355 req->outstanding_cmds[handle] = sp;
356 sp->vha = vha;
357 sp->que = req; 356 sp->que = req;
358 sp->cmd->host_scribble = (unsigned char *)(unsigned long)handle; 357 sp->cmd->host_scribble = (unsigned char *)(unsigned long)handle;
359 req->cnt -= req_cnt; 358 req->cnt -= req_cnt;
@@ -656,7 +655,7 @@ qla24xx_build_scsi_iocbs(srb_t *sp, struct cmd_type_7 *cmd_pkt,
656 return; 655 return;
657 } 656 }
658 657
659 vha = sp->vha; 658 vha = sp->fcport->vha;
660 req = sp->que; 659 req = sp->que;
661 660
662 /* Set transfer direction */ 661 /* Set transfer direction */
@@ -723,7 +722,7 @@ qla24xx_start_scsi(srb_t *sp)
723 struct req_que *req = NULL; 722 struct req_que *req = NULL;
724 struct rsp_que *rsp = NULL; 723 struct rsp_que *rsp = NULL;
725 struct scsi_cmnd *cmd = sp->cmd; 724 struct scsi_cmnd *cmd = sp->cmd;
726 struct scsi_qla_host *vha = sp->vha; 725 struct scsi_qla_host *vha = sp->fcport->vha;
727 struct qla_hw_data *ha = vha->hw; 726 struct qla_hw_data *ha = vha->hw;
728 uint16_t que_id; 727 uint16_t que_id;
729 728
@@ -791,7 +790,6 @@ qla24xx_start_scsi(srb_t *sp)
791 /* Build command packet. */ 790 /* Build command packet. */
792 req->current_outstanding_cmd = handle; 791 req->current_outstanding_cmd = handle;
793 req->outstanding_cmds[handle] = sp; 792 req->outstanding_cmds[handle] = sp;
794 sp->vha = vha;
795 sp->cmd->host_scribble = (unsigned char *)(unsigned long)handle; 793 sp->cmd->host_scribble = (unsigned char *)(unsigned long)handle;
796 req->cnt -= req_cnt; 794 req->cnt -= req_cnt;
797 795
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index d5fb79a88001..789fc576f222 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -275,7 +275,7 @@ void
275qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb) 275qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb)
276{ 276{
277#define LS_UNKNOWN 2 277#define LS_UNKNOWN 2
278 static char *link_speeds[5] = { "1", "2", "?", "4", "8" }; 278 static char *link_speeds[] = { "1", "2", "?", "4", "8", "10" };
279 char *link_speed; 279 char *link_speed;
280 uint16_t handle_cnt; 280 uint16_t handle_cnt;
281 uint16_t cnt; 281 uint16_t cnt;
@@ -288,6 +288,8 @@ qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb)
288 288
289 /* Setup to process RIO completion. */ 289 /* Setup to process RIO completion. */
290 handle_cnt = 0; 290 handle_cnt = 0;
291 if (IS_QLA81XX(ha))
292 goto skip_rio;
291 switch (mb[0]) { 293 switch (mb[0]) {
292 case MBA_SCSI_COMPLETION: 294 case MBA_SCSI_COMPLETION:
293 handles[0] = le32_to_cpu((uint32_t)((mb[2] << 16) | mb[1])); 295 handles[0] = le32_to_cpu((uint32_t)((mb[2] << 16) | mb[1]));
@@ -339,7 +341,7 @@ qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb)
339 default: 341 default:
340 break; 342 break;
341 } 343 }
342 344skip_rio:
343 switch (mb[0]) { 345 switch (mb[0]) {
344 case MBA_SCSI_COMPLETION: /* Fast Post */ 346 case MBA_SCSI_COMPLETION: /* Fast Post */
345 if (!vha->flags.online) 347 if (!vha->flags.online)
@@ -362,7 +364,6 @@ qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb)
362 "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh.\n", 364 "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh.\n",
363 mb[1], mb[2], mb[3]); 365 mb[1], mb[2], mb[3]);
364 366
365 qla2x00_post_hwe_work(vha, mb[0], mb[1], mb[2], mb[3]);
366 ha->isp_ops->fw_dump(vha, 1); 367 ha->isp_ops->fw_dump(vha, 1);
367 368
368 if (IS_FWI2_CAPABLE(ha)) { 369 if (IS_FWI2_CAPABLE(ha)) {
@@ -387,7 +388,6 @@ qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb)
387 vha->host_no)); 388 vha->host_no));
388 qla_printk(KERN_WARNING, ha, "ISP Request Transfer Error.\n"); 389 qla_printk(KERN_WARNING, ha, "ISP Request Transfer Error.\n");
389 390
390 qla2x00_post_hwe_work(vha, mb[0], mb[1], mb[2], mb[3]);
391 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); 391 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
392 break; 392 break;
393 393
@@ -396,7 +396,6 @@ qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb)
396 vha->host_no)); 396 vha->host_no));
397 qla_printk(KERN_WARNING, ha, "ISP Response Transfer Error.\n"); 397 qla_printk(KERN_WARNING, ha, "ISP Response Transfer Error.\n");
398 398
399 qla2x00_post_hwe_work(vha, mb[0], mb[1], mb[2], mb[3]);
400 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); 399 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
401 break; 400 break;
402 401
@@ -436,6 +435,8 @@ qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb)
436 link_speed = link_speeds[LS_UNKNOWN]; 435 link_speed = link_speeds[LS_UNKNOWN];
437 if (mb[1] < 5) 436 if (mb[1] < 5)
438 link_speed = link_speeds[mb[1]]; 437 link_speed = link_speeds[mb[1]];
438 else if (mb[1] == 0x13)
439 link_speed = link_speeds[5];
439 ha->link_data_rate = mb[1]; 440 ha->link_data_rate = mb[1];
440 } 441 }
441 442
@@ -495,12 +496,17 @@ qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb)
495 qla2x00_post_aen_work(vha, FCH_EVT_LIPRESET, mb[1]); 496 qla2x00_post_aen_work(vha, FCH_EVT_LIPRESET, mb[1]);
496 break; 497 break;
497 498
499 /* case MBA_DCBX_COMPLETE: */
498 case MBA_POINT_TO_POINT: /* Point-to-Point */ 500 case MBA_POINT_TO_POINT: /* Point-to-Point */
499 if (IS_QLA2100(ha)) 501 if (IS_QLA2100(ha))
500 break; 502 break;
501 503
502 DEBUG2(printk("scsi(%ld): Asynchronous P2P MODE received.\n", 504 if (IS_QLA81XX(ha))
503 vha->host_no)); 505 DEBUG2(printk("scsi(%ld): DCBX Completed -- %04x %04x "
506 "%04x\n", vha->host_no, mb[1], mb[2], mb[3]));
507 else
508 DEBUG2(printk("scsi(%ld): Asynchronous P2P MODE "
509 "received.\n", vha->host_no));
504 510
505 /* 511 /*
506 * Until there's a transition from loop down to loop up, treat 512 * Until there's a transition from loop down to loop up, treat
@@ -641,10 +647,7 @@ qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb)
641 647
642 /* case MBA_RIO_RESPONSE: */ 648 /* case MBA_RIO_RESPONSE: */
643 case MBA_ZIO_RESPONSE: 649 case MBA_ZIO_RESPONSE:
644 DEBUG2(printk("scsi(%ld): [R|Z]IO update completion.\n", 650 DEBUG3(printk("scsi(%ld): [R|Z]IO update completion.\n",
645 vha->host_no));
646 DEBUG(printk(KERN_INFO
647 "scsi(%ld): [R|Z]IO update completion.\n",
648 vha->host_no)); 651 vha->host_no));
649 652
650 if (IS_FWI2_CAPABLE(ha)) 653 if (IS_FWI2_CAPABLE(ha))
@@ -698,6 +701,35 @@ qla2x00_async_event(scsi_qla_host_t *vha, struct rsp_que *rsp, uint16_t *mb)
698 } 701 }
699 spin_unlock_irqrestore(&ha->cs84xx->access_lock, flags); 702 spin_unlock_irqrestore(&ha->cs84xx->access_lock, flags);
700 break; 703 break;
704 case MBA_DCBX_START:
705 DEBUG2(printk("scsi(%ld): DCBX Started -- %04x %04x %04x\n",
706 vha->host_no, mb[1], mb[2], mb[3]));
707 break;
708 case MBA_DCBX_PARAM_UPDATE:
709 DEBUG2(printk("scsi(%ld): DCBX Parameters Updated -- "
710 "%04x %04x %04x\n", vha->host_no, mb[1], mb[2], mb[3]));
711 break;
712 case MBA_FCF_CONF_ERR:
713 DEBUG2(printk("scsi(%ld): FCF Configuration Error -- "
714 "%04x %04x %04x\n", vha->host_no, mb[1], mb[2], mb[3]));
715 break;
716 case MBA_IDC_COMPLETE:
717 DEBUG2(printk("scsi(%ld): Inter-Driver Commucation "
718 "Complete -- %04x %04x %04x\n", vha->host_no, mb[1], mb[2],
719 mb[3]));
720 break;
721 case MBA_IDC_NOTIFY:
722 DEBUG2(printk("scsi(%ld): Inter-Driver Commucation "
723 "Request Notification -- %04x %04x %04x\n", vha->host_no,
724 mb[1], mb[2], mb[3]));
725 /**** Mailbox registers 4 - 7 valid!!! */
726 break;
727 case MBA_IDC_TIME_EXT:
728 DEBUG2(printk("scsi(%ld): Inter-Driver Commucation "
729 "Time Extension -- %04x %04x %04x\n", vha->host_no, mb[1],
730 mb[2], mb[3]));
731 /**** Mailbox registers 4 - 7 valid!!! */
732 break;
701 } 733 }
702 734
703 if (!vha->vp_idx && ha->num_vhosts) 735 if (!vha->vp_idx && ha->num_vhosts)
@@ -1510,7 +1542,7 @@ qla2xxx_check_risc_status(scsi_qla_host_t *vha)
1510 struct qla_hw_data *ha = vha->hw; 1542 struct qla_hw_data *ha = vha->hw;
1511 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; 1543 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1512 1544
1513 if (!IS_QLA25XX(ha)) 1545 if (!IS_QLA25XX(ha) && !IS_QLA81XX(ha))
1514 return; 1546 return;
1515 1547
1516 rval = QLA_SUCCESS; 1548 rval = QLA_SUCCESS;
@@ -1590,12 +1622,6 @@ qla24xx_intr_handler(int irq, void *dev_id)
1590 if (pci_channel_offline(ha->pdev)) 1622 if (pci_channel_offline(ha->pdev))
1591 break; 1623 break;
1592 1624
1593 if (ha->hw_event_pause_errors == 0)
1594 qla2x00_post_hwe_work(vha, HW_EVENT_PARITY_ERR,
1595 0, MSW(stat), LSW(stat));
1596 else if (ha->hw_event_pause_errors < 0xffffffff)
1597 ha->hw_event_pause_errors++;
1598
1599 hccr = RD_REG_DWORD(&reg->hccr); 1625 hccr = RD_REG_DWORD(&reg->hccr);
1600 1626
1601 qla_printk(KERN_INFO, ha, "RISC paused -- HCCR=%x, " 1627 qla_printk(KERN_INFO, ha, "RISC paused -- HCCR=%x, "
@@ -1740,12 +1766,6 @@ qla24xx_msix_default(int irq, void *dev_id)
1740 if (pci_channel_offline(ha->pdev)) 1766 if (pci_channel_offline(ha->pdev))
1741 break; 1767 break;
1742 1768
1743 if (ha->hw_event_pause_errors == 0)
1744 qla2x00_post_hwe_work(vha, HW_EVENT_PARITY_ERR,
1745 0, MSW(stat), LSW(stat));
1746 else if (ha->hw_event_pause_errors < 0xffffffff)
1747 ha->hw_event_pause_errors++;
1748
1749 hccr = RD_REG_DWORD(&reg->hccr); 1769 hccr = RD_REG_DWORD(&reg->hccr);
1750 1770
1751 qla_printk(KERN_INFO, ha, "RISC paused -- HCCR=%x, " 1771 qla_printk(KERN_INFO, ha, "RISC paused -- HCCR=%x, "
@@ -1944,7 +1964,8 @@ qla2x00_request_irqs(struct qla_hw_data *ha, struct rsp_que *rsp)
1944 device_reg_t __iomem *reg = ha->iobase; 1964 device_reg_t __iomem *reg = ha->iobase;
1945 1965
1946 /* If possible, enable MSI-X. */ 1966 /* If possible, enable MSI-X. */
1947 if (!IS_QLA2432(ha) && !IS_QLA2532(ha) && !IS_QLA8432(ha)) 1967 if (!IS_QLA2432(ha) && !IS_QLA2532(ha) &&
1968 !IS_QLA8432(ha) && !IS_QLA8001(ha))
1948 goto skip_msix; 1969 goto skip_msix;
1949 1970
1950 if (IS_QLA2432(ha) && (ha->pdev->revision < QLA_MSIX_CHIP_REV_24XX || 1971 if (IS_QLA2432(ha) && (ha->pdev->revision < QLA_MSIX_CHIP_REV_24XX ||
@@ -1979,7 +2000,8 @@ qla2x00_request_irqs(struct qla_hw_data *ha, struct rsp_que *rsp)
1979 "MSI-X: Falling back-to INTa mode -- %d.\n", ret); 2000 "MSI-X: Falling back-to INTa mode -- %d.\n", ret);
1980skip_msix: 2001skip_msix:
1981 2002
1982 if (!IS_QLA24XX(ha) && !IS_QLA2532(ha) && !IS_QLA8432(ha)) 2003 if (!IS_QLA24XX(ha) && !IS_QLA2532(ha) && !IS_QLA8432(ha) &&
2004 !IS_QLA8001(ha))
1983 goto skip_msi; 2005 goto skip_msi;
1984 2006
1985 ret = pci_enable_msi(ha->pdev); 2007 ret = pci_enable_msi(ha->pdev);
@@ -2000,6 +2022,12 @@ skip_msi:
2000 ha->flags.inta_enabled = 1; 2022 ha->flags.inta_enabled = 1;
2001clear_risc_ints: 2023clear_risc_ints:
2002 2024
2025 /*
2026 * FIXME: Noted that 8014s were being dropped during NK testing.
2027 * Timing deltas during MSI-X/INTa transitions?
2028 */
2029 if (IS_QLA81XX(ha))
2030 goto fail;
2003 spin_lock_irq(&ha->hardware_lock); 2031 spin_lock_irq(&ha->hardware_lock);
2004 if (IS_FWI2_CAPABLE(ha)) { 2032 if (IS_FWI2_CAPABLE(ha)) {
2005 WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_CLR_HOST_INT); 2033 WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_CLR_HOST_INT);
@@ -2044,7 +2072,7 @@ qla2x00_get_rsp_host(struct rsp_que *rsp)
2044 if (pkt && pkt->handle < MAX_OUTSTANDING_COMMANDS) { 2072 if (pkt && pkt->handle < MAX_OUTSTANDING_COMMANDS) {
2045 sp = req->outstanding_cmds[pkt->handle]; 2073 sp = req->outstanding_cmds[pkt->handle];
2046 if (sp) 2074 if (sp)
2047 vha = sp->vha; 2075 vha = sp->fcport->vha;
2048 } 2076 }
2049 } 2077 }
2050 if (!vha) 2078 if (!vha)
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index a99976f5fabd..db4df45234a5 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -123,8 +123,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
123 123
124 /* Wait for mbx cmd completion until timeout */ 124 /* Wait for mbx cmd completion until timeout */
125 125
126 if (!abort_active && io_lock_on) { 126 if ((!abort_active && io_lock_on) || IS_NOPOLLING_TYPE(ha)) {
127
128 set_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); 127 set_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags);
129 128
130 if (IS_FWI2_CAPABLE(ha)) 129 if (IS_FWI2_CAPABLE(ha))
@@ -218,7 +217,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
218 /* Clean up */ 217 /* Clean up */
219 ha->mcp = NULL; 218 ha->mcp = NULL;
220 219
221 if (abort_active || !io_lock_on) { 220 if ((abort_active || !io_lock_on) && !IS_NOPOLLING_TYPE(ha)) {
222 DEBUG11(printk("%s(%ld): checking for additional resp " 221 DEBUG11(printk("%s(%ld): checking for additional resp "
223 "interrupt.\n", __func__, base_vha->host_no)); 222 "interrupt.\n", __func__, base_vha->host_no));
224 223
@@ -412,7 +411,8 @@ qla2x00_execute_fw(scsi_qla_host_t *vha, uint32_t risc_addr)
412 */ 411 */
413void 412void
414qla2x00_get_fw_version(scsi_qla_host_t *vha, uint16_t *major, uint16_t *minor, 413qla2x00_get_fw_version(scsi_qla_host_t *vha, uint16_t *major, uint16_t *minor,
415 uint16_t *subminor, uint16_t *attributes, uint32_t *memory) 414 uint16_t *subminor, uint16_t *attributes, uint32_t *memory, uint8_t *mpi,
415 uint32_t *mpi_caps)
416{ 416{
417 int rval; 417 int rval;
418 mbx_cmd_t mc; 418 mbx_cmd_t mc;
@@ -423,6 +423,8 @@ qla2x00_get_fw_version(scsi_qla_host_t *vha, uint16_t *major, uint16_t *minor,
423 mcp->mb[0] = MBC_GET_FIRMWARE_VERSION; 423 mcp->mb[0] = MBC_GET_FIRMWARE_VERSION;
424 mcp->out_mb = MBX_0; 424 mcp->out_mb = MBX_0;
425 mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0; 425 mcp->in_mb = MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
426 if (IS_QLA81XX(vha->hw))
427 mcp->in_mb |= MBX_13|MBX_12|MBX_11|MBX_10;
426 mcp->flags = 0; 428 mcp->flags = 0;
427 mcp->tov = MBX_TOV_SECONDS; 429 mcp->tov = MBX_TOV_SECONDS;
428 rval = qla2x00_mailbox_command(vha, mcp); 430 rval = qla2x00_mailbox_command(vha, mcp);
@@ -436,6 +438,13 @@ qla2x00_get_fw_version(scsi_qla_host_t *vha, uint16_t *major, uint16_t *minor,
436 *memory = 0x1FFFF; /* Defaults to 128KB. */ 438 *memory = 0x1FFFF; /* Defaults to 128KB. */
437 else 439 else
438 *memory = (mcp->mb[5] << 16) | mcp->mb[4]; 440 *memory = (mcp->mb[5] << 16) | mcp->mb[4];
441 if (IS_QLA81XX(vha->hw)) {
442 mpi[0] = mcp->mb[10] >> 8;
443 mpi[1] = mcp->mb[10] & 0xff;
444 mpi[2] = mcp->mb[11] >> 8;
445 mpi[3] = mcp->mb[11] & 0xff;
446 *mpi_caps = (mcp->mb[12] << 16) | mcp->mb[13];
447 }
439 448
440 if (rval != QLA_SUCCESS) { 449 if (rval != QLA_SUCCESS) {
441 /*EMPTY*/ 450 /*EMPTY*/
@@ -568,7 +577,6 @@ int
568qla2x00_mbx_reg_test(scsi_qla_host_t *vha) 577qla2x00_mbx_reg_test(scsi_qla_host_t *vha)
569{ 578{
570 int rval; 579 int rval;
571 struct qla_hw_data *ha = vha->hw;
572 mbx_cmd_t mc; 580 mbx_cmd_t mc;
573 mbx_cmd_t *mcp = &mc; 581 mbx_cmd_t *mcp = &mc;
574 582
@@ -595,14 +603,6 @@ qla2x00_mbx_reg_test(scsi_qla_host_t *vha)
595 if (mcp->mb[5] != 0xA5A5 || mcp->mb[6] != 0x5A5A || 603 if (mcp->mb[5] != 0xA5A5 || mcp->mb[6] != 0x5A5A ||
596 mcp->mb[7] != 0x2525) 604 mcp->mb[7] != 0x2525)
597 rval = QLA_FUNCTION_FAILED; 605 rval = QLA_FUNCTION_FAILED;
598 if (rval == QLA_FUNCTION_FAILED) {
599 struct device_reg_24xx __iomem *reg =
600 &ha->iobase->isp24;
601
602 qla2xxx_hw_event_log(vha, HW_EVENT_ISP_ERR, 0,
603 LSW(RD_REG_DWORD(&reg->hccr)),
604 LSW(RD_REG_DWORD(&reg->istatus)));
605 }
606 } 606 }
607 607
608 if (rval != QLA_SUCCESS) { 608 if (rval != QLA_SUCCESS) {
@@ -1363,7 +1363,13 @@ qla2x00_lip_reset(scsi_qla_host_t *vha)
1363 1363
1364 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 1364 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
1365 1365
1366 if (IS_FWI2_CAPABLE(vha->hw)) { 1366 if (IS_QLA81XX(vha->hw)) {
1367 /* Logout across all FCFs. */
1368 mcp->mb[0] = MBC_LIP_FULL_LOGIN;
1369 mcp->mb[1] = BIT_1;
1370 mcp->mb[2] = 0;
1371 mcp->out_mb = MBX_2|MBX_1|MBX_0;
1372 } else if (IS_FWI2_CAPABLE(vha->hw)) {
1367 mcp->mb[0] = MBC_LIP_FULL_LOGIN; 1373 mcp->mb[0] = MBC_LIP_FULL_LOGIN;
1368 mcp->mb[1] = BIT_6; 1374 mcp->mb[1] = BIT_6;
1369 mcp->mb[2] = 0; 1375 mcp->mb[2] = 0;
@@ -1853,6 +1859,9 @@ qla2x00_full_login_lip(scsi_qla_host_t *vha)
1853 mbx_cmd_t mc; 1859 mbx_cmd_t mc;
1854 mbx_cmd_t *mcp = &mc; 1860 mbx_cmd_t *mcp = &mc;
1855 1861
1862 if (IS_QLA81XX(vha->hw))
1863 return QLA_SUCCESS;
1864
1856 DEBUG11(printk("qla2x00_full_login_lip(%ld): entered.\n", 1865 DEBUG11(printk("qla2x00_full_login_lip(%ld): entered.\n",
1857 vha->host_no)); 1866 vha->host_no));
1858 1867
@@ -2512,7 +2521,7 @@ qla2x00_enable_fce_trace(scsi_qla_host_t *vha, dma_addr_t fce_dma,
2512 mbx_cmd_t mc; 2521 mbx_cmd_t mc;
2513 mbx_cmd_t *mcp = &mc; 2522 mbx_cmd_t *mcp = &mc;
2514 2523
2515 if (!IS_QLA25XX(vha->hw)) 2524 if (!IS_QLA25XX(vha->hw) && !IS_QLA81XX(vha->hw))
2516 return QLA_FUNCTION_FAILED; 2525 return QLA_FUNCTION_FAILED;
2517 2526
2518 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no)); 2527 DEBUG11(printk("%s(%ld): entered.\n", __func__, vha->host_no));
@@ -3155,7 +3164,7 @@ qla25xx_init_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp,
3155 mcp->mb[7] = LSW(MSD(rsp->dma)); 3164 mcp->mb[7] = LSW(MSD(rsp->dma));
3156 mcp->mb[5] = rsp->length; 3165 mcp->mb[5] = rsp->length;
3157 mcp->mb[11] = rsp->vp_idx; 3166 mcp->mb[11] = rsp->vp_idx;
3158 mcp->mb[14] = rsp->msix->vector; 3167 mcp->mb[14] = rsp->msix->entry;
3159 mcp->mb[13] = rsp->rid; 3168 mcp->mb[13] = rsp->rid;
3160 3169
3161 reg = (struct device_reg_25xxmq *)((void *)(ha->mqiobase) + 3170 reg = (struct device_reg_25xxmq *)((void *)(ha->mqiobase) +
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
index 386ffeae5b5a..f53179c46423 100644
--- a/drivers/scsi/qla2xxx/qla_mid.c
+++ b/drivers/scsi/qla2xxx/qla_mid.c
@@ -614,8 +614,10 @@ qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options,
614 req->vp_idx = vp_idx; 614 req->vp_idx = vp_idx;
615 req->qos = qos; 615 req->qos = qos;
616 616
617 if (ha->rsp_q_map[rsp_que]) 617 if (ha->rsp_q_map[rsp_que]) {
618 req->rsp = ha->rsp_q_map[rsp_que]; 618 req->rsp = ha->rsp_q_map[rsp_que];
619 req->rsp->req = req;
620 }
619 /* Use alternate PCI bus number */ 621 /* Use alternate PCI bus number */
620 if (MSB(req->rid)) 622 if (MSB(req->rid))
621 options |= BIT_4; 623 options |= BIT_4;
@@ -627,6 +629,7 @@ qla25xx_create_req_que(struct qla_hw_data *ha, uint16_t options,
627 req->ring_index = 0; 629 req->ring_index = 0;
628 req->cnt = req->length; 630 req->cnt = req->length;
629 req->id = que_id; 631 req->id = que_id;
632 req->max_q_depth = ha->req_q_map[0]->max_q_depth;
630 mutex_unlock(&ha->vport_lock); 633 mutex_unlock(&ha->vport_lock);
631 634
632 ret = qla25xx_init_req_que(base_vha, req, options); 635 ret = qla25xx_init_req_que(base_vha, req, options);
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 8ea927788b3f..cf32653fe01a 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -404,26 +404,9 @@ static char *
404qla24xx_fw_version_str(struct scsi_qla_host *vha, char *str) 404qla24xx_fw_version_str(struct scsi_qla_host *vha, char *str)
405{ 405{
406 struct qla_hw_data *ha = vha->hw; 406 struct qla_hw_data *ha = vha->hw;
407 sprintf(str, "%d.%02d.%02d ", ha->fw_major_version,
408 ha->fw_minor_version,
409 ha->fw_subminor_version);
410 407
411 if (ha->fw_attributes & BIT_0) 408 sprintf(str, "%d.%02d.%02d (%x)", ha->fw_major_version,
412 strcat(str, "[Class 2] "); 409 ha->fw_minor_version, ha->fw_subminor_version, ha->fw_attributes);
413 if (ha->fw_attributes & BIT_1)
414 strcat(str, "[IP] ");
415 if (ha->fw_attributes & BIT_2)
416 strcat(str, "[Multi-ID] ");
417 if (ha->fw_attributes & BIT_3)
418 strcat(str, "[SB-2] ");
419 if (ha->fw_attributes & BIT_4)
420 strcat(str, "[T10 CRC] ");
421 if (ha->fw_attributes & BIT_5)
422 strcat(str, "[VI] ");
423 if (ha->fw_attributes & BIT_10)
424 strcat(str, "[84XX] ");
425 if (ha->fw_attributes & BIT_13)
426 strcat(str, "[Experimental]");
427 return str; 410 return str;
428} 411}
429 412
@@ -438,7 +421,6 @@ qla2x00_get_new_sp(scsi_qla_host_t *vha, fc_port_t *fcport,
438 if (!sp) 421 if (!sp)
439 return sp; 422 return sp;
440 423
441 sp->vha = vha;
442 sp->fcport = fcport; 424 sp->fcport = fcport;
443 sp->cmd = cmd; 425 sp->cmd = cmd;
444 sp->que = ha->req_q_map[0]; 426 sp->que = ha->req_q_map[0];
@@ -1176,13 +1158,13 @@ qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res)
1176 struct req_que *req; 1158 struct req_que *req;
1177 1159
1178 spin_lock_irqsave(&ha->hardware_lock, flags); 1160 spin_lock_irqsave(&ha->hardware_lock, flags);
1179 for (que = 0; que < QLA_MAX_HOST_QUES; que++) { 1161 for (que = 0; que < ha->max_queues; que++) {
1180 req = ha->req_q_map[vha->req_ques[que]]; 1162 req = ha->req_q_map[que];
1181 if (!req) 1163 if (!req)
1182 continue; 1164 continue;
1183 for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { 1165 for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
1184 sp = req->outstanding_cmds[cnt]; 1166 sp = req->outstanding_cmds[cnt];
1185 if (sp && sp->vha == vha) { 1167 if (sp && sp->fcport->vha == vha) {
1186 req->outstanding_cmds[cnt] = NULL; 1168 req->outstanding_cmds[cnt] = NULL;
1187 sp->cmd->result = res; 1169 sp->cmd->result = res;
1188 qla2x00_sp_compl(ha, sp); 1170 qla2x00_sp_compl(ha, sp);
@@ -1211,7 +1193,7 @@ qla2xxx_slave_configure(struct scsi_device *sdev)
1211 scsi_qla_host_t *vha = shost_priv(sdev->host); 1193 scsi_qla_host_t *vha = shost_priv(sdev->host);
1212 struct qla_hw_data *ha = vha->hw; 1194 struct qla_hw_data *ha = vha->hw;
1213 struct fc_rport *rport = starget_to_rport(sdev->sdev_target); 1195 struct fc_rport *rport = starget_to_rport(sdev->sdev_target);
1214 struct req_que *req = ha->req_q_map[0]; 1196 struct req_que *req = ha->req_q_map[vha->req_ques[0]];
1215 1197
1216 if (sdev->tagged_supported) 1198 if (sdev->tagged_supported)
1217 scsi_activate_tcq(sdev, req->max_q_depth); 1199 scsi_activate_tcq(sdev, req->max_q_depth);
@@ -1329,6 +1311,8 @@ qla24xx_disable_intrs(struct qla_hw_data *ha)
1329 unsigned long flags = 0; 1311 unsigned long flags = 0;
1330 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; 1312 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1331 1313
1314 if (IS_NOPOLLING_TYPE(ha))
1315 return;
1332 spin_lock_irqsave(&ha->hardware_lock, flags); 1316 spin_lock_irqsave(&ha->hardware_lock, flags);
1333 ha->interrupts_on = 0; 1317 ha->interrupts_on = 0;
1334 WRT_REG_DWORD(&reg->ictrl, 0); 1318 WRT_REG_DWORD(&reg->ictrl, 0);
@@ -1488,6 +1472,44 @@ static struct isp_operations qla25xx_isp_ops = {
1488 .rd_req_reg = qla24xx_rd_req_reg, 1472 .rd_req_reg = qla24xx_rd_req_reg,
1489}; 1473};
1490 1474
1475static struct isp_operations qla81xx_isp_ops = {
1476 .pci_config = qla25xx_pci_config,
1477 .reset_chip = qla24xx_reset_chip,
1478 .chip_diag = qla24xx_chip_diag,
1479 .config_rings = qla24xx_config_rings,
1480 .reset_adapter = qla24xx_reset_adapter,
1481 .nvram_config = qla81xx_nvram_config,
1482 .update_fw_options = qla81xx_update_fw_options,
1483 .load_risc = qla24xx_load_risc,
1484 .pci_info_str = qla24xx_pci_info_str,
1485 .fw_version_str = qla24xx_fw_version_str,
1486 .intr_handler = qla24xx_intr_handler,
1487 .enable_intrs = qla24xx_enable_intrs,
1488 .disable_intrs = qla24xx_disable_intrs,
1489 .abort_command = qla24xx_abort_command,
1490 .target_reset = qla24xx_abort_target,
1491 .lun_reset = qla24xx_lun_reset,
1492 .fabric_login = qla24xx_login_fabric,
1493 .fabric_logout = qla24xx_fabric_logout,
1494 .calc_req_entries = NULL,
1495 .build_iocbs = NULL,
1496 .prep_ms_iocb = qla24xx_prep_ms_iocb,
1497 .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb,
1498 .read_nvram = qla25xx_read_nvram_data,
1499 .write_nvram = qla25xx_write_nvram_data,
1500 .fw_dump = qla81xx_fw_dump,
1501 .beacon_on = qla24xx_beacon_on,
1502 .beacon_off = qla24xx_beacon_off,
1503 .beacon_blink = qla24xx_beacon_blink,
1504 .read_optrom = qla25xx_read_optrom_data,
1505 .write_optrom = qla24xx_write_optrom_data,
1506 .get_flash_version = qla24xx_get_flash_version,
1507 .start_scsi = qla24xx_start_scsi,
1508 .wrt_req_reg = qla24xx_wrt_req_reg,
1509 .wrt_rsp_reg = qla24xx_wrt_rsp_reg,
1510 .rd_req_reg = qla24xx_rd_req_reg,
1511};
1512
1491static inline void 1513static inline void
1492qla2x00_set_isp_flags(struct qla_hw_data *ha) 1514qla2x00_set_isp_flags(struct qla_hw_data *ha)
1493{ 1515{
@@ -1567,6 +1589,13 @@ qla2x00_set_isp_flags(struct qla_hw_data *ha)
1567 ha->device_type |= DT_IIDMA; 1589 ha->device_type |= DT_IIDMA;
1568 ha->fw_srisc_address = RISC_START_ADDRESS_2400; 1590 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
1569 break; 1591 break;
1592 case PCI_DEVICE_ID_QLOGIC_ISP8001:
1593 ha->device_type |= DT_ISP8001;
1594 ha->device_type |= DT_ZIO_SUPPORTED;
1595 ha->device_type |= DT_FWI2;
1596 ha->device_type |= DT_IIDMA;
1597 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
1598 break;
1570 } 1599 }
1571} 1600}
1572 1601
@@ -1629,7 +1658,7 @@ skip_pio:
1629 1658
1630 /* Determine queue resources */ 1659 /* Determine queue resources */
1631 ha->max_queues = 1; 1660 ha->max_queues = 1;
1632 if (ql2xmaxqueues <= 1 || !IS_QLA25XX(ha)) 1661 if (ql2xmaxqueues <= 1 || (!IS_QLA25XX(ha) && !IS_QLA81XX(ha)))
1633 goto mqiobase_exit; 1662 goto mqiobase_exit;
1634 ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3), 1663 ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3),
1635 pci_resource_len(ha->pdev, 3)); 1664 pci_resource_len(ha->pdev, 3));
@@ -1706,7 +1735,8 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1706 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8432 || 1735 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8432 ||
1707 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 || 1736 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 ||
1708 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 || 1737 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 ||
1709 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532) { 1738 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532 ||
1739 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8001) {
1710 bars = pci_select_bars(pdev, IORESOURCE_MEM); 1740 bars = pci_select_bars(pdev, IORESOURCE_MEM);
1711 sht = &qla24xx_driver_template; 1741 sht = &qla24xx_driver_template;
1712 mem_only = 1; 1742 mem_only = 1;
@@ -1760,6 +1790,10 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1760 rsp_length = RESPONSE_ENTRY_CNT_2100; 1790 rsp_length = RESPONSE_ENTRY_CNT_2100;
1761 ha->max_loop_id = SNS_LAST_LOOP_ID_2100; 1791 ha->max_loop_id = SNS_LAST_LOOP_ID_2100;
1762 ha->gid_list_info_size = 4; 1792 ha->gid_list_info_size = 4;
1793 ha->flash_conf_off = ~0;
1794 ha->flash_data_off = ~0;
1795 ha->nvram_conf_off = ~0;
1796 ha->nvram_data_off = ~0;
1763 ha->isp_ops = &qla2100_isp_ops; 1797 ha->isp_ops = &qla2100_isp_ops;
1764 } else if (IS_QLA2200(ha)) { 1798 } else if (IS_QLA2200(ha)) {
1765 ha->mbx_count = MAILBOX_REGISTER_COUNT; 1799 ha->mbx_count = MAILBOX_REGISTER_COUNT;
@@ -1767,6 +1801,10 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1767 rsp_length = RESPONSE_ENTRY_CNT_2100; 1801 rsp_length = RESPONSE_ENTRY_CNT_2100;
1768 ha->max_loop_id = SNS_LAST_LOOP_ID_2100; 1802 ha->max_loop_id = SNS_LAST_LOOP_ID_2100;
1769 ha->gid_list_info_size = 4; 1803 ha->gid_list_info_size = 4;
1804 ha->flash_conf_off = ~0;
1805 ha->flash_data_off = ~0;
1806 ha->nvram_conf_off = ~0;
1807 ha->nvram_data_off = ~0;
1770 ha->isp_ops = &qla2100_isp_ops; 1808 ha->isp_ops = &qla2100_isp_ops;
1771 } else if (IS_QLA23XX(ha)) { 1809 } else if (IS_QLA23XX(ha)) {
1772 ha->mbx_count = MAILBOX_REGISTER_COUNT; 1810 ha->mbx_count = MAILBOX_REGISTER_COUNT;
@@ -1776,6 +1814,10 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1776 ha->gid_list_info_size = 6; 1814 ha->gid_list_info_size = 6;
1777 if (IS_QLA2322(ha) || IS_QLA6322(ha)) 1815 if (IS_QLA2322(ha) || IS_QLA6322(ha))
1778 ha->optrom_size = OPTROM_SIZE_2322; 1816 ha->optrom_size = OPTROM_SIZE_2322;
1817 ha->flash_conf_off = ~0;
1818 ha->flash_data_off = ~0;
1819 ha->nvram_conf_off = ~0;
1820 ha->nvram_data_off = ~0;
1779 ha->isp_ops = &qla2300_isp_ops; 1821 ha->isp_ops = &qla2300_isp_ops;
1780 } else if (IS_QLA24XX_TYPE(ha)) { 1822 } else if (IS_QLA24XX_TYPE(ha)) {
1781 ha->mbx_count = MAILBOX_REGISTER_COUNT; 1823 ha->mbx_count = MAILBOX_REGISTER_COUNT;
@@ -1787,6 +1829,10 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1787 ha->optrom_size = OPTROM_SIZE_24XX; 1829 ha->optrom_size = OPTROM_SIZE_24XX;
1788 ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA24XX; 1830 ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA24XX;
1789 ha->isp_ops = &qla24xx_isp_ops; 1831 ha->isp_ops = &qla24xx_isp_ops;
1832 ha->flash_conf_off = FARX_ACCESS_FLASH_CONF;
1833 ha->flash_data_off = FARX_ACCESS_FLASH_DATA;
1834 ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF;
1835 ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA;
1790 } else if (IS_QLA25XX(ha)) { 1836 } else if (IS_QLA25XX(ha)) {
1791 ha->mbx_count = MAILBOX_REGISTER_COUNT; 1837 ha->mbx_count = MAILBOX_REGISTER_COUNT;
1792 req_length = REQUEST_ENTRY_CNT_24XX; 1838 req_length = REQUEST_ENTRY_CNT_24XX;
@@ -1797,6 +1843,23 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1797 ha->optrom_size = OPTROM_SIZE_25XX; 1843 ha->optrom_size = OPTROM_SIZE_25XX;
1798 ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; 1844 ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX;
1799 ha->isp_ops = &qla25xx_isp_ops; 1845 ha->isp_ops = &qla25xx_isp_ops;
1846 ha->flash_conf_off = FARX_ACCESS_FLASH_CONF;
1847 ha->flash_data_off = FARX_ACCESS_FLASH_DATA;
1848 ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF;
1849 ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA;
1850 } else if (IS_QLA81XX(ha)) {
1851 ha->mbx_count = MAILBOX_REGISTER_COUNT;
1852 req_length = REQUEST_ENTRY_CNT_24XX;
1853 rsp_length = RESPONSE_ENTRY_CNT_2300;
1854 ha->max_loop_id = SNS_LAST_LOOP_ID_2300;
1855 ha->init_cb_size = sizeof(struct mid_init_cb_81xx);
1856 ha->gid_list_info_size = 8;
1857 ha->optrom_size = OPTROM_SIZE_81XX;
1858 ha->isp_ops = &qla81xx_isp_ops;
1859 ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX;
1860 ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX;
1861 ha->nvram_conf_off = ~0;
1862 ha->nvram_data_off = ~0;
1800 } 1863 }
1801 1864
1802 mutex_init(&ha->vport_lock); 1865 mutex_init(&ha->vport_lock);
@@ -1935,7 +1998,6 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1935 return 0; 1998 return 0;
1936 1999
1937probe_failed: 2000probe_failed:
1938 qla2x00_free_que(ha, req, rsp);
1939 qla2x00_free_device(base_vha); 2001 qla2x00_free_device(base_vha);
1940 2002
1941 scsi_host_put(base_vha->host); 2003 scsi_host_put(base_vha->host);
@@ -2458,23 +2520,6 @@ qla2x00_post_aen_work(struct scsi_qla_host *vha, enum fc_host_event_code code,
2458 return qla2x00_post_work(vha, e, 1); 2520 return qla2x00_post_work(vha, e, 1);
2459} 2521}
2460 2522
2461int
2462qla2x00_post_hwe_work(struct scsi_qla_host *vha, uint16_t code, uint16_t d1,
2463 uint16_t d2, uint16_t d3)
2464{
2465 struct qla_work_evt *e;
2466
2467 e = qla2x00_alloc_work(vha, QLA_EVT_HWE_LOG, 1);
2468 if (!e)
2469 return QLA_FUNCTION_FAILED;
2470
2471 e->u.hwe.code = code;
2472 e->u.hwe.d1 = d1;
2473 e->u.hwe.d2 = d2;
2474 e->u.hwe.d3 = d3;
2475 return qla2x00_post_work(vha, e, 1);
2476}
2477
2478static void 2523static void
2479qla2x00_do_work(struct scsi_qla_host *vha) 2524qla2x00_do_work(struct scsi_qla_host *vha)
2480{ 2525{
@@ -2492,10 +2537,6 @@ qla2x00_do_work(struct scsi_qla_host *vha)
2492 fc_host_post_event(vha->host, fc_get_event_number(), 2537 fc_host_post_event(vha->host, fc_get_event_number(),
2493 e->u.aen.code, e->u.aen.data); 2538 e->u.aen.code, e->u.aen.data);
2494 break; 2539 break;
2495 case QLA_EVT_HWE_LOG:
2496 qla2xxx_hw_event_log(vha, e->u.hwe.code, e->u.hwe.d1,
2497 e->u.hwe.d2, e->u.hwe.d3);
2498 break;
2499 } 2540 }
2500 if (e->flags & QLA_EVT_FLAG_FREE) 2541 if (e->flags & QLA_EVT_FLAG_FREE)
2501 kfree(e); 2542 kfree(e);
@@ -2914,13 +2955,14 @@ qla2x00_timer(scsi_qla_host_t *vha)
2914 2955
2915/* Firmware interface routines. */ 2956/* Firmware interface routines. */
2916 2957
2917#define FW_BLOBS 6 2958#define FW_BLOBS 7
2918#define FW_ISP21XX 0 2959#define FW_ISP21XX 0
2919#define FW_ISP22XX 1 2960#define FW_ISP22XX 1
2920#define FW_ISP2300 2 2961#define FW_ISP2300 2
2921#define FW_ISP2322 3 2962#define FW_ISP2322 3
2922#define FW_ISP24XX 4 2963#define FW_ISP24XX 4
2923#define FW_ISP25XX 5 2964#define FW_ISP25XX 5
2965#define FW_ISP81XX 6
2924 2966
2925#define FW_FILE_ISP21XX "ql2100_fw.bin" 2967#define FW_FILE_ISP21XX "ql2100_fw.bin"
2926#define FW_FILE_ISP22XX "ql2200_fw.bin" 2968#define FW_FILE_ISP22XX "ql2200_fw.bin"
@@ -2928,6 +2970,7 @@ qla2x00_timer(scsi_qla_host_t *vha)
2928#define FW_FILE_ISP2322 "ql2322_fw.bin" 2970#define FW_FILE_ISP2322 "ql2322_fw.bin"
2929#define FW_FILE_ISP24XX "ql2400_fw.bin" 2971#define FW_FILE_ISP24XX "ql2400_fw.bin"
2930#define FW_FILE_ISP25XX "ql2500_fw.bin" 2972#define FW_FILE_ISP25XX "ql2500_fw.bin"
2973#define FW_FILE_ISP81XX "ql8100_fw.bin"
2931 2974
2932static DEFINE_MUTEX(qla_fw_lock); 2975static DEFINE_MUTEX(qla_fw_lock);
2933 2976
@@ -2938,6 +2981,7 @@ static struct fw_blob qla_fw_blobs[FW_BLOBS] = {
2938 { .name = FW_FILE_ISP2322, .segs = { 0x800, 0x1c000, 0x1e000, 0 }, }, 2981 { .name = FW_FILE_ISP2322, .segs = { 0x800, 0x1c000, 0x1e000, 0 }, },
2939 { .name = FW_FILE_ISP24XX, }, 2982 { .name = FW_FILE_ISP24XX, },
2940 { .name = FW_FILE_ISP25XX, }, 2983 { .name = FW_FILE_ISP25XX, },
2984 { .name = FW_FILE_ISP81XX, },
2941}; 2985};
2942 2986
2943struct fw_blob * 2987struct fw_blob *
@@ -2959,6 +3003,8 @@ qla2x00_request_firmware(scsi_qla_host_t *vha)
2959 blob = &qla_fw_blobs[FW_ISP24XX]; 3003 blob = &qla_fw_blobs[FW_ISP24XX];
2960 } else if (IS_QLA25XX(ha)) { 3004 } else if (IS_QLA25XX(ha)) {
2961 blob = &qla_fw_blobs[FW_ISP25XX]; 3005 blob = &qla_fw_blobs[FW_ISP25XX];
3006 } else if (IS_QLA81XX(ha)) {
3007 blob = &qla_fw_blobs[FW_ISP81XX];
2962 } 3008 }
2963 3009
2964 mutex_lock(&qla_fw_lock); 3010 mutex_lock(&qla_fw_lock);
@@ -3112,6 +3158,7 @@ static struct pci_device_id qla2xxx_pci_tbl[] = {
3112 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422) }, 3158 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422) },
3113 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) }, 3159 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) },
3114 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2532) }, 3160 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2532) },
3161 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8001) },
3115 { 0 }, 3162 { 0 },
3116}; 3163};
3117MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl); 3164MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl);
@@ -3200,3 +3247,4 @@ MODULE_FIRMWARE(FW_FILE_ISP2300);
3200MODULE_FIRMWARE(FW_FILE_ISP2322); 3247MODULE_FIRMWARE(FW_FILE_ISP2322);
3201MODULE_FIRMWARE(FW_FILE_ISP24XX); 3248MODULE_FIRMWARE(FW_FILE_ISP24XX);
3202MODULE_FIRMWARE(FW_FILE_ISP25XX); 3249MODULE_FIRMWARE(FW_FILE_ISP25XX);
3250MODULE_FIRMWARE(FW_FILE_ISP81XX);
diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c
index c538ee1b1a31..303f8ee11f25 100644
--- a/drivers/scsi/qla2xxx/qla_sup.c
+++ b/drivers/scsi/qla2xxx/qla_sup.c
@@ -425,27 +425,27 @@ qla2x00_set_nvram_protection(struct qla_hw_data *ha, int stat)
425#define OPTROM_BURST_DWORDS (OPTROM_BURST_SIZE / 4) 425#define OPTROM_BURST_DWORDS (OPTROM_BURST_SIZE / 4)
426 426
427static inline uint32_t 427static inline uint32_t
428flash_conf_to_access_addr(uint32_t faddr) 428flash_conf_addr(struct qla_hw_data *ha, uint32_t faddr)
429{ 429{
430 return FARX_ACCESS_FLASH_CONF | faddr; 430 return ha->flash_conf_off | faddr;
431} 431}
432 432
433static inline uint32_t 433static inline uint32_t
434flash_data_to_access_addr(uint32_t faddr) 434flash_data_addr(struct qla_hw_data *ha, uint32_t faddr)
435{ 435{
436 return FARX_ACCESS_FLASH_DATA | faddr; 436 return ha->flash_data_off | faddr;
437} 437}
438 438
439static inline uint32_t 439static inline uint32_t
440nvram_conf_to_access_addr(uint32_t naddr) 440nvram_conf_addr(struct qla_hw_data *ha, uint32_t naddr)
441{ 441{
442 return FARX_ACCESS_NVRAM_CONF | naddr; 442 return ha->nvram_conf_off | naddr;
443} 443}
444 444
445static inline uint32_t 445static inline uint32_t
446nvram_data_to_access_addr(uint32_t naddr) 446nvram_data_addr(struct qla_hw_data *ha, uint32_t naddr)
447{ 447{
448 return FARX_ACCESS_NVRAM_DATA | naddr; 448 return ha->nvram_data_off | naddr;
449} 449}
450 450
451static uint32_t 451static uint32_t
@@ -481,10 +481,12 @@ qla24xx_read_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr,
481 uint32_t dwords) 481 uint32_t dwords)
482{ 482{
483 uint32_t i; 483 uint32_t i;
484 struct qla_hw_data *ha = vha->hw;
485
484 /* Dword reads to flash. */ 486 /* Dword reads to flash. */
485 for (i = 0; i < dwords; i++, faddr++) 487 for (i = 0; i < dwords; i++, faddr++)
486 dwptr[i] = cpu_to_le32(qla24xx_read_flash_dword(vha->hw, 488 dwptr[i] = cpu_to_le32(qla24xx_read_flash_dword(ha,
487 flash_data_to_access_addr(faddr))); 489 flash_data_addr(ha, faddr)));
488 490
489 return dwptr; 491 return dwptr;
490} 492}
@@ -518,7 +520,7 @@ qla24xx_get_flash_manufacturer(struct qla_hw_data *ha, uint8_t *man_id,
518{ 520{
519 uint32_t ids; 521 uint32_t ids;
520 522
521 ids = qla24xx_read_flash_dword(ha, flash_data_to_access_addr(0xd03ab)); 523 ids = qla24xx_read_flash_dword(ha, flash_conf_addr(ha, 0x03ab));
522 *man_id = LSB(ids); 524 *man_id = LSB(ids);
523 *flash_id = MSB(ids); 525 *flash_id = MSB(ids);
524 526
@@ -530,8 +532,7 @@ qla24xx_get_flash_manufacturer(struct qla_hw_data *ha, uint8_t *man_id,
530 * Example: ATMEL 0x00 01 45 1F 532 * Example: ATMEL 0x00 01 45 1F
531 * Extract MFG and Dev ID from last two bytes. 533 * Extract MFG and Dev ID from last two bytes.
532 */ 534 */
533 ids = qla24xx_read_flash_dword(ha, 535 ids = qla24xx_read_flash_dword(ha, flash_conf_addr(ha, 0x009f));
534 flash_data_to_access_addr(0xd009f));
535 *man_id = LSB(ids); 536 *man_id = LSB(ids);
536 *flash_id = MSB(ids); 537 *flash_id = MSB(ids);
537 } 538 }
@@ -555,9 +556,13 @@ qla2xxx_find_flt_start(scsi_qla_host_t *vha, uint32_t *start)
555 556
556 /* Begin with sane defaults. */ 557 /* Begin with sane defaults. */
557 loc = locations[0]; 558 loc = locations[0];
558 *start = IS_QLA24XX_TYPE(ha) ? FA_FLASH_LAYOUT_ADDR_24: 559 *start = 0;
559 FA_FLASH_LAYOUT_ADDR; 560 if (IS_QLA24XX_TYPE(ha))
560 561 *start = FA_FLASH_LAYOUT_ADDR_24;
562 else if (IS_QLA25XX(ha))
563 *start = FA_FLASH_LAYOUT_ADDR;
564 else if (IS_QLA81XX(ha))
565 *start = FA_FLASH_LAYOUT_ADDR_81;
561 /* Begin with first PCI expansion ROM header. */ 566 /* Begin with first PCI expansion ROM header. */
562 buf = (uint8_t *)req->ring; 567 buf = (uint8_t *)req->ring;
563 dcode = (uint32_t *)req->ring; 568 dcode = (uint32_t *)req->ring;
@@ -618,6 +623,22 @@ static void
618qla2xxx_get_flt_info(scsi_qla_host_t *vha, uint32_t flt_addr) 623qla2xxx_get_flt_info(scsi_qla_host_t *vha, uint32_t flt_addr)
619{ 624{
620 const char *loc, *locations[] = { "DEF", "FLT" }; 625 const char *loc, *locations[] = { "DEF", "FLT" };
626 const uint32_t def_fw[] =
627 { FA_RISC_CODE_ADDR, FA_RISC_CODE_ADDR, FA_RISC_CODE_ADDR_81 };
628 const uint32_t def_boot[] =
629 { FA_BOOT_CODE_ADDR, FA_BOOT_CODE_ADDR, FA_BOOT_CODE_ADDR_81 };
630 const uint32_t def_vpd_nvram[] =
631 { FA_VPD_NVRAM_ADDR, FA_VPD_NVRAM_ADDR, FA_VPD_NVRAM_ADDR_81 };
632 const uint32_t def_fdt[] =
633 { FA_FLASH_DESCR_ADDR_24, FA_FLASH_DESCR_ADDR,
634 FA_FLASH_DESCR_ADDR_81 };
635 const uint32_t def_npiv_conf0[] =
636 { FA_NPIV_CONF0_ADDR_24, FA_NPIV_CONF0_ADDR,
637 FA_NPIV_CONF0_ADDR_81 };
638 const uint32_t def_npiv_conf1[] =
639 { FA_NPIV_CONF1_ADDR_24, FA_NPIV_CONF1_ADDR,
640 FA_NPIV_CONF1_ADDR_81 };
641 uint32_t def;
621 uint16_t *wptr; 642 uint16_t *wptr;
622 uint16_t cnt, chksum; 643 uint16_t cnt, chksum;
623 uint32_t start; 644 uint32_t start;
@@ -676,20 +697,12 @@ qla2xxx_get_flt_info(scsi_qla_host_t *vha, uint32_t flt_addr)
676 case FLT_REG_FDT: 697 case FLT_REG_FDT:
677 ha->flt_region_fdt = start; 698 ha->flt_region_fdt = start;
678 break; 699 break;
679 case FLT_REG_HW_EVENT_0:
680 if (!PCI_FUNC(ha->pdev->devfn))
681 ha->flt_region_hw_event = start;
682 break;
683 case FLT_REG_HW_EVENT_1:
684 if (PCI_FUNC(ha->pdev->devfn))
685 ha->flt_region_hw_event = start;
686 break;
687 case FLT_REG_NPIV_CONF_0: 700 case FLT_REG_NPIV_CONF_0:
688 if (!PCI_FUNC(ha->pdev->devfn)) 701 if (!(PCI_FUNC(ha->pdev->devfn) & 1))
689 ha->flt_region_npiv_conf = start; 702 ha->flt_region_npiv_conf = start;
690 break; 703 break;
691 case FLT_REG_NPIV_CONF_1: 704 case FLT_REG_NPIV_CONF_1:
692 if (PCI_FUNC(ha->pdev->devfn)) 705 if (PCI_FUNC(ha->pdev->devfn) & 1)
693 ha->flt_region_npiv_conf = start; 706 ha->flt_region_npiv_conf = start;
694 break; 707 break;
695 } 708 }
@@ -699,22 +712,24 @@ qla2xxx_get_flt_info(scsi_qla_host_t *vha, uint32_t flt_addr)
699no_flash_data: 712no_flash_data:
700 /* Use hardcoded defaults. */ 713 /* Use hardcoded defaults. */
701 loc = locations[0]; 714 loc = locations[0];
702 ha->flt_region_fw = FA_RISC_CODE_ADDR; 715 def = 0;
703 ha->flt_region_boot = FA_BOOT_CODE_ADDR; 716 if (IS_QLA24XX_TYPE(ha))
704 ha->flt_region_vpd_nvram = FA_VPD_NVRAM_ADDR; 717 def = 0;
705 ha->flt_region_fdt = IS_QLA24XX_TYPE(ha) ? FA_FLASH_DESCR_ADDR_24: 718 else if (IS_QLA25XX(ha))
706 FA_FLASH_DESCR_ADDR; 719 def = 1;
707 ha->flt_region_hw_event = !PCI_FUNC(ha->pdev->devfn) ? 720 else if (IS_QLA81XX(ha))
708 FA_HW_EVENT0_ADDR: FA_HW_EVENT1_ADDR; 721 def = 2;
709 ha->flt_region_npiv_conf = !PCI_FUNC(ha->pdev->devfn) ? 722 ha->flt_region_fw = def_fw[def];
710 (IS_QLA24XX_TYPE(ha) ? FA_NPIV_CONF0_ADDR_24: FA_NPIV_CONF0_ADDR): 723 ha->flt_region_boot = def_boot[def];
711 (IS_QLA24XX_TYPE(ha) ? FA_NPIV_CONF1_ADDR_24: FA_NPIV_CONF1_ADDR); 724 ha->flt_region_vpd_nvram = def_vpd_nvram[def];
725 ha->flt_region_fdt = def_fdt[def];
726 ha->flt_region_npiv_conf = !(PCI_FUNC(ha->pdev->devfn) & 1) ?
727 def_npiv_conf0[def]: def_npiv_conf1[def];
712done: 728done:
713 DEBUG2(qla_printk(KERN_DEBUG, ha, "FLT[%s]: boot=0x%x fw=0x%x " 729 DEBUG2(qla_printk(KERN_DEBUG, ha, "FLT[%s]: boot=0x%x fw=0x%x "
714 "vpd_nvram=0x%x fdt=0x%x flt=0x%x hwe=0x%x npiv=0x%x.\n", loc, 730 "vpd_nvram=0x%x fdt=0x%x flt=0x%x npiv=0x%x.\n", loc,
715 ha->flt_region_boot, ha->flt_region_fw, ha->flt_region_vpd_nvram, 731 ha->flt_region_boot, ha->flt_region_fw, ha->flt_region_vpd_nvram,
716 ha->flt_region_fdt, ha->flt_region_flt, ha->flt_region_hw_event, 732 ha->flt_region_fdt, ha->flt_region_flt, ha->flt_region_npiv_conf));
717 ha->flt_region_npiv_conf));
718} 733}
719 734
720static void 735static void
@@ -757,14 +772,14 @@ qla2xxx_get_fdt_info(scsi_qla_host_t *vha)
757 mid = le16_to_cpu(fdt->man_id); 772 mid = le16_to_cpu(fdt->man_id);
758 fid = le16_to_cpu(fdt->id); 773 fid = le16_to_cpu(fdt->id);
759 ha->fdt_wrt_disable = fdt->wrt_disable_bits; 774 ha->fdt_wrt_disable = fdt->wrt_disable_bits;
760 ha->fdt_erase_cmd = flash_conf_to_access_addr(0x0300 | fdt->erase_cmd); 775 ha->fdt_erase_cmd = flash_conf_addr(ha, 0x0300 | fdt->erase_cmd);
761 ha->fdt_block_size = le32_to_cpu(fdt->block_size); 776 ha->fdt_block_size = le32_to_cpu(fdt->block_size);
762 if (fdt->unprotect_sec_cmd) { 777 if (fdt->unprotect_sec_cmd) {
763 ha->fdt_unprotect_sec_cmd = flash_conf_to_access_addr(0x0300 | 778 ha->fdt_unprotect_sec_cmd = flash_conf_addr(ha, 0x0300 |
764 fdt->unprotect_sec_cmd); 779 fdt->unprotect_sec_cmd);
765 ha->fdt_protect_sec_cmd = fdt->protect_sec_cmd ? 780 ha->fdt_protect_sec_cmd = fdt->protect_sec_cmd ?
766 flash_conf_to_access_addr(0x0300 | fdt->protect_sec_cmd): 781 flash_conf_addr(ha, 0x0300 | fdt->protect_sec_cmd):
767 flash_conf_to_access_addr(0x0336); 782 flash_conf_addr(ha, 0x0336);
768 } 783 }
769 goto done; 784 goto done;
770no_flash_data: 785no_flash_data:
@@ -773,7 +788,7 @@ no_flash_data:
773 mid = man_id; 788 mid = man_id;
774 fid = flash_id; 789 fid = flash_id;
775 ha->fdt_wrt_disable = 0x9c; 790 ha->fdt_wrt_disable = 0x9c;
776 ha->fdt_erase_cmd = flash_conf_to_access_addr(0x03d8); 791 ha->fdt_erase_cmd = flash_conf_addr(ha, 0x03d8);
777 switch (man_id) { 792 switch (man_id) {
778 case 0xbf: /* STT flash. */ 793 case 0xbf: /* STT flash. */
779 if (flash_id == 0x8e) 794 if (flash_id == 0x8e)
@@ -782,16 +797,16 @@ no_flash_data:
782 ha->fdt_block_size = FLASH_BLK_SIZE_32K; 797 ha->fdt_block_size = FLASH_BLK_SIZE_32K;
783 798
784 if (flash_id == 0x80) 799 if (flash_id == 0x80)
785 ha->fdt_erase_cmd = flash_conf_to_access_addr(0x0352); 800 ha->fdt_erase_cmd = flash_conf_addr(ha, 0x0352);
786 break; 801 break;
787 case 0x13: /* ST M25P80. */ 802 case 0x13: /* ST M25P80. */
788 ha->fdt_block_size = FLASH_BLK_SIZE_64K; 803 ha->fdt_block_size = FLASH_BLK_SIZE_64K;
789 break; 804 break;
790 case 0x1f: /* Atmel 26DF081A. */ 805 case 0x1f: /* Atmel 26DF081A. */
791 ha->fdt_block_size = FLASH_BLK_SIZE_4K; 806 ha->fdt_block_size = FLASH_BLK_SIZE_4K;
792 ha->fdt_erase_cmd = flash_conf_to_access_addr(0x0320); 807 ha->fdt_erase_cmd = flash_conf_addr(ha, 0x0320);
793 ha->fdt_unprotect_sec_cmd = flash_conf_to_access_addr(0x0339); 808 ha->fdt_unprotect_sec_cmd = flash_conf_addr(ha, 0x0339);
794 ha->fdt_protect_sec_cmd = flash_conf_to_access_addr(0x0336); 809 ha->fdt_protect_sec_cmd = flash_conf_addr(ha, 0x0336);
795 break; 810 break;
796 default: 811 default:
797 /* Default to 64 kb sector size. */ 812 /* Default to 64 kb sector size. */
@@ -813,7 +828,7 @@ qla2xxx_get_flash_info(scsi_qla_host_t *vha)
813 uint32_t flt_addr; 828 uint32_t flt_addr;
814 struct qla_hw_data *ha = vha->hw; 829 struct qla_hw_data *ha = vha->hw;
815 830
816 if (!IS_QLA24XX_TYPE(ha) && !IS_QLA25XX(ha)) 831 if (!IS_QLA24XX_TYPE(ha) && !IS_QLA25XX(ha) && !IS_QLA81XX(ha))
817 return QLA_SUCCESS; 832 return QLA_SUCCESS;
818 833
819 ret = qla2xxx_find_flt_start(vha, &flt_addr); 834 ret = qla2xxx_find_flt_start(vha, &flt_addr);
@@ -838,7 +853,7 @@ qla2xxx_flash_npiv_conf(scsi_qla_host_t *vha)
838 struct qla_npiv_entry *entry; 853 struct qla_npiv_entry *entry;
839 struct qla_hw_data *ha = vha->hw; 854 struct qla_hw_data *ha = vha->hw;
840 855
841 if (!IS_QLA24XX_TYPE(ha) && !IS_QLA25XX(ha)) 856 if (!IS_QLA24XX_TYPE(ha) && !IS_QLA25XX(ha) && !IS_QLA81XX(ha))
842 return; 857 return;
843 858
844 ha->isp_ops->read_optrom(vha, (uint8_t *)&hdr, 859 ha->isp_ops->read_optrom(vha, (uint8_t *)&hdr,
@@ -930,9 +945,9 @@ qla24xx_unprotect_flash(struct qla_hw_data *ha)
930 return; 945 return;
931 946
932 /* Disable flash write-protection. */ 947 /* Disable flash write-protection. */
933 qla24xx_write_flash_dword(ha, flash_conf_to_access_addr(0x101), 0); 948 qla24xx_write_flash_dword(ha, flash_conf_addr(ha, 0x101), 0);
934 /* Some flash parts need an additional zero-write to clear bits.*/ 949 /* Some flash parts need an additional zero-write to clear bits.*/
935 qla24xx_write_flash_dword(ha, flash_conf_to_access_addr(0x101), 0); 950 qla24xx_write_flash_dword(ha, flash_conf_addr(ha, 0x101), 0);
936} 951}
937 952
938static void 953static void
@@ -945,11 +960,10 @@ qla24xx_protect_flash(struct qla_hw_data *ha)
945 goto skip_wrt_protect; 960 goto skip_wrt_protect;
946 961
947 /* Enable flash write-protection and wait for completion. */ 962 /* Enable flash write-protection and wait for completion. */
948 qla24xx_write_flash_dword(ha, flash_conf_to_access_addr(0x101), 963 qla24xx_write_flash_dword(ha, flash_conf_addr(ha, 0x101),
949 ha->fdt_wrt_disable); 964 ha->fdt_wrt_disable);
950 for (cnt = 300; cnt && 965 for (cnt = 300; cnt &&
951 qla24xx_read_flash_dword(ha, 966 qla24xx_read_flash_dword(ha, flash_conf_addr(ha, 0x005)) & BIT_0;
952 flash_conf_to_access_addr(0x005)) & BIT_0;
953 cnt--) { 967 cnt--) {
954 udelay(10); 968 udelay(10);
955 } 969 }
@@ -977,7 +991,7 @@ qla24xx_write_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr,
977 ret = QLA_SUCCESS; 991 ret = QLA_SUCCESS;
978 992
979 /* Prepare burst-capable write on supported ISPs. */ 993 /* Prepare burst-capable write on supported ISPs. */
980 if (IS_QLA25XX(ha) && !(faddr & 0xfff) && 994 if ((IS_QLA25XX(ha) || IS_QLA81XX(ha)) && !(faddr & 0xfff) &&
981 dwords > OPTROM_BURST_DWORDS) { 995 dwords > OPTROM_BURST_DWORDS) {
982 optrom = dma_alloc_coherent(&ha->pdev->dev, OPTROM_BURST_SIZE, 996 optrom = dma_alloc_coherent(&ha->pdev->dev, OPTROM_BURST_SIZE,
983 &optrom_dma, GFP_KERNEL); 997 &optrom_dma, GFP_KERNEL);
@@ -989,7 +1003,7 @@ qla24xx_write_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr,
989 } 1003 }
990 1004
991 rest_addr = (ha->fdt_block_size >> 2) - 1; 1005 rest_addr = (ha->fdt_block_size >> 2) - 1;
992 sec_mask = 0x80000 - (ha->fdt_block_size >> 2); 1006 sec_mask = (ha->optrom_size >> 2) - (ha->fdt_block_size >> 2);
993 1007
994 qla24xx_unprotect_flash(ha); 1008 qla24xx_unprotect_flash(ha);
995 1009
@@ -1024,13 +1038,13 @@ qla24xx_write_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr,
1024 *s = cpu_to_le32(*d); 1038 *s = cpu_to_le32(*d);
1025 1039
1026 ret = qla2x00_load_ram(vha, optrom_dma, 1040 ret = qla2x00_load_ram(vha, optrom_dma,
1027 flash_data_to_access_addr(faddr), 1041 flash_data_addr(ha, faddr),
1028 OPTROM_BURST_DWORDS); 1042 OPTROM_BURST_DWORDS);
1029 if (ret != QLA_SUCCESS) { 1043 if (ret != QLA_SUCCESS) {
1030 qla_printk(KERN_WARNING, ha, 1044 qla_printk(KERN_WARNING, ha,
1031 "Unable to burst-write optrom segment " 1045 "Unable to burst-write optrom segment "
1032 "(%x/%x/%llx).\n", ret, 1046 "(%x/%x/%llx).\n", ret,
1033 flash_data_to_access_addr(faddr), 1047 flash_data_addr(ha, faddr),
1034 (unsigned long long)optrom_dma); 1048 (unsigned long long)optrom_dma);
1035 qla_printk(KERN_WARNING, ha, 1049 qla_printk(KERN_WARNING, ha,
1036 "Reverting to slow-write.\n"); 1050 "Reverting to slow-write.\n");
@@ -1047,7 +1061,7 @@ qla24xx_write_flash_data(scsi_qla_host_t *vha, uint32_t *dwptr, uint32_t faddr,
1047 } 1061 }
1048 1062
1049 ret = qla24xx_write_flash_dword(ha, 1063 ret = qla24xx_write_flash_dword(ha,
1050 flash_data_to_access_addr(faddr), cpu_to_le32(*dwptr)); 1064 flash_data_addr(ha, faddr), cpu_to_le32(*dwptr));
1051 if (ret != QLA_SUCCESS) { 1065 if (ret != QLA_SUCCESS) {
1052 DEBUG9(printk("%s(%ld) Unable to program flash " 1066 DEBUG9(printk("%s(%ld) Unable to program flash "
1053 "address=%x data=%x.\n", __func__, 1067 "address=%x data=%x.\n", __func__,
@@ -1098,12 +1112,13 @@ qla24xx_read_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr,
1098{ 1112{
1099 uint32_t i; 1113 uint32_t i;
1100 uint32_t *dwptr; 1114 uint32_t *dwptr;
1115 struct qla_hw_data *ha = vha->hw;
1101 1116
1102 /* Dword reads to flash. */ 1117 /* Dword reads to flash. */
1103 dwptr = (uint32_t *)buf; 1118 dwptr = (uint32_t *)buf;
1104 for (i = 0; i < bytes >> 2; i++, naddr++) 1119 for (i = 0; i < bytes >> 2; i++, naddr++)
1105 dwptr[i] = cpu_to_le32(qla24xx_read_flash_dword(vha->hw, 1120 dwptr[i] = cpu_to_le32(qla24xx_read_flash_dword(ha,
1106 nvram_data_to_access_addr(naddr))); 1121 nvram_data_addr(ha, naddr)));
1107 1122
1108 return buf; 1123 return buf;
1109} 1124}
@@ -1160,17 +1175,14 @@ qla24xx_write_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr,
1160 RD_REG_DWORD(&reg->ctrl_status); /* PCI Posting. */ 1175 RD_REG_DWORD(&reg->ctrl_status); /* PCI Posting. */
1161 1176
1162 /* Disable NVRAM write-protection. */ 1177 /* Disable NVRAM write-protection. */
1163 qla24xx_write_flash_dword(ha, nvram_conf_to_access_addr(0x101), 1178 qla24xx_write_flash_dword(ha, nvram_conf_addr(ha, 0x101), 0);
1164 0); 1179 qla24xx_write_flash_dword(ha, nvram_conf_addr(ha, 0x101), 0);
1165 qla24xx_write_flash_dword(ha, nvram_conf_to_access_addr(0x101),
1166 0);
1167 1180
1168 /* Dword writes to flash. */ 1181 /* Dword writes to flash. */
1169 dwptr = (uint32_t *)buf; 1182 dwptr = (uint32_t *)buf;
1170 for (i = 0; i < bytes >> 2; i++, naddr++, dwptr++) { 1183 for (i = 0; i < bytes >> 2; i++, naddr++, dwptr++) {
1171 ret = qla24xx_write_flash_dword(ha, 1184 ret = qla24xx_write_flash_dword(ha,
1172 nvram_data_to_access_addr(naddr), 1185 nvram_data_addr(ha, naddr), cpu_to_le32(*dwptr));
1173 cpu_to_le32(*dwptr));
1174 if (ret != QLA_SUCCESS) { 1186 if (ret != QLA_SUCCESS) {
1175 DEBUG9(qla_printk("Unable to program nvram address=%x " 1187 DEBUG9(qla_printk("Unable to program nvram address=%x "
1176 "data=%x.\n", naddr, *dwptr)); 1188 "data=%x.\n", naddr, *dwptr));
@@ -1179,8 +1191,7 @@ qla24xx_write_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr,
1179 } 1191 }
1180 1192
1181 /* Enable NVRAM write-protection. */ 1193 /* Enable NVRAM write-protection. */
1182 qla24xx_write_flash_dword(ha, nvram_conf_to_access_addr(0x101), 1194 qla24xx_write_flash_dword(ha, nvram_conf_addr(ha, 0x101), 0x8c);
1183 0x8c);
1184 1195
1185 /* Disable flash write. */ 1196 /* Disable flash write. */
1186 WRT_REG_DWORD(&reg->ctrl_status, 1197 WRT_REG_DWORD(&reg->ctrl_status,
@@ -1202,8 +1213,7 @@ qla25xx_read_nvram_data(scsi_qla_host_t *vha, uint8_t *buf, uint32_t naddr,
1202 dwptr = (uint32_t *)buf; 1213 dwptr = (uint32_t *)buf;
1203 for (i = 0; i < bytes >> 2; i++, naddr++) 1214 for (i = 0; i < bytes >> 2; i++, naddr++)
1204 dwptr[i] = cpu_to_le32(qla24xx_read_flash_dword(ha, 1215 dwptr[i] = cpu_to_le32(qla24xx_read_flash_dword(ha,
1205 flash_data_to_access_addr(ha->flt_region_vpd_nvram | 1216 flash_data_addr(ha, ha->flt_region_vpd_nvram | naddr)));
1206 naddr)));
1207 1217
1208 return buf; 1218 return buf;
1209} 1219}
@@ -2246,12 +2256,12 @@ qla25xx_read_optrom_data(struct scsi_qla_host *vha, uint8_t *buf,
2246 burst = left; 2256 burst = left;
2247 2257
2248 rval = qla2x00_dump_ram(vha, optrom_dma, 2258 rval = qla2x00_dump_ram(vha, optrom_dma,
2249 flash_data_to_access_addr(faddr), burst); 2259 flash_data_addr(ha, faddr), burst);
2250 if (rval) { 2260 if (rval) {
2251 qla_printk(KERN_WARNING, ha, 2261 qla_printk(KERN_WARNING, ha,
2252 "Unable to burst-read optrom segment " 2262 "Unable to burst-read optrom segment "
2253 "(%x/%x/%llx).\n", rval, 2263 "(%x/%x/%llx).\n", rval,
2254 flash_data_to_access_addr(faddr), 2264 flash_data_addr(ha, faddr),
2255 (unsigned long long)optrom_dma); 2265 (unsigned long long)optrom_dma);
2256 qla_printk(KERN_WARNING, ha, 2266 qla_printk(KERN_WARNING, ha,
2257 "Reverting to slow-read.\n"); 2267 "Reverting to slow-read.\n");
@@ -2648,108 +2658,3 @@ qla2xxx_get_vpd_field(scsi_qla_host_t *vha, char *key, char *str, size_t size)
2648 2658
2649 return 0; 2659 return 0;
2650} 2660}
2651
2652static int
2653qla2xxx_hw_event_store(scsi_qla_host_t *vha, uint32_t *fdata)
2654{
2655 uint32_t d[2], faddr;
2656 struct qla_hw_data *ha = vha->hw;
2657
2658 /* Locate first empty entry. */
2659 for (;;) {
2660 if (ha->hw_event_ptr >=
2661 ha->flt_region_hw_event + FA_HW_EVENT_SIZE) {
2662 DEBUG2(qla_printk(KERN_WARNING, ha,
2663 "HW event -- Log Full!\n"));
2664 return QLA_MEMORY_ALLOC_FAILED;
2665 }
2666
2667 qla24xx_read_flash_data(vha, d, ha->hw_event_ptr, 2);
2668 faddr = flash_data_to_access_addr(ha->hw_event_ptr);
2669 ha->hw_event_ptr += FA_HW_EVENT_ENTRY_SIZE;
2670 if (d[0] == __constant_cpu_to_le32(0xffffffff) &&
2671 d[1] == __constant_cpu_to_le32(0xffffffff)) {
2672 qla24xx_unprotect_flash(ha);
2673
2674 qla24xx_write_flash_dword(ha, faddr++,
2675 cpu_to_le32(jiffies));
2676 qla24xx_write_flash_dword(ha, faddr++, 0);
2677 qla24xx_write_flash_dword(ha, faddr++, *fdata++);
2678 qla24xx_write_flash_dword(ha, faddr++, *fdata);
2679
2680 qla24xx_protect_flash(ha);
2681 break;
2682 }
2683 }
2684 return QLA_SUCCESS;
2685}
2686
2687int
2688qla2xxx_hw_event_log(scsi_qla_host_t *vha, uint16_t code, uint16_t d1,
2689 uint16_t d2, uint16_t d3)
2690{
2691#define QMARK(a, b, c, d) \
2692 cpu_to_le32(LSB(a) << 24 | LSB(b) << 16 | LSB(c) << 8 | LSB(d))
2693 struct qla_hw_data *ha = vha->hw;
2694 int rval;
2695 uint32_t marker[2], fdata[4];
2696
2697 if (ha->flt_region_hw_event == 0)
2698 return QLA_FUNCTION_FAILED;
2699
2700 DEBUG2(qla_printk(KERN_WARNING, ha,
2701 "HW event -- code=%x, d1=%x, d2=%x, d3=%x.\n", code, d1, d2, d3));
2702
2703 /* If marker not already found, locate or write. */
2704 if (!ha->flags.hw_event_marker_found) {
2705 /* Create marker. */
2706 marker[0] = QMARK('L', ha->fw_major_version,
2707 ha->fw_minor_version, ha->fw_subminor_version);
2708 marker[1] = QMARK(QLA_DRIVER_MAJOR_VER, QLA_DRIVER_MINOR_VER,
2709 QLA_DRIVER_PATCH_VER, QLA_DRIVER_BETA_VER);
2710
2711 /* Locate marker. */
2712 ha->hw_event_ptr = ha->flt_region_hw_event;
2713 for (;;) {
2714 qla24xx_read_flash_data(vha, fdata, ha->hw_event_ptr,
2715 4);
2716 if (fdata[0] == __constant_cpu_to_le32(0xffffffff) &&
2717 fdata[1] == __constant_cpu_to_le32(0xffffffff))
2718 break;
2719 ha->hw_event_ptr += FA_HW_EVENT_ENTRY_SIZE;
2720 if (ha->hw_event_ptr >=
2721 ha->flt_region_hw_event + FA_HW_EVENT_SIZE) {
2722 DEBUG2(qla_printk(KERN_WARNING, ha,
2723 "HW event -- Log Full!\n"));
2724 return QLA_MEMORY_ALLOC_FAILED;
2725 }
2726 if (fdata[2] == marker[0] && fdata[3] == marker[1]) {
2727 ha->flags.hw_event_marker_found = 1;
2728 break;
2729 }
2730 }
2731 /* No marker, write it. */
2732 if (!ha->flags.hw_event_marker_found) {
2733 rval = qla2xxx_hw_event_store(vha, marker);
2734 if (rval != QLA_SUCCESS) {
2735 DEBUG2(qla_printk(KERN_WARNING, ha,
2736 "HW event -- Failed marker write=%x.!\n",
2737 rval));
2738 return rval;
2739 }
2740 ha->flags.hw_event_marker_found = 1;
2741 }
2742 }
2743
2744 /* Store error. */
2745 fdata[0] = cpu_to_le32(code << 16 | d1);
2746 fdata[1] = cpu_to_le32(d2 << 16 | d3);
2747 rval = qla2xxx_hw_event_store(vha, fdata);
2748 if (rval != QLA_SUCCESS) {
2749 DEBUG2(qla_printk(KERN_WARNING, ha,
2750 "HW event -- Failed error write=%x.!\n",
2751 rval));
2752 }
2753
2754 return rval;
2755}
diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h
index be22f3a09f8d..808bab6ef06b 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,9 +7,9 @@
7/* 7/*
8 * Driver version 8 * Driver version
9 */ 9 */
10#define QLA2XXX_VERSION "8.02.03-k1" 10#define QLA2XXX_VERSION "8.03.00-k1"
11 11
12#define QLA_DRIVER_MAJOR_VER 8 12#define QLA_DRIVER_MAJOR_VER 8
13#define QLA_DRIVER_MINOR_VER 2 13#define QLA_DRIVER_MINOR_VER 3
14#define QLA_DRIVER_PATCH_VER 3 14#define QLA_DRIVER_PATCH_VER 0
15#define QLA_DRIVER_BETA_VER 0 15#define QLA_DRIVER_BETA_VER 0
diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index c577d79bd7e8..051b0f5e8c8e 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -392,7 +392,7 @@ int qla4xxx_get_firmware_status(struct scsi_qla_host * ha)
392 ha->iocb_hiwat -= IOCB_HIWAT_CUSHION; 392 ha->iocb_hiwat -= IOCB_HIWAT_CUSHION;
393 else 393 else
394 dev_info(&ha->pdev->dev, "WARNING!!! You have less than %d " 394 dev_info(&ha->pdev->dev, "WARNING!!! You have less than %d "
395 "firmare IOCBs available (%d).\n", 395 "firmware IOCBs available (%d).\n",
396 IOCB_HIWAT_CUSHION, ha->iocb_hiwat); 396 IOCB_HIWAT_CUSHION, ha->iocb_hiwat);
397 397
398 return QLA_SUCCESS; 398 return QLA_SUCCESS;
diff --git a/drivers/scsi/raid_class.c b/drivers/scsi/raid_class.c
index 913a931176ef..8e5c169b03fb 100644
--- a/drivers/scsi/raid_class.c
+++ b/drivers/scsi/raid_class.c
@@ -237,8 +237,7 @@ int raid_component_add(struct raid_template *r,struct device *raid_dev,
237 rc->dev.parent = get_device(component_dev); 237 rc->dev.parent = get_device(component_dev);
238 rc->num = rd->component_count++; 238 rc->num = rd->component_count++;
239 239
240 snprintf(rc->dev.bus_id, sizeof(rc->dev.bus_id), 240 dev_set_name(&rc->dev, "component-%d", rc->num);
241 "component-%d", rc->num);
242 list_add_tail(&rc->node, &rd->component_list); 241 list_add_tail(&rc->node, &rd->component_list);
243 rc->dev.class = &raid_class.class; 242 rc->dev.class = &raid_class.class;
244 err = device_add(&rc->dev); 243 err = device_add(&rc->dev);
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index f8b79d401d58..cbcd3f681b62 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -651,10 +651,6 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
651 unsigned long timeout; 651 unsigned long timeout;
652 int rtn = 0; 652 int rtn = 0;
653 653
654 /*
655 * We will use a queued command if possible, otherwise we will
656 * emulate the queuing and calling of completion function ourselves.
657 */
658 atomic_inc(&cmd->device->iorequest_cnt); 654 atomic_inc(&cmd->device->iorequest_cnt);
659 655
660 /* check if the device is still usable */ 656 /* check if the device is still usable */
@@ -1099,7 +1095,8 @@ EXPORT_SYMBOL(__starget_for_each_device);
1099 * Description: Looks up the scsi_device with the specified @lun for a given 1095 * Description: Looks up the scsi_device with the specified @lun for a given
1100 * @starget. The returned scsi_device does not have an additional 1096 * @starget. The returned scsi_device does not have an additional
1101 * reference. You must hold the host's host_lock over this call and 1097 * reference. You must hold the host's host_lock over this call and
1102 * any access to the returned scsi_device. 1098 * any access to the returned scsi_device. A scsi_device in state
1099 * SDEV_DEL is skipped.
1103 * 1100 *
1104 * Note: The only reason why drivers should use this is because 1101 * Note: The only reason why drivers should use this is because
1105 * they need to access the device list in irq context. Otherwise you 1102 * they need to access the device list in irq context. Otherwise you
@@ -1111,6 +1108,8 @@ struct scsi_device *__scsi_device_lookup_by_target(struct scsi_target *starget,
1111 struct scsi_device *sdev; 1108 struct scsi_device *sdev;
1112 1109
1113 list_for_each_entry(sdev, &starget->devices, same_target_siblings) { 1110 list_for_each_entry(sdev, &starget->devices, same_target_siblings) {
1111 if (sdev->sdev_state == SDEV_DEL)
1112 continue;
1114 if (sdev->lun ==lun) 1113 if (sdev->lun ==lun)
1115 return sdev; 1114 return sdev;
1116 } 1115 }
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 27c633f55794..6eebd0bbe8a8 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -2508,7 +2508,7 @@ static void pseudo_0_release(struct device *dev)
2508} 2508}
2509 2509
2510static struct device pseudo_primary = { 2510static struct device pseudo_primary = {
2511 .bus_id = "pseudo_0", 2511 .init_name = "pseudo_0",
2512 .release = pseudo_0_release, 2512 .release = pseudo_0_release,
2513}; 2513};
2514 2514
@@ -2680,7 +2680,7 @@ static int sdebug_add_adapter(void)
2680 sdbg_host->dev.bus = &pseudo_lld_bus; 2680 sdbg_host->dev.bus = &pseudo_lld_bus;
2681 sdbg_host->dev.parent = &pseudo_primary; 2681 sdbg_host->dev.parent = &pseudo_primary;
2682 sdbg_host->dev.release = &sdebug_release_adapter; 2682 sdbg_host->dev.release = &sdebug_release_adapter;
2683 sprintf(sdbg_host->dev.bus_id, "adapter%d", scsi_debug_add_host); 2683 dev_set_name(&sdbg_host->dev, "adapter%d", scsi_debug_add_host);
2684 2684
2685 error = device_register(&sdbg_host->dev); 2685 error = device_register(&sdbg_host->dev);
2686 2686
diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
index 4969e4ec75ea..099b5455bbce 100644
--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -224,6 +224,7 @@ static struct {
224 {"SGI", "TP9100", "*", BLIST_REPORTLUN2}, 224 {"SGI", "TP9100", "*", BLIST_REPORTLUN2},
225 {"SGI", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, 225 {"SGI", "Universal Xport", "*", BLIST_NO_ULD_ATTACH},
226 {"IBM", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, 226 {"IBM", "Universal Xport", "*", BLIST_NO_ULD_ATTACH},
227 {"SUN", "Universal Xport", "*", BLIST_NO_ULD_ATTACH},
227 {"SMSC", "USB 2 HS-CF", NULL, BLIST_SPARSELUN | BLIST_INQUIRY_36}, 228 {"SMSC", "USB 2 HS-CF", NULL, BLIST_SPARSELUN | BLIST_INQUIRY_36},
228 {"SONY", "CD-ROM CDU-8001", NULL, BLIST_BORKEN}, 229 {"SONY", "CD-ROM CDU-8001", NULL, BLIST_BORKEN},
229 {"SONY", "TSL", NULL, BLIST_FORCELUN}, /* DDS3 & DDS4 autoloaders */ 230 {"SONY", "TSL", NULL, BLIST_FORCELUN}, /* DDS3 & DDS4 autoloaders */
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 381838ebd460..ad6a1370761e 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -124,34 +124,22 @@ int scsi_eh_scmd_add(struct scsi_cmnd *scmd, int eh_flag)
124enum blk_eh_timer_return scsi_times_out(struct request *req) 124enum blk_eh_timer_return scsi_times_out(struct request *req)
125{ 125{
126 struct scsi_cmnd *scmd = req->special; 126 struct scsi_cmnd *scmd = req->special;
127 enum blk_eh_timer_return (*eh_timed_out)(struct scsi_cmnd *);
128 enum blk_eh_timer_return rtn = BLK_EH_NOT_HANDLED; 127 enum blk_eh_timer_return rtn = BLK_EH_NOT_HANDLED;
129 128
130 scsi_log_completion(scmd, TIMEOUT_ERROR); 129 scsi_log_completion(scmd, TIMEOUT_ERROR);
131 130
132 if (scmd->device->host->transportt->eh_timed_out) 131 if (scmd->device->host->transportt->eh_timed_out)
133 eh_timed_out = scmd->device->host->transportt->eh_timed_out; 132 rtn = scmd->device->host->transportt->eh_timed_out(scmd);
134 else if (scmd->device->host->hostt->eh_timed_out) 133 else if (scmd->device->host->hostt->eh_timed_out)
135 eh_timed_out = scmd->device->host->hostt->eh_timed_out; 134 rtn = scmd->device->host->hostt->eh_timed_out(scmd);
136 else
137 eh_timed_out = NULL;
138 135
139 if (eh_timed_out) { 136 if (unlikely(rtn == BLK_EH_NOT_HANDLED &&
140 rtn = eh_timed_out(scmd); 137 !scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD))) {
141 switch (rtn) {
142 case BLK_EH_NOT_HANDLED:
143 break;
144 default:
145 return rtn;
146 }
147 }
148
149 if (unlikely(!scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD))) {
150 scmd->result |= DID_TIME_OUT << 16; 138 scmd->result |= DID_TIME_OUT << 16;
151 return BLK_EH_HANDLED; 139 rtn = BLK_EH_HANDLED;
152 } 140 }
153 141
154 return BLK_EH_NOT_HANDLED; 142 return rtn;
155} 143}
156 144
157/** 145/**
@@ -1650,7 +1638,7 @@ int scsi_error_handler(void *data)
1650 * We use TASK_INTERRUPTIBLE so that the thread is not 1638 * We use TASK_INTERRUPTIBLE so that the thread is not
1651 * counted against the load average as a running process. 1639 * counted against the load average as a running process.
1652 * We never actually get interrupted because kthread_run 1640 * We never actually get interrupted because kthread_run
1653 * disables singal delivery for the created thread. 1641 * disables signal delivery for the created thread.
1654 */ 1642 */
1655 set_current_state(TASK_INTERRUPTIBLE); 1643 set_current_state(TASK_INTERRUPTIBLE);
1656 while (!kthread_should_stop()) { 1644 while (!kthread_should_stop()) {
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index 2ae4f8fc5831..b98f763931c5 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -167,10 +167,17 @@ EXPORT_SYMBOL(scsi_set_medium_removal);
167static int scsi_ioctl_get_pci(struct scsi_device *sdev, void __user *arg) 167static int scsi_ioctl_get_pci(struct scsi_device *sdev, void __user *arg)
168{ 168{
169 struct device *dev = scsi_get_device(sdev->host); 169 struct device *dev = scsi_get_device(sdev->host);
170 const char *name;
170 171
171 if (!dev) 172 if (!dev)
172 return -ENXIO; 173 return -ENXIO;
173 return copy_to_user(arg, dev->bus_id, sizeof(dev->bus_id))? -EFAULT: 0; 174
175 name = dev_name(dev);
176
177 /* compatibility with old ioctl which only returned
178 * 20 characters */
179 return copy_to_user(arg, name, min(strlen(name), (size_t)20))
180 ? -EFAULT: 0;
174} 181}
175 182
176 183
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index f2f51e0333eb..940dc32ff0dc 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -91,26 +91,19 @@ static void scsi_unprep_request(struct request *req)
91 scsi_put_command(cmd); 91 scsi_put_command(cmd);
92} 92}
93 93
94/* 94/**
95 * Function: scsi_queue_insert() 95 * __scsi_queue_insert - private queue insertion
96 * 96 * @cmd: The SCSI command being requeued
97 * Purpose: Insert a command in the midlevel queue. 97 * @reason: The reason for the requeue
98 * 98 * @unbusy: Whether the queue should be unbusied
99 * Arguments: cmd - command that we are adding to queue. 99 *
100 * reason - why we are inserting command to queue. 100 * This is a private queue insertion. The public interface
101 * 101 * scsi_queue_insert() always assumes the queue should be unbusied
102 * Lock status: Assumed that lock is not held upon entry. 102 * because it's always called before the completion. This function is
103 * 103 * for a requeue after completion, which should only occur in this
104 * Returns: Nothing. 104 * file.
105 *
106 * Notes: We do this for one of two cases. Either the host is busy
107 * and it cannot accept any more commands for the time being,
108 * or the device returned QUEUE_FULL and can accept no more
109 * commands.
110 * Notes: This could be called either from an interrupt context or a
111 * normal process context.
112 */ 105 */
113int scsi_queue_insert(struct scsi_cmnd *cmd, int reason) 106static int __scsi_queue_insert(struct scsi_cmnd *cmd, int reason, int unbusy)
114{ 107{
115 struct Scsi_Host *host = cmd->device->host; 108 struct Scsi_Host *host = cmd->device->host;
116 struct scsi_device *device = cmd->device; 109 struct scsi_device *device = cmd->device;
@@ -150,7 +143,8 @@ int scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
150 * Decrement the counters, since these commands are no longer 143 * Decrement the counters, since these commands are no longer
151 * active on the host/device. 144 * active on the host/device.
152 */ 145 */
153 scsi_device_unbusy(device); 146 if (unbusy)
147 scsi_device_unbusy(device);
154 148
155 /* 149 /*
156 * Requeue this command. It will go before all other commands 150 * Requeue this command. It will go before all other commands
@@ -172,6 +166,29 @@ int scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
172 return 0; 166 return 0;
173} 167}
174 168
169/*
170 * Function: scsi_queue_insert()
171 *
172 * Purpose: Insert a command in the midlevel queue.
173 *
174 * Arguments: cmd - command that we are adding to queue.
175 * reason - why we are inserting command to queue.
176 *
177 * Lock status: Assumed that lock is not held upon entry.
178 *
179 * Returns: Nothing.
180 *
181 * Notes: We do this for one of two cases. Either the host is busy
182 * and it cannot accept any more commands for the time being,
183 * or the device returned QUEUE_FULL and can accept no more
184 * commands.
185 * Notes: This could be called either from an interrupt context or a
186 * normal process context.
187 */
188int scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
189{
190 return __scsi_queue_insert(cmd, reason, 1);
191}
175/** 192/**
176 * scsi_execute - insert request and wait for the result 193 * scsi_execute - insert request and wait for the result
177 * @sdev: scsi device 194 * @sdev: scsi device
@@ -684,6 +701,8 @@ void scsi_run_host_queues(struct Scsi_Host *shost)
684 scsi_run_queue(sdev->request_queue); 701 scsi_run_queue(sdev->request_queue);
685} 702}
686 703
704static void __scsi_release_buffers(struct scsi_cmnd *, int);
705
687/* 706/*
688 * Function: scsi_end_request() 707 * Function: scsi_end_request()
689 * 708 *
@@ -732,6 +751,7 @@ static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int error,
732 * leftovers in the front of the 751 * leftovers in the front of the
733 * queue, and goose the queue again. 752 * queue, and goose the queue again.
734 */ 753 */
754 scsi_release_buffers(cmd);
735 scsi_requeue_command(q, cmd); 755 scsi_requeue_command(q, cmd);
736 cmd = NULL; 756 cmd = NULL;
737 } 757 }
@@ -743,6 +763,7 @@ static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int error,
743 * This will goose the queue request function at the end, so we don't 763 * This will goose the queue request function at the end, so we don't
744 * need to worry about launching another command. 764 * need to worry about launching another command.
745 */ 765 */
766 __scsi_release_buffers(cmd, 0);
746 scsi_next_command(cmd); 767 scsi_next_command(cmd);
747 return NULL; 768 return NULL;
748} 769}
@@ -798,6 +819,26 @@ static void scsi_free_sgtable(struct scsi_data_buffer *sdb)
798 __sg_free_table(&sdb->table, SCSI_MAX_SG_SEGMENTS, scsi_sg_free); 819 __sg_free_table(&sdb->table, SCSI_MAX_SG_SEGMENTS, scsi_sg_free);
799} 820}
800 821
822static void __scsi_release_buffers(struct scsi_cmnd *cmd, int do_bidi_check)
823{
824
825 if (cmd->sdb.table.nents)
826 scsi_free_sgtable(&cmd->sdb);
827
828 memset(&cmd->sdb, 0, sizeof(cmd->sdb));
829
830 if (do_bidi_check && scsi_bidi_cmnd(cmd)) {
831 struct scsi_data_buffer *bidi_sdb =
832 cmd->request->next_rq->special;
833 scsi_free_sgtable(bidi_sdb);
834 kmem_cache_free(scsi_sdb_cache, bidi_sdb);
835 cmd->request->next_rq->special = NULL;
836 }
837
838 if (scsi_prot_sg_count(cmd))
839 scsi_free_sgtable(cmd->prot_sdb);
840}
841
801/* 842/*
802 * Function: scsi_release_buffers() 843 * Function: scsi_release_buffers()
803 * 844 *
@@ -817,21 +858,7 @@ static void scsi_free_sgtable(struct scsi_data_buffer *sdb)
817 */ 858 */
818void scsi_release_buffers(struct scsi_cmnd *cmd) 859void scsi_release_buffers(struct scsi_cmnd *cmd)
819{ 860{
820 if (cmd->sdb.table.nents) 861 __scsi_release_buffers(cmd, 1);
821 scsi_free_sgtable(&cmd->sdb);
822
823 memset(&cmd->sdb, 0, sizeof(cmd->sdb));
824
825 if (scsi_bidi_cmnd(cmd)) {
826 struct scsi_data_buffer *bidi_sdb =
827 cmd->request->next_rq->special;
828 scsi_free_sgtable(bidi_sdb);
829 kmem_cache_free(scsi_sdb_cache, bidi_sdb);
830 cmd->request->next_rq->special = NULL;
831 }
832
833 if (scsi_prot_sg_count(cmd))
834 scsi_free_sgtable(cmd->prot_sdb);
835} 862}
836EXPORT_SYMBOL(scsi_release_buffers); 863EXPORT_SYMBOL(scsi_release_buffers);
837 864
@@ -945,7 +972,6 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
945 } 972 }
946 973
947 BUG_ON(blk_bidi_rq(req)); /* bidi not support for !blk_pc_request yet */ 974 BUG_ON(blk_bidi_rq(req)); /* bidi not support for !blk_pc_request yet */
948 scsi_release_buffers(cmd);
949 975
950 /* 976 /*
951 * Next deal with any sectors which we were able to correctly 977 * Next deal with any sectors which we were able to correctly
@@ -963,6 +989,8 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
963 return; 989 return;
964 this_count = blk_rq_bytes(req); 990 this_count = blk_rq_bytes(req);
965 991
992 error = -EIO;
993
966 if (host_byte(result) == DID_RESET) { 994 if (host_byte(result) == DID_RESET) {
967 /* Third party bus reset or reset for error recovery 995 /* Third party bus reset or reset for error recovery
968 * reasons. Just retry the command and see what 996 * reasons. Just retry the command and see what
@@ -1004,13 +1032,18 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
1004 /* This will issue a new 6-byte command. */ 1032 /* This will issue a new 6-byte command. */
1005 cmd->device->use_10_for_rw = 0; 1033 cmd->device->use_10_for_rw = 0;
1006 action = ACTION_REPREP; 1034 action = ACTION_REPREP;
1035 } else if (sshdr.asc == 0x10) /* DIX */ {
1036 description = "Host Data Integrity Failure";
1037 action = ACTION_FAIL;
1038 error = -EILSEQ;
1007 } else 1039 } else
1008 action = ACTION_FAIL; 1040 action = ACTION_FAIL;
1009 break; 1041 break;
1010 case ABORTED_COMMAND: 1042 case ABORTED_COMMAND:
1011 if (sshdr.asc == 0x10) { /* DIF */ 1043 if (sshdr.asc == 0x10) { /* DIF */
1044 description = "Target Data Integrity Failure";
1012 action = ACTION_FAIL; 1045 action = ACTION_FAIL;
1013 description = "Data Integrity Failure"; 1046 error = -EILSEQ;
1014 } else 1047 } else
1015 action = ACTION_RETRY; 1048 action = ACTION_RETRY;
1016 break; 1049 break;
@@ -1029,6 +1062,10 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
1029 case 0x09: /* self test in progress */ 1062 case 0x09: /* self test in progress */
1030 action = ACTION_DELAYED_RETRY; 1063 action = ACTION_DELAYED_RETRY;
1031 break; 1064 break;
1065 default:
1066 description = "Device not ready";
1067 action = ACTION_FAIL;
1068 break;
1032 } 1069 }
1033 } else { 1070 } else {
1034 description = "Device not ready"; 1071 description = "Device not ready";
@@ -1052,9 +1089,10 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
1052 switch (action) { 1089 switch (action) {
1053 case ACTION_FAIL: 1090 case ACTION_FAIL:
1054 /* Give up and fail the remainder of the request */ 1091 /* Give up and fail the remainder of the request */
1092 scsi_release_buffers(cmd);
1055 if (!(req->cmd_flags & REQ_QUIET)) { 1093 if (!(req->cmd_flags & REQ_QUIET)) {
1056 if (description) 1094 if (description)
1057 scmd_printk(KERN_INFO, cmd, "%s", 1095 scmd_printk(KERN_INFO, cmd, "%s\n",
1058 description); 1096 description);
1059 scsi_print_result(cmd); 1097 scsi_print_result(cmd);
1060 if (driver_byte(result) & DRIVER_SENSE) 1098 if (driver_byte(result) & DRIVER_SENSE)
@@ -1067,15 +1105,16 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
1067 /* Unprep the request and put it back at the head of the queue. 1105 /* Unprep the request and put it back at the head of the queue.
1068 * A new command will be prepared and issued. 1106 * A new command will be prepared and issued.
1069 */ 1107 */
1108 scsi_release_buffers(cmd);
1070 scsi_requeue_command(q, cmd); 1109 scsi_requeue_command(q, cmd);
1071 break; 1110 break;
1072 case ACTION_RETRY: 1111 case ACTION_RETRY:
1073 /* Retry the same command immediately */ 1112 /* Retry the same command immediately */
1074 scsi_queue_insert(cmd, SCSI_MLQUEUE_EH_RETRY); 1113 __scsi_queue_insert(cmd, SCSI_MLQUEUE_EH_RETRY, 0);
1075 break; 1114 break;
1076 case ACTION_DELAYED_RETRY: 1115 case ACTION_DELAYED_RETRY:
1077 /* Retry the same command after a delay */ 1116 /* Retry the same command after a delay */
1078 scsi_queue_insert(cmd, SCSI_MLQUEUE_DEVICE_BUSY); 1117 __scsi_queue_insert(cmd, SCSI_MLQUEUE_DEVICE_BUSY, 0);
1079 break; 1118 break;
1080 } 1119 }
1081} 1120}
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 18486b51668d..66505bb79410 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -32,6 +32,7 @@
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/kthread.h> 33#include <linux/kthread.h>
34#include <linux/spinlock.h> 34#include <linux/spinlock.h>
35#include <linux/async.h>
35 36
36#include <scsi/scsi.h> 37#include <scsi/scsi.h>
37#include <scsi/scsi_cmnd.h> 38#include <scsi/scsi_cmnd.h>
@@ -179,6 +180,8 @@ int scsi_complete_async_scans(void)
179 spin_unlock(&async_scan_lock); 180 spin_unlock(&async_scan_lock);
180 181
181 kfree(data); 182 kfree(data);
183 /* Synchronize async operations globally */
184 async_synchronize_full();
182 return 0; 185 return 0;
183} 186}
184 187
@@ -411,8 +414,7 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,
411 device_initialize(dev); 414 device_initialize(dev);
412 starget->reap_ref = 1; 415 starget->reap_ref = 1;
413 dev->parent = get_device(parent); 416 dev->parent = get_device(parent);
414 sprintf(dev->bus_id, "target%d:%d:%d", 417 dev_set_name(dev, "target%d:%d:%d", shost->host_no, channel, id);
415 shost->host_no, channel, id);
416#ifndef CONFIG_SYSFS_DEPRECATED 418#ifndef CONFIG_SYSFS_DEPRECATED
417 dev->bus = &scsi_bus_type; 419 dev->bus = &scsi_bus_type;
418#endif 420#endif
@@ -1021,7 +1023,7 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
1021 if (rescan || !scsi_device_created(sdev)) { 1023 if (rescan || !scsi_device_created(sdev)) {
1022 SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO 1024 SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO
1023 "scsi scan: device exists on %s\n", 1025 "scsi scan: device exists on %s\n",
1024 sdev->sdev_gendev.bus_id)); 1026 dev_name(&sdev->sdev_gendev)));
1025 if (sdevp) 1027 if (sdevp)
1026 *sdevp = sdev; 1028 *sdevp = sdev;
1027 else 1029 else
@@ -1160,7 +1162,7 @@ static void scsi_sequential_lun_scan(struct scsi_target *starget,
1160 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 1162 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
1161 1163
1162 SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO "scsi scan: Sequential scan of" 1164 SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO "scsi scan: Sequential scan of"
1163 "%s\n", starget->dev.bus_id)); 1165 "%s\n", dev_name(&starget->dev)));
1164 1166
1165 max_dev_lun = min(max_scsi_luns, shost->max_lun); 1167 max_dev_lun = min(max_scsi_luns, shost->max_lun);
1166 /* 1168 /*
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 93c28f30bbd7..da63802cbf9d 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -1079,16 +1079,14 @@ void scsi_sysfs_device_initialize(struct scsi_device *sdev)
1079 device_initialize(&sdev->sdev_gendev); 1079 device_initialize(&sdev->sdev_gendev);
1080 sdev->sdev_gendev.bus = &scsi_bus_type; 1080 sdev->sdev_gendev.bus = &scsi_bus_type;
1081 sdev->sdev_gendev.type = &scsi_dev_type; 1081 sdev->sdev_gendev.type = &scsi_dev_type;
1082 sprintf(sdev->sdev_gendev.bus_id,"%d:%d:%d:%d", 1082 dev_set_name(&sdev->sdev_gendev, "%d:%d:%d:%d",
1083 sdev->host->host_no, sdev->channel, sdev->id, 1083 sdev->host->host_no, sdev->channel, sdev->id, sdev->lun);
1084 sdev->lun); 1084
1085
1086 device_initialize(&sdev->sdev_dev); 1085 device_initialize(&sdev->sdev_dev);
1087 sdev->sdev_dev.parent = &sdev->sdev_gendev; 1086 sdev->sdev_dev.parent = &sdev->sdev_gendev;
1088 sdev->sdev_dev.class = &sdev_class; 1087 sdev->sdev_dev.class = &sdev_class;
1089 snprintf(sdev->sdev_dev.bus_id, BUS_ID_SIZE, 1088 dev_set_name(&sdev->sdev_dev, "%d:%d:%d:%d",
1090 "%d:%d:%d:%d", sdev->host->host_no, 1089 sdev->host->host_no, sdev->channel, sdev->id, sdev->lun);
1091 sdev->channel, sdev->id, sdev->lun);
1092 sdev->scsi_level = starget->scsi_level; 1090 sdev->scsi_level = starget->scsi_level;
1093 transport_setup_device(&sdev->sdev_gendev); 1091 transport_setup_device(&sdev->sdev_gendev);
1094 spin_lock_irqsave(shost->host_lock, flags); 1092 spin_lock_irqsave(shost->host_lock, flags);
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 062304de4854..5f77417ed585 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -2407,8 +2407,12 @@ fc_rport_final_delete(struct work_struct *work)
2407 /* 2407 /*
2408 * Notify the driver that the rport is now dead. The LLDD will 2408 * Notify the driver that the rport is now dead. The LLDD will
2409 * also guarantee that any communication to the rport is terminated 2409 * also guarantee that any communication to the rport is terminated
2410 *
2411 * Avoid this call if we already called it when we preserved the
2412 * rport for the binding.
2410 */ 2413 */
2411 if (i->f->dev_loss_tmo_callbk) 2414 if (!(rport->flags & FC_RPORT_DEVLOSS_CALLBK_DONE) &&
2415 (i->f->dev_loss_tmo_callbk))
2412 i->f->dev_loss_tmo_callbk(rport); 2416 i->f->dev_loss_tmo_callbk(rport);
2413 2417
2414 transport_remove_device(dev); 2418 transport_remove_device(dev);
@@ -2486,8 +2490,8 @@ fc_rport_create(struct Scsi_Host *shost, int channel,
2486 device_initialize(dev); /* takes self reference */ 2490 device_initialize(dev); /* takes self reference */
2487 dev->parent = get_device(&shost->shost_gendev); /* parent reference */ 2491 dev->parent = get_device(&shost->shost_gendev); /* parent reference */
2488 dev->release = fc_rport_dev_release; 2492 dev->release = fc_rport_dev_release;
2489 sprintf(dev->bus_id, "rport-%d:%d-%d", 2493 dev_set_name(dev, "rport-%d:%d-%d",
2490 shost->host_no, channel, rport->number); 2494 shost->host_no, channel, rport->number);
2491 transport_setup_device(dev); 2495 transport_setup_device(dev);
2492 2496
2493 error = device_add(dev); 2497 error = device_add(dev);
@@ -2647,7 +2651,8 @@ fc_remote_port_add(struct Scsi_Host *shost, int channel,
2647 spin_lock_irqsave(shost->host_lock, flags); 2651 spin_lock_irqsave(shost->host_lock, flags);
2648 2652
2649 rport->flags &= ~(FC_RPORT_FAST_FAIL_TIMEDOUT | 2653 rport->flags &= ~(FC_RPORT_FAST_FAIL_TIMEDOUT |
2650 FC_RPORT_DEVLOSS_PENDING); 2654 FC_RPORT_DEVLOSS_PENDING |
2655 FC_RPORT_DEVLOSS_CALLBK_DONE);
2651 2656
2652 /* if target, initiate a scan */ 2657 /* if target, initiate a scan */
2653 if (rport->scsi_target_id != -1) { 2658 if (rport->scsi_target_id != -1) {
@@ -2944,6 +2949,7 @@ fc_timeout_deleted_rport(struct work_struct *work)
2944 struct fc_rport *rport = 2949 struct fc_rport *rport =
2945 container_of(work, struct fc_rport, dev_loss_work.work); 2950 container_of(work, struct fc_rport, dev_loss_work.work);
2946 struct Scsi_Host *shost = rport_to_shost(rport); 2951 struct Scsi_Host *shost = rport_to_shost(rport);
2952 struct fc_internal *i = to_fc_internal(shost->transportt);
2947 struct fc_host_attrs *fc_host = shost_to_fc_host(shost); 2953 struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
2948 unsigned long flags; 2954 unsigned long flags;
2949 2955
@@ -3011,6 +3017,7 @@ fc_timeout_deleted_rport(struct work_struct *work)
3011 rport->roles = FC_PORT_ROLE_UNKNOWN; 3017 rport->roles = FC_PORT_ROLE_UNKNOWN;
3012 rport->port_state = FC_PORTSTATE_NOTPRESENT; 3018 rport->port_state = FC_PORTSTATE_NOTPRESENT;
3013 rport->flags &= ~FC_RPORT_FAST_FAIL_TIMEDOUT; 3019 rport->flags &= ~FC_RPORT_FAST_FAIL_TIMEDOUT;
3020 rport->flags |= FC_RPORT_DEVLOSS_CALLBK_DONE;
3014 3021
3015 /* 3022 /*
3016 * Pre-emptively kill I/O rather than waiting for the work queue 3023 * Pre-emptively kill I/O rather than waiting for the work queue
@@ -3046,8 +3053,18 @@ fc_timeout_deleted_rport(struct work_struct *work)
3046 * all attached scsi devices. 3053 * all attached scsi devices.
3047 */ 3054 */
3048 fc_queue_work(shost, &rport->stgt_delete_work); 3055 fc_queue_work(shost, &rport->stgt_delete_work);
3056
3057 /*
3058 * Notify the driver that the rport is now dead. The LLDD will
3059 * also guarantee that any communication to the rport is terminated
3060 *
3061 * Note: we set the CALLBK_DONE flag above to correspond
3062 */
3063 if (i->f->dev_loss_tmo_callbk)
3064 i->f->dev_loss_tmo_callbk(rport);
3049} 3065}
3050 3066
3067
3051/** 3068/**
3052 * fc_timeout_fail_rport_io - Timeout handler for a fast io failing on a disconnected SCSI target. 3069 * fc_timeout_fail_rport_io - Timeout handler for a fast io failing on a disconnected SCSI target.
3053 * @work: rport to terminate io on. 3070 * @work: rport to terminate io on.
@@ -3164,8 +3181,8 @@ fc_vport_setup(struct Scsi_Host *shost, int channel, struct device *pdev,
3164 device_initialize(dev); /* takes self reference */ 3181 device_initialize(dev); /* takes self reference */
3165 dev->parent = get_device(pdev); /* takes parent reference */ 3182 dev->parent = get_device(pdev); /* takes parent reference */
3166 dev->release = fc_vport_dev_release; 3183 dev->release = fc_vport_dev_release;
3167 sprintf(dev->bus_id, "vport-%d:%d-%d", 3184 dev_set_name(dev, "vport-%d:%d-%d",
3168 shost->host_no, channel, vport->number); 3185 shost->host_no, channel, vport->number);
3169 transport_setup_device(dev); 3186 transport_setup_device(dev);
3170 3187
3171 error = device_add(dev); 3188 error = device_add(dev);
@@ -3188,19 +3205,19 @@ fc_vport_setup(struct Scsi_Host *shost, int channel, struct device *pdev,
3188 */ 3205 */
3189 if (pdev != &shost->shost_gendev) { 3206 if (pdev != &shost->shost_gendev) {
3190 error = sysfs_create_link(&shost->shost_gendev.kobj, 3207 error = sysfs_create_link(&shost->shost_gendev.kobj,
3191 &dev->kobj, dev->bus_id); 3208 &dev->kobj, dev_name(dev));
3192 if (error) 3209 if (error)
3193 printk(KERN_ERR 3210 printk(KERN_ERR
3194 "%s: Cannot create vport symlinks for " 3211 "%s: Cannot create vport symlinks for "
3195 "%s, err=%d\n", 3212 "%s, err=%d\n",
3196 __func__, dev->bus_id, error); 3213 __func__, dev_name(dev), error);
3197 } 3214 }
3198 spin_lock_irqsave(shost->host_lock, flags); 3215 spin_lock_irqsave(shost->host_lock, flags);
3199 vport->flags &= ~FC_VPORT_CREATING; 3216 vport->flags &= ~FC_VPORT_CREATING;
3200 spin_unlock_irqrestore(shost->host_lock, flags); 3217 spin_unlock_irqrestore(shost->host_lock, flags);
3201 3218
3202 dev_printk(KERN_NOTICE, pdev, 3219 dev_printk(KERN_NOTICE, pdev,
3203 "%s created via shost%d channel %d\n", dev->bus_id, 3220 "%s created via shost%d channel %d\n", dev_name(dev),
3204 shost->host_no, channel); 3221 shost->host_no, channel);
3205 3222
3206 *ret_vport = vport; 3223 *ret_vport = vport;
@@ -3297,7 +3314,7 @@ fc_vport_terminate(struct fc_vport *vport)
3297 return stat; 3314 return stat;
3298 3315
3299 if (dev->parent != &shost->shost_gendev) 3316 if (dev->parent != &shost->shost_gendev)
3300 sysfs_remove_link(&shost->shost_gendev.kobj, dev->bus_id); 3317 sysfs_remove_link(&shost->shost_gendev.kobj, dev_name(dev));
3301 transport_remove_device(dev); 3318 transport_remove_device(dev);
3302 device_del(dev); 3319 device_del(dev);
3303 transport_destroy_device(dev); 3320 transport_destroy_device(dev);
@@ -3329,7 +3346,7 @@ fc_vport_sched_delete(struct work_struct *work)
3329 dev_printk(KERN_ERR, vport->dev.parent, 3346 dev_printk(KERN_ERR, vport->dev.parent,
3330 "%s: %s could not be deleted created via " 3347 "%s: %s could not be deleted created via "
3331 "shost%d channel %d - error %d\n", __func__, 3348 "shost%d channel %d - error %d\n", __func__,
3332 vport->dev.bus_id, vport->shost->host_no, 3349 dev_name(&vport->dev), vport->shost->host_no,
3333 vport->channel, stat); 3350 vport->channel, stat);
3334} 3351}
3335 3352
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 4a803ebaf508..75c9297694cb 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -187,8 +187,7 @@ iscsi_create_endpoint(int dd_size)
187 187
188 ep->id = id; 188 ep->id = id;
189 ep->dev.class = &iscsi_endpoint_class; 189 ep->dev.class = &iscsi_endpoint_class;
190 snprintf(ep->dev.bus_id, BUS_ID_SIZE, "ep-%llu", 190 dev_set_name(&ep->dev, "ep-%llu", (unsigned long long) id);
191 (unsigned long long) id);
192 err = device_register(&ep->dev); 191 err = device_register(&ep->dev);
193 if (err) 192 if (err)
194 goto free_ep; 193 goto free_ep;
@@ -724,8 +723,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
724 } 723 }
725 session->target_id = id; 724 session->target_id = id;
726 725
727 snprintf(session->dev.bus_id, BUS_ID_SIZE, "session%u", 726 dev_set_name(&session->dev, "session%u", session->sid);
728 session->sid);
729 err = device_add(&session->dev); 727 err = device_add(&session->dev);
730 if (err) { 728 if (err) {
731 iscsi_cls_session_printk(KERN_ERR, session, 729 iscsi_cls_session_printk(KERN_ERR, session,
@@ -898,8 +896,7 @@ iscsi_create_conn(struct iscsi_cls_session *session, int dd_size, uint32_t cid)
898 if (!get_device(&session->dev)) 896 if (!get_device(&session->dev))
899 goto free_conn; 897 goto free_conn;
900 898
901 snprintf(conn->dev.bus_id, BUS_ID_SIZE, "connection%d:%u", 899 dev_set_name(&conn->dev, "connection%d:%u", session->sid, cid);
902 session->sid, cid);
903 conn->dev.parent = &session->dev; 900 conn->dev.parent = &session->dev;
904 conn->dev.release = iscsi_conn_release; 901 conn->dev.release = iscsi_conn_release;
905 err = device_register(&conn->dev); 902 err = device_register(&conn->dev);
@@ -1816,7 +1813,7 @@ iscsi_register_transport(struct iscsi_transport *tt)
1816 priv->t.create_work_queue = 1; 1813 priv->t.create_work_queue = 1;
1817 1814
1818 priv->dev.class = &iscsi_transport_class; 1815 priv->dev.class = &iscsi_transport_class;
1819 snprintf(priv->dev.bus_id, BUS_ID_SIZE, "%s", tt->name); 1816 dev_set_name(&priv->dev, "%s", tt->name);
1820 err = device_register(&priv->dev); 1817 err = device_register(&priv->dev);
1821 if (err) 1818 if (err)
1822 goto free_priv; 1819 goto free_priv;
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index 366609386be1..50988cbf7b2d 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -207,7 +207,7 @@ static int sas_bsg_initialize(struct Scsi_Host *shost, struct sas_rphy *rphy)
207 struct request_queue *q; 207 struct request_queue *q;
208 int error; 208 int error;
209 struct device *dev; 209 struct device *dev;
210 char namebuf[BUS_ID_SIZE]; 210 char namebuf[20];
211 const char *name; 211 const char *name;
212 void (*release)(struct device *); 212 void (*release)(struct device *);
213 213
@@ -219,7 +219,7 @@ static int sas_bsg_initialize(struct Scsi_Host *shost, struct sas_rphy *rphy)
219 if (rphy) { 219 if (rphy) {
220 q = blk_init_queue(sas_non_host_smp_request, NULL); 220 q = blk_init_queue(sas_non_host_smp_request, NULL);
221 dev = &rphy->dev; 221 dev = &rphy->dev;
222 name = dev->bus_id; 222 name = dev_name(dev);
223 release = NULL; 223 release = NULL;
224 } else { 224 } else {
225 q = blk_init_queue(sas_host_smp_request, NULL); 225 q = blk_init_queue(sas_host_smp_request, NULL);
@@ -629,10 +629,10 @@ struct sas_phy *sas_phy_alloc(struct device *parent, int number)
629 INIT_LIST_HEAD(&phy->port_siblings); 629 INIT_LIST_HEAD(&phy->port_siblings);
630 if (scsi_is_sas_expander_device(parent)) { 630 if (scsi_is_sas_expander_device(parent)) {
631 struct sas_rphy *rphy = dev_to_rphy(parent); 631 struct sas_rphy *rphy = dev_to_rphy(parent);
632 sprintf(phy->dev.bus_id, "phy-%d:%d:%d", shost->host_no, 632 dev_set_name(&phy->dev, "phy-%d:%d:%d", shost->host_no,
633 rphy->scsi_target_id, number); 633 rphy->scsi_target_id, number);
634 } else 634 } else
635 sprintf(phy->dev.bus_id, "phy-%d:%d", shost->host_no, number); 635 dev_set_name(&phy->dev, "phy-%d:%d", shost->host_no, number);
636 636
637 transport_setup_device(&phy->dev); 637 transport_setup_device(&phy->dev);
638 638
@@ -770,7 +770,7 @@ static void sas_port_create_link(struct sas_port *port,
770 int res; 770 int res;
771 771
772 res = sysfs_create_link(&port->dev.kobj, &phy->dev.kobj, 772 res = sysfs_create_link(&port->dev.kobj, &phy->dev.kobj,
773 phy->dev.bus_id); 773 dev_name(&phy->dev));
774 if (res) 774 if (res)
775 goto err; 775 goto err;
776 res = sysfs_create_link(&phy->dev.kobj, &port->dev.kobj, "port"); 776 res = sysfs_create_link(&phy->dev.kobj, &port->dev.kobj, "port");
@@ -785,7 +785,7 @@ err:
785static void sas_port_delete_link(struct sas_port *port, 785static void sas_port_delete_link(struct sas_port *port,
786 struct sas_phy *phy) 786 struct sas_phy *phy)
787{ 787{
788 sysfs_remove_link(&port->dev.kobj, phy->dev.bus_id); 788 sysfs_remove_link(&port->dev.kobj, dev_name(&phy->dev));
789 sysfs_remove_link(&phy->dev.kobj, "port"); 789 sysfs_remove_link(&phy->dev.kobj, "port");
790} 790}
791 791
@@ -821,11 +821,11 @@ struct sas_port *sas_port_alloc(struct device *parent, int port_id)
821 821
822 if (scsi_is_sas_expander_device(parent)) { 822 if (scsi_is_sas_expander_device(parent)) {
823 struct sas_rphy *rphy = dev_to_rphy(parent); 823 struct sas_rphy *rphy = dev_to_rphy(parent);
824 sprintf(port->dev.bus_id, "port-%d:%d:%d", shost->host_no, 824 dev_set_name(&port->dev, "port-%d:%d:%d", shost->host_no,
825 rphy->scsi_target_id, port->port_identifier); 825 rphy->scsi_target_id, port->port_identifier);
826 } else 826 } else
827 sprintf(port->dev.bus_id, "port-%d:%d", shost->host_no, 827 dev_set_name(&port->dev, "port-%d:%d", shost->host_no,
828 port->port_identifier); 828 port->port_identifier);
829 829
830 transport_setup_device(&port->dev); 830 transport_setup_device(&port->dev);
831 831
@@ -935,7 +935,7 @@ void sas_port_delete(struct sas_port *port)
935 if (port->is_backlink) { 935 if (port->is_backlink) {
936 struct device *parent = port->dev.parent; 936 struct device *parent = port->dev.parent;
937 937
938 sysfs_remove_link(&port->dev.kobj, parent->bus_id); 938 sysfs_remove_link(&port->dev.kobj, dev_name(parent));
939 port->is_backlink = 0; 939 port->is_backlink = 0;
940 } 940 }
941 941
@@ -984,7 +984,8 @@ void sas_port_add_phy(struct sas_port *port, struct sas_phy *phy)
984 /* If this trips, you added a phy that was already 984 /* If this trips, you added a phy that was already
985 * part of a different port */ 985 * part of a different port */
986 if (unlikely(tmp != phy)) { 986 if (unlikely(tmp != phy)) {
987 dev_printk(KERN_ERR, &port->dev, "trying to add phy %s fails: it's already part of another port\n", phy->dev.bus_id); 987 dev_printk(KERN_ERR, &port->dev, "trying to add phy %s fails: it's already part of another port\n",
988 dev_name(&phy->dev));
988 BUG(); 989 BUG();
989 } 990 }
990 } else { 991 } else {
@@ -1023,7 +1024,7 @@ void sas_port_mark_backlink(struct sas_port *port)
1023 return; 1024 return;
1024 port->is_backlink = 1; 1025 port->is_backlink = 1;
1025 res = sysfs_create_link(&port->dev.kobj, &parent->kobj, 1026 res = sysfs_create_link(&port->dev.kobj, &parent->kobj,
1026 parent->bus_id); 1027 dev_name(parent));
1027 if (res) 1028 if (res)
1028 goto err; 1029 goto err;
1029 return; 1030 return;
@@ -1367,11 +1368,12 @@ struct sas_rphy *sas_end_device_alloc(struct sas_port *parent)
1367 rdev->rphy.dev.release = sas_end_device_release; 1368 rdev->rphy.dev.release = sas_end_device_release;
1368 if (scsi_is_sas_expander_device(parent->dev.parent)) { 1369 if (scsi_is_sas_expander_device(parent->dev.parent)) {
1369 struct sas_rphy *rphy = dev_to_rphy(parent->dev.parent); 1370 struct sas_rphy *rphy = dev_to_rphy(parent->dev.parent);
1370 sprintf(rdev->rphy.dev.bus_id, "end_device-%d:%d:%d", 1371 dev_set_name(&rdev->rphy.dev, "end_device-%d:%d:%d",
1371 shost->host_no, rphy->scsi_target_id, parent->port_identifier); 1372 shost->host_no, rphy->scsi_target_id,
1373 parent->port_identifier);
1372 } else 1374 } else
1373 sprintf(rdev->rphy.dev.bus_id, "end_device-%d:%d", 1375 dev_set_name(&rdev->rphy.dev, "end_device-%d:%d",
1374 shost->host_no, parent->port_identifier); 1376 shost->host_no, parent->port_identifier);
1375 rdev->rphy.identify.device_type = SAS_END_DEVICE; 1377 rdev->rphy.identify.device_type = SAS_END_DEVICE;
1376 sas_rphy_initialize(&rdev->rphy); 1378 sas_rphy_initialize(&rdev->rphy);
1377 transport_setup_device(&rdev->rphy.dev); 1379 transport_setup_device(&rdev->rphy.dev);
@@ -1411,8 +1413,8 @@ struct sas_rphy *sas_expander_alloc(struct sas_port *parent,
1411 mutex_lock(&sas_host->lock); 1413 mutex_lock(&sas_host->lock);
1412 rdev->rphy.scsi_target_id = sas_host->next_expander_id++; 1414 rdev->rphy.scsi_target_id = sas_host->next_expander_id++;
1413 mutex_unlock(&sas_host->lock); 1415 mutex_unlock(&sas_host->lock);
1414 sprintf(rdev->rphy.dev.bus_id, "expander-%d:%d", 1416 dev_set_name(&rdev->rphy.dev, "expander-%d:%d",
1415 shost->host_no, rdev->rphy.scsi_target_id); 1417 shost->host_no, rdev->rphy.scsi_target_id);
1416 rdev->rphy.identify.device_type = type; 1418 rdev->rphy.identify.device_type = type;
1417 sas_rphy_initialize(&rdev->rphy); 1419 sas_rphy_initialize(&rdev->rphy);
1418 transport_setup_device(&rdev->rphy.dev); 1420 transport_setup_device(&rdev->rphy.dev);
@@ -1445,7 +1447,7 @@ int sas_rphy_add(struct sas_rphy *rphy)
1445 transport_add_device(&rphy->dev); 1447 transport_add_device(&rphy->dev);
1446 transport_configure_device(&rphy->dev); 1448 transport_configure_device(&rphy->dev);
1447 if (sas_bsg_initialize(shost, rphy)) 1449 if (sas_bsg_initialize(shost, rphy))
1448 printk("fail to a bsg device %s\n", rphy->dev.bus_id); 1450 printk("fail to a bsg device %s\n", dev_name(&rphy->dev));
1449 1451
1450 1452
1451 mutex_lock(&sas_host->lock); 1453 mutex_lock(&sas_host->lock);
diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
index 8a7af951d98a..21a045e0559f 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -212,7 +212,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
212 rport->roles = ids->roles; 212 rport->roles = ids->roles;
213 213
214 id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id); 214 id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
215 sprintf(rport->dev.bus_id, "port-%d:%d", shost->host_no, id); 215 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
216 216
217 transport_setup_device(&rport->dev); 217 transport_setup_device(&rport->dev);
218 218
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 62b28d58e65e..d57566b8be0a 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -48,6 +48,7 @@
48#include <linux/delay.h> 48#include <linux/delay.h>
49#include <linux/mutex.h> 49#include <linux/mutex.h>
50#include <linux/string_helpers.h> 50#include <linux/string_helpers.h>
51#include <linux/async.h>
51#include <asm/uaccess.h> 52#include <asm/uaccess.h>
52 53
53#include <scsi/scsi.h> 54#include <scsi/scsi.h>
@@ -1802,6 +1803,71 @@ static int sd_format_disk_name(char *prefix, int index, char *buf, int buflen)
1802 return 0; 1803 return 0;
1803} 1804}
1804 1805
1806/*
1807 * The asynchronous part of sd_probe
1808 */
1809static void sd_probe_async(void *data, async_cookie_t cookie)
1810{
1811 struct scsi_disk *sdkp = data;
1812 struct scsi_device *sdp;
1813 struct gendisk *gd;
1814 u32 index;
1815 struct device *dev;
1816
1817 sdp = sdkp->device;
1818 gd = sdkp->disk;
1819 index = sdkp->index;
1820 dev = &sdp->sdev_gendev;
1821
1822 if (!sdp->request_queue->rq_timeout) {
1823 if (sdp->type != TYPE_MOD)
1824 blk_queue_rq_timeout(sdp->request_queue, SD_TIMEOUT);
1825 else
1826 blk_queue_rq_timeout(sdp->request_queue,
1827 SD_MOD_TIMEOUT);
1828 }
1829
1830 device_initialize(&sdkp->dev);
1831 sdkp->dev.parent = &sdp->sdev_gendev;
1832 sdkp->dev.class = &sd_disk_class;
1833 dev_set_name(&sdkp->dev, dev_name(&sdp->sdev_gendev));
1834
1835 if (device_add(&sdkp->dev))
1836 goto out_free_index;
1837
1838 get_device(&sdp->sdev_gendev);
1839
1840 if (index < SD_MAX_DISKS) {
1841 gd->major = sd_major((index & 0xf0) >> 4);
1842 gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00);
1843 gd->minors = SD_MINORS;
1844 }
1845 gd->fops = &sd_fops;
1846 gd->private_data = &sdkp->driver;
1847 gd->queue = sdkp->device->request_queue;
1848
1849 sd_revalidate_disk(gd);
1850
1851 blk_queue_prep_rq(sdp->request_queue, sd_prep_fn);
1852
1853 gd->driverfs_dev = &sdp->sdev_gendev;
1854 gd->flags = GENHD_FL_EXT_DEVT | GENHD_FL_DRIVERFS;
1855 if (sdp->removable)
1856 gd->flags |= GENHD_FL_REMOVABLE;
1857
1858 dev_set_drvdata(dev, sdkp);
1859 add_disk(gd);
1860 sd_dif_config_host(sdkp);
1861
1862 sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n",
1863 sdp->removable ? "removable " : "");
1864
1865 return;
1866
1867 out_free_index:
1868 ida_remove(&sd_index_ida, index);
1869}
1870
1805/** 1871/**
1806 * sd_probe - called during driver initialization and whenever a 1872 * sd_probe - called during driver initialization and whenever a
1807 * new scsi device is attached to the system. It is called once 1873 * new scsi device is attached to the system. It is called once
@@ -1865,48 +1931,7 @@ static int sd_probe(struct device *dev)
1865 sdkp->openers = 0; 1931 sdkp->openers = 0;
1866 sdkp->previous_state = 1; 1932 sdkp->previous_state = 1;
1867 1933
1868 if (!sdp->request_queue->rq_timeout) { 1934 async_schedule(sd_probe_async, sdkp);
1869 if (sdp->type != TYPE_MOD)
1870 blk_queue_rq_timeout(sdp->request_queue, SD_TIMEOUT);
1871 else
1872 blk_queue_rq_timeout(sdp->request_queue,
1873 SD_MOD_TIMEOUT);
1874 }
1875
1876 device_initialize(&sdkp->dev);
1877 sdkp->dev.parent = &sdp->sdev_gendev;
1878 sdkp->dev.class = &sd_disk_class;
1879 strncpy(sdkp->dev.bus_id, sdp->sdev_gendev.bus_id, BUS_ID_SIZE);
1880
1881 if (device_add(&sdkp->dev))
1882 goto out_free_index;
1883
1884 get_device(&sdp->sdev_gendev);
1885
1886 if (index < SD_MAX_DISKS) {
1887 gd->major = sd_major((index & 0xf0) >> 4);
1888 gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00);
1889 gd->minors = SD_MINORS;
1890 }
1891 gd->fops = &sd_fops;
1892 gd->private_data = &sdkp->driver;
1893 gd->queue = sdkp->device->request_queue;
1894
1895 sd_revalidate_disk(gd);
1896
1897 blk_queue_prep_rq(sdp->request_queue, sd_prep_fn);
1898
1899 gd->driverfs_dev = &sdp->sdev_gendev;
1900 gd->flags = GENHD_FL_EXT_DEVT | GENHD_FL_DRIVERFS;
1901 if (sdp->removable)
1902 gd->flags |= GENHD_FL_REMOVABLE;
1903
1904 dev_set_drvdata(dev, sdkp);
1905 add_disk(gd);
1906 sd_dif_config_host(sdkp);
1907
1908 sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n",
1909 sdp->removable ? "removable " : "");
1910 1935
1911 return 0; 1936 return 0;
1912 1937
diff --git a/drivers/scsi/sd_dif.c b/drivers/scsi/sd_dif.c
index 3ebb1f289490..184dff492797 100644
--- a/drivers/scsi/sd_dif.c
+++ b/drivers/scsi/sd_dif.c
@@ -142,7 +142,7 @@ static int sd_dif_type1_verify_ip(struct blk_integrity_exchg *bix)
142static void sd_dif_type1_set_tag(void *prot, void *tag_buf, unsigned int sectors) 142static void sd_dif_type1_set_tag(void *prot, void *tag_buf, unsigned int sectors)
143{ 143{
144 struct sd_dif_tuple *sdt = prot; 144 struct sd_dif_tuple *sdt = prot;
145 char *tag = tag_buf; 145 u8 *tag = tag_buf;
146 unsigned int i, j; 146 unsigned int i, j;
147 147
148 for (i = 0, j = 0 ; i < sectors ; i++, j += 2, sdt++) { 148 for (i = 0, j = 0 ; i < sectors ; i++, j += 2, sdt++) {
@@ -154,7 +154,7 @@ static void sd_dif_type1_set_tag(void *prot, void *tag_buf, unsigned int sectors
154static void sd_dif_type1_get_tag(void *prot, void *tag_buf, unsigned int sectors) 154static void sd_dif_type1_get_tag(void *prot, void *tag_buf, unsigned int sectors)
155{ 155{
156 struct sd_dif_tuple *sdt = prot; 156 struct sd_dif_tuple *sdt = prot;
157 char *tag = tag_buf; 157 u8 *tag = tag_buf;
158 unsigned int i, j; 158 unsigned int i, j;
159 159
160 for (i = 0, j = 0 ; i < sectors ; i++, j += 2, sdt++) { 160 for (i = 0, j = 0 ; i < sectors ; i++, j += 2, sdt++) {
@@ -256,7 +256,7 @@ static int sd_dif_type3_verify_ip(struct blk_integrity_exchg *bix)
256static void sd_dif_type3_set_tag(void *prot, void *tag_buf, unsigned int sectors) 256static void sd_dif_type3_set_tag(void *prot, void *tag_buf, unsigned int sectors)
257{ 257{
258 struct sd_dif_tuple *sdt = prot; 258 struct sd_dif_tuple *sdt = prot;
259 char *tag = tag_buf; 259 u8 *tag = tag_buf;
260 unsigned int i, j; 260 unsigned int i, j;
261 261
262 for (i = 0, j = 0 ; i < sectors ; i++, j += 6, sdt++) { 262 for (i = 0, j = 0 ; i < sectors ; i++, j += 6, sdt++) {
@@ -269,7 +269,7 @@ static void sd_dif_type3_set_tag(void *prot, void *tag_buf, unsigned int sectors
269static void sd_dif_type3_get_tag(void *prot, void *tag_buf, unsigned int sectors) 269static void sd_dif_type3_get_tag(void *prot, void *tag_buf, unsigned int sectors)
270{ 270{
271 struct sd_dif_tuple *sdt = prot; 271 struct sd_dif_tuple *sdt = prot;
272 char *tag = tag_buf; 272 u8 *tag = tag_buf;
273 unsigned int i, j; 273 unsigned int i, j;
274 274
275 for (i = 0, j = 0 ; i < sectors ; i++, j += 2, sdt++) { 275 for (i = 0, j = 0 ; i < sectors ; i++, j += 2, sdt++) {
@@ -374,7 +374,10 @@ void sd_dif_op(struct scsi_cmnd *scmd, unsigned int dif, unsigned int dix, unsig
374 else 374 else
375 csum_convert = 0; 375 csum_convert = 0;
376 376
377 BUG_ON(dif && (scmd->cmnd[0] == READ_6 || scmd->cmnd[0] == WRITE_6));
378
377 switch (scmd->cmnd[0]) { 379 switch (scmd->cmnd[0]) {
380 case READ_6:
378 case READ_10: 381 case READ_10:
379 case READ_12: 382 case READ_12:
380 case READ_16: 383 case READ_16:
@@ -390,6 +393,7 @@ void sd_dif_op(struct scsi_cmnd *scmd, unsigned int dif, unsigned int dix, unsig
390 393
391 break; 394 break;
392 395
396 case WRITE_6:
393 case WRITE_10: 397 case WRITE_10:
394 case WRITE_12: 398 case WRITE_12:
395 case WRITE_16: 399 case WRITE_16:
@@ -475,8 +479,9 @@ int sd_dif_prepare(struct request *rq, sector_t hw_sector, unsigned int sector_s
475 479
476error: 480error:
477 kunmap_atomic(sdt, KM_USER0); 481 kunmap_atomic(sdt, KM_USER0);
478 sd_printk(KERN_ERR, sdkp, "%s: virt %u, phys %u, ref %u\n", 482 sd_printk(KERN_ERR, sdkp, "%s: virt %u, phys %u, ref %u, app %4x\n",
479 __func__, virt, phys, be32_to_cpu(sdt->ref_tag)); 483 __func__, virt, phys, be32_to_cpu(sdt->ref_tag),
484 be16_to_cpu(sdt->app_tag));
480 485
481 return -EIO; 486 return -EIO;
482} 487}
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index 7f0df29f3a64..e946e05db7f7 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -526,7 +526,7 @@ static int ses_intf_add(struct device *cdev,
526 if (!scomp) 526 if (!scomp)
527 goto err_free; 527 goto err_free;
528 528
529 edev = enclosure_register(cdev->parent, sdev->sdev_gendev.bus_id, 529 edev = enclosure_register(cdev->parent, dev_name(&sdev->sdev_gendev),
530 components, &ses_enclosure_callbacks); 530 components, &ses_enclosure_callbacks);
531 if (IS_ERR(edev)) { 531 if (IS_ERR(edev)) {
532 err = PTR_ERR(edev); 532 err = PTR_ERR(edev);
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 5103855242ae..8f0bd3f7a59f 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1669,6 +1669,8 @@ static int sg_start_req(Sg_request *srp, unsigned char *cmd)
1669 md->pages = req_schp->pages; 1669 md->pages = req_schp->pages;
1670 md->page_order = req_schp->page_order; 1670 md->page_order = req_schp->page_order;
1671 md->nr_entries = req_schp->k_use_sg; 1671 md->nr_entries = req_schp->k_use_sg;
1672 md->offset = 0;
1673 md->null_mapped = hp->dxferp ? 0 : 1;
1672 } 1674 }
1673 1675
1674 if (iov_count) 1676 if (iov_count)
diff --git a/drivers/scsi/sgiwd93.c b/drivers/scsi/sgiwd93.c
index 31fe6051c799..0807b260268b 100644
--- a/drivers/scsi/sgiwd93.c
+++ b/drivers/scsi/sgiwd93.c
@@ -297,7 +297,7 @@ out:
297 return err; 297 return err;
298} 298}
299 299
300static void __exit sgiwd93_remove(struct platform_device *pdev) 300static int __exit sgiwd93_remove(struct platform_device *pdev)
301{ 301{
302 struct Scsi_Host *host = platform_get_drvdata(pdev); 302 struct Scsi_Host *host = platform_get_drvdata(pdev);
303 struct ip22_hostdata *hdata = (struct ip22_hostdata *) host->hostdata; 303 struct ip22_hostdata *hdata = (struct ip22_hostdata *) host->hostdata;
@@ -307,6 +307,7 @@ static void __exit sgiwd93_remove(struct platform_device *pdev)
307 free_irq(pd->irq, host); 307 free_irq(pd->irq, host);
308 dma_free_noncoherent(&pdev->dev, HPC_DMA_SIZE, hdata->cpu, hdata->dma); 308 dma_free_noncoherent(&pdev->dev, HPC_DMA_SIZE, hdata->cpu, hdata->dma);
309 scsi_host_put(host); 309 scsi_host_put(host);
310 return 0;
310} 311}
311 312
312static struct platform_driver sgiwd93_driver = { 313static struct platform_driver sgiwd93_driver = {
diff --git a/drivers/scsi/sim710.c b/drivers/scsi/sim710.c
index d63d229e2323..6dc8b846c112 100644
--- a/drivers/scsi/sim710.c
+++ b/drivers/scsi/sim710.c
@@ -102,7 +102,7 @@ sim710_probe_common(struct device *dev, unsigned long base_addr,
102 struct NCR_700_Host_Parameters *hostdata = 102 struct NCR_700_Host_Parameters *hostdata =
103 kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL); 103 kzalloc(sizeof(struct NCR_700_Host_Parameters), GFP_KERNEL);
104 104
105 printk(KERN_NOTICE "sim710: %s\n", dev->bus_id); 105 printk(KERN_NOTICE "sim710: %s\n", dev_name(dev));
106 printk(KERN_NOTICE "sim710: irq = %d, clock = %d, base = 0x%lx, scsi_id = %d\n", 106 printk(KERN_NOTICE "sim710: irq = %d, clock = %d, base = 0x%lx, scsi_id = %d\n",
107 irq, clock, base_addr, scsi_id); 107 irq, clock, base_addr, scsi_id);
108 108
@@ -305,7 +305,7 @@ sim710_eisa_probe(struct device *dev)
305 scsi_id = ffs(val) - 1; 305 scsi_id = ffs(val) - 1;
306 306
307 if(scsi_id > 7 || (val & ~(1<<scsi_id)) != 0) { 307 if(scsi_id > 7 || (val & ~(1<<scsi_id)) != 0) {
308 printk(KERN_ERR "sim710.c, EISA card %s has incorrect scsi_id, setting to 7\n", dev->bus_id); 308 printk(KERN_ERR "sim710.c, EISA card %s has incorrect scsi_id, setting to 7\n", dev_name(dev));
309 scsi_id = 7; 309 scsi_id = 7;
310 } 310 }
311 } else { 311 } else {
diff --git a/drivers/scsi/sni_53c710.c b/drivers/scsi/sni_53c710.c
index 2bbef4c45a0d..77f0b2cdaa94 100644
--- a/drivers/scsi/sni_53c710.c
+++ b/drivers/scsi/sni_53c710.c
@@ -78,8 +78,7 @@ static int __init snirm710_probe(struct platform_device *dev)
78 base = res->start; 78 base = res->start;
79 hostdata = kzalloc(sizeof(*hostdata), GFP_KERNEL); 79 hostdata = kzalloc(sizeof(*hostdata), GFP_KERNEL);
80 if (!hostdata) { 80 if (!hostdata) {
81 printk(KERN_ERR "%s: Failed to allocate host data\n", 81 dev_printk(KERN_ERR, dev, "Failed to allocate host data\n");
82 dev->dev.bus_id);
83 return -ENOMEM; 82 return -ENOMEM;
84 } 83 }
85 84
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 7f3f317ee6ca..c6f19ee8f2cb 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -17,7 +17,7 @@
17 Last modified: 18-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Devfs support 17 Last modified: 18-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Devfs support
18 */ 18 */
19 19
20static const char *verstr = "20080504"; 20static const char *verstr = "20081215";
21 21
22#include <linux/module.h> 22#include <linux/module.h>
23 23
@@ -182,18 +182,16 @@ static struct scsi_tape **scsi_tapes = NULL;
182 182
183static int modes_defined; 183static int modes_defined;
184 184
185static struct st_buffer *new_tape_buffer(int, int, int);
186static int enlarge_buffer(struct st_buffer *, int, int); 185static int enlarge_buffer(struct st_buffer *, int, int);
187static void clear_buffer(struct st_buffer *); 186static void clear_buffer(struct st_buffer *);
188static void normalize_buffer(struct st_buffer *); 187static void normalize_buffer(struct st_buffer *);
189static int append_to_buffer(const char __user *, struct st_buffer *, int); 188static int append_to_buffer(const char __user *, struct st_buffer *, int);
190static int from_buffer(struct st_buffer *, char __user *, int); 189static int from_buffer(struct st_buffer *, char __user *, int);
191static void move_buffer_data(struct st_buffer *, int); 190static void move_buffer_data(struct st_buffer *, int);
192static void buf_to_sg(struct st_buffer *, unsigned int);
193 191
194static int sgl_map_user_pages(struct scatterlist *, const unsigned int, 192static int sgl_map_user_pages(struct st_buffer *, const unsigned int,
195 unsigned long, size_t, int); 193 unsigned long, size_t, int);
196static int sgl_unmap_user_pages(struct scatterlist *, const unsigned int, int); 194static int sgl_unmap_user_pages(struct st_buffer *, const unsigned int, int);
197 195
198static int st_probe(struct device *); 196static int st_probe(struct device *);
199static int st_remove(struct device *); 197static int st_remove(struct device *);
@@ -435,22 +433,6 @@ static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt)
435 return (-EIO); 433 return (-EIO);
436} 434}
437 435
438
439/* Wakeup from interrupt */
440static void st_sleep_done(void *data, char *sense, int result, int resid)
441{
442 struct st_request *SRpnt = data;
443 struct scsi_tape *STp = SRpnt->stp;
444
445 memcpy(SRpnt->sense, sense, SCSI_SENSE_BUFFERSIZE);
446 (STp->buffer)->cmdstat.midlevel_result = SRpnt->result = result;
447 (STp->buffer)->cmdstat.residual = resid;
448 DEB( STp->write_pending = 0; )
449
450 if (SRpnt->waiting)
451 complete(SRpnt->waiting);
452}
453
454static struct st_request *st_allocate_request(struct scsi_tape *stp) 436static struct st_request *st_allocate_request(struct scsi_tape *stp)
455{ 437{
456 struct st_request *streq; 438 struct st_request *streq;
@@ -475,6 +457,63 @@ static void st_release_request(struct st_request *streq)
475 kfree(streq); 457 kfree(streq);
476} 458}
477 459
460static void st_scsi_execute_end(struct request *req, int uptodate)
461{
462 struct st_request *SRpnt = req->end_io_data;
463 struct scsi_tape *STp = SRpnt->stp;
464
465 STp->buffer->cmdstat.midlevel_result = SRpnt->result = req->errors;
466 STp->buffer->cmdstat.residual = req->data_len;
467
468 if (SRpnt->waiting)
469 complete(SRpnt->waiting);
470
471 blk_rq_unmap_user(SRpnt->bio);
472 __blk_put_request(req->q, req);
473}
474
475static int st_scsi_execute(struct st_request *SRpnt, const unsigned char *cmd,
476 int data_direction, void *buffer, unsigned bufflen,
477 int timeout, int retries)
478{
479 struct request *req;
480 struct rq_map_data *mdata = &SRpnt->stp->buffer->map_data;
481 int err = 0;
482 int write = (data_direction == DMA_TO_DEVICE);
483
484 req = blk_get_request(SRpnt->stp->device->request_queue, write,
485 GFP_KERNEL);
486 if (!req)
487 return DRIVER_ERROR << 24;
488
489 req->cmd_type = REQ_TYPE_BLOCK_PC;
490 req->cmd_flags |= REQ_QUIET;
491
492 mdata->null_mapped = 1;
493
494 if (bufflen) {
495 err = blk_rq_map_user(req->q, req, mdata, NULL, bufflen,
496 GFP_KERNEL);
497 if (err) {
498 blk_put_request(req);
499 return DRIVER_ERROR << 24;
500 }
501 }
502
503 SRpnt->bio = req->bio;
504 req->cmd_len = COMMAND_SIZE(cmd[0]);
505 memset(req->cmd, 0, BLK_MAX_CDB);
506 memcpy(req->cmd, cmd, req->cmd_len);
507 req->sense = SRpnt->sense;
508 req->sense_len = 0;
509 req->timeout = timeout;
510 req->retries = retries;
511 req->end_io_data = SRpnt;
512
513 blk_execute_rq_nowait(req->q, NULL, req, 1, st_scsi_execute_end);
514 return 0;
515}
516
478/* Do the scsi command. Waits until command performed if do_wait is true. 517/* Do the scsi command. Waits until command performed if do_wait is true.
479 Otherwise write_behind_check() is used to check that the command 518 Otherwise write_behind_check() is used to check that the command
480 has finished. */ 519 has finished. */
@@ -483,6 +522,8 @@ st_do_scsi(struct st_request * SRpnt, struct scsi_tape * STp, unsigned char *cmd
483 int bytes, int direction, int timeout, int retries, int do_wait) 522 int bytes, int direction, int timeout, int retries, int do_wait)
484{ 523{
485 struct completion *waiting; 524 struct completion *waiting;
525 struct rq_map_data *mdata = &STp->buffer->map_data;
526 int ret;
486 527
487 /* if async, make sure there's no command outstanding */ 528 /* if async, make sure there's no command outstanding */
488 if (!do_wait && ((STp->buffer)->last_SRpnt)) { 529 if (!do_wait && ((STp->buffer)->last_SRpnt)) {
@@ -510,21 +551,27 @@ st_do_scsi(struct st_request * SRpnt, struct scsi_tape * STp, unsigned char *cmd
510 init_completion(waiting); 551 init_completion(waiting);
511 SRpnt->waiting = waiting; 552 SRpnt->waiting = waiting;
512 553
513 if (!STp->buffer->do_dio) 554 if (STp->buffer->do_dio) {
514 buf_to_sg(STp->buffer, bytes); 555 mdata->nr_entries = STp->buffer->sg_segs;
556 mdata->pages = STp->buffer->mapped_pages;
557 } else {
558 mdata->nr_entries =
559 DIV_ROUND_UP(bytes, PAGE_SIZE << mdata->page_order);
560 STp->buffer->map_data.pages = STp->buffer->reserved_pages;
561 STp->buffer->map_data.offset = 0;
562 }
515 563
516 memcpy(SRpnt->cmd, cmd, sizeof(SRpnt->cmd)); 564 memcpy(SRpnt->cmd, cmd, sizeof(SRpnt->cmd));
517 STp->buffer->cmdstat.have_sense = 0; 565 STp->buffer->cmdstat.have_sense = 0;
518 STp->buffer->syscall_result = 0; 566 STp->buffer->syscall_result = 0;
519 567
520 if (scsi_execute_async(STp->device, cmd, COMMAND_SIZE(cmd[0]), direction, 568 ret = st_scsi_execute(SRpnt, cmd, direction, NULL, bytes, timeout,
521 &((STp->buffer)->sg[0]), bytes, (STp->buffer)->sg_segs, 569 retries);
522 timeout, retries, SRpnt, st_sleep_done, GFP_KERNEL)) { 570 if (ret) {
523 /* could not allocate the buffer or request was too large */ 571 /* could not allocate the buffer or request was too large */
524 (STp->buffer)->syscall_result = (-EBUSY); 572 (STp->buffer)->syscall_result = (-EBUSY);
525 (STp->buffer)->last_SRpnt = NULL; 573 (STp->buffer)->last_SRpnt = NULL;
526 } 574 } else if (do_wait) {
527 else if (do_wait) {
528 wait_for_completion(waiting); 575 wait_for_completion(waiting);
529 SRpnt->waiting = NULL; 576 SRpnt->waiting = NULL;
530 (STp->buffer)->syscall_result = st_chk_result(STp, SRpnt); 577 (STp->buffer)->syscall_result = st_chk_result(STp, SRpnt);
@@ -533,28 +580,6 @@ st_do_scsi(struct st_request * SRpnt, struct scsi_tape * STp, unsigned char *cmd
533 return SRpnt; 580 return SRpnt;
534} 581}
535 582
536static int st_scsi_kern_execute(struct st_request *streq,
537 const unsigned char *cmd, int data_direction,
538 void *buffer, unsigned bufflen, int timeout,
539 int retries)
540{
541 struct scsi_tape *stp = streq->stp;
542 int ret, resid;
543
544 stp->buffer->cmdstat.have_sense = 0;
545 memcpy(streq->cmd, cmd, sizeof(streq->cmd));
546
547 ret = scsi_execute(stp->device, cmd, data_direction, buffer, bufflen,
548 streq->sense, timeout, retries, 0, &resid);
549 if (driver_byte(ret) & DRIVER_ERROR)
550 return -EBUSY;
551
552 stp->buffer->cmdstat.midlevel_result = streq->result = ret;
553 stp->buffer->cmdstat.residual = resid;
554 stp->buffer->syscall_result = st_chk_result(stp, streq);
555
556 return 0;
557}
558 583
559/* Handle the write-behind checking (waits for completion). Returns -ENOSPC if 584/* Handle the write-behind checking (waits for completion). Returns -ENOSPC if
560 write has been correct but EOM early warning reached, -EIO if write ended in 585 write has been correct but EOM early warning reached, -EIO if write ended in
@@ -627,7 +652,6 @@ static int cross_eof(struct scsi_tape * STp, int forward)
627{ 652{
628 struct st_request *SRpnt; 653 struct st_request *SRpnt;
629 unsigned char cmd[MAX_COMMAND_SIZE]; 654 unsigned char cmd[MAX_COMMAND_SIZE];
630 int ret;
631 655
632 cmd[0] = SPACE; 656 cmd[0] = SPACE;
633 cmd[1] = 0x01; /* Space FileMarks */ 657 cmd[1] = 0x01; /* Space FileMarks */
@@ -641,26 +665,20 @@ static int cross_eof(struct scsi_tape * STp, int forward)
641 DEBC(printk(ST_DEB_MSG "%s: Stepping over filemark %s.\n", 665 DEBC(printk(ST_DEB_MSG "%s: Stepping over filemark %s.\n",
642 tape_name(STp), forward ? "forward" : "backward")); 666 tape_name(STp), forward ? "forward" : "backward"));
643 667
644 SRpnt = st_allocate_request(STp); 668 SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE,
669 STp->device->request_queue->rq_timeout,
670 MAX_RETRIES, 1);
645 if (!SRpnt) 671 if (!SRpnt)
646 return STp->buffer->syscall_result; 672 return (STp->buffer)->syscall_result;
647
648 ret = st_scsi_kern_execute(SRpnt, cmd, DMA_NONE, NULL, 0,
649 STp->device->request_queue->rq_timeout,
650 MAX_RETRIES);
651 if (ret)
652 goto out;
653 673
654 ret = STp->buffer->syscall_result; 674 st_release_request(SRpnt);
675 SRpnt = NULL;
655 676
656 if ((STp->buffer)->cmdstat.midlevel_result != 0) 677 if ((STp->buffer)->cmdstat.midlevel_result != 0)
657 printk(KERN_ERR "%s: Stepping over filemark %s failed.\n", 678 printk(KERN_ERR "%s: Stepping over filemark %s failed.\n",
658 tape_name(STp), forward ? "forward" : "backward"); 679 tape_name(STp), forward ? "forward" : "backward");
659 680
660out: 681 return (STp->buffer)->syscall_result;
661 st_release_request(SRpnt);
662
663 return ret;
664} 682}
665 683
666 684
@@ -881,24 +899,21 @@ static int test_ready(struct scsi_tape *STp, int do_wait)
881 int attentions, waits, max_wait, scode; 899 int attentions, waits, max_wait, scode;
882 int retval = CHKRES_READY, new_session = 0; 900 int retval = CHKRES_READY, new_session = 0;
883 unsigned char cmd[MAX_COMMAND_SIZE]; 901 unsigned char cmd[MAX_COMMAND_SIZE];
884 struct st_request *SRpnt; 902 struct st_request *SRpnt = NULL;
885 struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; 903 struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat;
886 904
887 SRpnt = st_allocate_request(STp);
888 if (!SRpnt)
889 return STp->buffer->syscall_result;
890
891 max_wait = do_wait ? ST_BLOCK_SECONDS : 0; 905 max_wait = do_wait ? ST_BLOCK_SECONDS : 0;
892 906
893 for (attentions=waits=0; ; ) { 907 for (attentions=waits=0; ; ) {
894 memset((void *) &cmd[0], 0, MAX_COMMAND_SIZE); 908 memset((void *) &cmd[0], 0, MAX_COMMAND_SIZE);
895 cmd[0] = TEST_UNIT_READY; 909 cmd[0] = TEST_UNIT_READY;
910 SRpnt = st_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE,
911 STp->long_timeout, MAX_READY_RETRIES, 1);
896 912
897 retval = st_scsi_kern_execute(SRpnt, cmd, DMA_NONE, NULL, 0, 913 if (!SRpnt) {
898 STp->long_timeout, 914 retval = (STp->buffer)->syscall_result;
899 MAX_READY_RETRIES);
900 if (retval)
901 break; 915 break;
916 }
902 917
903 if (cmdstatp->have_sense) { 918 if (cmdstatp->have_sense) {
904 919
@@ -942,8 +957,8 @@ static int test_ready(struct scsi_tape *STp, int do_wait)
942 break; 957 break;
943 } 958 }
944 959
945 st_release_request(SRpnt); 960 if (SRpnt != NULL)
946 961 st_release_request(SRpnt);
947 return retval; 962 return retval;
948} 963}
949 964
@@ -1020,24 +1035,17 @@ static int check_tape(struct scsi_tape *STp, struct file *filp)
1020 } 1035 }
1021 } 1036 }
1022 1037
1023 SRpnt = st_allocate_request(STp);
1024 if (!SRpnt) {
1025 retval = STp->buffer->syscall_result;
1026 goto err_out;
1027 }
1028
1029 if (STp->omit_blklims) 1038 if (STp->omit_blklims)
1030 STp->min_block = STp->max_block = (-1); 1039 STp->min_block = STp->max_block = (-1);
1031 else { 1040 else {
1032 memset((void *) &cmd[0], 0, MAX_COMMAND_SIZE); 1041 memset((void *) &cmd[0], 0, MAX_COMMAND_SIZE);
1033 cmd[0] = READ_BLOCK_LIMITS; 1042 cmd[0] = READ_BLOCK_LIMITS;
1034 1043
1035 retval = st_scsi_kern_execute(SRpnt, cmd, DMA_FROM_DEVICE, 1044 SRpnt = st_do_scsi(SRpnt, STp, cmd, 6, DMA_FROM_DEVICE,
1036 STp->buffer->b_data, 6, 1045 STp->device->request_queue->rq_timeout,
1037 STp->device->request_queue->rq_timeout, 1046 MAX_READY_RETRIES, 1);
1038 MAX_READY_RETRIES); 1047 if (!SRpnt) {
1039 if (retval) { 1048 retval = (STp->buffer)->syscall_result;
1040 st_release_request(SRpnt);
1041 goto err_out; 1049 goto err_out;
1042 } 1050 }
1043 1051
@@ -1061,12 +1069,11 @@ static int check_tape(struct scsi_tape *STp, struct file *filp)
1061 cmd[0] = MODE_SENSE; 1069 cmd[0] = MODE_SENSE;
1062 cmd[4] = 12; 1070 cmd[4] = 12;
1063 1071
1064 retval = st_scsi_kern_execute(SRpnt, cmd, DMA_FROM_DEVICE, 1072 SRpnt = st_do_scsi(SRpnt, STp, cmd, 12, DMA_FROM_DEVICE,
1065 STp->buffer->b_data, 12, 1073 STp->device->request_queue->rq_timeout,
1066 STp->device->request_queue->rq_timeout, 1074 MAX_READY_RETRIES, 1);
1067 MAX_READY_RETRIES); 1075 if (!SRpnt) {
1068 if (retval) { 1076 retval = (STp->buffer)->syscall_result;
1069 st_release_request(SRpnt);
1070 goto err_out; 1077 goto err_out;
1071 } 1078 }
1072 1079
@@ -1296,17 +1303,11 @@ static int st_flush(struct file *filp, fl_owner_t id)
1296 cmd[0] = WRITE_FILEMARKS; 1303 cmd[0] = WRITE_FILEMARKS;
1297 cmd[4] = 1 + STp->two_fm; 1304 cmd[4] = 1 + STp->two_fm;
1298 1305
1299 SRpnt = st_allocate_request(STp); 1306 SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE,
1307 STp->device->request_queue->rq_timeout,
1308 MAX_WRITE_RETRIES, 1);
1300 if (!SRpnt) { 1309 if (!SRpnt) {
1301 result = STp->buffer->syscall_result; 1310 result = (STp->buffer)->syscall_result;
1302 goto out;
1303 }
1304
1305 result = st_scsi_kern_execute(SRpnt, cmd, DMA_NONE, NULL, 0,
1306 STp->device->request_queue->rq_timeout,
1307 MAX_WRITE_RETRIES);
1308 if (result) {
1309 st_release_request(SRpnt);
1310 goto out; 1311 goto out;
1311 } 1312 }
1312 1313
@@ -1471,8 +1472,8 @@ static int setup_buffering(struct scsi_tape *STp, const char __user *buf,
1471 1472
1472 if (i && ((unsigned long)buf & queue_dma_alignment( 1473 if (i && ((unsigned long)buf & queue_dma_alignment(
1473 STp->device->request_queue)) == 0) { 1474 STp->device->request_queue)) == 0) {
1474 i = sgl_map_user_pages(&(STbp->sg[0]), STbp->use_sg, 1475 i = sgl_map_user_pages(STbp, STbp->use_sg, (unsigned long)buf,
1475 (unsigned long)buf, count, (is_read ? READ : WRITE)); 1476 count, (is_read ? READ : WRITE));
1476 if (i > 0) { 1477 if (i > 0) {
1477 STbp->do_dio = i; 1478 STbp->do_dio = i;
1478 STbp->buffer_bytes = 0; /* can be used as transfer counter */ 1479 STbp->buffer_bytes = 0; /* can be used as transfer counter */
@@ -1480,7 +1481,6 @@ static int setup_buffering(struct scsi_tape *STp, const char __user *buf,
1480 else 1481 else
1481 STbp->do_dio = 0; /* fall back to buffering with any error */ 1482 STbp->do_dio = 0; /* fall back to buffering with any error */
1482 STbp->sg_segs = STbp->do_dio; 1483 STbp->sg_segs = STbp->do_dio;
1483 STbp->frp_sg_current = 0;
1484 DEB( 1484 DEB(
1485 if (STbp->do_dio) { 1485 if (STbp->do_dio) {
1486 STp->nbr_dio++; 1486 STp->nbr_dio++;
@@ -1526,7 +1526,7 @@ static void release_buffering(struct scsi_tape *STp, int is_read)
1526 1526
1527 STbp = STp->buffer; 1527 STbp = STp->buffer;
1528 if (STbp->do_dio) { 1528 if (STbp->do_dio) {
1529 sgl_unmap_user_pages(&(STbp->sg[0]), STbp->do_dio, is_read); 1529 sgl_unmap_user_pages(STbp, STbp->do_dio, is_read);
1530 STbp->do_dio = 0; 1530 STbp->do_dio = 0;
1531 STbp->sg_segs = 0; 1531 STbp->sg_segs = 0;
1532 } 1532 }
@@ -2372,7 +2372,6 @@ static int read_mode_page(struct scsi_tape *STp, int page, int omit_block_descs)
2372{ 2372{
2373 unsigned char cmd[MAX_COMMAND_SIZE]; 2373 unsigned char cmd[MAX_COMMAND_SIZE];
2374 struct st_request *SRpnt; 2374 struct st_request *SRpnt;
2375 int ret;
2376 2375
2377 memset(cmd, 0, MAX_COMMAND_SIZE); 2376 memset(cmd, 0, MAX_COMMAND_SIZE);
2378 cmd[0] = MODE_SENSE; 2377 cmd[0] = MODE_SENSE;
@@ -2381,17 +2380,14 @@ static int read_mode_page(struct scsi_tape *STp, int page, int omit_block_descs)
2381 cmd[2] = page; 2380 cmd[2] = page;
2382 cmd[4] = 255; 2381 cmd[4] = 255;
2383 2382
2384 SRpnt = st_allocate_request(STp); 2383 SRpnt = st_do_scsi(NULL, STp, cmd, cmd[4], DMA_FROM_DEVICE,
2385 if (!SRpnt) 2384 STp->device->request_queue->rq_timeout, 0, 1);
2386 return STp->buffer->syscall_result; 2385 if (SRpnt == NULL)
2386 return (STp->buffer)->syscall_result;
2387 2387
2388 ret = st_scsi_kern_execute(SRpnt, cmd, DMA_FROM_DEVICE,
2389 STp->buffer->b_data, cmd[4],
2390 STp->device->request_queue->rq_timeout,
2391 MAX_RETRIES);
2392 st_release_request(SRpnt); 2388 st_release_request(SRpnt);
2393 2389
2394 return ret ? : STp->buffer->syscall_result; 2390 return STp->buffer->syscall_result;
2395} 2391}
2396 2392
2397 2393
@@ -2399,9 +2395,10 @@ static int read_mode_page(struct scsi_tape *STp, int page, int omit_block_descs)
2399 in the buffer is correctly formatted. The long timeout is used if slow is non-zero. */ 2395 in the buffer is correctly formatted. The long timeout is used if slow is non-zero. */
2400static int write_mode_page(struct scsi_tape *STp, int page, int slow) 2396static int write_mode_page(struct scsi_tape *STp, int page, int slow)
2401{ 2397{
2402 int pgo, timeout, ret = 0; 2398 int pgo;
2403 unsigned char cmd[MAX_COMMAND_SIZE]; 2399 unsigned char cmd[MAX_COMMAND_SIZE];
2404 struct st_request *SRpnt; 2400 struct st_request *SRpnt;
2401 int timeout;
2405 2402
2406 memset(cmd, 0, MAX_COMMAND_SIZE); 2403 memset(cmd, 0, MAX_COMMAND_SIZE);
2407 cmd[0] = MODE_SELECT; 2404 cmd[0] = MODE_SELECT;
@@ -2415,21 +2412,16 @@ static int write_mode_page(struct scsi_tape *STp, int page, int slow)
2415 (STp->buffer)->b_data[MH_OFF_DEV_SPECIFIC] &= ~MH_BIT_WP; 2412 (STp->buffer)->b_data[MH_OFF_DEV_SPECIFIC] &= ~MH_BIT_WP;
2416 (STp->buffer)->b_data[pgo + MP_OFF_PAGE_NBR] &= MP_MSK_PAGE_NBR; 2413 (STp->buffer)->b_data[pgo + MP_OFF_PAGE_NBR] &= MP_MSK_PAGE_NBR;
2417 2414
2418 SRpnt = st_allocate_request(STp); 2415 timeout = slow ?
2419 if (!SRpnt) 2416 STp->long_timeout : STp->device->request_queue->rq_timeout;
2420 return ret; 2417 SRpnt = st_do_scsi(NULL, STp, cmd, cmd[4], DMA_TO_DEVICE,
2421 2418 timeout, 0, 1);
2422 timeout = slow ? STp->long_timeout : 2419 if (SRpnt == NULL)
2423 STp->device->request_queue->rq_timeout; 2420 return (STp->buffer)->syscall_result;
2424
2425 ret = st_scsi_kern_execute(SRpnt, cmd, DMA_TO_DEVICE,
2426 STp->buffer->b_data, cmd[4], timeout, 0);
2427 if (!ret)
2428 ret = STp->buffer->syscall_result;
2429 2421
2430 st_release_request(SRpnt); 2422 st_release_request(SRpnt);
2431 2423
2432 return ret; 2424 return STp->buffer->syscall_result;
2433} 2425}
2434 2426
2435 2427
@@ -2547,16 +2539,13 @@ static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_cod
2547 printk(ST_DEB_MSG "%s: Loading tape.\n", name); 2539 printk(ST_DEB_MSG "%s: Loading tape.\n", name);
2548 ); 2540 );
2549 2541
2550 SRpnt = st_allocate_request(STp); 2542 SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE,
2543 timeout, MAX_RETRIES, 1);
2551 if (!SRpnt) 2544 if (!SRpnt)
2552 return STp->buffer->syscall_result; 2545 return (STp->buffer)->syscall_result;
2553
2554 retval = st_scsi_kern_execute(SRpnt, cmd, DMA_NONE, NULL, 0, timeout,
2555 MAX_RETRIES);
2556 if (retval)
2557 goto out;
2558 2546
2559 retval = (STp->buffer)->syscall_result; 2547 retval = (STp->buffer)->syscall_result;
2548 st_release_request(SRpnt);
2560 2549
2561 if (!retval) { /* SCSI command successful */ 2550 if (!retval) { /* SCSI command successful */
2562 2551
@@ -2575,8 +2564,6 @@ static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_cod
2575 STps = &(STp->ps[STp->partition]); 2564 STps = &(STp->ps[STp->partition]);
2576 STps->drv_file = STps->drv_block = (-1); 2565 STps->drv_file = STps->drv_block = (-1);
2577 } 2566 }
2578out:
2579 st_release_request(SRpnt);
2580 2567
2581 return retval; 2568 return retval;
2582} 2569}
@@ -2852,15 +2839,12 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
2852 return (-ENOSYS); 2839 return (-ENOSYS);
2853 } 2840 }
2854 2841
2855 SRpnt = st_allocate_request(STp); 2842 SRpnt = st_do_scsi(NULL, STp, cmd, datalen, direction,
2843 timeout, MAX_RETRIES, 1);
2856 if (!SRpnt) 2844 if (!SRpnt)
2857 return (STp->buffer)->syscall_result; 2845 return (STp->buffer)->syscall_result;
2858 2846
2859 ioctl_result = st_scsi_kern_execute(SRpnt, cmd, direction, 2847 ioctl_result = (STp->buffer)->syscall_result;
2860 STp->buffer->b_data, datalen,
2861 timeout, MAX_RETRIES);
2862 if (!ioctl_result)
2863 ioctl_result = (STp->buffer)->syscall_result;
2864 2848
2865 if (!ioctl_result) { /* SCSI command successful */ 2849 if (!ioctl_result) { /* SCSI command successful */
2866 st_release_request(SRpnt); 2850 st_release_request(SRpnt);
@@ -3022,17 +3006,11 @@ static int get_location(struct scsi_tape *STp, unsigned int *block, int *partiti
3022 if (!logical && !STp->scsi2_logical) 3006 if (!logical && !STp->scsi2_logical)
3023 scmd[1] = 1; 3007 scmd[1] = 1;
3024 } 3008 }
3025 3009 SRpnt = st_do_scsi(NULL, STp, scmd, 20, DMA_FROM_DEVICE,
3026 SRpnt = st_allocate_request(STp); 3010 STp->device->request_queue->rq_timeout,
3011 MAX_READY_RETRIES, 1);
3027 if (!SRpnt) 3012 if (!SRpnt)
3028 return STp->buffer->syscall_result; 3013 return (STp->buffer)->syscall_result;
3029
3030 result = st_scsi_kern_execute(SRpnt, scmd, DMA_FROM_DEVICE,
3031 STp->buffer->b_data, 20,
3032 STp->device->request_queue->rq_timeout,
3033 MAX_READY_RETRIES);
3034 if (result)
3035 goto out;
3036 3014
3037 if ((STp->buffer)->syscall_result != 0 || 3015 if ((STp->buffer)->syscall_result != 0 ||
3038 (STp->device->scsi_level >= SCSI_2 && 3016 (STp->device->scsi_level >= SCSI_2 &&
@@ -3060,7 +3038,6 @@ static int get_location(struct scsi_tape *STp, unsigned int *block, int *partiti
3060 DEBC(printk(ST_DEB_MSG "%s: Got tape pos. blk %d part %d.\n", name, 3038 DEBC(printk(ST_DEB_MSG "%s: Got tape pos. blk %d part %d.\n", name,
3061 *block, *partition)); 3039 *block, *partition));
3062 } 3040 }
3063out:
3064 st_release_request(SRpnt); 3041 st_release_request(SRpnt);
3065 SRpnt = NULL; 3042 SRpnt = NULL;
3066 3043
@@ -3135,14 +3112,10 @@ static int set_location(struct scsi_tape *STp, unsigned int block, int partition
3135 timeout = STp->device->request_queue->rq_timeout; 3112 timeout = STp->device->request_queue->rq_timeout;
3136 } 3113 }
3137 3114
3138 SRpnt = st_allocate_request(STp); 3115 SRpnt = st_do_scsi(NULL, STp, scmd, 0, DMA_NONE,
3116 timeout, MAX_READY_RETRIES, 1);
3139 if (!SRpnt) 3117 if (!SRpnt)
3140 return STp->buffer->syscall_result; 3118 return (STp->buffer)->syscall_result;
3141
3142 result = st_scsi_kern_execute(SRpnt, scmd, DMA_NONE, NULL, 0,
3143 timeout, MAX_READY_RETRIES);
3144 if (result)
3145 goto out;
3146 3119
3147 STps->drv_block = STps->drv_file = (-1); 3120 STps->drv_block = STps->drv_file = (-1);
3148 STps->eof = ST_NOEOF; 3121 STps->eof = ST_NOEOF;
@@ -3167,7 +3140,7 @@ static int set_location(struct scsi_tape *STp, unsigned int block, int partition
3167 STps->drv_block = STps->drv_file = 0; 3140 STps->drv_block = STps->drv_file = 0;
3168 result = 0; 3141 result = 0;
3169 } 3142 }
3170out: 3143
3171 st_release_request(SRpnt); 3144 st_release_request(SRpnt);
3172 SRpnt = NULL; 3145 SRpnt = NULL;
3173 3146
@@ -3696,38 +3669,34 @@ static long st_compat_ioctl(struct file *file, unsigned int cmd, unsigned long a
3696 3669
3697/* Try to allocate a new tape buffer. Calling function must not hold 3670/* Try to allocate a new tape buffer. Calling function must not hold
3698 dev_arr_lock. */ 3671 dev_arr_lock. */
3699static struct st_buffer * 3672static struct st_buffer *new_tape_buffer(int need_dma, int max_sg)
3700 new_tape_buffer(int from_initialization, int need_dma, int max_sg)
3701{ 3673{
3702 int i, got = 0;
3703 gfp_t priority;
3704 struct st_buffer *tb; 3674 struct st_buffer *tb;
3705 3675
3706 if (from_initialization) 3676 tb = kzalloc(sizeof(struct st_buffer), GFP_ATOMIC);
3707 priority = GFP_ATOMIC;
3708 else
3709 priority = GFP_KERNEL;
3710
3711 i = sizeof(struct st_buffer) + (max_sg - 1) * sizeof(struct scatterlist) +
3712 max_sg * sizeof(struct st_buf_fragment);
3713 tb = kzalloc(i, priority);
3714 if (!tb) { 3677 if (!tb) {
3715 printk(KERN_NOTICE "st: Can't allocate new tape buffer.\n"); 3678 printk(KERN_NOTICE "st: Can't allocate new tape buffer.\n");
3716 return NULL; 3679 return NULL;
3717 } 3680 }
3718 tb->frp_segs = tb->orig_frp_segs = 0; 3681 tb->frp_segs = 0;
3719 tb->use_sg = max_sg; 3682 tb->use_sg = max_sg;
3720 tb->frp = (struct st_buf_fragment *)(&(tb->sg[0]) + max_sg);
3721
3722 tb->dma = need_dma; 3683 tb->dma = need_dma;
3723 tb->buffer_size = got; 3684 tb->buffer_size = 0;
3724 sg_init_table(tb->sg, max_sg); 3685
3686 tb->reserved_pages = kzalloc(max_sg * sizeof(struct page *),
3687 GFP_ATOMIC);
3688 if (!tb->reserved_pages) {
3689 kfree(tb);
3690 return NULL;
3691 }
3725 3692
3726 return tb; 3693 return tb;
3727} 3694}
3728 3695
3729 3696
3730/* Try to allocate enough space in the tape buffer */ 3697/* Try to allocate enough space in the tape buffer */
3698#define ST_MAX_ORDER 6
3699
3731static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dma) 3700static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dma)
3732{ 3701{
3733 int segs, nbr, max_segs, b_size, order, got; 3702 int segs, nbr, max_segs, b_size, order, got;
@@ -3747,33 +3716,45 @@ static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dm
3747 priority = GFP_KERNEL | __GFP_NOWARN; 3716 priority = GFP_KERNEL | __GFP_NOWARN;
3748 if (need_dma) 3717 if (need_dma)
3749 priority |= GFP_DMA; 3718 priority |= GFP_DMA;
3750 for (b_size = PAGE_SIZE, order=0; order <= 6 && 3719
3751 b_size < new_size - STbuffer->buffer_size; 3720 if (STbuffer->cleared)
3752 order++, b_size *= 2) 3721 priority |= __GFP_ZERO;
3753 ; /* empty */ 3722
3723 if (STbuffer->frp_segs) {
3724 order = STbuffer->map_data.page_order;
3725 b_size = PAGE_SIZE << order;
3726 } else {
3727 for (b_size = PAGE_SIZE, order = 0;
3728 order < ST_MAX_ORDER && b_size < new_size;
3729 order++, b_size *= 2)
3730 ; /* empty */
3731 }
3732 if (max_segs * (PAGE_SIZE << order) < new_size) {
3733 if (order == ST_MAX_ORDER)
3734 return 0;
3735 normalize_buffer(STbuffer);
3736 return enlarge_buffer(STbuffer, new_size, need_dma);
3737 }
3754 3738
3755 for (segs = STbuffer->frp_segs, got = STbuffer->buffer_size; 3739 for (segs = STbuffer->frp_segs, got = STbuffer->buffer_size;
3756 segs < max_segs && got < new_size;) { 3740 segs < max_segs && got < new_size;) {
3757 STbuffer->frp[segs].page = alloc_pages(priority, order); 3741 struct page *page;
3758 if (STbuffer->frp[segs].page == NULL) { 3742
3759 if (new_size - got <= (max_segs - segs) * b_size / 2) { 3743 page = alloc_pages(priority, order);
3760 b_size /= 2; /* Large enough for the rest of the buffers */ 3744 if (!page) {
3761 order--;
3762 continue;
3763 }
3764 DEB(STbuffer->buffer_size = got); 3745 DEB(STbuffer->buffer_size = got);
3765 normalize_buffer(STbuffer); 3746 normalize_buffer(STbuffer);
3766 return 0; 3747 return 0;
3767 } 3748 }
3768 STbuffer->frp[segs].length = b_size; 3749
3769 STbuffer->frp_segs += 1; 3750 STbuffer->frp_segs += 1;
3770 got += b_size; 3751 got += b_size;
3771 STbuffer->buffer_size = got; 3752 STbuffer->buffer_size = got;
3772 if (STbuffer->cleared) 3753 STbuffer->reserved_pages[segs] = page;
3773 memset(page_address(STbuffer->frp[segs].page), 0, b_size);
3774 segs++; 3754 segs++;
3775 } 3755 }
3776 STbuffer->b_data = page_address(STbuffer->frp[0].page); 3756 STbuffer->b_data = page_address(STbuffer->reserved_pages[0]);
3757 STbuffer->map_data.page_order = order;
3777 3758
3778 return 1; 3759 return 1;
3779} 3760}
@@ -3785,7 +3766,8 @@ static void clear_buffer(struct st_buffer * st_bp)
3785 int i; 3766 int i;
3786 3767
3787 for (i=0; i < st_bp->frp_segs; i++) 3768 for (i=0; i < st_bp->frp_segs; i++)
3788 memset(page_address(st_bp->frp[i].page), 0, st_bp->frp[i].length); 3769 memset(page_address(st_bp->reserved_pages[i]), 0,
3770 PAGE_SIZE << st_bp->map_data.page_order);
3789 st_bp->cleared = 1; 3771 st_bp->cleared = 1;
3790} 3772}
3791 3773
@@ -3793,16 +3775,16 @@ static void clear_buffer(struct st_buffer * st_bp)
3793/* Release the extra buffer */ 3775/* Release the extra buffer */
3794static void normalize_buffer(struct st_buffer * STbuffer) 3776static void normalize_buffer(struct st_buffer * STbuffer)
3795{ 3777{
3796 int i, order; 3778 int i, order = STbuffer->map_data.page_order;
3797 3779
3798 for (i = STbuffer->orig_frp_segs; i < STbuffer->frp_segs; i++) { 3780 for (i = 0; i < STbuffer->frp_segs; i++) {
3799 order = get_order(STbuffer->frp[i].length); 3781 __free_pages(STbuffer->reserved_pages[i], order);
3800 __free_pages(STbuffer->frp[i].page, order); 3782 STbuffer->buffer_size -= (PAGE_SIZE << order);
3801 STbuffer->buffer_size -= STbuffer->frp[i].length;
3802 } 3783 }
3803 STbuffer->frp_segs = STbuffer->orig_frp_segs; 3784 STbuffer->frp_segs = 0;
3804 STbuffer->frp_sg_current = 0;
3805 STbuffer->sg_segs = 0; 3785 STbuffer->sg_segs = 0;
3786 STbuffer->map_data.page_order = 0;
3787 STbuffer->map_data.offset = 0;
3806} 3788}
3807 3789
3808 3790
@@ -3811,18 +3793,19 @@ static void normalize_buffer(struct st_buffer * STbuffer)
3811static int append_to_buffer(const char __user *ubp, struct st_buffer * st_bp, int do_count) 3793static int append_to_buffer(const char __user *ubp, struct st_buffer * st_bp, int do_count)
3812{ 3794{
3813 int i, cnt, res, offset; 3795 int i, cnt, res, offset;
3796 int length = PAGE_SIZE << st_bp->map_data.page_order;
3814 3797
3815 for (i = 0, offset = st_bp->buffer_bytes; 3798 for (i = 0, offset = st_bp->buffer_bytes;
3816 i < st_bp->frp_segs && offset >= st_bp->frp[i].length; i++) 3799 i < st_bp->frp_segs && offset >= length; i++)
3817 offset -= st_bp->frp[i].length; 3800 offset -= length;
3818 if (i == st_bp->frp_segs) { /* Should never happen */ 3801 if (i == st_bp->frp_segs) { /* Should never happen */
3819 printk(KERN_WARNING "st: append_to_buffer offset overflow.\n"); 3802 printk(KERN_WARNING "st: append_to_buffer offset overflow.\n");
3820 return (-EIO); 3803 return (-EIO);
3821 } 3804 }
3822 for (; i < st_bp->frp_segs && do_count > 0; i++) { 3805 for (; i < st_bp->frp_segs && do_count > 0; i++) {
3823 cnt = st_bp->frp[i].length - offset < do_count ? 3806 struct page *page = st_bp->reserved_pages[i];
3824 st_bp->frp[i].length - offset : do_count; 3807 cnt = length - offset < do_count ? length - offset : do_count;
3825 res = copy_from_user(page_address(st_bp->frp[i].page) + offset, ubp, cnt); 3808 res = copy_from_user(page_address(page) + offset, ubp, cnt);
3826 if (res) 3809 if (res)
3827 return (-EFAULT); 3810 return (-EFAULT);
3828 do_count -= cnt; 3811 do_count -= cnt;
@@ -3842,18 +3825,19 @@ static int append_to_buffer(const char __user *ubp, struct st_buffer * st_bp, in
3842static int from_buffer(struct st_buffer * st_bp, char __user *ubp, int do_count) 3825static int from_buffer(struct st_buffer * st_bp, char __user *ubp, int do_count)
3843{ 3826{
3844 int i, cnt, res, offset; 3827 int i, cnt, res, offset;
3828 int length = PAGE_SIZE << st_bp->map_data.page_order;
3845 3829
3846 for (i = 0, offset = st_bp->read_pointer; 3830 for (i = 0, offset = st_bp->read_pointer;
3847 i < st_bp->frp_segs && offset >= st_bp->frp[i].length; i++) 3831 i < st_bp->frp_segs && offset >= length; i++)
3848 offset -= st_bp->frp[i].length; 3832 offset -= length;
3849 if (i == st_bp->frp_segs) { /* Should never happen */ 3833 if (i == st_bp->frp_segs) { /* Should never happen */
3850 printk(KERN_WARNING "st: from_buffer offset overflow.\n"); 3834 printk(KERN_WARNING "st: from_buffer offset overflow.\n");
3851 return (-EIO); 3835 return (-EIO);
3852 } 3836 }
3853 for (; i < st_bp->frp_segs && do_count > 0; i++) { 3837 for (; i < st_bp->frp_segs && do_count > 0; i++) {
3854 cnt = st_bp->frp[i].length - offset < do_count ? 3838 struct page *page = st_bp->reserved_pages[i];
3855 st_bp->frp[i].length - offset : do_count; 3839 cnt = length - offset < do_count ? length - offset : do_count;
3856 res = copy_to_user(ubp, page_address(st_bp->frp[i].page) + offset, cnt); 3840 res = copy_to_user(ubp, page_address(page) + offset, cnt);
3857 if (res) 3841 if (res)
3858 return (-EFAULT); 3842 return (-EFAULT);
3859 do_count -= cnt; 3843 do_count -= cnt;
@@ -3874,6 +3858,7 @@ static void move_buffer_data(struct st_buffer * st_bp, int offset)
3874{ 3858{
3875 int src_seg, dst_seg, src_offset = 0, dst_offset; 3859 int src_seg, dst_seg, src_offset = 0, dst_offset;
3876 int count, total; 3860 int count, total;
3861 int length = PAGE_SIZE << st_bp->map_data.page_order;
3877 3862
3878 if (offset == 0) 3863 if (offset == 0)
3879 return; 3864 return;
@@ -3881,24 +3866,26 @@ static void move_buffer_data(struct st_buffer * st_bp, int offset)
3881 total=st_bp->buffer_bytes - offset; 3866 total=st_bp->buffer_bytes - offset;
3882 for (src_seg=0; src_seg < st_bp->frp_segs; src_seg++) { 3867 for (src_seg=0; src_seg < st_bp->frp_segs; src_seg++) {
3883 src_offset = offset; 3868 src_offset = offset;
3884 if (src_offset < st_bp->frp[src_seg].length) 3869 if (src_offset < length)
3885 break; 3870 break;
3886 offset -= st_bp->frp[src_seg].length; 3871 offset -= length;
3887 } 3872 }
3888 3873
3889 st_bp->buffer_bytes = st_bp->read_pointer = total; 3874 st_bp->buffer_bytes = st_bp->read_pointer = total;
3890 for (dst_seg=dst_offset=0; total > 0; ) { 3875 for (dst_seg=dst_offset=0; total > 0; ) {
3891 count = min(st_bp->frp[dst_seg].length - dst_offset, 3876 struct page *dpage = st_bp->reserved_pages[dst_seg];
3892 st_bp->frp[src_seg].length - src_offset); 3877 struct page *spage = st_bp->reserved_pages[src_seg];
3893 memmove(page_address(st_bp->frp[dst_seg].page) + dst_offset, 3878
3894 page_address(st_bp->frp[src_seg].page) + src_offset, count); 3879 count = min(length - dst_offset, length - src_offset);
3880 memmove(page_address(dpage) + dst_offset,
3881 page_address(spage) + src_offset, count);
3895 src_offset += count; 3882 src_offset += count;
3896 if (src_offset >= st_bp->frp[src_seg].length) { 3883 if (src_offset >= length) {
3897 src_seg++; 3884 src_seg++;
3898 src_offset = 0; 3885 src_offset = 0;
3899 } 3886 }
3900 dst_offset += count; 3887 dst_offset += count;
3901 if (dst_offset >= st_bp->frp[dst_seg].length) { 3888 if (dst_offset >= length) {
3902 dst_seg++; 3889 dst_seg++;
3903 dst_offset = 0; 3890 dst_offset = 0;
3904 } 3891 }
@@ -3906,32 +3893,6 @@ static void move_buffer_data(struct st_buffer * st_bp, int offset)
3906 } 3893 }
3907} 3894}
3908 3895
3909
3910/* Fill the s/g list up to the length required for this transfer */
3911static void buf_to_sg(struct st_buffer *STbp, unsigned int length)
3912{
3913 int i;
3914 unsigned int count;
3915 struct scatterlist *sg;
3916 struct st_buf_fragment *frp;
3917
3918 if (length == STbp->frp_sg_current)
3919 return; /* work already done */
3920
3921 sg = &(STbp->sg[0]);
3922 frp = STbp->frp;
3923 for (i=count=0; count < length; i++) {
3924 if (length - count > frp[i].length)
3925 sg_set_page(&sg[i], frp[i].page, frp[i].length, 0);
3926 else
3927 sg_set_page(&sg[i], frp[i].page, length - count, 0);
3928 count += sg[i].length;
3929 }
3930 STbp->sg_segs = i;
3931 STbp->frp_sg_current = length;
3932}
3933
3934
3935/* Validate the options from command line or module parameters */ 3896/* Validate the options from command line or module parameters */
3936static void validate_options(void) 3897static void validate_options(void)
3937{ 3898{
@@ -4026,7 +3987,7 @@ static int st_probe(struct device *dev)
4026 SDp->request_queue->max_phys_segments); 3987 SDp->request_queue->max_phys_segments);
4027 if (st_max_sg_segs < i) 3988 if (st_max_sg_segs < i)
4028 i = st_max_sg_segs; 3989 i = st_max_sg_segs;
4029 buffer = new_tape_buffer(1, (SDp->host)->unchecked_isa_dma, i); 3990 buffer = new_tape_buffer((SDp->host)->unchecked_isa_dma, i);
4030 if (buffer == NULL) { 3991 if (buffer == NULL) {
4031 printk(KERN_ERR 3992 printk(KERN_ERR
4032 "st: Can't allocate new tape buffer. Device not attached.\n"); 3993 "st: Can't allocate new tape buffer. Device not attached.\n");
@@ -4280,8 +4241,8 @@ static void scsi_tape_release(struct kref *kref)
4280 tpnt->device = NULL; 4241 tpnt->device = NULL;
4281 4242
4282 if (tpnt->buffer) { 4243 if (tpnt->buffer) {
4283 tpnt->buffer->orig_frp_segs = 0;
4284 normalize_buffer(tpnt->buffer); 4244 normalize_buffer(tpnt->buffer);
4245 kfree(tpnt->buffer->reserved_pages);
4285 kfree(tpnt->buffer); 4246 kfree(tpnt->buffer);
4286 } 4247 }
4287 4248
@@ -4567,14 +4528,16 @@ out:
4567} 4528}
4568 4529
4569/* The following functions may be useful for a larger audience. */ 4530/* The following functions may be useful for a larger audience. */
4570static int sgl_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages, 4531static int sgl_map_user_pages(struct st_buffer *STbp,
4571 unsigned long uaddr, size_t count, int rw) 4532 const unsigned int max_pages, unsigned long uaddr,
4533 size_t count, int rw)
4572{ 4534{
4573 unsigned long end = (uaddr + count + PAGE_SIZE - 1) >> PAGE_SHIFT; 4535 unsigned long end = (uaddr + count + PAGE_SIZE - 1) >> PAGE_SHIFT;
4574 unsigned long start = uaddr >> PAGE_SHIFT; 4536 unsigned long start = uaddr >> PAGE_SHIFT;
4575 const int nr_pages = end - start; 4537 const int nr_pages = end - start;
4576 int res, i, j; 4538 int res, i, j;
4577 struct page **pages; 4539 struct page **pages;
4540 struct rq_map_data *mdata = &STbp->map_data;
4578 4541
4579 /* User attempted Overflow! */ 4542 /* User attempted Overflow! */
4580 if ((uaddr + count) < uaddr) 4543 if ((uaddr + count) < uaddr)
@@ -4616,24 +4579,11 @@ static int sgl_map_user_pages(struct scatterlist *sgl, const unsigned int max_pa
4616 flush_dcache_page(pages[i]); 4579 flush_dcache_page(pages[i]);
4617 } 4580 }
4618 4581
4619 /* Populate the scatter/gather list */ 4582 mdata->offset = uaddr & ~PAGE_MASK;
4620 sg_set_page(&sgl[0], pages[0], 0, uaddr & ~PAGE_MASK); 4583 mdata->page_order = 0;
4621 if (nr_pages > 1) { 4584 STbp->mapped_pages = pages;
4622 sgl[0].length = PAGE_SIZE - sgl[0].offset;
4623 count -= sgl[0].length;
4624 for (i=1; i < nr_pages ; i++) {
4625 sg_set_page(&sgl[i], pages[i],
4626 count < PAGE_SIZE ? count : PAGE_SIZE, 0);;
4627 count -= PAGE_SIZE;
4628 }
4629 }
4630 else {
4631 sgl[0].length = count;
4632 }
4633 4585
4634 kfree(pages);
4635 return nr_pages; 4586 return nr_pages;
4636
4637 out_unmap: 4587 out_unmap:
4638 if (res > 0) { 4588 if (res > 0) {
4639 for (j=0; j < res; j++) 4589 for (j=0; j < res; j++)
@@ -4646,13 +4596,13 @@ static int sgl_map_user_pages(struct scatterlist *sgl, const unsigned int max_pa
4646 4596
4647 4597
4648/* And unmap them... */ 4598/* And unmap them... */
4649static int sgl_unmap_user_pages(struct scatterlist *sgl, const unsigned int nr_pages, 4599static int sgl_unmap_user_pages(struct st_buffer *STbp,
4650 int dirtied) 4600 const unsigned int nr_pages, int dirtied)
4651{ 4601{
4652 int i; 4602 int i;
4653 4603
4654 for (i=0; i < nr_pages; i++) { 4604 for (i=0; i < nr_pages; i++) {
4655 struct page *page = sg_page(&sgl[i]); 4605 struct page *page = STbp->mapped_pages[i];
4656 4606
4657 if (dirtied) 4607 if (dirtied)
4658 SetPageDirty(page); 4608 SetPageDirty(page);
@@ -4661,6 +4611,8 @@ static int sgl_unmap_user_pages(struct scatterlist *sgl, const unsigned int nr_p
4661 */ 4611 */
4662 page_cache_release(page); 4612 page_cache_release(page);
4663 } 4613 }
4614 kfree(STbp->mapped_pages);
4615 STbp->mapped_pages = NULL;
4664 4616
4665 return 0; 4617 return 0;
4666} 4618}
diff --git a/drivers/scsi/st.h b/drivers/scsi/st.h
index b92712f95931..544dc6b1f548 100644
--- a/drivers/scsi/st.h
+++ b/drivers/scsi/st.h
@@ -29,6 +29,7 @@ struct st_request {
29 int result; 29 int result;
30 struct scsi_tape *stp; 30 struct scsi_tape *stp;
31 struct completion *waiting; 31 struct completion *waiting;
32 struct bio *bio;
32}; 33};
33 34
34/* The tape buffer descriptor. */ 35/* The tape buffer descriptor. */
@@ -44,20 +45,13 @@ struct st_buffer {
44 int syscall_result; 45 int syscall_result;
45 struct st_request *last_SRpnt; 46 struct st_request *last_SRpnt;
46 struct st_cmdstatus cmdstat; 47 struct st_cmdstatus cmdstat;
48 struct page **reserved_pages;
49 struct page **mapped_pages;
50 struct rq_map_data map_data;
47 unsigned char *b_data; 51 unsigned char *b_data;
48 unsigned short use_sg; /* zero or max number of s/g segments for this adapter */ 52 unsigned short use_sg; /* zero or max number of s/g segments for this adapter */
49 unsigned short sg_segs; /* number of segments in s/g list */ 53 unsigned short sg_segs; /* number of segments in s/g list */
50 unsigned short orig_frp_segs; /* number of segments allocated at first try */
51 unsigned short frp_segs; /* number of buffer segments */ 54 unsigned short frp_segs; /* number of buffer segments */
52 unsigned int frp_sg_current; /* driver buffer length currently in s/g list */
53 struct st_buf_fragment *frp; /* the allocated buffer fragment list */
54 struct scatterlist sg[1]; /* MUST BE last item */
55};
56
57/* The tape buffer fragment descriptor */
58struct st_buf_fragment {
59 struct page *page;
60 unsigned int length;
61}; 55};
62 56
63/* The tape mode definition */ 57/* The tape mode definition */
diff --git a/drivers/scsi/zalon.c b/drivers/scsi/zalon.c
index 3c4a300494a4..a8d61a62522e 100644
--- a/drivers/scsi/zalon.c
+++ b/drivers/scsi/zalon.c
@@ -137,8 +137,8 @@ zalon_probe(struct parisc_device *dev)
137 goto fail; 137 goto fail;
138 138
139 if (request_irq(dev->irq, ncr53c8xx_intr, IRQF_SHARED, "zalon", host)) { 139 if (request_irq(dev->irq, ncr53c8xx_intr, IRQF_SHARED, "zalon", host)) {
140 printk(KERN_ERR "%s: irq problem with %d, detaching\n ", 140 dev_printk(KERN_ERR, dev, "irq problem with %d, detaching\n ",
141 dev->dev.bus_id, dev->irq); 141 dev->irq);
142 goto fail; 142 goto fail;
143 } 143 }
144 144
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index daa00567bc44..0d934bfbdd9b 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -2839,6 +2839,8 @@ int __init early_serial_setup(struct uart_port *port)
2839 p->flags = port->flags; 2839 p->flags = port->flags;
2840 p->mapbase = port->mapbase; 2840 p->mapbase = port->mapbase;
2841 p->private_data = port->private_data; 2841 p->private_data = port->private_data;
2842 p->type = port->type;
2843 p->line = port->line;
2842 2844
2843 set_io_from_upio(p); 2845 set_io_from_upio(p);
2844 if (port->serial_in) 2846 if (port->serial_in)
@@ -3123,7 +3125,7 @@ static int __init serial8250_init(void)
3123 if (nr_uarts > UART_NR) 3125 if (nr_uarts > UART_NR)
3124 nr_uarts = UART_NR; 3126 nr_uarts = UART_NR;
3125 3127
3126 printk(KERN_INFO "Serial: 8250/16550 driver" 3128 printk(KERN_INFO "Serial: 8250/16550 driver, "
3127 "%d ports, IRQ sharing %sabled\n", nr_uarts, 3129 "%d ports, IRQ sharing %sabled\n", nr_uarts,
3128 share_irqs ? "en" : "dis"); 3130 share_irqs ? "en" : "dis");
3129 3131
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index c088146b7513..2a3671233b15 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -602,6 +602,10 @@ static int pci_netmos_init(struct pci_dev *dev)
602 /* subdevice 0x00PS means <P> parallel, <S> serial */ 602 /* subdevice 0x00PS means <P> parallel, <S> serial */
603 unsigned int num_serial = dev->subsystem_device & 0xf; 603 unsigned int num_serial = dev->subsystem_device & 0xf;
604 604
605 if (dev->subsystem_vendor == PCI_VENDOR_ID_IBM &&
606 dev->subsystem_device == 0x0299)
607 return 0;
608
605 if (num_serial == 0) 609 if (num_serial == 0)
606 return -ENODEV; 610 return -ENODEV;
607 return num_serial; 611 return num_serial;
@@ -3096,6 +3100,10 @@ static struct pci_device_id serial_pci_tbl[] = {
3096 0, 3100 0,
3097 pbn_b0_8_115200 }, 3101 pbn_b0_8_115200 },
3098 3102
3103 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9835,
3104 PCI_VENDOR_ID_IBM, 0x0299,
3105 0, 0, pbn_b0_bt_2_115200 },
3106
3099 /* 3107 /*
3100 * These entries match devices with class COMMUNICATION_SERIAL, 3108 * These entries match devices with class COMMUNICATION_SERIAL,
3101 * COMMUNICATION_MODEM or COMMUNICATION_MULTISERIAL 3109 * COMMUNICATION_MODEM or COMMUNICATION_MULTISERIAL
diff --git a/drivers/serial/8250_pnp.c b/drivers/serial/8250_pnp.c
index fde7f9ccf57e..bbcfc26a3b6d 100644
--- a/drivers/serial/8250_pnp.c
+++ b/drivers/serial/8250_pnp.c
@@ -270,6 +270,8 @@ static const struct pnp_device_id pnp_dev_table[] = {
270 { "RSS0250", 0 }, 270 { "RSS0250", 0 },
271 /* SupraExpress 28.8 Data/Fax PnP modem */ 271 /* SupraExpress 28.8 Data/Fax PnP modem */
272 { "SUP1310", 0 }, 272 { "SUP1310", 0 },
273 /* SupraExpress 336i PnP Voice Modem */
274 { "SUP1381", 0 },
273 /* SupraExpress 33.6 Data/Fax PnP modem */ 275 /* SupraExpress 33.6 Data/Fax PnP modem */
274 { "SUP1421", 0 }, 276 { "SUP1421", 0 },
275 /* SupraExpress 33.6 Data/Fax PnP modem */ 277 /* SupraExpress 33.6 Data/Fax PnP modem */
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index b695ab3142d8..3e525e38a5d9 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -457,7 +457,7 @@ config SERIAL_SAMSUNG
457 457
458config SERIAL_SAMSUNG_UARTS 458config SERIAL_SAMSUNG_UARTS
459 int 459 int
460 depends on SERIAL_SAMSUNG 460 depends on ARM && PLAT_S3C
461 default 2 if ARCH_S3C2400 461 default 2 if ARCH_S3C2400
462 default 4 if ARCH_S3C64XX || CPU_S3C2443 462 default 4 if ARCH_S3C64XX || CPU_S3C2443
463 default 3 463 default 3
@@ -1320,13 +1320,30 @@ config SERIAL_NETX_CONSOLE
1320config SERIAL_OF_PLATFORM 1320config SERIAL_OF_PLATFORM
1321 tristate "Serial port on Open Firmware platform bus" 1321 tristate "Serial port on Open Firmware platform bus"
1322 depends on PPC_OF 1322 depends on PPC_OF
1323 depends on SERIAL_8250 1323 depends on SERIAL_8250 || SERIAL_OF_PLATFORM_NWPSERIAL
1324 help 1324 help
1325 If you have a PowerPC based system that has serial ports 1325 If you have a PowerPC based system that has serial ports
1326 on a platform specific bus, you should enable this option. 1326 on a platform specific bus, you should enable this option.
1327 Currently, only 8250 compatible ports are supported, but 1327 Currently, only 8250 compatible ports are supported, but
1328 others can easily be added. 1328 others can easily be added.
1329 1329
1330config SERIAL_OF_PLATFORM_NWPSERIAL
1331 tristate "NWP serial port driver"
1332 depends on PPC_OF && PPC_DCR
1333 select SERIAL_OF_PLATFORM
1334 select SERIAL_CORE_CONSOLE
1335 select SERIAL_CORE
1336 help
1337 This driver supports the cell network processor nwp serial
1338 device.
1339
1340config SERIAL_OF_PLATFORM_NWPSERIAL_CONSOLE
1341 bool "Console on NWP serial port"
1342 depends on SERIAL_OF_PLATFORM_NWPSERIAL=y
1343 select SERIAL_CORE_CONSOLE
1344 help
1345 Support for Console on the NWP serial ports.
1346
1330config SERIAL_QE 1347config SERIAL_QE
1331 tristate "Freescale QUICC Engine serial port support" 1348 tristate "Freescale QUICC Engine serial port support"
1332 depends on QUICC_ENGINE 1349 depends on QUICC_ENGINE
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index dfe775ac45b2..8844c0a03929 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -72,6 +72,7 @@ obj-$(CONFIG_SERIAL_ATMEL) += atmel_serial.o
72obj-$(CONFIG_SERIAL_UARTLITE) += uartlite.o 72obj-$(CONFIG_SERIAL_UARTLITE) += uartlite.o
73obj-$(CONFIG_SERIAL_NETX) += netx-serial.o 73obj-$(CONFIG_SERIAL_NETX) += netx-serial.o
74obj-$(CONFIG_SERIAL_OF_PLATFORM) += of_serial.o 74obj-$(CONFIG_SERIAL_OF_PLATFORM) += of_serial.o
75obj-$(CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL) += nwpserial.o
75obj-$(CONFIG_SERIAL_KS8695) += serial_ks8695.o 76obj-$(CONFIG_SERIAL_KS8695) += serial_ks8695.o
76obj-$(CONFIG_KGDB_SERIAL_CONSOLE) += kgdboc.o 77obj-$(CONFIG_KGDB_SERIAL_CONSOLE) += kgdboc.o
77obj-$(CONFIG_SERIAL_QE) += ucc_uart.o 78obj-$(CONFIG_SERIAL_QE) += ucc_uart.o
diff --git a/drivers/serial/atmel_serial.c b/drivers/serial/atmel_serial.c
index d5efd6c77904..89362d733d62 100644
--- a/drivers/serial/atmel_serial.c
+++ b/drivers/serial/atmel_serial.c
@@ -579,7 +579,7 @@ static void atmel_tx_dma(struct uart_port *port)
579 /* disable PDC transmit */ 579 /* disable PDC transmit */
580 UART_PUT_PTCR(port, ATMEL_PDC_TXTDIS); 580 UART_PUT_PTCR(port, ATMEL_PDC_TXTDIS);
581 581
582 if (!uart_circ_empty(xmit)) { 582 if (!uart_circ_empty(xmit) && !uart_tx_stopped(port)) {
583 dma_sync_single_for_device(port->dev, 583 dma_sync_single_for_device(port->dev,
584 pdc->dma_addr, 584 pdc->dma_addr,
585 pdc->dma_size, 585 pdc->dma_size,
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c
index 8b2c619a09f2..e642c22c80e2 100644
--- a/drivers/serial/crisv10.c
+++ b/drivers/serial/crisv10.c
@@ -1203,7 +1203,7 @@ static void e100_disable_txdma_channel(struct e100_serial *info)
1203 unsigned long flags; 1203 unsigned long flags;
1204 1204
1205 /* Disable output DMA channel for the serial port in question 1205 /* Disable output DMA channel for the serial port in question
1206 * ( set to something other then serialX) 1206 * ( set to something other than serialX)
1207 */ 1207 */
1208 local_irq_save(flags); 1208 local_irq_save(flags);
1209 DFLOW(DEBUG_LOG(info->line, "disable_txdma_channel %i\n", info->line)); 1209 DFLOW(DEBUG_LOG(info->line, "disable_txdma_channel %i\n", info->line));
@@ -1266,7 +1266,7 @@ static void e100_disable_rxdma_channel(struct e100_serial *info)
1266 unsigned long flags; 1266 unsigned long flags;
1267 1267
1268 /* Disable input DMA channel for the serial port in question 1268 /* Disable input DMA channel for the serial port in question
1269 * ( set to something other then serialX) 1269 * ( set to something other than serialX)
1270 */ 1270 */
1271 local_irq_save(flags); 1271 local_irq_save(flags);
1272 if (info->line == 0) { 1272 if (info->line == 0) {
diff --git a/drivers/serial/jsm/jsm_neo.c b/drivers/serial/jsm/jsm_neo.c
index b7584ca55ade..e6390d023634 100644
--- a/drivers/serial/jsm/jsm_neo.c
+++ b/drivers/serial/jsm/jsm_neo.c
@@ -577,9 +577,6 @@ static void neo_parse_modem(struct jsm_channel *ch, u8 signals)
577 jsm_printk(MSIGS, INFO, &ch->ch_bd->pci_dev, 577 jsm_printk(MSIGS, INFO, &ch->ch_bd->pci_dev,
578 "neo_parse_modem: port: %d msignals: %x\n", ch->ch_portnum, msignals); 578 "neo_parse_modem: port: %d msignals: %x\n", ch->ch_portnum, msignals);
579 579
580 if (!ch)
581 return;
582
583 /* Scrub off lower bits. They signify delta's, which I don't care about */ 580 /* Scrub off lower bits. They signify delta's, which I don't care about */
584 /* Keep DDCD and DDSR though */ 581 /* Keep DDCD and DDSR though */
585 msignals &= 0xf8; 582 msignals &= 0xf8;
diff --git a/drivers/serial/nwpserial.c b/drivers/serial/nwpserial.c
new file mode 100644
index 000000000000..32f3eaf0d262
--- /dev/null
+++ b/drivers/serial/nwpserial.c
@@ -0,0 +1,475 @@
1/*
2 * Serial Port driver for a NWP uart device
3 *
4 * Copyright (C) 2008 IBM Corp., Benjamin Krill <ben@codiert.org>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 */
12#include <linux/init.h>
13#include <linux/console.h>
14#include <linux/serial.h>
15#include <linux/serial_reg.h>
16#include <linux/serial_core.h>
17#include <linux/tty.h>
18#include <linux/irqreturn.h>
19#include <linux/mutex.h>
20#include <linux/of_platform.h>
21#include <linux/of_device.h>
22#include <linux/nwpserial.h>
23#include <asm/prom.h>
24#include <asm/dcr.h>
25
26#define NWPSERIAL_NR 2
27
28#define NWPSERIAL_STATUS_RXVALID 0x1
29#define NWPSERIAL_STATUS_TXFULL 0x2
30
31struct nwpserial_port {
32 struct uart_port port;
33 dcr_host_t dcr_host;
34 unsigned int ier;
35 unsigned int mcr;
36};
37
38static DEFINE_MUTEX(nwpserial_mutex);
39static struct nwpserial_port nwpserial_ports[NWPSERIAL_NR];
40
41static void wait_for_bits(struct nwpserial_port *up, int bits)
42{
43 unsigned int status, tmout = 10000;
44
45 /* Wait up to 10ms for the character(s) to be sent. */
46 do {
47 status = dcr_read(up->dcr_host, UART_LSR);
48
49 if (--tmout == 0)
50 break;
51 udelay(1);
52 } while ((status & bits) != bits);
53}
54
55#ifdef CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL_CONSOLE
56static void nwpserial_console_putchar(struct uart_port *port, int c)
57{
58 struct nwpserial_port *up;
59 up = container_of(port, struct nwpserial_port, port);
60 /* check if tx buffer is full */
61 wait_for_bits(up, UART_LSR_THRE);
62 dcr_write(up->dcr_host, UART_TX, c);
63 up->port.icount.tx++;
64}
65
66static void
67nwpserial_console_write(struct console *co, const char *s, unsigned int count)
68{
69 struct nwpserial_port *up = &nwpserial_ports[co->index];
70 unsigned long flags;
71 int locked = 1;
72
73 if (oops_in_progress)
74 locked = spin_trylock_irqsave(&up->port.lock, flags);
75 else
76 spin_lock_irqsave(&up->port.lock, flags);
77
78 /* save and disable interrupt */
79 up->ier = dcr_read(up->dcr_host, UART_IER);
80 dcr_write(up->dcr_host, UART_IER, up->ier & ~UART_IER_RDI);
81
82 uart_console_write(&up->port, s, count, nwpserial_console_putchar);
83
84 /* wait for transmitter to become emtpy */
85 while ((dcr_read(up->dcr_host, UART_LSR) & UART_LSR_THRE) == 0)
86 cpu_relax();
87
88 /* restore interrupt state */
89 dcr_write(up->dcr_host, UART_IER, up->ier);
90
91 if (locked)
92 spin_unlock_irqrestore(&up->port.lock, flags);
93}
94
95static struct uart_driver nwpserial_reg;
96static struct console nwpserial_console = {
97 .name = "ttySQ",
98 .write = nwpserial_console_write,
99 .device = uart_console_device,
100 .flags = CON_PRINTBUFFER,
101 .index = -1,
102 .data = &nwpserial_reg,
103};
104#define NWPSERIAL_CONSOLE (&nwpserial_console)
105#else
106#define NWPSERIAL_CONSOLE NULL
107#endif /* CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL_CONSOLE */
108
109/**************************************************************************/
110
111static int nwpserial_request_port(struct uart_port *port)
112{
113 return 0;
114}
115
116static void nwpserial_release_port(struct uart_port *port)
117{
118 /* N/A */
119}
120
121static void nwpserial_config_port(struct uart_port *port, int flags)
122{
123 port->type = PORT_NWPSERIAL;
124}
125
126static irqreturn_t nwpserial_interrupt(int irq, void *dev_id)
127{
128 struct nwpserial_port *up = dev_id;
129 struct tty_struct *tty = up->port.info->port.tty;
130 irqreturn_t ret;
131 unsigned int iir;
132 unsigned char ch;
133
134 spin_lock(&up->port.lock);
135
136 /* check if the uart was the interrupt source. */
137 iir = dcr_read(up->dcr_host, UART_IIR);
138 if (!iir) {
139 ret = IRQ_NONE;
140 goto out;
141 }
142
143 do {
144 up->port.icount.rx++;
145 ch = dcr_read(up->dcr_host, UART_RX);
146 if (up->port.ignore_status_mask != NWPSERIAL_STATUS_RXVALID)
147 tty_insert_flip_char(tty, ch, TTY_NORMAL);
148 } while (dcr_read(up->dcr_host, UART_RX) & UART_LSR_DR);
149
150 tty_flip_buffer_push(tty);
151 ret = IRQ_HANDLED;
152
153out:
154 spin_unlock(&up->port.lock);
155 return ret;
156}
157
158static int nwpserial_startup(struct uart_port *port)
159{
160 struct nwpserial_port *up;
161 int err;
162
163 up = container_of(port, struct nwpserial_port, port);
164
165 /* disable flow control by default */
166 up->mcr = dcr_read(up->dcr_host, UART_MCR) & ~UART_MCR_AFE;
167 dcr_write(up->dcr_host, UART_MCR, up->mcr);
168
169 /* register interrupt handler */
170 err = request_irq(up->port.irq, nwpserial_interrupt,
171 IRQF_SHARED, "nwpserial", up);
172 if (err)
173 return err;
174
175 /* enable interrupts */
176 up->ier = UART_IER_RDI;
177 dcr_write(up->dcr_host, UART_IER, up->ier);
178
179 /* enable receiving */
180 up->port.ignore_status_mask &= ~NWPSERIAL_STATUS_RXVALID;
181
182 return 0;
183}
184
185static void nwpserial_shutdown(struct uart_port *port)
186{
187 struct nwpserial_port *up;
188 up = container_of(port, struct nwpserial_port, port);
189
190 /* disable receiving */
191 up->port.ignore_status_mask |= NWPSERIAL_STATUS_RXVALID;
192
193 /* disable interrupts from this port */
194 up->ier = 0;
195 dcr_write(up->dcr_host, UART_IER, up->ier);
196
197 /* free irq */
198 free_irq(up->port.irq, port);
199}
200
201static int nwpserial_verify_port(struct uart_port *port,
202 struct serial_struct *ser)
203{
204 return -EINVAL;
205}
206
207static const char *nwpserial_type(struct uart_port *port)
208{
209 return port->type == PORT_NWPSERIAL ? "nwpserial" : NULL;
210}
211
212static void nwpserial_set_termios(struct uart_port *port,
213 struct ktermios *termios, struct ktermios *old)
214{
215 struct nwpserial_port *up;
216 up = container_of(port, struct nwpserial_port, port);
217
218 up->port.read_status_mask = NWPSERIAL_STATUS_RXVALID
219 | NWPSERIAL_STATUS_TXFULL;
220
221 up->port.ignore_status_mask = 0;
222 /* ignore all characters if CREAD is not set */
223 if ((termios->c_cflag & CREAD) == 0)
224 up->port.ignore_status_mask |= NWPSERIAL_STATUS_RXVALID;
225
226 /* Copy back the old hardware settings */
227 if (old)
228 tty_termios_copy_hw(termios, old);
229}
230
231static void nwpserial_break_ctl(struct uart_port *port, int ctl)
232{
233 /* N/A */
234}
235
236static void nwpserial_enable_ms(struct uart_port *port)
237{
238 /* N/A */
239}
240
241static void nwpserial_stop_rx(struct uart_port *port)
242{
243 struct nwpserial_port *up;
244 up = container_of(port, struct nwpserial_port, port);
245 /* don't forward any more data (like !CREAD) */
246 up->port.ignore_status_mask = NWPSERIAL_STATUS_RXVALID;
247}
248
249static void nwpserial_putchar(struct nwpserial_port *up, unsigned char c)
250{
251 /* check if tx buffer is full */
252 wait_for_bits(up, UART_LSR_THRE);
253 dcr_write(up->dcr_host, UART_TX, c);
254 up->port.icount.tx++;
255}
256
257static void nwpserial_start_tx(struct uart_port *port)
258{
259 struct nwpserial_port *up;
260 struct circ_buf *xmit;
261 up = container_of(port, struct nwpserial_port, port);
262 xmit = &up->port.info->xmit;
263
264 if (port->x_char) {
265 nwpserial_putchar(up, up->port.x_char);
266 port->x_char = 0;
267 }
268
269 while (!(uart_circ_empty(xmit) || uart_tx_stopped(&up->port))) {
270 nwpserial_putchar(up, xmit->buf[xmit->tail]);
271 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE-1);
272 }
273}
274
275static unsigned int nwpserial_get_mctrl(struct uart_port *port)
276{
277 return 0;
278}
279
280static void nwpserial_set_mctrl(struct uart_port *port, unsigned int mctrl)
281{
282 /* N/A */
283}
284
285static void nwpserial_stop_tx(struct uart_port *port)
286{
287 /* N/A */
288}
289
290static unsigned int nwpserial_tx_empty(struct uart_port *port)
291{
292 struct nwpserial_port *up;
293 unsigned long flags;
294 int ret;
295 up = container_of(port, struct nwpserial_port, port);
296
297 spin_lock_irqsave(&up->port.lock, flags);
298 ret = dcr_read(up->dcr_host, UART_LSR);
299 spin_unlock_irqrestore(&up->port.lock, flags);
300
301 return ret & UART_LSR_TEMT ? TIOCSER_TEMT : 0;
302}
303
304static struct uart_ops nwpserial_pops = {
305 .tx_empty = nwpserial_tx_empty,
306 .set_mctrl = nwpserial_set_mctrl,
307 .get_mctrl = nwpserial_get_mctrl,
308 .stop_tx = nwpserial_stop_tx,
309 .start_tx = nwpserial_start_tx,
310 .stop_rx = nwpserial_stop_rx,
311 .enable_ms = nwpserial_enable_ms,
312 .break_ctl = nwpserial_break_ctl,
313 .startup = nwpserial_startup,
314 .shutdown = nwpserial_shutdown,
315 .set_termios = nwpserial_set_termios,
316 .type = nwpserial_type,
317 .release_port = nwpserial_release_port,
318 .request_port = nwpserial_request_port,
319 .config_port = nwpserial_config_port,
320 .verify_port = nwpserial_verify_port,
321};
322
323static struct uart_driver nwpserial_reg = {
324 .owner = THIS_MODULE,
325 .driver_name = "nwpserial",
326 .dev_name = "ttySQ",
327 .major = TTY_MAJOR,
328 .minor = 68,
329 .nr = NWPSERIAL_NR,
330 .cons = NWPSERIAL_CONSOLE,
331};
332
333int nwpserial_register_port(struct uart_port *port)
334{
335 struct nwpserial_port *up = NULL;
336 int ret = -1;
337 int i;
338 static int first = 1;
339 int dcr_len;
340 int dcr_base;
341 struct device_node *dn;
342
343 mutex_lock(&nwpserial_mutex);
344
345 dn = to_of_device(port->dev)->node;
346 if (dn == NULL)
347 goto out;
348
349 /* get dcr base. */
350 dcr_base = dcr_resource_start(dn, 0);
351
352 /* find matching entry */
353 for (i = 0; i < NWPSERIAL_NR; i++)
354 if (nwpserial_ports[i].port.iobase == dcr_base) {
355 up = &nwpserial_ports[i];
356 break;
357 }
358
359 /* we didn't find a mtching entry, search for a free port */
360 if (up == NULL)
361 for (i = 0; i < NWPSERIAL_NR; i++)
362 if (nwpserial_ports[i].port.type == PORT_UNKNOWN &&
363 nwpserial_ports[i].port.iobase == 0) {
364 up = &nwpserial_ports[i];
365 break;
366 }
367
368 if (up == NULL) {
369 ret = -EBUSY;
370 goto out;
371 }
372
373 if (first)
374 uart_register_driver(&nwpserial_reg);
375 first = 0;
376
377 up->port.membase = port->membase;
378 up->port.irq = port->irq;
379 up->port.uartclk = port->uartclk;
380 up->port.fifosize = port->fifosize;
381 up->port.regshift = port->regshift;
382 up->port.iotype = port->iotype;
383 up->port.flags = port->flags;
384 up->port.mapbase = port->mapbase;
385 up->port.private_data = port->private_data;
386
387 if (port->dev)
388 up->port.dev = port->dev;
389
390 if (up->port.iobase != dcr_base) {
391 up->port.ops = &nwpserial_pops;
392 up->port.fifosize = 16;
393
394 spin_lock_init(&up->port.lock);
395
396 up->port.iobase = dcr_base;
397 dcr_len = dcr_resource_len(dn, 0);
398
399 up->dcr_host = dcr_map(dn, dcr_base, dcr_len);
400 if (!DCR_MAP_OK(up->dcr_host)) {
401 printk(KERN_ERR "Cannot map DCR resources for NWPSERIAL");
402 goto out;
403 }
404 }
405
406 ret = uart_add_one_port(&nwpserial_reg, &up->port);
407 if (ret == 0)
408 ret = up->port.line;
409
410out:
411 mutex_unlock(&nwpserial_mutex);
412
413 return ret;
414}
415EXPORT_SYMBOL(nwpserial_register_port);
416
417void nwpserial_unregister_port(int line)
418{
419 struct nwpserial_port *up = &nwpserial_ports[line];
420 mutex_lock(&nwpserial_mutex);
421 uart_remove_one_port(&nwpserial_reg, &up->port);
422
423 up->port.type = PORT_UNKNOWN;
424
425 mutex_unlock(&nwpserial_mutex);
426}
427EXPORT_SYMBOL(nwpserial_unregister_port);
428
429#ifdef CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL_CONSOLE
430static int __init nwpserial_console_init(void)
431{
432 struct nwpserial_port *up = NULL;
433 struct device_node *dn;
434 const char *name;
435 int dcr_base;
436 int dcr_len;
437 int i;
438
439 /* search for a free port */
440 for (i = 0; i < NWPSERIAL_NR; i++)
441 if (nwpserial_ports[i].port.type == PORT_UNKNOWN) {
442 up = &nwpserial_ports[i];
443 break;
444 }
445
446 if (up == NULL)
447 return -1;
448
449 name = of_get_property(of_chosen, "linux,stdout-path", NULL);
450 if (name == NULL)
451 return -1;
452
453 dn = of_find_node_by_path(name);
454 if (!dn)
455 return -1;
456
457 spin_lock_init(&up->port.lock);
458 up->port.ops = &nwpserial_pops;
459 up->port.type = PORT_NWPSERIAL;
460 up->port.fifosize = 16;
461
462 dcr_base = dcr_resource_start(dn, 0);
463 dcr_len = dcr_resource_len(dn, 0);
464 up->port.iobase = dcr_base;
465
466 up->dcr_host = dcr_map(dn, dcr_base, dcr_len);
467 if (!DCR_MAP_OK(up->dcr_host)) {
468 printk("Cannot map DCR resources for SERIAL");
469 return -1;
470 }
471 register_console(&nwpserial_console);
472 return 0;
473}
474console_initcall(nwpserial_console_init);
475#endif /* CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL_CONSOLE */
diff --git a/drivers/serial/of_serial.c b/drivers/serial/of_serial.c
index 8fa0ff561e9f..14f8fa9135be 100644
--- a/drivers/serial/of_serial.c
+++ b/drivers/serial/of_serial.c
@@ -14,6 +14,7 @@
14#include <linux/serial_core.h> 14#include <linux/serial_core.h>
15#include <linux/serial_8250.h> 15#include <linux/serial_8250.h>
16#include <linux/of_platform.h> 16#include <linux/of_platform.h>
17#include <linux/nwpserial.h>
17 18
18#include <asm/prom.h> 19#include <asm/prom.h>
19 20
@@ -99,9 +100,16 @@ static int __devinit of_platform_serial_probe(struct of_device *ofdev,
99 goto out; 100 goto out;
100 101
101 switch (port_type) { 102 switch (port_type) {
103#ifdef CONFIG_SERIAL_8250
102 case PORT_8250 ... PORT_MAX_8250: 104 case PORT_8250 ... PORT_MAX_8250:
103 ret = serial8250_register_port(&port); 105 ret = serial8250_register_port(&port);
104 break; 106 break;
107#endif
108#ifdef CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL
109 case PORT_NWPSERIAL:
110 ret = nwpserial_register_port(&port);
111 break;
112#endif
105 default: 113 default:
106 /* need to add code for these */ 114 /* need to add code for these */
107 case PORT_UNKNOWN: 115 case PORT_UNKNOWN:
@@ -129,9 +137,16 @@ static int of_platform_serial_remove(struct of_device *ofdev)
129{ 137{
130 struct of_serial_info *info = ofdev->dev.driver_data; 138 struct of_serial_info *info = ofdev->dev.driver_data;
131 switch (info->type) { 139 switch (info->type) {
140#ifdef CONFIG_SERIAL_8250
132 case PORT_8250 ... PORT_MAX_8250: 141 case PORT_8250 ... PORT_MAX_8250:
133 serial8250_unregister_port(info->line); 142 serial8250_unregister_port(info->line);
134 break; 143 break;
144#endif
145#ifdef CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL
146 case PORT_NWPSERIAL:
147 nwpserial_unregister_port(info->line);
148 break;
149#endif
135 default: 150 default:
136 /* need to add code for these */ 151 /* need to add code for these */
137 break; 152 break;
@@ -148,6 +163,11 @@ static struct of_device_id __devinitdata of_platform_serial_table[] = {
148 { .type = "serial", .compatible = "ns16450", .data = (void *)PORT_16450, }, 163 { .type = "serial", .compatible = "ns16450", .data = (void *)PORT_16450, },
149 { .type = "serial", .compatible = "ns16550", .data = (void *)PORT_16550, }, 164 { .type = "serial", .compatible = "ns16550", .data = (void *)PORT_16550, },
150 { .type = "serial", .compatible = "ns16750", .data = (void *)PORT_16750, }, 165 { .type = "serial", .compatible = "ns16750", .data = (void *)PORT_16750, },
166 { .type = "serial", .compatible = "ns16850", .data = (void *)PORT_16850, },
167#ifdef CONFIG_SERIAL_OF_PLATFORM_NWPSERIAL
168 { .type = "serial", .compatible = "ibm,qpace-nwp-serial",
169 .data = (void *)PORT_NWPSERIAL, },
170#endif
151 { .type = "serial", .data = (void *)PORT_UNKNOWN, }, 171 { .type = "serial", .data = (void *)PORT_UNKNOWN, },
152 { /* end of list */ }, 172 { /* end of list */ },
153}; 173};
diff --git a/drivers/serial/pnx8xxx_uart.c b/drivers/serial/pnx8xxx_uart.c
index 22e30d21225e..1bb8f1b45767 100644
--- a/drivers/serial/pnx8xxx_uart.c
+++ b/drivers/serial/pnx8xxx_uart.c
@@ -187,7 +187,7 @@ static void pnx8xxx_rx_chars(struct pnx8xxx_port *sport)
187 status = FIFO_TO_SM(serial_in(sport, PNX8XXX_FIFO)) | 187 status = FIFO_TO_SM(serial_in(sport, PNX8XXX_FIFO)) |
188 ISTAT_TO_SM(serial_in(sport, PNX8XXX_ISTAT)); 188 ISTAT_TO_SM(serial_in(sport, PNX8XXX_ISTAT));
189 while (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFIFO)) { 189 while (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFIFO)) {
190 ch = serial_in(sport, PNX8XXX_FIFO); 190 ch = serial_in(sport, PNX8XXX_FIFO) & 0xff;
191 191
192 sport->port.icount.rx++; 192 sport->port.icount.rx++;
193 193
@@ -198,9 +198,16 @@ static void pnx8xxx_rx_chars(struct pnx8xxx_port *sport)
198 * out of the main execution path 198 * out of the main execution path
199 */ 199 */
200 if (status & (FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE | 200 if (status & (FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE |
201 PNX8XXX_UART_FIFO_RXPAR) | 201 PNX8XXX_UART_FIFO_RXPAR |
202 PNX8XXX_UART_FIFO_RXBRK) |
202 ISTAT_TO_SM(PNX8XXX_UART_INT_RXOVRN))) { 203 ISTAT_TO_SM(PNX8XXX_UART_INT_RXOVRN))) {
203 if (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXPAR)) 204 if (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXBRK)) {
205 status &= ~(FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE) |
206 FIFO_TO_SM(PNX8XXX_UART_FIFO_RXPAR));
207 sport->port.icount.brk++;
208 if (uart_handle_break(&sport->port))
209 goto ignore_char;
210 } else if (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXPAR))
204 sport->port.icount.parity++; 211 sport->port.icount.parity++;
205 else if (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE)) 212 else if (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE))
206 sport->port.icount.frame++; 213 sport->port.icount.frame++;
@@ -284,14 +291,8 @@ static irqreturn_t pnx8xxx_int(int irq, void *dev_id)
284 /* Get the interrupts */ 291 /* Get the interrupts */
285 status = serial_in(sport, PNX8XXX_ISTAT) & serial_in(sport, PNX8XXX_IEN); 292 status = serial_in(sport, PNX8XXX_ISTAT) & serial_in(sport, PNX8XXX_IEN);
286 293
287 /* Break signal received */ 294 /* Byte or break signal received */
288 if (status & PNX8XXX_UART_INT_BREAK) { 295 if (status & (PNX8XXX_UART_INT_RX | PNX8XXX_UART_INT_BREAK))
289 sport->port.icount.brk++;
290 uart_handle_break(&sport->port);
291 }
292
293 /* Byte received */
294 if (status & PNX8XXX_UART_INT_RX)
295 pnx8xxx_rx_chars(sport); 296 pnx8xxx_rx_chars(sport);
296 297
297 /* TX holding register empty - transmit a byte */ 298 /* TX holding register empty - transmit a byte */
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index 5e39bac9c51b..56ff3e6864ea 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -670,8 +670,7 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *msg)
670 dev_dbg(controller, "new message %p submitted for %s\n", 670 dev_dbg(controller, "new message %p submitted for %s\n",
671 msg, spi->dev.bus_id); 671 msg, spi->dev.bus_id);
672 672
673 if (unlikely(list_empty(&msg->transfers) 673 if (unlikely(list_empty(&msg->transfers)))
674 || !spi->max_speed_hz))
675 return -EINVAL; 674 return -EINVAL;
676 675
677 if (as->stopping) 676 if (as->stopping)
diff --git a/drivers/spi/spi_lm70llp.c b/drivers/spi/spi_lm70llp.c
index af6526767e2a..568c781ad91c 100644
--- a/drivers/spi/spi_lm70llp.c
+++ b/drivers/spi/spi_lm70llp.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * spi_lm70llp.c - driver for lm70llp eval board for the LM70 sensor 2 * spi_lm70llp.c - driver for LM70EVAL-LLP board for the LM70 sensor
3 * 3 *
4 * Copyright (C) 2006 Kaiwan N Billimoria <kaiwan@designergraphix.com> 4 * Copyright (C) 2006 Kaiwan N Billimoria <kaiwan@designergraphix.com>
5 * 5 *
@@ -40,8 +40,12 @@
40 * master controller driver. The hwmon/lm70 driver is a "SPI protocol 40 * master controller driver. The hwmon/lm70 driver is a "SPI protocol
41 * driver", layered on top of this one and usable without the lm70llp. 41 * driver", layered on top of this one and usable without the lm70llp.
42 * 42 *
43 * Datasheet and Schematic:
43 * The LM70 is a temperature sensor chip from National Semiconductor; its 44 * The LM70 is a temperature sensor chip from National Semiconductor; its
44 * datasheet is available at http://www.national.com/pf/LM/LM70.html 45 * datasheet is available at http://www.national.com/pf/LM/LM70.html
46 * The schematic for this particular board (the LM70EVAL-LLP) is
47 * available (on page 4) here:
48 * http://www.national.com/appinfo/tempsensors/files/LM70LLPEVALmanual.pdf
45 * 49 *
46 * Also see Documentation/spi/spi-lm70llp. The SPI<->parport code here is 50 * Also see Documentation/spi/spi-lm70llp. The SPI<->parport code here is
47 * (heavily) based on spi-butterfly by David Brownell. 51 * (heavily) based on spi-butterfly by David Brownell.
@@ -64,7 +68,7 @@
64 * 68 *
65 * Note that parport pin 13 actually gets inverted by the transistor 69 * Note that parport pin 13 actually gets inverted by the transistor
66 * arrangement which lets either the parport or the LM70 drive the 70 * arrangement which lets either the parport or the LM70 drive the
67 * SI/SO signal. 71 * SI/SO signal (see the schematic for details).
68 */ 72 */
69 73
70#define DRVNAME "spi-lm70llp" 74#define DRVNAME "spi-lm70llp"
@@ -106,12 +110,16 @@ static inline struct spi_lm70llp *spidev_to_pp(struct spi_device *spi)
106static inline void deassertCS(struct spi_lm70llp *pp) 110static inline void deassertCS(struct spi_lm70llp *pp)
107{ 111{
108 u8 data = parport_read_data(pp->port); 112 u8 data = parport_read_data(pp->port);
113
114 data &= ~0x80; /* pull D7/SI-out low while de-asserted */
109 parport_write_data(pp->port, data | nCS); 115 parport_write_data(pp->port, data | nCS);
110} 116}
111 117
112static inline void assertCS(struct spi_lm70llp *pp) 118static inline void assertCS(struct spi_lm70llp *pp)
113{ 119{
114 u8 data = parport_read_data(pp->port); 120 u8 data = parport_read_data(pp->port);
121
122 data |= 0x80; /* pull D7/SI-out high so lm70 drives SO-in */
115 parport_write_data(pp->port, data & ~nCS); 123 parport_write_data(pp->port, data & ~nCS);
116} 124}
117 125
@@ -184,22 +192,7 @@ static void lm70_chipselect(struct spi_device *spi, int value)
184 */ 192 */
185static u32 lm70_txrx(struct spi_device *spi, unsigned nsecs, u32 word, u8 bits) 193static u32 lm70_txrx(struct spi_device *spi, unsigned nsecs, u32 word, u8 bits)
186{ 194{
187 static u32 sio=0; 195 return bitbang_txrx_be_cpha0(spi, nsecs, 0, word, bits);
188 static int first_time=1;
189
190 /* First time: perform SPI bitbang and return the LSB of
191 * the result of the SPI call.
192 */
193 if (first_time) {
194 sio = bitbang_txrx_be_cpha0(spi, nsecs, 0, word, bits);
195 first_time=0;
196 return (sio & 0x00ff);
197 }
198 /* Return the MSB of the result of the SPI call */
199 else {
200 first_time=1;
201 return (sio >> 8);
202 }
203} 196}
204 197
205static void spi_lm70llp_attach(struct parport *p) 198static void spi_lm70llp_attach(struct parport *p)
@@ -293,10 +286,9 @@ static void spi_lm70llp_attach(struct parport *p)
293 status = -ENODEV; 286 status = -ENODEV;
294 goto out_bitbang_stop; 287 goto out_bitbang_stop;
295 } 288 }
296 pp->spidev_lm70->bits_per_word = 16; 289 pp->spidev_lm70->bits_per_word = 8;
297 290
298 lm70llp = pp; 291 lm70llp = pp;
299
300 return; 292 return;
301 293
302out_bitbang_stop: 294out_bitbang_stop:
@@ -326,7 +318,6 @@ static void spi_lm70llp_detach(struct parport *p)
326 318
327 /* power down */ 319 /* power down */
328 parport_write_data(pp->port, 0); 320 parport_write_data(pp->port, 0);
329 msleep(10);
330 321
331 parport_release(pp->pd); 322 parport_release(pp->pd);
332 parport_unregister_device(pp->pd); 323 parport_unregister_device(pp->pd);
diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c
index 68d6f4988fb5..fe7e5f35e5d0 100644
--- a/drivers/spi/xilinx_spi.c
+++ b/drivers/spi/xilinx_spi.c
@@ -15,12 +15,15 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18
19#include <linux/of_platform.h>
20#include <linux/of_device.h>
21#include <linux/of_spi.h>
22
18#include <linux/spi/spi.h> 23#include <linux/spi/spi.h>
19#include <linux/spi/spi_bitbang.h> 24#include <linux/spi/spi_bitbang.h>
20#include <linux/io.h> 25#include <linux/io.h>
21 26
22#include <syslib/virtex_devices.h>
23
24#define XILINX_SPI_NAME "xilinx_spi" 27#define XILINX_SPI_NAME "xilinx_spi"
25 28
26/* Register definitions as per "OPB Serial Peripheral Interface (SPI) (v1.00e) 29/* Register definitions as per "OPB Serial Peripheral Interface (SPI) (v1.00e)
@@ -144,23 +147,14 @@ static int xilinx_spi_setup_transfer(struct spi_device *spi,
144 struct spi_transfer *t) 147 struct spi_transfer *t)
145{ 148{
146 u8 bits_per_word; 149 u8 bits_per_word;
147 u32 hz;
148 struct xilinx_spi *xspi = spi_master_get_devdata(spi->master);
149 150
150 bits_per_word = (t) ? t->bits_per_word : spi->bits_per_word; 151 bits_per_word = (t) ? t->bits_per_word : spi->bits_per_word;
151 hz = (t) ? t->speed_hz : spi->max_speed_hz;
152 if (bits_per_word != 8) { 152 if (bits_per_word != 8) {
153 dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n", 153 dev_err(&spi->dev, "%s, unsupported bits_per_word=%d\n",
154 __func__, bits_per_word); 154 __func__, bits_per_word);
155 return -EINVAL; 155 return -EINVAL;
156 } 156 }
157 157
158 if (hz && xspi->speed_hz > hz) {
159 dev_err(&spi->dev, "%s, unsupported clock rate %uHz\n",
160 __func__, hz);
161 return -EINVAL;
162 }
163
164 return 0; 158 return 0;
165} 159}
166 160
@@ -304,32 +298,38 @@ static irqreturn_t xilinx_spi_irq(int irq, void *dev_id)
304 return IRQ_HANDLED; 298 return IRQ_HANDLED;
305} 299}
306 300
307static int __init xilinx_spi_probe(struct platform_device *dev) 301static int __init xilinx_spi_of_probe(struct of_device *ofdev,
302 const struct of_device_id *match)
308{ 303{
309 int ret = 0;
310 struct spi_master *master; 304 struct spi_master *master;
311 struct xilinx_spi *xspi; 305 struct xilinx_spi *xspi;
312 struct xspi_platform_data *pdata; 306 struct resource r_irq_struct;
313 struct resource *r; 307 struct resource r_mem_struct;
308
309 struct resource *r_irq = &r_irq_struct;
310 struct resource *r_mem = &r_mem_struct;
311 int rc = 0;
312 const u32 *prop;
313 int len;
314 314
315 /* Get resources(memory, IRQ) associated with the device */ 315 /* Get resources(memory, IRQ) associated with the device */
316 master = spi_alloc_master(&dev->dev, sizeof(struct xilinx_spi)); 316 master = spi_alloc_master(&ofdev->dev, sizeof(struct xilinx_spi));
317 317
318 if (master == NULL) { 318 if (master == NULL) {
319 return -ENOMEM; 319 return -ENOMEM;
320 } 320 }
321 321
322 platform_set_drvdata(dev, master); 322 dev_set_drvdata(&ofdev->dev, master);
323 pdata = dev->dev.platform_data;
324 323
325 if (pdata == NULL) { 324 rc = of_address_to_resource(ofdev->node, 0, r_mem);
326 ret = -ENODEV; 325 if (rc) {
326 dev_warn(&ofdev->dev, "invalid address\n");
327 goto put_master; 327 goto put_master;
328 } 328 }
329 329
330 r = platform_get_resource(dev, IORESOURCE_MEM, 0); 330 rc = of_irq_to_resource(ofdev->node, 0, r_irq);
331 if (r == NULL) { 331 if (rc == NO_IRQ) {
332 ret = -ENODEV; 332 dev_warn(&ofdev->dev, "no IRQ found\n");
333 goto put_master; 333 goto put_master;
334 } 334 }
335 335
@@ -341,47 +341,57 @@ static int __init xilinx_spi_probe(struct platform_device *dev)
341 xspi->bitbang.master->setup = xilinx_spi_setup; 341 xspi->bitbang.master->setup = xilinx_spi_setup;
342 init_completion(&xspi->done); 342 init_completion(&xspi->done);
343 343
344 if (!request_mem_region(r->start, 344 xspi->irq = r_irq->start;
345 r->end - r->start + 1, XILINX_SPI_NAME)) { 345
346 ret = -ENXIO; 346 if (!request_mem_region(r_mem->start,
347 r_mem->end - r_mem->start + 1, XILINX_SPI_NAME)) {
348 rc = -ENXIO;
349 dev_warn(&ofdev->dev, "memory request failure\n");
347 goto put_master; 350 goto put_master;
348 } 351 }
349 352
350 xspi->regs = ioremap(r->start, r->end - r->start + 1); 353 xspi->regs = ioremap(r_mem->start, r_mem->end - r_mem->start + 1);
351 if (xspi->regs == NULL) { 354 if (xspi->regs == NULL) {
352 ret = -ENOMEM; 355 rc = -ENOMEM;
356 dev_warn(&ofdev->dev, "ioremap failure\n");
353 goto put_master; 357 goto put_master;
354 } 358 }
359 xspi->irq = r_irq->start;
355 360
356 ret = platform_get_irq(dev, 0); 361 /* dynamic bus assignment */
357 if (ret < 0) { 362 master->bus_num = -1;
358 ret = -ENXIO;
359 goto unmap_io;
360 }
361 xspi->irq = ret;
362 363
363 master->bus_num = pdata->bus_num; 364 /* number of slave select bits is required */
364 master->num_chipselect = pdata->num_chipselect; 365 prop = of_get_property(ofdev->node, "xlnx,num-ss-bits", &len);
365 xspi->speed_hz = pdata->speed_hz; 366 if (!prop || len < sizeof(*prop)) {
367 dev_warn(&ofdev->dev, "no 'xlnx,num-ss-bits' property\n");
368 goto put_master;
369 }
370 master->num_chipselect = *prop;
366 371
367 /* SPI controller initializations */ 372 /* SPI controller initializations */
368 xspi_init_hw(xspi->regs); 373 xspi_init_hw(xspi->regs);
369 374
370 /* Register for SPI Interrupt */ 375 /* Register for SPI Interrupt */
371 ret = request_irq(xspi->irq, xilinx_spi_irq, 0, XILINX_SPI_NAME, xspi); 376 rc = request_irq(xspi->irq, xilinx_spi_irq, 0, XILINX_SPI_NAME, xspi);
372 if (ret != 0) 377 if (rc != 0) {
378 dev_warn(&ofdev->dev, "irq request failure: %d\n", xspi->irq);
373 goto unmap_io; 379 goto unmap_io;
380 }
374 381
375 ret = spi_bitbang_start(&xspi->bitbang); 382 rc = spi_bitbang_start(&xspi->bitbang);
376 if (ret != 0) { 383 if (rc != 0) {
377 dev_err(&dev->dev, "spi_bitbang_start FAILED\n"); 384 dev_err(&ofdev->dev, "spi_bitbang_start FAILED\n");
378 goto free_irq; 385 goto free_irq;
379 } 386 }
380 387
381 dev_info(&dev->dev, "at 0x%08X mapped to 0x%08X, irq=%d\n", 388 dev_info(&ofdev->dev, "at 0x%08X mapped to 0x%08X, irq=%d\n",
382 r->start, (u32)xspi->regs, xspi->irq); 389 (unsigned int)r_mem->start, (u32)xspi->regs, xspi->irq);
383 390
384 return ret; 391 /* Add any subnodes on the SPI bus */
392 of_register_spi_devices(master, ofdev->node);
393
394 return rc;
385 395
386free_irq: 396free_irq:
387 free_irq(xspi->irq, xspi); 397 free_irq(xspi->irq, xspi);
@@ -389,21 +399,21 @@ unmap_io:
389 iounmap(xspi->regs); 399 iounmap(xspi->regs);
390put_master: 400put_master:
391 spi_master_put(master); 401 spi_master_put(master);
392 return ret; 402 return rc;
393} 403}
394 404
395static int __devexit xilinx_spi_remove(struct platform_device *dev) 405static int __devexit xilinx_spi_remove(struct of_device *ofdev)
396{ 406{
397 struct xilinx_spi *xspi; 407 struct xilinx_spi *xspi;
398 struct spi_master *master; 408 struct spi_master *master;
399 409
400 master = platform_get_drvdata(dev); 410 master = platform_get_drvdata(ofdev);
401 xspi = spi_master_get_devdata(master); 411 xspi = spi_master_get_devdata(master);
402 412
403 spi_bitbang_stop(&xspi->bitbang); 413 spi_bitbang_stop(&xspi->bitbang);
404 free_irq(xspi->irq, xspi); 414 free_irq(xspi->irq, xspi);
405 iounmap(xspi->regs); 415 iounmap(xspi->regs);
406 platform_set_drvdata(dev, 0); 416 dev_set_drvdata(&ofdev->dev, 0);
407 spi_master_put(xspi->bitbang.master); 417 spi_master_put(xspi->bitbang.master);
408 418
409 return 0; 419 return 0;
@@ -412,27 +422,42 @@ static int __devexit xilinx_spi_remove(struct platform_device *dev)
412/* work with hotplug and coldplug */ 422/* work with hotplug and coldplug */
413MODULE_ALIAS("platform:" XILINX_SPI_NAME); 423MODULE_ALIAS("platform:" XILINX_SPI_NAME);
414 424
415static struct platform_driver xilinx_spi_driver = { 425static int __exit xilinx_spi_of_remove(struct of_device *op)
416 .probe = xilinx_spi_probe, 426{
417 .remove = __devexit_p(xilinx_spi_remove), 427 return xilinx_spi_remove(op);
428}
429
430static struct of_device_id xilinx_spi_of_match[] = {
431 { .compatible = "xlnx,xps-spi-2.00.a", },
432 { .compatible = "xlnx,xps-spi-2.00.b", },
433 {}
434};
435
436MODULE_DEVICE_TABLE(of, xilinx_spi_of_match);
437
438static struct of_platform_driver xilinx_spi_of_driver = {
439 .owner = THIS_MODULE,
440 .name = "xilinx-xps-spi",
441 .match_table = xilinx_spi_of_match,
442 .probe = xilinx_spi_of_probe,
443 .remove = __exit_p(xilinx_spi_of_remove),
418 .driver = { 444 .driver = {
419 .name = XILINX_SPI_NAME, 445 .name = "xilinx-xps-spi",
420 .owner = THIS_MODULE, 446 .owner = THIS_MODULE,
421 }, 447 },
422}; 448};
423 449
424static int __init xilinx_spi_init(void) 450static int __init xilinx_spi_init(void)
425{ 451{
426 return platform_driver_register(&xilinx_spi_driver); 452 return of_register_platform_driver(&xilinx_spi_of_driver);
427} 453}
428module_init(xilinx_spi_init); 454module_init(xilinx_spi_init);
429 455
430static void __exit xilinx_spi_exit(void) 456static void __exit xilinx_spi_exit(void)
431{ 457{
432 platform_driver_unregister(&xilinx_spi_driver); 458 of_unregister_platform_driver(&xilinx_spi_of_driver);
433} 459}
434module_exit(xilinx_spi_exit); 460module_exit(xilinx_spi_exit);
435
436MODULE_AUTHOR("MontaVista Software, Inc. <source@mvista.com>"); 461MODULE_AUTHOR("MontaVista Software, Inc. <source@mvista.com>");
437MODULE_DESCRIPTION("Xilinx SPI driver"); 462MODULE_DESCRIPTION("Xilinx SPI driver");
438MODULE_LICENSE("GPL"); 463MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index 06372b227bb2..36a93b95e3f2 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -557,7 +557,7 @@ unsigned int comedi_buf_munge(comedi_async * async, unsigned int num_bytes)
557 block_size = num_bytes - count; 557 block_size = num_bytes - count;
558 if (block_size < 0) { 558 if (block_size < 0) {
559 rt_printk("%s: %s: bug! block_size is negative\n", 559 rt_printk("%s: %s: bug! block_size is negative\n",
560 __FILE__, __FUNCTION__); 560 __FILE__, __func__);
561 break; 561 break;
562 } 562 }
563 if ((int)(async->munge_ptr + block_size - 563 if ((int)(async->munge_ptr + block_size -
diff --git a/drivers/staging/epl/Edrv8139.c b/drivers/staging/epl/Edrv8139.c
index 88ab4a4f1023..296354aaa9c7 100644
--- a/drivers/staging/epl/Edrv8139.c
+++ b/drivers/staging/epl/Edrv8139.c
@@ -391,19 +391,19 @@ tEplKernel EdrvInit(tEdrvInitParam * pEdrvInitParam_p)
391 // register PCI driver 391 // register PCI driver
392 iResult = pci_register_driver(&EdrvDriver); 392 iResult = pci_register_driver(&EdrvDriver);
393 if (iResult != 0) { 393 if (iResult != 0) {
394 printk("%s pci_register_driver failed with %d\n", __FUNCTION__, 394 printk("%s pci_register_driver failed with %d\n", __func__,
395 iResult); 395 iResult);
396 Ret = kEplNoResource; 396 Ret = kEplNoResource;
397 goto Exit; 397 goto Exit;
398 } 398 }
399 399
400 if (EdrvInstance_l.m_pPciDev == NULL) { 400 if (EdrvInstance_l.m_pPciDev == NULL) {
401 printk("%s m_pPciDev=NULL\n", __FUNCTION__); 401 printk("%s m_pPciDev=NULL\n", __func__);
402 Ret = kEplNoResource; 402 Ret = kEplNoResource;
403 goto Exit; 403 goto Exit;
404 } 404 }
405 // read MAC address from controller 405 // read MAC address from controller
406 printk("%s local MAC = ", __FUNCTION__); 406 printk("%s local MAC = ", __func__);
407 for (iResult = 0; iResult < 6; iResult++) { 407 for (iResult = 0; iResult < 6; iResult++) {
408 pEdrvInitParam_p->m_abMyMacAddr[iResult] = 408 pEdrvInitParam_p->m_abMyMacAddr[iResult] =
409 EDRV_REGB_READ((EDRV_REGDW_IDR0 + iResult)); 409 EDRV_REGB_READ((EDRV_REGDW_IDR0 + iResult));
@@ -434,7 +434,7 @@ tEplKernel EdrvShutdown(void)
434{ 434{
435 435
436 // unregister PCI driver 436 // unregister PCI driver
437 printk("%s calling pci_unregister_driver()\n", __FUNCTION__); 437 printk("%s calling pci_unregister_driver()\n", __func__);
438 pci_unregister_driver(&EdrvDriver); 438 pci_unregister_driver(&EdrvDriver);
439 439
440 return kEplSuccessful; 440 return kEplSuccessful;
@@ -621,7 +621,7 @@ tEplKernel EdrvSendTxMsg(tEdrvTxBuffer * pBuffer_p)
621 EDRV_REGDW_READ((EDRV_REGDW_TSD0 + 621 EDRV_REGDW_READ((EDRV_REGDW_TSD0 +
622 (EdrvInstance_l.m_uiCurTxDesc * 622 (EdrvInstance_l.m_uiCurTxDesc *
623 sizeof(DWORD)))); 623 sizeof(DWORD))));
624 printk("%s InvOp TSD%u = 0x%08lX", __FUNCTION__, 624 printk("%s InvOp TSD%u = 0x%08lX", __func__,
625 EdrvInstance_l.m_uiCurTxDesc, dwTemp); 625 EdrvInstance_l.m_uiCurTxDesc, dwTemp);
626 printk(" Cmd = 0x%02X\n", 626 printk(" Cmd = 0x%02X\n",
627 (WORD) EDRV_REGB_READ(EDRV_REGB_COMMAND)); 627 (WORD) EDRV_REGB_READ(EDRV_REGB_COMMAND));
@@ -646,7 +646,7 @@ tEplKernel EdrvSendTxMsg(tEdrvTxBuffer * pBuffer_p)
646 dwTemp = 646 dwTemp =
647 EDRV_REGDW_READ((EDRV_REGDW_TSAD0 + 647 EDRV_REGDW_READ((EDRV_REGDW_TSAD0 +
648 (EdrvInstance_l.m_uiCurTxDesc * sizeof(DWORD)))); 648 (EdrvInstance_l.m_uiCurTxDesc * sizeof(DWORD))));
649// printk("%s TSAD%u = 0x%08lX", __FUNCTION__, EdrvInstance_l.m_uiCurTxDesc, dwTemp); 649// printk("%s TSAD%u = 0x%08lX", __func__, EdrvInstance_l.m_uiCurTxDesc, dwTemp);
650 650
651 // start transmission 651 // start transmission
652 EDRV_REGDW_WRITE((EDRV_REGDW_TSD0 + 652 EDRV_REGDW_WRITE((EDRV_REGDW_TSD0 +
@@ -786,7 +786,7 @@ static int TgtEthIsr(int nIrqNum_p, void *ppDevInstData_p,
786 786
787 if (EdrvInstance_l.m_pbTxBuf == NULL) { 787 if (EdrvInstance_l.m_pbTxBuf == NULL) {
788 printk("%s Tx buffers currently not allocated\n", 788 printk("%s Tx buffers currently not allocated\n",
789 __FUNCTION__); 789 __func__);
790 goto Exit; 790 goto Exit;
791 } 791 }
792 // read transmit status 792 // read transmit status
@@ -842,7 +842,7 @@ static int TgtEthIsr(int nIrqNum_p, void *ppDevInstData_p,
842 842
843 if (EdrvInstance_l.m_pbRxBuf == NULL) { 843 if (EdrvInstance_l.m_pbRxBuf == NULL) {
844 printk("%s Rx buffers currently not allocated\n", 844 printk("%s Rx buffers currently not allocated\n",
845 __FUNCTION__); 845 __func__);
846 goto Exit; 846 goto Exit;
847 } 847 }
848 // read current offset in receive buffer 848 // read current offset in receive buffer
@@ -944,7 +944,7 @@ static int EdrvInitOne(struct pci_dev *pPciDev, const struct pci_device_id *pId)
944 DWORD dwTemp; 944 DWORD dwTemp;
945 945
946 if (EdrvInstance_l.m_pPciDev != NULL) { // Edrv is already connected to a PCI device 946 if (EdrvInstance_l.m_pPciDev != NULL) { // Edrv is already connected to a PCI device
947 printk("%s device %s discarded\n", __FUNCTION__, 947 printk("%s device %s discarded\n", __func__,
948 pci_name(pPciDev)); 948 pci_name(pPciDev));
949 iResult = -ENODEV; 949 iResult = -ENODEV;
950 goto Exit; 950 goto Exit;
@@ -953,7 +953,7 @@ static int EdrvInitOne(struct pci_dev *pPciDev, const struct pci_device_id *pId)
953 if (pPciDev->revision >= 0x20) { 953 if (pPciDev->revision >= 0x20) {
954 printk 954 printk
955 ("%s device %s is an enhanced 8139C+ version, which is not supported\n", 955 ("%s device %s is an enhanced 8139C+ version, which is not supported\n",
956 __FUNCTION__, pci_name(pPciDev)); 956 __func__, pci_name(pPciDev));
957 iResult = -ENODEV; 957 iResult = -ENODEV;
958 goto Exit; 958 goto Exit;
959 } 959 }
@@ -961,7 +961,7 @@ static int EdrvInitOne(struct pci_dev *pPciDev, const struct pci_device_id *pId)
961 EdrvInstance_l.m_pPciDev = pPciDev; 961 EdrvInstance_l.m_pPciDev = pPciDev;
962 962
963 // enable device 963 // enable device
964 printk("%s enable device\n", __FUNCTION__); 964 printk("%s enable device\n", __func__);
965 iResult = pci_enable_device(pPciDev); 965 iResult = pci_enable_device(pPciDev);
966 if (iResult != 0) { 966 if (iResult != 0) {
967 goto Exit; 967 goto Exit;
@@ -972,13 +972,13 @@ static int EdrvInitOne(struct pci_dev *pPciDev, const struct pci_device_id *pId)
972 goto Exit; 972 goto Exit;
973 } 973 }
974 974
975 printk("%s request regions\n", __FUNCTION__); 975 printk("%s request regions\n", __func__);
976 iResult = pci_request_regions(pPciDev, DRV_NAME); 976 iResult = pci_request_regions(pPciDev, DRV_NAME);
977 if (iResult != 0) { 977 if (iResult != 0) {
978 goto Exit; 978 goto Exit;
979 } 979 }
980 980
981 printk("%s ioremap\n", __FUNCTION__); 981 printk("%s ioremap\n", __func__);
982 EdrvInstance_l.m_pIoAddr = 982 EdrvInstance_l.m_pIoAddr =
983 ioremap(pci_resource_start(pPciDev, 1), 983 ioremap(pci_resource_start(pPciDev, 1),
984 pci_resource_len(pPciDev, 1)); 984 pci_resource_len(pPciDev, 1));
@@ -987,11 +987,11 @@ static int EdrvInitOne(struct pci_dev *pPciDev, const struct pci_device_id *pId)
987 goto Exit; 987 goto Exit;
988 } 988 }
989 // enable PCI busmaster 989 // enable PCI busmaster
990 printk("%s enable busmaster\n", __FUNCTION__); 990 printk("%s enable busmaster\n", __func__);
991 pci_set_master(pPciDev); 991 pci_set_master(pPciDev);
992 992
993 // reset controller 993 // reset controller
994 printk("%s reset controller\n", __FUNCTION__); 994 printk("%s reset controller\n", __func__);
995 EDRV_REGB_WRITE(EDRV_REGB_COMMAND, EDRV_REGB_COMMAND_RST); 995 EDRV_REGB_WRITE(EDRV_REGB_COMMAND, EDRV_REGB_COMMAND_RST);
996 996
997 // wait until reset has finished 997 // wait until reset has finished
@@ -1008,20 +1008,20 @@ static int EdrvInitOne(struct pci_dev *pPciDev, const struct pci_device_id *pId)
1008 dwTemp = EDRV_REGDW_READ(EDRV_REGDW_TCR); 1008 dwTemp = EDRV_REGDW_READ(EDRV_REGDW_TCR);
1009 if (((dwTemp & EDRV_REGDW_TCR_VER_MASK) != EDRV_REGDW_TCR_VER_C) 1009 if (((dwTemp & EDRV_REGDW_TCR_VER_MASK) != EDRV_REGDW_TCR_VER_C)
1010 && ((dwTemp & EDRV_REGDW_TCR_VER_MASK) != EDRV_REGDW_TCR_VER_D)) { // unsupported chip 1010 && ((dwTemp & EDRV_REGDW_TCR_VER_MASK) != EDRV_REGDW_TCR_VER_D)) { // unsupported chip
1011 printk("%s Unsupported chip! TCR = 0x%08lX\n", __FUNCTION__, 1011 printk("%s Unsupported chip! TCR = 0x%08lX\n", __func__,
1012 dwTemp); 1012 dwTemp);
1013 iResult = -ENODEV; 1013 iResult = -ENODEV;
1014 goto Exit; 1014 goto Exit;
1015 } 1015 }
1016 // disable interrupts 1016 // disable interrupts
1017 printk("%s disable interrupts\n", __FUNCTION__); 1017 printk("%s disable interrupts\n", __func__);
1018 EDRV_REGW_WRITE(EDRV_REGW_INT_MASK, 0); 1018 EDRV_REGW_WRITE(EDRV_REGW_INT_MASK, 0);
1019 // acknowledge all pending interrupts 1019 // acknowledge all pending interrupts
1020 EDRV_REGW_WRITE(EDRV_REGW_INT_STATUS, 1020 EDRV_REGW_WRITE(EDRV_REGW_INT_STATUS,
1021 EDRV_REGW_READ(EDRV_REGW_INT_STATUS)); 1021 EDRV_REGW_READ(EDRV_REGW_INT_STATUS));
1022 1022
1023 // install interrupt handler 1023 // install interrupt handler
1024 printk("%s install interrupt handler\n", __FUNCTION__); 1024 printk("%s install interrupt handler\n", __func__);
1025 iResult = 1025 iResult =
1026 request_irq(pPciDev->irq, TgtEthIsr, IRQF_SHARED, 1026 request_irq(pPciDev->irq, TgtEthIsr, IRQF_SHARED,
1027 DRV_NAME /*pPciDev->dev.name */ , pPciDev); 1027 DRV_NAME /*pPciDev->dev.name */ , pPciDev);
@@ -1031,16 +1031,16 @@ static int EdrvInitOne(struct pci_dev *pPciDev, const struct pci_device_id *pId)
1031 1031
1032/* 1032/*
1033 // unlock configuration registers 1033 // unlock configuration registers
1034 printk("%s unlock configuration registers\n", __FUNCTION__); 1034 printk("%s unlock configuration registers\n", __func__);
1035 EDRV_REGB_WRITE(EDRV_REGB_CMD9346, EDRV_REGB_CMD9346_UNLOCK); 1035 EDRV_REGB_WRITE(EDRV_REGB_CMD9346, EDRV_REGB_CMD9346_UNLOCK);
1036 1036
1037 // check if user specified a MAC address 1037 // check if user specified a MAC address
1038 printk("%s check specified MAC address\n", __FUNCTION__); 1038 printk("%s check specified MAC address\n", __func__);
1039 for (iResult = 0; iResult < 6; iResult++) 1039 for (iResult = 0; iResult < 6; iResult++)
1040 { 1040 {
1041 if (EdrvInstance_l.m_InitParam.m_abMyMacAddr[iResult] != 0) 1041 if (EdrvInstance_l.m_InitParam.m_abMyMacAddr[iResult] != 0)
1042 { 1042 {
1043 printk("%s set local MAC address\n", __FUNCTION__); 1043 printk("%s set local MAC address\n", __func__);
1044 // write this MAC address to controller 1044 // write this MAC address to controller
1045 EDRV_REGDW_WRITE(EDRV_REGDW_IDR0, 1045 EDRV_REGDW_WRITE(EDRV_REGDW_IDR0,
1046 le32_to_cpu(*((DWORD*)&EdrvInstance_l.m_InitParam.m_abMyMacAddr[0]))); 1046 le32_to_cpu(*((DWORD*)&EdrvInstance_l.m_InitParam.m_abMyMacAddr[0])));
@@ -1059,7 +1059,7 @@ static int EdrvInitOne(struct pci_dev *pPciDev, const struct pci_device_id *pId)
1059*/ 1059*/
1060 1060
1061 // allocate buffers 1061 // allocate buffers
1062 printk("%s allocate buffers\n", __FUNCTION__); 1062 printk("%s allocate buffers\n", __func__);
1063 EdrvInstance_l.m_pbTxBuf = 1063 EdrvInstance_l.m_pbTxBuf =
1064 pci_alloc_consistent(pPciDev, EDRV_TX_BUFFER_SIZE, 1064 pci_alloc_consistent(pPciDev, EDRV_TX_BUFFER_SIZE,
1065 &EdrvInstance_l.m_pTxBufDma); 1065 &EdrvInstance_l.m_pTxBufDma);
@@ -1076,7 +1076,7 @@ static int EdrvInitOne(struct pci_dev *pPciDev, const struct pci_device_id *pId)
1076 goto Exit; 1076 goto Exit;
1077 } 1077 }
1078 // reset pointers for Tx buffers 1078 // reset pointers for Tx buffers
1079 printk("%s reset pointers fo Tx buffers\n", __FUNCTION__); 1079 printk("%s reset pointers fo Tx buffers\n", __func__);
1080 EDRV_REGDW_WRITE(EDRV_REGDW_TSAD0, 0); 1080 EDRV_REGDW_WRITE(EDRV_REGDW_TSAD0, 0);
1081 dwTemp = EDRV_REGDW_READ(EDRV_REGDW_TSAD0); 1081 dwTemp = EDRV_REGDW_READ(EDRV_REGDW_TSAD0);
1082 EDRV_REGDW_WRITE(EDRV_REGDW_TSAD1, 0); 1082 EDRV_REGDW_WRITE(EDRV_REGDW_TSAD1, 0);
@@ -1090,11 +1090,11 @@ static int EdrvInitOne(struct pci_dev *pPciDev, const struct pci_device_id *pId)
1090 (WORD) EDRV_REGB_READ(EDRV_REGB_COMMAND)); 1090 (WORD) EDRV_REGB_READ(EDRV_REGB_COMMAND));
1091 1091
1092 // set pointer for receive buffer in controller 1092 // set pointer for receive buffer in controller
1093 printk("%s set pointer to Rx buffer\n", __FUNCTION__); 1093 printk("%s set pointer to Rx buffer\n", __func__);
1094 EDRV_REGDW_WRITE(EDRV_REGDW_RBSTART, EdrvInstance_l.m_pRxBufDma); 1094 EDRV_REGDW_WRITE(EDRV_REGDW_RBSTART, EdrvInstance_l.m_pRxBufDma);
1095 1095
1096 // enable transmitter and receiver 1096 // enable transmitter and receiver
1097 printk("%s enable Tx and Rx", __FUNCTION__); 1097 printk("%s enable Tx and Rx", __func__);
1098 EDRV_REGB_WRITE(EDRV_REGB_COMMAND, 1098 EDRV_REGB_WRITE(EDRV_REGB_COMMAND,
1099 (EDRV_REGB_COMMAND_RE | EDRV_REGB_COMMAND_TE)); 1099 (EDRV_REGB_COMMAND_RE | EDRV_REGB_COMMAND_TE));
1100 printk(" Command = 0x%02X\n", 1100 printk(" Command = 0x%02X\n",
@@ -1104,12 +1104,12 @@ static int EdrvInitOne(struct pci_dev *pPciDev, const struct pci_device_id *pId)
1104 EDRV_REGDW_WRITE(EDRV_REGDW_MPC, 0); 1104 EDRV_REGDW_WRITE(EDRV_REGDW_MPC, 0);
1105 1105
1106 // set transmit configuration register 1106 // set transmit configuration register
1107 printk("%s set Tx conf register", __FUNCTION__); 1107 printk("%s set Tx conf register", __func__);
1108 EDRV_REGDW_WRITE(EDRV_REGDW_TCR, EDRV_REGDW_TCR_DEF); 1108 EDRV_REGDW_WRITE(EDRV_REGDW_TCR, EDRV_REGDW_TCR_DEF);
1109 printk(" = 0x%08X\n", EDRV_REGDW_READ(EDRV_REGDW_TCR)); 1109 printk(" = 0x%08X\n", EDRV_REGDW_READ(EDRV_REGDW_TCR));
1110 1110
1111 // set receive configuration register 1111 // set receive configuration register
1112 printk("%s set Rx conf register", __FUNCTION__); 1112 printk("%s set Rx conf register", __func__);
1113 EDRV_REGDW_WRITE(EDRV_REGDW_RCR, EDRV_REGDW_RCR_DEF); 1113 EDRV_REGDW_WRITE(EDRV_REGDW_RCR, EDRV_REGDW_RCR_DEF);
1114 printk(" = 0x%08X\n", EDRV_REGDW_READ(EDRV_REGDW_RCR)); 1114 printk(" = 0x%08X\n", EDRV_REGDW_READ(EDRV_REGDW_RCR));
1115 1115
@@ -1121,7 +1121,7 @@ static int EdrvInitOne(struct pci_dev *pPciDev, const struct pci_device_id *pId)
1121 1121
1122/* 1122/*
1123 // enable transmitter and receiver 1123 // enable transmitter and receiver
1124 printk("%s enable Tx and Rx", __FUNCTION__); 1124 printk("%s enable Tx and Rx", __func__);
1125 EDRV_REGB_WRITE(EDRV_REGB_COMMAND, (EDRV_REGB_COMMAND_RE | EDRV_REGB_COMMAND_TE)); 1125 EDRV_REGB_WRITE(EDRV_REGB_COMMAND, (EDRV_REGB_COMMAND_RE | EDRV_REGB_COMMAND_TE));
1126 printk(" Command = 0x%02X\n", (WORD) EDRV_REGB_READ(EDRV_REGB_COMMAND)); 1126 printk(" Command = 0x%02X\n", (WORD) EDRV_REGB_READ(EDRV_REGB_COMMAND));
1127*/ 1127*/
@@ -1129,11 +1129,11 @@ static int EdrvInitOne(struct pci_dev *pPciDev, const struct pci_device_id *pId)
1129 EDRV_REGW_WRITE(EDRV_REGW_MULINT, 0); 1129 EDRV_REGW_WRITE(EDRV_REGW_MULINT, 0);
1130 1130
1131 // enable interrupts 1131 // enable interrupts
1132 printk("%s enable interrupts\n", __FUNCTION__); 1132 printk("%s enable interrupts\n", __func__);
1133 EDRV_REGW_WRITE(EDRV_REGW_INT_MASK, EDRV_REGW_INT_MASK_DEF); 1133 EDRV_REGW_WRITE(EDRV_REGW_INT_MASK, EDRV_REGW_INT_MASK_DEF);
1134 1134
1135 Exit: 1135 Exit:
1136 printk("%s finished with %d\n", __FUNCTION__, iResult); 1136 printk("%s finished with %d\n", __func__, iResult);
1137 return iResult; 1137 return iResult;
1138} 1138}
1139 1139
diff --git a/drivers/staging/epl/EplSdoAsySequ.c b/drivers/staging/epl/EplSdoAsySequ.c
index 991c6be880c0..6b6a9975d78b 100644
--- a/drivers/staging/epl/EplSdoAsySequ.c
+++ b/drivers/staging/epl/EplSdoAsySequ.c
@@ -876,7 +876,7 @@ static tEplKernel EplSdoAsySeqProcess(unsigned int uiHandle_p,
876 { 876 {
877/* 877/*
878 PRINTF3("%s scon=%u rcon=%u\n", 878 PRINTF3("%s scon=%u rcon=%u\n",
879 __FUNCTION__, 879 __func__,
880 pRecFrame_p->m_le_bSendSeqNumCon, 880 pRecFrame_p->m_le_bSendSeqNumCon,
881 pRecFrame_p->m_le_bRecSeqNumCon); 881 pRecFrame_p->m_le_bRecSeqNumCon);
882*/ 882*/
diff --git a/drivers/staging/frontier/alphatrack.c b/drivers/staging/frontier/alphatrack.c
index 61d7c5df87af..6136e3f8762d 100644
--- a/drivers/staging/frontier/alphatrack.c
+++ b/drivers/staging/frontier/alphatrack.c
@@ -239,7 +239,7 @@ static void usb_alphatrack_interrupt_in_callback(struct urb *urb)
239 goto exit; 239 goto exit;
240 } else { 240 } else {
241 dbg_info(&dev->intf->dev, "%s: nonzero status received: %d\n", 241 dbg_info(&dev->intf->dev, "%s: nonzero status received: %d\n",
242 __FUNCTION__, urb->status); 242 __func__, urb->status);
243 goto resubmit; /* maybe we can recover */ 243 goto resubmit; /* maybe we can recover */
244 } 244 }
245 } 245 }
@@ -261,7 +261,7 @@ static void usb_alphatrack_interrupt_in_callback(struct urb *urb)
261 if(dev->offline > 0 && dev->interrupt_in_buffer[1] != 0xff) { dev->offline = 0; } 261 if(dev->offline > 0 && dev->interrupt_in_buffer[1] != 0xff) { dev->offline = 0; }
262 if(dev->offline == 0 && dev->interrupt_in_buffer[1] == 0xff) { dev->offline = 1; } 262 if(dev->offline == 0 && dev->interrupt_in_buffer[1] == 0xff) { dev->offline = 1; }
263#endif 263#endif
264 dbg_info(&dev->intf->dev, "%s: head, tail are %x, %x\n", __FUNCTION__,dev->ring_head,dev->ring_tail); 264 dbg_info(&dev->intf->dev, "%s: head, tail are %x, %x\n", __func__,dev->ring_head,dev->ring_tail);
265 next_ring_head = (dev->ring_head+1) % ring_buffer_size; 265 next_ring_head = (dev->ring_head+1) % ring_buffer_size;
266 266
267 if (next_ring_head != dev->ring_tail) { 267 if (next_ring_head != dev->ring_tail) {
@@ -305,7 +305,7 @@ static void usb_alphatrack_interrupt_out_callback(struct urb *urb)
305 urb->status == -ESHUTDOWN)) 305 urb->status == -ESHUTDOWN))
306 dbg_info(&dev->intf->dev, 306 dbg_info(&dev->intf->dev,
307 "%s - nonzero write interrupt status received: %d\n", 307 "%s - nonzero write interrupt status received: %d\n",
308 __FUNCTION__, urb->status); 308 __func__, urb->status);
309 atomic_dec(&dev->writes_pending); 309 atomic_dec(&dev->writes_pending);
310 dev->interrupt_out_busy = 0; 310 dev->interrupt_out_busy = 0;
311 wake_up_interruptible(&dev->write_wait); 311 wake_up_interruptible(&dev->write_wait);
@@ -330,7 +330,7 @@ static int usb_alphatrack_open(struct inode *inode, struct file *file)
330 330
331 if (!interface) { 331 if (!interface) {
332 err("%s - error, can't find device for minor %d\n", 332 err("%s - error, can't find device for minor %d\n",
333 __FUNCTION__, subminor); 333 __func__, subminor);
334 retval = -ENODEV; 334 retval = -ENODEV;
335 goto unlock_disconnect_exit; 335 goto unlock_disconnect_exit;
336 } 336 }
@@ -514,7 +514,7 @@ static ssize_t usb_alphatrack_read(struct file *file, char __user *buffer, size_
514 } 514 }
515 dev->ring_tail = (dev->ring_tail+1) % ring_buffer_size; 515 dev->ring_tail = (dev->ring_tail+1) % ring_buffer_size;
516 c+=INPUT_CMD_SIZE; 516 c+=INPUT_CMD_SIZE;
517 dbg_info(&dev->intf->dev, "%s: head, tail are %x, %x\n", __FUNCTION__,dev->ring_head,dev->ring_tail); 517 dbg_info(&dev->intf->dev, "%s: head, tail are %x, %x\n", __func__,dev->ring_head,dev->ring_tail);
518 } 518 }
519 retval = c; 519 retval = c;
520 520
@@ -573,7 +573,7 @@ static ssize_t usb_alphatrack_write(struct file *file, const char __user *buffer
573 if (bytes_to_write < count) 573 if (bytes_to_write < count)
574 dev_warn(&dev->intf->dev, "Write buffer overflow, %zd bytes dropped\n",count-bytes_to_write); 574 dev_warn(&dev->intf->dev, "Write buffer overflow, %zd bytes dropped\n",count-bytes_to_write);
575 575
576 dbg_info(&dev->intf->dev, "%s: count = %zd, bytes_to_write = %zd\n", __FUNCTION__, count, bytes_to_write); 576 dbg_info(&dev->intf->dev, "%s: count = %zd, bytes_to_write = %zd\n", __func__, count, bytes_to_write);
577 577
578 if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write)) { 578 if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write)) {
579 retval = -EFAULT; 579 retval = -EFAULT;
diff --git a/drivers/staging/frontier/tranzport.c b/drivers/staging/frontier/tranzport.c
index 275faa762388..79abb6b16f74 100644
--- a/drivers/staging/frontier/tranzport.c
+++ b/drivers/staging/frontier/tranzport.c
@@ -335,7 +335,7 @@ static void usb_tranzport_interrupt_in_callback(struct urb *urb)
335 goto exit; 335 goto exit;
336 } else { 336 } else {
337 dbg_info(&dev->intf->dev, "%s: nonzero status received: %d\n", 337 dbg_info(&dev->intf->dev, "%s: nonzero status received: %d\n",
338 __FUNCTION__, urb->status); 338 __func__, urb->status);
339 goto resubmit; /* maybe we can recover */ 339 goto resubmit; /* maybe we can recover */
340 } 340 }
341 } 341 }
@@ -345,7 +345,7 @@ static void usb_tranzport_interrupt_in_callback(struct urb *urb)
345 "Urb length was %d bytes!! Do something intelligent \n", urb->actual_length); 345 "Urb length was %d bytes!! Do something intelligent \n", urb->actual_length);
346 } else { 346 } else {
347 dbg_info(&dev->intf->dev, "%s: received: %02x%02x%02x%02x%02x%02x%02x%02x\n", 347 dbg_info(&dev->intf->dev, "%s: received: %02x%02x%02x%02x%02x%02x%02x%02x\n",
348 __FUNCTION__, dev->interrupt_in_buffer[0],dev->interrupt_in_buffer[1],dev->interrupt_in_buffer[2],dev->interrupt_in_buffer[3],dev->interrupt_in_buffer[4],dev->interrupt_in_buffer[5],dev->interrupt_in_buffer[6],dev->interrupt_in_buffer[7]); 348 __func__, dev->interrupt_in_buffer[0],dev->interrupt_in_buffer[1],dev->interrupt_in_buffer[2],dev->interrupt_in_buffer[3],dev->interrupt_in_buffer[4],dev->interrupt_in_buffer[5],dev->interrupt_in_buffer[6],dev->interrupt_in_buffer[7]);
349#if SUPPRESS_EXTRA_OFFLINE_EVENTS 349#if SUPPRESS_EXTRA_OFFLINE_EVENTS
350 if(dev->offline == 2 && dev->interrupt_in_buffer[1] == 0xff) { goto resubmit; } 350 if(dev->offline == 2 && dev->interrupt_in_buffer[1] == 0xff) { goto resubmit; }
351 if(dev->offline == 1 && dev->interrupt_in_buffer[1] == 0xff) { dev->offline = 2; goto resubmit; } 351 if(dev->offline == 1 && dev->interrupt_in_buffer[1] == 0xff) { dev->offline = 2; goto resubmit; }
@@ -355,7 +355,7 @@ static void usb_tranzport_interrupt_in_callback(struct urb *urb)
355 if(dev->offline == 0 && dev->interrupt_in_buffer[1] == 0xff) { dev->offline = 1; } 355 if(dev->offline == 0 && dev->interrupt_in_buffer[1] == 0xff) { dev->offline = 1; }
356 356
357#endif 357#endif
358 dbg_info(&dev->intf->dev, "%s: head, tail are %x, %x\n", __FUNCTION__,dev->ring_head,dev->ring_tail); 358 dbg_info(&dev->intf->dev, "%s: head, tail are %x, %x\n", __func__,dev->ring_head,dev->ring_tail);
359 359
360 next_ring_head = (dev->ring_head+1) % ring_buffer_size; 360 next_ring_head = (dev->ring_head+1) % ring_buffer_size;
361 361
@@ -399,7 +399,7 @@ static void usb_tranzport_interrupt_out_callback(struct urb *urb)
399 urb->status == -ESHUTDOWN)) 399 urb->status == -ESHUTDOWN))
400 dbg_info(&dev->intf->dev, 400 dbg_info(&dev->intf->dev,
401 "%s - nonzero write interrupt status received: %d\n", 401 "%s - nonzero write interrupt status received: %d\n",
402 __FUNCTION__, urb->status); 402 __func__, urb->status);
403 403
404 dev->interrupt_out_busy = 0; 404 dev->interrupt_out_busy = 0;
405 wake_up_interruptible(&dev->write_wait); 405 wake_up_interruptible(&dev->write_wait);
@@ -424,7 +424,7 @@ static int usb_tranzport_open(struct inode *inode, struct file *file)
424 424
425 if (!interface) { 425 if (!interface) {
426 err("%s - error, can't find device for minor %d\n", 426 err("%s - error, can't find device for minor %d\n",
427 __FUNCTION__, subminor); 427 __func__, subminor);
428 retval = -ENODEV; 428 retval = -ENODEV;
429 goto unlock_disconnect_exit; 429 goto unlock_disconnect_exit;
430 } 430 }
@@ -613,7 +613,7 @@ static ssize_t usb_tranzport_read(struct file *file, char __user *buffer, size_t
613 } 613 }
614 614
615 dbg_info(&dev->intf->dev, "%s: copying to userspace: %02x%02x%02x%02x%02x%02x%02x%02x\n", 615 dbg_info(&dev->intf->dev, "%s: copying to userspace: %02x%02x%02x%02x%02x%02x%02x%02x\n",
616 __FUNCTION__, (*dev->ring_buffer)[dev->ring_tail].cmd[0],(*dev->ring_buffer)[dev->ring_tail].cmd[1],(*dev->ring_buffer)[dev->ring_tail].cmd[2],(*dev->ring_buffer)[dev->ring_tail].cmd[3],(*dev->ring_buffer)[dev->ring_tail].cmd[4],(*dev->ring_buffer)[dev->ring_tail].cmd[5],(*dev->ring_buffer)[dev->ring_tail].cmd[6],(*dev->ring_buffer)[dev->ring_tail].cmd[7]); 616 __func__, (*dev->ring_buffer)[dev->ring_tail].cmd[0],(*dev->ring_buffer)[dev->ring_tail].cmd[1],(*dev->ring_buffer)[dev->ring_tail].cmd[2],(*dev->ring_buffer)[dev->ring_tail].cmd[3],(*dev->ring_buffer)[dev->ring_tail].cmd[4],(*dev->ring_buffer)[dev->ring_tail].cmd[5],(*dev->ring_buffer)[dev->ring_tail].cmd[6],(*dev->ring_buffer)[dev->ring_tail].cmd[7]);
617 617
618#if BUFFERED_READS 618#if BUFFERED_READS
619 c = 0; 619 c = 0;
@@ -632,7 +632,7 @@ static ssize_t usb_tranzport_read(struct file *file, char __user *buffer, size_t
632 // FIXME the math is wrong for going in reverse, actually, as the midi spec doesn't allow signed chars 632 // FIXME the math is wrong for going in reverse, actually, as the midi spec doesn't allow signed chars
633 633
634 dbg_info(&dev->intf->dev, "%s: trying to compress: %02x%02x%02x%02x%02x %02x %02x %02x\n", 634 dbg_info(&dev->intf->dev, "%s: trying to compress: %02x%02x%02x%02x%02x %02x %02x %02x\n",
635 __FUNCTION__, (*dev->ring_buffer)[dev->ring_tail].cmd[0],(*dev->ring_buffer)[dev->ring_tail].cmd[1],(*dev->ring_buffer)[dev->ring_tail].cmd[2],(*dev->ring_buffer)[dev->ring_tail].cmd[3],(*dev->ring_buffer)[dev->ring_tail].cmd[4],(*dev->ring_buffer)[dev->ring_tail].cmd[5],(*dev->ring_buffer)[dev->ring_tail].cmd[6],(*dev->ring_buffer)[dev->ring_tail].cmd[7]); 635 __func__, (*dev->ring_buffer)[dev->ring_tail].cmd[0],(*dev->ring_buffer)[dev->ring_tail].cmd[1],(*dev->ring_buffer)[dev->ring_tail].cmd[2],(*dev->ring_buffer)[dev->ring_tail].cmd[3],(*dev->ring_buffer)[dev->ring_tail].cmd[4],(*dev->ring_buffer)[dev->ring_tail].cmd[5],(*dev->ring_buffer)[dev->ring_tail].cmd[6],(*dev->ring_buffer)[dev->ring_tail].cmd[7]);
636 636
637 637
638 if(((*dev->ring_buffer)[dev->ring_tail].cmd[6] != 0 && 638 if(((*dev->ring_buffer)[dev->ring_tail].cmd[6] != 0 &&
@@ -645,7 +645,7 @@ static ssize_t usb_tranzport_read(struct file *file, char __user *buffer, size_t
645 ((*dev->ring_buffer)[dev->ring_tail].cmd[5] == (*dev->ring_buffer)[next_tail].cmd[5])) 645 ((*dev->ring_buffer)[dev->ring_tail].cmd[5] == (*dev->ring_buffer)[next_tail].cmd[5]))
646 { 646 {
647 dbg_info(&dev->intf->dev, "%s: should compress: %02x%02x%02x%02x%02x%02x%02x%02x\n", 647 dbg_info(&dev->intf->dev, "%s: should compress: %02x%02x%02x%02x%02x%02x%02x%02x\n",
648 __FUNCTION__, (*dev->ring_buffer)[dev->ring_tail].cmd[0],(*dev->ring_buffer)[dev->ring_tail].cmd[1],(*dev->ring_buffer)[dev->ring_tail].cmd[2],(*dev->ring_buffer)[dev->ring_tail].cmd[3],(*dev->ring_buffer)[dev->ring_tail].cmd[4],(*dev->ring_buffer)[dev->ring_tail].cmd[5],(*dev->ring_buffer)[dev->ring_tail].cmd[6],(*dev->ring_buffer)[dev->ring_tail].cmd[7]); 648 __func__, (*dev->ring_buffer)[dev->ring_tail].cmd[0],(*dev->ring_buffer)[dev->ring_tail].cmd[1],(*dev->ring_buffer)[dev->ring_tail].cmd[2],(*dev->ring_buffer)[dev->ring_tail].cmd[3],(*dev->ring_buffer)[dev->ring_tail].cmd[4],(*dev->ring_buffer)[dev->ring_tail].cmd[5],(*dev->ring_buffer)[dev->ring_tail].cmd[6],(*dev->ring_buffer)[dev->ring_tail].cmd[7]);
649 649
650 newwheel += oldwheel; 650 newwheel += oldwheel;
651 if(oldwheel > 0 && !(newwheel > 0)) { 651 if(oldwheel > 0 && !(newwheel > 0)) {
@@ -673,7 +673,7 @@ static ssize_t usb_tranzport_read(struct file *file, char __user *buffer, size_t
673 673
674 dev->ring_tail = (dev->ring_tail+1) % ring_buffer_size; 674 dev->ring_tail = (dev->ring_tail+1) % ring_buffer_size;
675 c+=8; 675 c+=8;
676 dbg_info(&dev->intf->dev, "%s: head, tail are %x, %x\n", __FUNCTION__,dev->ring_head,dev->ring_tail); 676 dbg_info(&dev->intf->dev, "%s: head, tail are %x, %x\n", __func__,dev->ring_head,dev->ring_tail);
677 } 677 }
678 retval = c; 678 retval = c;
679 679
@@ -684,7 +684,7 @@ static ssize_t usb_tranzport_read(struct file *file, char __user *buffer, size_t
684 } 684 }
685 685
686 dev->ring_tail = (dev->ring_tail+1) % ring_buffer_size; 686 dev->ring_tail = (dev->ring_tail+1) % ring_buffer_size;
687 dbg_info(&dev->intf->dev, "%s: head, tail are %x, %x\n", __FUNCTION__,dev->ring_head,dev->ring_tail); 687 dbg_info(&dev->intf->dev, "%s: head, tail are %x, %x\n", __func__,dev->ring_head,dev->ring_tail);
688 688
689 retval = 8; 689 retval = 8;
690#endif /* BUFFERED_READS */ 690#endif /* BUFFERED_READS */
@@ -743,7 +743,7 @@ static ssize_t usb_tranzport_write(struct file *file, const char __user *buffer,
743 if (bytes_to_write < count) 743 if (bytes_to_write < count)
744 dev_warn(&dev->intf->dev, "Write buffer overflow, %zd bytes dropped\n",count-bytes_to_write); 744 dev_warn(&dev->intf->dev, "Write buffer overflow, %zd bytes dropped\n",count-bytes_to_write);
745 745
746 dbg_info(&dev->intf->dev, "%s: count = %zd, bytes_to_write = %zd\n", __FUNCTION__, count, bytes_to_write); 746 dbg_info(&dev->intf->dev, "%s: count = %zd, bytes_to_write = %zd\n", __func__, count, bytes_to_write);
747 747
748 if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write)) { 748 if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write)) {
749 retval = -EFAULT; 749 retval = -EFAULT;
diff --git a/drivers/staging/go7007/go7007-v4l2.c b/drivers/staging/go7007/go7007-v4l2.c
index 4f7237a03ad1..868edb65e7bf 100644
--- a/drivers/staging/go7007/go7007-v4l2.c
+++ b/drivers/staging/go7007/go7007-v4l2.c
@@ -1712,8 +1712,7 @@ static int go7007_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
1712 page = alloc_page(GFP_USER | __GFP_DMA32); 1712 page = alloc_page(GFP_USER | __GFP_DMA32);
1713 if (!page) 1713 if (!page)
1714 return VM_FAULT_OOM; 1714 return VM_FAULT_OOM;
1715 clear_user_page(page_address(page), (unsigned long)vmf->virtual_address, 1715 clear_user_highpage(page, (unsigned long)vmf->virtual_address);
1716 page);
1717 vmf->page = page; 1716 vmf->page = page;
1718 return 0; 1717 return 0;
1719} 1718}
diff --git a/drivers/staging/meilhaus/me0600_ext_irq.c b/drivers/staging/meilhaus/me0600_ext_irq.c
index a449ab200940..eba18adecb72 100644
--- a/drivers/staging/meilhaus/me0600_ext_irq.c
+++ b/drivers/staging/meilhaus/me0600_ext_irq.c
@@ -360,7 +360,7 @@ static irqreturn_t me0600_isr(int irq, void *dev_id, struct pt_regs *regs)
360 if (instance->lintno > 1) { 360 if (instance->lintno > 1) {
361 PERROR_CRITICAL 361 PERROR_CRITICAL
362 ("%s():Wrong subdevice index=%d plx:irq_status_reg=0x%04X.\n", 362 ("%s():Wrong subdevice index=%d plx:irq_status_reg=0x%04X.\n",
363 __FUNCTION__, instance->lintno, inl(instance->intcsr)); 363 __func__, instance->lintno, inl(instance->intcsr));
364 return IRQ_NONE; 364 return IRQ_NONE;
365 } 365 }
366 366
@@ -384,7 +384,7 @@ static irqreturn_t me0600_isr(int irq, void *dev_id, struct pt_regs *regs)
384 } else { 384 } else {
385 PINFO 385 PINFO
386 ("%ld Shared interrupt. %s(): idx=0 plx:irq_status_reg=0x%04X\n", 386 ("%ld Shared interrupt. %s(): idx=0 plx:irq_status_reg=0x%04X\n",
387 jiffies, __FUNCTION__, status); 387 jiffies, __func__, status);
388 ret = IRQ_NONE; 388 ret = IRQ_NONE;
389 } 389 }
390 spin_unlock(instance->intcsr_lock); 390 spin_unlock(instance->intcsr_lock);
diff --git a/drivers/staging/meilhaus/me1400_ext_irq.c b/drivers/staging/meilhaus/me1400_ext_irq.c
index b8c2696bc150..b4df7cc58ab7 100644
--- a/drivers/staging/meilhaus/me1400_ext_irq.c
+++ b/drivers/staging/meilhaus/me1400_ext_irq.c
@@ -349,7 +349,7 @@ static irqreturn_t me1400_ext_irq_isr(int irq, void *dev_id,
349 (PLX_LOCAL_INT1_STATE | PLX_LOCAL_INT1_EN | PLX_PCI_INT_EN)) { 349 (PLX_LOCAL_INT1_STATE | PLX_LOCAL_INT1_EN | PLX_PCI_INT_EN)) {
350 spin_unlock(&instance->subdevice_lock); 350 spin_unlock(&instance->subdevice_lock);
351 PINFO("%ld Shared interrupt. %s(): irq_status_reg=0x%04X\n", 351 PINFO("%ld Shared interrupt. %s(): irq_status_reg=0x%04X\n",
352 jiffies, __FUNCTION__, status); 352 jiffies, __func__, status);
353 return IRQ_NONE; 353 return IRQ_NONE;
354 } 354 }
355 355
diff --git a/drivers/staging/meilhaus/me1600_ao.c b/drivers/staging/meilhaus/me1600_ao.c
index 6f26665b30b7..d127c6b00307 100644
--- a/drivers/staging/meilhaus/me1600_ao.c
+++ b/drivers/staging/meilhaus/me1600_ao.c
@@ -977,7 +977,7 @@ static void me1600_ao_work_control_task(struct work_struct *work)
977 container_of((void *)work, me1600_ao_subdevice_t, ao_control_task); 977 container_of((void *)work, me1600_ao_subdevice_t, ao_control_task);
978#endif 978#endif
979 979
980 PINFO("<%s: %ld> executed. idx=%d\n", __FUNCTION__, jiffies, 980 PINFO("<%s: %ld> executed. idx=%d\n", __func__, jiffies,
981 instance->ao_idx); 981 instance->ao_idx);
982 982
983 if (!((instance->ao_regs_shadows)->trigger & instance->ao_idx)) { // Output was triggerd. 983 if (!((instance->ao_regs_shadows)->trigger & instance->ao_idx)) { // Output was triggerd.
@@ -1027,7 +1027,7 @@ static void me1600_ao_work_control_task(struct work_struct *work)
1027 queue_delayed_work(instance->me1600_workqueue, 1027 queue_delayed_work(instance->me1600_workqueue,
1028 &instance->ao_control_task, 1); 1028 &instance->ao_control_task, 1);
1029 } else { 1029 } else {
1030 PINFO("<%s> Ending control task.\n", __FUNCTION__); 1030 PINFO("<%s> Ending control task.\n", __func__);
1031 } 1031 }
1032 1032
1033} 1033}
diff --git a/drivers/staging/meilhaus/me4600_ai.c b/drivers/staging/meilhaus/me4600_ai.c
index 1a0de5dea277..0a8c9d737e90 100644
--- a/drivers/staging/meilhaus/me4600_ai.c
+++ b/drivers/staging/meilhaus/me4600_ai.c
@@ -2629,11 +2629,11 @@ static irqreturn_t me4600_ai_isr(int irq, void *dev_id, struct pt_regs *regs)
2629 if ((irq_status & (ME4600_IRQ_STATUS_BIT_AI_HF | ME4600_IRQ_STATUS_BIT_SC | ME4600_IRQ_STATUS_BIT_LE)) == ME4600_IRQ_STATUS_BIT_LE) { //This is security check case. LE is unused. This should never ever happend. 2629 if ((irq_status & (ME4600_IRQ_STATUS_BIT_AI_HF | ME4600_IRQ_STATUS_BIT_SC | ME4600_IRQ_STATUS_BIT_LE)) == ME4600_IRQ_STATUS_BIT_LE) { //This is security check case. LE is unused. This should never ever happend.
2630 PINFO 2630 PINFO
2631 ("%ld Shared interrupt. %s(): irq_status_reg=LE_IRQ\n", 2631 ("%ld Shared interrupt. %s(): irq_status_reg=LE_IRQ\n",
2632 jiffies, __FUNCTION__); 2632 jiffies, __func__);
2633 } else { 2633 } else {
2634 PINFO 2634 PINFO
2635 ("%ld Shared interrupt. %s(): irq_status_reg=0x%04X\n", 2635 ("%ld Shared interrupt. %s(): irq_status_reg=0x%04X\n",
2636 jiffies, __FUNCTION__, irq_status); 2636 jiffies, __func__, irq_status);
2637 } 2637 }
2638#endif 2638#endif
2639 return IRQ_NONE; 2639 return IRQ_NONE;
@@ -3329,7 +3329,7 @@ static void me4600_ai_work_control_task(struct work_struct *work)
3329 instance = 3329 instance =
3330 container_of((void *)work, me4600_ai_subdevice_t, ai_control_task); 3330 container_of((void *)work, me4600_ai_subdevice_t, ai_control_task);
3331#endif 3331#endif
3332 PINFO("<%s: %ld> executed.\n", __FUNCTION__, jiffies); 3332 PINFO("<%s: %ld> executed.\n", __func__, jiffies);
3333 3333
3334 status = inl(instance->status_reg); 3334 status = inl(instance->status_reg);
3335 PDEBUG_REG("status_reg inl(0x%lX+0x%lX)=0x%x\n", instance->reg_base, 3335 PDEBUG_REG("status_reg inl(0x%lX+0x%lX)=0x%x\n", instance->reg_base,
@@ -3428,7 +3428,7 @@ static void me4600_ai_work_control_task(struct work_struct *work)
3428 queue_delayed_work(instance->me4600_workqueue, 3428 queue_delayed_work(instance->me4600_workqueue,
3429 &instance->ai_control_task, 1); 3429 &instance->ai_control_task, 1);
3430 } else { 3430 } else {
3431 PINFO("<%s> Ending control task.\n", __FUNCTION__); 3431 PINFO("<%s> Ending control task.\n", __func__);
3432 } 3432 }
3433 3433
3434} 3434}
diff --git a/drivers/staging/meilhaus/me4600_ao.c b/drivers/staging/meilhaus/me4600_ao.c
index 2c92e655a81e..e2bec8229abd 100644
--- a/drivers/staging/meilhaus/me4600_ao.c
+++ b/drivers/staging/meilhaus/me4600_ao.c
@@ -2294,7 +2294,7 @@ static irqreturn_t me4600_ao_isr(int irq, void *dev_id
2294 irq_status = inl(instance->irq_status_reg); 2294 irq_status = inl(instance->irq_status_reg);
2295 if (!(irq_status & (ME4600_IRQ_STATUS_BIT_AO_HF << instance->ao_idx))) { 2295 if (!(irq_status & (ME4600_IRQ_STATUS_BIT_AO_HF << instance->ao_idx))) {
2296 PINFO("%ld Shared interrupt. %s(): ID=%d: status_reg=0x%04X\n", 2296 PINFO("%ld Shared interrupt. %s(): ID=%d: status_reg=0x%04X\n",
2297 jiffies, __FUNCTION__, instance->ao_idx, irq_status); 2297 jiffies, __func__, instance->ao_idx, irq_status);
2298 return IRQ_NONE; 2298 return IRQ_NONE;
2299 } 2299 }
2300 2300
@@ -3009,7 +3009,7 @@ static void me4600_ao_work_control_task(
3009 instance = 3009 instance =
3010 container_of((void *)work, me4600_ao_subdevice_t, ao_control_task); 3010 container_of((void *)work, me4600_ao_subdevice_t, ao_control_task);
3011#endif 3011#endif
3012 PINFO("<%s: %ld> executed. idx=%d\n", __FUNCTION__, jiffies, 3012 PINFO("<%s: %ld> executed. idx=%d\n", __func__, jiffies,
3013 instance->ao_idx); 3013 instance->ao_idx);
3014 3014
3015 status = inl(instance->status_reg); 3015 status = inl(instance->status_reg);
@@ -3316,7 +3316,7 @@ static void me4600_ao_work_control_task(
3316 queue_delayed_work(instance->me4600_workqueue, 3316 queue_delayed_work(instance->me4600_workqueue,
3317 &instance->ao_control_task, 1); 3317 &instance->ao_control_task, 1);
3318 } else { 3318 } else {
3319 PINFO("<%s> Ending control task.\n", __FUNCTION__); 3319 PINFO("<%s> Ending control task.\n", __func__);
3320 } 3320 }
3321 3321
3322} 3322}
diff --git a/drivers/staging/meilhaus/me4600_ext_irq.c b/drivers/staging/meilhaus/me4600_ext_irq.c
index 8a10dceae32a..adc1e1babf40 100644
--- a/drivers/staging/meilhaus/me4600_ext_irq.c
+++ b/drivers/staging/meilhaus/me4600_ext_irq.c
@@ -356,7 +356,7 @@ static irqreturn_t me4600_ext_irq_isr(int irq, void *dev_id,
356 irq_status = inl(instance->irq_status_reg); 356 irq_status = inl(instance->irq_status_reg);
357 if (!(irq_status & ME4600_IRQ_STATUS_BIT_EX)) { 357 if (!(irq_status & ME4600_IRQ_STATUS_BIT_EX)) {
358 PINFO("%ld Shared interrupt. %s(): irq_status_reg=0x%04X\n", 358 PINFO("%ld Shared interrupt. %s(): irq_status_reg=0x%04X\n",
359 jiffies, __FUNCTION__, irq_status); 359 jiffies, __func__, irq_status);
360 return IRQ_NONE; 360 return IRQ_NONE;
361 } 361 }
362 362
diff --git a/drivers/staging/meilhaus/me6000_ao.c b/drivers/staging/meilhaus/me6000_ao.c
index 3f5ff6d1b991..94f01231f79a 100644
--- a/drivers/staging/meilhaus/me6000_ao.c
+++ b/drivers/staging/meilhaus/me6000_ao.c
@@ -863,7 +863,7 @@ static int me6000_ao_io_single_write(me_subdevice_t * subdevice,
863 863
864/// @note When flag 'ME_IO_SINGLE_TYPE_TRIG_SYNCHRONOUS' is set than output is triggered. ALWAYS! 864/// @note When flag 'ME_IO_SINGLE_TYPE_TRIG_SYNCHRONOUS' is set than output is triggered. ALWAYS!
865 865
866 PINFO("<%s> start mode= 0x%08x %s\n", __FUNCTION__, mode, 866 PINFO("<%s> start mode= 0x%08x %s\n", __func__, mode,
867 (flags & ME_IO_SINGLE_TYPE_TRIG_SYNCHRONOUS) ? "SYNCHRONOUS" : 867 (flags & ME_IO_SINGLE_TYPE_TRIG_SYNCHRONOUS) ? "SYNCHRONOUS" :
868 ""); 868 "");
869 if (instance->fifo & ME6000_AO_HAS_FIFO) { // FIFO - Continous mode 869 if (instance->fifo & ME6000_AO_HAS_FIFO) { // FIFO - Continous mode
@@ -1663,7 +1663,7 @@ static int me6000_ao_io_stream_start(me_subdevice_t * subdevice,
1663 1663
1664 status = inl(instance->status_reg); 1664 status = inl(instance->status_reg);
1665 //Start state machine and interrupts 1665 //Start state machine and interrupts
1666 PINFO("<%s:%d> Start state machine.\n", __FUNCTION__, __LINE__); 1666 PINFO("<%s:%d> Start state machine.\n", __func__, __LINE__);
1667 ctrl &= ~(ME6000_AO_CTRL_BIT_STOP | ME6000_AO_CTRL_BIT_IMMEDIATE_STOP); 1667 ctrl &= ~(ME6000_AO_CTRL_BIT_STOP | ME6000_AO_CTRL_BIT_IMMEDIATE_STOP);
1668 if (instance->start_mode == ME6000_AO_EXT_TRIG) { 1668 if (instance->start_mode == ME6000_AO_EXT_TRIG) {
1669 PDEBUG("DIGITAL TRIGGER\n"); 1669 PDEBUG("DIGITAL TRIGGER\n");
@@ -1671,7 +1671,7 @@ static int me6000_ao_io_stream_start(me_subdevice_t * subdevice,
1671 } 1671 }
1672 if (!(status & ME6000_AO_STATUS_BIT_HF)) { //More than half! 1672 if (!(status & ME6000_AO_STATUS_BIT_HF)) { //More than half!
1673 if ((ctrl & ME6000_AO_CTRL_MODE_MASK) == ME6000_AO_MODE_CONTINUOUS) { //Enable IRQ only when hardware_continous is set and FIFO is more than half 1673 if ((ctrl & ME6000_AO_CTRL_MODE_MASK) == ME6000_AO_MODE_CONTINUOUS) { //Enable IRQ only when hardware_continous is set and FIFO is more than half
1674 PINFO("<%s:%d> Start interrupts.\n", __FUNCTION__, 1674 PINFO("<%s:%d> Start interrupts.\n", __func__,
1675 __LINE__); 1675 __LINE__);
1676 ctrl |= ME6000_AO_CTRL_BIT_ENABLE_IRQ; 1676 ctrl |= ME6000_AO_CTRL_BIT_ENABLE_IRQ;
1677 } 1677 }
@@ -1682,7 +1682,7 @@ static int me6000_ao_io_stream_start(me_subdevice_t * subdevice,
1682 spin_unlock_irqrestore(&instance->subdevice_lock, cpu_flags); 1682 spin_unlock_irqrestore(&instance->subdevice_lock, cpu_flags);
1683 1683
1684 //Trigger output 1684 //Trigger output
1685 PINFO("<%s> start mode= 0x%x %s\n", __FUNCTION__, instance->start_mode, 1685 PINFO("<%s> start mode= 0x%x %s\n", __func__, instance->start_mode,
1686 (flags & ME_IO_SINGLE_TYPE_TRIG_SYNCHRONOUS) ? "SYNCHRONOUS" : 1686 (flags & ME_IO_SINGLE_TYPE_TRIG_SYNCHRONOUS) ? "SYNCHRONOUS" :
1687 ""); 1687 "");
1688 if (flags & ME_IO_SINGLE_TYPE_TRIG_SYNCHRONOUS) { //Trigger outputs 1688 if (flags & ME_IO_SINGLE_TYPE_TRIG_SYNCHRONOUS) { //Trigger outputs
@@ -1777,7 +1777,7 @@ static int me6000_ao_io_stream_start(me_subdevice_t * subdevice,
1777 status = inl(instance->status_reg); 1777 status = inl(instance->status_reg);
1778 if (!(status & ME6000_AO_STATUS_BIT_HF)) { //More than half! 1778 if (!(status & ME6000_AO_STATUS_BIT_HF)) { //More than half!
1779 spin_lock_irqsave(&instance->subdevice_lock, cpu_flags); 1779 spin_lock_irqsave(&instance->subdevice_lock, cpu_flags);
1780 PINFO("<%s:%d> Start interrupts.\n", __FUNCTION__, 1780 PINFO("<%s:%d> Start interrupts.\n", __func__,
1781 __LINE__); 1781 __LINE__);
1782 ctrl = inl(instance->ctrl_reg); 1782 ctrl = inl(instance->ctrl_reg);
1783 ctrl |= ME6000_AO_CTRL_BIT_ENABLE_IRQ; 1783 ctrl |= ME6000_AO_CTRL_BIT_ENABLE_IRQ;
@@ -1819,7 +1819,7 @@ static int me6000_ao_io_stream_start(me_subdevice_t * subdevice,
1819 spin_lock_irqsave(&instance->subdevice_lock, 1819 spin_lock_irqsave(&instance->subdevice_lock,
1820 cpu_flags); 1820 cpu_flags);
1821 PINFO("<%s:%d> Start interrupts.\n", 1821 PINFO("<%s:%d> Start interrupts.\n",
1822 __FUNCTION__, __LINE__); 1822 __func__, __LINE__);
1823 ctrl = inl(instance->ctrl_reg); 1823 ctrl = inl(instance->ctrl_reg);
1824 ctrl |= ME6000_AO_CTRL_BIT_ENABLE_IRQ; 1824 ctrl |= ME6000_AO_CTRL_BIT_ENABLE_IRQ;
1825 outl(ctrl, instance->ctrl_reg); 1825 outl(ctrl, instance->ctrl_reg);
@@ -2346,7 +2346,7 @@ static irqreturn_t me6000_ao_isr(int irq, void *dev_id, struct pt_regs *regs)
2346 irq_status = inl(instance->irq_status_reg); 2346 irq_status = inl(instance->irq_status_reg);
2347 if (!(irq_status & (ME6000_IRQ_STATUS_BIT_AO_HF << instance->ao_idx))) { 2347 if (!(irq_status & (ME6000_IRQ_STATUS_BIT_AO_HF << instance->ao_idx))) {
2348 PINFO("%ld Shared interrupt. %s(): ID=%d: status_reg=0x%04X\n", 2348 PINFO("%ld Shared interrupt. %s(): ID=%d: status_reg=0x%04X\n",
2349 jiffies, __FUNCTION__, instance->ao_idx, irq_status); 2349 jiffies, __func__, instance->ao_idx, irq_status);
2350 return IRQ_NONE; 2350 return IRQ_NONE;
2351 } 2351 }
2352 2352
@@ -2861,7 +2861,7 @@ int inline ao_stop_immediately(me6000_ao_subdevice_t * instance)
2861 } 2861 }
2862 } 2862 }
2863 2863
2864 PINFO("<%s> Wait for stop: %d\n", __FUNCTION__, i); 2864 PINFO("<%s> Wait for stop: %d\n", __func__, i);
2865 2865
2866 //Still working! 2866 //Still working!
2867 set_current_state(TASK_INTERRUPTIBLE); 2867 set_current_state(TASK_INTERRUPTIBLE);
@@ -3132,7 +3132,7 @@ static void me6000_ao_work_control_task(
3132 instance = 3132 instance =
3133 container_of((void *)work, me6000_ao_subdevice_t, ao_control_task); 3133 container_of((void *)work, me6000_ao_subdevice_t, ao_control_task);
3134#endif 3134#endif
3135 PINFO("<%s: %ld> executed. idx=%d\n", __FUNCTION__, jiffies, 3135 PINFO("<%s: %ld> executed. idx=%d\n", __func__, jiffies,
3136 instance->ao_idx); 3136 instance->ao_idx);
3137 3137
3138 status = inl(instance->status_reg); 3138 status = inl(instance->status_reg);
@@ -3550,7 +3550,7 @@ static void me6000_ao_work_control_task(
3550 queue_delayed_work(instance->me6000_workqueue, 3550 queue_delayed_work(instance->me6000_workqueue,
3551 &instance->ao_control_task, 1); 3551 &instance->ao_control_task, 1);
3552 } else { 3552 } else {
3553 PINFO("<%s> Ending control task.\n", __FUNCTION__); 3553 PINFO("<%s> Ending control task.\n", __func__);
3554 } 3554 }
3555 3555
3556} 3556}
diff --git a/drivers/staging/meilhaus/me8100_di.c b/drivers/staging/meilhaus/me8100_di.c
index 0f146371b9a0..971727c9e305 100644
--- a/drivers/staging/meilhaus/me8100_di.c
+++ b/drivers/staging/meilhaus/me8100_di.c
@@ -536,7 +536,7 @@ static irqreturn_t me8100_isr(int irq, void *dev_id, struct pt_regs *regs)
536 PLX_INTCSR_LOCAL_INT1_EN)) { 536 PLX_INTCSR_LOCAL_INT1_EN)) {
537 PINFO 537 PINFO
538 ("%ld Shared interrupt. %s(): idx=0 plx:irq_status_reg=0x%04X\n", 538 ("%ld Shared interrupt. %s(): idx=0 plx:irq_status_reg=0x%04X\n",
539 jiffies, __FUNCTION__, icsr); 539 jiffies, __func__, icsr);
540 return IRQ_NONE; 540 return IRQ_NONE;
541 } 541 }
542 } else if (instance->di_idx == 1) { 542 } else if (instance->di_idx == 1) {
@@ -547,11 +547,11 @@ static irqreturn_t me8100_isr(int irq, void *dev_id, struct pt_regs *regs)
547 PLX_INTCSR_LOCAL_INT2_EN)) { 547 PLX_INTCSR_LOCAL_INT2_EN)) {
548 PINFO 548 PINFO
549 ("%ld Shared interrupt. %s(): idx=1 plx:irq_status_reg=0x%04X\n", 549 ("%ld Shared interrupt. %s(): idx=1 plx:irq_status_reg=0x%04X\n",
550 jiffies, __FUNCTION__, icsr); 550 jiffies, __func__, icsr);
551 return IRQ_NONE; 551 return IRQ_NONE;
552 } 552 }
553 } else { 553 } else {
554 PERROR("%s():Wrong interrupt idx=%d csr=0x%X.\n", __FUNCTION__, 554 PERROR("%s():Wrong interrupt idx=%d csr=0x%X.\n", __func__,
555 instance->di_idx, icsr); 555 instance->di_idx, icsr);
556 return IRQ_NONE; 556 return IRQ_NONE;
557 } 557 }
diff --git a/drivers/staging/meilhaus/me8200_di.c b/drivers/staging/meilhaus/me8200_di.c
index 0bb4567091cc..27525bc067b6 100644
--- a/drivers/staging/meilhaus/me8200_di.c
+++ b/drivers/staging/meilhaus/me8200_di.c
@@ -570,7 +570,7 @@ static irqreturn_t me8200_isr(int irq, void *dev_id, struct pt_regs *regs)
570 if (!irq_status) { 570 if (!irq_status) {
571 PINFO 571 PINFO
572 ("%ld Shared interrupt. %s(): idx=%d irq_status_reg=0x%04X\n", 572 ("%ld Shared interrupt. %s(): idx=%d irq_status_reg=0x%04X\n",
573 jiffies, __FUNCTION__, instance->di_idx, irq_status); 573 jiffies, __func__, instance->di_idx, irq_status);
574 return IRQ_NONE; 574 return IRQ_NONE;
575 } 575 }
576 576
@@ -658,7 +658,7 @@ static irqreturn_t me8200_isr_EX(int irq, void *dev_id, struct pt_regs *regs)
658 if (!irq_status) { 658 if (!irq_status) {
659 PINFO 659 PINFO
660 ("%ld Shared interrupt. %s(): idx=%d irq_status_reg=0x%04X\n", 660 ("%ld Shared interrupt. %s(): idx=%d irq_status_reg=0x%04X\n",
661 jiffies, __FUNCTION__, instance->di_idx, irq_status); 661 jiffies, __func__, instance->di_idx, irq_status);
662 return IRQ_NONE; 662 return IRQ_NONE;
663 } 663 }
664 664
diff --git a/drivers/staging/meilhaus/me8200_do.c b/drivers/staging/meilhaus/me8200_do.c
index 5f4ba5dfa860..d2bebd16ff41 100644
--- a/drivers/staging/meilhaus/me8200_do.c
+++ b/drivers/staging/meilhaus/me8200_do.c
@@ -475,7 +475,7 @@ static irqreturn_t me8200_do_isr(int irq, void *dev_id, struct pt_regs *regs)
475 (ME8200_DO_IRQ_STATUS_BIT_ACTIVE << instance->do_idx))) { 475 (ME8200_DO_IRQ_STATUS_BIT_ACTIVE << instance->do_idx))) {
476 PINFO 476 PINFO
477 ("%ld Shared interrupt. %s(): idx=%d irq_status_reg=0x%04X\n", 477 ("%ld Shared interrupt. %s(): idx=%d irq_status_reg=0x%04X\n",
478 jiffies, __FUNCTION__, instance->do_idx, irq_status); 478 jiffies, __func__, instance->do_idx, irq_status);
479 return IRQ_NONE; 479 return IRQ_NONE;
480 } 480 }
481 481
diff --git a/drivers/staging/meilhaus/medebug.h b/drivers/staging/meilhaus/medebug.h
index 382d00fe311d..dcfb97c26fd1 100644
--- a/drivers/staging/meilhaus/medebug.h
+++ b/drivers/staging/meilhaus/medebug.h
@@ -66,21 +66,21 @@
66 66
67#ifdef MEDEBUG_DEBUG 67#ifdef MEDEBUG_DEBUG
68# define PDEBUG(fmt, args...) \ 68# define PDEBUG(fmt, args...) \
69 printk(KERN_DEBUG"ME_DRV D: <%s> " fmt, __FUNCTION__, ##args) 69 printk(KERN_DEBUG"ME_DRV D: <%s> " fmt, __func__, ##args)
70#else 70#else
71# define PDEBUG(fmt, args...) 71# define PDEBUG(fmt, args...)
72#endif 72#endif
73 73
74#ifdef MEDEBUG_DEBUG_LOCKS 74#ifdef MEDEBUG_DEBUG_LOCKS
75# define PDEBUG_LOCKS(fmt, args...) \ 75# define PDEBUG_LOCKS(fmt, args...) \
76 printk(KERN_DEBUG"ME_DRV L: <%s> " fmt, __FUNCTION__, ##args) 76 printk(KERN_DEBUG"ME_DRV L: <%s> " fmt, __func__, ##args)
77#else 77#else
78# define PDEBUG_LOCKS(fmt, args...) 78# define PDEBUG_LOCKS(fmt, args...)
79#endif 79#endif
80 80
81#ifdef MEDEBUG_DEBUG_REG 81#ifdef MEDEBUG_DEBUG_REG
82# define PDEBUG_REG(fmt, args...) \ 82# define PDEBUG_REG(fmt, args...) \
83 printk(KERN_DEBUG"ME_DRV R: <%s:%d> REG:" fmt, __FUNCTION__, __LINE__, ##args) 83 printk(KERN_DEBUG"ME_DRV R: <%s:%d> REG:" fmt, __func__, __LINE__, ##args)
84#else 84#else
85# define PDEBUG_REG(fmt, args...) 85# define PDEBUG_REG(fmt, args...)
86#endif 86#endif
@@ -108,7 +108,7 @@
108 108
109//This debug is only to detect logical errors! 109//This debug is only to detect logical errors!
110# define PSECURITY(fmt, args...) \ 110# define PSECURITY(fmt, args...) \
111 printk(KERN_CRIT"ME_DRV SECURITY: <%s:%s:%i> " fmt, __FILE__, __FUNCTION__, __LINE__, ##args) 111 printk(KERN_CRIT"ME_DRV SECURITY: <%s:%s:%i> " fmt, __FILE__, __func__, __LINE__, ##args)
112//This debug is to keep track in customers' system 112//This debug is to keep track in customers' system
113# define PLOG(fmt, args...) \ 113# define PLOG(fmt, args...) \
114 printk(KERN_INFO"ME_DRV: " fmt, ##args) 114 printk(KERN_INFO"ME_DRV: " fmt, ##args)
@@ -116,7 +116,7 @@
116//This debug is to check new parts during development 116//This debug is to check new parts during development
117#ifdef MEDEBUG_DEVELOP 117#ifdef MEDEBUG_DEVELOP
118# define PDEVELOP(fmt, args...) \ 118# define PDEVELOP(fmt, args...) \
119 printk(KERN_CRIT"ME_DRV: <%s:%s:%i> " fmt, __FILE__, __FUNCTION__, __LINE__, ##args) 119 printk(KERN_CRIT"ME_DRV: <%s:%s:%i> " fmt, __FILE__, __func__, __LINE__, ##args)
120#else 120#else
121# define PDEVELOP(fmt, args...) 121# define PDEVELOP(fmt, args...)
122#endif 122#endif
diff --git a/drivers/staging/otus/80211core/cagg.c b/drivers/staging/otus/80211core/cagg.c
index fcfd01a6b36c..4942190747a1 100644
--- a/drivers/staging/otus/80211core/cagg.c
+++ b/drivers/staging/otus/80211core/cagg.c
@@ -1933,7 +1933,7 @@ u16_t zfAggRx(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo *addInfo, struct a
1933 */ 1933 */
1934 1934
1935 /* zm_msg2_agg(ZM_LV_0, "queue seq = ", seq_no); 1935 /* zm_msg2_agg(ZM_LV_0, "queue seq = ", seq_no);
1936 * DbgPrint("%s:%s%lxh %s%lxh\n", __FUNCTION__, "queue seq=", seq_no, 1936 * DbgPrint("%s:%s%lxh %s%lxh\n", __func__, "queue seq=", seq_no,
1937 * "; seq_start=", tid_rx->seq_start); 1937 * "; seq_start=", tid_rx->seq_start);
1938 */ 1938 */
1939 1939
diff --git a/drivers/staging/otus/80211core/pub_zfw.h b/drivers/staging/otus/80211core/pub_zfw.h
index 01a227216726..2474bb7536e8 100644
--- a/drivers/staging/otus/80211core/pub_zfw.h
+++ b/drivers/staging/otus/80211core/pub_zfw.h
@@ -23,7 +23,7 @@
23/* Buffer management */ 23/* Buffer management */
24#ifdef ZM_ENABLE_BUFFER_DEBUG 24#ifdef ZM_ENABLE_BUFFER_DEBUG
25extern zbuf_t* zfwBufAllocateWithContext(zdev_t* dev, u16_t len, u8_t *functionName, ULONG line); 25extern zbuf_t* zfwBufAllocateWithContext(zdev_t* dev, u16_t len, u8_t *functionName, ULONG line);
26#define zfwBufAllocate(dev, len) zfwBufAllocateWithContext(dev, len, (u8_t *)__FUNCTION__, __LINE__) 26#define zfwBufAllocate(dev, len) zfwBufAllocateWithContext(dev, len, (u8_t *)__func__, __LINE__)
27#else 27#else
28extern zbuf_t* zfwBufAllocate(zdev_t* dev, u16_t len); 28extern zbuf_t* zfwBufAllocate(zdev_t* dev, u16_t len);
29#endif 29#endif
diff --git a/drivers/staging/otus/80211core/struct.h b/drivers/staging/otus/80211core/struct.h
index 43631c630a8f..17b5ce37ebb5 100644
--- a/drivers/staging/otus/80211core/struct.h
+++ b/drivers/staging/otus/80211core/struct.h
@@ -137,7 +137,7 @@ extern const u8_t zg11gRateTbl[8];
137 137
138#ifdef ZM_ENABLE_BUFFER_TRACE 138#ifdef ZM_ENABLE_BUFFER_TRACE
139extern void zfwBufTrace(zdev_t* dev, zbuf_t *buf, u8_t *functionName); 139extern void zfwBufTrace(zdev_t* dev, zbuf_t *buf, u8_t *functionName);
140#define ZM_BUFFER_TRACE(dev, buf) zfwBufTrace(dev, buf, __FUNCTION__); 140#define ZM_BUFFER_TRACE(dev, buf) zfwBufTrace(dev, buf, __func__);
141#else 141#else
142#define ZM_BUFFER_TRACE(dev, buf) 142#define ZM_BUFFER_TRACE(dev, buf)
143#endif 143#endif
diff --git a/drivers/staging/otus/oal_marc.h b/drivers/staging/otus/oal_marc.h
index 438e4bc2e9a6..206111616a03 100644
--- a/drivers/staging/otus/oal_marc.h
+++ b/drivers/staging/otus/oal_marc.h
@@ -106,14 +106,14 @@
106 106
107/***** Debug message *****/ 107/***** Debug message *****/
108#if 0 108#if 0
109#define zm_debug_msg0(msg) printk("%s:%s\n", __FUNCTION__, msg); 109#define zm_debug_msg0(msg) printk("%s:%s\n", __func__, msg);
110#define zm_debug_msg1(msg, val) printk("%s:%s%ld\n", __FUNCTION__, \ 110#define zm_debug_msg1(msg, val) printk("%s:%s%ld\n", __func__, \
111 msg, (u32_t)val); 111 msg, (u32_t)val);
112#define zm_debug_msg2(msg, val) printk("%s:%s%lxh\n", __FUNCTION__, \ 112#define zm_debug_msg2(msg, val) printk("%s:%s%lxh\n", __func__, \
113 msg, (u32_t)val); 113 msg, (u32_t)val);
114#define zm_debug_msg_s(msg, val) printk("%s:%s%s\n", __FUNCTION__, \ 114#define zm_debug_msg_s(msg, val) printk("%s:%s%s\n", __func__, \
115 msg, val); 115 msg, val);
116#define zm_debug_msg_p(msg, val1, val2) printk("%s:%s%01ld.%02ld\n", __FUNCTION__, \ 116#define zm_debug_msg_p(msg, val1, val2) printk("%s:%s%01ld.%02ld\n", __func__, \
117 msg, (val1/val2), (((val1*100)/val2)%100)); 117 msg, (val1/val2), (((val1*100)/val2)%100));
118#define zm_dbg(S) printk S 118#define zm_dbg(S) printk S
119#else 119#else
@@ -127,7 +127,7 @@
127 127
128#define zm_assert(expr) if(!(expr)) { \ 128#define zm_assert(expr) if(!(expr)) { \
129 printk( "Atheors Assertion failed! %s,%s,%s,line=%d\n", \ 129 printk( "Atheors Assertion failed! %s,%s,%s,line=%d\n", \
130 #expr,__FILE__,__FUNCTION__,__LINE__); \ 130 #expr,__FILE__,__func__,__LINE__); \
131 } 131 }
132 132
133#define DbgPrint printk 133#define DbgPrint printk
diff --git a/drivers/staging/rt2860/2860_main_dev.c b/drivers/staging/rt2860/2860_main_dev.c
index 1e38f2d1f692..08ca81f43cc8 100644
--- a/drivers/staging/rt2860/2860_main_dev.c
+++ b/drivers/staging/rt2860/2860_main_dev.c
@@ -1202,7 +1202,7 @@ VOID RT28xx_UpdateBeaconToAsic(
1202 UCHAR bcn_idx = 0; 1202 UCHAR bcn_idx = 0;
1203 1203
1204 { 1204 {
1205 DBGPRINT(RT_DEBUG_ERROR, ("%s() : No valid Interface be found.\n", __FUNCTION__)); 1205 DBGPRINT(RT_DEBUG_ERROR, ("%s() : No valid Interface be found.\n", __func__));
1206 return; 1206 return;
1207 } 1207 }
1208 1208
diff --git a/drivers/staging/rt2860/common/ba_action.c b/drivers/staging/rt2860/common/ba_action.c
index 8247aeb73a23..591d1e2158da 100644
--- a/drivers/staging/rt2860/common/ba_action.c
+++ b/drivers/staging/rt2860/common/ba_action.c
@@ -599,7 +599,7 @@ VOID BAOriSessionAdd(
599 599
600 pBAEntry->ORIBATimer.TimerValue = 0; //pFrame->TimeOutValue; 600 pBAEntry->ORIBATimer.TimerValue = 0; //pFrame->TimeOutValue;
601 601
602 DBGPRINT(RT_DEBUG_TRACE,("%s : TXBAbitmap = %x, BAWinSize = %d, TimeOut = %ld\n", __FUNCTION__, pEntry->TXBAbitmap, 602 DBGPRINT(RT_DEBUG_TRACE,("%s : TXBAbitmap = %x, BAWinSize = %d, TimeOut = %ld\n", __func__, pEntry->TXBAbitmap,
603 pBAEntry->BAWinSize, pBAEntry->ORIBATimer.TimerValue)); 603 pBAEntry->BAWinSize, pBAEntry->ORIBATimer.TimerValue));
604 604
605 // SEND BAR ; 605 // SEND BAR ;
@@ -673,7 +673,7 @@ BOOLEAN BARecSessionAdd(
673 ba_refresh_reordering_mpdus(pAd, pBAEntry); 673 ba_refresh_reordering_mpdus(pAd, pBAEntry);
674 } 674 }
675 675
676 DBGPRINT(RT_DEBUG_TRACE,("%s(%ld): Idx = %d, BAWinSize(req %d) = %d\n", __FUNCTION__, pAd->BATable.numAsRecipient, Idx, 676 DBGPRINT(RT_DEBUG_TRACE,("%s(%ld): Idx = %d, BAWinSize(req %d) = %d\n", __func__, pAd->BATable.numAsRecipient, Idx,
677 pFrame->BaParm.BufSize, BAWinSize)); 677 pFrame->BaParm.BufSize, BAWinSize));
678 678
679 // Start fill in parameters. 679 // Start fill in parameters.
@@ -915,7 +915,7 @@ VOID BAOriSessionTearDown(
915 return; 915 return;
916 } 916 }
917 917
918 DBGPRINT(RT_DEBUG_TRACE,("%s===>Wcid=%d.TID=%d \n", __FUNCTION__, Wcid, TID)); 918 DBGPRINT(RT_DEBUG_TRACE,("%s===>Wcid=%d.TID=%d \n", __func__, Wcid, TID));
919 919
920 pBAEntry = &pAd->BATable.BAOriEntry[Idx]; 920 pBAEntry = &pAd->BATable.BAOriEntry[Idx];
921 DBGPRINT(RT_DEBUG_TRACE,("\t===>Idx = %ld, Wcid=%d.TID=%d, ORI_BA_Status = %d \n", Idx, Wcid, TID, pBAEntry->ORI_BA_Status)); 921 DBGPRINT(RT_DEBUG_TRACE,("\t===>Idx = %ld, Wcid=%d.TID=%d, ORI_BA_Status = %d \n", Idx, Wcid, TID, pBAEntry->ORI_BA_Status));
@@ -974,7 +974,7 @@ VOID BARecSessionTearDown(
974 if (Idx == 0) 974 if (Idx == 0)
975 return; 975 return;
976 976
977 DBGPRINT(RT_DEBUG_TRACE,("%s===>Wcid=%d.TID=%d \n", __FUNCTION__, Wcid, TID)); 977 DBGPRINT(RT_DEBUG_TRACE,("%s===>Wcid=%d.TID=%d \n", __func__, Wcid, TID));
978 978
979 979
980 pBAEntry = &pAd->BATable.BARecEntry[Idx]; 980 pBAEntry = &pAd->BATable.BARecEntry[Idx];
@@ -1185,7 +1185,7 @@ VOID PeerAddBAReqAction(
1185 PULONG ptemp; 1185 PULONG ptemp;
1186 PMAC_TABLE_ENTRY pMacEntry; 1186 PMAC_TABLE_ENTRY pMacEntry;
1187 1187
1188 DBGPRINT(RT_DEBUG_TRACE, ("%s ==> (Wcid = %d)\n", __FUNCTION__, Elem->Wcid)); 1188 DBGPRINT(RT_DEBUG_TRACE, ("%s ==> (Wcid = %d)\n", __func__, Elem->Wcid));
1189 1189
1190 //hex_dump("AddBAReq", Elem->Msg, Elem->MsgLen); 1190 //hex_dump("AddBAReq", Elem->Msg, Elem->MsgLen);
1191 1191
@@ -1269,7 +1269,7 @@ VOID PeerAddBAReqAction(
1269 MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen); 1269 MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
1270 MlmeFreeMemory(pAd, pOutBuffer); 1270 MlmeFreeMemory(pAd, pOutBuffer);
1271 1271
1272 DBGPRINT(RT_DEBUG_TRACE, ("%s(%d): TID(%d), BufSize(%d) <== \n", __FUNCTION__, Elem->Wcid, ADDframe.BaParm.TID, 1272 DBGPRINT(RT_DEBUG_TRACE, ("%s(%d): TID(%d), BufSize(%d) <== \n", __func__, Elem->Wcid, ADDframe.BaParm.TID,
1273 ADDframe.BaParm.BufSize)); 1273 ADDframe.BaParm.BufSize));
1274} 1274}
1275 1275
@@ -1288,7 +1288,7 @@ VOID PeerAddBARspAction(
1288 if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE) 1288 if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
1289 return; 1289 return;
1290 1290
1291 DBGPRINT(RT_DEBUG_TRACE, ("%s ==> Wcid(%d)\n", __FUNCTION__, Elem->Wcid)); 1291 DBGPRINT(RT_DEBUG_TRACE, ("%s ==> Wcid(%d)\n", __func__, Elem->Wcid));
1292 1292
1293 //hex_dump("PeerAddBARspAction()", Elem->Msg, Elem->MsgLen); 1293 //hex_dump("PeerAddBARspAction()", Elem->Msg, Elem->MsgLen);
1294 1294
@@ -1329,7 +1329,7 @@ VOID PeerDelBAAction(
1329 //PUCHAR pOutBuffer = NULL; 1329 //PUCHAR pOutBuffer = NULL;
1330 PFRAME_DELBA_REQ pDelFrame = NULL; 1330 PFRAME_DELBA_REQ pDelFrame = NULL;
1331 1331
1332 DBGPRINT(RT_DEBUG_TRACE,("%s ==>\n", __FUNCTION__)); 1332 DBGPRINT(RT_DEBUG_TRACE,("%s ==>\n", __func__));
1333 //DELBA Request from unknown peer, ignore this. 1333 //DELBA Request from unknown peer, ignore this.
1334 if (PeerDelBAActionSanity(pAd, Elem->Wcid, Elem->Msg, Elem->MsgLen)) 1334 if (PeerDelBAActionSanity(pAd, Elem->Wcid, Elem->Msg, Elem->MsgLen))
1335 { 1335 {
@@ -1366,7 +1366,7 @@ BOOLEAN CntlEnqueueForRecv(
1366 1366
1367 TID = (UCHAR)pFrame->BARControl.TID; 1367 TID = (UCHAR)pFrame->BARControl.TID;
1368 1368
1369 DBGPRINT(RT_DEBUG_TRACE, ("%s(): BAR-Wcid(%ld), Tid (%d)\n", __FUNCTION__, Wcid, TID)); 1369 DBGPRINT(RT_DEBUG_TRACE, ("%s(): BAR-Wcid(%ld), Tid (%d)\n", __func__, Wcid, TID));
1370 //hex_dump("BAR", (PCHAR) pFrame, MsgLen); 1370 //hex_dump("BAR", (PCHAR) pFrame, MsgLen);
1371 // Do nothing if the driver is starting halt state. 1371 // Do nothing if the driver is starting halt state.
1372 // This might happen when timer already been fired before cancel timer with mlmehalt 1372 // This might happen when timer already been fired before cancel timer with mlmehalt
diff --git a/drivers/staging/rt2860/common/cmm_data.c b/drivers/staging/rt2860/common/cmm_data.c
index ac549011ccb9..b67b9eba7229 100644
--- a/drivers/staging/rt2860/common/cmm_data.c
+++ b/drivers/staging/rt2860/common/cmm_data.c
@@ -2787,7 +2787,7 @@ BOOLEAN MacTableDeleteEntry(
2787 } 2787 }
2788 else 2788 else
2789 { 2789 {
2790 printk("\n%s: Impossible Wcid = %d !!!!!\n", __FUNCTION__, wcid); 2790 printk("\n%s: Impossible Wcid = %d !!!!!\n", __func__, wcid);
2791 } 2791 }
2792 } 2792 }
2793 2793
diff --git a/drivers/staging/rt2860/common/cmm_data_2860.c b/drivers/staging/rt2860/common/cmm_data_2860.c
index 4f414edd658c..419e50c3fc4c 100644
--- a/drivers/staging/rt2860/common/cmm_data_2860.c
+++ b/drivers/staging/rt2860/common/cmm_data_2860.c
@@ -1002,7 +1002,7 @@ VOID RT28xxPciStaAsicSleepThenAutoWakeup(
1002 AutoWakeupCfg.field.AutoLeadTime = 5; 1002 AutoWakeupCfg.field.AutoLeadTime = 5;
1003 RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word); 1003 RTMP_IO_WRITE32(pAd, AUTO_WAKEUP_CFG, AutoWakeupCfg.word);
1004 AsicSendCommandToMcu(pAd, 0x30, 0xff, 0xff, 0x00); // send POWER-SAVE command to MCU. Timeout 40us. 1004 AsicSendCommandToMcu(pAd, 0x30, 0xff, 0xff, 0x00); // send POWER-SAVE command to MCU. Timeout 40us.
1005 DBGPRINT(RT_DEBUG_TRACE, ("<-- %s, TbttNumToNextWakeUp=%d \n", __FUNCTION__, TbttNumToNextWakeUp)); 1005 DBGPRINT(RT_DEBUG_TRACE, ("<-- %s, TbttNumToNextWakeUp=%d \n", __func__, TbttNumToNextWakeUp));
1006 } 1006 }
1007 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_DOZE); 1007 OPSTATUS_SET_FLAG(pAd, fOP_STATUS_DOZE);
1008} 1008}
@@ -1115,7 +1115,7 @@ VOID RT28xxPciMlmeRadioOn(
1115 if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF)) 1115 if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
1116 return; 1116 return;
1117 1117
1118 DBGPRINT(RT_DEBUG_TRACE,("%s===>\n", __FUNCTION__)); 1118 DBGPRINT(RT_DEBUG_TRACE,("%s===>\n", __func__));
1119 1119
1120 if ((pAd->OpMode == OPMODE_AP) || 1120 if ((pAd->OpMode == OPMODE_AP) ||
1121 ((pAd->OpMode == OPMODE_STA) && (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE)))) 1121 ((pAd->OpMode == OPMODE_STA) && (!OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_ADVANCE_POWER_SAVE_PCIE_DEVICE))))
@@ -1165,7 +1165,7 @@ VOID RT28xxPciMlmeRadioOFF(
1165 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF)) 1165 if (RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF))
1166 return; 1166 return;
1167 1167
1168 DBGPRINT(RT_DEBUG_TRACE,("%s===>\n", __FUNCTION__)); 1168 DBGPRINT(RT_DEBUG_TRACE,("%s===>\n", __func__));
1169 1169
1170 // Set LED 1170 // Set LED
1171 RTMPSetLED(pAd, LED_RADIO_OFF); 1171 RTMPSetLED(pAd, LED_RADIO_OFF);
diff --git a/drivers/staging/rt2860/common/cmm_info.c b/drivers/staging/rt2860/common/cmm_info.c
index 0aadf8af633a..dd92ac6eaed2 100644
--- a/drivers/staging/rt2860/common/cmm_info.c
+++ b/drivers/staging/rt2860/common/cmm_info.c
@@ -2039,7 +2039,7 @@ VOID RTMPIoctlGetMacTable(
2039 wrq->u.data.length = sizeof(RT_802_11_MAC_TABLE); 2039 wrq->u.data.length = sizeof(RT_802_11_MAC_TABLE);
2040 if (copy_to_user(wrq->u.data.pointer, &MacTab, wrq->u.data.length)) 2040 if (copy_to_user(wrq->u.data.pointer, &MacTab, wrq->u.data.length))
2041 { 2041 {
2042 DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __FUNCTION__)); 2042 DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __func__));
2043 } 2043 }
2044 2044
2045 msg = (CHAR *) kmalloc(sizeof(CHAR)*(MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN), MEM_ALLOC_FLAG); 2045 msg = (CHAR *) kmalloc(sizeof(CHAR)*(MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN), MEM_ALLOC_FLAG);
diff --git a/drivers/staging/rt2860/common/dfs.c b/drivers/staging/rt2860/common/dfs.c
index 23cf1510e2d2..b09bba5cb206 100644
--- a/drivers/staging/rt2860/common/dfs.c
+++ b/drivers/staging/rt2860/common/dfs.c
@@ -428,7 +428,7 @@ INT Set_ChMovingTime_Proc(
428 428
429 pAd->CommonCfg.RadarDetect.ChMovingTime = Value; 429 pAd->CommonCfg.RadarDetect.ChMovingTime = Value;
430 430
431 DBGPRINT(RT_DEBUG_TRACE, ("%s:: %d\n", __FUNCTION__, 431 DBGPRINT(RT_DEBUG_TRACE, ("%s:: %d\n", __func__,
432 pAd->CommonCfg.RadarDetect.ChMovingTime)); 432 pAd->CommonCfg.RadarDetect.ChMovingTime));
433 433
434 return TRUE; 434 return TRUE;
@@ -444,7 +444,7 @@ INT Set_LongPulseRadarTh_Proc(
444 444
445 pAd->CommonCfg.RadarDetect.LongPulseRadarTh = Value; 445 pAd->CommonCfg.RadarDetect.LongPulseRadarTh = Value;
446 446
447 DBGPRINT(RT_DEBUG_TRACE, ("%s:: %d\n", __FUNCTION__, 447 DBGPRINT(RT_DEBUG_TRACE, ("%s:: %d\n", __func__,
448 pAd->CommonCfg.RadarDetect.LongPulseRadarTh)); 448 pAd->CommonCfg.RadarDetect.LongPulseRadarTh));
449 449
450 return TRUE; 450 return TRUE;
diff --git a/drivers/staging/rt2860/common/rtmp_init.c b/drivers/staging/rt2860/common/rtmp_init.c
index 84edfa52dec3..563f2c5bb856 100644
--- a/drivers/staging/rt2860/common/rtmp_init.c
+++ b/drivers/staging/rt2860/common/rtmp_init.c
@@ -2542,7 +2542,7 @@ NDIS_STATUS NICLoadFirmware(
2542#ifdef BIN_IN_FILE 2542#ifdef BIN_IN_FILE
2543#define NICLF_DEFAULT_USE() \ 2543#define NICLF_DEFAULT_USE() \
2544 flg_default_firm_use = TRUE; \ 2544 flg_default_firm_use = TRUE; \
2545 printk("%s - Use default firmware!\n", __FUNCTION__); 2545 printk("%s - Use default firmware!\n", __func__);
2546 2546
2547 NDIS_STATUS Status = NDIS_STATUS_SUCCESS; 2547 NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
2548 PUCHAR src; 2548 PUCHAR src;
@@ -2557,7 +2557,7 @@ NDIS_STATUS NICLoadFirmware(
2557 BOOLEAN flg_default_firm_use = FALSE; 2557 BOOLEAN flg_default_firm_use = FALSE;
2558 2558
2559 2559
2560 DBGPRINT(RT_DEBUG_TRACE, ("===> %s\n", __FUNCTION__)); 2560 DBGPRINT(RT_DEBUG_TRACE, ("===> %s\n", __func__));
2561 2561
2562 /* init */ 2562 /* init */
2563 pFirmwareImage = NULL; 2563 pFirmwareImage = NULL;
@@ -2580,7 +2580,7 @@ NDIS_STATUS NICLoadFirmware(
2580 if (pFirmwareImage == NULL) 2580 if (pFirmwareImage == NULL)
2581 { 2581 {
2582 /* allocate fail, use default firmware array in firmware.h */ 2582 /* allocate fail, use default firmware array in firmware.h */
2583 printk("%s - Allocate memory fail!\n", __FUNCTION__); 2583 printk("%s - Allocate memory fail!\n", __func__);
2584 NICLF_DEFAULT_USE(); 2584 NICLF_DEFAULT_USE();
2585 } 2585 }
2586 else 2586 else
@@ -2601,7 +2601,7 @@ NDIS_STATUS NICLoadFirmware(
2601 if (IS_ERR(srcf)) 2601 if (IS_ERR(srcf))
2602 { 2602 {
2603 printk("%s - Error %ld opening %s\n", 2603 printk("%s - Error %ld opening %s\n",
2604 __FUNCTION__, -PTR_ERR(srcf), src); 2604 __func__, -PTR_ERR(srcf), src);
2605 NICLF_DEFAULT_USE(); 2605 NICLF_DEFAULT_USE();
2606 break; 2606 break;
2607 } /* End of if */ 2607 } /* End of if */
@@ -2609,7 +2609,7 @@ NDIS_STATUS NICLoadFirmware(
2609 /* the object must have a read method */ 2609 /* the object must have a read method */
2610 if ((srcf->f_op == NULL) || (srcf->f_op->read == NULL)) 2610 if ((srcf->f_op == NULL) || (srcf->f_op->read == NULL))
2611 { 2611 {
2612 printk("%s - %s does not have a write method\n", __FUNCTION__, src); 2612 printk("%s - %s does not have a write method\n", __func__, src);
2613 NICLF_DEFAULT_USE(); 2613 NICLF_DEFAULT_USE();
2614 break; 2614 break;
2615 } /* End of if */ 2615 } /* End of if */
@@ -2623,7 +2623,7 @@ NDIS_STATUS NICLoadFirmware(
2623 if (FileLength != MAX_FIRMWARE_IMAGE_SIZE) 2623 if (FileLength != MAX_FIRMWARE_IMAGE_SIZE)
2624 { 2624 {
2625 printk("%s: error file length (=%d) in RT2860AP.BIN\n", 2625 printk("%s: error file length (=%d) in RT2860AP.BIN\n",
2626 __FUNCTION__, FileLength); 2626 __func__, FileLength);
2627 NICLF_DEFAULT_USE(); 2627 NICLF_DEFAULT_USE();
2628 break; 2628 break;
2629 } 2629 }
@@ -2646,7 +2646,7 @@ NDIS_STATUS NICLoadFirmware(
2646 /* CRC fail */ 2646 /* CRC fail */
2647 printk("%s: CRC = 0x%02x 0x%02x " 2647 printk("%s: CRC = 0x%02x 0x%02x "
2648 "error, should be 0x%02x 0x%02x\n", 2648 "error, should be 0x%02x 0x%02x\n",
2649 __FUNCTION__, 2649 __func__,
2650 pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-2], 2650 pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-2],
2651 pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-1], 2651 pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-1],
2652 (UCHAR)(crc>>8), (UCHAR)(crc)); 2652 (UCHAR)(crc>>8), (UCHAR)(crc));
@@ -2665,7 +2665,7 @@ NDIS_STATUS NICLoadFirmware(
2665 ((FIRMWARE_MAJOR_VERSION << 8) + 2665 ((FIRMWARE_MAJOR_VERSION << 8) +
2666 FIRMWARE_MINOR_VERSION)) 2666 FIRMWARE_MINOR_VERSION))
2667 { 2667 {
2668 printk("%s: firmware version too old!\n", __FUNCTION__); 2668 printk("%s: firmware version too old!\n", __func__);
2669 NICLF_DEFAULT_USE(); 2669 NICLF_DEFAULT_USE();
2670 break; 2670 break;
2671 } /* End of if */ 2671 } /* End of if */
@@ -2770,7 +2770,7 @@ NDIS_STATUS NICLoadFirmware(
2770 } /* End of if */ 2770 } /* End of if */
2771 2771
2772 DBGPRINT(RT_DEBUG_TRACE, 2772 DBGPRINT(RT_DEBUG_TRACE,
2773 ("<=== %s (status=%d)\n", __FUNCTION__, Status)); 2773 ("<=== %s (status=%d)\n", __func__, Status));
2774 return Status; 2774 return Status;
2775} /* End of NICLoadFirmware */ 2775} /* End of NICLoadFirmware */
2776 2776
diff --git a/drivers/staging/rt2860/common/spectrum.c b/drivers/staging/rt2860/common/spectrum.c
index 85e636a607f7..0265a6d1df1a 100644
--- a/drivers/staging/rt2860/common/spectrum.c
+++ b/drivers/staging/rt2860/common/spectrum.c
@@ -49,7 +49,7 @@ VOID MeasureReqTabInit(
49 if (pAd->CommonCfg.pMeasureReqTab) 49 if (pAd->CommonCfg.pMeasureReqTab)
50 NdisZeroMemory(pAd->CommonCfg.pMeasureReqTab, sizeof(MEASURE_REQ_TAB)); 50 NdisZeroMemory(pAd->CommonCfg.pMeasureReqTab, sizeof(MEASURE_REQ_TAB));
51 else 51 else
52 DBGPRINT(RT_DEBUG_ERROR, ("%s Fail to alloc memory for pAd->CommonCfg.pMeasureReqTab.\n", __FUNCTION__)); 52 DBGPRINT(RT_DEBUG_ERROR, ("%s Fail to alloc memory for pAd->CommonCfg.pMeasureReqTab.\n", __func__));
53 53
54 return; 54 return;
55} 55}
@@ -77,7 +77,7 @@ static PMEASURE_REQ_ENTRY MeasureReqLookUp(
77 77
78 if (pTab == NULL) 78 if (pTab == NULL)
79 { 79 {
80 DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __FUNCTION__)); 80 DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __func__));
81 return NULL; 81 return NULL;
82 } 82 }
83 83
@@ -114,7 +114,7 @@ static PMEASURE_REQ_ENTRY MeasureReqInsert(
114 114
115 if(pTab == NULL) 115 if(pTab == NULL)
116 { 116 {
117 DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __FUNCTION__)); 117 DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __func__));
118 return NULL; 118 return NULL;
119 } 119 }
120 120
@@ -175,7 +175,7 @@ static PMEASURE_REQ_ENTRY MeasureReqInsert(
175 else 175 else
176 { 176 {
177 pEntry = NULL; 177 pEntry = NULL;
178 DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab tab full.\n", __FUNCTION__)); 178 DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab tab full.\n", __func__));
179 } 179 }
180 180
181 // add this Neighbor entry into HASH table 181 // add this Neighbor entry into HASH table
@@ -210,7 +210,7 @@ static VOID MeasureReqDelete(
210 210
211 if(pTab == NULL) 211 if(pTab == NULL)
212 { 212 {
213 DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __FUNCTION__)); 213 DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __func__));
214 return; 214 return;
215 } 215 }
216 216
@@ -267,7 +267,7 @@ VOID TpcReqTabInit(
267 if (pAd->CommonCfg.pTpcReqTab) 267 if (pAd->CommonCfg.pTpcReqTab)
268 NdisZeroMemory(pAd->CommonCfg.pTpcReqTab, sizeof(TPC_REQ_TAB)); 268 NdisZeroMemory(pAd->CommonCfg.pTpcReqTab, sizeof(TPC_REQ_TAB));
269 else 269 else
270 DBGPRINT(RT_DEBUG_ERROR, ("%s Fail to alloc memory for pAd->CommonCfg.pTpcReqTab.\n", __FUNCTION__)); 270 DBGPRINT(RT_DEBUG_ERROR, ("%s Fail to alloc memory for pAd->CommonCfg.pTpcReqTab.\n", __func__));
271 271
272 return; 272 return;
273} 273}
@@ -295,7 +295,7 @@ static PTPC_REQ_ENTRY TpcReqLookUp(
295 295
296 if (pTab == NULL) 296 if (pTab == NULL)
297 { 297 {
298 DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __FUNCTION__)); 298 DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __func__));
299 return NULL; 299 return NULL;
300 } 300 }
301 301
@@ -333,7 +333,7 @@ static PTPC_REQ_ENTRY TpcReqInsert(
333 333
334 if(pTab == NULL) 334 if(pTab == NULL)
335 { 335 {
336 DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __FUNCTION__)); 336 DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __func__));
337 return NULL; 337 return NULL;
338 } 338 }
339 339
@@ -394,7 +394,7 @@ static PTPC_REQ_ENTRY TpcReqInsert(
394 else 394 else
395 { 395 {
396 pEntry = NULL; 396 pEntry = NULL;
397 DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab tab full.\n", __FUNCTION__)); 397 DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab tab full.\n", __func__));
398 } 398 }
399 399
400 // add this Neighbor entry into HASH table 400 // add this Neighbor entry into HASH table
@@ -429,7 +429,7 @@ static VOID TpcReqDelete(
429 429
430 if(pTab == NULL) 430 if(pTab == NULL)
431 { 431 {
432 DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __FUNCTION__)); 432 DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __func__));
433 return; 433 return;
434 } 434 }
435 435
@@ -782,7 +782,7 @@ VOID EnqueueMeasurementReq(
782 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory 782 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
783 if(NStatus != NDIS_STATUS_SUCCESS) 783 if(NStatus != NDIS_STATUS_SUCCESS)
784 { 784 {
785 DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __FUNCTION__)); 785 DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __func__));
786 return; 786 return;
787 } 787 }
788 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11)); 788 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
@@ -844,7 +844,7 @@ VOID EnqueueMeasurementRep(
844 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory 844 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
845 if(NStatus != NDIS_STATUS_SUCCESS) 845 if(NStatus != NDIS_STATUS_SUCCESS)
846 { 846 {
847 DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __FUNCTION__)); 847 DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __func__));
848 return; 848 return;
849 } 849 }
850 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11)); 850 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
@@ -898,7 +898,7 @@ VOID EnqueueTPCReq(
898 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory 898 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
899 if(NStatus != NDIS_STATUS_SUCCESS) 899 if(NStatus != NDIS_STATUS_SUCCESS)
900 { 900 {
901 DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __FUNCTION__)); 901 DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __func__));
902 return; 902 return;
903 } 903 }
904 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11)); 904 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
@@ -950,7 +950,7 @@ VOID EnqueueTPCRep(
950 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory 950 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
951 if(NStatus != NDIS_STATUS_SUCCESS) 951 if(NStatus != NDIS_STATUS_SUCCESS)
952 { 952 {
953 DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __FUNCTION__)); 953 DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __func__));
954 return; 954 return;
955 } 955 }
956 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11)); 956 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
@@ -1003,7 +1003,7 @@ VOID EnqueueChSwAnn(
1003 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory 1003 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
1004 if(NStatus != NDIS_STATUS_SUCCESS) 1004 if(NStatus != NDIS_STATUS_SUCCESS)
1005 { 1005 {
1006 DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __FUNCTION__)); 1006 DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __func__));
1007 return; 1007 return;
1008 } 1008 }
1009 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11)); 1009 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
@@ -1596,7 +1596,7 @@ static VOID PeerMeasureReportAction(
1596 1596
1597 if ((pMeasureReportInfo = kmalloc(sizeof(MEASURE_RPI_REPORT), GFP_ATOMIC)) == NULL) 1597 if ((pMeasureReportInfo = kmalloc(sizeof(MEASURE_RPI_REPORT), GFP_ATOMIC)) == NULL)
1598 { 1598 {
1599 DBGPRINT(RT_DEBUG_ERROR, ("%s unable to alloc memory for measure report buffer (size=%d).\n", __FUNCTION__, sizeof(MEASURE_RPI_REPORT))); 1599 DBGPRINT(RT_DEBUG_ERROR, ("%s unable to alloc memory for measure report buffer (size=%d).\n", __func__, sizeof(MEASURE_RPI_REPORT)));
1600 return; 1600 return;
1601 } 1601 }
1602 1602
@@ -1705,7 +1705,7 @@ static VOID PeerTpcRepAction(
1705 { 1705 {
1706 TpcReqDelete(pAd, pEntry->DialogToken); 1706 TpcReqDelete(pAd, pEntry->DialogToken);
1707 DBGPRINT(RT_DEBUG_TRACE, ("%s: DialogToken=%x, TxPwr=%d, LinkMargin=%d\n", 1707 DBGPRINT(RT_DEBUG_TRACE, ("%s: DialogToken=%x, TxPwr=%d, LinkMargin=%d\n",
1708 __FUNCTION__, DialogToken, TpcRepInfo.TxPwr, TpcRepInfo.LinkMargin)); 1708 __func__, DialogToken, TpcRepInfo.TxPwr, TpcRepInfo.LinkMargin));
1709 } 1709 }
1710 } 1710 }
1711 1711
@@ -1821,7 +1821,7 @@ INT Set_MeasureReq_Proc(
1821 MeasureReqType = simple_strtol(thisChar, 0, 16); 1821 MeasureReqType = simple_strtol(thisChar, 0, 16);
1822 if (MeasureReqType > 3) 1822 if (MeasureReqType > 3)
1823 { 1823 {
1824 DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow MeasureReqType(%d)\n", __FUNCTION__, MeasureReqType)); 1824 DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow MeasureReqType(%d)\n", __func__, MeasureReqType));
1825 return TRUE; 1825 return TRUE;
1826 } 1826 }
1827 break; 1827 break;
@@ -1833,10 +1833,10 @@ INT Set_MeasureReq_Proc(
1833 ArgIdx++; 1833 ArgIdx++;
1834 } 1834 }
1835 1835
1836 DBGPRINT(RT_DEBUG_TRACE, ("%s::Aid = %d, MeasureReqType=%d MeasureCh=%d\n", __FUNCTION__, Aid, MeasureReqType, MeasureCh)); 1836 DBGPRINT(RT_DEBUG_TRACE, ("%s::Aid = %d, MeasureReqType=%d MeasureCh=%d\n", __func__, Aid, MeasureReqType, MeasureCh));
1837 if (!VALID_WCID(Aid)) 1837 if (!VALID_WCID(Aid))
1838 { 1838 {
1839 DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow sta of Aid(%d)\n", __FUNCTION__, Aid)); 1839 DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow sta of Aid(%d)\n", __func__, Aid));
1840 return TRUE; 1840 return TRUE;
1841 } 1841 }
1842 1842
@@ -1861,10 +1861,10 @@ INT Set_TpcReq_Proc(
1861 1861
1862 Aid = simple_strtol(arg, 0, 16); 1862 Aid = simple_strtol(arg, 0, 16);
1863 1863
1864 DBGPRINT(RT_DEBUG_TRACE, ("%s::Aid = %d\n", __FUNCTION__, Aid)); 1864 DBGPRINT(RT_DEBUG_TRACE, ("%s::Aid = %d\n", __func__, Aid));
1865 if (!VALID_WCID(Aid)) 1865 if (!VALID_WCID(Aid))
1866 { 1866 {
1867 DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow sta of Aid(%d)\n", __FUNCTION__, Aid)); 1867 DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow sta of Aid(%d)\n", __func__, Aid));
1868 return TRUE; 1868 return TRUE;
1869 } 1869 }
1870 1870
diff --git a/drivers/staging/rt2860/rt_ate.c b/drivers/staging/rt2860/rt_ate.c
index 2f07db565c30..f3316ec0b156 100644
--- a/drivers/staging/rt2860/rt_ate.c
+++ b/drivers/staging/rt2860/rt_ate.c
@@ -291,7 +291,7 @@ static INT ATETxPwrHandler(
291 Bbp94 = BBPR94_DEFAULT; 291 Bbp94 = BBPR94_DEFAULT;
292 } 292 }
293 293
294 ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R=%ld, BBP_R94=%d)\n", __FUNCTION__, TxPower, R, Bbp94)); 294 ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R=%ld, BBP_R94=%d)\n", __func__, TxPower, R, Bbp94));
295 } 295 }
296 else// 5.5 GHz 296 else// 5.5 GHz
297 { 297 {
@@ -318,7 +318,7 @@ static INT ATETxPwrHandler(
318 R = (ULONG) TxPower; 318 R = (ULONG) TxPower;
319 } 319 }
320 320
321 ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R=%lu)\n", __FUNCTION__, TxPower, R)); 321 ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R=%lu)\n", __func__, TxPower, R));
322 } 322 }
323 323
324 if (pAd->ate.Channel <= 14) 324 if (pAd->ate.Channel <= 14)
@@ -431,7 +431,7 @@ static INT ATETxPwrHandler(
431 Bbp94 = BBPR94_DEFAULT; 431 Bbp94 = BBPR94_DEFAULT;
432 } 432 }
433 433
434 ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R3=%ld, BBP_R94=%d)\n", __FUNCTION__, TxPower, R, Bbp94)); 434 ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R3=%ld, BBP_R94=%d)\n", __func__, TxPower, R, Bbp94));
435 435
436 if (pAd->ate.Channel <= 14) 436 if (pAd->ate.Channel <= 14)
437 { 437 {
@@ -2098,7 +2098,7 @@ INT Set_ATE_Load_E2P_Proc(
2098 UINT32 FileLength = 0; 2098 UINT32 FileLength = 0;
2099 UINT32 value = simple_strtol(arg, 0, 10); 2099 UINT32 value = simple_strtol(arg, 0, 10);
2100 2100
2101 ATEDBGPRINT(RT_DEBUG_ERROR, ("===> %s (value=%d)\n\n", __FUNCTION__, value)); 2101 ATEDBGPRINT(RT_DEBUG_ERROR, ("===> %s (value=%d)\n\n", __func__, value));
2102 2102
2103 if (value > 0) 2103 if (value > 0)
2104 { 2104 {
@@ -2122,14 +2122,14 @@ INT Set_ATE_Load_E2P_Proc(
2122 2122
2123 if (IS_ERR(srcf)) 2123 if (IS_ERR(srcf))
2124 { 2124 {
2125 ate_print("%s - Error %ld opening %s\n", __FUNCTION__, -PTR_ERR(srcf), src); 2125 ate_print("%s - Error %ld opening %s\n", __func__, -PTR_ERR(srcf), src);
2126 break; 2126 break;
2127 } 2127 }
2128 2128
2129 /* the object must have a read method */ 2129 /* the object must have a read method */
2130 if ((srcf->f_op == NULL) || (srcf->f_op->read == NULL)) 2130 if ((srcf->f_op == NULL) || (srcf->f_op->read == NULL))
2131 { 2131 {
2132 ate_print("%s - %s does not have a read method\n", __FUNCTION__, src); 2132 ate_print("%s - %s does not have a read method\n", __func__, src);
2133 break; 2133 break;
2134 } 2134 }
2135 2135
@@ -2142,7 +2142,7 @@ INT Set_ATE_Load_E2P_Proc(
2142 if (FileLength != EEPROM_SIZE) 2142 if (FileLength != EEPROM_SIZE)
2143 { 2143 {
2144 ate_print("%s: error file length (=%d) in e2p.bin\n", 2144 ate_print("%s: error file length (=%d) in e2p.bin\n",
2145 __FUNCTION__, FileLength); 2145 __func__, FileLength);
2146 break; 2146 break;
2147 } 2147 }
2148 else 2148 else
@@ -2174,7 +2174,7 @@ INT Set_ATE_Load_E2P_Proc(
2174 current->fsuid = orgfsuid; 2174 current->fsuid = orgfsuid;
2175 current->fsgid = orgfsgid; 2175 current->fsgid = orgfsgid;
2176 } 2176 }
2177 ATEDBGPRINT(RT_DEBUG_ERROR, ("<=== %s (ret=%d)\n", __FUNCTION__, ret)); 2177 ATEDBGPRINT(RT_DEBUG_ERROR, ("<=== %s (ret=%d)\n", __func__, ret));
2178 2178
2179 return ret; 2179 return ret;
2180 2180
@@ -2187,12 +2187,12 @@ INT Set_ATE_Load_E2P_Proc(
2187 USHORT WriteEEPROM[(EEPROM_SIZE/2)]; 2187 USHORT WriteEEPROM[(EEPROM_SIZE/2)];
2188 struct iwreq *wrq = (struct iwreq *)arg; 2188 struct iwreq *wrq = (struct iwreq *)arg;
2189 2189
2190 ATEDBGPRINT(RT_DEBUG_TRACE, ("===> %s (wrq->u.data.length = %d)\n\n", __FUNCTION__, wrq->u.data.length)); 2190 ATEDBGPRINT(RT_DEBUG_TRACE, ("===> %s (wrq->u.data.length = %d)\n\n", __func__, wrq->u.data.length));
2191 2191
2192 if (wrq->u.data.length != EEPROM_SIZE) 2192 if (wrq->u.data.length != EEPROM_SIZE)
2193 { 2193 {
2194 ate_print("%s: error length (=%d) from host\n", 2194 ate_print("%s: error length (=%d) from host\n",
2195 __FUNCTION__, wrq->u.data.length); 2195 __func__, wrq->u.data.length);
2196 return FALSE; 2196 return FALSE;
2197 } 2197 }
2198 else/* (wrq->u.data.length == EEPROM_SIZE) */ 2198 else/* (wrq->u.data.length == EEPROM_SIZE) */
@@ -2211,7 +2211,7 @@ INT Set_ATE_Load_E2P_Proc(
2211 } while(FALSE); 2211 } while(FALSE);
2212 } 2212 }
2213 2213
2214 ATEDBGPRINT(RT_DEBUG_TRACE, ("<=== %s\n", __FUNCTION__)); 2214 ATEDBGPRINT(RT_DEBUG_TRACE, ("<=== %s\n", __func__));
2215 2215
2216 return TRUE; 2216 return TRUE;
2217 2217
@@ -3353,7 +3353,7 @@ static INT ATESetUpFrame(
3353 if (pPacket == NULL) 3353 if (pPacket == NULL)
3354 { 3354 {
3355 pAd->ate.TxCount = 0; 3355 pAd->ate.TxCount = 0;
3356 ATEDBGPRINT(RT_DEBUG_TRACE, ("%s fail to alloc packet space.\n", __FUNCTION__)); 3356 ATEDBGPRINT(RT_DEBUG_TRACE, ("%s fail to alloc packet space.\n", __func__));
3357 return -1; 3357 return -1;
3358 } 3358 }
3359 pTxRing->Cell[TxIdx].pNextNdisPacket = pPacket; 3359 pTxRing->Cell[TxIdx].pNextNdisPacket = pPacket;
@@ -3646,7 +3646,7 @@ VOID RtmpDoAte(
3646 3646
3647 Command_Id = ntohs(pRaCfg->command_id); 3647 Command_Id = ntohs(pRaCfg->command_id);
3648 3648
3649 ATEDBGPRINT(RT_DEBUG_TRACE,("\n%s: Command_Id = 0x%04x !\n", __FUNCTION__, Command_Id)); 3649 ATEDBGPRINT(RT_DEBUG_TRACE,("\n%s: Command_Id = 0x%04x !\n", __func__, Command_Id));
3650 3650
3651 switch (Command_Id) 3651 switch (Command_Id)
3652 { 3652 {
@@ -5690,7 +5690,7 @@ BOOLEAN SyncTxRxConfig(PRTMP_ADAPTER pAd, USHORT offset, UCHAR value)
5690 pAd->ate.TxAntennaSel = 2; 5690 pAd->ate.TxAntennaSel = 2;
5691 break; 5691 break;
5692 default: 5692 default:
5693 DBGPRINT(RT_DEBUG_TRACE, ("%s -- Sth. wrong! : return FALSE; \n", __FUNCTION__)); 5693 DBGPRINT(RT_DEBUG_TRACE, ("%s -- Sth. wrong! : return FALSE; \n", __func__));
5694 return FALSE; 5694 return FALSE;
5695 } 5695 }
5696 break;/* case BBP_R1 */ 5696 break;/* case BBP_R1 */
@@ -5728,13 +5728,13 @@ BOOLEAN SyncTxRxConfig(PRTMP_ADAPTER pAd, USHORT offset, UCHAR value)
5728 pAd->ate.RxAntennaSel = 3; 5728 pAd->ate.RxAntennaSel = 3;
5729 break; 5729 break;
5730 default: 5730 default:
5731 DBGPRINT(RT_DEBUG_ERROR, ("%s -- Impossible! : return FALSE; \n", __FUNCTION__)); 5731 DBGPRINT(RT_DEBUG_ERROR, ("%s -- Impossible! : return FALSE; \n", __func__));
5732 return FALSE; 5732 return FALSE;
5733 } 5733 }
5734 break;/* case BBP_R3 */ 5734 break;/* case BBP_R3 */
5735 5735
5736 default: 5736 default:
5737 DBGPRINT(RT_DEBUG_ERROR, ("%s -- Sth. wrong! : return FALSE; \n", __FUNCTION__)); 5737 DBGPRINT(RT_DEBUG_ERROR, ("%s -- Sth. wrong! : return FALSE; \n", __func__));
5738 return FALSE; 5738 return FALSE;
5739 5739
5740 } 5740 }
diff --git a/drivers/staging/rt2860/rt_linux.c b/drivers/staging/rt2860/rt_linux.c
index 374c174c88ee..f14500931efb 100644
--- a/drivers/staging/rt2860/rt_linux.c
+++ b/drivers/staging/rt2860/rt_linux.c
@@ -406,7 +406,7 @@ NDIS_STATUS RTMPAllocateNdisPacket(
406 skb_put(GET_OS_PKT_TYPE(pPacket), HeaderLen+DataLen); 406 skb_put(GET_OS_PKT_TYPE(pPacket), HeaderLen+DataLen);
407 407
408 RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS); 408 RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS);
409// printk("%s : pPacket = %p, len = %d\n", __FUNCTION__, pPacket, GET_OS_PKT_LEN(pPacket)); 409// printk("%s : pPacket = %p, len = %d\n", __func__, pPacket, GET_OS_PKT_LEN(pPacket));
410 *ppPacket = pPacket; 410 *ppPacket = pPacket;
411 return NDIS_STATUS_SUCCESS; 411 return NDIS_STATUS_SUCCESS;
412} 412}
@@ -773,13 +773,13 @@ VOID RTMPSendWirelessEvent(
773 773
774 if (event_table_len == 0) 774 if (event_table_len == 0)
775 { 775 {
776 DBGPRINT(RT_DEBUG_ERROR, ("%s : The type(%0x02x) is not valid.\n", __FUNCTION__, type)); 776 DBGPRINT(RT_DEBUG_ERROR, ("%s : The type(%0x02x) is not valid.\n", __func__, type));
777 return; 777 return;
778 } 778 }
779 779
780 if (event >= event_table_len) 780 if (event >= event_table_len)
781 { 781 {
782 DBGPRINT(RT_DEBUG_ERROR, ("%s : The event(%0x02x) is not valid.\n", __FUNCTION__, event)); 782 DBGPRINT(RT_DEBUG_ERROR, ("%s : The event(%0x02x) is not valid.\n", __func__, event));
783 return; 783 return;
784 } 784 }
785 785
@@ -817,14 +817,14 @@ VOID RTMPSendWirelessEvent(
817 //send wireless event 817 //send wireless event
818 wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, pBuf); 818 wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, pBuf);
819 819
820 //DBGPRINT(RT_DEBUG_TRACE, ("%s : %s\n", __FUNCTION__, pBuf)); 820 //DBGPRINT(RT_DEBUG_TRACE, ("%s : %s\n", __func__, pBuf));
821 821
822 kfree(pBuf); 822 kfree(pBuf);
823 } 823 }
824 else 824 else
825 DBGPRINT(RT_DEBUG_ERROR, ("%s : Can't allocate memory for wireless event.\n", __FUNCTION__)); 825 DBGPRINT(RT_DEBUG_ERROR, ("%s : Can't allocate memory for wireless event.\n", __func__));
826#else 826#else
827 DBGPRINT(RT_DEBUG_ERROR, ("%s : The Wireless Extension MUST be v15 or newer.\n", __FUNCTION__)); 827 DBGPRINT(RT_DEBUG_ERROR, ("%s : The Wireless Extension MUST be v15 or newer.\n", __func__));
828#endif /* WIRELESS_EXT >= 15 */ 828#endif /* WIRELESS_EXT >= 15 */
829} 829}
830 830
@@ -848,13 +848,13 @@ void send_monitor_packets(
848 ASSERT(pRxBlk->pRxPacket); 848 ASSERT(pRxBlk->pRxPacket);
849 if (pRxBlk->DataSize < 10) 849 if (pRxBlk->DataSize < 10)
850 { 850 {
851 DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too small! (%d)\n", __FUNCTION__, pRxBlk->DataSize)); 851 DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too small! (%d)\n", __func__, pRxBlk->DataSize));
852 goto err_free_sk_buff; 852 goto err_free_sk_buff;
853 } 853 }
854 854
855 if (pRxBlk->DataSize + sizeof(wlan_ng_prism2_header) > RX_BUFFER_AGGRESIZE) 855 if (pRxBlk->DataSize + sizeof(wlan_ng_prism2_header) > RX_BUFFER_AGGRESIZE)
856 { 856 {
857 DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too large! (%d)\n", __FUNCTION__, pRxBlk->DataSize + sizeof(wlan_ng_prism2_header))); 857 DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too large! (%d)\n", __func__, pRxBlk->DataSize + sizeof(wlan_ng_prism2_header)));
858 goto err_free_sk_buff; 858 goto err_free_sk_buff;
859 } 859 }
860 860
@@ -910,7 +910,7 @@ void send_monitor_packets(
910 910
911 if (skb_headroom(pOSPkt) < (sizeof(wlan_ng_prism2_header)+ header_len)) { 911 if (skb_headroom(pOSPkt) < (sizeof(wlan_ng_prism2_header)+ header_len)) {
912 if (pskb_expand_head(pOSPkt, (sizeof(wlan_ng_prism2_header) + header_len), 0, GFP_ATOMIC)) { 912 if (pskb_expand_head(pOSPkt, (sizeof(wlan_ng_prism2_header) + header_len), 0, GFP_ATOMIC)) {
913 DBGPRINT(RT_DEBUG_ERROR, ("%s : Reallocate header size of sk_buff fail!\n", __FUNCTION__)); 913 DBGPRINT(RT_DEBUG_ERROR, ("%s : Reallocate header size of sk_buff fail!\n", __func__));
914 goto err_free_sk_buff; 914 goto err_free_sk_buff;
915 } //end if 915 } //end if
916 } //end if 916 } //end if
diff --git a/drivers/staging/rt2860/rt_linux.h b/drivers/staging/rt2860/rt_linux.h
index 0cc7cf23d762..0fd58f5109f2 100644
--- a/drivers/staging/rt2860/rt_linux.h
+++ b/drivers/staging/rt2860/rt_linux.h
@@ -131,7 +131,7 @@ typedef int (*HARD_START_XMIT_FUNC)(struct sk_buff *skb, struct net_device *net_
131#define RT_MOD_INC_USE_COUNT() \ 131#define RT_MOD_INC_USE_COUNT() \
132 if (!try_module_get(THIS_MODULE)) \ 132 if (!try_module_get(THIS_MODULE)) \
133 { \ 133 { \
134 DBGPRINT(RT_DEBUG_ERROR, ("%s: cannot reserve module\n", __FUNCTION__)); \ 134 DBGPRINT(RT_DEBUG_ERROR, ("%s: cannot reserve module\n", __func__)); \
135 return -1; \ 135 return -1; \
136 } 136 }
137 137
diff --git a/drivers/staging/rt2860/rt_profile.c b/drivers/staging/rt2860/rt_profile.c
index cd7ffc8a6e8a..326a3cb52b9c 100644
--- a/drivers/staging/rt2860/rt_profile.c
+++ b/drivers/staging/rt2860/rt_profile.c
@@ -1024,7 +1024,7 @@ NDIS_STATUS RTMPReadParametersHook(
1024 pAd->MlmeAux.SsidLen = pAd->CommonCfg.SsidLen; 1024 pAd->MlmeAux.SsidLen = pAd->CommonCfg.SsidLen;
1025 NdisZeroMemory(pAd->MlmeAux.Ssid, NDIS_802_11_LENGTH_SSID); 1025 NdisZeroMemory(pAd->MlmeAux.Ssid, NDIS_802_11_LENGTH_SSID);
1026 NdisMoveMemory(pAd->MlmeAux.Ssid, tmpbuf, pAd->MlmeAux.SsidLen); 1026 NdisMoveMemory(pAd->MlmeAux.Ssid, tmpbuf, pAd->MlmeAux.SsidLen);
1027 DBGPRINT(RT_DEBUG_TRACE, ("%s::(SSID=%s)\n", __FUNCTION__, tmpbuf)); 1027 DBGPRINT(RT_DEBUG_TRACE, ("%s::(SSID=%s)\n", __func__, tmpbuf));
1028 } 1028 }
1029 } 1029 }
1030 } 1030 }
@@ -1043,7 +1043,7 @@ NDIS_STATUS RTMPReadParametersHook(
1043 pAd->StaCfg.BssType = BSS_INFRA; 1043 pAd->StaCfg.BssType = BSS_INFRA;
1044 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key 1044 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
1045 pAd->StaCfg.WpaState = SS_NOTUSE; 1045 pAd->StaCfg.WpaState = SS_NOTUSE;
1046 DBGPRINT(RT_DEBUG_TRACE, ("%s::(NetworkType=%d)\n", __FUNCTION__, pAd->StaCfg.BssType)); 1046 DBGPRINT(RT_DEBUG_TRACE, ("%s::(NetworkType=%d)\n", __func__, pAd->StaCfg.BssType));
1047 } 1047 }
1048 } 1048 }
1049#endif // CONFIG_STA_SUPPORT // 1049#endif // CONFIG_STA_SUPPORT //
@@ -1337,7 +1337,7 @@ NDIS_STATUS RTMPReadParametersHook(
1337 1337
1338 pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED; 1338 pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
1339 1339
1340 DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __FUNCTION__, pAd->StaCfg.WepStatus)); 1340 DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __func__, pAd->StaCfg.WepStatus));
1341 } 1341 }
1342#endif // CONFIG_STA_SUPPORT // 1342#endif // CONFIG_STA_SUPPORT //
1343 } 1343 }
@@ -1363,7 +1363,7 @@ NDIS_STATUS RTMPReadParametersHook(
1363 pAd->StaCfg.OrigWepStatus = pAd->StaCfg.WepStatus; 1363 pAd->StaCfg.OrigWepStatus = pAd->StaCfg.WepStatus;
1364 pAd->StaCfg.bMixCipher = FALSE; 1364 pAd->StaCfg.bMixCipher = FALSE;
1365 1365
1366 DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __FUNCTION__, pAd->StaCfg.WepStatus)); 1366 DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __func__, pAd->StaCfg.WepStatus));
1367 } 1367 }
1368#endif // CONFIG_STA_SUPPORT // 1368#endif // CONFIG_STA_SUPPORT //
1369 } 1369 }
@@ -1400,7 +1400,7 @@ NDIS_STATUS RTMPReadParametersHook(
1400 else 1400 else
1401 { 1401 {
1402 err = 1; 1402 err = 1;
1403 DBGPRINT(RT_DEBUG_ERROR, ("%s::(WPAPSK key-string required 8 ~ 64 characters!)\n", __FUNCTION__)); 1403 DBGPRINT(RT_DEBUG_ERROR, ("%s::(WPAPSK key-string required 8 ~ 64 characters!)\n", __func__));
1404 } 1404 }
1405 1405
1406 if (err == 0) 1406 if (err == 0)
@@ -1416,7 +1416,7 @@ NDIS_STATUS RTMPReadParametersHook(
1416 pAd->StaCfg.WpaState = SS_NOTUSE; 1416 pAd->StaCfg.WpaState = SS_NOTUSE;
1417 } 1417 }
1418 1418
1419 DBGPRINT(RT_DEBUG_TRACE, ("%s::(WPAPSK=%s)\n", __FUNCTION__, tmpbuf)); 1419 DBGPRINT(RT_DEBUG_TRACE, ("%s::(WPAPSK=%s)\n", __func__, tmpbuf));
1420 } 1420 }
1421 } 1421 }
1422 } 1422 }
diff --git a/drivers/staging/rt2860/rtmp_def.h b/drivers/staging/rt2860/rtmp_def.h
index bb6f37b0bdc2..be982147883f 100644
--- a/drivers/staging/rt2860/rtmp_def.h
+++ b/drivers/staging/rt2860/rtmp_def.h
@@ -333,7 +333,7 @@
333/* sanity check for apidx */ 333/* sanity check for apidx */
334#define MBSS_MR_APIDX_SANITY_CHECK(apidx) \ 334#define MBSS_MR_APIDX_SANITY_CHECK(apidx) \
335 { if (apidx > MAX_MBSSID_NUM) { \ 335 { if (apidx > MAX_MBSSID_NUM) { \
336 printk("%s> Error! apidx = %d > MAX_MBSSID_NUM!\n", __FUNCTION__, apidx); \ 336 printk("%s> Error! apidx = %d > MAX_MBSSID_NUM!\n", __func__, apidx); \
337 apidx = MAIN_MBSSID; } } 337 apidx = MAIN_MBSSID; } }
338 338
339#define VALID_WCID(_wcid) ((_wcid) > 0 && (_wcid) < MAX_LEN_OF_MAC_TABLE ) 339#define VALID_WCID(_wcid) ((_wcid) > 0 && (_wcid) < MAX_LEN_OF_MAC_TABLE )
diff --git a/drivers/staging/rt2860/sta_ioctl.c b/drivers/staging/rt2860/sta_ioctl.c
index 9347d11b586e..3ea2b2c4ab0e 100644
--- a/drivers/staging/rt2860/sta_ioctl.c
+++ b/drivers/staging/rt2860/sta_ioctl.c
@@ -2200,7 +2200,7 @@ rt_private_show(struct net_device *dev, struct iw_request_info *info,
2200 } 2200 }
2201 break; 2201 break;
2202 default: 2202 default:
2203 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __FUNCTION__, subcmd)); 2203 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
2204 break; 2204 break;
2205 } 2205 }
2206 2206
@@ -2219,7 +2219,7 @@ int rt_ioctl_siwmlme(struct net_device *dev,
2219 MLME_DISASSOC_REQ_STRUCT DisAssocReq; 2219 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2220 MLME_DEAUTH_REQ_STRUCT DeAuthReq; 2220 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2221 2221
2222 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __FUNCTION__)); 2222 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
2223 2223
2224 if (pMlme == NULL) 2224 if (pMlme == NULL)
2225 return -EINVAL; 2225 return -EINVAL;
@@ -2228,7 +2228,7 @@ int rt_ioctl_siwmlme(struct net_device *dev,
2228 { 2228 {
2229#ifdef IW_MLME_DEAUTH 2229#ifdef IW_MLME_DEAUTH
2230 case IW_MLME_DEAUTH: 2230 case IW_MLME_DEAUTH:
2231 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __FUNCTION__)); 2231 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
2232 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid); 2232 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2233 DeAuthReq.Reason = pMlme->reason_code; 2233 DeAuthReq.Reason = pMlme->reason_code;
2234 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT); 2234 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
@@ -2243,7 +2243,7 @@ int rt_ioctl_siwmlme(struct net_device *dev,
2243#endif // IW_MLME_DEAUTH // 2243#endif // IW_MLME_DEAUTH //
2244#ifdef IW_MLME_DISASSOC 2244#ifdef IW_MLME_DISASSOC
2245 case IW_MLME_DISASSOC: 2245 case IW_MLME_DISASSOC:
2246 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __FUNCTION__)); 2246 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
2247 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid); 2247 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2248 DisAssocReq.Reason = pMlme->reason_code; 2248 DisAssocReq.Reason = pMlme->reason_code;
2249 2249
@@ -2257,7 +2257,7 @@ int rt_ioctl_siwmlme(struct net_device *dev,
2257 break; 2257 break;
2258#endif // IW_MLME_DISASSOC // 2258#endif // IW_MLME_DISASSOC //
2259 default: 2259 default:
2260 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __FUNCTION__)); 2260 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
2261 break; 2261 break;
2262 } 2262 }
2263 2263
@@ -2290,7 +2290,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
2290 else if (param->value == IW_AUTH_WPA_VERSION_WPA2) 2290 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2291 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK; 2291 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2292 2292
2293 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __FUNCTION__, param->value)); 2293 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2294 break; 2294 break;
2295 case IW_AUTH_CIPHER_PAIRWISE: 2295 case IW_AUTH_CIPHER_PAIRWISE:
2296 if (param->value == IW_AUTH_CIPHER_NONE) 2296 if (param->value == IW_AUTH_CIPHER_NONE)
@@ -2321,7 +2321,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
2321 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus; 2321 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2322 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled; 2322 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2323 } 2323 }
2324 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __FUNCTION__, param->value)); 2324 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
2325 break; 2325 break;
2326 case IW_AUTH_CIPHER_GROUP: 2326 case IW_AUTH_CIPHER_GROUP:
2327 if (param->value == IW_AUTH_CIPHER_NONE) 2327 if (param->value == IW_AUTH_CIPHER_NONE)
@@ -2341,7 +2341,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
2341 { 2341 {
2342 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled; 2342 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2343 } 2343 }
2344 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __FUNCTION__, param->value)); 2344 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
2345 break; 2345 break;
2346 case IW_AUTH_KEY_MGMT: 2346 case IW_AUTH_KEY_MGMT:
2347 if (param->value == IW_AUTH_KEY_MGMT_802_1X) 2347 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
@@ -2370,12 +2370,12 @@ int rt_ioctl_siwauth(struct net_device *dev,
2370 { 2370 {
2371 STA_PORT_SECURED(pAdapter); 2371 STA_PORT_SECURED(pAdapter);
2372 } 2372 }
2373 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __FUNCTION__, param->value)); 2373 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2374 break; 2374 break;
2375 case IW_AUTH_RX_UNENCRYPTED_EAPOL: 2375 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2376 break; 2376 break;
2377 case IW_AUTH_PRIVACY_INVOKED: 2377 case IW_AUTH_PRIVACY_INVOKED:
2378 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __FUNCTION__, param->value)); 2378 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2379 break; 2379 break;
2380 case IW_AUTH_DROP_UNENCRYPTED: 2380 case IW_AUTH_DROP_UNENCRYPTED:
2381 if (param->value != 0) 2381 if (param->value != 0)
@@ -2384,7 +2384,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
2384 { 2384 {
2385 STA_PORT_SECURED(pAdapter); 2385 STA_PORT_SECURED(pAdapter);
2386 } 2386 }
2387 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __FUNCTION__, param->value)); 2387 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2388 break; 2388 break;
2389 case IW_AUTH_80211_AUTH_ALG: 2389 case IW_AUTH_80211_AUTH_ALG:
2390 if (param->value & IW_AUTH_ALG_SHARED_KEY) 2390 if (param->value & IW_AUTH_ALG_SHARED_KEY)
@@ -2397,10 +2397,10 @@ int rt_ioctl_siwauth(struct net_device *dev,
2397 } 2397 }
2398 else 2398 else
2399 return -EINVAL; 2399 return -EINVAL;
2400 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __FUNCTION__, param->value)); 2400 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2401 break; 2401 break;
2402 case IW_AUTH_WPA_ENABLED: 2402 case IW_AUTH_WPA_ENABLED:
2403 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __FUNCTION__, param->value)); 2403 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2404 break; 2404 break;
2405 default: 2405 default:
2406 return -EOPNOTSUPP; 2406 return -EOPNOTSUPP;
@@ -2508,7 +2508,7 @@ int rt_ioctl_siwencodeext(struct net_device *dev,
2508 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE; 2508 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2509 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx); 2509 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2510 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY)); 2510 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2511 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __FUNCTION__, encoding->flags)); 2511 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2512 } 2512 }
2513 else 2513 else
2514 { 2514 {
@@ -2520,15 +2520,15 @@ int rt_ioctl_siwencodeext(struct net_device *dev,
2520 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) 2520 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2521 { 2521 {
2522 pAdapter->StaCfg.DefaultKeyId = keyIdx; 2522 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2523 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __FUNCTION__, pAdapter->StaCfg.DefaultKeyId)); 2523 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2524 } 2524 }
2525 2525
2526 switch (alg) { 2526 switch (alg) {
2527 case IW_ENCODE_ALG_NONE: 2527 case IW_ENCODE_ALG_NONE:
2528 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __FUNCTION__)); 2528 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2529 break; 2529 break;
2530 case IW_ENCODE_ALG_WEP: 2530 case IW_ENCODE_ALG_WEP:
2531 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __FUNCTION__, ext->key_len, keyIdx)); 2531 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2532 if (ext->key_len == MAX_WEP_KEY_SIZE) 2532 if (ext->key_len == MAX_WEP_KEY_SIZE)
2533 { 2533 {
2534 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE; 2534 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
@@ -2546,7 +2546,7 @@ int rt_ioctl_siwencodeext(struct net_device *dev,
2546 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len); 2546 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2547 break; 2547 break;
2548 case IW_ENCODE_ALG_TKIP: 2548 case IW_ENCODE_ALG_TKIP:
2549 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __FUNCTION__, keyIdx, ext->key_len)); 2549 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2550 if (ext->key_len == 32) 2550 if (ext->key_len == 32)
2551 { 2551 {
2552 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) 2552 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
diff --git a/drivers/staging/rt2870/2870_main_dev.c b/drivers/staging/rt2870/2870_main_dev.c
index 91da4e2298ac..04c764d95d77 100644
--- a/drivers/staging/rt2870/2870_main_dev.c
+++ b/drivers/staging/rt2870/2870_main_dev.c
@@ -263,7 +263,7 @@ INT MlmeThread(
263 * This is important in preemption kernels, which transfer the flow 263 * This is important in preemption kernels, which transfer the flow
264 * of execution immediately upon a complete(). 264 * of execution immediately upon a complete().
265 */ 265 */
266 DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__FUNCTION__)); 266 DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__func__));
267 267
268 pObj->MLMEThr_pid = THREAD_PID_INIT_VALUE; 268 pObj->MLMEThr_pid = THREAD_PID_INIT_VALUE;
269 269
@@ -465,7 +465,7 @@ INT TimerQThread(
465 * This is important in preemption kernels, which transfer the flow 465 * This is important in preemption kernels, which transfer the flow
466 * of execution immediately upon a complete(). 466 * of execution immediately upon a complete().
467 */ 467 */
468 DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__FUNCTION__)); 468 DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__func__));
469 469
470 pObj->TimerQThr_pid = THREAD_PID_INIT_VALUE; 470 pObj->TimerQThr_pid = THREAD_PID_INIT_VALUE;
471 471
@@ -1258,7 +1258,7 @@ BOOLEAN RT28XXProbePostConfig(
1258 1258
1259 if (!(pAd->BulkInEpAddr && pAd->BulkOutEpAddr[0])) 1259 if (!(pAd->BulkInEpAddr && pAd->BulkOutEpAddr[0]))
1260 { 1260 {
1261 printk("%s: Could not find both bulk-in and bulk-out endpoints\n", __FUNCTION__); 1261 printk("%s: Could not find both bulk-in and bulk-out endpoints\n", __func__);
1262 return FALSE; 1262 return FALSE;
1263 } 1263 }
1264 1264
diff --git a/drivers/staging/rt2870/common/2870_rtmp_init.c b/drivers/staging/rt2870/common/2870_rtmp_init.c
index 5d89a310d1ea..9f5143b3922e 100644
--- a/drivers/staging/rt2870/common/2870_rtmp_init.c
+++ b/drivers/staging/rt2870/common/2870_rtmp_init.c
@@ -1087,7 +1087,7 @@ PNDIS_PACKET GetPacketFromRxRing(
1087 if (pRxWI->MPDUtotalByteCount > ThisFrameLen) 1087 if (pRxWI->MPDUtotalByteCount > ThisFrameLen)
1088 { 1088 {
1089 DBGPRINT(RT_DEBUG_ERROR, ("%s():pRxWIMPDUtotalByteCount(%d) large than RxDMALen(%ld)\n", 1089 DBGPRINT(RT_DEBUG_ERROR, ("%s():pRxWIMPDUtotalByteCount(%d) large than RxDMALen(%ld)\n",
1090 __FUNCTION__, pRxWI->MPDUtotalByteCount, ThisFrameLen)); 1090 __func__, pRxWI->MPDUtotalByteCount, ThisFrameLen));
1091 goto label_null; 1091 goto label_null;
1092 } 1092 }
1093#ifdef RT_BIG_ENDIAN 1093#ifdef RT_BIG_ENDIAN
@@ -1098,7 +1098,7 @@ PNDIS_PACKET GetPacketFromRxRing(
1098 pSkb = dev_alloc_skb(ThisFrameLen); 1098 pSkb = dev_alloc_skb(ThisFrameLen);
1099 if (pSkb == NULL) 1099 if (pSkb == NULL)
1100 { 1100 {
1101 DBGPRINT(RT_DEBUG_ERROR,("%s():Cannot Allocate sk buffer for this Bulk-In buffer!\n", __FUNCTION__)); 1101 DBGPRINT(RT_DEBUG_ERROR,("%s():Cannot Allocate sk buffer for this Bulk-In buffer!\n", __func__));
1102 goto label_null; 1102 goto label_null;
1103 } 1103 }
1104 1104
diff --git a/drivers/staging/rt2870/common/ba_action.c b/drivers/staging/rt2870/common/ba_action.c
index 95addb20bced..d9f738177e2b 100644
--- a/drivers/staging/rt2870/common/ba_action.c
+++ b/drivers/staging/rt2870/common/ba_action.c
@@ -595,7 +595,7 @@ VOID BAOriSessionAdd(
595 595
596 pBAEntry->ORIBATimer.TimerValue = 0; //pFrame->TimeOutValue; 596 pBAEntry->ORIBATimer.TimerValue = 0; //pFrame->TimeOutValue;
597 597
598 DBGPRINT(RT_DEBUG_TRACE,("%s : TXBAbitmap = %x, BAWinSize = %d, TimeOut = %ld\n", __FUNCTION__, pEntry->TXBAbitmap, 598 DBGPRINT(RT_DEBUG_TRACE,("%s : TXBAbitmap = %x, BAWinSize = %d, TimeOut = %ld\n", __func__, pEntry->TXBAbitmap,
599 pBAEntry->BAWinSize, pBAEntry->ORIBATimer.TimerValue)); 599 pBAEntry->BAWinSize, pBAEntry->ORIBATimer.TimerValue));
600 600
601 // SEND BAR ; 601 // SEND BAR ;
@@ -669,7 +669,7 @@ BOOLEAN BARecSessionAdd(
669 ba_refresh_reordering_mpdus(pAd, pBAEntry); 669 ba_refresh_reordering_mpdus(pAd, pBAEntry);
670 } 670 }
671 671
672 DBGPRINT(RT_DEBUG_TRACE,("%s(%ld): Idx = %d, BAWinSize(req %d) = %d\n", __FUNCTION__, pAd->BATable.numAsRecipient, Idx, 672 DBGPRINT(RT_DEBUG_TRACE,("%s(%ld): Idx = %d, BAWinSize(req %d) = %d\n", __func__, pAd->BATable.numAsRecipient, Idx,
673 pFrame->BaParm.BufSize, BAWinSize)); 673 pFrame->BaParm.BufSize, BAWinSize));
674 674
675 // Start fill in parameters. 675 // Start fill in parameters.
@@ -911,7 +911,7 @@ VOID BAOriSessionTearDown(
911 return; 911 return;
912 } 912 }
913 913
914 DBGPRINT(RT_DEBUG_TRACE,("%s===>Wcid=%d.TID=%d \n", __FUNCTION__, Wcid, TID)); 914 DBGPRINT(RT_DEBUG_TRACE,("%s===>Wcid=%d.TID=%d \n", __func__, Wcid, TID));
915 915
916 pBAEntry = &pAd->BATable.BAOriEntry[Idx]; 916 pBAEntry = &pAd->BATable.BAOriEntry[Idx];
917 DBGPRINT(RT_DEBUG_TRACE,("\t===>Idx = %ld, Wcid=%d.TID=%d, ORI_BA_Status = %d \n", Idx, Wcid, TID, pBAEntry->ORI_BA_Status)); 917 DBGPRINT(RT_DEBUG_TRACE,("\t===>Idx = %ld, Wcid=%d.TID=%d, ORI_BA_Status = %d \n", Idx, Wcid, TID, pBAEntry->ORI_BA_Status));
@@ -970,7 +970,7 @@ VOID BARecSessionTearDown(
970 if (Idx == 0) 970 if (Idx == 0)
971 return; 971 return;
972 972
973 DBGPRINT(RT_DEBUG_TRACE,("%s===>Wcid=%d.TID=%d \n", __FUNCTION__, Wcid, TID)); 973 DBGPRINT(RT_DEBUG_TRACE,("%s===>Wcid=%d.TID=%d \n", __func__, Wcid, TID));
974 974
975 975
976 pBAEntry = &pAd->BATable.BARecEntry[Idx]; 976 pBAEntry = &pAd->BATable.BARecEntry[Idx];
@@ -1181,7 +1181,7 @@ VOID PeerAddBAReqAction(
1181 PULONG ptemp; 1181 PULONG ptemp;
1182 PMAC_TABLE_ENTRY pMacEntry; 1182 PMAC_TABLE_ENTRY pMacEntry;
1183 1183
1184 DBGPRINT(RT_DEBUG_TRACE, ("%s ==> (Wcid = %d)\n", __FUNCTION__, Elem->Wcid)); 1184 DBGPRINT(RT_DEBUG_TRACE, ("%s ==> (Wcid = %d)\n", __func__, Elem->Wcid));
1185 1185
1186 //hex_dump("AddBAReq", Elem->Msg, Elem->MsgLen); 1186 //hex_dump("AddBAReq", Elem->Msg, Elem->MsgLen);
1187 1187
@@ -1265,7 +1265,7 @@ VOID PeerAddBAReqAction(
1265 MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen); 1265 MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen);
1266 MlmeFreeMemory(pAd, pOutBuffer); 1266 MlmeFreeMemory(pAd, pOutBuffer);
1267 1267
1268 DBGPRINT(RT_DEBUG_TRACE, ("%s(%d): TID(%d), BufSize(%d) <== \n", __FUNCTION__, Elem->Wcid, ADDframe.BaParm.TID, 1268 DBGPRINT(RT_DEBUG_TRACE, ("%s(%d): TID(%d), BufSize(%d) <== \n", __func__, Elem->Wcid, ADDframe.BaParm.TID,
1269 ADDframe.BaParm.BufSize)); 1269 ADDframe.BaParm.BufSize));
1270} 1270}
1271 1271
@@ -1284,7 +1284,7 @@ VOID PeerAddBARspAction(
1284 if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE) 1284 if (Elem->Wcid >= MAX_LEN_OF_MAC_TABLE)
1285 return; 1285 return;
1286 1286
1287 DBGPRINT(RT_DEBUG_TRACE, ("%s ==> Wcid(%d)\n", __FUNCTION__, Elem->Wcid)); 1287 DBGPRINT(RT_DEBUG_TRACE, ("%s ==> Wcid(%d)\n", __func__, Elem->Wcid));
1288 1288
1289 //hex_dump("PeerAddBARspAction()", Elem->Msg, Elem->MsgLen); 1289 //hex_dump("PeerAddBARspAction()", Elem->Msg, Elem->MsgLen);
1290 1290
@@ -1325,7 +1325,7 @@ VOID PeerDelBAAction(
1325 //PUCHAR pOutBuffer = NULL; 1325 //PUCHAR pOutBuffer = NULL;
1326 PFRAME_DELBA_REQ pDelFrame = NULL; 1326 PFRAME_DELBA_REQ pDelFrame = NULL;
1327 1327
1328 DBGPRINT(RT_DEBUG_TRACE,("%s ==>\n", __FUNCTION__)); 1328 DBGPRINT(RT_DEBUG_TRACE,("%s ==>\n", __func__));
1329 //DELBA Request from unknown peer, ignore this. 1329 //DELBA Request from unknown peer, ignore this.
1330 if (PeerDelBAActionSanity(pAd, Elem->Wcid, Elem->Msg, Elem->MsgLen)) 1330 if (PeerDelBAActionSanity(pAd, Elem->Wcid, Elem->Msg, Elem->MsgLen))
1331 { 1331 {
@@ -1362,7 +1362,7 @@ BOOLEAN CntlEnqueueForRecv(
1362 1362
1363 TID = (UCHAR)pFrame->BARControl.TID; 1363 TID = (UCHAR)pFrame->BARControl.TID;
1364 1364
1365 DBGPRINT(RT_DEBUG_TRACE, ("%s(): BAR-Wcid(%ld), Tid (%d)\n", __FUNCTION__, Wcid, TID)); 1365 DBGPRINT(RT_DEBUG_TRACE, ("%s(): BAR-Wcid(%ld), Tid (%d)\n", __func__, Wcid, TID));
1366 //hex_dump("BAR", (PCHAR) pFrame, MsgLen); 1366 //hex_dump("BAR", (PCHAR) pFrame, MsgLen);
1367 // Do nothing if the driver is starting halt state. 1367 // Do nothing if the driver is starting halt state.
1368 // This might happen when timer already been fired before cancel timer with mlmehalt 1368 // This might happen when timer already been fired before cancel timer with mlmehalt
diff --git a/drivers/staging/rt2870/common/cmm_data.c b/drivers/staging/rt2870/common/cmm_data.c
index 4477a8e64a29..fd809abf6df0 100644
--- a/drivers/staging/rt2870/common/cmm_data.c
+++ b/drivers/staging/rt2870/common/cmm_data.c
@@ -2009,7 +2009,7 @@ BOOLEAN MacTableDeleteEntry(
2009 } 2009 }
2010 else 2010 else
2011 { 2011 {
2012 printk("\n%s: Impossible Wcid = %d !!!!!\n", __FUNCTION__, wcid); 2012 printk("\n%s: Impossible Wcid = %d !!!!!\n", __func__, wcid);
2013 } 2013 }
2014 } 2014 }
2015 2015
diff --git a/drivers/staging/rt2870/common/cmm_info.c b/drivers/staging/rt2870/common/cmm_info.c
index 40792e162374..47a1b1a73f09 100644
--- a/drivers/staging/rt2870/common/cmm_info.c
+++ b/drivers/staging/rt2870/common/cmm_info.c
@@ -2331,7 +2331,7 @@ VOID RTMPIoctlGetMacTable(
2331 wrq->u.data.length = sizeof(RT_802_11_MAC_TABLE); 2331 wrq->u.data.length = sizeof(RT_802_11_MAC_TABLE);
2332 if (copy_to_user(wrq->u.data.pointer, &MacTab, wrq->u.data.length)) 2332 if (copy_to_user(wrq->u.data.pointer, &MacTab, wrq->u.data.length))
2333 { 2333 {
2334 DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __FUNCTION__)); 2334 DBGPRINT(RT_DEBUG_TRACE, ("%s: copy_to_user() fail\n", __func__));
2335 } 2335 }
2336 2336
2337 msg = (CHAR *) kmalloc(sizeof(CHAR)*(MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN), MEM_ALLOC_FLAG); 2337 msg = (CHAR *) kmalloc(sizeof(CHAR)*(MAX_LEN_OF_MAC_TABLE*MAC_LINE_LEN), MEM_ALLOC_FLAG);
diff --git a/drivers/staging/rt2870/common/dfs.c b/drivers/staging/rt2870/common/dfs.c
index 23cf1510e2d2..b09bba5cb206 100644
--- a/drivers/staging/rt2870/common/dfs.c
+++ b/drivers/staging/rt2870/common/dfs.c
@@ -428,7 +428,7 @@ INT Set_ChMovingTime_Proc(
428 428
429 pAd->CommonCfg.RadarDetect.ChMovingTime = Value; 429 pAd->CommonCfg.RadarDetect.ChMovingTime = Value;
430 430
431 DBGPRINT(RT_DEBUG_TRACE, ("%s:: %d\n", __FUNCTION__, 431 DBGPRINT(RT_DEBUG_TRACE, ("%s:: %d\n", __func__,
432 pAd->CommonCfg.RadarDetect.ChMovingTime)); 432 pAd->CommonCfg.RadarDetect.ChMovingTime));
433 433
434 return TRUE; 434 return TRUE;
@@ -444,7 +444,7 @@ INT Set_LongPulseRadarTh_Proc(
444 444
445 pAd->CommonCfg.RadarDetect.LongPulseRadarTh = Value; 445 pAd->CommonCfg.RadarDetect.LongPulseRadarTh = Value;
446 446
447 DBGPRINT(RT_DEBUG_TRACE, ("%s:: %d\n", __FUNCTION__, 447 DBGPRINT(RT_DEBUG_TRACE, ("%s:: %d\n", __func__,
448 pAd->CommonCfg.RadarDetect.LongPulseRadarTh)); 448 pAd->CommonCfg.RadarDetect.LongPulseRadarTh));
449 449
450 return TRUE; 450 return TRUE;
diff --git a/drivers/staging/rt2870/common/rtmp_init.c b/drivers/staging/rt2870/common/rtmp_init.c
index 87028fd60bc2..870a00da3dac 100644
--- a/drivers/staging/rt2870/common/rtmp_init.c
+++ b/drivers/staging/rt2870/common/rtmp_init.c
@@ -2746,7 +2746,7 @@ NDIS_STATUS NICLoadFirmware(
2746#ifdef BIN_IN_FILE 2746#ifdef BIN_IN_FILE
2747#define NICLF_DEFAULT_USE() \ 2747#define NICLF_DEFAULT_USE() \
2748 flg_default_firm_use = TRUE; \ 2748 flg_default_firm_use = TRUE; \
2749 printk("%s - Use default firmware!\n", __FUNCTION__); 2749 printk("%s - Use default firmware!\n", __func__);
2750 2750
2751 NDIS_STATUS Status = NDIS_STATUS_SUCCESS; 2751 NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
2752 PUCHAR src; 2752 PUCHAR src;
@@ -2761,7 +2761,7 @@ NDIS_STATUS NICLoadFirmware(
2761 BOOLEAN flg_default_firm_use = FALSE; 2761 BOOLEAN flg_default_firm_use = FALSE;
2762 2762
2763 2763
2764 DBGPRINT(RT_DEBUG_TRACE, ("===> %s\n", __FUNCTION__)); 2764 DBGPRINT(RT_DEBUG_TRACE, ("===> %s\n", __func__));
2765 2765
2766 /* init */ 2766 /* init */
2767 pFirmwareImage = NULL; 2767 pFirmwareImage = NULL;
@@ -2784,7 +2784,7 @@ NDIS_STATUS NICLoadFirmware(
2784 if (pFirmwareImage == NULL) 2784 if (pFirmwareImage == NULL)
2785 { 2785 {
2786 /* allocate fail, use default firmware array in firmware.h */ 2786 /* allocate fail, use default firmware array in firmware.h */
2787 printk("%s - Allocate memory fail!\n", __FUNCTION__); 2787 printk("%s - Allocate memory fail!\n", __func__);
2788 NICLF_DEFAULT_USE(); 2788 NICLF_DEFAULT_USE();
2789 } 2789 }
2790 else 2790 else
@@ -2805,7 +2805,7 @@ NDIS_STATUS NICLoadFirmware(
2805 if (IS_ERR(srcf)) 2805 if (IS_ERR(srcf))
2806 { 2806 {
2807 printk("%s - Error %ld opening %s\n", 2807 printk("%s - Error %ld opening %s\n",
2808 __FUNCTION__, -PTR_ERR(srcf), src); 2808 __func__, -PTR_ERR(srcf), src);
2809 NICLF_DEFAULT_USE(); 2809 NICLF_DEFAULT_USE();
2810 break; 2810 break;
2811 } /* End of if */ 2811 } /* End of if */
@@ -2813,7 +2813,7 @@ NDIS_STATUS NICLoadFirmware(
2813 /* the object must have a read method */ 2813 /* the object must have a read method */
2814 if ((srcf->f_op == NULL) || (srcf->f_op->read == NULL)) 2814 if ((srcf->f_op == NULL) || (srcf->f_op->read == NULL))
2815 { 2815 {
2816 printk("%s - %s does not have a write method\n", __FUNCTION__, src); 2816 printk("%s - %s does not have a write method\n", __func__, src);
2817 NICLF_DEFAULT_USE(); 2817 NICLF_DEFAULT_USE();
2818 break; 2818 break;
2819 } /* End of if */ 2819 } /* End of if */
@@ -2827,7 +2827,7 @@ NDIS_STATUS NICLoadFirmware(
2827 if (FileLength != MAX_FIRMWARE_IMAGE_SIZE) 2827 if (FileLength != MAX_FIRMWARE_IMAGE_SIZE)
2828 { 2828 {
2829 printk("%s: error file length (=%d) in RT2860AP.BIN\n", 2829 printk("%s: error file length (=%d) in RT2860AP.BIN\n",
2830 __FUNCTION__, FileLength); 2830 __func__, FileLength);
2831 NICLF_DEFAULT_USE(); 2831 NICLF_DEFAULT_USE();
2832 break; 2832 break;
2833 } 2833 }
@@ -2850,7 +2850,7 @@ NDIS_STATUS NICLoadFirmware(
2850 /* CRC fail */ 2850 /* CRC fail */
2851 printk("%s: CRC = 0x%02x 0x%02x " 2851 printk("%s: CRC = 0x%02x 0x%02x "
2852 "error, should be 0x%02x 0x%02x\n", 2852 "error, should be 0x%02x 0x%02x\n",
2853 __FUNCTION__, 2853 __func__,
2854 pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-2], 2854 pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-2],
2855 pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-1], 2855 pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-1],
2856 (UCHAR)(crc>>8), (UCHAR)(crc)); 2856 (UCHAR)(crc>>8), (UCHAR)(crc));
@@ -2869,7 +2869,7 @@ NDIS_STATUS NICLoadFirmware(
2869 ((FIRMWARE_MAJOR_VERSION << 8) + 2869 ((FIRMWARE_MAJOR_VERSION << 8) +
2870 FIRMWARE_MINOR_VERSION)) 2870 FIRMWARE_MINOR_VERSION))
2871 { 2871 {
2872 printk("%s: firmware version too old!\n", __FUNCTION__); 2872 printk("%s: firmware version too old!\n", __func__);
2873 NICLF_DEFAULT_USE(); 2873 NICLF_DEFAULT_USE();
2874 break; 2874 break;
2875 } /* End of if */ 2875 } /* End of if */
@@ -3024,10 +3024,10 @@ NDIS_STATUS NICLoadFirmware(
3024 3024
3025#if 0 3025#if 0
3026 DBGPRINT(RT_DEBUG_TRACE, 3026 DBGPRINT(RT_DEBUG_TRACE,
3027 ("<=== %s (src=%s, status=%d)\n", __FUNCTION__, src, Status)); 3027 ("<=== %s (src=%s, status=%d)\n", __func__, src, Status));
3028#else 3028#else
3029 DBGPRINT(RT_DEBUG_TRACE, 3029 DBGPRINT(RT_DEBUG_TRACE,
3030 ("<=== %s (status=%d)\n", __FUNCTION__, Status)); 3030 ("<=== %s (status=%d)\n", __func__, Status));
3031#endif 3031#endif
3032 return Status; 3032 return Status;
3033} /* End of NICLoadFirmware */ 3033} /* End of NICLoadFirmware */
diff --git a/drivers/staging/rt2870/common/rtusb_bulk.c b/drivers/staging/rt2870/common/rtusb_bulk.c
index 3c6ba1b9deb1..c46d9166ccf4 100644
--- a/drivers/staging/rt2870/common/rtusb_bulk.c
+++ b/drivers/staging/rt2870/common/rtusb_bulk.c
@@ -329,7 +329,7 @@ VOID RTUSBBulkOutDataPacket(
329 329
330 if (pTxInfo->QSEL != FIFO_EDCA) 330 if (pTxInfo->QSEL != FIFO_EDCA)
331 { 331 {
332 printk("%s(): ====> pTxInfo->QueueSel(%d)!= FIFO_EDCA!!!!\n", __FUNCTION__, pTxInfo->QSEL); 332 printk("%s(): ====> pTxInfo->QueueSel(%d)!= FIFO_EDCA!!!!\n", __func__, pTxInfo->QSEL);
333 printk("\tCWPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d!\n", pHTTXContext->CurWritePosition, pHTTXContext->NextBulkOutPosition, pHTTXContext->ENextBulkOutPosition, pHTTXContext->bCopySavePad); 333 printk("\tCWPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d!\n", pHTTXContext->CurWritePosition, pHTTXContext->NextBulkOutPosition, pHTTXContext->ENextBulkOutPosition, pHTTXContext->bCopySavePad);
334 hex_dump("Wrong QSel Pkt:", (PUCHAR)&pWirelessPkt[TmpBulkEndPos], (pHTTXContext->CurWritePosition - pHTTXContext->NextBulkOutPosition)); 334 hex_dump("Wrong QSel Pkt:", (PUCHAR)&pWirelessPkt[TmpBulkEndPos], (pHTTXContext->CurWritePosition - pHTTXContext->NextBulkOutPosition));
335 } 335 }
@@ -942,7 +942,7 @@ VOID RTUSBBulkOutMLMEPacket(
942 pTxInfo = (PTXINFO_STRUC)pMLMEContext->TransferBuffer; 942 pTxInfo = (PTXINFO_STRUC)pMLMEContext->TransferBuffer;
943 if (pTxInfo->QSEL != FIFO_EDCA) 943 if (pTxInfo->QSEL != FIFO_EDCA)
944 { 944 {
945 printk("%s(): ====> pTxInfo->QueueSel(%d)!= FIFO_EDCA!!!!\n", __FUNCTION__, pTxInfo->QSEL); 945 printk("%s(): ====> pTxInfo->QueueSel(%d)!= FIFO_EDCA!!!!\n", __func__, pTxInfo->QSEL);
946 printk("\tMLME_Index=%d!\n", Index); 946 printk("\tMLME_Index=%d!\n", Index);
947 hex_dump("Wrong QSel Pkt:", (PUCHAR)pMLMEContext->TransferBuffer, pTxInfo->USBDMATxPktLen); 947 hex_dump("Wrong QSel Pkt:", (PUCHAR)pMLMEContext->TransferBuffer, pTxInfo->USBDMATxPktLen);
948 } 948 }
diff --git a/drivers/staging/rt2870/common/spectrum.c b/drivers/staging/rt2870/common/spectrum.c
index abba8405184f..43782ce9288f 100644
--- a/drivers/staging/rt2870/common/spectrum.c
+++ b/drivers/staging/rt2870/common/spectrum.c
@@ -48,7 +48,7 @@ VOID MeasureReqTabInit(
48 if (pAd->CommonCfg.pMeasureReqTab) 48 if (pAd->CommonCfg.pMeasureReqTab)
49 NdisZeroMemory(pAd->CommonCfg.pMeasureReqTab, sizeof(MEASURE_REQ_TAB)); 49 NdisZeroMemory(pAd->CommonCfg.pMeasureReqTab, sizeof(MEASURE_REQ_TAB));
50 else 50 else
51 DBGPRINT(RT_DEBUG_ERROR, ("%s Fail to alloc memory for pAd->CommonCfg.pMeasureReqTab.\n", __FUNCTION__)); 51 DBGPRINT(RT_DEBUG_ERROR, ("%s Fail to alloc memory for pAd->CommonCfg.pMeasureReqTab.\n", __func__));
52 52
53 return; 53 return;
54} 54}
@@ -76,7 +76,7 @@ static PMEASURE_REQ_ENTRY MeasureReqLookUp(
76 76
77 if (pTab == NULL) 77 if (pTab == NULL)
78 { 78 {
79 DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __FUNCTION__)); 79 DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __func__));
80 return NULL; 80 return NULL;
81 } 81 }
82 82
@@ -113,7 +113,7 @@ static PMEASURE_REQ_ENTRY MeasureReqInsert(
113 113
114 if(pTab == NULL) 114 if(pTab == NULL)
115 { 115 {
116 DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __FUNCTION__)); 116 DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __func__));
117 return NULL; 117 return NULL;
118 } 118 }
119 119
@@ -174,7 +174,7 @@ static PMEASURE_REQ_ENTRY MeasureReqInsert(
174 else 174 else
175 { 175 {
176 pEntry = NULL; 176 pEntry = NULL;
177 DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab tab full.\n", __FUNCTION__)); 177 DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab tab full.\n", __func__));
178 } 178 }
179 179
180 // add this Neighbor entry into HASH table 180 // add this Neighbor entry into HASH table
@@ -209,7 +209,7 @@ static VOID MeasureReqDelete(
209 209
210 if(pTab == NULL) 210 if(pTab == NULL)
211 { 211 {
212 DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __FUNCTION__)); 212 DBGPRINT(RT_DEBUG_ERROR, ("%s: pMeasureReqTab doesn't exist.\n", __func__));
213 return; 213 return;
214 } 214 }
215 215
@@ -266,7 +266,7 @@ VOID TpcReqTabInit(
266 if (pAd->CommonCfg.pTpcReqTab) 266 if (pAd->CommonCfg.pTpcReqTab)
267 NdisZeroMemory(pAd->CommonCfg.pTpcReqTab, sizeof(TPC_REQ_TAB)); 267 NdisZeroMemory(pAd->CommonCfg.pTpcReqTab, sizeof(TPC_REQ_TAB));
268 else 268 else
269 DBGPRINT(RT_DEBUG_ERROR, ("%s Fail to alloc memory for pAd->CommonCfg.pTpcReqTab.\n", __FUNCTION__)); 269 DBGPRINT(RT_DEBUG_ERROR, ("%s Fail to alloc memory for pAd->CommonCfg.pTpcReqTab.\n", __func__));
270 270
271 return; 271 return;
272} 272}
@@ -294,7 +294,7 @@ static PTPC_REQ_ENTRY TpcReqLookUp(
294 294
295 if (pTab == NULL) 295 if (pTab == NULL)
296 { 296 {
297 DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __FUNCTION__)); 297 DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __func__));
298 return NULL; 298 return NULL;
299 } 299 }
300 300
@@ -332,7 +332,7 @@ static PTPC_REQ_ENTRY TpcReqInsert(
332 332
333 if(pTab == NULL) 333 if(pTab == NULL)
334 { 334 {
335 DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __FUNCTION__)); 335 DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __func__));
336 return NULL; 336 return NULL;
337 } 337 }
338 338
@@ -393,7 +393,7 @@ static PTPC_REQ_ENTRY TpcReqInsert(
393 else 393 else
394 { 394 {
395 pEntry = NULL; 395 pEntry = NULL;
396 DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab tab full.\n", __FUNCTION__)); 396 DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab tab full.\n", __func__));
397 } 397 }
398 398
399 // add this Neighbor entry into HASH table 399 // add this Neighbor entry into HASH table
@@ -428,7 +428,7 @@ static VOID TpcReqDelete(
428 428
429 if(pTab == NULL) 429 if(pTab == NULL)
430 { 430 {
431 DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __FUNCTION__)); 431 DBGPRINT(RT_DEBUG_ERROR, ("%s: pTpcReqTab doesn't exist.\n", __func__));
432 return; 432 return;
433 } 433 }
434 434
@@ -781,7 +781,7 @@ VOID EnqueueMeasurementReq(
781 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory 781 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
782 if(NStatus != NDIS_STATUS_SUCCESS) 782 if(NStatus != NDIS_STATUS_SUCCESS)
783 { 783 {
784 DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __FUNCTION__)); 784 DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __func__));
785 return; 785 return;
786 } 786 }
787 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11)); 787 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
@@ -843,7 +843,7 @@ VOID EnqueueMeasurementRep(
843 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory 843 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
844 if(NStatus != NDIS_STATUS_SUCCESS) 844 if(NStatus != NDIS_STATUS_SUCCESS)
845 { 845 {
846 DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __FUNCTION__)); 846 DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __func__));
847 return; 847 return;
848 } 848 }
849 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11)); 849 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
@@ -897,7 +897,7 @@ VOID EnqueueTPCReq(
897 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory 897 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
898 if(NStatus != NDIS_STATUS_SUCCESS) 898 if(NStatus != NDIS_STATUS_SUCCESS)
899 { 899 {
900 DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __FUNCTION__)); 900 DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __func__));
901 return; 901 return;
902 } 902 }
903 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11)); 903 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
@@ -949,7 +949,7 @@ VOID EnqueueTPCRep(
949 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory 949 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
950 if(NStatus != NDIS_STATUS_SUCCESS) 950 if(NStatus != NDIS_STATUS_SUCCESS)
951 { 951 {
952 DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __FUNCTION__)); 952 DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __func__));
953 return; 953 return;
954 } 954 }
955 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11)); 955 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
@@ -1002,7 +1002,7 @@ VOID EnqueueChSwAnn(
1002 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory 1002 NStatus = MlmeAllocateMemory(pAd, (PVOID)&pOutBuffer); //Get an unused nonpaged memory
1003 if(NStatus != NDIS_STATUS_SUCCESS) 1003 if(NStatus != NDIS_STATUS_SUCCESS)
1004 { 1004 {
1005 DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __FUNCTION__)); 1005 DBGPRINT(RT_DEBUG_TRACE, ("%s() allocate memory failed \n", __func__));
1006 return; 1006 return;
1007 } 1007 }
1008 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11)); 1008 NdisMoveMemory(pOutBuffer, (PCHAR)&ActHdr, sizeof(HEADER_802_11));
@@ -1595,7 +1595,7 @@ static VOID PeerMeasureReportAction(
1595 1595
1596 if ((pMeasureReportInfo = kmalloc(sizeof(MEASURE_RPI_REPORT), GFP_ATOMIC)) == NULL) 1596 if ((pMeasureReportInfo = kmalloc(sizeof(MEASURE_RPI_REPORT), GFP_ATOMIC)) == NULL)
1597 { 1597 {
1598 DBGPRINT(RT_DEBUG_ERROR, ("%s unable to alloc memory for measure report buffer (size=%d).\n", __FUNCTION__, sizeof(MEASURE_RPI_REPORT))); 1598 DBGPRINT(RT_DEBUG_ERROR, ("%s unable to alloc memory for measure report buffer (size=%d).\n", __func__, sizeof(MEASURE_RPI_REPORT)));
1599 return; 1599 return;
1600 } 1600 }
1601 1601
@@ -1704,7 +1704,7 @@ static VOID PeerTpcRepAction(
1704 { 1704 {
1705 TpcReqDelete(pAd, pEntry->DialogToken); 1705 TpcReqDelete(pAd, pEntry->DialogToken);
1706 DBGPRINT(RT_DEBUG_TRACE, ("%s: DialogToken=%x, TxPwr=%d, LinkMargin=%d\n", 1706 DBGPRINT(RT_DEBUG_TRACE, ("%s: DialogToken=%x, TxPwr=%d, LinkMargin=%d\n",
1707 __FUNCTION__, DialogToken, TpcRepInfo.TxPwr, TpcRepInfo.LinkMargin)); 1707 __func__, DialogToken, TpcRepInfo.TxPwr, TpcRepInfo.LinkMargin));
1708 } 1708 }
1709 } 1709 }
1710 1710
@@ -1820,7 +1820,7 @@ INT Set_MeasureReq_Proc(
1820 MeasureReqType = simple_strtol(thisChar, 0, 16); 1820 MeasureReqType = simple_strtol(thisChar, 0, 16);
1821 if (MeasureReqType > 3) 1821 if (MeasureReqType > 3)
1822 { 1822 {
1823 DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow MeasureReqType(%d)\n", __FUNCTION__, MeasureReqType)); 1823 DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow MeasureReqType(%d)\n", __func__, MeasureReqType));
1824 return TRUE; 1824 return TRUE;
1825 } 1825 }
1826 break; 1826 break;
@@ -1832,10 +1832,10 @@ INT Set_MeasureReq_Proc(
1832 ArgIdx++; 1832 ArgIdx++;
1833 } 1833 }
1834 1834
1835 DBGPRINT(RT_DEBUG_TRACE, ("%s::Aid = %d, MeasureReqType=%d MeasureCh=%d\n", __FUNCTION__, Aid, MeasureReqType, MeasureCh)); 1835 DBGPRINT(RT_DEBUG_TRACE, ("%s::Aid = %d, MeasureReqType=%d MeasureCh=%d\n", __func__, Aid, MeasureReqType, MeasureCh));
1836 if (!VALID_WCID(Aid)) 1836 if (!VALID_WCID(Aid))
1837 { 1837 {
1838 DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow sta of Aid(%d)\n", __FUNCTION__, Aid)); 1838 DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow sta of Aid(%d)\n", __func__, Aid));
1839 return TRUE; 1839 return TRUE;
1840 } 1840 }
1841 1841
@@ -1860,10 +1860,10 @@ INT Set_TpcReq_Proc(
1860 1860
1861 Aid = simple_strtol(arg, 0, 16); 1861 Aid = simple_strtol(arg, 0, 16);
1862 1862
1863 DBGPRINT(RT_DEBUG_TRACE, ("%s::Aid = %d\n", __FUNCTION__, Aid)); 1863 DBGPRINT(RT_DEBUG_TRACE, ("%s::Aid = %d\n", __func__, Aid));
1864 if (!VALID_WCID(Aid)) 1864 if (!VALID_WCID(Aid))
1865 { 1865 {
1866 DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow sta of Aid(%d)\n", __FUNCTION__, Aid)); 1866 DBGPRINT(RT_DEBUG_ERROR, ("%s: unknow sta of Aid(%d)\n", __func__, Aid));
1867 return TRUE; 1867 return TRUE;
1868 } 1868 }
1869 1869
diff --git a/drivers/staging/rt2870/rt_ate.c b/drivers/staging/rt2870/rt_ate.c
index e99b3da0b62d..27c763ee9276 100644
--- a/drivers/staging/rt2870/rt_ate.c
+++ b/drivers/staging/rt2870/rt_ate.c
@@ -314,7 +314,7 @@ static INT ATETxPwrHandler(
314 Bbp94 = BBPR94_DEFAULT; 314 Bbp94 = BBPR94_DEFAULT;
315 } 315 }
316 316
317 ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R=%ld, BBP_R94=%d)\n", __FUNCTION__, TxPower, R, Bbp94)); 317 ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R=%ld, BBP_R94=%d)\n", __func__, TxPower, R, Bbp94));
318 } 318 }
319 else// 5.5 GHz 319 else// 5.5 GHz
320 { 320 {
@@ -341,7 +341,7 @@ static INT ATETxPwrHandler(
341 R = (ULONG) TxPower; 341 R = (ULONG) TxPower;
342 } 342 }
343 343
344 ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R=%lu)\n", __FUNCTION__, TxPower, R)); 344 ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R=%lu)\n", __func__, TxPower, R));
345 } 345 }
346 346
347 if (pAd->ate.Channel <= 14) 347 if (pAd->ate.Channel <= 14)
@@ -454,7 +454,7 @@ static INT ATETxPwrHandler(
454 Bbp94 = BBPR94_DEFAULT; 454 Bbp94 = BBPR94_DEFAULT;
455 } 455 }
456 456
457 ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R3=%ld, BBP_R94=%d)\n", __FUNCTION__, TxPower, R, Bbp94)); 457 ATEDBGPRINT(RT_DEBUG_TRACE, ("%s (TxPower=%d, R3=%ld, BBP_R94=%d)\n", __func__, TxPower, R, Bbp94));
458 458
459 if (pAd->ate.Channel <= 14) 459 if (pAd->ate.Channel <= 14)
460 { 460 {
@@ -2261,7 +2261,7 @@ INT Set_ATE_Load_E2P_Proc(
2261 UINT32 FileLength = 0; 2261 UINT32 FileLength = 0;
2262 UINT32 value = simple_strtol(arg, 0, 10); 2262 UINT32 value = simple_strtol(arg, 0, 10);
2263 2263
2264 ATEDBGPRINT(RT_DEBUG_ERROR, ("===> %s (value=%d)\n\n", __FUNCTION__, value)); 2264 ATEDBGPRINT(RT_DEBUG_ERROR, ("===> %s (value=%d)\n\n", __func__, value));
2265 2265
2266 if (value > 0) 2266 if (value > 0)
2267 { 2267 {
@@ -2285,14 +2285,14 @@ INT Set_ATE_Load_E2P_Proc(
2285 2285
2286 if (IS_ERR(srcf)) 2286 if (IS_ERR(srcf))
2287 { 2287 {
2288 ate_print("%s - Error %ld opening %s\n", __FUNCTION__, -PTR_ERR(srcf), src); 2288 ate_print("%s - Error %ld opening %s\n", __func__, -PTR_ERR(srcf), src);
2289 break; 2289 break;
2290 } 2290 }
2291 2291
2292 /* the object must have a read method */ 2292 /* the object must have a read method */
2293 if ((srcf->f_op == NULL) || (srcf->f_op->read == NULL)) 2293 if ((srcf->f_op == NULL) || (srcf->f_op->read == NULL))
2294 { 2294 {
2295 ate_print("%s - %s does not have a read method\n", __FUNCTION__, src); 2295 ate_print("%s - %s does not have a read method\n", __func__, src);
2296 break; 2296 break;
2297 } 2297 }
2298 2298
@@ -2305,7 +2305,7 @@ INT Set_ATE_Load_E2P_Proc(
2305 if (FileLength != EEPROM_SIZE) 2305 if (FileLength != EEPROM_SIZE)
2306 { 2306 {
2307 ate_print("%s: error file length (=%d) in e2p.bin\n", 2307 ate_print("%s: error file length (=%d) in e2p.bin\n",
2308 __FUNCTION__, FileLength); 2308 __func__, FileLength);
2309 break; 2309 break;
2310 } 2310 }
2311 else 2311 else
@@ -2337,7 +2337,7 @@ INT Set_ATE_Load_E2P_Proc(
2337 current->fsuid = orgfsuid; 2337 current->fsuid = orgfsuid;
2338 current->fsgid = orgfsgid; 2338 current->fsgid = orgfsgid;
2339 } 2339 }
2340 ATEDBGPRINT(RT_DEBUG_ERROR, ("<=== %s (ret=%d)\n", __FUNCTION__, ret)); 2340 ATEDBGPRINT(RT_DEBUG_ERROR, ("<=== %s (ret=%d)\n", __func__, ret));
2341 2341
2342 return ret; 2342 return ret;
2343 2343
@@ -2350,12 +2350,12 @@ INT Set_ATE_Load_E2P_Proc(
2350 USHORT WriteEEPROM[(EEPROM_SIZE/2)]; 2350 USHORT WriteEEPROM[(EEPROM_SIZE/2)];
2351 struct iwreq *wrq = (struct iwreq *)arg; 2351 struct iwreq *wrq = (struct iwreq *)arg;
2352 2352
2353 ATEDBGPRINT(RT_DEBUG_TRACE, ("===> %s (wrq->u.data.length = %d)\n\n", __FUNCTION__, wrq->u.data.length)); 2353 ATEDBGPRINT(RT_DEBUG_TRACE, ("===> %s (wrq->u.data.length = %d)\n\n", __func__, wrq->u.data.length));
2354 2354
2355 if (wrq->u.data.length != EEPROM_SIZE) 2355 if (wrq->u.data.length != EEPROM_SIZE)
2356 { 2356 {
2357 ate_print("%s: error length (=%d) from host\n", 2357 ate_print("%s: error length (=%d) from host\n",
2358 __FUNCTION__, wrq->u.data.length); 2358 __func__, wrq->u.data.length);
2359 return FALSE; 2359 return FALSE;
2360 } 2360 }
2361 else/* (wrq->u.data.length == EEPROM_SIZE) */ 2361 else/* (wrq->u.data.length == EEPROM_SIZE) */
@@ -2374,7 +2374,7 @@ INT Set_ATE_Load_E2P_Proc(
2374 } while(FALSE); 2374 } while(FALSE);
2375 } 2375 }
2376 2376
2377 ATEDBGPRINT(RT_DEBUG_TRACE, ("<=== %s\n", __FUNCTION__)); 2377 ATEDBGPRINT(RT_DEBUG_TRACE, ("<=== %s\n", __func__));
2378 2378
2379 return TRUE; 2379 return TRUE;
2380 2380
@@ -4083,7 +4083,7 @@ VOID RtmpDoAte(
4083 4083
4084 Command_Id = ntohs(pRaCfg->command_id); 4084 Command_Id = ntohs(pRaCfg->command_id);
4085 4085
4086 ATEDBGPRINT(RT_DEBUG_TRACE,("\n%s: Command_Id = 0x%04x !\n", __FUNCTION__, Command_Id)); 4086 ATEDBGPRINT(RT_DEBUG_TRACE,("\n%s: Command_Id = 0x%04x !\n", __func__, Command_Id));
4087 4087
4088 switch (Command_Id) 4088 switch (Command_Id)
4089 { 4089 {
@@ -6117,7 +6117,7 @@ BOOLEAN SyncTxRxConfig(PRTMP_ADAPTER pAd, USHORT offset, UCHAR value)
6117 pAd->ate.TxAntennaSel = 2; 6117 pAd->ate.TxAntennaSel = 2;
6118 break; 6118 break;
6119 default: 6119 default:
6120 DBGPRINT(RT_DEBUG_TRACE, ("%s -- Sth. wrong! : return FALSE; \n", __FUNCTION__)); 6120 DBGPRINT(RT_DEBUG_TRACE, ("%s -- Sth. wrong! : return FALSE; \n", __func__));
6121 return FALSE; 6121 return FALSE;
6122 } 6122 }
6123 break;/* case BBP_R1 */ 6123 break;/* case BBP_R1 */
@@ -6155,13 +6155,13 @@ BOOLEAN SyncTxRxConfig(PRTMP_ADAPTER pAd, USHORT offset, UCHAR value)
6155 pAd->ate.RxAntennaSel = 3; 6155 pAd->ate.RxAntennaSel = 3;
6156 break; 6156 break;
6157 default: 6157 default:
6158 DBGPRINT(RT_DEBUG_ERROR, ("%s -- Impossible! : return FALSE; \n", __FUNCTION__)); 6158 DBGPRINT(RT_DEBUG_ERROR, ("%s -- Impossible! : return FALSE; \n", __func__));
6159 return FALSE; 6159 return FALSE;
6160 } 6160 }
6161 break;/* case BBP_R3 */ 6161 break;/* case BBP_R3 */
6162 6162
6163 default: 6163 default:
6164 DBGPRINT(RT_DEBUG_ERROR, ("%s -- Sth. wrong! : return FALSE; \n", __FUNCTION__)); 6164 DBGPRINT(RT_DEBUG_ERROR, ("%s -- Sth. wrong! : return FALSE; \n", __func__));
6165 return FALSE; 6165 return FALSE;
6166 6166
6167 } 6167 }
diff --git a/drivers/staging/rt2870/rt_linux.c b/drivers/staging/rt2870/rt_linux.c
index f2ea8ebcd042..992e3d16f9b4 100644
--- a/drivers/staging/rt2870/rt_linux.c
+++ b/drivers/staging/rt2870/rt_linux.c
@@ -404,7 +404,7 @@ NDIS_STATUS RTMPAllocateNdisPacket(
404 skb_put(GET_OS_PKT_TYPE(pPacket), HeaderLen+DataLen); 404 skb_put(GET_OS_PKT_TYPE(pPacket), HeaderLen+DataLen);
405 405
406 RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS); 406 RTMP_SET_PACKET_SOURCE(pPacket, PKTSRC_NDIS);
407// printk("%s : pPacket = %p, len = %d\n", __FUNCTION__, pPacket, GET_OS_PKT_LEN(pPacket)); 407// printk("%s : pPacket = %p, len = %d\n", __func__, pPacket, GET_OS_PKT_LEN(pPacket));
408 *ppPacket = pPacket; 408 *ppPacket = pPacket;
409 return NDIS_STATUS_SUCCESS; 409 return NDIS_STATUS_SUCCESS;
410} 410}
@@ -814,13 +814,13 @@ VOID RTMPSendWirelessEvent(
814 814
815 if (event_table_len == 0) 815 if (event_table_len == 0)
816 { 816 {
817 DBGPRINT(RT_DEBUG_ERROR, ("%s : The type(%0x02x) is not valid.\n", __FUNCTION__, type)); 817 DBGPRINT(RT_DEBUG_ERROR, ("%s : The type(%0x02x) is not valid.\n", __func__, type));
818 return; 818 return;
819 } 819 }
820 820
821 if (event >= event_table_len) 821 if (event >= event_table_len)
822 { 822 {
823 DBGPRINT(RT_DEBUG_ERROR, ("%s : The event(%0x02x) is not valid.\n", __FUNCTION__, event)); 823 DBGPRINT(RT_DEBUG_ERROR, ("%s : The event(%0x02x) is not valid.\n", __func__, event));
824 return; 824 return;
825 } 825 }
826 826
@@ -858,14 +858,14 @@ VOID RTMPSendWirelessEvent(
858 //send wireless event 858 //send wireless event
859 wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, pBuf); 859 wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, pBuf);
860 860
861 //DBGPRINT(RT_DEBUG_TRACE, ("%s : %s\n", __FUNCTION__, pBuf)); 861 //DBGPRINT(RT_DEBUG_TRACE, ("%s : %s\n", __func__, pBuf));
862 862
863 kfree(pBuf); 863 kfree(pBuf);
864 } 864 }
865 else 865 else
866 DBGPRINT(RT_DEBUG_ERROR, ("%s : Can't allocate memory for wireless event.\n", __FUNCTION__)); 866 DBGPRINT(RT_DEBUG_ERROR, ("%s : Can't allocate memory for wireless event.\n", __func__));
867#else 867#else
868 DBGPRINT(RT_DEBUG_ERROR, ("%s : The Wireless Extension MUST be v15 or newer.\n", __FUNCTION__)); 868 DBGPRINT(RT_DEBUG_ERROR, ("%s : The Wireless Extension MUST be v15 or newer.\n", __func__));
869#endif /* WIRELESS_EXT >= 15 */ 869#endif /* WIRELESS_EXT >= 15 */
870} 870}
871 871
@@ -889,13 +889,13 @@ void send_monitor_packets(
889 ASSERT(pRxBlk->pRxPacket); 889 ASSERT(pRxBlk->pRxPacket);
890 if (pRxBlk->DataSize < 10) 890 if (pRxBlk->DataSize < 10)
891 { 891 {
892 DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too small! (%d)\n", __FUNCTION__, pRxBlk->DataSize)); 892 DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too small! (%d)\n", __func__, pRxBlk->DataSize));
893 goto err_free_sk_buff; 893 goto err_free_sk_buff;
894 } 894 }
895 895
896 if (pRxBlk->DataSize + sizeof(wlan_ng_prism2_header) > RX_BUFFER_AGGRESIZE) 896 if (pRxBlk->DataSize + sizeof(wlan_ng_prism2_header) > RX_BUFFER_AGGRESIZE)
897 { 897 {
898 DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too large! (%d)\n", __FUNCTION__, pRxBlk->DataSize + sizeof(wlan_ng_prism2_header))); 898 DBGPRINT(RT_DEBUG_ERROR, ("%s : Size is too large! (%d)\n", __func__, pRxBlk->DataSize + sizeof(wlan_ng_prism2_header)));
899 goto err_free_sk_buff; 899 goto err_free_sk_buff;
900 } 900 }
901 901
@@ -951,7 +951,7 @@ void send_monitor_packets(
951 951
952 if (skb_headroom(pOSPkt) < (sizeof(wlan_ng_prism2_header)+ header_len)) { 952 if (skb_headroom(pOSPkt) < (sizeof(wlan_ng_prism2_header)+ header_len)) {
953 if (pskb_expand_head(pOSPkt, (sizeof(wlan_ng_prism2_header) + header_len), 0, GFP_ATOMIC)) { 953 if (pskb_expand_head(pOSPkt, (sizeof(wlan_ng_prism2_header) + header_len), 0, GFP_ATOMIC)) {
954 DBGPRINT(RT_DEBUG_ERROR, ("%s : Reallocate header size of sk_buff fail!\n", __FUNCTION__)); 954 DBGPRINT(RT_DEBUG_ERROR, ("%s : Reallocate header size of sk_buff fail!\n", __func__));
955 goto err_free_sk_buff; 955 goto err_free_sk_buff;
956 } //end if 956 } //end if
957 } //end if 957 } //end if
diff --git a/drivers/staging/rt2870/rt_linux.h b/drivers/staging/rt2870/rt_linux.h
index 814297577261..859f9cef0a19 100644
--- a/drivers/staging/rt2870/rt_linux.h
+++ b/drivers/staging/rt2870/rt_linux.h
@@ -124,7 +124,7 @@ typedef int (*HARD_START_XMIT_FUNC)(struct sk_buff *skb, struct net_device *net_
124#define RT_MOD_INC_USE_COUNT() \ 124#define RT_MOD_INC_USE_COUNT() \
125 if (!try_module_get(THIS_MODULE)) \ 125 if (!try_module_get(THIS_MODULE)) \
126 { \ 126 { \
127 DBGPRINT(RT_DEBUG_ERROR, ("%s: cannot reserve module\n", __FUNCTION__)); \ 127 DBGPRINT(RT_DEBUG_ERROR, ("%s: cannot reserve module\n", __func__)); \
128 return -1; \ 128 return -1; \
129 } 129 }
130 130
diff --git a/drivers/staging/rt2870/rt_main_dev.c b/drivers/staging/rt2870/rt_main_dev.c
index b990f8a61641..313ecea0bfa8 100644
--- a/drivers/staging/rt2870/rt_main_dev.c
+++ b/drivers/staging/rt2870/rt_main_dev.c
@@ -1554,7 +1554,7 @@ int rt28xx_packet_xmit(struct sk_buff *skb)
1554#if 0 1554#if 0
1555// if ((pkt->data[0] & 0x1) == 0) 1555// if ((pkt->data[0] & 0x1) == 0)
1556 { 1556 {
1557 //hex_dump(__FUNCTION__, pkt->data, pkt->len); 1557 //hex_dump(__func__, pkt->data, pkt->len);
1558 printk("pPacket = %x\n", pPacket); 1558 printk("pPacket = %x\n", pPacket);
1559 } 1559 }
1560#endif 1560#endif
diff --git a/drivers/staging/rt2870/rt_profile.c b/drivers/staging/rt2870/rt_profile.c
index c4474a6428ac..467fea35e4a9 100644
--- a/drivers/staging/rt2870/rt_profile.c
+++ b/drivers/staging/rt2870/rt_profile.c
@@ -1024,7 +1024,7 @@ NDIS_STATUS RTMPReadParametersHook(
1024 pAd->MlmeAux.SsidLen = pAd->CommonCfg.SsidLen; 1024 pAd->MlmeAux.SsidLen = pAd->CommonCfg.SsidLen;
1025 NdisZeroMemory(pAd->MlmeAux.Ssid, NDIS_802_11_LENGTH_SSID); 1025 NdisZeroMemory(pAd->MlmeAux.Ssid, NDIS_802_11_LENGTH_SSID);
1026 NdisMoveMemory(pAd->MlmeAux.Ssid, tmpbuf, pAd->MlmeAux.SsidLen); 1026 NdisMoveMemory(pAd->MlmeAux.Ssid, tmpbuf, pAd->MlmeAux.SsidLen);
1027 DBGPRINT(RT_DEBUG_TRACE, ("%s::(SSID=%s)\n", __FUNCTION__, tmpbuf)); 1027 DBGPRINT(RT_DEBUG_TRACE, ("%s::(SSID=%s)\n", __func__, tmpbuf));
1028 } 1028 }
1029 } 1029 }
1030 } 1030 }
@@ -1043,7 +1043,7 @@ NDIS_STATUS RTMPReadParametersHook(
1043 pAd->StaCfg.BssType = BSS_INFRA; 1043 pAd->StaCfg.BssType = BSS_INFRA;
1044 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key 1044 // Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
1045 pAd->StaCfg.WpaState = SS_NOTUSE; 1045 pAd->StaCfg.WpaState = SS_NOTUSE;
1046 DBGPRINT(RT_DEBUG_TRACE, ("%s::(NetworkType=%d)\n", __FUNCTION__, pAd->StaCfg.BssType)); 1046 DBGPRINT(RT_DEBUG_TRACE, ("%s::(NetworkType=%d)\n", __func__, pAd->StaCfg.BssType));
1047 } 1047 }
1048 } 1048 }
1049#endif // CONFIG_STA_SUPPORT // 1049#endif // CONFIG_STA_SUPPORT //
@@ -1341,7 +1341,7 @@ NDIS_STATUS RTMPReadParametersHook(
1341 1341
1342 pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED; 1342 pAd->StaCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
1343 1343
1344 DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __FUNCTION__, pAd->StaCfg.WepStatus)); 1344 DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __func__, pAd->StaCfg.WepStatus));
1345 } 1345 }
1346#endif // CONFIG_STA_SUPPORT // 1346#endif // CONFIG_STA_SUPPORT //
1347 } 1347 }
@@ -1368,7 +1368,7 @@ NDIS_STATUS RTMPReadParametersHook(
1368 pAd->StaCfg.bMixCipher = FALSE; 1368 pAd->StaCfg.bMixCipher = FALSE;
1369 1369
1370 //RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, 0); 1370 //RTMPMakeRSNIE(pAd, pAd->StaCfg.AuthMode, pAd->StaCfg.WepStatus, 0);
1371 DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __FUNCTION__, pAd->StaCfg.WepStatus)); 1371 DBGPRINT(RT_DEBUG_TRACE, ("%s::(EncrypType=%d)\n", __func__, pAd->StaCfg.WepStatus));
1372 } 1372 }
1373#endif // CONFIG_STA_SUPPORT // 1373#endif // CONFIG_STA_SUPPORT //
1374 } 1374 }
@@ -1405,7 +1405,7 @@ NDIS_STATUS RTMPReadParametersHook(
1405 else 1405 else
1406 { 1406 {
1407 err = 1; 1407 err = 1;
1408 DBGPRINT(RT_DEBUG_ERROR, ("%s::(WPAPSK key-string required 8 ~ 64 characters!)\n", __FUNCTION__)); 1408 DBGPRINT(RT_DEBUG_ERROR, ("%s::(WPAPSK key-string required 8 ~ 64 characters!)\n", __func__));
1409 } 1409 }
1410 1410
1411 if (err == 0) 1411 if (err == 0)
@@ -1436,7 +1436,7 @@ NDIS_STATUS RTMPReadParametersHook(
1436 pAd->StaCfg.WpaState = SS_NOTUSE; 1436 pAd->StaCfg.WpaState = SS_NOTUSE;
1437 } 1437 }
1438 1438
1439 DBGPRINT(RT_DEBUG_TRACE, ("%s::(WPAPSK=%s)\n", __FUNCTION__, tmpbuf)); 1439 DBGPRINT(RT_DEBUG_TRACE, ("%s::(WPAPSK=%s)\n", __func__, tmpbuf));
1440 } 1440 }
1441 } 1441 }
1442 } 1442 }
diff --git a/drivers/staging/rt2870/rtmp_def.h b/drivers/staging/rt2870/rtmp_def.h
index 9b86325b4c55..c0f7561a9d9d 100644
--- a/drivers/staging/rt2870/rtmp_def.h
+++ b/drivers/staging/rt2870/rtmp_def.h
@@ -342,7 +342,7 @@
342/* sanity check for apidx */ 342/* sanity check for apidx */
343#define MBSS_MR_APIDX_SANITY_CHECK(apidx) \ 343#define MBSS_MR_APIDX_SANITY_CHECK(apidx) \
344 { if (apidx > MAX_MBSSID_NUM) { \ 344 { if (apidx > MAX_MBSSID_NUM) { \
345 printk("%s> Error! apidx = %d > MAX_MBSSID_NUM!\n", __FUNCTION__, apidx); \ 345 printk("%s> Error! apidx = %d > MAX_MBSSID_NUM!\n", __func__, apidx); \
346 apidx = MAIN_MBSSID; } } 346 apidx = MAIN_MBSSID; } }
347 347
348#define VALID_WCID(_wcid) ((_wcid) > 0 && (_wcid) < MAX_LEN_OF_MAC_TABLE ) 348#define VALID_WCID(_wcid) ((_wcid) > 0 && (_wcid) < MAX_LEN_OF_MAC_TABLE )
diff --git a/drivers/staging/rt2870/sta_ioctl.c b/drivers/staging/rt2870/sta_ioctl.c
index 422f39f9004a..91f0fab11313 100644
--- a/drivers/staging/rt2870/sta_ioctl.c
+++ b/drivers/staging/rt2870/sta_ioctl.c
@@ -2224,7 +2224,7 @@ rt_private_show(struct net_device *dev, struct iw_request_info *info,
2224 wrq->length = strlen(extra) + 1; // 1: size of '\0' 2224 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2225 break; 2225 break;
2226 default: 2226 default:
2227 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __FUNCTION__, subcmd)); 2227 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
2228 break; 2228 break;
2229 } 2229 }
2230 2230
@@ -2243,7 +2243,7 @@ int rt_ioctl_siwmlme(struct net_device *dev,
2243 MLME_DISASSOC_REQ_STRUCT DisAssocReq; 2243 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2244 MLME_DEAUTH_REQ_STRUCT DeAuthReq; 2244 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2245 2245
2246 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __FUNCTION__)); 2246 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
2247 2247
2248 if (pMlme == NULL) 2248 if (pMlme == NULL)
2249 return -EINVAL; 2249 return -EINVAL;
@@ -2252,7 +2252,7 @@ int rt_ioctl_siwmlme(struct net_device *dev,
2252 { 2252 {
2253#ifdef IW_MLME_DEAUTH 2253#ifdef IW_MLME_DEAUTH
2254 case IW_MLME_DEAUTH: 2254 case IW_MLME_DEAUTH:
2255 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __FUNCTION__)); 2255 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
2256 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid); 2256 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2257 DeAuthReq.Reason = pMlme->reason_code; 2257 DeAuthReq.Reason = pMlme->reason_code;
2258 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT); 2258 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
@@ -2267,7 +2267,7 @@ int rt_ioctl_siwmlme(struct net_device *dev,
2267#endif // IW_MLME_DEAUTH // 2267#endif // IW_MLME_DEAUTH //
2268#ifdef IW_MLME_DISASSOC 2268#ifdef IW_MLME_DISASSOC
2269 case IW_MLME_DISASSOC: 2269 case IW_MLME_DISASSOC:
2270 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __FUNCTION__)); 2270 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
2271 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid); 2271 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2272 DisAssocReq.Reason = pMlme->reason_code; 2272 DisAssocReq.Reason = pMlme->reason_code;
2273 2273
@@ -2281,7 +2281,7 @@ int rt_ioctl_siwmlme(struct net_device *dev,
2281 break; 2281 break;
2282#endif // IW_MLME_DISASSOC // 2282#endif // IW_MLME_DISASSOC //
2283 default: 2283 default:
2284 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __FUNCTION__)); 2284 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
2285 break; 2285 break;
2286 } 2286 }
2287 2287
@@ -2314,7 +2314,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
2314 else if (param->value == IW_AUTH_WPA_VERSION_WPA2) 2314 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2315 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK; 2315 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2316 2316
2317 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __FUNCTION__, param->value)); 2317 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2318 break; 2318 break;
2319 case IW_AUTH_CIPHER_PAIRWISE: 2319 case IW_AUTH_CIPHER_PAIRWISE:
2320 if (param->value == IW_AUTH_CIPHER_NONE) 2320 if (param->value == IW_AUTH_CIPHER_NONE)
@@ -2345,7 +2345,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
2345 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus; 2345 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2346 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled; 2346 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2347 } 2347 }
2348 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __FUNCTION__, param->value)); 2348 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
2349 break; 2349 break;
2350 case IW_AUTH_CIPHER_GROUP: 2350 case IW_AUTH_CIPHER_GROUP:
2351 if (param->value == IW_AUTH_CIPHER_NONE) 2351 if (param->value == IW_AUTH_CIPHER_NONE)
@@ -2365,7 +2365,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
2365 { 2365 {
2366 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled; 2366 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2367 } 2367 }
2368 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __FUNCTION__, param->value)); 2368 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
2369 break; 2369 break;
2370 case IW_AUTH_KEY_MGMT: 2370 case IW_AUTH_KEY_MGMT:
2371 if (param->value == IW_AUTH_KEY_MGMT_802_1X) 2371 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
@@ -2395,7 +2395,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
2395 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; 2395 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2396 STA_PORT_SECURED(pAdapter); 2396 STA_PORT_SECURED(pAdapter);
2397 } 2397 }
2398 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __FUNCTION__, param->value)); 2398 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2399 break; 2399 break;
2400 case IW_AUTH_RX_UNENCRYPTED_EAPOL: 2400 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2401 break; 2401 break;
@@ -2408,7 +2408,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
2408 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled; 2408 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2409 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled; 2409 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2410 }*/ 2410 }*/
2411 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __FUNCTION__, param->value)); 2411 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2412 break; 2412 break;
2413 case IW_AUTH_DROP_UNENCRYPTED: 2413 case IW_AUTH_DROP_UNENCRYPTED:
2414 if (param->value != 0) 2414 if (param->value != 0)
@@ -2418,7 +2418,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
2418 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; 2418 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2419 STA_PORT_SECURED(pAdapter); 2419 STA_PORT_SECURED(pAdapter);
2420 } 2420 }
2421 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __FUNCTION__, param->value)); 2421 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2422 break; 2422 break;
2423 case IW_AUTH_80211_AUTH_ALG: 2423 case IW_AUTH_80211_AUTH_ALG:
2424 if (param->value & IW_AUTH_ALG_SHARED_KEY) 2424 if (param->value & IW_AUTH_ALG_SHARED_KEY)
@@ -2431,10 +2431,10 @@ int rt_ioctl_siwauth(struct net_device *dev,
2431 } 2431 }
2432 else 2432 else
2433 return -EINVAL; 2433 return -EINVAL;
2434 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __FUNCTION__, param->value)); 2434 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2435 break; 2435 break;
2436 case IW_AUTH_WPA_ENABLED: 2436 case IW_AUTH_WPA_ENABLED:
2437 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __FUNCTION__, param->value)); 2437 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2438 break; 2438 break;
2439 default: 2439 default:
2440 return -EOPNOTSUPP; 2440 return -EOPNOTSUPP;
@@ -2542,7 +2542,7 @@ int rt_ioctl_siwencodeext(struct net_device *dev,
2542 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE; 2542 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2543 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx); 2543 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2544 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY)); 2544 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2545 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __FUNCTION__, encoding->flags)); 2545 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2546 } 2546 }
2547 else 2547 else
2548 { 2548 {
@@ -2554,15 +2554,15 @@ int rt_ioctl_siwencodeext(struct net_device *dev,
2554 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) 2554 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2555 { 2555 {
2556 pAdapter->StaCfg.DefaultKeyId = keyIdx; 2556 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2557 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __FUNCTION__, pAdapter->StaCfg.DefaultKeyId)); 2557 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2558 } 2558 }
2559 2559
2560 switch (alg) { 2560 switch (alg) {
2561 case IW_ENCODE_ALG_NONE: 2561 case IW_ENCODE_ALG_NONE:
2562 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __FUNCTION__)); 2562 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2563 break; 2563 break;
2564 case IW_ENCODE_ALG_WEP: 2564 case IW_ENCODE_ALG_WEP:
2565 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __FUNCTION__, ext->key_len, keyIdx)); 2565 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2566 if (ext->key_len == MAX_WEP_KEY_SIZE) 2566 if (ext->key_len == MAX_WEP_KEY_SIZE)
2567 { 2567 {
2568 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE; 2568 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
@@ -2595,7 +2595,7 @@ int rt_ioctl_siwencodeext(struct net_device *dev,
2595 } 2595 }
2596 break; 2596 break;
2597 case IW_ENCODE_ALG_TKIP: 2597 case IW_ENCODE_ALG_TKIP:
2598 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __FUNCTION__, keyIdx, ext->key_len)); 2598 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2599 if (ext->key_len == 32) 2599 if (ext->key_len == 32)
2600 { 2600 {
2601 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) 2601 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
diff --git a/drivers/staging/rt2870/tmp60 b/drivers/staging/rt2870/tmp60
index 992096a248c5..975e44484379 100644
--- a/drivers/staging/rt2870/tmp60
+++ b/drivers/staging/rt2870/tmp60
@@ -2224,7 +2224,7 @@ rt_private_show(struct net_device *dev, struct iw_request_info *info,
2224 wrq->length = strlen(extra) + 1; // 1: size of '\0' 2224 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2225 break; 2225 break;
2226 default: 2226 default:
2227 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __FUNCTION__, subcmd)); 2227 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
2228 break; 2228 break;
2229 } 2229 }
2230 2230
@@ -2243,7 +2243,7 @@ int rt_ioctl_siwmlme(struct net_device *dev,
2243 MLME_DISASSOC_REQ_STRUCT DisAssocReq; 2243 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2244 MLME_DEAUTH_REQ_STRUCT DeAuthReq; 2244 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2245 2245
2246 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __FUNCTION__)); 2246 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
2247 2247
2248 if (pMlme == NULL) 2248 if (pMlme == NULL)
2249 return -EINVAL; 2249 return -EINVAL;
@@ -2252,7 +2252,7 @@ int rt_ioctl_siwmlme(struct net_device *dev,
2252 { 2252 {
2253#ifdef IW_MLME_DEAUTH 2253#ifdef IW_MLME_DEAUTH
2254 case IW_MLME_DEAUTH: 2254 case IW_MLME_DEAUTH:
2255 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __FUNCTION__)); 2255 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
2256 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid); 2256 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2257 DeAuthReq.Reason = pMlme->reason_code; 2257 DeAuthReq.Reason = pMlme->reason_code;
2258 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT); 2258 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
@@ -2267,7 +2267,7 @@ int rt_ioctl_siwmlme(struct net_device *dev,
2267#endif // IW_MLME_DEAUTH // 2267#endif // IW_MLME_DEAUTH //
2268#ifdef IW_MLME_DISASSOC 2268#ifdef IW_MLME_DISASSOC
2269 case IW_MLME_DISASSOC: 2269 case IW_MLME_DISASSOC:
2270 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __FUNCTION__)); 2270 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
2271 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid); 2271 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2272 DisAssocReq.Reason = pMlme->reason_code; 2272 DisAssocReq.Reason = pMlme->reason_code;
2273 2273
@@ -2281,7 +2281,7 @@ int rt_ioctl_siwmlme(struct net_device *dev,
2281 break; 2281 break;
2282#endif // IW_MLME_DISASSOC // 2282#endif // IW_MLME_DISASSOC //
2283 default: 2283 default:
2284 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __FUNCTION__)); 2284 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
2285 break; 2285 break;
2286 } 2286 }
2287 2287
@@ -2314,7 +2314,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
2314 else if (param->value == IW_AUTH_WPA_VERSION_WPA2) 2314 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2315 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK; 2315 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2316 2316
2317 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __FUNCTION__, param->value)); 2317 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2318 break; 2318 break;
2319 case IW_AUTH_CIPHER_PAIRWISE: 2319 case IW_AUTH_CIPHER_PAIRWISE:
2320 if (param->value == IW_AUTH_CIPHER_NONE) 2320 if (param->value == IW_AUTH_CIPHER_NONE)
@@ -2345,7 +2345,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
2345 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus; 2345 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2346 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled; 2346 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2347 } 2347 }
2348 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __FUNCTION__, param->value)); 2348 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
2349 break; 2349 break;
2350 case IW_AUTH_CIPHER_GROUP: 2350 case IW_AUTH_CIPHER_GROUP:
2351 if (param->value == IW_AUTH_CIPHER_NONE) 2351 if (param->value == IW_AUTH_CIPHER_NONE)
@@ -2365,7 +2365,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
2365 { 2365 {
2366 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled; 2366 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2367 } 2367 }
2368 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __FUNCTION__, param->value)); 2368 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
2369 break; 2369 break;
2370 case IW_AUTH_KEY_MGMT: 2370 case IW_AUTH_KEY_MGMT:
2371 if (param->value == IW_AUTH_KEY_MGMT_802_1X) 2371 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
@@ -2395,7 +2395,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
2395 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; 2395 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2396 STA_PORT_SECURED(pAdapter); 2396 STA_PORT_SECURED(pAdapter);
2397 } 2397 }
2398 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __FUNCTION__, param->value)); 2398 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2399 break; 2399 break;
2400 case IW_AUTH_RX_UNENCRYPTED_EAPOL: 2400 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2401 break; 2401 break;
@@ -2408,7 +2408,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
2408 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled; 2408 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2409 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled; 2409 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2410 }*/ 2410 }*/
2411 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __FUNCTION__, param->value)); 2411 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2412 break; 2412 break;
2413 case IW_AUTH_DROP_UNENCRYPTED: 2413 case IW_AUTH_DROP_UNENCRYPTED:
2414 if (param->value != 0) 2414 if (param->value != 0)
@@ -2418,7 +2418,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
2418 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; 2418 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2419 STA_PORT_SECURED(pAdapter); 2419 STA_PORT_SECURED(pAdapter);
2420 } 2420 }
2421 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __FUNCTION__, param->value)); 2421 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2422 break; 2422 break;
2423 case IW_AUTH_80211_AUTH_ALG: 2423 case IW_AUTH_80211_AUTH_ALG:
2424 if (param->value & IW_AUTH_ALG_SHARED_KEY) 2424 if (param->value & IW_AUTH_ALG_SHARED_KEY)
@@ -2431,10 +2431,10 @@ int rt_ioctl_siwauth(struct net_device *dev,
2431 } 2431 }
2432 else 2432 else
2433 return -EINVAL; 2433 return -EINVAL;
2434 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __FUNCTION__, param->value)); 2434 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2435 break; 2435 break;
2436 case IW_AUTH_WPA_ENABLED: 2436 case IW_AUTH_WPA_ENABLED:
2437 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __FUNCTION__, param->value)); 2437 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2438 break; 2438 break;
2439 default: 2439 default:
2440 return -EOPNOTSUPP; 2440 return -EOPNOTSUPP;
@@ -2542,7 +2542,7 @@ int rt_ioctl_siwencodeext(struct net_device *dev,
2542 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE; 2542 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2543 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx); 2543 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2544 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY)); 2544 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2545 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __FUNCTION__, encoding->flags)); 2545 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2546 } 2546 }
2547 else 2547 else
2548 { 2548 {
@@ -2554,15 +2554,15 @@ int rt_ioctl_siwencodeext(struct net_device *dev,
2554 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) 2554 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2555 { 2555 {
2556 pAdapter->StaCfg.DefaultKeyId = keyIdx; 2556 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2557 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __FUNCTION__, pAdapter->StaCfg.DefaultKeyId)); 2557 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2558 } 2558 }
2559 2559
2560 switch (alg) { 2560 switch (alg) {
2561 case IW_ENCODE_ALG_NONE: 2561 case IW_ENCODE_ALG_NONE:
2562 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __FUNCTION__)); 2562 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2563 break; 2563 break;
2564 case IW_ENCODE_ALG_WEP: 2564 case IW_ENCODE_ALG_WEP:
2565 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __FUNCTION__, ext->key_len, keyIdx)); 2565 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2566 if (ext->key_len == MAX_WEP_KEY_SIZE) 2566 if (ext->key_len == MAX_WEP_KEY_SIZE)
2567 { 2567 {
2568 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE; 2568 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
@@ -2580,7 +2580,7 @@ int rt_ioctl_siwencodeext(struct net_device *dev,
2580 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len); 2580 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2581 break; 2581 break;
2582 case IW_ENCODE_ALG_TKIP: 2582 case IW_ENCODE_ALG_TKIP:
2583 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __FUNCTION__, keyIdx, ext->key_len)); 2583 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2584 if (ext->key_len == 32) 2584 if (ext->key_len == 32)
2585 { 2585 {
2586 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) 2586 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
diff --git a/drivers/staging/rt2870/tmp61 b/drivers/staging/rt2870/tmp61
index 992096a248c5..975e44484379 100644
--- a/drivers/staging/rt2870/tmp61
+++ b/drivers/staging/rt2870/tmp61
@@ -2224,7 +2224,7 @@ rt_private_show(struct net_device *dev, struct iw_request_info *info,
2224 wrq->length = strlen(extra) + 1; // 1: size of '\0' 2224 wrq->length = strlen(extra) + 1; // 1: size of '\0'
2225 break; 2225 break;
2226 default: 2226 default:
2227 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __FUNCTION__, subcmd)); 2227 DBGPRINT(RT_DEBUG_TRACE, ("%s - unknow subcmd = %d\n", __func__, subcmd));
2228 break; 2228 break;
2229 } 2229 }
2230 2230
@@ -2243,7 +2243,7 @@ int rt_ioctl_siwmlme(struct net_device *dev,
2243 MLME_DISASSOC_REQ_STRUCT DisAssocReq; 2243 MLME_DISASSOC_REQ_STRUCT DisAssocReq;
2244 MLME_DEAUTH_REQ_STRUCT DeAuthReq; 2244 MLME_DEAUTH_REQ_STRUCT DeAuthReq;
2245 2245
2246 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __FUNCTION__)); 2246 DBGPRINT(RT_DEBUG_TRACE, ("====> %s\n", __func__));
2247 2247
2248 if (pMlme == NULL) 2248 if (pMlme == NULL)
2249 return -EINVAL; 2249 return -EINVAL;
@@ -2252,7 +2252,7 @@ int rt_ioctl_siwmlme(struct net_device *dev,
2252 { 2252 {
2253#ifdef IW_MLME_DEAUTH 2253#ifdef IW_MLME_DEAUTH
2254 case IW_MLME_DEAUTH: 2254 case IW_MLME_DEAUTH:
2255 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __FUNCTION__)); 2255 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DEAUTH\n", __func__));
2256 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid); 2256 COPY_MAC_ADDR(DeAuthReq.Addr, pAd->CommonCfg.Bssid);
2257 DeAuthReq.Reason = pMlme->reason_code; 2257 DeAuthReq.Reason = pMlme->reason_code;
2258 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT); 2258 MsgElem.MsgLen = sizeof(MLME_DEAUTH_REQ_STRUCT);
@@ -2267,7 +2267,7 @@ int rt_ioctl_siwmlme(struct net_device *dev,
2267#endif // IW_MLME_DEAUTH // 2267#endif // IW_MLME_DEAUTH //
2268#ifdef IW_MLME_DISASSOC 2268#ifdef IW_MLME_DISASSOC
2269 case IW_MLME_DISASSOC: 2269 case IW_MLME_DISASSOC:
2270 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __FUNCTION__)); 2270 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - IW_MLME_DISASSOC\n", __func__));
2271 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid); 2271 COPY_MAC_ADDR(DisAssocReq.Addr, pAd->CommonCfg.Bssid);
2272 DisAssocReq.Reason = pMlme->reason_code; 2272 DisAssocReq.Reason = pMlme->reason_code;
2273 2273
@@ -2281,7 +2281,7 @@ int rt_ioctl_siwmlme(struct net_device *dev,
2281 break; 2281 break;
2282#endif // IW_MLME_DISASSOC // 2282#endif // IW_MLME_DISASSOC //
2283 default: 2283 default:
2284 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __FUNCTION__)); 2284 DBGPRINT(RT_DEBUG_TRACE, ("====> %s - Unknow Command\n", __func__));
2285 break; 2285 break;
2286 } 2286 }
2287 2287
@@ -2314,7 +2314,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
2314 else if (param->value == IW_AUTH_WPA_VERSION_WPA2) 2314 else if (param->value == IW_AUTH_WPA_VERSION_WPA2)
2315 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK; 2315 pAdapter->StaCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;
2316 2316
2317 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __FUNCTION__, param->value)); 2317 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2318 break; 2318 break;
2319 case IW_AUTH_CIPHER_PAIRWISE: 2319 case IW_AUTH_CIPHER_PAIRWISE:
2320 if (param->value == IW_AUTH_CIPHER_NONE) 2320 if (param->value == IW_AUTH_CIPHER_NONE)
@@ -2345,7 +2345,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
2345 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus; 2345 pAdapter->StaCfg.OrigWepStatus = pAdapter->StaCfg.WepStatus;
2346 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled; 2346 pAdapter->StaCfg.PairCipher = Ndis802_11Encryption3Enabled;
2347 } 2347 }
2348 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __FUNCTION__, param->value)); 2348 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_PAIRWISE - param->value = %d!\n", __func__, param->value));
2349 break; 2349 break;
2350 case IW_AUTH_CIPHER_GROUP: 2350 case IW_AUTH_CIPHER_GROUP:
2351 if (param->value == IW_AUTH_CIPHER_NONE) 2351 if (param->value == IW_AUTH_CIPHER_NONE)
@@ -2365,7 +2365,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
2365 { 2365 {
2366 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled; 2366 pAdapter->StaCfg.GroupCipher = Ndis802_11Encryption3Enabled;
2367 } 2367 }
2368 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __FUNCTION__, param->value)); 2368 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_CIPHER_GROUP - param->value = %d!\n", __func__, param->value));
2369 break; 2369 break;
2370 case IW_AUTH_KEY_MGMT: 2370 case IW_AUTH_KEY_MGMT:
2371 if (param->value == IW_AUTH_KEY_MGMT_802_1X) 2371 if (param->value == IW_AUTH_KEY_MGMT_802_1X)
@@ -2395,7 +2395,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
2395 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; 2395 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2396 STA_PORT_SECURED(pAdapter); 2396 STA_PORT_SECURED(pAdapter);
2397 } 2397 }
2398 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __FUNCTION__, param->value)); 2398 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_KEY_MGMT - param->value = %d!\n", __func__, param->value));
2399 break; 2399 break;
2400 case IW_AUTH_RX_UNENCRYPTED_EAPOL: 2400 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
2401 break; 2401 break;
@@ -2408,7 +2408,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
2408 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled; 2408 pAdapter->StaCfg.PairCipher = Ndis802_11WEPDisabled;
2409 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled; 2409 pAdapter->StaCfg.GroupCipher = Ndis802_11WEPDisabled;
2410 }*/ 2410 }*/
2411 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __FUNCTION__, param->value)); 2411 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_PRIVACY_INVOKED - param->value = %d!\n", __func__, param->value));
2412 break; 2412 break;
2413 case IW_AUTH_DROP_UNENCRYPTED: 2413 case IW_AUTH_DROP_UNENCRYPTED:
2414 if (param->value != 0) 2414 if (param->value != 0)
@@ -2418,7 +2418,7 @@ int rt_ioctl_siwauth(struct net_device *dev,
2418 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED; 2418 //pAdapter->StaCfg.PortSecured = WPA_802_1X_PORT_SECURED;
2419 STA_PORT_SECURED(pAdapter); 2419 STA_PORT_SECURED(pAdapter);
2420 } 2420 }
2421 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __FUNCTION__, param->value)); 2421 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_VERSION - param->value = %d!\n", __func__, param->value));
2422 break; 2422 break;
2423 case IW_AUTH_80211_AUTH_ALG: 2423 case IW_AUTH_80211_AUTH_ALG:
2424 if (param->value & IW_AUTH_ALG_SHARED_KEY) 2424 if (param->value & IW_AUTH_ALG_SHARED_KEY)
@@ -2431,10 +2431,10 @@ int rt_ioctl_siwauth(struct net_device *dev,
2431 } 2431 }
2432 else 2432 else
2433 return -EINVAL; 2433 return -EINVAL;
2434 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __FUNCTION__, param->value)); 2434 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_80211_AUTH_ALG - param->value = %d!\n", __func__, param->value));
2435 break; 2435 break;
2436 case IW_AUTH_WPA_ENABLED: 2436 case IW_AUTH_WPA_ENABLED:
2437 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __FUNCTION__, param->value)); 2437 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_AUTH_WPA_ENABLED - Driver supports WPA!(param->value = %d)\n", __func__, param->value));
2438 break; 2438 break;
2439 default: 2439 default:
2440 return -EOPNOTSUPP; 2440 return -EOPNOTSUPP;
@@ -2542,7 +2542,7 @@ int rt_ioctl_siwencodeext(struct net_device *dev,
2542 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE; 2542 pAdapter->SharedKey[BSS0][keyIdx].CipherAlg = CIPHER_NONE;
2543 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx); 2543 AsicRemoveSharedKeyEntry(pAdapter, 0, (UCHAR)keyIdx);
2544 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY)); 2544 NdisZeroMemory(&pAdapter->SharedKey[BSS0][keyIdx], sizeof(CIPHER_KEY));
2545 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __FUNCTION__, encoding->flags)); 2545 DBGPRINT(RT_DEBUG_TRACE, ("%s::Remove all keys!(encoding->flags = %x)\n", __func__, encoding->flags));
2546 } 2546 }
2547 else 2547 else
2548 { 2548 {
@@ -2554,15 +2554,15 @@ int rt_ioctl_siwencodeext(struct net_device *dev,
2554 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) 2554 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
2555 { 2555 {
2556 pAdapter->StaCfg.DefaultKeyId = keyIdx; 2556 pAdapter->StaCfg.DefaultKeyId = keyIdx;
2557 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __FUNCTION__, pAdapter->StaCfg.DefaultKeyId)); 2557 DBGPRINT(RT_DEBUG_TRACE, ("%s::DefaultKeyId = %d\n", __func__, pAdapter->StaCfg.DefaultKeyId));
2558 } 2558 }
2559 2559
2560 switch (alg) { 2560 switch (alg) {
2561 case IW_ENCODE_ALG_NONE: 2561 case IW_ENCODE_ALG_NONE:
2562 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __FUNCTION__)); 2562 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_NONE\n", __func__));
2563 break; 2563 break;
2564 case IW_ENCODE_ALG_WEP: 2564 case IW_ENCODE_ALG_WEP:
2565 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __FUNCTION__, ext->key_len, keyIdx)); 2565 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_WEP - ext->key_len = %d, keyIdx = %d\n", __func__, ext->key_len, keyIdx));
2566 if (ext->key_len == MAX_WEP_KEY_SIZE) 2566 if (ext->key_len == MAX_WEP_KEY_SIZE)
2567 { 2567 {
2568 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE; 2568 pAdapter->SharedKey[BSS0][keyIdx].KeyLen = MAX_WEP_KEY_SIZE;
@@ -2580,7 +2580,7 @@ int rt_ioctl_siwencodeext(struct net_device *dev,
2580 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len); 2580 NdisMoveMemory(pAdapter->SharedKey[BSS0][keyIdx].Key, ext->key, ext->key_len);
2581 break; 2581 break;
2582 case IW_ENCODE_ALG_TKIP: 2582 case IW_ENCODE_ALG_TKIP:
2583 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __FUNCTION__, keyIdx, ext->key_len)); 2583 DBGPRINT(RT_DEBUG_TRACE, ("%s::IW_ENCODE_ALG_TKIP - keyIdx = %d, ext->key_len = %d\n", __func__, keyIdx, ext->key_len));
2584 if (ext->key_len == 32) 2584 if (ext->key_len == 32)
2585 { 2585 {
2586 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) 2586 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
diff --git a/drivers/staging/rtl8187se/ieee80211.h b/drivers/staging/rtl8187se/ieee80211.h
index bf06abeeaeb8..58336080ad50 100644
--- a/drivers/staging/rtl8187se/ieee80211.h
+++ b/drivers/staging/rtl8187se/ieee80211.h
@@ -396,7 +396,7 @@ extern u32 ieee80211_debug_level;
396#define IEEE80211_DEBUG(level, fmt, args...) \ 396#define IEEE80211_DEBUG(level, fmt, args...) \
397do { if (ieee80211_debug_level & (level)) \ 397do { if (ieee80211_debug_level & (level)) \
398 printk(KERN_DEBUG "ieee80211: %c %s " fmt, \ 398 printk(KERN_DEBUG "ieee80211: %c %s " fmt, \
399 in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0) 399 in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0)
400#else 400#else
401#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0) 401#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0)
402#endif /* CONFIG_IEEE80211_DEBUG */ 402#endif /* CONFIG_IEEE80211_DEBUG */
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211.h b/drivers/staging/rtl8187se/ieee80211/ieee80211.h
index bf06abeeaeb8..58336080ad50 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211.h
@@ -396,7 +396,7 @@ extern u32 ieee80211_debug_level;
396#define IEEE80211_DEBUG(level, fmt, args...) \ 396#define IEEE80211_DEBUG(level, fmt, args...) \
397do { if (ieee80211_debug_level & (level)) \ 397do { if (ieee80211_debug_level & (level)) \
398 printk(KERN_DEBUG "ieee80211: %c %s " fmt, \ 398 printk(KERN_DEBUG "ieee80211: %c %s " fmt, \
399 in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0) 399 in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0)
400#else 400#else
401#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0) 401#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0)
402#endif /* CONFIG_IEEE80211_DEBUG */ 402#endif /* CONFIG_IEEE80211_DEBUG */
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c
index 7d890c328b0e..08add385790f 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c
@@ -490,7 +490,7 @@ static char * ieee80211_ccmp_print_stats(char *p, void *priv)
490 490
491void ieee80211_ccmp_null(void) 491void ieee80211_ccmp_null(void)
492{ 492{
493// printk("============>%s()\n", __FUNCTION__); 493// printk("============>%s()\n", __func__);
494 return; 494 return;
495} 495}
496static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = { 496static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = {
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c
index e560b1e11020..de97bbec0da5 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c
@@ -984,7 +984,7 @@ void ieee80211_crypto_tkip_exit(void)
984 984
985void ieee80211_tkip_null(void) 985void ieee80211_tkip_null(void)
986{ 986{
987// printk("============>%s()\n", __FUNCTION__); 987// printk("============>%s()\n", __func__);
988 return; 988 return;
989} 989}
990 990
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c
index f973daeeeb0f..68a22b32fcf0 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c
@@ -380,7 +380,7 @@ void ieee80211_crypto_wep_exit(void)
380 380
381void ieee80211_wep_null(void) 381void ieee80211_wep_null(void)
382{ 382{
383// printk("============>%s()\n", __FUNCTION__); 383// printk("============>%s()\n", __func__);
384 return; 384 return;
385} 385}
386#if 0 386#if 0
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c
index 79ec64959cf6..23519b37538f 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c
@@ -1635,7 +1635,7 @@ inline void update_network(struct ieee80211_network *dst,
1635 memcpy(dst->rates_ex, src->rates_ex, src->rates_ex_len); 1635 memcpy(dst->rates_ex, src->rates_ex, src->rates_ex_len);
1636 dst->rates_ex_len = src->rates_ex_len; 1636 dst->rates_ex_len = src->rates_ex_len;
1637 dst->HighestOperaRate= src->HighestOperaRate; 1637 dst->HighestOperaRate= src->HighestOperaRate;
1638 //printk("==========>in %s: src->ssid is %s,chan is %d\n",__FUNCTION__,src->ssid,src->channel); 1638 //printk("==========>in %s: src->ssid is %s,chan is %d\n",__func__,src->ssid,src->channel);
1639 1639
1640 //YJ,add,080819,for hidden ap 1640 //YJ,add,080819,for hidden ap
1641 if(src->ssid_len > 0) 1641 if(src->ssid_len > 0)
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
index fcffee516d51..e5752f615e09 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
@@ -731,7 +731,7 @@ void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee)
731 memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1); 731 memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1);
732#endif 732#endif
733// printk("ieee80211_softmac_scan_wq ENABLE_IPS\n"); 733// printk("ieee80211_softmac_scan_wq ENABLE_IPS\n");
734// printk("in %s\n",__FUNCTION__); 734// printk("in %s\n",__func__);
735 down(&ieee->scan_sem); 735 down(&ieee->scan_sem);
736 736
737 do{ 737 do{
@@ -1785,7 +1785,7 @@ void ieee80211_associate_step1(struct ieee80211_device *ieee)
1785 //If call dev_kfree_skb_any,a warning will ocur.... 1785 //If call dev_kfree_skb_any,a warning will ocur....
1786 //KERNEL: assertion (!atomic_read(&skb->users)) failed at net/core/dev.c (1708) 1786 //KERNEL: assertion (!atomic_read(&skb->users)) failed at net/core/dev.c (1708)
1787 //So ... 1204 by lawrence. 1787 //So ... 1204 by lawrence.
1788 //printk("\nIn %s,line %d call kfree skb.",__FUNCTION__,__LINE__); 1788 //printk("\nIn %s,line %d call kfree skb.",__func__,__LINE__);
1789 //dev_kfree_skb_any(skb);//edit by thomas 1789 //dev_kfree_skb_any(skb);//edit by thomas
1790 } 1790 }
1791} 1791}
@@ -2432,7 +2432,7 @@ inline void ieee80211_sta_ps(struct ieee80211_device *ieee)
2432 } 2432 }
2433 2433
2434 sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl); 2434 sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl);
2435// printk("===>%s,%d[2 wake, 1 sleep, 0 do nothing], ieee->sta_sleep = %d\n",__FUNCTION__, sleep,ieee->sta_sleep); 2435// printk("===>%s,%d[2 wake, 1 sleep, 0 do nothing], ieee->sta_sleep = %d\n",__func__, sleep,ieee->sta_sleep);
2436 /* 2 wake, 1 sleep, 0 do nothing */ 2436 /* 2 wake, 1 sleep, 0 do nothing */
2437 if(sleep == 0) 2437 if(sleep == 0)
2438 goto out; 2438 goto out;
@@ -2510,7 +2510,7 @@ void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success)
2510 /* Null frame with PS bit set */ 2510 /* Null frame with PS bit set */
2511 if(success){ 2511 if(success){
2512 2512
2513 // printk("==================> %s::enter sleep state\n",__FUNCTION__); 2513 // printk("==================> %s::enter sleep state\n",__func__);
2514 ieee->sta_sleep = 1; 2514 ieee->sta_sleep = 1;
2515 ieee->enter_sleep_state(ieee->dev,ieee->ps_th,ieee->ps_tl); 2515 ieee->enter_sleep_state(ieee->dev,ieee->ps_th,ieee->ps_tl);
2516 } 2516 }
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c
index 43b8aecee9de..93af37e2d31a 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c
@@ -31,7 +31,7 @@ int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info
31{ 31{
32 int ret; 32 int ret;
33 struct iw_freq *fwrq = & wrqu->freq; 33 struct iw_freq *fwrq = & wrqu->freq;
34// printk("in %s\n",__FUNCTION__); 34// printk("in %s\n",__func__);
35 down(&ieee->wx_sem); 35 down(&ieee->wx_sem);
36 36
37 if(ieee->iw_mode == IW_MODE_INFRA){ 37 if(ieee->iw_mode == IW_MODE_INFRA){
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c
index c7d9f4fda413..6aad61e78041 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c
@@ -663,7 +663,7 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
663 ret = -EINVAL; 663 ret = -EINVAL;
664 goto done; 664 goto done;
665 } 665 }
666// printk("8-09-08-9=====>%s, alg name:%s\n",__FUNCTION__, alg); 666// printk("8-09-08-9=====>%s, alg name:%s\n",__func__, alg);
667 667
668 ops = ieee80211_get_crypto_ops(alg); 668 ops = ieee80211_get_crypto_ops(alg);
669 if (ops == NULL) { 669 if (ops == NULL) {
@@ -757,7 +757,7 @@ int ieee80211_wx_set_mlme(struct ieee80211_device *ieee,
757 union iwreq_data *wrqu, char *extra) 757 union iwreq_data *wrqu, char *extra)
758{ 758{
759 struct iw_mlme *mlme = (struct iw_mlme *) extra; 759 struct iw_mlme *mlme = (struct iw_mlme *) extra;
760// printk("\ndkgadfslkdjgalskdf===============>%s(), cmd:%x\n", __FUNCTION__, mlme->cmd); 760// printk("\ndkgadfslkdjgalskdf===============>%s(), cmd:%x\n", __func__, mlme->cmd);
761#if 1 761#if 1
762 switch (mlme->cmd) { 762 switch (mlme->cmd) {
763 case IW_MLME_DEAUTH: 763 case IW_MLME_DEAUTH:
@@ -830,7 +830,7 @@ int ieee80211_wx_set_auth(struct ieee80211_device *ieee,
830int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len) 830int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len)
831{ 831{
832#if 0 832#if 0
833 printk("====>%s()\n", __FUNCTION__); 833 printk("====>%s()\n", __func__);
834 { 834 {
835 int i; 835 int i;
836 for (i=0; i<len; i++) 836 for (i=0; i<len; i++)
@@ -866,7 +866,7 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len)
866 ieee->wpa_ie = NULL; 866 ieee->wpa_ie = NULL;
867 ieee->wpa_ie_len = 0; 867 ieee->wpa_ie_len = 0;
868 } 868 }
869// printk("<=====out %s()\n", __FUNCTION__); 869// printk("<=====out %s()\n", __func__);
870 870
871 return 0; 871 return 0;
872 872
diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c
index 00f4df49bc0e..94534955e38b 100644
--- a/drivers/staging/rtl8187se/r8180_core.c
+++ b/drivers/staging/rtl8187se/r8180_core.c
@@ -1407,12 +1407,12 @@ void rtl8180_set_chan(struct net_device *dev,short ch)
1407 1407
1408 if((ch > 14) || (ch < 1)) 1408 if((ch > 14) || (ch < 1))
1409 { 1409 {
1410 printk("In %s: Invalid chnanel %d\n", __FUNCTION__, ch); 1410 printk("In %s: Invalid chnanel %d\n", __func__, ch);
1411 return; 1411 return;
1412 } 1412 }
1413 1413
1414 priv->chan=ch; 1414 priv->chan=ch;
1415 //printk("in %s:channel is %d\n",__FUNCTION__,ch); 1415 //printk("in %s:channel is %d\n",__func__,ch);
1416 priv->rf_set_chan(dev,priv->chan); 1416 priv->rf_set_chan(dev,priv->chan);
1417 1417
1418} 1418}
@@ -3656,7 +3656,7 @@ void rtl8180_link_change(struct net_device *dev)
3656void rtl8180_rq_tx_ack(struct net_device *dev){ 3656void rtl8180_rq_tx_ack(struct net_device *dev){
3657 3657
3658 struct r8180_priv *priv = ieee80211_priv(dev); 3658 struct r8180_priv *priv = ieee80211_priv(dev);
3659// printk("====================>%s\n",__FUNCTION__); 3659// printk("====================>%s\n",__func__);
3660 write_nic_byte(dev,CONFIG4,read_nic_byte(dev,CONFIG4)|CONFIG4_PWRMGT); 3660 write_nic_byte(dev,CONFIG4,read_nic_byte(dev,CONFIG4)|CONFIG4_PWRMGT);
3661 priv->ack_tx_to_ieee = 1; 3661 priv->ack_tx_to_ieee = 1;
3662} 3662}
@@ -5448,7 +5448,7 @@ void rtl8180_hw_wakeup_wq(struct net_device *dev)
5448#endif 5448#endif
5449 5449
5450// printk("dev is %d\n",dev); 5450// printk("dev is %d\n",dev);
5451// printk("&*&(^*(&(&=========>%s()\n", __FUNCTION__); 5451// printk("&*&(^*(&(&=========>%s()\n", __func__);
5452 rtl8180_hw_wakeup(dev); 5452 rtl8180_hw_wakeup(dev);
5453 5453
5454} 5454}
@@ -6318,12 +6318,12 @@ priv->txnpring)/8);
6318// printk("NumTxOkTotal is %d\n",priv->NumTxOkTotal++); 6318// printk("NumTxOkTotal is %d\n",priv->NumTxOkTotal++);
6319 } 6319 }
6320#endif 6320#endif
6321 // printk("in function %s:curr_retry_count is %d\n",__FUNCTION__,((*head) & (0x000000ff))); 6321 // printk("in function %s:curr_retry_count is %d\n",__func__,((*head) & (0x000000ff)));
6322 } 6322 }
6323 if(!error){ 6323 if(!error){
6324 priv->NumTxOkBytesTotal += (*(head+3)) & (0x00000fff); 6324 priv->NumTxOkBytesTotal += (*(head+3)) & (0x00000fff);
6325 } 6325 }
6326// printk("in function %s:curr_txokbyte_count is %d\n",__FUNCTION__,(*(head+3)) & (0x00000fff)); 6326// printk("in function %s:curr_txokbyte_count is %d\n",__func__,(*(head+3)) & (0x00000fff));
6327 *head = *head &~ (1<<31); 6327 *head = *head &~ (1<<31);
6328 6328
6329 if((head - begin)/8 == priv->txringcount-1) 6329 if((head - begin)/8 == priv->txringcount-1)
diff --git a/drivers/staging/rtl8187se/r8180_rtl8225z2.c b/drivers/staging/rtl8187se/r8180_rtl8225z2.c
index 90a574d46da0..4136b9429597 100644
--- a/drivers/staging/rtl8187se/r8180_rtl8225z2.c
+++ b/drivers/staging/rtl8187se/r8180_rtl8225z2.c
@@ -1571,7 +1571,7 @@ void rtl8225z4_rf_sleep(struct net_device *dev)
1571 // 1571 //
1572 // Turn off RF power. 1572 // Turn off RF power.
1573 // 1573 //
1574 //printk("=========>%s()\n", __FUNCTION__); 1574 //printk("=========>%s()\n", __func__);
1575 MgntActSet_RF_State(dev, eRfSleep, RF_CHANGE_BY_PS); 1575 MgntActSet_RF_State(dev, eRfSleep, RF_CHANGE_BY_PS);
1576 //mdelay(2); //FIXME 1576 //mdelay(2); //FIXME
1577} 1577}
@@ -1580,7 +1580,7 @@ void rtl8225z4_rf_wakeup(struct net_device *dev)
1580 // 1580 //
1581 // Turn on RF power. 1581 // Turn on RF power.
1582 // 1582 //
1583 //printk("=========>%s()\n", __FUNCTION__); 1583 //printk("=========>%s()\n", __func__);
1584 MgntActSet_RF_State(dev, eRfOn, RF_CHANGE_BY_PS); 1584 MgntActSet_RF_State(dev, eRfOn, RF_CHANGE_BY_PS);
1585} 1585}
1586#endif 1586#endif
diff --git a/drivers/staging/rtl8187se/r8180_wx.c b/drivers/staging/rtl8187se/r8180_wx.c
index c77abe502b79..8b3901d87f87 100644
--- a/drivers/staging/rtl8187se/r8180_wx.c
+++ b/drivers/staging/rtl8187se/r8180_wx.c
@@ -1177,7 +1177,7 @@ static int r8180_wx_set_channelplan(struct net_device *dev,
1177 //struct ieee80211_device *ieee = netdev_priv(dev); 1177 //struct ieee80211_device *ieee = netdev_priv(dev);
1178 int *val = (int *)extra; 1178 int *val = (int *)extra;
1179 int i; 1179 int i;
1180 printk("-----in fun %s\n", __FUNCTION__); 1180 printk("-----in fun %s\n", __func__);
1181 1181
1182 if(priv->ieee80211->bHwRadioOff) 1182 if(priv->ieee80211->bHwRadioOff)
1183 return 0; 1183 return 0;
@@ -1235,7 +1235,7 @@ static int r8180_wx_set_forcerate(struct net_device *dev,
1235 1235
1236 down(&priv->wx_sem); 1236 down(&priv->wx_sem);
1237 1237
1238 printk("==============>%s(): forcerate is %d\n",__FUNCTION__,forcerate); 1238 printk("==============>%s(): forcerate is %d\n",__func__,forcerate);
1239 if((forcerate == 2) || (forcerate == 4) || (forcerate == 11) || (forcerate == 22) || (forcerate == 12) || 1239 if((forcerate == 2) || (forcerate == 4) || (forcerate == 11) || (forcerate == 22) || (forcerate == 12) ||
1240 (forcerate == 18) || (forcerate == 24) || (forcerate == 36) || (forcerate == 48) || (forcerate == 72) || 1240 (forcerate == 18) || (forcerate == 24) || (forcerate == 36) || (forcerate == 48) || (forcerate == 72) ||
1241 (forcerate == 96) || (forcerate == 108)) 1241 (forcerate == 96) || (forcerate == 108))
@@ -1260,7 +1260,7 @@ static int r8180_wx_set_enc_ext(struct net_device *dev,
1260{ 1260{
1261 1261
1262 struct r8180_priv *priv = ieee80211_priv(dev); 1262 struct r8180_priv *priv = ieee80211_priv(dev);
1263 //printk("===>%s()\n", __FUNCTION__); 1263 //printk("===>%s()\n", __func__);
1264 1264
1265 int ret=0; 1265 int ret=0;
1266 1266
@@ -1277,7 +1277,7 @@ static int r8180_wx_set_auth(struct net_device *dev,
1277 struct iw_request_info *info, 1277 struct iw_request_info *info,
1278 struct iw_param *data, char *extra) 1278 struct iw_param *data, char *extra)
1279{ 1279{
1280 //printk("====>%s()\n", __FUNCTION__); 1280 //printk("====>%s()\n", __func__);
1281 struct r8180_priv *priv = ieee80211_priv(dev); 1281 struct r8180_priv *priv = ieee80211_priv(dev);
1282 int ret=0; 1282 int ret=0;
1283 1283
@@ -1294,7 +1294,7 @@ static int r8180_wx_set_mlme(struct net_device *dev,
1294 struct iw_request_info *info, 1294 struct iw_request_info *info,
1295 union iwreq_data *wrqu, char *extra) 1295 union iwreq_data *wrqu, char *extra)
1296{ 1296{
1297 //printk("====>%s()\n", __FUNCTION__); 1297 //printk("====>%s()\n", __func__);
1298 1298
1299 int ret=0; 1299 int ret=0;
1300 struct r8180_priv *priv = ieee80211_priv(dev); 1300 struct r8180_priv *priv = ieee80211_priv(dev);
@@ -1315,7 +1315,7 @@ static int r8180_wx_set_gen_ie(struct net_device *dev,
1315 struct iw_request_info *info, 1315 struct iw_request_info *info,
1316 struct iw_point *data, char *extra) 1316 struct iw_point *data, char *extra)
1317{ 1317{
1318// printk("====>%s(), len:%d\n", __FUNCTION__, data->length); 1318// printk("====>%s(), len:%d\n", __func__, data->length);
1319 int ret=0; 1319 int ret=0;
1320 struct r8180_priv *priv = ieee80211_priv(dev); 1320 struct r8180_priv *priv = ieee80211_priv(dev);
1321 1321
@@ -1328,7 +1328,7 @@ static int r8180_wx_set_gen_ie(struct net_device *dev,
1328 ret = ieee80211_wx_set_gen_ie(priv->ieee80211, extra, data->length); 1328 ret = ieee80211_wx_set_gen_ie(priv->ieee80211, extra, data->length);
1329#endif 1329#endif
1330 up(&priv->wx_sem); 1330 up(&priv->wx_sem);
1331 //printk("<======%s(), ret:%d\n", __FUNCTION__, ret); 1331 //printk("<======%s(), ret:%d\n", __func__, ret);
1332 return ret; 1332 return ret;
1333 1333
1334 1334
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index 289d81adfb9c..83babb0a1df7 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -150,4 +150,6 @@ source "drivers/usb/atm/Kconfig"
150 150
151source "drivers/usb/gadget/Kconfig" 151source "drivers/usb/gadget/Kconfig"
152 152
153source "drivers/usb/otg/Kconfig"
154
153endif # USB_SUPPORT 155endif # USB_SUPPORT
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index d50a99f70aee..00b47ea24f86 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1275,7 +1275,7 @@ static int acm_suspend(struct usb_interface *intf, pm_message_t message)
1275 struct acm *acm = usb_get_intfdata(intf); 1275 struct acm *acm = usb_get_intfdata(intf);
1276 int cnt; 1276 int cnt;
1277 1277
1278 if (acm->dev->auto_pm) { 1278 if (message.event & PM_EVENT_AUTO) {
1279 int b; 1279 int b;
1280 1280
1281 spin_lock_irq(&acm->read_lock); 1281 spin_lock_irq(&acm->read_lock);
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 5a8ecc045e3f..3771d6e6d0cc 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -764,7 +764,8 @@ static int wdm_suspend(struct usb_interface *intf, pm_message_t message)
764 764
765 mutex_lock(&desc->plock); 765 mutex_lock(&desc->plock);
766#ifdef CONFIG_PM 766#ifdef CONFIG_PM
767 if (interface_to_usbdev(desc->intf)->auto_pm && test_bit(WDM_IN_USE, &desc->flags)) { 767 if ((message.event & PM_EVENT_AUTO) &&
768 test_bit(WDM_IN_USE, &desc->flags)) {
768 rv = -EBUSY; 769 rv = -EBUSY;
769 } else { 770 } else {
770#endif 771#endif
diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index 43a863c5cc43..0f5c05f6f9df 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -21,6 +21,7 @@
21 21
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/kernel.h>
24#include <linux/fs.h> 25#include <linux/fs.h>
25#include <linux/uaccess.h> 26#include <linux/uaccess.h>
26#include <linux/kref.h> 27#include <linux/kref.h>
@@ -482,7 +483,6 @@ static ssize_t usbtmc_write(struct file *filp, const char __user *buf,
482 int retval; 483 int retval;
483 int actual; 484 int actual;
484 unsigned long int n_bytes; 485 unsigned long int n_bytes;
485 int n;
486 int remaining; 486 int remaining;
487 int done; 487 int done;
488 int this_part; 488 int this_part;
@@ -526,11 +526,8 @@ static ssize_t usbtmc_write(struct file *filp, const char __user *buf,
526 goto exit; 526 goto exit;
527 } 527 }
528 528
529 n_bytes = 12 + this_part; 529 n_bytes = roundup(12 + this_part, 4);
530 if (this_part % 4) 530 memset(buffer + 12 + this_part, 0, n_bytes - (12 + this_part));
531 n_bytes += 4 - this_part % 4;
532 for (n = 12 + this_part; n < n_bytes; n++)
533 buffer[n] = 0;
534 531
535 retval = usb_bulk_msg(data->usb_dev, 532 retval = usb_bulk_msg(data->usb_dev,
536 usb_sndbulkpipe(data->usb_dev, 533 usb_sndbulkpipe(data->usb_dev,
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index aa79280df15d..26fece124e0e 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -981,9 +981,6 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
981 return -EINVAL; 981 return -EINVAL;
982 if (!uurb->buffer) 982 if (!uurb->buffer)
983 return -EINVAL; 983 return -EINVAL;
984 if (uurb->signr != 0 && (uurb->signr < SIGRTMIN ||
985 uurb->signr > SIGRTMAX))
986 return -EINVAL;
987 if (!(uurb->type == USBDEVFS_URB_TYPE_CONTROL && 984 if (!(uurb->type == USBDEVFS_URB_TYPE_CONTROL &&
988 (uurb->endpoint & ~USB_ENDPOINT_DIR_MASK) == 0)) { 985 (uurb->endpoint & ~USB_ENDPOINT_DIR_MASK) == 0)) {
989 ifnum = findintfep(ps->dev, uurb->endpoint); 986 ifnum = findintfep(ps->dev, uurb->endpoint);
@@ -1320,7 +1317,7 @@ static int get_urb32(struct usbdevfs_urb *kurb,
1320 if (__get_user(uptr, &uurb->buffer)) 1317 if (__get_user(uptr, &uurb->buffer))
1321 return -EFAULT; 1318 return -EFAULT;
1322 kurb->buffer = compat_ptr(uptr); 1319 kurb->buffer = compat_ptr(uptr);
1323 if (__get_user(uptr, &uurb->buffer)) 1320 if (__get_user(uptr, &uurb->usercontext))
1324 return -EFAULT; 1321 return -EFAULT;
1325 kurb->usercontext = compat_ptr(uptr); 1322 kurb->usercontext = compat_ptr(uptr);
1326 1323
@@ -1401,8 +1398,6 @@ static int proc_disconnectsignal(struct dev_state *ps, void __user *arg)
1401 1398
1402 if (copy_from_user(&ds, arg, sizeof(ds))) 1399 if (copy_from_user(&ds, arg, sizeof(ds)))
1403 return -EFAULT; 1400 return -EFAULT;
1404 if (ds.signr != 0 && (ds.signr < SIGRTMIN || ds.signr > SIGRTMAX))
1405 return -EINVAL;
1406 ps->discsignr = ds.signr; 1401 ps->discsignr = ds.signr;
1407 ps->disccontext = ds.context; 1402 ps->disccontext = ds.context;
1408 return 0; 1403 return 0;
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 8c081308b0e2..98760553bc95 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -184,6 +184,20 @@ static int usb_unbind_device(struct device *dev)
184 return 0; 184 return 0;
185} 185}
186 186
187/*
188 * Cancel any pending scheduled resets
189 *
190 * [see usb_queue_reset_device()]
191 *
192 * Called after unconfiguring / when releasing interfaces. See
193 * comments in __usb_queue_reset_device() regarding
194 * udev->reset_running.
195 */
196static void usb_cancel_queued_reset(struct usb_interface *iface)
197{
198 if (iface->reset_running == 0)
199 cancel_work_sync(&iface->reset_ws);
200}
187 201
188/* called from driver core with dev locked */ 202/* called from driver core with dev locked */
189static int usb_probe_interface(struct device *dev) 203static int usb_probe_interface(struct device *dev)
@@ -242,6 +256,7 @@ static int usb_probe_interface(struct device *dev)
242 mark_quiesced(intf); 256 mark_quiesced(intf);
243 intf->needs_remote_wakeup = 0; 257 intf->needs_remote_wakeup = 0;
244 intf->condition = USB_INTERFACE_UNBOUND; 258 intf->condition = USB_INTERFACE_UNBOUND;
259 usb_cancel_queued_reset(intf);
245 } else 260 } else
246 intf->condition = USB_INTERFACE_BOUND; 261 intf->condition = USB_INTERFACE_BOUND;
247 262
@@ -272,6 +287,7 @@ static int usb_unbind_interface(struct device *dev)
272 usb_disable_interface(udev, intf); 287 usb_disable_interface(udev, intf);
273 288
274 driver->disconnect(intf); 289 driver->disconnect(intf);
290 usb_cancel_queued_reset(intf);
275 291
276 /* Reset other interface state. 292 /* Reset other interface state.
277 * We cannot do a Set-Interface if the device is suspended or 293 * We cannot do a Set-Interface if the device is suspended or
@@ -279,9 +295,12 @@ static int usb_unbind_interface(struct device *dev)
279 * altsetting means creating new endpoint device entries). 295 * altsetting means creating new endpoint device entries).
280 * When either of these happens, defer the Set-Interface. 296 * When either of these happens, defer the Set-Interface.
281 */ 297 */
282 if (intf->cur_altsetting->desc.bAlternateSetting == 0) 298 if (intf->cur_altsetting->desc.bAlternateSetting == 0) {
283 ; /* Already in altsetting 0 so skip Set-Interface */ 299 /* Already in altsetting 0 so skip Set-Interface.
284 else if (!error && intf->dev.power.status == DPM_ON) 300 * Just re-enable it without affecting the endpoint toggles.
301 */
302 usb_enable_interface(udev, intf, false);
303 } else if (!error && intf->dev.power.status == DPM_ON)
285 usb_set_interface(udev, intf->altsetting[0]. 304 usb_set_interface(udev, intf->altsetting[0].
286 desc.bInterfaceNumber, 0); 305 desc.bInterfaceNumber, 0);
287 else 306 else
@@ -380,8 +399,10 @@ void usb_driver_release_interface(struct usb_driver *driver,
380 if (device_is_registered(dev)) { 399 if (device_is_registered(dev)) {
381 iface->condition = USB_INTERFACE_UNBINDING; 400 iface->condition = USB_INTERFACE_UNBINDING;
382 device_release_driver(dev); 401 device_release_driver(dev);
402 } else {
403 iface->condition = USB_INTERFACE_UNBOUND;
404 usb_cancel_queued_reset(iface);
383 } 405 }
384
385 dev->driver = NULL; 406 dev->driver = NULL;
386 usb_set_intfdata(iface, NULL); 407 usb_set_intfdata(iface, NULL);
387 408
@@ -904,7 +925,7 @@ static int usb_suspend_device(struct usb_device *udev, pm_message_t msg)
904} 925}
905 926
906/* Caller has locked udev's pm_mutex */ 927/* Caller has locked udev's pm_mutex */
907static int usb_resume_device(struct usb_device *udev) 928static int usb_resume_device(struct usb_device *udev, pm_message_t msg)
908{ 929{
909 struct usb_device_driver *udriver; 930 struct usb_device_driver *udriver;
910 int status = 0; 931 int status = 0;
@@ -922,7 +943,7 @@ static int usb_resume_device(struct usb_device *udev)
922 udev->reset_resume = 1; 943 udev->reset_resume = 1;
923 944
924 udriver = to_usb_device_driver(udev->dev.driver); 945 udriver = to_usb_device_driver(udev->dev.driver);
925 status = udriver->resume(udev); 946 status = udriver->resume(udev, msg);
926 947
927 done: 948 done:
928 dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status); 949 dev_vdbg(&udev->dev, "%s: status %d\n", __func__, status);
@@ -942,7 +963,8 @@ static int usb_suspend_interface(struct usb_device *udev,
942 if (udev->state == USB_STATE_NOTATTACHED || !is_active(intf)) 963 if (udev->state == USB_STATE_NOTATTACHED || !is_active(intf))
943 goto done; 964 goto done;
944 965
945 if (intf->condition == USB_INTERFACE_UNBOUND) /* This can't happen */ 966 /* This can happen; see usb_driver_release_interface() */
967 if (intf->condition == USB_INTERFACE_UNBOUND)
946 goto done; 968 goto done;
947 driver = to_usb_driver(intf->dev.driver); 969 driver = to_usb_driver(intf->dev.driver);
948 970
@@ -950,7 +972,7 @@ static int usb_suspend_interface(struct usb_device *udev,
950 status = driver->suspend(intf, msg); 972 status = driver->suspend(intf, msg);
951 if (status == 0) 973 if (status == 0)
952 mark_quiesced(intf); 974 mark_quiesced(intf);
953 else if (!udev->auto_pm) 975 else if (!(msg.event & PM_EVENT_AUTO))
954 dev_err(&intf->dev, "%s error %d\n", 976 dev_err(&intf->dev, "%s error %d\n",
955 "suspend", status); 977 "suspend", status);
956 } else { 978 } else {
@@ -968,7 +990,7 @@ static int usb_suspend_interface(struct usb_device *udev,
968 990
969/* Caller has locked intf's usb_device's pm_mutex */ 991/* Caller has locked intf's usb_device's pm_mutex */
970static int usb_resume_interface(struct usb_device *udev, 992static int usb_resume_interface(struct usb_device *udev,
971 struct usb_interface *intf, int reset_resume) 993 struct usb_interface *intf, pm_message_t msg, int reset_resume)
972{ 994{
973 struct usb_driver *driver; 995 struct usb_driver *driver;
974 int status = 0; 996 int status = 0;
@@ -1092,7 +1114,7 @@ static int autosuspend_check(struct usb_device *udev, int reschedule)
1092 if (reschedule) { 1114 if (reschedule) {
1093 if (!timer_pending(&udev->autosuspend.timer)) { 1115 if (!timer_pending(&udev->autosuspend.timer)) {
1094 queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend, 1116 queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend,
1095 round_jiffies_relative(suspend_time - j)); 1117 round_jiffies_up_relative(suspend_time - j));
1096 } 1118 }
1097 return -EAGAIN; 1119 return -EAGAIN;
1098 } 1120 }
@@ -1119,10 +1141,9 @@ static inline int autosuspend_check(struct usb_device *udev, int reschedule)
1119 * all the interfaces which were suspended are resumed so that they remain 1141 * all the interfaces which were suspended are resumed so that they remain
1120 * in the same state as the device. 1142 * in the same state as the device.
1121 * 1143 *
1122 * If an autosuspend is in progress (@udev->auto_pm is set), the routine 1144 * If an autosuspend is in progress the routine checks first to make sure
1123 * checks first to make sure that neither the device itself or any of its 1145 * that neither the device itself or any of its active interfaces is in use
1124 * active interfaces is in use (pm_usage_cnt is greater than 0). If they 1146 * (pm_usage_cnt is greater than 0). If they are, the autosuspend fails.
1125 * are, the autosuspend fails.
1126 * 1147 *
1127 * If the suspend succeeds, the routine recursively queues an autosuspend 1148 * If the suspend succeeds, the routine recursively queues an autosuspend
1128 * request for @udev's parent device, thereby propagating the change up 1149 * request for @udev's parent device, thereby propagating the change up
@@ -1157,7 +1178,7 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
1157 1178
1158 udev->do_remote_wakeup = device_may_wakeup(&udev->dev); 1179 udev->do_remote_wakeup = device_may_wakeup(&udev->dev);
1159 1180
1160 if (udev->auto_pm) { 1181 if (msg.event & PM_EVENT_AUTO) {
1161 status = autosuspend_check(udev, 0); 1182 status = autosuspend_check(udev, 0);
1162 if (status < 0) 1183 if (status < 0)
1163 goto done; 1184 goto done;
@@ -1177,13 +1198,16 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
1177 1198
1178 /* If the suspend failed, resume interfaces that did get suspended */ 1199 /* If the suspend failed, resume interfaces that did get suspended */
1179 if (status != 0) { 1200 if (status != 0) {
1201 pm_message_t msg2;
1202
1203 msg2.event = msg.event ^ (PM_EVENT_SUSPEND | PM_EVENT_RESUME);
1180 while (--i >= 0) { 1204 while (--i >= 0) {
1181 intf = udev->actconfig->interface[i]; 1205 intf = udev->actconfig->interface[i];
1182 usb_resume_interface(udev, intf, 0); 1206 usb_resume_interface(udev, intf, msg2, 0);
1183 } 1207 }
1184 1208
1185 /* Try another autosuspend when the interfaces aren't busy */ 1209 /* Try another autosuspend when the interfaces aren't busy */
1186 if (udev->auto_pm) 1210 if (msg.event & PM_EVENT_AUTO)
1187 autosuspend_check(udev, status == -EBUSY); 1211 autosuspend_check(udev, status == -EBUSY);
1188 1212
1189 /* If the suspend succeeded then prevent any more URB submissions, 1213 /* If the suspend succeeded then prevent any more URB submissions,
@@ -1213,6 +1237,7 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
1213/** 1237/**
1214 * usb_resume_both - resume a USB device and its interfaces 1238 * usb_resume_both - resume a USB device and its interfaces
1215 * @udev: the usb_device to resume 1239 * @udev: the usb_device to resume
1240 * @msg: Power Management message describing this state transition
1216 * 1241 *
1217 * This is the central routine for resuming USB devices. It calls the 1242 * This is the central routine for resuming USB devices. It calls the
1218 * the resume method for @udev and then calls the resume methods for all 1243 * the resume method for @udev and then calls the resume methods for all
@@ -1238,7 +1263,7 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
1238 * 1263 *
1239 * This routine can run only in process context. 1264 * This routine can run only in process context.
1240 */ 1265 */
1241static int usb_resume_both(struct usb_device *udev) 1266static int usb_resume_both(struct usb_device *udev, pm_message_t msg)
1242{ 1267{
1243 int status = 0; 1268 int status = 0;
1244 int i; 1269 int i;
@@ -1254,14 +1279,15 @@ static int usb_resume_both(struct usb_device *udev)
1254 1279
1255 /* Propagate the resume up the tree, if necessary */ 1280 /* Propagate the resume up the tree, if necessary */
1256 if (udev->state == USB_STATE_SUSPENDED) { 1281 if (udev->state == USB_STATE_SUSPENDED) {
1257 if (udev->auto_pm && udev->autoresume_disabled) { 1282 if ((msg.event & PM_EVENT_AUTO) &&
1283 udev->autoresume_disabled) {
1258 status = -EPERM; 1284 status = -EPERM;
1259 goto done; 1285 goto done;
1260 } 1286 }
1261 if (parent) { 1287 if (parent) {
1262 status = usb_autoresume_device(parent); 1288 status = usb_autoresume_device(parent);
1263 if (status == 0) { 1289 if (status == 0) {
1264 status = usb_resume_device(udev); 1290 status = usb_resume_device(udev, msg);
1265 if (status || udev->state == 1291 if (status || udev->state ==
1266 USB_STATE_NOTATTACHED) { 1292 USB_STATE_NOTATTACHED) {
1267 usb_autosuspend_device(parent); 1293 usb_autosuspend_device(parent);
@@ -1284,15 +1310,16 @@ static int usb_resume_both(struct usb_device *udev)
1284 /* We can't progagate beyond the USB subsystem, 1310 /* We can't progagate beyond the USB subsystem,
1285 * so if a root hub's controller is suspended 1311 * so if a root hub's controller is suspended
1286 * then we're stuck. */ 1312 * then we're stuck. */
1287 status = usb_resume_device(udev); 1313 status = usb_resume_device(udev, msg);
1288 } 1314 }
1289 } else if (udev->reset_resume) 1315 } else if (udev->reset_resume)
1290 status = usb_resume_device(udev); 1316 status = usb_resume_device(udev, msg);
1291 1317
1292 if (status == 0 && udev->actconfig) { 1318 if (status == 0 && udev->actconfig) {
1293 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { 1319 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
1294 intf = udev->actconfig->interface[i]; 1320 intf = udev->actconfig->interface[i];
1295 usb_resume_interface(udev, intf, udev->reset_resume); 1321 usb_resume_interface(udev, intf, msg,
1322 udev->reset_resume);
1296 } 1323 }
1297 } 1324 }
1298 1325
@@ -1320,13 +1347,13 @@ static int usb_autopm_do_device(struct usb_device *udev, int inc_usage_cnt)
1320 udev->last_busy = jiffies; 1347 udev->last_busy = jiffies;
1321 if (inc_usage_cnt >= 0 && udev->pm_usage_cnt > 0) { 1348 if (inc_usage_cnt >= 0 && udev->pm_usage_cnt > 0) {
1322 if (udev->state == USB_STATE_SUSPENDED) 1349 if (udev->state == USB_STATE_SUSPENDED)
1323 status = usb_resume_both(udev); 1350 status = usb_resume_both(udev, PMSG_AUTO_RESUME);
1324 if (status != 0) 1351 if (status != 0)
1325 udev->pm_usage_cnt -= inc_usage_cnt; 1352 udev->pm_usage_cnt -= inc_usage_cnt;
1326 else if (inc_usage_cnt) 1353 else if (inc_usage_cnt)
1327 udev->last_busy = jiffies; 1354 udev->last_busy = jiffies;
1328 } else if (inc_usage_cnt <= 0 && udev->pm_usage_cnt <= 0) { 1355 } else if (inc_usage_cnt <= 0 && udev->pm_usage_cnt <= 0) {
1329 status = usb_suspend_both(udev, PMSG_SUSPEND); 1356 status = usb_suspend_both(udev, PMSG_AUTO_SUSPEND);
1330 } 1357 }
1331 usb_pm_unlock(udev); 1358 usb_pm_unlock(udev);
1332 return status; 1359 return status;
@@ -1341,6 +1368,19 @@ void usb_autosuspend_work(struct work_struct *work)
1341 usb_autopm_do_device(udev, 0); 1368 usb_autopm_do_device(udev, 0);
1342} 1369}
1343 1370
1371/* usb_autoresume_work - callback routine to autoresume a USB device */
1372void usb_autoresume_work(struct work_struct *work)
1373{
1374 struct usb_device *udev =
1375 container_of(work, struct usb_device, autoresume);
1376
1377 /* Wake it up, let the drivers do their thing, and then put it
1378 * back to sleep.
1379 */
1380 if (usb_autopm_do_device(udev, 1) == 0)
1381 usb_autopm_do_device(udev, -1);
1382}
1383
1344/** 1384/**
1345 * usb_autosuspend_device - delayed autosuspend of a USB device and its interfaces 1385 * usb_autosuspend_device - delayed autosuspend of a USB device and its interfaces
1346 * @udev: the usb_device to autosuspend 1386 * @udev: the usb_device to autosuspend
@@ -1437,13 +1477,14 @@ static int usb_autopm_do_interface(struct usb_interface *intf,
1437 udev->last_busy = jiffies; 1477 udev->last_busy = jiffies;
1438 if (inc_usage_cnt >= 0 && intf->pm_usage_cnt > 0) { 1478 if (inc_usage_cnt >= 0 && intf->pm_usage_cnt > 0) {
1439 if (udev->state == USB_STATE_SUSPENDED) 1479 if (udev->state == USB_STATE_SUSPENDED)
1440 status = usb_resume_both(udev); 1480 status = usb_resume_both(udev,
1481 PMSG_AUTO_RESUME);
1441 if (status != 0) 1482 if (status != 0)
1442 intf->pm_usage_cnt -= inc_usage_cnt; 1483 intf->pm_usage_cnt -= inc_usage_cnt;
1443 else 1484 else
1444 udev->last_busy = jiffies; 1485 udev->last_busy = jiffies;
1445 } else if (inc_usage_cnt <= 0 && intf->pm_usage_cnt <= 0) { 1486 } else if (inc_usage_cnt <= 0 && intf->pm_usage_cnt <= 0) {
1446 status = usb_suspend_both(udev, PMSG_SUSPEND); 1487 status = usb_suspend_both(udev, PMSG_AUTO_SUSPEND);
1447 } 1488 }
1448 } 1489 }
1449 usb_pm_unlock(udev); 1490 usb_pm_unlock(udev);
@@ -1492,6 +1533,45 @@ void usb_autopm_put_interface(struct usb_interface *intf)
1492EXPORT_SYMBOL_GPL(usb_autopm_put_interface); 1533EXPORT_SYMBOL_GPL(usb_autopm_put_interface);
1493 1534
1494/** 1535/**
1536 * usb_autopm_put_interface_async - decrement a USB interface's PM-usage counter
1537 * @intf: the usb_interface whose counter should be decremented
1538 *
1539 * This routine does essentially the same thing as
1540 * usb_autopm_put_interface(): it decrements @intf's usage counter and
1541 * queues a delayed autosuspend request if the counter is <= 0. The
1542 * difference is that it does not acquire the device's pm_mutex;
1543 * callers must handle all synchronization issues themselves.
1544 *
1545 * Typically a driver would call this routine during an URB's completion
1546 * handler, if no more URBs were pending.
1547 *
1548 * This routine can run in atomic context.
1549 */
1550void usb_autopm_put_interface_async(struct usb_interface *intf)
1551{
1552 struct usb_device *udev = interface_to_usbdev(intf);
1553 int status = 0;
1554
1555 if (intf->condition == USB_INTERFACE_UNBOUND) {
1556 status = -ENODEV;
1557 } else {
1558 udev->last_busy = jiffies;
1559 --intf->pm_usage_cnt;
1560 if (udev->autosuspend_disabled || udev->autosuspend_delay < 0)
1561 status = -EPERM;
1562 else if (intf->pm_usage_cnt <= 0 &&
1563 !timer_pending(&udev->autosuspend.timer)) {
1564 queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend,
1565 round_jiffies_up_relative(
1566 udev->autosuspend_delay));
1567 }
1568 }
1569 dev_vdbg(&intf->dev, "%s: status %d cnt %d\n",
1570 __func__, status, intf->pm_usage_cnt);
1571}
1572EXPORT_SYMBOL_GPL(usb_autopm_put_interface_async);
1573
1574/**
1495 * usb_autopm_get_interface - increment a USB interface's PM-usage counter 1575 * usb_autopm_get_interface - increment a USB interface's PM-usage counter
1496 * @intf: the usb_interface whose counter should be incremented 1576 * @intf: the usb_interface whose counter should be incremented
1497 * 1577 *
@@ -1537,6 +1617,37 @@ int usb_autopm_get_interface(struct usb_interface *intf)
1537EXPORT_SYMBOL_GPL(usb_autopm_get_interface); 1617EXPORT_SYMBOL_GPL(usb_autopm_get_interface);
1538 1618
1539/** 1619/**
1620 * usb_autopm_get_interface_async - increment a USB interface's PM-usage counter
1621 * @intf: the usb_interface whose counter should be incremented
1622 *
1623 * This routine does much the same thing as
1624 * usb_autopm_get_interface(): it increments @intf's usage counter and
1625 * queues an autoresume request if the result is > 0. The differences
1626 * are that it does not acquire the device's pm_mutex (callers must
1627 * handle all synchronization issues themselves), and it does not
1628 * autoresume the device directly (it only queues a request). After a
1629 * successful call, the device will generally not yet be resumed.
1630 *
1631 * This routine can run in atomic context.
1632 */
1633int usb_autopm_get_interface_async(struct usb_interface *intf)
1634{
1635 struct usb_device *udev = interface_to_usbdev(intf);
1636 int status = 0;
1637
1638 if (intf->condition == USB_INTERFACE_UNBOUND)
1639 status = -ENODEV;
1640 else if (udev->autoresume_disabled)
1641 status = -EPERM;
1642 else if (++intf->pm_usage_cnt > 0 && udev->state == USB_STATE_SUSPENDED)
1643 queue_work(ksuspend_usb_wq, &udev->autoresume);
1644 dev_vdbg(&intf->dev, "%s: status %d cnt %d\n",
1645 __func__, status, intf->pm_usage_cnt);
1646 return status;
1647}
1648EXPORT_SYMBOL_GPL(usb_autopm_get_interface_async);
1649
1650/**
1540 * usb_autopm_set_interface - set a USB interface's autosuspend state 1651 * usb_autopm_set_interface - set a USB interface's autosuspend state
1541 * @intf: the usb_interface whose state should be set 1652 * @intf: the usb_interface whose state should be set
1542 * 1653 *
@@ -1563,6 +1674,9 @@ EXPORT_SYMBOL_GPL(usb_autopm_set_interface);
1563void usb_autosuspend_work(struct work_struct *work) 1674void usb_autosuspend_work(struct work_struct *work)
1564{} 1675{}
1565 1676
1677void usb_autoresume_work(struct work_struct *work)
1678{}
1679
1566#endif /* CONFIG_USB_SUSPEND */ 1680#endif /* CONFIG_USB_SUSPEND */
1567 1681
1568/** 1682/**
@@ -1595,6 +1709,7 @@ int usb_external_suspend_device(struct usb_device *udev, pm_message_t msg)
1595/** 1709/**
1596 * usb_external_resume_device - external resume of a USB device and its interfaces 1710 * usb_external_resume_device - external resume of a USB device and its interfaces
1597 * @udev: the usb_device to resume 1711 * @udev: the usb_device to resume
1712 * @msg: Power Management message describing this state transition
1598 * 1713 *
1599 * This routine handles external resume requests: ones not generated 1714 * This routine handles external resume requests: ones not generated
1600 * internally by a USB driver (autoresume) but rather coming from the user 1715 * internally by a USB driver (autoresume) but rather coming from the user
@@ -1603,13 +1718,13 @@ int usb_external_suspend_device(struct usb_device *udev, pm_message_t msg)
1603 * 1718 *
1604 * The caller must hold @udev's device lock. 1719 * The caller must hold @udev's device lock.
1605 */ 1720 */
1606int usb_external_resume_device(struct usb_device *udev) 1721int usb_external_resume_device(struct usb_device *udev, pm_message_t msg)
1607{ 1722{
1608 int status; 1723 int status;
1609 1724
1610 usb_pm_lock(udev); 1725 usb_pm_lock(udev);
1611 udev->auto_pm = 0; 1726 udev->auto_pm = 0;
1612 status = usb_resume_both(udev); 1727 status = usb_resume_both(udev, msg);
1613 udev->last_busy = jiffies; 1728 udev->last_busy = jiffies;
1614 usb_pm_unlock(udev); 1729 usb_pm_unlock(udev);
1615 if (status == 0) 1730 if (status == 0)
@@ -1622,7 +1737,7 @@ int usb_external_resume_device(struct usb_device *udev)
1622 return status; 1737 return status;
1623} 1738}
1624 1739
1625int usb_suspend(struct device *dev, pm_message_t message) 1740int usb_suspend(struct device *dev, pm_message_t msg)
1626{ 1741{
1627 struct usb_device *udev; 1742 struct usb_device *udev;
1628 1743
@@ -1641,10 +1756,10 @@ int usb_suspend(struct device *dev, pm_message_t message)
1641 } 1756 }
1642 1757
1643 udev->skip_sys_resume = 0; 1758 udev->skip_sys_resume = 0;
1644 return usb_external_suspend_device(udev, message); 1759 return usb_external_suspend_device(udev, msg);
1645} 1760}
1646 1761
1647int usb_resume(struct device *dev) 1762int usb_resume(struct device *dev, pm_message_t msg)
1648{ 1763{
1649 struct usb_device *udev; 1764 struct usb_device *udev;
1650 1765
@@ -1656,7 +1771,7 @@ int usb_resume(struct device *dev)
1656 */ 1771 */
1657 if (udev->skip_sys_resume) 1772 if (udev->skip_sys_resume)
1658 return 0; 1773 return 0;
1659 return usb_external_resume_device(udev); 1774 return usb_external_resume_device(udev, msg);
1660} 1775}
1661 1776
1662#endif /* CONFIG_PM */ 1777#endif /* CONFIG_PM */
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index 946fae43d622..e1710f260b4f 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -276,7 +276,7 @@ static void ep_device_release(struct device *dev)
276 kfree(ep_dev); 276 kfree(ep_dev);
277} 277}
278 278
279int usb_create_ep_files(struct device *parent, 279int usb_create_ep_devs(struct device *parent,
280 struct usb_host_endpoint *endpoint, 280 struct usb_host_endpoint *endpoint,
281 struct usb_device *udev) 281 struct usb_device *udev)
282{ 282{
@@ -340,7 +340,7 @@ exit:
340 return retval; 340 return retval;
341} 341}
342 342
343void usb_remove_ep_files(struct usb_host_endpoint *endpoint) 343void usb_remove_ep_devs(struct usb_host_endpoint *endpoint)
344{ 344{
345 struct ep_device *ep_dev = endpoint->ep_dev; 345 struct ep_device *ep_dev = endpoint->ep_dev;
346 346
diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
index 7e912f21fd36..30ecac3af15a 100644
--- a/drivers/usb/core/generic.c
+++ b/drivers/usb/core/generic.c
@@ -200,18 +200,18 @@ static int generic_suspend(struct usb_device *udev, pm_message_t msg)
200 * interfaces manually by doing a bus (or "global") suspend. 200 * interfaces manually by doing a bus (or "global") suspend.
201 */ 201 */
202 if (!udev->parent) 202 if (!udev->parent)
203 rc = hcd_bus_suspend(udev); 203 rc = hcd_bus_suspend(udev, msg);
204 204
205 /* Non-root devices don't need to do anything for FREEZE or PRETHAW */ 205 /* Non-root devices don't need to do anything for FREEZE or PRETHAW */
206 else if (msg.event == PM_EVENT_FREEZE || msg.event == PM_EVENT_PRETHAW) 206 else if (msg.event == PM_EVENT_FREEZE || msg.event == PM_EVENT_PRETHAW)
207 rc = 0; 207 rc = 0;
208 else 208 else
209 rc = usb_port_suspend(udev); 209 rc = usb_port_suspend(udev, msg);
210 210
211 return rc; 211 return rc;
212} 212}
213 213
214static int generic_resume(struct usb_device *udev) 214static int generic_resume(struct usb_device *udev, pm_message_t msg)
215{ 215{
216 int rc; 216 int rc;
217 217
@@ -221,9 +221,9 @@ static int generic_resume(struct usb_device *udev)
221 * interfaces manually by doing a bus (or "global") resume. 221 * interfaces manually by doing a bus (or "global") resume.
222 */ 222 */
223 if (!udev->parent) 223 if (!udev->parent)
224 rc = hcd_bus_resume(udev); 224 rc = hcd_bus_resume(udev, msg);
225 else 225 else
226 rc = usb_port_resume(udev); 226 rc = usb_port_resume(udev, msg);
227 return rc; 227 return rc;
228} 228}
229 229
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index 5b87ae7f0a6a..507741ed4482 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -128,6 +128,7 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
128 } 128 }
129 129
130 pci_set_master(dev); 130 pci_set_master(dev);
131 device_set_wakeup_enable(&dev->dev, 1);
131 132
132 retval = usb_add_hcd(hcd, dev->irq, IRQF_DISABLED | IRQF_SHARED); 133 retval = usb_add_hcd(hcd, dev->irq, IRQF_DISABLED | IRQF_SHARED);
133 if (retval != 0) 134 if (retval != 0)
@@ -191,17 +192,15 @@ EXPORT_SYMBOL_GPL(usb_hcd_pci_remove);
191/** 192/**
192 * usb_hcd_pci_suspend - power management suspend of a PCI-based HCD 193 * usb_hcd_pci_suspend - power management suspend of a PCI-based HCD
193 * @dev: USB Host Controller being suspended 194 * @dev: USB Host Controller being suspended
194 * @message: semantics in flux 195 * @message: Power Management message describing this state transition
195 * 196 *
196 * Store this function in the HCD's struct pci_driver as suspend(). 197 * Store this function in the HCD's struct pci_driver as .suspend.
197 */ 198 */
198int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t message) 199int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t message)
199{ 200{
200 struct usb_hcd *hcd; 201 struct usb_hcd *hcd = pci_get_drvdata(dev);
201 int retval = 0; 202 int retval = 0;
202 int has_pci_pm; 203 int wake, w;
203
204 hcd = pci_get_drvdata(dev);
205 204
206 /* Root hub suspend should have stopped all downstream traffic, 205 /* Root hub suspend should have stopped all downstream traffic,
207 * and all bus master traffic. And done so for both the interface 206 * and all bus master traffic. And done so for both the interface
@@ -212,8 +211,15 @@ int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t message)
212 * otherwise the swsusp will save (and restore) garbage state. 211 * otherwise the swsusp will save (and restore) garbage state.
213 */ 212 */
214 if (!(hcd->state == HC_STATE_SUSPENDED || 213 if (!(hcd->state == HC_STATE_SUSPENDED ||
215 hcd->state == HC_STATE_HALT)) 214 hcd->state == HC_STATE_HALT)) {
216 return -EBUSY; 215 dev_warn(&dev->dev, "Root hub is not suspended\n");
216 retval = -EBUSY;
217 goto done;
218 }
219
220 /* We might already be suspended (runtime PM -- not yet written) */
221 if (dev->current_state != PCI_D0)
222 goto done;
217 223
218 if (hcd->driver->pci_suspend) { 224 if (hcd->driver->pci_suspend) {
219 retval = hcd->driver->pci_suspend(hcd, message); 225 retval = hcd->driver->pci_suspend(hcd, message);
@@ -221,49 +227,60 @@ int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t message)
221 if (retval) 227 if (retval)
222 goto done; 228 goto done;
223 } 229 }
224 synchronize_irq(dev->irq);
225 230
226 /* FIXME until the generic PM interfaces change a lot more, this 231 synchronize_irq(dev->irq);
227 * can't use PCI D1 and D2 states. For example, the confusion
228 * between messages and states will need to vanish, and messages
229 * will need to provide a target system state again.
230 *
231 * It'll be important to learn characteristics of the target state,
232 * especially on embedded hardware where the HCD will often be in
233 * charge of an external VBUS power supply and one or more clocks.
234 * Some target system states will leave them active; others won't.
235 * (With PCI, that's often handled by platform BIOS code.)
236 */
237 232
238 /* even when the PCI layer rejects some of the PCI calls 233 /* Don't fail on error to enable wakeup. We rely on pci code
239 * below, HCs can try global suspend and reduce DMA traffic. 234 * to reject requests the hardware can't implement, rather
240 * PM-sensitive HCDs may already have done this. 235 * than coding the same thing.
241 */ 236 */
242 has_pci_pm = pci_find_capability(dev, PCI_CAP_ID_PM); 237 wake = (hcd->state == HC_STATE_SUSPENDED &&
238 device_may_wakeup(&dev->dev));
239 w = pci_wake_from_d3(dev, wake);
240 if (w < 0)
241 wake = w;
242 dev_dbg(&dev->dev, "wakeup: %d\n", wake);
243 243
244 /* Downstream ports from this root hub should already be quiesced, so 244 /* Downstream ports from this root hub should already be quiesced, so
245 * there will be no DMA activity. Now we can shut down the upstream 245 * there will be no DMA activity. Now we can shut down the upstream
246 * link (except maybe for PME# resume signaling) and enter some PCI 246 * link (except maybe for PME# resume signaling) and enter some PCI
247 * low power state, if the hardware allows. 247 * low power state, if the hardware allows.
248 */ 248 */
249 if (hcd->state == HC_STATE_SUSPENDED) { 249 pci_disable_device(dev);
250 done:
251 return retval;
252}
253EXPORT_SYMBOL_GPL(usb_hcd_pci_suspend);
250 254
251 /* no DMA or IRQs except when HC is active */ 255/**
252 if (dev->current_state == PCI_D0) { 256 * usb_hcd_pci_suspend_late - suspend a PCI-based HCD after IRQs are disabled
253 pci_save_state(dev); 257 * @dev: USB Host Controller being suspended
254 pci_disable_device(dev); 258 * @message: Power Management message describing this state transition
255 } 259 *
260 * Store this function in the HCD's struct pci_driver as .suspend_late.
261 */
262int usb_hcd_pci_suspend_late(struct pci_dev *dev, pm_message_t message)
263{
264 int retval = 0;
265 int has_pci_pm;
256 266
257 if (message.event == PM_EVENT_FREEZE || 267 /* We might already be suspended (runtime PM -- not yet written) */
258 message.event == PM_EVENT_PRETHAW) { 268 if (dev->current_state != PCI_D0)
259 dev_dbg(hcd->self.controller, "--> no state change\n"); 269 goto done;
260 goto done;
261 }
262 270
263 if (!has_pci_pm) { 271 pci_save_state(dev);
264 dev_dbg(hcd->self.controller, "--> PCI D0/legacy\n"); 272
265 goto done; 273 /* Don't change state if we don't need to */
266 } 274 if (message.event == PM_EVENT_FREEZE ||
275 message.event == PM_EVENT_PRETHAW) {
276 dev_dbg(&dev->dev, "--> no state change\n");
277 goto done;
278 }
279
280 has_pci_pm = pci_find_capability(dev, PCI_CAP_ID_PM);
281 if (!has_pci_pm) {
282 dev_dbg(&dev->dev, "--> PCI D0 legacy\n");
283 } else {
267 284
268 /* NOTE: dev->current_state becomes nonzero only here, and 285 /* NOTE: dev->current_state becomes nonzero only here, and
269 * only for devices that support PCI PM. Also, exiting 286 * only for devices that support PCI PM. Also, exiting
@@ -273,35 +290,16 @@ int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t message)
273 retval = pci_set_power_state(dev, PCI_D3hot); 290 retval = pci_set_power_state(dev, PCI_D3hot);
274 suspend_report_result(pci_set_power_state, retval); 291 suspend_report_result(pci_set_power_state, retval);
275 if (retval == 0) { 292 if (retval == 0) {
276 int wake = device_can_wakeup(&hcd->self.root_hub->dev); 293 dev_dbg(&dev->dev, "--> PCI D3\n");
277
278 wake = wake && device_may_wakeup(hcd->self.controller);
279
280 dev_dbg(hcd->self.controller, "--> PCI D3%s\n",
281 wake ? "/wakeup" : "");
282
283 /* Ignore these return values. We rely on pci code to
284 * reject requests the hardware can't implement, rather
285 * than coding the same thing.
286 */
287 (void) pci_enable_wake(dev, PCI_D3hot, wake);
288 (void) pci_enable_wake(dev, PCI_D3cold, wake);
289 } else { 294 } else {
290 dev_dbg(&dev->dev, "PCI D3 suspend fail, %d\n", 295 dev_dbg(&dev->dev, "PCI D3 suspend fail, %d\n",
291 retval); 296 retval);
292 (void) usb_hcd_pci_resume(dev); 297 pci_restore_state(dev);
293 } 298 }
294
295 } else if (hcd->state != HC_STATE_HALT) {
296 dev_dbg(hcd->self.controller, "hcd state %d; not suspended\n",
297 hcd->state);
298 WARN_ON(1);
299 retval = -EINVAL;
300 } 299 }
301 300
302done:
303 if (retval == 0) {
304#ifdef CONFIG_PPC_PMAC 301#ifdef CONFIG_PPC_PMAC
302 if (retval == 0) {
305 /* Disable ASIC clocks for USB */ 303 /* Disable ASIC clocks for USB */
306 if (machine_is(powermac)) { 304 if (machine_is(powermac)) {
307 struct device_node *of_node; 305 struct device_node *of_node;
@@ -311,30 +309,24 @@ done:
311 pmac_call_feature(PMAC_FTR_USB_ENABLE, 309 pmac_call_feature(PMAC_FTR_USB_ENABLE,
312 of_node, 0, 0); 310 of_node, 0, 0);
313 } 311 }
314#endif
315 } 312 }
313#endif
316 314
315 done:
317 return retval; 316 return retval;
318} 317}
319EXPORT_SYMBOL_GPL(usb_hcd_pci_suspend); 318EXPORT_SYMBOL_GPL(usb_hcd_pci_suspend_late);
320 319
321/** 320/**
322 * usb_hcd_pci_resume - power management resume of a PCI-based HCD 321 * usb_hcd_pci_resume_early - resume a PCI-based HCD before IRQs are enabled
323 * @dev: USB Host Controller being resumed 322 * @dev: USB Host Controller being resumed
324 * 323 *
325 * Store this function in the HCD's struct pci_driver as resume(). 324 * Store this function in the HCD's struct pci_driver as .resume_early.
326 */ 325 */
327int usb_hcd_pci_resume(struct pci_dev *dev) 326int usb_hcd_pci_resume_early(struct pci_dev *dev)
328{ 327{
329 struct usb_hcd *hcd; 328 int retval = 0;
330 int retval; 329 pci_power_t state = dev->current_state;
331
332 hcd = pci_get_drvdata(dev);
333 if (hcd->state != HC_STATE_SUSPENDED) {
334 dev_dbg(hcd->self.controller,
335 "can't resume, not suspended!\n");
336 return 0;
337 }
338 330
339#ifdef CONFIG_PPC_PMAC 331#ifdef CONFIG_PPC_PMAC
340 /* Reenable ASIC clocks for USB */ 332 /* Reenable ASIC clocks for USB */
@@ -352,7 +344,7 @@ int usb_hcd_pci_resume(struct pci_dev *dev)
352 * calls "standby", "suspend to RAM", and so on). There are also 344 * calls "standby", "suspend to RAM", and so on). There are also
353 * dirty cases when swsusp fakes a suspend in "shutdown" mode. 345 * dirty cases when swsusp fakes a suspend in "shutdown" mode.
354 */ 346 */
355 if (dev->current_state != PCI_D0) { 347 if (state != PCI_D0) {
356#ifdef DEBUG 348#ifdef DEBUG
357 int pci_pm; 349 int pci_pm;
358 u16 pmcr; 350 u16 pmcr;
@@ -364,8 +356,7 @@ int usb_hcd_pci_resume(struct pci_dev *dev)
364 /* Clean case: power to USB and to HC registers was 356 /* Clean case: power to USB and to HC registers was
365 * maintained; remote wakeup is easy. 357 * maintained; remote wakeup is easy.
366 */ 358 */
367 dev_dbg(hcd->self.controller, "resume from PCI D%d\n", 359 dev_dbg(&dev->dev, "resume from PCI D%d\n", pmcr);
368 pmcr);
369 } else { 360 } else {
370 /* Clean: HC lost Vcc power, D0 uninitialized 361 /* Clean: HC lost Vcc power, D0 uninitialized
371 * + Vaux may have preserved port and transceiver 362 * + Vaux may have preserved port and transceiver
@@ -376,32 +367,55 @@ int usb_hcd_pci_resume(struct pci_dev *dev)
376 * + after BIOS init 367 * + after BIOS init
377 * + after Linux init (HCD statically linked) 368 * + after Linux init (HCD statically linked)
378 */ 369 */
379 dev_dbg(hcd->self.controller, 370 dev_dbg(&dev->dev, "resume from previous PCI D%d\n",
380 "PCI D0, from previous PCI D%d\n", 371 state);
381 dev->current_state);
382 } 372 }
383#endif 373#endif
384 /* yes, ignore these results too... */ 374
385 (void) pci_enable_wake(dev, dev->current_state, 0); 375 retval = pci_set_power_state(dev, PCI_D0);
386 (void) pci_enable_wake(dev, PCI_D3cold, 0);
387 } else { 376 } else {
388 /* Same basic cases: clean (powered/not), dirty */ 377 /* Same basic cases: clean (powered/not), dirty */
389 dev_dbg(hcd->self.controller, "PCI legacy resume\n"); 378 dev_dbg(&dev->dev, "PCI legacy resume\n");
379 }
380
381 if (retval < 0)
382 dev_err(&dev->dev, "can't resume: %d\n", retval);
383 else
384 pci_restore_state(dev);
385
386 return retval;
387}
388EXPORT_SYMBOL_GPL(usb_hcd_pci_resume_early);
389
390/**
391 * usb_hcd_pci_resume - power management resume of a PCI-based HCD
392 * @dev: USB Host Controller being resumed
393 *
394 * Store this function in the HCD's struct pci_driver as .resume.
395 */
396int usb_hcd_pci_resume(struct pci_dev *dev)
397{
398 struct usb_hcd *hcd;
399 int retval;
400
401 hcd = pci_get_drvdata(dev);
402 if (hcd->state != HC_STATE_SUSPENDED) {
403 dev_dbg(hcd->self.controller,
404 "can't resume, not suspended!\n");
405 return 0;
390 } 406 }
391 407
392 /* NOTE: the PCI API itself is asymmetric here. We don't need to
393 * pci_set_power_state(PCI_D0) since that's part of re-enabling;
394 * but that won't re-enable bus mastering. Yet pci_disable_device()
395 * explicitly disables bus mastering...
396 */
397 retval = pci_enable_device(dev); 408 retval = pci_enable_device(dev);
398 if (retval < 0) { 409 if (retval < 0) {
399 dev_err(hcd->self.controller, 410 dev_err(&dev->dev, "can't re-enable after resume, %d!\n",
400 "can't re-enable after resume, %d!\n", retval); 411 retval);
401 return retval; 412 return retval;
402 } 413 }
414
403 pci_set_master(dev); 415 pci_set_master(dev);
404 pci_restore_state(dev); 416
417 /* yes, ignore this result too... */
418 (void) pci_wake_from_d3(dev, 0);
405 419
406 clear_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); 420 clear_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
407 421
@@ -413,7 +427,6 @@ int usb_hcd_pci_resume(struct pci_dev *dev)
413 usb_hc_died(hcd); 427 usb_hc_died(hcd);
414 } 428 }
415 } 429 }
416
417 return retval; 430 return retval;
418} 431}
419EXPORT_SYMBOL_GPL(usb_hcd_pci_resume); 432EXPORT_SYMBOL_GPL(usb_hcd_pci_resume);
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index e1b42626d04d..3c711db55d86 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1010,7 +1010,7 @@ int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb)
1010 spin_lock(&hcd_urb_list_lock); 1010 spin_lock(&hcd_urb_list_lock);
1011 1011
1012 /* Check that the URB isn't being killed */ 1012 /* Check that the URB isn't being killed */
1013 if (unlikely(urb->reject)) { 1013 if (unlikely(atomic_read(&urb->reject))) {
1014 rc = -EPERM; 1014 rc = -EPERM;
1015 goto done; 1015 goto done;
1016 } 1016 }
@@ -1340,7 +1340,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
1340 INIT_LIST_HEAD(&urb->urb_list); 1340 INIT_LIST_HEAD(&urb->urb_list);
1341 atomic_dec(&urb->use_count); 1341 atomic_dec(&urb->use_count);
1342 atomic_dec(&urb->dev->urbnum); 1342 atomic_dec(&urb->dev->urbnum);
1343 if (urb->reject) 1343 if (atomic_read(&urb->reject))
1344 wake_up(&usb_kill_urb_queue); 1344 wake_up(&usb_kill_urb_queue);
1345 usb_put_urb(urb); 1345 usb_put_urb(urb);
1346 } 1346 }
@@ -1444,7 +1444,7 @@ void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, int status)
1444 urb->status = status; 1444 urb->status = status;
1445 urb->complete (urb); 1445 urb->complete (urb);
1446 atomic_dec (&urb->use_count); 1446 atomic_dec (&urb->use_count);
1447 if (unlikely (urb->reject)) 1447 if (unlikely(atomic_read(&urb->reject)))
1448 wake_up (&usb_kill_urb_queue); 1448 wake_up (&usb_kill_urb_queue);
1449 usb_put_urb (urb); 1449 usb_put_urb (urb);
1450} 1450}
@@ -1573,14 +1573,14 @@ int usb_hcd_get_frame_number (struct usb_device *udev)
1573 1573
1574#ifdef CONFIG_PM 1574#ifdef CONFIG_PM
1575 1575
1576int hcd_bus_suspend(struct usb_device *rhdev) 1576int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg)
1577{ 1577{
1578 struct usb_hcd *hcd = container_of(rhdev->bus, struct usb_hcd, self); 1578 struct usb_hcd *hcd = container_of(rhdev->bus, struct usb_hcd, self);
1579 int status; 1579 int status;
1580 int old_state = hcd->state; 1580 int old_state = hcd->state;
1581 1581
1582 dev_dbg(&rhdev->dev, "bus %s%s\n", 1582 dev_dbg(&rhdev->dev, "bus %s%s\n",
1583 rhdev->auto_pm ? "auto-" : "", "suspend"); 1583 (msg.event & PM_EVENT_AUTO ? "auto-" : ""), "suspend");
1584 if (!hcd->driver->bus_suspend) { 1584 if (!hcd->driver->bus_suspend) {
1585 status = -ENOENT; 1585 status = -ENOENT;
1586 } else { 1586 } else {
@@ -1598,14 +1598,14 @@ int hcd_bus_suspend(struct usb_device *rhdev)
1598 return status; 1598 return status;
1599} 1599}
1600 1600
1601int hcd_bus_resume(struct usb_device *rhdev) 1601int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg)
1602{ 1602{
1603 struct usb_hcd *hcd = container_of(rhdev->bus, struct usb_hcd, self); 1603 struct usb_hcd *hcd = container_of(rhdev->bus, struct usb_hcd, self);
1604 int status; 1604 int status;
1605 int old_state = hcd->state; 1605 int old_state = hcd->state;
1606 1606
1607 dev_dbg(&rhdev->dev, "usb %s%s\n", 1607 dev_dbg(&rhdev->dev, "usb %s%s\n",
1608 rhdev->auto_pm ? "auto-" : "", "resume"); 1608 (msg.event & PM_EVENT_AUTO ? "auto-" : ""), "resume");
1609 if (!hcd->driver->bus_resume) 1609 if (!hcd->driver->bus_resume)
1610 return -ENOENT; 1610 return -ENOENT;
1611 if (hcd->state == HC_STATE_RUNNING) 1611 if (hcd->state == HC_STATE_RUNNING)
@@ -1638,7 +1638,7 @@ static void hcd_resume_work(struct work_struct *work)
1638 1638
1639 usb_lock_device(udev); 1639 usb_lock_device(udev);
1640 usb_mark_last_busy(udev); 1640 usb_mark_last_busy(udev);
1641 usb_external_resume_device(udev); 1641 usb_external_resume_device(udev, PMSG_REMOTE_RESUME);
1642 usb_unlock_device(udev); 1642 usb_unlock_device(udev);
1643} 1643}
1644 1644
@@ -2028,7 +2028,7 @@ EXPORT_SYMBOL_GPL(usb_hcd_platform_shutdown);
2028 2028
2029/*-------------------------------------------------------------------------*/ 2029/*-------------------------------------------------------------------------*/
2030 2030
2031#if defined(CONFIG_USB_MON) 2031#if defined(CONFIG_USB_MON) || defined(CONFIG_USB_MON_MODULE)
2032 2032
2033struct usb_mon_operations *mon_ops; 2033struct usb_mon_operations *mon_ops;
2034 2034
@@ -2064,4 +2064,4 @@ void usb_mon_deregister (void)
2064} 2064}
2065EXPORT_SYMBOL_GPL (usb_mon_deregister); 2065EXPORT_SYMBOL_GPL (usb_mon_deregister);
2066 2066
2067#endif /* CONFIG_USB_MON */ 2067#endif /* CONFIG_USB_MON || CONFIG_USB_MON_MODULE */
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
index 9465e70f4dd0..572d2cf46e8d 100644
--- a/drivers/usb/core/hcd.h
+++ b/drivers/usb/core/hcd.h
@@ -16,6 +16,8 @@
16 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 17 */
18 18
19#ifndef __USB_CORE_HCD_H
20#define __USB_CORE_HCD_H
19 21
20#ifdef __KERNEL__ 22#ifdef __KERNEL__
21 23
@@ -254,7 +256,9 @@ extern int usb_hcd_pci_probe(struct pci_dev *dev,
254extern void usb_hcd_pci_remove(struct pci_dev *dev); 256extern void usb_hcd_pci_remove(struct pci_dev *dev);
255 257
256#ifdef CONFIG_PM 258#ifdef CONFIG_PM
257extern int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t state); 259extern int usb_hcd_pci_suspend(struct pci_dev *dev, pm_message_t msg);
260extern int usb_hcd_pci_suspend_late(struct pci_dev *dev, pm_message_t msg);
261extern int usb_hcd_pci_resume_early(struct pci_dev *dev);
258extern int usb_hcd_pci_resume(struct pci_dev *dev); 262extern int usb_hcd_pci_resume(struct pci_dev *dev);
259#endif /* CONFIG_PM */ 263#endif /* CONFIG_PM */
260 264
@@ -386,8 +390,8 @@ extern int usb_find_interface_driver(struct usb_device *dev,
386#ifdef CONFIG_PM 390#ifdef CONFIG_PM
387extern void usb_hcd_resume_root_hub(struct usb_hcd *hcd); 391extern void usb_hcd_resume_root_hub(struct usb_hcd *hcd);
388extern void usb_root_hub_lost_power(struct usb_device *rhdev); 392extern void usb_root_hub_lost_power(struct usb_device *rhdev);
389extern int hcd_bus_suspend(struct usb_device *rhdev); 393extern int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg);
390extern int hcd_bus_resume(struct usb_device *rhdev); 394extern int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg);
391#else 395#else
392static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd) 396static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd)
393{ 397{
@@ -419,7 +423,7 @@ static inline void usbfs_cleanup(void) { }
419 423
420/*-------------------------------------------------------------------------*/ 424/*-------------------------------------------------------------------------*/
421 425
422#if defined(CONFIG_USB_MON) 426#if defined(CONFIG_USB_MON) || defined(CONFIG_USB_MON_MODULE)
423 427
424struct usb_mon_operations { 428struct usb_mon_operations {
425 void (*urb_submit)(struct usb_bus *bus, struct urb *urb); 429 void (*urb_submit)(struct usb_bus *bus, struct urb *urb);
@@ -461,7 +465,7 @@ static inline void usbmon_urb_submit_error(struct usb_bus *bus, struct urb *urb,
461static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb, 465static inline void usbmon_urb_complete(struct usb_bus *bus, struct urb *urb,
462 int status) {} 466 int status) {}
463 467
464#endif /* CONFIG_USB_MON */ 468#endif /* CONFIG_USB_MON || CONFIG_USB_MON_MODULE */
465 469
466/*-------------------------------------------------------------------------*/ 470/*-------------------------------------------------------------------------*/
467 471
@@ -490,3 +494,5 @@ extern struct rw_semaphore ehci_cf_port_reset_rwsem;
490extern unsigned long usb_hcds_loaded; 494extern unsigned long usb_hcds_loaded;
491 495
492#endif /* __KERNEL__ */ 496#endif /* __KERNEL__ */
497
498#endif /* __USB_CORE_HCD_H */
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index b19cbfcd51da..94d5ee263c20 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -107,7 +107,9 @@ MODULE_PARM_DESC (blinkenlights, "true to cycle leds on hubs");
107/* define initial 64-byte descriptor request timeout in milliseconds */ 107/* define initial 64-byte descriptor request timeout in milliseconds */
108static int initial_descriptor_timeout = USB_CTRL_GET_TIMEOUT; 108static int initial_descriptor_timeout = USB_CTRL_GET_TIMEOUT;
109module_param(initial_descriptor_timeout, int, S_IRUGO|S_IWUSR); 109module_param(initial_descriptor_timeout, int, S_IRUGO|S_IWUSR);
110MODULE_PARM_DESC(initial_descriptor_timeout, "initial 64-byte descriptor request timeout in milliseconds (default 5000 - 5.0 seconds)"); 110MODULE_PARM_DESC(initial_descriptor_timeout,
111 "initial 64-byte descriptor request timeout in milliseconds "
112 "(default 5000 - 5.0 seconds)");
111 113
112/* 114/*
113 * As of 2.6.10 we introduce a new USB device initialization scheme which 115 * As of 2.6.10 we introduce a new USB device initialization scheme which
@@ -1136,8 +1138,8 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
1136 hdev = interface_to_usbdev(intf); 1138 hdev = interface_to_usbdev(intf);
1137 1139
1138 if (hdev->level == MAX_TOPO_LEVEL) { 1140 if (hdev->level == MAX_TOPO_LEVEL) {
1139 dev_err(&intf->dev, "Unsupported bus topology: " 1141 dev_err(&intf->dev,
1140 "hub nested too deep\n"); 1142 "Unsupported bus topology: hub nested too deep\n");
1141 return -E2BIG; 1143 return -E2BIG;
1142 } 1144 }
1143 1145
@@ -1374,8 +1376,9 @@ static void usb_stop_pm(struct usb_device *udev)
1374 usb_autosuspend_device(udev->parent); 1376 usb_autosuspend_device(udev->parent);
1375 usb_pm_unlock(udev); 1377 usb_pm_unlock(udev);
1376 1378
1377 /* Stop any autosuspend requests already submitted */ 1379 /* Stop any autosuspend or autoresume requests already submitted */
1378 cancel_rearming_delayed_work(&udev->autosuspend); 1380 cancel_delayed_work_sync(&udev->autosuspend);
1381 cancel_work_sync(&udev->autoresume);
1379} 1382}
1380 1383
1381#else 1384#else
@@ -1434,17 +1437,12 @@ void usb_disconnect(struct usb_device **pdev)
1434 usb_disable_device(udev, 0); 1437 usb_disable_device(udev, 0);
1435 usb_hcd_synchronize_unlinks(udev); 1438 usb_hcd_synchronize_unlinks(udev);
1436 1439
1440 usb_remove_ep_devs(&udev->ep0);
1437 usb_unlock_device(udev); 1441 usb_unlock_device(udev);
1438 1442
1439 /* Remove the device-specific files from sysfs. This must be
1440 * done with udev unlocked, because some of the attribute
1441 * routines try to acquire the device lock.
1442 */
1443 usb_remove_sysfs_dev_files(udev);
1444
1445 /* Unregister the device. The device driver is responsible 1443 /* Unregister the device. The device driver is responsible
1446 * for removing the device files from usbfs and sysfs and for 1444 * for de-configuring the device and invoking the remove-device
1447 * de-configuring the device. 1445 * notifier chain (used by usbfs and possibly others).
1448 */ 1446 */
1449 device_del(&udev->dev); 1447 device_del(&udev->dev);
1450 1448
@@ -1476,8 +1474,8 @@ static void announce_device(struct usb_device *udev)
1476 dev_info(&udev->dev, "New USB device found, idVendor=%04x, idProduct=%04x\n", 1474 dev_info(&udev->dev, "New USB device found, idVendor=%04x, idProduct=%04x\n",
1477 le16_to_cpu(udev->descriptor.idVendor), 1475 le16_to_cpu(udev->descriptor.idVendor),
1478 le16_to_cpu(udev->descriptor.idProduct)); 1476 le16_to_cpu(udev->descriptor.idProduct));
1479 dev_info(&udev->dev, "New USB device strings: Mfr=%d, Product=%d, " 1477 dev_info(&udev->dev,
1480 "SerialNumber=%d\n", 1478 "New USB device strings: Mfr=%d, Product=%d, SerialNumber=%d\n",
1481 udev->descriptor.iManufacturer, 1479 udev->descriptor.iManufacturer,
1482 udev->descriptor.iProduct, 1480 udev->descriptor.iProduct,
1483 udev->descriptor.iSerialNumber); 1481 udev->descriptor.iSerialNumber);
@@ -1542,7 +1540,7 @@ static int usb_configure_device_otg(struct usb_device *udev)
1542 * customize to match your product. 1540 * customize to match your product.
1543 */ 1541 */
1544 dev_info(&udev->dev, 1542 dev_info(&udev->dev,
1545 "can't set HNP mode; %d\n", 1543 "can't set HNP mode: %d\n",
1546 err); 1544 err);
1547 bus->b_hnp_enable = 0; 1545 bus->b_hnp_enable = 0;
1548 } 1546 }
@@ -1556,7 +1554,7 @@ static int usb_configure_device_otg(struct usb_device *udev)
1556 * (Includes HNP test device.) 1554 * (Includes HNP test device.)
1557 */ 1555 */
1558 if (udev->bus->b_hnp_enable || udev->bus->is_b_host) { 1556 if (udev->bus->b_hnp_enable || udev->bus->is_b_host) {
1559 err = usb_port_suspend(udev); 1557 err = usb_port_suspend(udev, PMSG_SUSPEND);
1560 if (err < 0) 1558 if (err < 0)
1561 dev_dbg(&udev->dev, "HNP fail, %d\n", err); 1559 dev_dbg(&udev->dev, "HNP fail, %d\n", err);
1562 } 1560 }
@@ -1635,6 +1633,10 @@ int usb_new_device(struct usb_device *udev)
1635{ 1633{
1636 int err; 1634 int err;
1637 1635
1636 /* Increment the parent's count of unsuspended children */
1637 if (udev->parent)
1638 usb_autoresume_device(udev->parent);
1639
1638 usb_detect_quirks(udev); /* Determine quirks */ 1640 usb_detect_quirks(udev); /* Determine quirks */
1639 err = usb_configure_device(udev); /* detect & probe dev/intfs */ 1641 err = usb_configure_device(udev); /* detect & probe dev/intfs */
1640 if (err < 0) 1642 if (err < 0)
@@ -1643,13 +1645,12 @@ int usb_new_device(struct usb_device *udev)
1643 udev->dev.devt = MKDEV(USB_DEVICE_MAJOR, 1645 udev->dev.devt = MKDEV(USB_DEVICE_MAJOR,
1644 (((udev->bus->busnum-1) * 128) + (udev->devnum-1))); 1646 (((udev->bus->busnum-1) * 128) + (udev->devnum-1)));
1645 1647
1646 /* Increment the parent's count of unsuspended children */ 1648 /* Tell the world! */
1647 if (udev->parent) 1649 announce_device(udev);
1648 usb_autoresume_device(udev->parent);
1649 1650
1650 /* Register the device. The device driver is responsible 1651 /* Register the device. The device driver is responsible
1651 * for adding the device files to sysfs and for configuring 1652 * for configuring the device and invoking the add-device
1652 * the device. 1653 * notifier chain (used by usbfs and possibly others).
1653 */ 1654 */
1654 err = device_add(&udev->dev); 1655 err = device_add(&udev->dev);
1655 if (err) { 1656 if (err) {
@@ -1657,15 +1658,12 @@ int usb_new_device(struct usb_device *udev)
1657 goto fail; 1658 goto fail;
1658 } 1659 }
1659 1660
1660 /* put device-specific files into sysfs */ 1661 (void) usb_create_ep_devs(&udev->dev, &udev->ep0, udev);
1661 usb_create_sysfs_dev_files(udev);
1662
1663 /* Tell the world! */
1664 announce_device(udev);
1665 return err; 1662 return err;
1666 1663
1667fail: 1664fail:
1668 usb_set_device_state(udev, USB_STATE_NOTATTACHED); 1665 usb_set_device_state(udev, USB_STATE_NOTATTACHED);
1666 usb_stop_pm(udev);
1669 return err; 1667 return err;
1670} 1668}
1671 1669
@@ -1982,7 +1980,7 @@ static int check_port_resume_type(struct usb_device *udev,
1982 * 1980 *
1983 * Returns 0 on success, else negative errno. 1981 * Returns 0 on success, else negative errno.
1984 */ 1982 */
1985int usb_port_suspend(struct usb_device *udev) 1983int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
1986{ 1984{
1987 struct usb_hub *hub = hdev_to_hub(udev->parent); 1985 struct usb_hub *hub = hdev_to_hub(udev->parent);
1988 int port1 = udev->portnum; 1986 int port1 = udev->portnum;
@@ -2021,7 +2019,7 @@ int usb_port_suspend(struct usb_device *udev)
2021 } else { 2019 } else {
2022 /* device has up to 10 msec to fully suspend */ 2020 /* device has up to 10 msec to fully suspend */
2023 dev_dbg(&udev->dev, "usb %ssuspend\n", 2021 dev_dbg(&udev->dev, "usb %ssuspend\n",
2024 udev->auto_pm ? "auto-" : ""); 2022 (msg.event & PM_EVENT_AUTO ? "auto-" : ""));
2025 usb_set_device_state(udev, USB_STATE_SUSPENDED); 2023 usb_set_device_state(udev, USB_STATE_SUSPENDED);
2026 msleep(10); 2024 msleep(10);
2027 } 2025 }
@@ -2045,8 +2043,8 @@ static int finish_port_resume(struct usb_device *udev)
2045 u16 devstatus; 2043 u16 devstatus;
2046 2044
2047 /* caller owns the udev device lock */ 2045 /* caller owns the udev device lock */
2048 dev_dbg(&udev->dev, "finish %sresume\n", 2046 dev_dbg(&udev->dev, "%s\n",
2049 udev->reset_resume ? "reset-" : ""); 2047 udev->reset_resume ? "finish reset-resume" : "finish resume");
2050 2048
2051 /* usb ch9 identifies four variants of SUSPENDED, based on what 2049 /* usb ch9 identifies four variants of SUSPENDED, based on what
2052 * state the device resumes to. Linux currently won't see the 2050 * state the device resumes to. Linux currently won't see the
@@ -2098,8 +2096,9 @@ static int finish_port_resume(struct usb_device *udev)
2098 NULL, 0, 2096 NULL, 0,
2099 USB_CTRL_SET_TIMEOUT); 2097 USB_CTRL_SET_TIMEOUT);
2100 if (status) 2098 if (status)
2101 dev_dbg(&udev->dev, "disable remote " 2099 dev_dbg(&udev->dev,
2102 "wakeup, status %d\n", status); 2100 "disable remote wakeup, status %d\n",
2101 status);
2103 } 2102 }
2104 status = 0; 2103 status = 0;
2105 } 2104 }
@@ -2140,7 +2139,7 @@ static int finish_port_resume(struct usb_device *udev)
2140 * 2139 *
2141 * Returns 0 on success, else negative errno. 2140 * Returns 0 on success, else negative errno.
2142 */ 2141 */
2143int usb_port_resume(struct usb_device *udev) 2142int usb_port_resume(struct usb_device *udev, pm_message_t msg)
2144{ 2143{
2145 struct usb_hub *hub = hdev_to_hub(udev->parent); 2144 struct usb_hub *hub = hdev_to_hub(udev->parent);
2146 int port1 = udev->portnum; 2145 int port1 = udev->portnum;
@@ -2165,7 +2164,7 @@ int usb_port_resume(struct usb_device *udev)
2165 } else { 2164 } else {
2166 /* drive resume for at least 20 msec */ 2165 /* drive resume for at least 20 msec */
2167 dev_dbg(&udev->dev, "usb %sresume\n", 2166 dev_dbg(&udev->dev, "usb %sresume\n",
2168 udev->auto_pm ? "auto-" : ""); 2167 (msg.event & PM_EVENT_AUTO ? "auto-" : ""));
2169 msleep(25); 2168 msleep(25);
2170 2169
2171 /* Virtual root hubs can trigger on GET_PORT_STATUS to 2170 /* Virtual root hubs can trigger on GET_PORT_STATUS to
@@ -2206,7 +2205,7 @@ static int remote_wakeup(struct usb_device *udev)
2206 if (udev->state == USB_STATE_SUSPENDED) { 2205 if (udev->state == USB_STATE_SUSPENDED) {
2207 dev_dbg(&udev->dev, "usb %sresume\n", "wakeup-"); 2206 dev_dbg(&udev->dev, "usb %sresume\n", "wakeup-");
2208 usb_mark_last_busy(udev); 2207 usb_mark_last_busy(udev);
2209 status = usb_external_resume_device(udev); 2208 status = usb_external_resume_device(udev, PMSG_REMOTE_RESUME);
2210 } 2209 }
2211 return status; 2210 return status;
2212} 2211}
@@ -2215,14 +2214,14 @@ static int remote_wakeup(struct usb_device *udev)
2215 2214
2216/* When CONFIG_USB_SUSPEND isn't set, we never suspend or resume any ports. */ 2215/* When CONFIG_USB_SUSPEND isn't set, we never suspend or resume any ports. */
2217 2216
2218int usb_port_suspend(struct usb_device *udev) 2217int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
2219{ 2218{
2220 return 0; 2219 return 0;
2221} 2220}
2222 2221
2223/* However we may need to do a reset-resume */ 2222/* However we may need to do a reset-resume */
2224 2223
2225int usb_port_resume(struct usb_device *udev) 2224int usb_port_resume(struct usb_device *udev, pm_message_t msg)
2226{ 2225{
2227 struct usb_hub *hub = hdev_to_hub(udev->parent); 2226 struct usb_hub *hub = hdev_to_hub(udev->parent);
2228 int port1 = udev->portnum; 2227 int port1 = udev->portnum;
@@ -2262,7 +2261,7 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
2262 2261
2263 udev = hdev->children [port1-1]; 2262 udev = hdev->children [port1-1];
2264 if (udev && udev->can_submit) { 2263 if (udev && udev->can_submit) {
2265 if (!hdev->auto_pm) 2264 if (!(msg.event & PM_EVENT_AUTO))
2266 dev_dbg(&intf->dev, "port %d nyet suspended\n", 2265 dev_dbg(&intf->dev, "port %d nyet suspended\n",
2267 port1); 2266 port1);
2268 return -EBUSY; 2267 return -EBUSY;
@@ -2385,7 +2384,7 @@ void usb_ep0_reinit(struct usb_device *udev)
2385{ 2384{
2386 usb_disable_endpoint(udev, 0 + USB_DIR_IN); 2385 usb_disable_endpoint(udev, 0 + USB_DIR_IN);
2387 usb_disable_endpoint(udev, 0 + USB_DIR_OUT); 2386 usb_disable_endpoint(udev, 0 + USB_DIR_OUT);
2388 usb_enable_endpoint(udev, &udev->ep0); 2387 usb_enable_endpoint(udev, &udev->ep0, true);
2389} 2388}
2390EXPORT_SYMBOL_GPL(usb_ep0_reinit); 2389EXPORT_SYMBOL_GPL(usb_ep0_reinit);
2391 2390
@@ -2582,9 +2581,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
2582 goto fail; 2581 goto fail;
2583 } 2582 }
2584 if (r) { 2583 if (r) {
2585 dev_err(&udev->dev, "device descriptor " 2584 dev_err(&udev->dev,
2586 "read/%s, error %d\n", 2585 "device descriptor read/64, error %d\n",
2587 "64", r); 2586 r);
2588 retval = -EMSGSIZE; 2587 retval = -EMSGSIZE;
2589 continue; 2588 continue;
2590 } 2589 }
@@ -2621,9 +2620,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
2621 2620
2622 retval = usb_get_device_descriptor(udev, 8); 2621 retval = usb_get_device_descriptor(udev, 8);
2623 if (retval < 8) { 2622 if (retval < 8) {
2624 dev_err(&udev->dev, "device descriptor " 2623 dev_err(&udev->dev,
2625 "read/%s, error %d\n", 2624 "device descriptor read/8, error %d\n",
2626 "8", retval); 2625 retval);
2627 if (retval >= 0) 2626 if (retval >= 0)
2628 retval = -EMSGSIZE; 2627 retval = -EMSGSIZE;
2629 } else { 2628 } else {
@@ -2650,8 +2649,8 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
2650 2649
2651 retval = usb_get_device_descriptor(udev, USB_DT_DEVICE_SIZE); 2650 retval = usb_get_device_descriptor(udev, USB_DT_DEVICE_SIZE);
2652 if (retval < (signed)sizeof(udev->descriptor)) { 2651 if (retval < (signed)sizeof(udev->descriptor)) {
2653 dev_err(&udev->dev, "device descriptor read/%s, error %d\n", 2652 dev_err(&udev->dev, "device descriptor read/all, error %d\n",
2654 "all", retval); 2653 retval);
2655 if (retval >= 0) 2654 if (retval >= 0)
2656 retval = -ENOMSG; 2655 retval = -ENOMSG;
2657 goto fail; 2656 goto fail;
@@ -2719,9 +2718,9 @@ hub_power_remaining (struct usb_hub *hub)
2719 else 2718 else
2720 delta = 8; 2719 delta = 8;
2721 if (delta > hub->mA_per_port) 2720 if (delta > hub->mA_per_port)
2722 dev_warn(&udev->dev, "%dmA is over %umA budget " 2721 dev_warn(&udev->dev,
2723 "for port %d!\n", 2722 "%dmA is over %umA budget for port %d!\n",
2724 delta, hub->mA_per_port, port1); 2723 delta, hub->mA_per_port, port1);
2725 remaining -= delta; 2724 remaining -= delta;
2726 } 2725 }
2727 if (remaining < 0) { 2726 if (remaining < 0) {
@@ -3517,3 +3516,46 @@ int usb_reset_device(struct usb_device *udev)
3517 return ret; 3516 return ret;
3518} 3517}
3519EXPORT_SYMBOL_GPL(usb_reset_device); 3518EXPORT_SYMBOL_GPL(usb_reset_device);
3519
3520
3521/**
3522 * usb_queue_reset_device - Reset a USB device from an atomic context
3523 * @iface: USB interface belonging to the device to reset
3524 *
3525 * This function can be used to reset a USB device from an atomic
3526 * context, where usb_reset_device() won't work (as it blocks).
3527 *
3528 * Doing a reset via this method is functionally equivalent to calling
3529 * usb_reset_device(), except for the fact that it is delayed to a
3530 * workqueue. This means that any drivers bound to other interfaces
3531 * might be unbound, as well as users from usbfs in user space.
3532 *
3533 * Corner cases:
3534 *
3535 * - Scheduling two resets at the same time from two different drivers
3536 * attached to two different interfaces of the same device is
3537 * possible; depending on how the driver attached to each interface
3538 * handles ->pre_reset(), the second reset might happen or not.
3539 *
3540 * - If a driver is unbound and it had a pending reset, the reset will
3541 * be cancelled.
3542 *
3543 * - This function can be called during .probe() or .disconnect()
3544 * times. On return from .disconnect(), any pending resets will be
3545 * cancelled.
3546 *
3547 * There is no no need to lock/unlock the @reset_ws as schedule_work()
3548 * does its own.
3549 *
3550 * NOTE: We don't do any reference count tracking because it is not
3551 * needed. The lifecycle of the work_struct is tied to the
3552 * usb_interface. Before destroying the interface we cancel the
3553 * work_struct, so the fact that work_struct is queued and or
3554 * running means the interface (and thus, the device) exist and
3555 * are referenced.
3556 */
3557void usb_queue_reset_device(struct usb_interface *iface)
3558{
3559 schedule_work(&iface->reset_ws);
3560}
3561EXPORT_SYMBOL_GPL(usb_queue_reset_device);
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 6d1048faf08e..de51667dd64d 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -18,6 +18,8 @@
18#include "hcd.h" /* for usbcore internals */ 18#include "hcd.h" /* for usbcore internals */
19#include "usb.h" 19#include "usb.h"
20 20
21static void cancel_async_set_config(struct usb_device *udev);
22
21struct api_context { 23struct api_context {
22 struct completion done; 24 struct completion done;
23 int status; 25 int status;
@@ -139,9 +141,9 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
139 141
140 dr->bRequestType = requesttype; 142 dr->bRequestType = requesttype;
141 dr->bRequest = request; 143 dr->bRequest = request;
142 dr->wValue = cpu_to_le16p(&value); 144 dr->wValue = cpu_to_le16(value);
143 dr->wIndex = cpu_to_le16p(&index); 145 dr->wIndex = cpu_to_le16(index);
144 dr->wLength = cpu_to_le16p(&size); 146 dr->wLength = cpu_to_le16(size);
145 147
146 /* dbg("usb_control_msg"); */ 148 /* dbg("usb_control_msg"); */
147 149
@@ -1004,6 +1006,34 @@ int usb_clear_halt(struct usb_device *dev, int pipe)
1004} 1006}
1005EXPORT_SYMBOL_GPL(usb_clear_halt); 1007EXPORT_SYMBOL_GPL(usb_clear_halt);
1006 1008
1009static int create_intf_ep_devs(struct usb_interface *intf)
1010{
1011 struct usb_device *udev = interface_to_usbdev(intf);
1012 struct usb_host_interface *alt = intf->cur_altsetting;
1013 int i;
1014
1015 if (intf->ep_devs_created || intf->unregistering)
1016 return 0;
1017
1018 for (i = 0; i < alt->desc.bNumEndpoints; ++i)
1019 (void) usb_create_ep_devs(&intf->dev, &alt->endpoint[i], udev);
1020 intf->ep_devs_created = 1;
1021 return 0;
1022}
1023
1024static void remove_intf_ep_devs(struct usb_interface *intf)
1025{
1026 struct usb_host_interface *alt = intf->cur_altsetting;
1027 int i;
1028
1029 if (!intf->ep_devs_created)
1030 return;
1031
1032 for (i = 0; i < alt->desc.bNumEndpoints; ++i)
1033 usb_remove_ep_devs(&alt->endpoint[i]);
1034 intf->ep_devs_created = 0;
1035}
1036
1007/** 1037/**
1008 * usb_disable_endpoint -- Disable an endpoint by address 1038 * usb_disable_endpoint -- Disable an endpoint by address
1009 * @dev: the device whose endpoint is being disabled 1039 * @dev: the device whose endpoint is being disabled
@@ -1092,7 +1122,7 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
1092 dev_dbg(&dev->dev, "unregistering interface %s\n", 1122 dev_dbg(&dev->dev, "unregistering interface %s\n",
1093 dev_name(&interface->dev)); 1123 dev_name(&interface->dev));
1094 interface->unregistering = 1; 1124 interface->unregistering = 1;
1095 usb_remove_sysfs_intf_files(interface); 1125 remove_intf_ep_devs(interface);
1096 device_del(&interface->dev); 1126 device_del(&interface->dev);
1097 } 1127 }
1098 1128
@@ -1113,22 +1143,26 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
1113 * usb_enable_endpoint - Enable an endpoint for USB communications 1143 * usb_enable_endpoint - Enable an endpoint for USB communications
1114 * @dev: the device whose interface is being enabled 1144 * @dev: the device whose interface is being enabled
1115 * @ep: the endpoint 1145 * @ep: the endpoint
1146 * @reset_toggle: flag to set the endpoint's toggle back to 0
1116 * 1147 *
1117 * Resets the endpoint toggle, and sets dev->ep_{in,out} pointers. 1148 * Resets the endpoint toggle if asked, and sets dev->ep_{in,out} pointers.
1118 * For control endpoints, both the input and output sides are handled. 1149 * For control endpoints, both the input and output sides are handled.
1119 */ 1150 */
1120void usb_enable_endpoint(struct usb_device *dev, struct usb_host_endpoint *ep) 1151void usb_enable_endpoint(struct usb_device *dev, struct usb_host_endpoint *ep,
1152 bool reset_toggle)
1121{ 1153{
1122 int epnum = usb_endpoint_num(&ep->desc); 1154 int epnum = usb_endpoint_num(&ep->desc);
1123 int is_out = usb_endpoint_dir_out(&ep->desc); 1155 int is_out = usb_endpoint_dir_out(&ep->desc);
1124 int is_control = usb_endpoint_xfer_control(&ep->desc); 1156 int is_control = usb_endpoint_xfer_control(&ep->desc);
1125 1157
1126 if (is_out || is_control) { 1158 if (is_out || is_control) {
1127 usb_settoggle(dev, epnum, 1, 0); 1159 if (reset_toggle)
1160 usb_settoggle(dev, epnum, 1, 0);
1128 dev->ep_out[epnum] = ep; 1161 dev->ep_out[epnum] = ep;
1129 } 1162 }
1130 if (!is_out || is_control) { 1163 if (!is_out || is_control) {
1131 usb_settoggle(dev, epnum, 0, 0); 1164 if (reset_toggle)
1165 usb_settoggle(dev, epnum, 0, 0);
1132 dev->ep_in[epnum] = ep; 1166 dev->ep_in[epnum] = ep;
1133 } 1167 }
1134 ep->enabled = 1; 1168 ep->enabled = 1;
@@ -1138,17 +1172,18 @@ void usb_enable_endpoint(struct usb_device *dev, struct usb_host_endpoint *ep)
1138 * usb_enable_interface - Enable all the endpoints for an interface 1172 * usb_enable_interface - Enable all the endpoints for an interface
1139 * @dev: the device whose interface is being enabled 1173 * @dev: the device whose interface is being enabled
1140 * @intf: pointer to the interface descriptor 1174 * @intf: pointer to the interface descriptor
1175 * @reset_toggles: flag to set the endpoints' toggles back to 0
1141 * 1176 *
1142 * Enables all the endpoints for the interface's current altsetting. 1177 * Enables all the endpoints for the interface's current altsetting.
1143 */ 1178 */
1144static void usb_enable_interface(struct usb_device *dev, 1179void usb_enable_interface(struct usb_device *dev,
1145 struct usb_interface *intf) 1180 struct usb_interface *intf, bool reset_toggles)
1146{ 1181{
1147 struct usb_host_interface *alt = intf->cur_altsetting; 1182 struct usb_host_interface *alt = intf->cur_altsetting;
1148 int i; 1183 int i;
1149 1184
1150 for (i = 0; i < alt->desc.bNumEndpoints; ++i) 1185 for (i = 0; i < alt->desc.bNumEndpoints; ++i)
1151 usb_enable_endpoint(dev, &alt->endpoint[i]); 1186 usb_enable_endpoint(dev, &alt->endpoint[i], reset_toggles);
1152} 1187}
1153 1188
1154/** 1189/**
@@ -1235,8 +1270,10 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
1235 */ 1270 */
1236 1271
1237 /* prevent submissions using previous endpoint settings */ 1272 /* prevent submissions using previous endpoint settings */
1238 if (iface->cur_altsetting != alt) 1273 if (iface->cur_altsetting != alt) {
1274 remove_intf_ep_devs(iface);
1239 usb_remove_sysfs_intf_files(iface); 1275 usb_remove_sysfs_intf_files(iface);
1276 }
1240 usb_disable_interface(dev, iface); 1277 usb_disable_interface(dev, iface);
1241 1278
1242 iface->cur_altsetting = alt; 1279 iface->cur_altsetting = alt;
@@ -1271,10 +1308,11 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
1271 * during the SETUP stage - hence EP0 toggles are "don't care" here. 1308 * during the SETUP stage - hence EP0 toggles are "don't care" here.
1272 * (Likewise, EP0 never "halts" on well designed devices.) 1309 * (Likewise, EP0 never "halts" on well designed devices.)
1273 */ 1310 */
1274 usb_enable_interface(dev, iface); 1311 usb_enable_interface(dev, iface, true);
1275 if (device_is_registered(&iface->dev)) 1312 if (device_is_registered(&iface->dev)) {
1276 usb_create_sysfs_intf_files(iface); 1313 usb_create_sysfs_intf_files(iface);
1277 1314 create_intf_ep_devs(iface);
1315 }
1278 return 0; 1316 return 0;
1279} 1317}
1280EXPORT_SYMBOL_GPL(usb_set_interface); 1318EXPORT_SYMBOL_GPL(usb_set_interface);
@@ -1334,7 +1372,6 @@ int usb_reset_configuration(struct usb_device *dev)
1334 struct usb_interface *intf = config->interface[i]; 1372 struct usb_interface *intf = config->interface[i];
1335 struct usb_host_interface *alt; 1373 struct usb_host_interface *alt;
1336 1374
1337 usb_remove_sysfs_intf_files(intf);
1338 alt = usb_altnum_to_altsetting(intf, 0); 1375 alt = usb_altnum_to_altsetting(intf, 0);
1339 1376
1340 /* No altsetting 0? We'll assume the first altsetting. 1377 /* No altsetting 0? We'll assume the first altsetting.
@@ -1345,10 +1382,16 @@ int usb_reset_configuration(struct usb_device *dev)
1345 if (!alt) 1382 if (!alt)
1346 alt = &intf->altsetting[0]; 1383 alt = &intf->altsetting[0];
1347 1384
1385 if (alt != intf->cur_altsetting) {
1386 remove_intf_ep_devs(intf);
1387 usb_remove_sysfs_intf_files(intf);
1388 }
1348 intf->cur_altsetting = alt; 1389 intf->cur_altsetting = alt;
1349 usb_enable_interface(dev, intf); 1390 usb_enable_interface(dev, intf, true);
1350 if (device_is_registered(&intf->dev)) 1391 if (device_is_registered(&intf->dev)) {
1351 usb_create_sysfs_intf_files(intf); 1392 usb_create_sysfs_intf_files(intf);
1393 create_intf_ep_devs(intf);
1394 }
1352 } 1395 }
1353 return 0; 1396 return 0;
1354} 1397}
@@ -1441,6 +1484,46 @@ static struct usb_interface_assoc_descriptor *find_iad(struct usb_device *dev,
1441 return retval; 1484 return retval;
1442} 1485}
1443 1486
1487
1488/*
1489 * Internal function to queue a device reset
1490 *
1491 * This is initialized into the workstruct in 'struct
1492 * usb_device->reset_ws' that is launched by
1493 * message.c:usb_set_configuration() when initializing each 'struct
1494 * usb_interface'.
1495 *
1496 * It is safe to get the USB device without reference counts because
1497 * the life cycle of @iface is bound to the life cycle of @udev. Then,
1498 * this function will be ran only if @iface is alive (and before
1499 * freeing it any scheduled instances of it will have been cancelled).
1500 *
1501 * We need to set a flag (usb_dev->reset_running) because when we call
1502 * the reset, the interfaces might be unbound. The current interface
1503 * cannot try to remove the queued work as it would cause a deadlock
1504 * (you cannot remove your work from within your executing
1505 * workqueue). This flag lets it know, so that
1506 * usb_cancel_queued_reset() doesn't try to do it.
1507 *
1508 * See usb_queue_reset_device() for more details
1509 */
1510void __usb_queue_reset_device(struct work_struct *ws)
1511{
1512 int rc;
1513 struct usb_interface *iface =
1514 container_of(ws, struct usb_interface, reset_ws);
1515 struct usb_device *udev = interface_to_usbdev(iface);
1516
1517 rc = usb_lock_device_for_reset(udev, iface);
1518 if (rc >= 0) {
1519 iface->reset_running = 1;
1520 usb_reset_device(udev);
1521 iface->reset_running = 0;
1522 usb_unlock_device(udev);
1523 }
1524}
1525
1526
1444/* 1527/*
1445 * usb_set_configuration - Makes a particular device setting be current 1528 * usb_set_configuration - Makes a particular device setting be current
1446 * @dev: the device whose configuration is being updated 1529 * @dev: the device whose configuration is being updated
@@ -1560,6 +1643,9 @@ free_interfaces:
1560 if (dev->state != USB_STATE_ADDRESS) 1643 if (dev->state != USB_STATE_ADDRESS)
1561 usb_disable_device(dev, 1); /* Skip ep0 */ 1644 usb_disable_device(dev, 1); /* Skip ep0 */
1562 1645
1646 /* Get rid of pending async Set-Config requests for this device */
1647 cancel_async_set_config(dev);
1648
1563 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1649 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1564 USB_REQ_SET_CONFIGURATION, 0, configuration, 0, 1650 USB_REQ_SET_CONFIGURATION, 0, configuration, 0,
1565 NULL, 0, USB_CTRL_SET_TIMEOUT); 1651 NULL, 0, USB_CTRL_SET_TIMEOUT);
@@ -1604,13 +1690,14 @@ free_interfaces:
1604 alt = &intf->altsetting[0]; 1690 alt = &intf->altsetting[0];
1605 1691
1606 intf->cur_altsetting = alt; 1692 intf->cur_altsetting = alt;
1607 usb_enable_interface(dev, intf); 1693 usb_enable_interface(dev, intf, true);
1608 intf->dev.parent = &dev->dev; 1694 intf->dev.parent = &dev->dev;
1609 intf->dev.driver = NULL; 1695 intf->dev.driver = NULL;
1610 intf->dev.bus = &usb_bus_type; 1696 intf->dev.bus = &usb_bus_type;
1611 intf->dev.type = &usb_if_device_type; 1697 intf->dev.type = &usb_if_device_type;
1612 intf->dev.groups = usb_interface_groups; 1698 intf->dev.groups = usb_interface_groups;
1613 intf->dev.dma_mask = dev->dev.dma_mask; 1699 intf->dev.dma_mask = dev->dev.dma_mask;
1700 INIT_WORK(&intf->reset_ws, __usb_queue_reset_device);
1614 device_initialize(&intf->dev); 1701 device_initialize(&intf->dev);
1615 mark_quiesced(intf); 1702 mark_quiesced(intf);
1616 dev_set_name(&intf->dev, "%d-%s:%d.%d", 1703 dev_set_name(&intf->dev, "%d-%s:%d.%d",
@@ -1641,17 +1728,21 @@ free_interfaces:
1641 dev_name(&intf->dev), ret); 1728 dev_name(&intf->dev), ret);
1642 continue; 1729 continue;
1643 } 1730 }
1644 usb_create_sysfs_intf_files(intf); 1731 create_intf_ep_devs(intf);
1645 } 1732 }
1646 1733
1647 usb_autosuspend_device(dev); 1734 usb_autosuspend_device(dev);
1648 return 0; 1735 return 0;
1649} 1736}
1650 1737
1738static LIST_HEAD(set_config_list);
1739static DEFINE_SPINLOCK(set_config_lock);
1740
1651struct set_config_request { 1741struct set_config_request {
1652 struct usb_device *udev; 1742 struct usb_device *udev;
1653 int config; 1743 int config;
1654 struct work_struct work; 1744 struct work_struct work;
1745 struct list_head node;
1655}; 1746};
1656 1747
1657/* Worker routine for usb_driver_set_configuration() */ 1748/* Worker routine for usb_driver_set_configuration() */
@@ -1659,14 +1750,35 @@ static void driver_set_config_work(struct work_struct *work)
1659{ 1750{
1660 struct set_config_request *req = 1751 struct set_config_request *req =
1661 container_of(work, struct set_config_request, work); 1752 container_of(work, struct set_config_request, work);
1753 struct usb_device *udev = req->udev;
1754
1755 usb_lock_device(udev);
1756 spin_lock(&set_config_lock);
1757 list_del(&req->node);
1758 spin_unlock(&set_config_lock);
1662 1759
1663 usb_lock_device(req->udev); 1760 if (req->config >= -1) /* Is req still valid? */
1664 usb_set_configuration(req->udev, req->config); 1761 usb_set_configuration(udev, req->config);
1665 usb_unlock_device(req->udev); 1762 usb_unlock_device(udev);
1666 usb_put_dev(req->udev); 1763 usb_put_dev(udev);
1667 kfree(req); 1764 kfree(req);
1668} 1765}
1669 1766
1767/* Cancel pending Set-Config requests for a device whose configuration
1768 * was just changed
1769 */
1770static void cancel_async_set_config(struct usb_device *udev)
1771{
1772 struct set_config_request *req;
1773
1774 spin_lock(&set_config_lock);
1775 list_for_each_entry(req, &set_config_list, node) {
1776 if (req->udev == udev)
1777 req->config = -999; /* Mark as cancelled */
1778 }
1779 spin_unlock(&set_config_lock);
1780}
1781
1670/** 1782/**
1671 * usb_driver_set_configuration - Provide a way for drivers to change device configurations 1783 * usb_driver_set_configuration - Provide a way for drivers to change device configurations
1672 * @udev: the device whose configuration is being updated 1784 * @udev: the device whose configuration is being updated
@@ -1698,6 +1810,10 @@ int usb_driver_set_configuration(struct usb_device *udev, int config)
1698 req->config = config; 1810 req->config = config;
1699 INIT_WORK(&req->work, driver_set_config_work); 1811 INIT_WORK(&req->work, driver_set_config_work);
1700 1812
1813 spin_lock(&set_config_lock);
1814 list_add(&req->node, &set_config_list);
1815 spin_unlock(&set_config_lock);
1816
1701 usb_get_dev(udev); 1817 usb_get_dev(udev);
1702 schedule_work(&req->work); 1818 schedule_work(&req->work);
1703 return 0; 1819 return 0;
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 4fb65fdc9dc3..4cc2456ef3be 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -359,19 +359,19 @@ set_level(struct device *dev, struct device_attribute *attr,
359 strncmp(buf, on_string, len) == 0) { 359 strncmp(buf, on_string, len) == 0) {
360 udev->autosuspend_disabled = 1; 360 udev->autosuspend_disabled = 1;
361 udev->autoresume_disabled = 0; 361 udev->autoresume_disabled = 0;
362 rc = usb_external_resume_device(udev); 362 rc = usb_external_resume_device(udev, PMSG_USER_RESUME);
363 363
364 } else if (len == sizeof auto_string - 1 && 364 } else if (len == sizeof auto_string - 1 &&
365 strncmp(buf, auto_string, len) == 0) { 365 strncmp(buf, auto_string, len) == 0) {
366 udev->autosuspend_disabled = 0; 366 udev->autosuspend_disabled = 0;
367 udev->autoresume_disabled = 0; 367 udev->autoresume_disabled = 0;
368 rc = usb_external_resume_device(udev); 368 rc = usb_external_resume_device(udev, PMSG_USER_RESUME);
369 369
370 } else if (len == sizeof suspend_string - 1 && 370 } else if (len == sizeof suspend_string - 1 &&
371 strncmp(buf, suspend_string, len) == 0) { 371 strncmp(buf, suspend_string, len) == 0) {
372 udev->autosuspend_disabled = 0; 372 udev->autosuspend_disabled = 0;
373 udev->autoresume_disabled = 1; 373 udev->autoresume_disabled = 1;
374 rc = usb_external_suspend_device(udev, PMSG_SUSPEND); 374 rc = usb_external_suspend_device(udev, PMSG_USER_SUSPEND);
375 375
376 } else 376 } else
377 rc = -EINVAL; 377 rc = -EINVAL;
@@ -629,9 +629,6 @@ int usb_create_sysfs_dev_files(struct usb_device *udev)
629 struct device *dev = &udev->dev; 629 struct device *dev = &udev->dev;
630 int retval; 630 int retval;
631 631
632 /* Unforunately these attributes cannot be created before
633 * the uevent is broadcast.
634 */
635 retval = device_create_bin_file(dev, &dev_bin_attr_descriptors); 632 retval = device_create_bin_file(dev, &dev_bin_attr_descriptors);
636 if (retval) 633 if (retval)
637 goto error; 634 goto error;
@@ -643,11 +640,7 @@ int usb_create_sysfs_dev_files(struct usb_device *udev)
643 retval = add_power_attributes(dev); 640 retval = add_power_attributes(dev);
644 if (retval) 641 if (retval)
645 goto error; 642 goto error;
646 643 return retval;
647 retval = usb_create_ep_files(dev, &udev->ep0, udev);
648 if (retval)
649 goto error;
650 return 0;
651error: 644error:
652 usb_remove_sysfs_dev_files(udev); 645 usb_remove_sysfs_dev_files(udev);
653 return retval; 646 return retval;
@@ -657,7 +650,6 @@ void usb_remove_sysfs_dev_files(struct usb_device *udev)
657{ 650{
658 struct device *dev = &udev->dev; 651 struct device *dev = &udev->dev;
659 652
660 usb_remove_ep_files(&udev->ep0);
661 remove_power_attributes(dev); 653 remove_power_attributes(dev);
662 remove_persist_attributes(dev); 654 remove_persist_attributes(dev);
663 device_remove_bin_file(dev, &dev_bin_attr_descriptors); 655 device_remove_bin_file(dev, &dev_bin_attr_descriptors);
@@ -812,28 +804,6 @@ struct attribute_group *usb_interface_groups[] = {
812 NULL 804 NULL
813}; 805};
814 806
815static inline void usb_create_intf_ep_files(struct usb_interface *intf,
816 struct usb_device *udev)
817{
818 struct usb_host_interface *iface_desc;
819 int i;
820
821 iface_desc = intf->cur_altsetting;
822 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i)
823 usb_create_ep_files(&intf->dev, &iface_desc->endpoint[i],
824 udev);
825}
826
827static inline void usb_remove_intf_ep_files(struct usb_interface *intf)
828{
829 struct usb_host_interface *iface_desc;
830 int i;
831
832 iface_desc = intf->cur_altsetting;
833 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i)
834 usb_remove_ep_files(&iface_desc->endpoint[i]);
835}
836
837int usb_create_sysfs_intf_files(struct usb_interface *intf) 807int usb_create_sysfs_intf_files(struct usb_interface *intf)
838{ 808{
839 struct usb_device *udev = interface_to_usbdev(intf); 809 struct usb_device *udev = interface_to_usbdev(intf);
@@ -843,26 +813,19 @@ int usb_create_sysfs_intf_files(struct usb_interface *intf)
843 if (intf->sysfs_files_created || intf->unregistering) 813 if (intf->sysfs_files_created || intf->unregistering)
844 return 0; 814 return 0;
845 815
846 /* The interface string may be present in some altsettings
847 * and missing in others. Hence its attribute cannot be created
848 * before the uevent is broadcast.
849 */
850 if (alt->string == NULL) 816 if (alt->string == NULL)
851 alt->string = usb_cache_string(udev, alt->desc.iInterface); 817 alt->string = usb_cache_string(udev, alt->desc.iInterface);
852 if (alt->string) 818 if (alt->string)
853 retval = device_create_file(&intf->dev, &dev_attr_interface); 819 retval = device_create_file(&intf->dev, &dev_attr_interface);
854 usb_create_intf_ep_files(intf, udev);
855 intf->sysfs_files_created = 1; 820 intf->sysfs_files_created = 1;
856 return 0; 821 return 0;
857} 822}
858 823
859void usb_remove_sysfs_intf_files(struct usb_interface *intf) 824void usb_remove_sysfs_intf_files(struct usb_interface *intf)
860{ 825{
861 struct device *dev = &intf->dev;
862
863 if (!intf->sysfs_files_created) 826 if (!intf->sysfs_files_created)
864 return; 827 return;
865 usb_remove_intf_ep_files(intf); 828
866 device_remove_file(dev, &dev_attr_interface); 829 device_remove_file(&intf->dev, &dev_attr_interface);
867 intf->sysfs_files_created = 0; 830 intf->sysfs_files_created = 0;
868} 831}
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 1f68af9db3f7..58bc5e3c2560 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -10,7 +10,6 @@
10 10
11#define to_urb(d) container_of(d, struct urb, kref) 11#define to_urb(d) container_of(d, struct urb, kref)
12 12
13static DEFINE_SPINLOCK(usb_reject_lock);
14 13
15static void urb_destroy(struct kref *kref) 14static void urb_destroy(struct kref *kref)
16{ 15{
@@ -131,9 +130,7 @@ void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor)
131 urb->anchor = anchor; 130 urb->anchor = anchor;
132 131
133 if (unlikely(anchor->poisoned)) { 132 if (unlikely(anchor->poisoned)) {
134 spin_lock(&usb_reject_lock); 133 atomic_inc(&urb->reject);
135 urb->reject++;
136 spin_unlock(&usb_reject_lock);
137 } 134 }
138 135
139 spin_unlock_irqrestore(&anchor->lock, flags); 136 spin_unlock_irqrestore(&anchor->lock, flags);
@@ -565,16 +562,12 @@ void usb_kill_urb(struct urb *urb)
565 might_sleep(); 562 might_sleep();
566 if (!(urb && urb->dev && urb->ep)) 563 if (!(urb && urb->dev && urb->ep))
567 return; 564 return;
568 spin_lock_irq(&usb_reject_lock); 565 atomic_inc(&urb->reject);
569 ++urb->reject;
570 spin_unlock_irq(&usb_reject_lock);
571 566
572 usb_hcd_unlink_urb(urb, -ENOENT); 567 usb_hcd_unlink_urb(urb, -ENOENT);
573 wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); 568 wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0);
574 569
575 spin_lock_irq(&usb_reject_lock); 570 atomic_dec(&urb->reject);
576 --urb->reject;
577 spin_unlock_irq(&usb_reject_lock);
578} 571}
579EXPORT_SYMBOL_GPL(usb_kill_urb); 572EXPORT_SYMBOL_GPL(usb_kill_urb);
580 573
@@ -606,9 +599,7 @@ void usb_poison_urb(struct urb *urb)
606 might_sleep(); 599 might_sleep();
607 if (!(urb && urb->dev && urb->ep)) 600 if (!(urb && urb->dev && urb->ep))
608 return; 601 return;
609 spin_lock_irq(&usb_reject_lock); 602 atomic_inc(&urb->reject);
610 ++urb->reject;
611 spin_unlock_irq(&usb_reject_lock);
612 603
613 usb_hcd_unlink_urb(urb, -ENOENT); 604 usb_hcd_unlink_urb(urb, -ENOENT);
614 wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); 605 wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0);
@@ -617,14 +608,10 @@ EXPORT_SYMBOL_GPL(usb_poison_urb);
617 608
618void usb_unpoison_urb(struct urb *urb) 609void usb_unpoison_urb(struct urb *urb)
619{ 610{
620 unsigned long flags;
621
622 if (!urb) 611 if (!urb)
623 return; 612 return;
624 613
625 spin_lock_irqsave(&usb_reject_lock, flags); 614 atomic_dec(&urb->reject);
626 --urb->reject;
627 spin_unlock_irqrestore(&usb_reject_lock, flags);
628} 615}
629EXPORT_SYMBOL_GPL(usb_unpoison_urb); 616EXPORT_SYMBOL_GPL(usb_unpoison_urb);
630 617
@@ -692,6 +679,26 @@ void usb_poison_anchored_urbs(struct usb_anchor *anchor)
692EXPORT_SYMBOL_GPL(usb_poison_anchored_urbs); 679EXPORT_SYMBOL_GPL(usb_poison_anchored_urbs);
693 680
694/** 681/**
682 * usb_unpoison_anchored_urbs - let an anchor be used successfully again
683 * @anchor: anchor the requests are bound to
684 *
685 * Reverses the effect of usb_poison_anchored_urbs
686 * the anchor can be used normally after it returns
687 */
688void usb_unpoison_anchored_urbs(struct usb_anchor *anchor)
689{
690 unsigned long flags;
691 struct urb *lazarus;
692
693 spin_lock_irqsave(&anchor->lock, flags);
694 list_for_each_entry(lazarus, &anchor->urb_list, anchor_list) {
695 usb_unpoison_urb(lazarus);
696 }
697 anchor->poisoned = 0;
698 spin_unlock_irqrestore(&anchor->lock, flags);
699}
700EXPORT_SYMBOL_GPL(usb_unpoison_anchored_urbs);
701/**
695 * usb_unlink_anchored_urbs - asynchronously cancel transfer requests en masse 702 * usb_unlink_anchored_urbs - asynchronously cancel transfer requests en masse
696 * @anchor: anchor the requests are bound to 703 * @anchor: anchor the requests are bound to
697 * 704 *
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 399e15fc5052..dcfc072630c1 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -253,7 +253,7 @@ static int usb_dev_prepare(struct device *dev)
253static void usb_dev_complete(struct device *dev) 253static void usb_dev_complete(struct device *dev)
254{ 254{
255 /* Currently used only for rebinding interfaces */ 255 /* Currently used only for rebinding interfaces */
256 usb_resume(dev); /* Implement eventually? */ 256 usb_resume(dev, PMSG_RESUME); /* Message event is meaningless */
257} 257}
258 258
259static int usb_dev_suspend(struct device *dev) 259static int usb_dev_suspend(struct device *dev)
@@ -263,7 +263,7 @@ static int usb_dev_suspend(struct device *dev)
263 263
264static int usb_dev_resume(struct device *dev) 264static int usb_dev_resume(struct device *dev)
265{ 265{
266 return usb_resume(dev); 266 return usb_resume(dev, PMSG_RESUME);
267} 267}
268 268
269static int usb_dev_freeze(struct device *dev) 269static int usb_dev_freeze(struct device *dev)
@@ -273,7 +273,7 @@ static int usb_dev_freeze(struct device *dev)
273 273
274static int usb_dev_thaw(struct device *dev) 274static int usb_dev_thaw(struct device *dev)
275{ 275{
276 return usb_resume(dev); 276 return usb_resume(dev, PMSG_THAW);
277} 277}
278 278
279static int usb_dev_poweroff(struct device *dev) 279static int usb_dev_poweroff(struct device *dev)
@@ -283,7 +283,7 @@ static int usb_dev_poweroff(struct device *dev)
283 283
284static int usb_dev_restore(struct device *dev) 284static int usb_dev_restore(struct device *dev)
285{ 285{
286 return usb_resume(dev); 286 return usb_resume(dev, PMSG_RESTORE);
287} 287}
288 288
289static struct dev_pm_ops usb_device_pm_ops = { 289static struct dev_pm_ops usb_device_pm_ops = {
@@ -362,7 +362,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
362 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE; 362 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
363 dev->ep0.desc.bDescriptorType = USB_DT_ENDPOINT; 363 dev->ep0.desc.bDescriptorType = USB_DT_ENDPOINT;
364 /* ep0 maxpacket comes later, from device descriptor */ 364 /* ep0 maxpacket comes later, from device descriptor */
365 usb_enable_endpoint(dev, &dev->ep0); 365 usb_enable_endpoint(dev, &dev->ep0, true);
366 dev->can_submit = 1; 366 dev->can_submit = 1;
367 367
368 /* Save readable and stable topology id, distinguishing devices 368 /* Save readable and stable topology id, distinguishing devices
@@ -402,6 +402,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
402#ifdef CONFIG_PM 402#ifdef CONFIG_PM
403 mutex_init(&dev->pm_mutex); 403 mutex_init(&dev->pm_mutex);
404 INIT_DELAYED_WORK(&dev->autosuspend, usb_autosuspend_work); 404 INIT_DELAYED_WORK(&dev->autosuspend, usb_autosuspend_work);
405 INIT_WORK(&dev->autoresume, usb_autoresume_work);
405 dev->autosuspend_delay = usb_autosuspend_delay * HZ; 406 dev->autosuspend_delay = usb_autosuspend_delay * HZ;
406 dev->connect_time = jiffies; 407 dev->connect_time = jiffies;
407 dev->active_duration = -jiffies; 408 dev->active_duration = -jiffies;
@@ -513,10 +514,7 @@ EXPORT_SYMBOL_GPL(usb_put_intf);
513 * disconnect; in some drivers (such as usb-storage) the disconnect() 514 * disconnect; in some drivers (such as usb-storage) the disconnect()
514 * or suspend() method will block waiting for a device reset to complete. 515 * or suspend() method will block waiting for a device reset to complete.
515 * 516 *
516 * Returns a negative error code for failure, otherwise 1 or 0 to indicate 517 * Returns a negative error code for failure, otherwise 0.
517 * that the device will or will not have to be unlocked. (0 can be
518 * returned when an interface is given and is BINDING, because in that
519 * case the driver already owns the device lock.)
520 */ 518 */
521int usb_lock_device_for_reset(struct usb_device *udev, 519int usb_lock_device_for_reset(struct usb_device *udev,
522 const struct usb_interface *iface) 520 const struct usb_interface *iface)
@@ -527,16 +525,9 @@ int usb_lock_device_for_reset(struct usb_device *udev,
527 return -ENODEV; 525 return -ENODEV;
528 if (udev->state == USB_STATE_SUSPENDED) 526 if (udev->state == USB_STATE_SUSPENDED)
529 return -EHOSTUNREACH; 527 return -EHOSTUNREACH;
530 if (iface) { 528 if (iface && (iface->condition == USB_INTERFACE_UNBINDING ||
531 switch (iface->condition) { 529 iface->condition == USB_INTERFACE_UNBOUND))
532 case USB_INTERFACE_BINDING: 530 return -EINTR;
533 return 0;
534 case USB_INTERFACE_BOUND:
535 break;
536 default:
537 return -EINTR;
538 }
539 }
540 531
541 while (usb_trylock_device(udev) != 0) { 532 while (usb_trylock_device(udev) != 0) {
542 533
@@ -550,10 +541,11 @@ int usb_lock_device_for_reset(struct usb_device *udev,
550 return -ENODEV; 541 return -ENODEV;
551 if (udev->state == USB_STATE_SUSPENDED) 542 if (udev->state == USB_STATE_SUSPENDED)
552 return -EHOSTUNREACH; 543 return -EHOSTUNREACH;
553 if (iface && iface->condition != USB_INTERFACE_BOUND) 544 if (iface && (iface->condition == USB_INTERFACE_UNBINDING ||
545 iface->condition == USB_INTERFACE_UNBOUND))
554 return -EINTR; 546 return -EINTR;
555 } 547 }
556 return 1; 548 return 0;
557} 549}
558EXPORT_SYMBOL_GPL(usb_lock_device_for_reset); 550EXPORT_SYMBOL_GPL(usb_lock_device_for_reset);
559 551
@@ -962,8 +954,12 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
962} 954}
963EXPORT_SYMBOL_GPL(usb_buffer_unmap_sg); 955EXPORT_SYMBOL_GPL(usb_buffer_unmap_sg);
964 956
965/* format to disable USB on kernel command line is: nousb */ 957/* To disable USB, kernel command line is 'nousb' not 'usbcore.nousb' */
966__module_param_call("", nousb, param_set_bool, param_get_bool, &nousb, 0444); 958#ifdef MODULE
959module_param(nousb, bool, 0444);
960#else
961core_param(nousb, nousb, bool, 0444);
962#endif
967 963
968/* 964/*
969 * for external read access to <nousb> 965 * for external read access to <nousb>
@@ -975,6 +971,37 @@ int usb_disabled(void)
975EXPORT_SYMBOL_GPL(usb_disabled); 971EXPORT_SYMBOL_GPL(usb_disabled);
976 972
977/* 973/*
974 * Notifications of device and interface registration
975 */
976static int usb_bus_notify(struct notifier_block *nb, unsigned long action,
977 void *data)
978{
979 struct device *dev = data;
980
981 switch (action) {
982 case BUS_NOTIFY_ADD_DEVICE:
983 if (dev->type == &usb_device_type)
984 (void) usb_create_sysfs_dev_files(to_usb_device(dev));
985 else if (dev->type == &usb_if_device_type)
986 (void) usb_create_sysfs_intf_files(
987 to_usb_interface(dev));
988 break;
989
990 case BUS_NOTIFY_DEL_DEVICE:
991 if (dev->type == &usb_device_type)
992 usb_remove_sysfs_dev_files(to_usb_device(dev));
993 else if (dev->type == &usb_if_device_type)
994 usb_remove_sysfs_intf_files(to_usb_interface(dev));
995 break;
996 }
997 return 0;
998}
999
1000static struct notifier_block usb_bus_nb = {
1001 .notifier_call = usb_bus_notify,
1002};
1003
1004/*
978 * Init 1005 * Init
979 */ 1006 */
980static int __init usb_init(void) 1007static int __init usb_init(void)
@@ -991,6 +1018,9 @@ static int __init usb_init(void)
991 retval = bus_register(&usb_bus_type); 1018 retval = bus_register(&usb_bus_type);
992 if (retval) 1019 if (retval)
993 goto bus_register_failed; 1020 goto bus_register_failed;
1021 retval = bus_register_notifier(&usb_bus_type, &usb_bus_nb);
1022 if (retval)
1023 goto bus_notifier_failed;
994 retval = usb_host_init(); 1024 retval = usb_host_init();
995 if (retval) 1025 if (retval)
996 goto host_init_failed; 1026 goto host_init_failed;
@@ -1025,6 +1055,8 @@ driver_register_failed:
1025major_init_failed: 1055major_init_failed:
1026 usb_host_cleanup(); 1056 usb_host_cleanup();
1027host_init_failed: 1057host_init_failed:
1058 bus_unregister_notifier(&usb_bus_type, &usb_bus_nb);
1059bus_notifier_failed:
1028 bus_unregister(&usb_bus_type); 1060 bus_unregister(&usb_bus_type);
1029bus_register_failed: 1061bus_register_failed:
1030 ksuspend_usb_cleanup(); 1062 ksuspend_usb_cleanup();
@@ -1048,6 +1080,7 @@ static void __exit usb_exit(void)
1048 usb_devio_cleanup(); 1080 usb_devio_cleanup();
1049 usb_hub_cleanup(); 1081 usb_hub_cleanup();
1050 usb_host_cleanup(); 1082 usb_host_cleanup();
1083 bus_unregister_notifier(&usb_bus_type, &usb_bus_nb);
1051 bus_unregister(&usb_bus_type); 1084 bus_unregister(&usb_bus_type);
1052 ksuspend_usb_cleanup(); 1085 ksuspend_usb_cleanup();
1053} 1086}
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 9a1a45ac3add..386177867a8a 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -1,16 +1,20 @@
1#include <linux/pm.h>
2
1/* Functions local to drivers/usb/core/ */ 3/* Functions local to drivers/usb/core/ */
2 4
3extern int usb_create_sysfs_dev_files(struct usb_device *dev); 5extern int usb_create_sysfs_dev_files(struct usb_device *dev);
4extern void usb_remove_sysfs_dev_files(struct usb_device *dev); 6extern void usb_remove_sysfs_dev_files(struct usb_device *dev);
5extern int usb_create_sysfs_intf_files(struct usb_interface *intf); 7extern int usb_create_sysfs_intf_files(struct usb_interface *intf);
6extern void usb_remove_sysfs_intf_files(struct usb_interface *intf); 8extern void usb_remove_sysfs_intf_files(struct usb_interface *intf);
7extern int usb_create_ep_files(struct device *parent, 9extern int usb_create_ep_devs(struct device *parent,
8 struct usb_host_endpoint *endpoint, 10 struct usb_host_endpoint *endpoint,
9 struct usb_device *udev); 11 struct usb_device *udev);
10extern void usb_remove_ep_files(struct usb_host_endpoint *endpoint); 12extern void usb_remove_ep_devs(struct usb_host_endpoint *endpoint);
11 13
12extern void usb_enable_endpoint(struct usb_device *dev, 14extern void usb_enable_endpoint(struct usb_device *dev,
13 struct usb_host_endpoint *ep); 15 struct usb_host_endpoint *ep, bool reset_toggle);
16extern void usb_enable_interface(struct usb_device *dev,
17 struct usb_interface *intf, bool reset_toggles);
14extern void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr); 18extern void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr);
15extern void usb_disable_interface(struct usb_device *dev, 19extern void usb_disable_interface(struct usb_device *dev,
16 struct usb_interface *intf); 20 struct usb_interface *intf);
@@ -42,14 +46,16 @@ extern void usb_host_cleanup(void);
42#ifdef CONFIG_PM 46#ifdef CONFIG_PM
43 47
44extern int usb_suspend(struct device *dev, pm_message_t msg); 48extern int usb_suspend(struct device *dev, pm_message_t msg);
45extern int usb_resume(struct device *dev); 49extern int usb_resume(struct device *dev, pm_message_t msg);
46 50
47extern void usb_autosuspend_work(struct work_struct *work); 51extern void usb_autosuspend_work(struct work_struct *work);
48extern int usb_port_suspend(struct usb_device *dev); 52extern void usb_autoresume_work(struct work_struct *work);
49extern int usb_port_resume(struct usb_device *dev); 53extern int usb_port_suspend(struct usb_device *dev, pm_message_t msg);
54extern int usb_port_resume(struct usb_device *dev, pm_message_t msg);
50extern int usb_external_suspend_device(struct usb_device *udev, 55extern int usb_external_suspend_device(struct usb_device *udev,
51 pm_message_t msg); 56 pm_message_t msg);
52extern int usb_external_resume_device(struct usb_device *udev); 57extern int usb_external_resume_device(struct usb_device *udev,
58 pm_message_t msg);
53 59
54static inline void usb_pm_lock(struct usb_device *udev) 60static inline void usb_pm_lock(struct usb_device *udev)
55{ 61{
@@ -63,12 +69,12 @@ static inline void usb_pm_unlock(struct usb_device *udev)
63 69
64#else 70#else
65 71
66static inline int usb_port_suspend(struct usb_device *udev) 72static inline int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
67{ 73{
68 return 0; 74 return 0;
69} 75}
70 76
71static inline int usb_port_resume(struct usb_device *udev) 77static inline int usb_port_resume(struct usb_device *udev, pm_message_t msg)
72{ 78{
73 return 0; 79 return 0;
74} 80}
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index dd4cd5a51370..3219d137340a 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -297,13 +297,34 @@ config USB_S3C2410_DEBUG
297 297
298# musb builds in ../musb along with host support 298# musb builds in ../musb along with host support
299config USB_GADGET_MUSB_HDRC 299config USB_GADGET_MUSB_HDRC
300 boolean "Inventra HDRC USB Peripheral (TI, ...)" 300 boolean "Inventra HDRC USB Peripheral (TI, ADI, ...)"
301 depends on USB_MUSB_HDRC && (USB_MUSB_PERIPHERAL || USB_MUSB_OTG) 301 depends on USB_MUSB_HDRC && (USB_MUSB_PERIPHERAL || USB_MUSB_OTG)
302 select USB_GADGET_DUALSPEED 302 select USB_GADGET_DUALSPEED
303 select USB_GADGET_SELECTED 303 select USB_GADGET_SELECTED
304 help 304 help
305 This OTG-capable silicon IP is used in dual designs including 305 This OTG-capable silicon IP is used in dual designs including
306 the TI DaVinci, OMAP 243x, OMAP 343x, and TUSB 6010. 306 the TI DaVinci, OMAP 243x, OMAP 343x, TUSB 6010, and ADI Blackfin
307
308config USB_GADGET_IMX
309 boolean "Freescale IMX USB Peripheral Controller"
310 depends on ARCH_MX1
311 help
312 Freescale's IMX series include an integrated full speed
313 USB 1.1 device controller. The controller in the IMX series
314 is register-compatible.
315
316 It has Six fixed-function endpoints, as well as endpoint
317 zero (for control transfers).
318
319 Say "y" to link the driver statically, or "m" to build a
320 dynamically linked module called "imx_udc" and force all
321 gadget drivers to also be dynamically linked.
322
323config USB_IMX
324 tristate
325 depends on USB_GADGET_IMX
326 default USB_GADGET
327 select USB_GADGET_SELECTED
307 328
308config USB_GADGET_M66592 329config USB_GADGET_M66592
309 boolean "Renesas M66592 USB Peripheral Controller" 330 boolean "Renesas M66592 USB Peripheral Controller"
@@ -377,6 +398,24 @@ config USB_FSL_QE
377 default USB_GADGET 398 default USB_GADGET
378 select USB_GADGET_SELECTED 399 select USB_GADGET_SELECTED
379 400
401config USB_GADGET_CI13XXX
402 boolean "MIPS USB CI13xxx"
403 depends on PCI
404 select USB_GADGET_DUALSPEED
405 help
406 MIPS USB IP core family device controller
407 Currently it only supports IP part number CI13412
408
409 Say "y" to link the driver statically, or "m" to build a
410 dynamically linked module called "ci13xxx_udc" and force all
411 gadget drivers to also be dynamically linked.
412
413config USB_CI13XXX
414 tristate
415 depends on USB_GADGET_CI13XXX
416 default USB_GADGET
417 select USB_GADGET_SELECTED
418
380config USB_GADGET_NET2280 419config USB_GADGET_NET2280
381 boolean "NetChip 228x" 420 boolean "NetChip 228x"
382 depends on PCI 421 depends on PCI
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index bd4041b47dce..39a51d746cb7 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_USB_NET2280) += net2280.o
10obj-$(CONFIG_USB_AMD5536UDC) += amd5536udc.o 10obj-$(CONFIG_USB_AMD5536UDC) += amd5536udc.o
11obj-$(CONFIG_USB_PXA25X) += pxa25x_udc.o 11obj-$(CONFIG_USB_PXA25X) += pxa25x_udc.o
12obj-$(CONFIG_USB_PXA27X) += pxa27x_udc.o 12obj-$(CONFIG_USB_PXA27X) += pxa27x_udc.o
13obj-$(CONFIG_USB_IMX) += imx_udc.o
13obj-$(CONFIG_USB_GOKU) += goku_udc.o 14obj-$(CONFIG_USB_GOKU) += goku_udc.o
14obj-$(CONFIG_USB_OMAP) += omap_udc.o 15obj-$(CONFIG_USB_OMAP) += omap_udc.o
15obj-$(CONFIG_USB_LH7A40X) += lh7a40x_udc.o 16obj-$(CONFIG_USB_LH7A40X) += lh7a40x_udc.o
@@ -19,6 +20,7 @@ obj-$(CONFIG_USB_ATMEL_USBA) += atmel_usba_udc.o
19obj-$(CONFIG_USB_FSL_USB2) += fsl_usb2_udc.o 20obj-$(CONFIG_USB_FSL_USB2) += fsl_usb2_udc.o
20obj-$(CONFIG_USB_M66592) += m66592-udc.o 21obj-$(CONFIG_USB_M66592) += m66592-udc.o
21obj-$(CONFIG_USB_FSL_QE) += fsl_qe_udc.o 22obj-$(CONFIG_USB_FSL_QE) += fsl_qe_udc.o
23obj-$(CONFIG_USB_CI13XXX) += ci13xxx_udc.o
22 24
23# 25#
24# USB gadget drivers 26# USB gadget drivers
diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c
new file mode 100644
index 000000000000..bebf911c7e5f
--- /dev/null
+++ b/drivers/usb/gadget/ci13xxx_udc.c
@@ -0,0 +1,2830 @@
1/*
2 * ci13xxx_udc.c - MIPS USB IP core family device controller
3 *
4 * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved.
5 *
6 * Author: David Lopo
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13/*
14 * Description: MIPS USB IP core family device controller
15 * Currently it only supports IP part number CI13412
16 *
17 * This driver is composed of several blocks:
18 * - HW: hardware interface
19 * - DBG: debug facilities (optional)
20 * - UTIL: utilities
21 * - ISR: interrupts handling
22 * - ENDPT: endpoint operations (Gadget API)
23 * - GADGET: gadget operations (Gadget API)
24 * - BUS: bus glue code, bus abstraction layer
25 * - PCI: PCI core interface and PCI resources (interrupts, memory...)
26 *
27 * Compile Options
28 * - CONFIG_USB_GADGET_DEBUG_FILES: enable debug facilities
29 * - STALL_IN: non-empty bulk-in pipes cannot be halted
30 * if defined mass storage compliance succeeds but with warnings
31 * => case 4: Hi > Dn
32 * => case 5: Hi > Di
33 * => case 8: Hi <> Do
34 * if undefined usbtest 13 fails
35 * - TRACE: enable function tracing (depends on DEBUG)
36 *
37 * Main Features
38 * - Chapter 9 & Mass Storage Compliance with Gadget File Storage
39 * - Chapter 9 Compliance with Gadget Zero (STALL_IN undefined)
40 * - Normal & LPM support
41 *
42 * USBTEST Report
43 * - OK: 0-12, 13 (STALL_IN defined) & 14
44 * - Not Supported: 15 & 16 (ISO)
45 *
46 * TODO List
47 * - OTG
48 * - Isochronous & Interrupt Traffic
49 * - Handle requests which spawns into several TDs
50 * - GET_STATUS(device) - always reports 0
51 * - Gadget API (majority of optional features)
52 * - Suspend & Remote Wakeup
53 */
54#include <linux/device.h>
55#include <linux/dmapool.h>
56#include <linux/dma-mapping.h>
57#include <linux/init.h>
58#include <linux/interrupt.h>
59#include <linux/interrupt.h>
60#include <linux/io.h>
61#include <linux/irq.h>
62#include <linux/kernel.h>
63#include <linux/module.h>
64#include <linux/pci.h>
65#include <linux/usb/ch9.h>
66#include <linux/usb/gadget.h>
67
68#include "ci13xxx_udc.h"
69
70
71/******************************************************************************
72 * DEFINE
73 *****************************************************************************/
74/* ctrl register bank access */
75static DEFINE_SPINLOCK(udc_lock);
76
77/* driver name */
78#define UDC_DRIVER_NAME "ci13xxx_udc"
79
80/* control endpoint description */
81static const struct usb_endpoint_descriptor
82ctrl_endpt_desc = {
83 .bLength = USB_DT_ENDPOINT_SIZE,
84 .bDescriptorType = USB_DT_ENDPOINT,
85
86 .bmAttributes = USB_ENDPOINT_XFER_CONTROL,
87 .wMaxPacketSize = cpu_to_le16(CTRL_PAYLOAD_MAX),
88};
89
90/* UDC descriptor */
91static struct ci13xxx *_udc;
92
93/* Interrupt statistics */
94#define ISR_MASK 0x1F
95static struct {
96 u32 test;
97 u32 ui;
98 u32 uei;
99 u32 pci;
100 u32 uri;
101 u32 sli;
102 u32 none;
103 struct {
104 u32 cnt;
105 u32 buf[ISR_MASK+1];
106 u32 idx;
107 } hndl;
108} isr_statistics;
109
110/**
111 * ffs_nr: find first (least significant) bit set
112 * @x: the word to search
113 *
114 * This function returns bit number (instead of position)
115 */
116static int ffs_nr(u32 x)
117{
118 int n = ffs(x);
119
120 return n ? n-1 : 32;
121}
122
123/******************************************************************************
124 * HW block
125 *****************************************************************************/
126/* register bank descriptor */
127static struct {
128 unsigned lpm; /* is LPM? */
129 void __iomem *abs; /* bus map offset */
130 void __iomem *cap; /* bus map offset + CAP offset + CAP data */
131 size_t size; /* bank size */
132} hw_bank;
133
134/* UDC register map */
135#define ABS_CAPLENGTH (0x100UL)
136#define ABS_HCCPARAMS (0x108UL)
137#define ABS_DCCPARAMS (0x124UL)
138#define ABS_TESTMODE (hw_bank.lpm ? 0x0FCUL : 0x138UL)
139/* offset to CAPLENTGH (addr + data) */
140#define CAP_USBCMD (0x000UL)
141#define CAP_USBSTS (0x004UL)
142#define CAP_USBINTR (0x008UL)
143#define CAP_DEVICEADDR (0x014UL)
144#define CAP_ENDPTLISTADDR (0x018UL)
145#define CAP_PORTSC (0x044UL)
146#define CAP_DEVLC (0x0B4UL)
147#define CAP_USBMODE (hw_bank.lpm ? 0x0C8UL : 0x068UL)
148#define CAP_ENDPTSETUPSTAT (hw_bank.lpm ? 0x0D8UL : 0x06CUL)
149#define CAP_ENDPTPRIME (hw_bank.lpm ? 0x0DCUL : 0x070UL)
150#define CAP_ENDPTFLUSH (hw_bank.lpm ? 0x0E0UL : 0x074UL)
151#define CAP_ENDPTSTAT (hw_bank.lpm ? 0x0E4UL : 0x078UL)
152#define CAP_ENDPTCOMPLETE (hw_bank.lpm ? 0x0E8UL : 0x07CUL)
153#define CAP_ENDPTCTRL (hw_bank.lpm ? 0x0ECUL : 0x080UL)
154#define CAP_LAST (hw_bank.lpm ? 0x12CUL : 0x0C0UL)
155
156/* maximum number of enpoints: valid only after hw_device_reset() */
157static unsigned hw_ep_max;
158
159/**
160 * hw_ep_bit: calculates the bit number
161 * @num: endpoint number
162 * @dir: endpoint direction
163 *
164 * This function returns bit number
165 */
166static inline int hw_ep_bit(int num, int dir)
167{
168 return num + (dir ? 16 : 0);
169}
170
171/**
172 * hw_aread: reads from register bitfield
173 * @addr: address relative to bus map
174 * @mask: bitfield mask
175 *
176 * This function returns register bitfield data
177 */
178static u32 hw_aread(u32 addr, u32 mask)
179{
180 return ioread32(addr + hw_bank.abs) & mask;
181}
182
183/**
184 * hw_awrite: writes to register bitfield
185 * @addr: address relative to bus map
186 * @mask: bitfield mask
187 * @data: new data
188 */
189static void hw_awrite(u32 addr, u32 mask, u32 data)
190{
191 iowrite32(hw_aread(addr, ~mask) | (data & mask),
192 addr + hw_bank.abs);
193}
194
195/**
196 * hw_cread: reads from register bitfield
197 * @addr: address relative to CAP offset plus content
198 * @mask: bitfield mask
199 *
200 * This function returns register bitfield data
201 */
202static u32 hw_cread(u32 addr, u32 mask)
203{
204 return ioread32(addr + hw_bank.cap) & mask;
205}
206
207/**
208 * hw_cwrite: writes to register bitfield
209 * @addr: address relative to CAP offset plus content
210 * @mask: bitfield mask
211 * @data: new data
212 */
213static void hw_cwrite(u32 addr, u32 mask, u32 data)
214{
215 iowrite32(hw_cread(addr, ~mask) | (data & mask),
216 addr + hw_bank.cap);
217}
218
219/**
220 * hw_ctest_and_clear: tests & clears register bitfield
221 * @addr: address relative to CAP offset plus content
222 * @mask: bitfield mask
223 *
224 * This function returns register bitfield data
225 */
226static u32 hw_ctest_and_clear(u32 addr, u32 mask)
227{
228 u32 reg = hw_cread(addr, mask);
229
230 iowrite32(reg, addr + hw_bank.cap);
231 return reg;
232}
233
234/**
235 * hw_ctest_and_write: tests & writes register bitfield
236 * @addr: address relative to CAP offset plus content
237 * @mask: bitfield mask
238 * @data: new data
239 *
240 * This function returns register bitfield data
241 */
242static u32 hw_ctest_and_write(u32 addr, u32 mask, u32 data)
243{
244 u32 reg = hw_cread(addr, ~0);
245
246 iowrite32((reg & ~mask) | (data & mask), addr + hw_bank.cap);
247 return (reg & mask) >> ffs_nr(mask);
248}
249
250/**
251 * hw_device_reset: resets chip (execute without interruption)
252 * @base: register base address
253 *
254 * This function returns an error code
255 */
256static int hw_device_reset(void __iomem *base)
257{
258 u32 reg;
259
260 /* bank is a module variable */
261 hw_bank.abs = base;
262
263 hw_bank.cap = hw_bank.abs;
264 hw_bank.cap += ABS_CAPLENGTH;
265 hw_bank.cap += ioread8(hw_bank.cap);
266
267 reg = hw_aread(ABS_HCCPARAMS, HCCPARAMS_LEN) >> ffs_nr(HCCPARAMS_LEN);
268 hw_bank.lpm = reg;
269 hw_bank.size = hw_bank.cap - hw_bank.abs;
270 hw_bank.size += CAP_LAST;
271 hw_bank.size /= sizeof(u32);
272
273 /* should flush & stop before reset */
274 hw_cwrite(CAP_ENDPTFLUSH, ~0, ~0);
275 hw_cwrite(CAP_USBCMD, USBCMD_RS, 0);
276
277 hw_cwrite(CAP_USBCMD, USBCMD_RST, USBCMD_RST);
278 while (hw_cread(CAP_USBCMD, USBCMD_RST))
279 udelay(10); /* not RTOS friendly */
280
281 /* USBMODE should be configured step by step */
282 hw_cwrite(CAP_USBMODE, USBMODE_CM, USBMODE_CM_IDLE);
283 hw_cwrite(CAP_USBMODE, USBMODE_CM, USBMODE_CM_DEVICE);
284 hw_cwrite(CAP_USBMODE, USBMODE_SLOM, USBMODE_SLOM); /* HW >= 2.3 */
285
286 if (hw_cread(CAP_USBMODE, USBMODE_CM) != USBMODE_CM_DEVICE) {
287 pr_err("cannot enter in device mode");
288 pr_err("lpm = %i", hw_bank.lpm);
289 return -ENODEV;
290 }
291
292 reg = hw_aread(ABS_DCCPARAMS, DCCPARAMS_DEN) >> ffs_nr(DCCPARAMS_DEN);
293 if (reg == 0 || reg > ENDPT_MAX)
294 return -ENODEV;
295
296 hw_ep_max = reg; /* cache hw ENDPT_MAX */
297
298 /* setup lock mode ? */
299
300 /* ENDPTSETUPSTAT is '0' by default */
301
302 /* HCSPARAMS.bf.ppc SHOULD BE zero for device */
303
304 return 0;
305}
306
307/**
308 * hw_device_state: enables/disables interrupts & starts/stops device (execute
309 * without interruption)
310 * @dma: 0 => disable, !0 => enable and set dma engine
311 *
312 * This function returns an error code
313 */
314static int hw_device_state(u32 dma)
315{
316 if (dma) {
317 hw_cwrite(CAP_ENDPTLISTADDR, ~0, dma);
318 /* interrupt, error, port change, reset, sleep/suspend */
319 hw_cwrite(CAP_USBINTR, ~0,
320 USBi_UI|USBi_UEI|USBi_PCI|USBi_URI|USBi_SLI);
321 hw_cwrite(CAP_USBCMD, USBCMD_RS, USBCMD_RS);
322 } else {
323 hw_cwrite(CAP_USBCMD, USBCMD_RS, 0);
324 hw_cwrite(CAP_USBINTR, ~0, 0);
325 }
326 return 0;
327}
328
329/**
330 * hw_ep_flush: flush endpoint fifo (execute without interruption)
331 * @num: endpoint number
332 * @dir: endpoint direction
333 *
334 * This function returns an error code
335 */
336static int hw_ep_flush(int num, int dir)
337{
338 int n = hw_ep_bit(num, dir);
339
340 do {
341 /* flush any pending transfer */
342 hw_cwrite(CAP_ENDPTFLUSH, BIT(n), BIT(n));
343 while (hw_cread(CAP_ENDPTFLUSH, BIT(n)))
344 cpu_relax();
345 } while (hw_cread(CAP_ENDPTSTAT, BIT(n)));
346
347 return 0;
348}
349
350/**
351 * hw_ep_disable: disables endpoint (execute without interruption)
352 * @num: endpoint number
353 * @dir: endpoint direction
354 *
355 * This function returns an error code
356 */
357static int hw_ep_disable(int num, int dir)
358{
359 hw_ep_flush(num, dir);
360 hw_cwrite(CAP_ENDPTCTRL + num * sizeof(u32),
361 dir ? ENDPTCTRL_TXE : ENDPTCTRL_RXE, 0);
362 return 0;
363}
364
365/**
366 * hw_ep_enable: enables endpoint (execute without interruption)
367 * @num: endpoint number
368 * @dir: endpoint direction
369 * @type: endpoint type
370 *
371 * This function returns an error code
372 */
373static int hw_ep_enable(int num, int dir, int type)
374{
375 u32 mask, data;
376
377 if (dir) {
378 mask = ENDPTCTRL_TXT; /* type */
379 data = type << ffs_nr(mask);
380
381 mask |= ENDPTCTRL_TXS; /* unstall */
382 mask |= ENDPTCTRL_TXR; /* reset data toggle */
383 data |= ENDPTCTRL_TXR;
384 mask |= ENDPTCTRL_TXE; /* enable */
385 data |= ENDPTCTRL_TXE;
386 } else {
387 mask = ENDPTCTRL_RXT; /* type */
388 data = type << ffs_nr(mask);
389
390 mask |= ENDPTCTRL_RXS; /* unstall */
391 mask |= ENDPTCTRL_RXR; /* reset data toggle */
392 data |= ENDPTCTRL_RXR;
393 mask |= ENDPTCTRL_RXE; /* enable */
394 data |= ENDPTCTRL_RXE;
395 }
396 hw_cwrite(CAP_ENDPTCTRL + num * sizeof(u32), mask, data);
397 return 0;
398}
399
400/**
401 * hw_ep_get_halt: return endpoint halt status
402 * @num: endpoint number
403 * @dir: endpoint direction
404 *
405 * This function returns 1 if endpoint halted
406 */
407static int hw_ep_get_halt(int num, int dir)
408{
409 u32 mask = dir ? ENDPTCTRL_TXS : ENDPTCTRL_RXS;
410
411 return hw_cread(CAP_ENDPTCTRL + num * sizeof(u32), mask) ? 1 : 0;
412}
413
414/**
415 * hw_ep_is_primed: test if endpoint is primed (execute without interruption)
416 * @num: endpoint number
417 * @dir: endpoint direction
418 *
419 * This function returns true if endpoint primed
420 */
421static int hw_ep_is_primed(int num, int dir)
422{
423 u32 reg = hw_cread(CAP_ENDPTPRIME, ~0) | hw_cread(CAP_ENDPTSTAT, ~0);
424
425 return test_bit(hw_ep_bit(num, dir), (void *)&reg);
426}
427
428/**
429 * hw_test_and_clear_setup_status: test & clear setup status (execute without
430 * interruption)
431 * @n: bit number (endpoint)
432 *
433 * This function returns setup status
434 */
435static int hw_test_and_clear_setup_status(int n)
436{
437 return hw_ctest_and_clear(CAP_ENDPTSETUPSTAT, BIT(n));
438}
439
440/**
441 * hw_ep_prime: primes endpoint (execute without interruption)
442 * @num: endpoint number
443 * @dir: endpoint direction
444 * @is_ctrl: true if control endpoint
445 *
446 * This function returns an error code
447 */
448static int hw_ep_prime(int num, int dir, int is_ctrl)
449{
450 int n = hw_ep_bit(num, dir);
451
452 /* the caller should flush first */
453 if (hw_ep_is_primed(num, dir))
454 return -EBUSY;
455
456 if (is_ctrl && dir == RX && hw_cread(CAP_ENDPTSETUPSTAT, BIT(num)))
457 return -EAGAIN;
458
459 hw_cwrite(CAP_ENDPTPRIME, BIT(n), BIT(n));
460
461 while (hw_cread(CAP_ENDPTPRIME, BIT(n)))
462 cpu_relax();
463 if (is_ctrl && dir == RX && hw_cread(CAP_ENDPTSETUPSTAT, BIT(num)))
464 return -EAGAIN;
465
466 /* status shoult be tested according with manual but it doesn't work */
467 return 0;
468}
469
470/**
471 * hw_ep_set_halt: configures ep halt & resets data toggle after clear (execute
472 * without interruption)
473 * @num: endpoint number
474 * @dir: endpoint direction
475 * @value: true => stall, false => unstall
476 *
477 * This function returns an error code
478 */
479static int hw_ep_set_halt(int num, int dir, int value)
480{
481 if (value != 0 && value != 1)
482 return -EINVAL;
483
484 do {
485 u32 addr = CAP_ENDPTCTRL + num * sizeof(u32);
486 u32 mask_xs = dir ? ENDPTCTRL_TXS : ENDPTCTRL_RXS;
487 u32 mask_xr = dir ? ENDPTCTRL_TXR : ENDPTCTRL_RXR;
488
489 /* data toggle - reserved for EP0 but it's in ESS */
490 hw_cwrite(addr, mask_xs|mask_xr, value ? mask_xs : mask_xr);
491
492 } while (value != hw_ep_get_halt(num, dir));
493
494 return 0;
495}
496
497/**
498 * hw_intr_clear: disables interrupt & clears interrupt status (execute without
499 * interruption)
500 * @n: interrupt bit
501 *
502 * This function returns an error code
503 */
504static int hw_intr_clear(int n)
505{
506 if (n >= REG_BITS)
507 return -EINVAL;
508
509 hw_cwrite(CAP_USBINTR, BIT(n), 0);
510 hw_cwrite(CAP_USBSTS, BIT(n), BIT(n));
511 return 0;
512}
513
514/**
515 * hw_intr_force: enables interrupt & forces interrupt status (execute without
516 * interruption)
517 * @n: interrupt bit
518 *
519 * This function returns an error code
520 */
521static int hw_intr_force(int n)
522{
523 if (n >= REG_BITS)
524 return -EINVAL;
525
526 hw_awrite(ABS_TESTMODE, TESTMODE_FORCE, TESTMODE_FORCE);
527 hw_cwrite(CAP_USBINTR, BIT(n), BIT(n));
528 hw_cwrite(CAP_USBSTS, BIT(n), BIT(n));
529 hw_awrite(ABS_TESTMODE, TESTMODE_FORCE, 0);
530 return 0;
531}
532
533/**
534 * hw_is_port_high_speed: test if port is high speed
535 *
536 * This function returns true if high speed port
537 */
538static int hw_port_is_high_speed(void)
539{
540 return hw_bank.lpm ? hw_cread(CAP_DEVLC, DEVLC_PSPD) :
541 hw_cread(CAP_PORTSC, PORTSC_HSP);
542}
543
544/**
545 * hw_port_test_get: reads port test mode value
546 *
547 * This function returns port test mode value
548 */
549static u8 hw_port_test_get(void)
550{
551 return hw_cread(CAP_PORTSC, PORTSC_PTC) >> ffs_nr(PORTSC_PTC);
552}
553
554/**
555 * hw_port_test_set: writes port test mode (execute without interruption)
556 * @mode: new value
557 *
558 * This function returns an error code
559 */
560static int hw_port_test_set(u8 mode)
561{
562 const u8 TEST_MODE_MAX = 7;
563
564 if (mode > TEST_MODE_MAX)
565 return -EINVAL;
566
567 hw_cwrite(CAP_PORTSC, PORTSC_PTC, mode << ffs_nr(PORTSC_PTC));
568 return 0;
569}
570
571/**
572 * hw_read_intr_enable: returns interrupt enable register
573 *
574 * This function returns register data
575 */
576static u32 hw_read_intr_enable(void)
577{
578 return hw_cread(CAP_USBINTR, ~0);
579}
580
581/**
582 * hw_read_intr_status: returns interrupt status register
583 *
584 * This function returns register data
585 */
586static u32 hw_read_intr_status(void)
587{
588 return hw_cread(CAP_USBSTS, ~0);
589}
590
591/**
592 * hw_register_read: reads all device registers (execute without interruption)
593 * @buf: destination buffer
594 * @size: buffer size
595 *
596 * This function returns number of registers read
597 */
598static size_t hw_register_read(u32 *buf, size_t size)
599{
600 unsigned i;
601
602 if (size > hw_bank.size)
603 size = hw_bank.size;
604
605 for (i = 0; i < size; i++)
606 buf[i] = hw_aread(i * sizeof(u32), ~0);
607
608 return size;
609}
610
611/**
612 * hw_register_write: writes to register
613 * @addr: register address
614 * @data: register value
615 *
616 * This function returns an error code
617 */
618static int hw_register_write(u16 addr, u32 data)
619{
620 /* align */
621 addr /= sizeof(u32);
622
623 if (addr >= hw_bank.size)
624 return -EINVAL;
625
626 /* align */
627 addr *= sizeof(u32);
628
629 hw_awrite(addr, ~0, data);
630 return 0;
631}
632
633/**
634 * hw_test_and_clear_complete: test & clear complete status (execute without
635 * interruption)
636 * @n: bit number (endpoint)
637 *
638 * This function returns complete status
639 */
640static int hw_test_and_clear_complete(int n)
641{
642 return hw_ctest_and_clear(CAP_ENDPTCOMPLETE, BIT(n));
643}
644
645/**
646 * hw_test_and_clear_intr_active: test & clear active interrupts (execute
647 * without interruption)
648 *
649 * This function returns active interrutps
650 */
651static u32 hw_test_and_clear_intr_active(void)
652{
653 u32 reg = hw_read_intr_status() & hw_read_intr_enable();
654
655 hw_cwrite(CAP_USBSTS, ~0, reg);
656 return reg;
657}
658
659/**
660 * hw_test_and_clear_setup_guard: test & clear setup guard (execute without
661 * interruption)
662 *
663 * This function returns guard value
664 */
665static int hw_test_and_clear_setup_guard(void)
666{
667 return hw_ctest_and_write(CAP_USBCMD, USBCMD_SUTW, 0);
668}
669
670/**
671 * hw_test_and_set_setup_guard: test & set setup guard (execute without
672 * interruption)
673 *
674 * This function returns guard value
675 */
676static int hw_test_and_set_setup_guard(void)
677{
678 return hw_ctest_and_write(CAP_USBCMD, USBCMD_SUTW, USBCMD_SUTW);
679}
680
681/**
682 * hw_usb_set_address: configures USB address (execute without interruption)
683 * @value: new USB address
684 *
685 * This function returns an error code
686 */
687static int hw_usb_set_address(u8 value)
688{
689 /* advance */
690 hw_cwrite(CAP_DEVICEADDR, DEVICEADDR_USBADR | DEVICEADDR_USBADRA,
691 value << ffs_nr(DEVICEADDR_USBADR) | DEVICEADDR_USBADRA);
692 return 0;
693}
694
695/**
696 * hw_usb_reset: restart device after a bus reset (execute without
697 * interruption)
698 *
699 * This function returns an error code
700 */
701static int hw_usb_reset(void)
702{
703 hw_usb_set_address(0);
704
705 /* ESS flushes only at end?!? */
706 hw_cwrite(CAP_ENDPTFLUSH, ~0, ~0); /* flush all EPs */
707
708 /* clear setup token semaphores */
709 hw_cwrite(CAP_ENDPTSETUPSTAT, 0, 0); /* writes its content */
710
711 /* clear complete status */
712 hw_cwrite(CAP_ENDPTCOMPLETE, 0, 0); /* writes its content */
713
714 /* wait until all bits cleared */
715 while (hw_cread(CAP_ENDPTPRIME, ~0))
716 udelay(10); /* not RTOS friendly */
717
718 /* reset all endpoints ? */
719
720 /* reset internal status and wait for further instructions
721 no need to verify the port reset status (ESS does it) */
722
723 return 0;
724}
725
726/******************************************************************************
727 * DBG block
728 *****************************************************************************/
729/**
730 * show_device: prints information about device capabilities and status
731 *
732 * Check "device.h" for details
733 */
734static ssize_t show_device(struct device *dev, struct device_attribute *attr,
735 char *buf)
736{
737 struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev);
738 struct usb_gadget *gadget = &udc->gadget;
739 int n = 0;
740
741 dbg_trace("[%s] %p\n", __func__, buf);
742 if (attr == NULL || buf == NULL) {
743 dev_err(dev, "[%s] EINVAL\n", __func__);
744 return 0;
745 }
746
747 n += scnprintf(buf + n, PAGE_SIZE - n, "speed = %d\n",
748 gadget->speed);
749 n += scnprintf(buf + n, PAGE_SIZE - n, "is_dualspeed = %d\n",
750 gadget->is_dualspeed);
751 n += scnprintf(buf + n, PAGE_SIZE - n, "is_otg = %d\n",
752 gadget->is_otg);
753 n += scnprintf(buf + n, PAGE_SIZE - n, "is_a_peripheral = %d\n",
754 gadget->is_a_peripheral);
755 n += scnprintf(buf + n, PAGE_SIZE - n, "b_hnp_enable = %d\n",
756 gadget->b_hnp_enable);
757 n += scnprintf(buf + n, PAGE_SIZE - n, "a_hnp_support = %d\n",
758 gadget->a_hnp_support);
759 n += scnprintf(buf + n, PAGE_SIZE - n, "a_alt_hnp_support = %d\n",
760 gadget->a_alt_hnp_support);
761 n += scnprintf(buf + n, PAGE_SIZE - n, "name = %s\n",
762 (gadget->name ? gadget->name : ""));
763
764 return n;
765}
766static DEVICE_ATTR(device, S_IRUSR, show_device, NULL);
767
768/**
769 * show_driver: prints information about attached gadget (if any)
770 *
771 * Check "device.h" for details
772 */
773static ssize_t show_driver(struct device *dev, struct device_attribute *attr,
774 char *buf)
775{
776 struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev);
777 struct usb_gadget_driver *driver = udc->driver;
778 int n = 0;
779
780 dbg_trace("[%s] %p\n", __func__, buf);
781 if (attr == NULL || buf == NULL) {
782 dev_err(dev, "[%s] EINVAL\n", __func__);
783 return 0;
784 }
785
786 if (driver == NULL)
787 return scnprintf(buf, PAGE_SIZE,
788 "There is no gadget attached!\n");
789
790 n += scnprintf(buf + n, PAGE_SIZE - n, "function = %s\n",
791 (driver->function ? driver->function : ""));
792 n += scnprintf(buf + n, PAGE_SIZE - n, "max speed = %d\n",
793 driver->speed);
794
795 return n;
796}
797static DEVICE_ATTR(driver, S_IRUSR, show_driver, NULL);
798
799/* Maximum event message length */
800#define DBG_DATA_MSG 64UL
801
802/* Maximum event messages */
803#define DBG_DATA_MAX 128UL
804
805/* Event buffer descriptor */
806static struct {
807 char (buf[DBG_DATA_MAX])[DBG_DATA_MSG]; /* buffer */
808 unsigned idx; /* index */
809 unsigned tty; /* print to console? */
810 rwlock_t lck; /* lock */
811} dbg_data = {
812 .idx = 0,
813 .tty = 0,
814 .lck = __RW_LOCK_UNLOCKED(lck)
815};
816
817/**
818 * dbg_dec: decrements debug event index
819 * @idx: buffer index
820 */
821static void dbg_dec(unsigned *idx)
822{
823 *idx = (*idx - 1) & (DBG_DATA_MAX-1);
824}
825
826/**
827 * dbg_inc: increments debug event index
828 * @idx: buffer index
829 */
830static void dbg_inc(unsigned *idx)
831{
832 *idx = (*idx + 1) & (DBG_DATA_MAX-1);
833}
834
835/**
836 * dbg_print: prints the common part of the event
837 * @addr: endpoint address
838 * @name: event name
839 * @status: status
840 * @extra: extra information
841 */
842static void dbg_print(u8 addr, const char *name, int status, const char *extra)
843{
844 struct timeval tval;
845 unsigned int stamp;
846 unsigned long flags;
847
848 write_lock_irqsave(&dbg_data.lck, flags);
849
850 do_gettimeofday(&tval);
851 stamp = tval.tv_sec & 0xFFFF; /* 2^32 = 4294967296. Limit to 4096s */
852 stamp = stamp * 1000000 + tval.tv_usec;
853
854 scnprintf(dbg_data.buf[dbg_data.idx], DBG_DATA_MSG,
855 "%04X\t» %02X %-7.7s %4i «\t%s\n",
856 stamp, addr, name, status, extra);
857
858 dbg_inc(&dbg_data.idx);
859
860 write_unlock_irqrestore(&dbg_data.lck, flags);
861
862 if (dbg_data.tty != 0)
863 pr_notice("%04X\t» %02X %-7.7s %4i «\t%s\n",
864 stamp, addr, name, status, extra);
865}
866
867/**
868 * dbg_done: prints a DONE event
869 * @addr: endpoint address
870 * @td: transfer descriptor
871 * @status: status
872 */
873static void dbg_done(u8 addr, const u32 token, int status)
874{
875 char msg[DBG_DATA_MSG];
876
877 scnprintf(msg, sizeof(msg), "%d %02X",
878 (int)(token & TD_TOTAL_BYTES) >> ffs_nr(TD_TOTAL_BYTES),
879 (int)(token & TD_STATUS) >> ffs_nr(TD_STATUS));
880 dbg_print(addr, "DONE", status, msg);
881}
882
883/**
884 * dbg_event: prints a generic event
885 * @addr: endpoint address
886 * @name: event name
887 * @status: status
888 */
889static void dbg_event(u8 addr, const char *name, int status)
890{
891 if (name != NULL)
892 dbg_print(addr, name, status, "");
893}
894
895/*
896 * dbg_queue: prints a QUEUE event
897 * @addr: endpoint address
898 * @req: USB request
899 * @status: status
900 */
901static void dbg_queue(u8 addr, const struct usb_request *req, int status)
902{
903 char msg[DBG_DATA_MSG];
904
905 if (req != NULL) {
906 scnprintf(msg, sizeof(msg),
907 "%d %d", !req->no_interrupt, req->length);
908 dbg_print(addr, "QUEUE", status, msg);
909 }
910}
911
912/**
913 * dbg_setup: prints a SETUP event
914 * @addr: endpoint address
915 * @req: setup request
916 */
917static void dbg_setup(u8 addr, const struct usb_ctrlrequest *req)
918{
919 char msg[DBG_DATA_MSG];
920
921 if (req != NULL) {
922 scnprintf(msg, sizeof(msg),
923 "%02X %02X %04X %04X %d", req->bRequestType,
924 req->bRequest, le16_to_cpu(req->wValue),
925 le16_to_cpu(req->wIndex), le16_to_cpu(req->wLength));
926 dbg_print(addr, "SETUP", 0, msg);
927 }
928}
929
930/**
931 * show_events: displays the event buffer
932 *
933 * Check "device.h" for details
934 */
935static ssize_t show_events(struct device *dev, struct device_attribute *attr,
936 char *buf)
937{
938 unsigned long flags;
939 unsigned i, j, n = 0;
940
941 dbg_trace("[%s] %p\n", __func__, buf);
942 if (attr == NULL || buf == NULL) {
943 dev_err(dev, "[%s] EINVAL\n", __func__);
944 return 0;
945 }
946
947 read_lock_irqsave(&dbg_data.lck, flags);
948
949 i = dbg_data.idx;
950 for (dbg_dec(&i); i != dbg_data.idx; dbg_dec(&i)) {
951 n += strlen(dbg_data.buf[i]);
952 if (n >= PAGE_SIZE) {
953 n -= strlen(dbg_data.buf[i]);
954 break;
955 }
956 }
957 for (j = 0, dbg_inc(&i); j < n; dbg_inc(&i))
958 j += scnprintf(buf + j, PAGE_SIZE - j,
959 "%s", dbg_data.buf[i]);
960
961 read_unlock_irqrestore(&dbg_data.lck, flags);
962
963 return n;
964}
965
966/**
967 * store_events: configure if events are going to be also printed to console
968 *
969 * Check "device.h" for details
970 */
971static ssize_t store_events(struct device *dev, struct device_attribute *attr,
972 const char *buf, size_t count)
973{
974 unsigned tty;
975
976 dbg_trace("[%s] %p, %d\n", __func__, buf, count);
977 if (attr == NULL || buf == NULL) {
978 dev_err(dev, "[%s] EINVAL\n", __func__);
979 goto done;
980 }
981
982 if (sscanf(buf, "%u", &tty) != 1 || tty > 1) {
983 dev_err(dev, "<1|0>: enable|disable console log\n");
984 goto done;
985 }
986
987 dbg_data.tty = tty;
988 dev_info(dev, "tty = %u", dbg_data.tty);
989
990 done:
991 return count;
992}
993static DEVICE_ATTR(events, S_IRUSR | S_IWUSR, show_events, store_events);
994
995/**
996 * show_inters: interrupt status, enable status and historic
997 *
998 * Check "device.h" for details
999 */
1000static ssize_t show_inters(struct device *dev, struct device_attribute *attr,
1001 char *buf)
1002{
1003 struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev);
1004 unsigned long flags;
1005 u32 intr;
1006 unsigned i, j, n = 0;
1007
1008 dbg_trace("[%s] %p\n", __func__, buf);
1009 if (attr == NULL || buf == NULL) {
1010 dev_err(dev, "[%s] EINVAL\n", __func__);
1011 return 0;
1012 }
1013
1014 spin_lock_irqsave(udc->lock, flags);
1015
1016 n += scnprintf(buf + n, PAGE_SIZE - n,
1017 "status = %08x\n", hw_read_intr_status());
1018 n += scnprintf(buf + n, PAGE_SIZE - n,
1019 "enable = %08x\n", hw_read_intr_enable());
1020
1021 n += scnprintf(buf + n, PAGE_SIZE - n, "*test = %d\n",
1022 isr_statistics.test);
1023 n += scnprintf(buf + n, PAGE_SIZE - n, "» ui = %d\n",
1024 isr_statistics.ui);
1025 n += scnprintf(buf + n, PAGE_SIZE - n, "» uei = %d\n",
1026 isr_statistics.uei);
1027 n += scnprintf(buf + n, PAGE_SIZE - n, "» pci = %d\n",
1028 isr_statistics.pci);
1029 n += scnprintf(buf + n, PAGE_SIZE - n, "» uri = %d\n",
1030 isr_statistics.uri);
1031 n += scnprintf(buf + n, PAGE_SIZE - n, "» sli = %d\n",
1032 isr_statistics.sli);
1033 n += scnprintf(buf + n, PAGE_SIZE - n, "*none = %d\n",
1034 isr_statistics.none);
1035 n += scnprintf(buf + n, PAGE_SIZE - n, "*hndl = %d\n",
1036 isr_statistics.hndl.cnt);
1037
1038 for (i = isr_statistics.hndl.idx, j = 0; j <= ISR_MASK; j++, i++) {
1039 i &= ISR_MASK;
1040 intr = isr_statistics.hndl.buf[i];
1041
1042 if (USBi_UI & intr)
1043 n += scnprintf(buf + n, PAGE_SIZE - n, "ui ");
1044 intr &= ~USBi_UI;
1045 if (USBi_UEI & intr)
1046 n += scnprintf(buf + n, PAGE_SIZE - n, "uei ");
1047 intr &= ~USBi_UEI;
1048 if (USBi_PCI & intr)
1049 n += scnprintf(buf + n, PAGE_SIZE - n, "pci ");
1050 intr &= ~USBi_PCI;
1051 if (USBi_URI & intr)
1052 n += scnprintf(buf + n, PAGE_SIZE - n, "uri ");
1053 intr &= ~USBi_URI;
1054 if (USBi_SLI & intr)
1055 n += scnprintf(buf + n, PAGE_SIZE - n, "sli ");
1056 intr &= ~USBi_SLI;
1057 if (intr)
1058 n += scnprintf(buf + n, PAGE_SIZE - n, "??? ");
1059 if (isr_statistics.hndl.buf[i])
1060 n += scnprintf(buf + n, PAGE_SIZE - n, "\n");
1061 }
1062
1063 spin_unlock_irqrestore(udc->lock, flags);
1064
1065 return n;
1066}
1067
1068/**
1069 * store_inters: enable & force or disable an individual interrutps
1070 * (to be used for test purposes only)
1071 *
1072 * Check "device.h" for details
1073 */
1074static ssize_t store_inters(struct device *dev, struct device_attribute *attr,
1075 const char *buf, size_t count)
1076{
1077 struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev);
1078 unsigned long flags;
1079 unsigned en, bit;
1080
1081 dbg_trace("[%s] %p, %d\n", __func__, buf, count);
1082 if (attr == NULL || buf == NULL) {
1083 dev_err(dev, "[%s] EINVAL\n", __func__);
1084 goto done;
1085 }
1086
1087 if (sscanf(buf, "%u %u", &en, &bit) != 2 || en > 1) {
1088 dev_err(dev, "<1|0> <bit>: enable|disable interrupt");
1089 goto done;
1090 }
1091
1092 spin_lock_irqsave(udc->lock, flags);
1093 if (en) {
1094 if (hw_intr_force(bit))
1095 dev_err(dev, "invalid bit number\n");
1096 else
1097 isr_statistics.test++;
1098 } else {
1099 if (hw_intr_clear(bit))
1100 dev_err(dev, "invalid bit number\n");
1101 }
1102 spin_unlock_irqrestore(udc->lock, flags);
1103
1104 done:
1105 return count;
1106}
1107static DEVICE_ATTR(inters, S_IRUSR | S_IWUSR, show_inters, store_inters);
1108
1109/**
1110 * show_port_test: reads port test mode
1111 *
1112 * Check "device.h" for details
1113 */
1114static ssize_t show_port_test(struct device *dev,
1115 struct device_attribute *attr, char *buf)
1116{
1117 struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev);
1118 unsigned long flags;
1119 unsigned mode;
1120
1121 dbg_trace("[%s] %p\n", __func__, buf);
1122 if (attr == NULL || buf == NULL) {
1123 dev_err(dev, "[%s] EINVAL\n", __func__);
1124 return 0;
1125 }
1126
1127 spin_lock_irqsave(udc->lock, flags);
1128 mode = hw_port_test_get();
1129 spin_unlock_irqrestore(udc->lock, flags);
1130
1131 return scnprintf(buf, PAGE_SIZE, "mode = %u\n", mode);
1132}
1133
1134/**
1135 * store_port_test: writes port test mode
1136 *
1137 * Check "device.h" for details
1138 */
1139static ssize_t store_port_test(struct device *dev,
1140 struct device_attribute *attr,
1141 const char *buf, size_t count)
1142{
1143 struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev);
1144 unsigned long flags;
1145 unsigned mode;
1146
1147 dbg_trace("[%s] %p, %d\n", __func__, buf, count);
1148 if (attr == NULL || buf == NULL) {
1149 dev_err(dev, "[%s] EINVAL\n", __func__);
1150 goto done;
1151 }
1152
1153 if (sscanf(buf, "%u", &mode) != 1) {
1154 dev_err(dev, "<mode>: set port test mode");
1155 goto done;
1156 }
1157
1158 spin_lock_irqsave(udc->lock, flags);
1159 if (hw_port_test_set(mode))
1160 dev_err(dev, "invalid mode\n");
1161 spin_unlock_irqrestore(udc->lock, flags);
1162
1163 done:
1164 return count;
1165}
1166static DEVICE_ATTR(port_test, S_IRUSR | S_IWUSR,
1167 show_port_test, store_port_test);
1168
1169/**
1170 * show_qheads: DMA contents of all queue heads
1171 *
1172 * Check "device.h" for details
1173 */
1174static ssize_t show_qheads(struct device *dev, struct device_attribute *attr,
1175 char *buf)
1176{
1177 struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev);
1178 unsigned long flags;
1179 unsigned i, j, n = 0;
1180
1181 dbg_trace("[%s] %p\n", __func__, buf);
1182 if (attr == NULL || buf == NULL) {
1183 dev_err(dev, "[%s] EINVAL\n", __func__);
1184 return 0;
1185 }
1186
1187 spin_lock_irqsave(udc->lock, flags);
1188 for (i = 0; i < hw_ep_max; i++) {
1189 struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i];
1190 n += scnprintf(buf + n, PAGE_SIZE - n,
1191 "EP=%02i: RX=%08X TX=%08X\n",
1192 i, (u32)mEp->qh[RX].dma, (u32)mEp->qh[TX].dma);
1193 for (j = 0; j < (sizeof(struct ci13xxx_qh)/sizeof(u32)); j++) {
1194 n += scnprintf(buf + n, PAGE_SIZE - n,
1195 " %04X: %08X %08X\n", j,
1196 *((u32 *)mEp->qh[RX].ptr + j),
1197 *((u32 *)mEp->qh[TX].ptr + j));
1198 }
1199 }
1200 spin_unlock_irqrestore(udc->lock, flags);
1201
1202 return n;
1203}
1204static DEVICE_ATTR(qheads, S_IRUSR, show_qheads, NULL);
1205
1206/**
1207 * show_registers: dumps all registers
1208 *
1209 * Check "device.h" for details
1210 */
1211static ssize_t show_registers(struct device *dev,
1212 struct device_attribute *attr, char *buf)
1213{
1214 struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev);
1215 unsigned long flags;
1216 u32 dump[512];
1217 unsigned i, k, n = 0;
1218
1219 dbg_trace("[%s] %p\n", __func__, buf);
1220 if (attr == NULL || buf == NULL) {
1221 dev_err(dev, "[%s] EINVAL\n", __func__);
1222 return 0;
1223 }
1224
1225 spin_lock_irqsave(udc->lock, flags);
1226 k = hw_register_read(dump, sizeof(dump)/sizeof(u32));
1227 spin_unlock_irqrestore(udc->lock, flags);
1228
1229 for (i = 0; i < k; i++) {
1230 n += scnprintf(buf + n, PAGE_SIZE - n,
1231 "reg[0x%04X] = 0x%08X\n",
1232 i * (unsigned)sizeof(u32), dump[i]);
1233 }
1234
1235 return n;
1236}
1237
1238/**
1239 * store_registers: writes value to register address
1240 *
1241 * Check "device.h" for details
1242 */
1243static ssize_t store_registers(struct device *dev,
1244 struct device_attribute *attr,
1245 const char *buf, size_t count)
1246{
1247 struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev);
1248 unsigned long addr, data, flags;
1249
1250 dbg_trace("[%s] %p, %d\n", __func__, buf, count);
1251 if (attr == NULL || buf == NULL) {
1252 dev_err(dev, "[%s] EINVAL\n", __func__);
1253 goto done;
1254 }
1255
1256 if (sscanf(buf, "%li %li", &addr, &data) != 2) {
1257 dev_err(dev, "<addr> <data>: write data to register address");
1258 goto done;
1259 }
1260
1261 spin_lock_irqsave(udc->lock, flags);
1262 if (hw_register_write(addr, data))
1263 dev_err(dev, "invalid address range\n");
1264 spin_unlock_irqrestore(udc->lock, flags);
1265
1266 done:
1267 return count;
1268}
1269static DEVICE_ATTR(registers, S_IRUSR | S_IWUSR,
1270 show_registers, store_registers);
1271
1272/**
1273 * show_requests: DMA contents of all requests currently queued (all endpts)
1274 *
1275 * Check "device.h" for details
1276 */
1277static ssize_t show_requests(struct device *dev, struct device_attribute *attr,
1278 char *buf)
1279{
1280 struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev);
1281 unsigned long flags;
1282 struct list_head *ptr = NULL;
1283 struct ci13xxx_req *req = NULL;
1284 unsigned i, j, k, n = 0, qSize = sizeof(struct ci13xxx_td)/sizeof(u32);
1285
1286 dbg_trace("[%s] %p\n", __func__, buf);
1287 if (attr == NULL || buf == NULL) {
1288 dev_err(dev, "[%s] EINVAL\n", __func__);
1289 return 0;
1290 }
1291
1292 spin_lock_irqsave(udc->lock, flags);
1293 for (i = 0; i < hw_ep_max; i++)
1294 for (k = RX; k <= TX; k++)
1295 list_for_each(ptr, &udc->ci13xxx_ep[i].qh[k].queue)
1296 {
1297 req = list_entry(ptr,
1298 struct ci13xxx_req, queue);
1299
1300 n += scnprintf(buf + n, PAGE_SIZE - n,
1301 "EP=%02i: TD=%08X %s\n",
1302 i, (u32)req->dma,
1303 ((k == RX) ? "RX" : "TX"));
1304
1305 for (j = 0; j < qSize; j++)
1306 n += scnprintf(buf + n, PAGE_SIZE - n,
1307 " %04X: %08X\n", j,
1308 *((u32 *)req->ptr + j));
1309 }
1310 spin_unlock_irqrestore(udc->lock, flags);
1311
1312 return n;
1313}
1314static DEVICE_ATTR(requests, S_IRUSR, show_requests, NULL);
1315
1316/**
1317 * dbg_create_files: initializes the attribute interface
1318 * @dev: device
1319 *
1320 * This function returns an error code
1321 */
1322__maybe_unused static int dbg_create_files(struct device *dev)
1323{
1324 int retval = 0;
1325
1326 if (dev == NULL)
1327 return -EINVAL;
1328 retval = device_create_file(dev, &dev_attr_device);
1329 if (retval)
1330 goto done;
1331 retval = device_create_file(dev, &dev_attr_driver);
1332 if (retval)
1333 goto rm_device;
1334 retval = device_create_file(dev, &dev_attr_events);
1335 if (retval)
1336 goto rm_driver;
1337 retval = device_create_file(dev, &dev_attr_inters);
1338 if (retval)
1339 goto rm_events;
1340 retval = device_create_file(dev, &dev_attr_port_test);
1341 if (retval)
1342 goto rm_inters;
1343 retval = device_create_file(dev, &dev_attr_qheads);
1344 if (retval)
1345 goto rm_port_test;
1346 retval = device_create_file(dev, &dev_attr_registers);
1347 if (retval)
1348 goto rm_qheads;
1349 retval = device_create_file(dev, &dev_attr_requests);
1350 if (retval)
1351 goto rm_registers;
1352 return 0;
1353
1354 rm_registers:
1355 device_remove_file(dev, &dev_attr_registers);
1356 rm_qheads:
1357 device_remove_file(dev, &dev_attr_qheads);
1358 rm_port_test:
1359 device_remove_file(dev, &dev_attr_port_test);
1360 rm_inters:
1361 device_remove_file(dev, &dev_attr_inters);
1362 rm_events:
1363 device_remove_file(dev, &dev_attr_events);
1364 rm_driver:
1365 device_remove_file(dev, &dev_attr_driver);
1366 rm_device:
1367 device_remove_file(dev, &dev_attr_device);
1368 done:
1369 return retval;
1370}
1371
1372/**
1373 * dbg_remove_files: destroys the attribute interface
1374 * @dev: device
1375 *
1376 * This function returns an error code
1377 */
1378__maybe_unused static int dbg_remove_files(struct device *dev)
1379{
1380 if (dev == NULL)
1381 return -EINVAL;
1382 device_remove_file(dev, &dev_attr_requests);
1383 device_remove_file(dev, &dev_attr_registers);
1384 device_remove_file(dev, &dev_attr_qheads);
1385 device_remove_file(dev, &dev_attr_port_test);
1386 device_remove_file(dev, &dev_attr_inters);
1387 device_remove_file(dev, &dev_attr_events);
1388 device_remove_file(dev, &dev_attr_driver);
1389 device_remove_file(dev, &dev_attr_device);
1390 return 0;
1391}
1392
1393/******************************************************************************
1394 * UTIL block
1395 *****************************************************************************/
1396/**
1397 * _usb_addr: calculates endpoint address from direction & number
1398 * @ep: endpoint
1399 */
1400static inline u8 _usb_addr(struct ci13xxx_ep *ep)
1401{
1402 return ((ep->dir == TX) ? USB_ENDPOINT_DIR_MASK : 0) | ep->num;
1403}
1404
1405/**
1406 * _hardware_queue: configures a request at hardware level
1407 * @gadget: gadget
1408 * @mEp: endpoint
1409 *
1410 * This function returns an error code
1411 */
1412static int _hardware_enqueue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq)
1413{
1414 unsigned i;
1415
1416 trace("%p, %p", mEp, mReq);
1417
1418 /* don't queue twice */
1419 if (mReq->req.status == -EALREADY)
1420 return -EALREADY;
1421
1422 if (hw_ep_is_primed(mEp->num, mEp->dir))
1423 return -EBUSY;
1424
1425 mReq->req.status = -EALREADY;
1426
1427 if (mReq->req.length && !mReq->req.dma) {
1428 mReq->req.dma = \
1429 dma_map_single(mEp->device, mReq->req.buf,
1430 mReq->req.length, mEp->dir ?
1431 DMA_TO_DEVICE : DMA_FROM_DEVICE);
1432 if (mReq->req.dma == 0)
1433 return -ENOMEM;
1434
1435 mReq->map = 1;
1436 }
1437
1438 /*
1439 * TD configuration
1440 * TODO - handle requests which spawns into several TDs
1441 */
1442 memset(mReq->ptr, 0, sizeof(*mReq->ptr));
1443 mReq->ptr->next |= TD_TERMINATE;
1444 mReq->ptr->token = mReq->req.length << ffs_nr(TD_TOTAL_BYTES);
1445 mReq->ptr->token &= TD_TOTAL_BYTES;
1446 mReq->ptr->token |= TD_IOC;
1447 mReq->ptr->token |= TD_STATUS_ACTIVE;
1448 mReq->ptr->page[0] = mReq->req.dma;
1449 for (i = 1; i < 5; i++)
1450 mReq->ptr->page[i] =
1451 (mReq->req.dma + i * PAGE_SIZE) & ~TD_RESERVED_MASK;
1452
1453 /*
1454 * QH configuration
1455 * At this point it's guaranteed exclusive access to qhead
1456 * (endpt is not primed) so it's no need to use tripwire
1457 */
1458 mEp->qh[mEp->dir].ptr->td.next = mReq->dma; /* TERMINATE = 0 */
1459 mEp->qh[mEp->dir].ptr->td.token &= ~TD_STATUS; /* clear status */
1460 if (mReq->req.zero == 0)
1461 mEp->qh[mEp->dir].ptr->cap |= QH_ZLT;
1462 else
1463 mEp->qh[mEp->dir].ptr->cap &= ~QH_ZLT;
1464
1465 wmb(); /* synchronize before ep prime */
1466
1467 return hw_ep_prime(mEp->num, mEp->dir,
1468 mEp->type == USB_ENDPOINT_XFER_CONTROL);
1469}
1470
1471/**
1472 * _hardware_dequeue: handles a request at hardware level
1473 * @gadget: gadget
1474 * @mEp: endpoint
1475 *
1476 * This function returns an error code
1477 */
1478static int _hardware_dequeue(struct ci13xxx_ep *mEp, struct ci13xxx_req *mReq)
1479{
1480 trace("%p, %p", mEp, mReq);
1481
1482 if (mReq->req.status != -EALREADY)
1483 return -EINVAL;
1484
1485 if (hw_ep_is_primed(mEp->num, mEp->dir))
1486 hw_ep_flush(mEp->num, mEp->dir);
1487
1488 mReq->req.status = 0;
1489
1490 if (mReq->map) {
1491 dma_unmap_single(mEp->device, mReq->req.dma, mReq->req.length,
1492 mEp->dir ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
1493 mReq->req.dma = 0;
1494 mReq->map = 0;
1495 }
1496
1497 mReq->req.status = mReq->ptr->token & TD_STATUS;
1498 if ((TD_STATUS_ACTIVE & mReq->req.status) != 0)
1499 mReq->req.status = -ECONNRESET;
1500 else if ((TD_STATUS_HALTED & mReq->req.status) != 0)
1501 mReq->req.status = -1;
1502 else if ((TD_STATUS_DT_ERR & mReq->req.status) != 0)
1503 mReq->req.status = -1;
1504 else if ((TD_STATUS_TR_ERR & mReq->req.status) != 0)
1505 mReq->req.status = -1;
1506
1507 mReq->req.actual = mReq->ptr->token & TD_TOTAL_BYTES;
1508 mReq->req.actual >>= ffs_nr(TD_TOTAL_BYTES);
1509 mReq->req.actual = mReq->req.length - mReq->req.actual;
1510 mReq->req.actual = mReq->req.status ? 0 : mReq->req.actual;
1511
1512 return mReq->req.actual;
1513}
1514
1515/**
1516 * _ep_nuke: dequeues all endpoint requests
1517 * @mEp: endpoint
1518 *
1519 * This function returns an error code
1520 * Caller must hold lock
1521 */
1522static int _ep_nuke(struct ci13xxx_ep *mEp)
1523__releases(mEp->lock)
1524__acquires(mEp->lock)
1525{
1526 trace("%p", mEp);
1527
1528 if (mEp == NULL)
1529 return -EINVAL;
1530
1531 hw_ep_flush(mEp->num, mEp->dir);
1532
1533 while (!list_empty(&mEp->qh[mEp->dir].queue)) {
1534
1535 /* pop oldest request */
1536 struct ci13xxx_req *mReq = \
1537 list_entry(mEp->qh[mEp->dir].queue.next,
1538 struct ci13xxx_req, queue);
1539 list_del_init(&mReq->queue);
1540 mReq->req.status = -ESHUTDOWN;
1541
1542 if (!mReq->req.no_interrupt && mReq->req.complete != NULL) {
1543 spin_unlock(mEp->lock);
1544 mReq->req.complete(&mEp->ep, &mReq->req);
1545 spin_lock(mEp->lock);
1546 }
1547 }
1548 return 0;
1549}
1550
1551/**
1552 * _gadget_stop_activity: stops all USB activity, flushes & disables all endpts
1553 * @gadget: gadget
1554 *
1555 * This function returns an error code
1556 * Caller must hold lock
1557 */
1558static int _gadget_stop_activity(struct usb_gadget *gadget)
1559__releases(udc->lock)
1560__acquires(udc->lock)
1561{
1562 struct usb_ep *ep;
1563 struct ci13xxx *udc = container_of(gadget, struct ci13xxx, gadget);
1564 struct ci13xxx_ep *mEp = container_of(gadget->ep0,
1565 struct ci13xxx_ep, ep);
1566
1567 trace("%p", gadget);
1568
1569 if (gadget == NULL)
1570 return -EINVAL;
1571
1572 spin_unlock(udc->lock);
1573
1574 /* flush all endpoints */
1575 gadget_for_each_ep(ep, gadget) {
1576 usb_ep_fifo_flush(ep);
1577 }
1578 usb_ep_fifo_flush(gadget->ep0);
1579
1580 udc->driver->disconnect(gadget);
1581
1582 /* make sure to disable all endpoints */
1583 gadget_for_each_ep(ep, gadget) {
1584 usb_ep_disable(ep);
1585 }
1586 usb_ep_disable(gadget->ep0);
1587
1588 if (mEp->status != NULL) {
1589 usb_ep_free_request(gadget->ep0, mEp->status);
1590 mEp->status = NULL;
1591 }
1592
1593 spin_lock(udc->lock);
1594
1595 return 0;
1596}
1597
1598/******************************************************************************
1599 * ISR block
1600 *****************************************************************************/
1601/**
1602 * isr_reset_handler: USB reset interrupt handler
1603 * @udc: UDC device
1604 *
1605 * This function resets USB engine after a bus reset occurred
1606 */
1607static void isr_reset_handler(struct ci13xxx *udc)
1608__releases(udc->lock)
1609__acquires(udc->lock)
1610{
1611 struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[0];
1612 int retval;
1613
1614 trace("%p", udc);
1615
1616 if (udc == NULL) {
1617 err("EINVAL");
1618 return;
1619 }
1620
1621 dbg_event(0xFF, "BUS RST", 0);
1622
1623 retval = _gadget_stop_activity(&udc->gadget);
1624 if (retval)
1625 goto done;
1626
1627 retval = hw_usb_reset();
1628 if (retval)
1629 goto done;
1630
1631 spin_unlock(udc->lock);
1632 retval = usb_ep_enable(&mEp->ep, &ctrl_endpt_desc);
1633 if (!retval) {
1634 mEp->status = usb_ep_alloc_request(&mEp->ep, GFP_KERNEL);
1635 if (mEp->status == NULL) {
1636 usb_ep_disable(&mEp->ep);
1637 retval = -ENOMEM;
1638 }
1639 }
1640 spin_lock(udc->lock);
1641
1642 done:
1643 if (retval)
1644 err("error: %i", retval);
1645}
1646
1647/**
1648 * isr_get_status_complete: get_status request complete function
1649 * @ep: endpoint
1650 * @req: request handled
1651 *
1652 * Caller must release lock
1653 */
1654static void isr_get_status_complete(struct usb_ep *ep, struct usb_request *req)
1655{
1656 trace("%p, %p", ep, req);
1657
1658 if (ep == NULL || req == NULL) {
1659 err("EINVAL");
1660 return;
1661 }
1662
1663 kfree(req->buf);
1664 usb_ep_free_request(ep, req);
1665}
1666
1667/**
1668 * isr_get_status_response: get_status request response
1669 * @ep: endpoint
1670 * @setup: setup request packet
1671 *
1672 * This function returns an error code
1673 */
1674static int isr_get_status_response(struct ci13xxx_ep *mEp,
1675 struct usb_ctrlrequest *setup)
1676__releases(mEp->lock)
1677__acquires(mEp->lock)
1678{
1679 struct usb_request *req = NULL;
1680 gfp_t gfp_flags = GFP_ATOMIC;
1681 int dir, num, retval;
1682
1683 trace("%p, %p", mEp, setup);
1684
1685 if (mEp == NULL || setup == NULL)
1686 return -EINVAL;
1687
1688 spin_unlock(mEp->lock);
1689 req = usb_ep_alloc_request(&mEp->ep, gfp_flags);
1690 spin_lock(mEp->lock);
1691 if (req == NULL)
1692 return -ENOMEM;
1693
1694 req->complete = isr_get_status_complete;
1695 req->length = 2;
1696 req->buf = kzalloc(req->length, gfp_flags);
1697 if (req->buf == NULL) {
1698 retval = -ENOMEM;
1699 goto err_free_req;
1700 }
1701
1702 if ((setup->bRequestType & USB_RECIP_MASK) == USB_RECIP_DEVICE) {
1703 /* TODO: D1 - Remote Wakeup; D0 - Self Powered */
1704 retval = 0;
1705 } else if ((setup->bRequestType & USB_RECIP_MASK) \
1706 == USB_RECIP_ENDPOINT) {
1707 dir = (le16_to_cpu(setup->wIndex) & USB_ENDPOINT_DIR_MASK) ?
1708 TX : RX;
1709 num = le16_to_cpu(setup->wIndex) & USB_ENDPOINT_NUMBER_MASK;
1710 *((u16 *)req->buf) = hw_ep_get_halt(num, dir);
1711 }
1712 /* else do nothing; reserved for future use */
1713
1714 spin_unlock(mEp->lock);
1715 retval = usb_ep_queue(&mEp->ep, req, gfp_flags);
1716 spin_lock(mEp->lock);
1717 if (retval)
1718 goto err_free_buf;
1719
1720 return 0;
1721
1722 err_free_buf:
1723 kfree(req->buf);
1724 err_free_req:
1725 spin_unlock(mEp->lock);
1726 usb_ep_free_request(&mEp->ep, req);
1727 spin_lock(mEp->lock);
1728 return retval;
1729}
1730
1731/**
1732 * isr_setup_status_phase: queues the status phase of a setup transation
1733 * @mEp: endpoint
1734 *
1735 * This function returns an error code
1736 */
1737static int isr_setup_status_phase(struct ci13xxx_ep *mEp)
1738__releases(mEp->lock)
1739__acquires(mEp->lock)
1740{
1741 int retval;
1742
1743 trace("%p", mEp);
1744
1745 /* mEp is always valid & configured */
1746
1747 if (mEp->type == USB_ENDPOINT_XFER_CONTROL)
1748 mEp->dir = (mEp->dir == TX) ? RX : TX;
1749
1750 mEp->status->no_interrupt = 1;
1751
1752 spin_unlock(mEp->lock);
1753 retval = usb_ep_queue(&mEp->ep, mEp->status, GFP_ATOMIC);
1754 spin_lock(mEp->lock);
1755
1756 return retval;
1757}
1758
1759/**
1760 * isr_tr_complete_low: transaction complete low level handler
1761 * @mEp: endpoint
1762 *
1763 * This function returns an error code
1764 * Caller must hold lock
1765 */
1766static int isr_tr_complete_low(struct ci13xxx_ep *mEp)
1767__releases(mEp->lock)
1768__acquires(mEp->lock)
1769{
1770 struct ci13xxx_req *mReq;
1771 int retval;
1772
1773 trace("%p", mEp);
1774
1775 if (list_empty(&mEp->qh[mEp->dir].queue))
1776 return -EINVAL;
1777
1778 /* pop oldest request */
1779 mReq = list_entry(mEp->qh[mEp->dir].queue.next,
1780 struct ci13xxx_req, queue);
1781 list_del_init(&mReq->queue);
1782
1783 retval = _hardware_dequeue(mEp, mReq);
1784 if (retval < 0) {
1785 dbg_event(_usb_addr(mEp), "DONE", retval);
1786 goto done;
1787 }
1788
1789 dbg_done(_usb_addr(mEp), mReq->ptr->token, retval);
1790
1791 if (!mReq->req.no_interrupt && mReq->req.complete != NULL) {
1792 spin_unlock(mEp->lock);
1793 mReq->req.complete(&mEp->ep, &mReq->req);
1794 spin_lock(mEp->lock);
1795 }
1796
1797 if (!list_empty(&mEp->qh[mEp->dir].queue)) {
1798 mReq = list_entry(mEp->qh[mEp->dir].queue.next,
1799 struct ci13xxx_req, queue);
1800 _hardware_enqueue(mEp, mReq);
1801 }
1802
1803 done:
1804 return retval;
1805}
1806
1807/**
1808 * isr_tr_complete_handler: transaction complete interrupt handler
1809 * @udc: UDC descriptor
1810 *
1811 * This function handles traffic events
1812 */
1813static void isr_tr_complete_handler(struct ci13xxx *udc)
1814__releases(udc->lock)
1815__acquires(udc->lock)
1816{
1817 unsigned i;
1818
1819 trace("%p", udc);
1820
1821 if (udc == NULL) {
1822 err("EINVAL");
1823 return;
1824 }
1825
1826 for (i = 0; i < hw_ep_max; i++) {
1827 struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i];
1828 int type, num, err = -EINVAL;
1829 struct usb_ctrlrequest req;
1830
1831
1832 if (mEp->desc == NULL)
1833 continue; /* not configured */
1834
1835 if ((mEp->dir == RX && hw_test_and_clear_complete(i)) ||
1836 (mEp->dir == TX && hw_test_and_clear_complete(i + 16))) {
1837 err = isr_tr_complete_low(mEp);
1838 if (mEp->type == USB_ENDPOINT_XFER_CONTROL) {
1839 if (err > 0) /* needs status phase */
1840 err = isr_setup_status_phase(mEp);
1841 if (err < 0) {
1842 dbg_event(_usb_addr(mEp),
1843 "ERROR", err);
1844 spin_unlock(udc->lock);
1845 if (usb_ep_set_halt(&mEp->ep))
1846 err("error: ep_set_halt");
1847 spin_lock(udc->lock);
1848 }
1849 }
1850 }
1851
1852 if (mEp->type != USB_ENDPOINT_XFER_CONTROL ||
1853 !hw_test_and_clear_setup_status(i))
1854 continue;
1855
1856 if (i != 0) {
1857 warn("ctrl traffic received at endpoint");
1858 continue;
1859 }
1860
1861 /* read_setup_packet */
1862 do {
1863 hw_test_and_set_setup_guard();
1864 memcpy(&req, &mEp->qh[RX].ptr->setup, sizeof(req));
1865 } while (!hw_test_and_clear_setup_guard());
1866
1867 type = req.bRequestType;
1868
1869 mEp->dir = (type & USB_DIR_IN) ? TX : RX;
1870
1871 dbg_setup(_usb_addr(mEp), &req);
1872
1873 switch (req.bRequest) {
1874 case USB_REQ_CLEAR_FEATURE:
1875 if (type != (USB_DIR_OUT|USB_RECIP_ENDPOINT) &&
1876 le16_to_cpu(req.wValue) != USB_ENDPOINT_HALT)
1877 goto delegate;
1878 if (req.wLength != 0)
1879 break;
1880 num = le16_to_cpu(req.wIndex);
1881 num &= USB_ENDPOINT_NUMBER_MASK;
1882 if (!udc->ci13xxx_ep[num].wedge) {
1883 spin_unlock(udc->lock);
1884 err = usb_ep_clear_halt(
1885 &udc->ci13xxx_ep[num].ep);
1886 spin_lock(udc->lock);
1887 if (err)
1888 break;
1889 }
1890 err = isr_setup_status_phase(mEp);
1891 break;
1892 case USB_REQ_GET_STATUS:
1893 if (type != (USB_DIR_IN|USB_RECIP_DEVICE) &&
1894 type != (USB_DIR_IN|USB_RECIP_ENDPOINT) &&
1895 type != (USB_DIR_IN|USB_RECIP_INTERFACE))
1896 goto delegate;
1897 if (le16_to_cpu(req.wLength) != 2 ||
1898 le16_to_cpu(req.wValue) != 0)
1899 break;
1900 err = isr_get_status_response(mEp, &req);
1901 break;
1902 case USB_REQ_SET_ADDRESS:
1903 if (type != (USB_DIR_OUT|USB_RECIP_DEVICE))
1904 goto delegate;
1905 if (le16_to_cpu(req.wLength) != 0 ||
1906 le16_to_cpu(req.wIndex) != 0)
1907 break;
1908 err = hw_usb_set_address((u8)le16_to_cpu(req.wValue));
1909 if (err)
1910 break;
1911 err = isr_setup_status_phase(mEp);
1912 break;
1913 case USB_REQ_SET_FEATURE:
1914 if (type != (USB_DIR_OUT|USB_RECIP_ENDPOINT) &&
1915 le16_to_cpu(req.wValue) != USB_ENDPOINT_HALT)
1916 goto delegate;
1917 if (req.wLength != 0)
1918 break;
1919 num = le16_to_cpu(req.wIndex);
1920 num &= USB_ENDPOINT_NUMBER_MASK;
1921
1922 spin_unlock(udc->lock);
1923 err = usb_ep_set_halt(&udc->ci13xxx_ep[num].ep);
1924 spin_lock(udc->lock);
1925 if (err)
1926 break;
1927 err = isr_setup_status_phase(mEp);
1928 break;
1929 default:
1930delegate:
1931 if (req.wLength == 0) /* no data phase */
1932 mEp->dir = TX;
1933
1934 spin_unlock(udc->lock);
1935 err = udc->driver->setup(&udc->gadget, &req);
1936 spin_lock(udc->lock);
1937 break;
1938 }
1939
1940 if (err < 0) {
1941 dbg_event(_usb_addr(mEp), "ERROR", err);
1942
1943 spin_unlock(udc->lock);
1944 if (usb_ep_set_halt(&mEp->ep))
1945 err("error: ep_set_halt");
1946 spin_lock(udc->lock);
1947 }
1948 }
1949}
1950
1951/******************************************************************************
1952 * ENDPT block
1953 *****************************************************************************/
1954/**
1955 * ep_enable: configure endpoint, making it usable
1956 *
1957 * Check usb_ep_enable() at "usb_gadget.h" for details
1958 */
1959static int ep_enable(struct usb_ep *ep,
1960 const struct usb_endpoint_descriptor *desc)
1961{
1962 struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep);
1963 int direction, retval = 0;
1964 unsigned long flags;
1965
1966 trace("%p, %p", ep, desc);
1967
1968 if (ep == NULL || desc == NULL)
1969 return -EINVAL;
1970
1971 spin_lock_irqsave(mEp->lock, flags);
1972
1973 /* only internal SW should enable ctrl endpts */
1974
1975 mEp->desc = desc;
1976
1977 if (!list_empty(&mEp->qh[mEp->dir].queue))
1978 warn("enabling a non-empty endpoint!");
1979
1980 mEp->dir = (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) ? TX : RX;
1981 mEp->num = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
1982 mEp->type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
1983
1984 mEp->ep.maxpacket = __constant_le16_to_cpu(desc->wMaxPacketSize);
1985
1986 direction = mEp->dir;
1987 do {
1988 dbg_event(_usb_addr(mEp), "ENABLE", 0);
1989
1990 if (mEp->type == USB_ENDPOINT_XFER_CONTROL)
1991 mEp->qh[mEp->dir].ptr->cap |= QH_IOS;
1992 else if (mEp->type == USB_ENDPOINT_XFER_ISOC)
1993 mEp->qh[mEp->dir].ptr->cap &= ~QH_MULT;
1994 else
1995 mEp->qh[mEp->dir].ptr->cap &= ~QH_ZLT;
1996
1997 mEp->qh[mEp->dir].ptr->cap |=
1998 (mEp->ep.maxpacket << ffs_nr(QH_MAX_PKT)) & QH_MAX_PKT;
1999 mEp->qh[mEp->dir].ptr->td.next |= TD_TERMINATE; /* needed? */
2000
2001 retval |= hw_ep_enable(mEp->num, mEp->dir, mEp->type);
2002
2003 if (mEp->type == USB_ENDPOINT_XFER_CONTROL)
2004 mEp->dir = (mEp->dir == TX) ? RX : TX;
2005
2006 } while (mEp->dir != direction);
2007
2008 spin_unlock_irqrestore(mEp->lock, flags);
2009 return retval;
2010}
2011
2012/**
2013 * ep_disable: endpoint is no longer usable
2014 *
2015 * Check usb_ep_disable() at "usb_gadget.h" for details
2016 */
2017static int ep_disable(struct usb_ep *ep)
2018{
2019 struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep);
2020 int direction, retval = 0;
2021 unsigned long flags;
2022
2023 trace("%p", ep);
2024
2025 if (ep == NULL)
2026 return -EINVAL;
2027 else if (mEp->desc == NULL)
2028 return -EBUSY;
2029
2030 spin_lock_irqsave(mEp->lock, flags);
2031
2032 /* only internal SW should disable ctrl endpts */
2033
2034 direction = mEp->dir;
2035 do {
2036 dbg_event(_usb_addr(mEp), "DISABLE", 0);
2037
2038 retval |= _ep_nuke(mEp);
2039 retval |= hw_ep_disable(mEp->num, mEp->dir);
2040
2041 if (mEp->type == USB_ENDPOINT_XFER_CONTROL)
2042 mEp->dir = (mEp->dir == TX) ? RX : TX;
2043
2044 } while (mEp->dir != direction);
2045
2046 mEp->desc = NULL;
2047
2048 spin_unlock_irqrestore(mEp->lock, flags);
2049 return retval;
2050}
2051
2052/**
2053 * ep_alloc_request: allocate a request object to use with this endpoint
2054 *
2055 * Check usb_ep_alloc_request() at "usb_gadget.h" for details
2056 */
2057static struct usb_request *ep_alloc_request(struct usb_ep *ep, gfp_t gfp_flags)
2058{
2059 struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep);
2060 struct ci13xxx_req *mReq = NULL;
2061 unsigned long flags;
2062
2063 trace("%p, %i", ep, gfp_flags);
2064
2065 if (ep == NULL) {
2066 err("EINVAL");
2067 return NULL;
2068 }
2069
2070 spin_lock_irqsave(mEp->lock, flags);
2071
2072 mReq = kzalloc(sizeof(struct ci13xxx_req), gfp_flags);
2073 if (mReq != NULL) {
2074 INIT_LIST_HEAD(&mReq->queue);
2075
2076 mReq->ptr = dma_pool_alloc(mEp->td_pool, gfp_flags,
2077 &mReq->dma);
2078 if (mReq->ptr == NULL) {
2079 kfree(mReq);
2080 mReq = NULL;
2081 }
2082 }
2083
2084 dbg_event(_usb_addr(mEp), "ALLOC", mReq == NULL);
2085
2086 spin_unlock_irqrestore(mEp->lock, flags);
2087
2088 return (mReq == NULL) ? NULL : &mReq->req;
2089}
2090
2091/**
2092 * ep_free_request: frees a request object
2093 *
2094 * Check usb_ep_free_request() at "usb_gadget.h" for details
2095 */
2096static void ep_free_request(struct usb_ep *ep, struct usb_request *req)
2097{
2098 struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep);
2099 struct ci13xxx_req *mReq = container_of(req, struct ci13xxx_req, req);
2100 unsigned long flags;
2101
2102 trace("%p, %p", ep, req);
2103
2104 if (ep == NULL || req == NULL) {
2105 err("EINVAL");
2106 return;
2107 } else if (!list_empty(&mReq->queue)) {
2108 err("EBUSY");
2109 return;
2110 }
2111
2112 spin_lock_irqsave(mEp->lock, flags);
2113
2114 if (mReq->ptr)
2115 dma_pool_free(mEp->td_pool, mReq->ptr, mReq->dma);
2116 kfree(mReq);
2117
2118 dbg_event(_usb_addr(mEp), "FREE", 0);
2119
2120 spin_unlock_irqrestore(mEp->lock, flags);
2121}
2122
2123/**
2124 * ep_queue: queues (submits) an I/O request to an endpoint
2125 *
2126 * Check usb_ep_queue()* at usb_gadget.h" for details
2127 */
2128static int ep_queue(struct usb_ep *ep, struct usb_request *req,
2129 gfp_t __maybe_unused gfp_flags)
2130{
2131 struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep);
2132 struct ci13xxx_req *mReq = container_of(req, struct ci13xxx_req, req);
2133 int retval = 0;
2134 unsigned long flags;
2135
2136 trace("%p, %p, %X", ep, req, gfp_flags);
2137
2138 if (ep == NULL || req == NULL || mEp->desc == NULL)
2139 return -EINVAL;
2140
2141 spin_lock_irqsave(mEp->lock, flags);
2142
2143 if (mEp->type == USB_ENDPOINT_XFER_CONTROL &&
2144 !list_empty(&mEp->qh[mEp->dir].queue)) {
2145 _ep_nuke(mEp);
2146 retval = -EOVERFLOW;
2147 warn("endpoint ctrl %X nuked", _usb_addr(mEp));
2148 }
2149
2150 /* first nuke then test link, e.g. previous status has not sent */
2151 if (!list_empty(&mReq->queue)) {
2152 retval = -EBUSY;
2153 err("request already in queue");
2154 goto done;
2155 }
2156
2157 if (req->length > (4 * PAGE_SIZE)) {
2158 req->length = (4 * PAGE_SIZE);
2159 retval = -EMSGSIZE;
2160 warn("request length truncated");
2161 }
2162
2163 dbg_queue(_usb_addr(mEp), req, retval);
2164
2165 /* push request */
2166 mReq->req.status = -EINPROGRESS;
2167 mReq->req.actual = 0;
2168 list_add_tail(&mReq->queue, &mEp->qh[mEp->dir].queue);
2169
2170 retval = _hardware_enqueue(mEp, mReq);
2171 if (retval == -EALREADY || retval == -EBUSY) {
2172 dbg_event(_usb_addr(mEp), "QUEUE", retval);
2173 retval = 0;
2174 }
2175
2176 done:
2177 spin_unlock_irqrestore(mEp->lock, flags);
2178 return retval;
2179}
2180
2181/**
2182 * ep_dequeue: dequeues (cancels, unlinks) an I/O request from an endpoint
2183 *
2184 * Check usb_ep_dequeue() at "usb_gadget.h" for details
2185 */
2186static int ep_dequeue(struct usb_ep *ep, struct usb_request *req)
2187{
2188 struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep);
2189 struct ci13xxx_req *mReq = container_of(req, struct ci13xxx_req, req);
2190 unsigned long flags;
2191
2192 trace("%p, %p", ep, req);
2193
2194 if (ep == NULL || req == NULL || mEp->desc == NULL ||
2195 list_empty(&mReq->queue) || list_empty(&mEp->qh[mEp->dir].queue))
2196 return -EINVAL;
2197
2198 spin_lock_irqsave(mEp->lock, flags);
2199
2200 dbg_event(_usb_addr(mEp), "DEQUEUE", 0);
2201
2202 if (mReq->req.status == -EALREADY)
2203 _hardware_dequeue(mEp, mReq);
2204
2205 /* pop request */
2206 list_del_init(&mReq->queue);
2207 req->status = -ECONNRESET;
2208
2209 if (!mReq->req.no_interrupt && mReq->req.complete != NULL) {
2210 spin_unlock(mEp->lock);
2211 mReq->req.complete(&mEp->ep, &mReq->req);
2212 spin_lock(mEp->lock);
2213 }
2214
2215 spin_unlock_irqrestore(mEp->lock, flags);
2216 return 0;
2217}
2218
2219/**
2220 * ep_set_halt: sets the endpoint halt feature
2221 *
2222 * Check usb_ep_set_halt() at "usb_gadget.h" for details
2223 */
2224static int ep_set_halt(struct usb_ep *ep, int value)
2225{
2226 struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep);
2227 int direction, retval = 0;
2228 unsigned long flags;
2229
2230 trace("%p, %i", ep, value);
2231
2232 if (ep == NULL || mEp->desc == NULL)
2233 return -EINVAL;
2234
2235 spin_lock_irqsave(mEp->lock, flags);
2236
2237#ifndef STALL_IN
2238 /* g_file_storage MS compliant but g_zero fails chapter 9 compliance */
2239 if (value && mEp->type == USB_ENDPOINT_XFER_BULK && mEp->dir == TX &&
2240 !list_empty(&mEp->qh[mEp->dir].queue)) {
2241 spin_unlock_irqrestore(mEp->lock, flags);
2242 return -EAGAIN;
2243 }
2244#endif
2245
2246 direction = mEp->dir;
2247 do {
2248 dbg_event(_usb_addr(mEp), "HALT", value);
2249 retval |= hw_ep_set_halt(mEp->num, mEp->dir, value);
2250
2251 if (!value)
2252 mEp->wedge = 0;
2253
2254 if (mEp->type == USB_ENDPOINT_XFER_CONTROL)
2255 mEp->dir = (mEp->dir == TX) ? RX : TX;
2256
2257 } while (mEp->dir != direction);
2258
2259 spin_unlock_irqrestore(mEp->lock, flags);
2260 return retval;
2261}
2262
2263/**
2264 * ep_set_wedge: sets the halt feature and ignores clear requests
2265 *
2266 * Check usb_ep_set_wedge() at "usb_gadget.h" for details
2267 */
2268static int ep_set_wedge(struct usb_ep *ep)
2269{
2270 struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep);
2271 unsigned long flags;
2272
2273 trace("%p", ep);
2274
2275 if (ep == NULL || mEp->desc == NULL)
2276 return -EINVAL;
2277
2278 spin_lock_irqsave(mEp->lock, flags);
2279
2280 dbg_event(_usb_addr(mEp), "WEDGE", 0);
2281 mEp->wedge = 1;
2282
2283 spin_unlock_irqrestore(mEp->lock, flags);
2284
2285 return usb_ep_set_halt(ep);
2286}
2287
2288/**
2289 * ep_fifo_flush: flushes contents of a fifo
2290 *
2291 * Check usb_ep_fifo_flush() at "usb_gadget.h" for details
2292 */
2293static void ep_fifo_flush(struct usb_ep *ep)
2294{
2295 struct ci13xxx_ep *mEp = container_of(ep, struct ci13xxx_ep, ep);
2296 unsigned long flags;
2297
2298 trace("%p", ep);
2299
2300 if (ep == NULL) {
2301 err("%02X: -EINVAL", _usb_addr(mEp));
2302 return;
2303 }
2304
2305 spin_lock_irqsave(mEp->lock, flags);
2306
2307 dbg_event(_usb_addr(mEp), "FFLUSH", 0);
2308 hw_ep_flush(mEp->num, mEp->dir);
2309
2310 spin_unlock_irqrestore(mEp->lock, flags);
2311}
2312
2313/**
2314 * Endpoint-specific part of the API to the USB controller hardware
2315 * Check "usb_gadget.h" for details
2316 */
2317static const struct usb_ep_ops usb_ep_ops = {
2318 .enable = ep_enable,
2319 .disable = ep_disable,
2320 .alloc_request = ep_alloc_request,
2321 .free_request = ep_free_request,
2322 .queue = ep_queue,
2323 .dequeue = ep_dequeue,
2324 .set_halt = ep_set_halt,
2325 .set_wedge = ep_set_wedge,
2326 .fifo_flush = ep_fifo_flush,
2327};
2328
2329/******************************************************************************
2330 * GADGET block
2331 *****************************************************************************/
2332/**
2333 * Device operations part of the API to the USB controller hardware,
2334 * which don't involve endpoints (or i/o)
2335 * Check "usb_gadget.h" for details
2336 */
2337static const struct usb_gadget_ops usb_gadget_ops;
2338
2339/**
2340 * usb_gadget_register_driver: register a gadget driver
2341 *
2342 * Check usb_gadget_register_driver() at "usb_gadget.h" for details
2343 * Interrupts are enabled here
2344 */
2345int usb_gadget_register_driver(struct usb_gadget_driver *driver)
2346{
2347 struct ci13xxx *udc = _udc;
2348 unsigned long i, k, flags;
2349 int retval = -ENOMEM;
2350
2351 trace("%p", driver);
2352
2353 if (driver == NULL ||
2354 driver->bind == NULL ||
2355 driver->unbind == NULL ||
2356 driver->setup == NULL ||
2357 driver->disconnect == NULL ||
2358 driver->suspend == NULL ||
2359 driver->resume == NULL)
2360 return -EINVAL;
2361 else if (udc == NULL)
2362 return -ENODEV;
2363 else if (udc->driver != NULL)
2364 return -EBUSY;
2365
2366 /* alloc resources */
2367 udc->qh_pool = dma_pool_create("ci13xxx_qh", &udc->gadget.dev,
2368 sizeof(struct ci13xxx_qh),
2369 64, PAGE_SIZE);
2370 if (udc->qh_pool == NULL)
2371 return -ENOMEM;
2372
2373 udc->td_pool = dma_pool_create("ci13xxx_td", &udc->gadget.dev,
2374 sizeof(struct ci13xxx_td),
2375 64, PAGE_SIZE);
2376 if (udc->td_pool == NULL) {
2377 dma_pool_destroy(udc->qh_pool);
2378 udc->qh_pool = NULL;
2379 return -ENOMEM;
2380 }
2381
2382 spin_lock_irqsave(udc->lock, flags);
2383
2384 info("hw_ep_max = %d", hw_ep_max);
2385
2386 udc->driver = driver;
2387 udc->gadget.ops = NULL;
2388 udc->gadget.dev.driver = NULL;
2389
2390 retval = 0;
2391 for (i = 0; i < hw_ep_max; i++) {
2392 struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i];
2393
2394 scnprintf(mEp->name, sizeof(mEp->name), "ep%i", (int)i);
2395
2396 mEp->lock = udc->lock;
2397 mEp->device = &udc->gadget.dev;
2398 mEp->td_pool = udc->td_pool;
2399
2400 mEp->ep.name = mEp->name;
2401 mEp->ep.ops = &usb_ep_ops;
2402 mEp->ep.maxpacket = CTRL_PAYLOAD_MAX;
2403
2404 /* this allocation cannot be random */
2405 for (k = RX; k <= TX; k++) {
2406 INIT_LIST_HEAD(&mEp->qh[k].queue);
2407 mEp->qh[k].ptr = dma_pool_alloc(udc->qh_pool,
2408 GFP_KERNEL,
2409 &mEp->qh[k].dma);
2410 if (mEp->qh[k].ptr == NULL)
2411 retval = -ENOMEM;
2412 else
2413 memset(mEp->qh[k].ptr, 0,
2414 sizeof(*mEp->qh[k].ptr));
2415 }
2416 if (i == 0)
2417 udc->gadget.ep0 = &mEp->ep;
2418 else
2419 list_add_tail(&mEp->ep.ep_list, &udc->gadget.ep_list);
2420 }
2421 if (retval)
2422 goto done;
2423
2424 /* bind gadget */
2425 driver->driver.bus = NULL;
2426 udc->gadget.ops = &usb_gadget_ops;
2427 udc->gadget.dev.driver = &driver->driver;
2428
2429 spin_unlock_irqrestore(udc->lock, flags);
2430 retval = driver->bind(&udc->gadget); /* MAY SLEEP */
2431 spin_lock_irqsave(udc->lock, flags);
2432
2433 if (retval) {
2434 udc->gadget.ops = NULL;
2435 udc->gadget.dev.driver = NULL;
2436 goto done;
2437 }
2438
2439 retval = hw_device_state(udc->ci13xxx_ep[0].qh[RX].dma);
2440
2441 done:
2442 spin_unlock_irqrestore(udc->lock, flags);
2443 if (retval)
2444 usb_gadget_unregister_driver(driver);
2445 return retval;
2446}
2447EXPORT_SYMBOL(usb_gadget_register_driver);
2448
2449/**
2450 * usb_gadget_unregister_driver: unregister a gadget driver
2451 *
2452 * Check usb_gadget_unregister_driver() at "usb_gadget.h" for details
2453 */
2454int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
2455{
2456 struct ci13xxx *udc = _udc;
2457 unsigned long i, k, flags;
2458
2459 trace("%p", driver);
2460
2461 if (driver == NULL ||
2462 driver->bind == NULL ||
2463 driver->unbind == NULL ||
2464 driver->setup == NULL ||
2465 driver->disconnect == NULL ||
2466 driver->suspend == NULL ||
2467 driver->resume == NULL ||
2468 driver != udc->driver)
2469 return -EINVAL;
2470
2471 spin_lock_irqsave(udc->lock, flags);
2472
2473 hw_device_state(0);
2474
2475 /* unbind gadget */
2476 if (udc->gadget.ops != NULL) {
2477 _gadget_stop_activity(&udc->gadget);
2478
2479 spin_unlock_irqrestore(udc->lock, flags);
2480 driver->unbind(&udc->gadget); /* MAY SLEEP */
2481 spin_lock_irqsave(udc->lock, flags);
2482
2483 udc->gadget.ops = NULL;
2484 udc->gadget.dev.driver = NULL;
2485 }
2486
2487 /* free resources */
2488 for (i = 0; i < hw_ep_max; i++) {
2489 struct ci13xxx_ep *mEp = &udc->ci13xxx_ep[i];
2490
2491 if (i == 0)
2492 udc->gadget.ep0 = NULL;
2493 else if (!list_empty(&mEp->ep.ep_list))
2494 list_del_init(&mEp->ep.ep_list);
2495
2496 for (k = RX; k <= TX; k++)
2497 if (mEp->qh[k].ptr != NULL)
2498 dma_pool_free(udc->qh_pool,
2499 mEp->qh[k].ptr, mEp->qh[k].dma);
2500 }
2501
2502 udc->driver = NULL;
2503
2504 spin_unlock_irqrestore(udc->lock, flags);
2505
2506 if (udc->td_pool != NULL) {
2507 dma_pool_destroy(udc->td_pool);
2508 udc->td_pool = NULL;
2509 }
2510 if (udc->qh_pool != NULL) {
2511 dma_pool_destroy(udc->qh_pool);
2512 udc->qh_pool = NULL;
2513 }
2514
2515 return 0;
2516}
2517EXPORT_SYMBOL(usb_gadget_unregister_driver);
2518
2519/******************************************************************************
2520 * BUS block
2521 *****************************************************************************/
2522/**
2523 * udc_irq: global interrupt handler
2524 *
2525 * This function returns IRQ_HANDLED if the IRQ has been handled
2526 * It locks access to registers
2527 */
2528static irqreturn_t udc_irq(void)
2529{
2530 struct ci13xxx *udc = _udc;
2531 irqreturn_t retval;
2532 u32 intr;
2533
2534 trace();
2535
2536 if (udc == NULL) {
2537 err("ENODEV");
2538 return IRQ_HANDLED;
2539 }
2540
2541 spin_lock(udc->lock);
2542 intr = hw_test_and_clear_intr_active();
2543 if (intr) {
2544 isr_statistics.hndl.buf[isr_statistics.hndl.idx++] = intr;
2545 isr_statistics.hndl.idx &= ISR_MASK;
2546 isr_statistics.hndl.cnt++;
2547
2548 /* order defines priority - do NOT change it */
2549 if (USBi_URI & intr) {
2550 isr_statistics.uri++;
2551 isr_reset_handler(udc);
2552 }
2553 if (USBi_PCI & intr) {
2554 isr_statistics.pci++;
2555 udc->gadget.speed = hw_port_is_high_speed() ?
2556 USB_SPEED_HIGH : USB_SPEED_FULL;
2557 }
2558 if (USBi_UEI & intr)
2559 isr_statistics.uei++;
2560 if (USBi_UI & intr) {
2561 isr_statistics.ui++;
2562 isr_tr_complete_handler(udc);
2563 }
2564 if (USBi_SLI & intr)
2565 isr_statistics.sli++;
2566 retval = IRQ_HANDLED;
2567 } else {
2568 isr_statistics.none++;
2569 retval = IRQ_NONE;
2570 }
2571 spin_unlock(udc->lock);
2572
2573 return retval;
2574}
2575
2576/**
2577 * udc_release: driver release function
2578 * @dev: device
2579 *
2580 * Currently does nothing
2581 */
2582static void udc_release(struct device *dev)
2583{
2584 trace("%p", dev);
2585
2586 if (dev == NULL)
2587 err("EINVAL");
2588}
2589
2590/**
2591 * udc_probe: parent probe must call this to initialize UDC
2592 * @dev: parent device
2593 * @regs: registers base address
2594 * @name: driver name
2595 *
2596 * This function returns an error code
2597 * No interrupts active, the IRQ has not been requested yet
2598 * Kernel assumes 32-bit DMA operations by default, no need to dma_set_mask
2599 */
2600static int udc_probe(struct device *dev, void __iomem *regs, const char *name)
2601{
2602 struct ci13xxx *udc;
2603 int retval = 0;
2604
2605 trace("%p, %p, %p", dev, regs, name);
2606
2607 if (dev == NULL || regs == NULL || name == NULL)
2608 return -EINVAL;
2609
2610 udc = kzalloc(sizeof(struct ci13xxx), GFP_KERNEL);
2611 if (udc == NULL)
2612 return -ENOMEM;
2613
2614 udc->lock = &udc_lock;
2615
2616 retval = hw_device_reset(regs);
2617 if (retval)
2618 goto done;
2619
2620 udc->gadget.ops = NULL;
2621 udc->gadget.speed = USB_SPEED_UNKNOWN;
2622 udc->gadget.is_dualspeed = 1;
2623 udc->gadget.is_otg = 0;
2624 udc->gadget.name = name;
2625
2626 INIT_LIST_HEAD(&udc->gadget.ep_list);
2627 udc->gadget.ep0 = NULL;
2628
2629 strcpy(udc->gadget.dev.bus_id, "gadget");
2630 udc->gadget.dev.dma_mask = dev->dma_mask;
2631 udc->gadget.dev.parent = dev;
2632 udc->gadget.dev.release = udc_release;
2633
2634 retval = device_register(&udc->gadget.dev);
2635 if (retval)
2636 goto done;
2637
2638#ifdef CONFIG_USB_GADGET_DEBUG_FILES
2639 retval = dbg_create_files(&udc->gadget.dev);
2640#endif
2641 if (retval) {
2642 device_unregister(&udc->gadget.dev);
2643 goto done;
2644 }
2645
2646 _udc = udc;
2647 return retval;
2648
2649 done:
2650 err("error = %i", retval);
2651 kfree(udc);
2652 _udc = NULL;
2653 return retval;
2654}
2655
2656/**
2657 * udc_remove: parent remove must call this to remove UDC
2658 *
2659 * No interrupts active, the IRQ has been released
2660 */
2661static void udc_remove(void)
2662{
2663 struct ci13xxx *udc = _udc;
2664
2665 if (udc == NULL) {
2666 err("EINVAL");
2667 return;
2668 }
2669
2670#ifdef CONFIG_USB_GADGET_DEBUG_FILES
2671 dbg_remove_files(&udc->gadget.dev);
2672#endif
2673 device_unregister(&udc->gadget.dev);
2674
2675 kfree(udc);
2676 _udc = NULL;
2677}
2678
2679/******************************************************************************
2680 * PCI block
2681 *****************************************************************************/
2682/**
2683 * ci13xxx_pci_irq: interrut handler
2684 * @irq: irq number
2685 * @pdev: USB Device Controller interrupt source
2686 *
2687 * This function returns IRQ_HANDLED if the IRQ has been handled
2688 * This is an ISR don't trace, use attribute interface instead
2689 */
2690static irqreturn_t ci13xxx_pci_irq(int irq, void *pdev)
2691{
2692 if (irq == 0) {
2693 dev_err(&((struct pci_dev *)pdev)->dev, "Invalid IRQ0 usage!");
2694 return IRQ_HANDLED;
2695 }
2696 return udc_irq();
2697}
2698
2699/**
2700 * ci13xxx_pci_probe: PCI probe
2701 * @pdev: USB device controller being probed
2702 * @id: PCI hotplug ID connecting controller to UDC framework
2703 *
2704 * This function returns an error code
2705 * Allocates basic PCI resources for this USB device controller, and then
2706 * invokes the udc_probe() method to start the UDC associated with it
2707 */
2708static int __devinit ci13xxx_pci_probe(struct pci_dev *pdev,
2709 const struct pci_device_id *id)
2710{
2711 void __iomem *regs = NULL;
2712 int retval = 0;
2713
2714 if (id == NULL)
2715 return -EINVAL;
2716
2717 retval = pci_enable_device(pdev);
2718 if (retval)
2719 goto done;
2720
2721 if (!pdev->irq) {
2722 dev_err(&pdev->dev, "No IRQ, check BIOS/PCI setup!");
2723 retval = -ENODEV;
2724 goto disable_device;
2725 }
2726
2727 retval = pci_request_regions(pdev, UDC_DRIVER_NAME);
2728 if (retval)
2729 goto disable_device;
2730
2731 /* BAR 0 holds all the registers */
2732 regs = pci_iomap(pdev, 0, 0);
2733 if (!regs) {
2734 dev_err(&pdev->dev, "Error mapping memory!");
2735 retval = -EFAULT;
2736 goto release_regions;
2737 }
2738 pci_set_drvdata(pdev, (__force void *)regs);
2739
2740 pci_set_master(pdev);
2741 pci_try_set_mwi(pdev);
2742
2743 retval = udc_probe(&pdev->dev, regs, UDC_DRIVER_NAME);
2744 if (retval)
2745 goto iounmap;
2746
2747 /* our device does not have MSI capability */
2748
2749 retval = request_irq(pdev->irq, ci13xxx_pci_irq, IRQF_SHARED,
2750 UDC_DRIVER_NAME, pdev);
2751 if (retval)
2752 goto gadget_remove;
2753
2754 return 0;
2755
2756 gadget_remove:
2757 udc_remove();
2758 iounmap:
2759 pci_iounmap(pdev, regs);
2760 release_regions:
2761 pci_release_regions(pdev);
2762 disable_device:
2763 pci_disable_device(pdev);
2764 done:
2765 return retval;
2766}
2767
2768/**
2769 * ci13xxx_pci_remove: PCI remove
2770 * @pdev: USB Device Controller being removed
2771 *
2772 * Reverses the effect of ci13xxx_pci_probe(),
2773 * first invoking the udc_remove() and then releases
2774 * all PCI resources allocated for this USB device controller
2775 */
2776static void __devexit ci13xxx_pci_remove(struct pci_dev *pdev)
2777{
2778 free_irq(pdev->irq, pdev);
2779 udc_remove();
2780 pci_iounmap(pdev, (__force void __iomem *)pci_get_drvdata(pdev));
2781 pci_release_regions(pdev);
2782 pci_disable_device(pdev);
2783}
2784
2785/**
2786 * PCI device table
2787 * PCI device structure
2788 *
2789 * Check "pci.h" for details
2790 */
2791static DEFINE_PCI_DEVICE_TABLE(ci13xxx_pci_id_table) = {
2792 { PCI_DEVICE(0x153F, 0x1004) },
2793 { PCI_DEVICE(0x153F, 0x1006) },
2794 { 0, 0, 0, 0, 0, 0, 0 /* end: all zeroes */ }
2795};
2796MODULE_DEVICE_TABLE(pci, ci13xxx_pci_id_table);
2797
2798static struct pci_driver ci13xxx_pci_driver = {
2799 .name = UDC_DRIVER_NAME,
2800 .id_table = ci13xxx_pci_id_table,
2801 .probe = ci13xxx_pci_probe,
2802 .remove = __devexit_p(ci13xxx_pci_remove),
2803};
2804
2805/**
2806 * ci13xxx_pci_init: module init
2807 *
2808 * Driver load
2809 */
2810static int __init ci13xxx_pci_init(void)
2811{
2812 return pci_register_driver(&ci13xxx_pci_driver);
2813}
2814module_init(ci13xxx_pci_init);
2815
2816/**
2817 * ci13xxx_pci_exit: module exit
2818 *
2819 * Driver unload
2820 */
2821static void __exit ci13xxx_pci_exit(void)
2822{
2823 pci_unregister_driver(&ci13xxx_pci_driver);
2824}
2825module_exit(ci13xxx_pci_exit);
2826
2827MODULE_AUTHOR("MIPS - David Lopo <dlopo@chipidea.mips.com>");
2828MODULE_DESCRIPTION("MIPS CI13XXX USB Peripheral Controller");
2829MODULE_LICENSE("GPL");
2830MODULE_VERSION("June 2008");
diff --git a/drivers/usb/gadget/ci13xxx_udc.h b/drivers/usb/gadget/ci13xxx_udc.h
new file mode 100644
index 000000000000..4026e9cede34
--- /dev/null
+++ b/drivers/usb/gadget/ci13xxx_udc.h
@@ -0,0 +1,195 @@
1/*
2 * ci13xxx_udc.h - structures, registers, and macros MIPS USB IP core
3 *
4 * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved.
5 *
6 * Author: David Lopo
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * Description: MIPS USB IP core family device controller
13 * Structures, registers and logging macros
14 */
15
16#ifndef _CI13XXX_h_
17#define _CI13XXX_h_
18
19/******************************************************************************
20 * DEFINE
21 *****************************************************************************/
22#define ENDPT_MAX (16)
23#define CTRL_PAYLOAD_MAX (64)
24#define RX (0) /* similar to USB_DIR_OUT but can be used as an index */
25#define TX (1) /* similar to USB_DIR_IN but can be used as an index */
26
27/******************************************************************************
28 * STRUCTURES
29 *****************************************************************************/
30/* DMA layout of transfer descriptors */
31struct ci13xxx_td {
32 /* 0 */
33 u32 next;
34#define TD_TERMINATE BIT(0)
35 /* 1 */
36 u32 token;
37#define TD_STATUS (0x00FFUL << 0)
38#define TD_STATUS_TR_ERR BIT(3)
39#define TD_STATUS_DT_ERR BIT(5)
40#define TD_STATUS_HALTED BIT(6)
41#define TD_STATUS_ACTIVE BIT(7)
42#define TD_MULTO (0x0003UL << 10)
43#define TD_IOC BIT(15)
44#define TD_TOTAL_BYTES (0x7FFFUL << 16)
45 /* 2 */
46 u32 page[5];
47#define TD_CURR_OFFSET (0x0FFFUL << 0)
48#define TD_FRAME_NUM (0x07FFUL << 0)
49#define TD_RESERVED_MASK (0x0FFFUL << 0)
50} __attribute__ ((packed));
51
52/* DMA layout of queue heads */
53struct ci13xxx_qh {
54 /* 0 */
55 u32 cap;
56#define QH_IOS BIT(15)
57#define QH_MAX_PKT (0x07FFUL << 16)
58#define QH_ZLT BIT(29)
59#define QH_MULT (0x0003UL << 30)
60 /* 1 */
61 u32 curr;
62 /* 2 - 8 */
63 struct ci13xxx_td td;
64 /* 9 */
65 u32 RESERVED;
66 struct usb_ctrlrequest setup;
67} __attribute__ ((packed));
68
69/* Extension of usb_request */
70struct ci13xxx_req {
71 struct usb_request req;
72 unsigned map;
73 struct list_head queue;
74 struct ci13xxx_td *ptr;
75 dma_addr_t dma;
76};
77
78/* Extension of usb_ep */
79struct ci13xxx_ep {
80 struct usb_ep ep;
81 const struct usb_endpoint_descriptor *desc;
82 u8 dir;
83 u8 num;
84 u8 type;
85 char name[16];
86 struct {
87 struct list_head queue;
88 struct ci13xxx_qh *ptr;
89 dma_addr_t dma;
90 } qh[2];
91 struct usb_request *status;
92 int wedge;
93
94 /* global resources */
95 spinlock_t *lock;
96 struct device *device;
97 struct dma_pool *td_pool;
98};
99
100/* CI13XXX UDC descriptor & global resources */
101struct ci13xxx {
102 spinlock_t *lock; /* ctrl register bank access */
103
104 struct dma_pool *qh_pool; /* DMA pool for queue heads */
105 struct dma_pool *td_pool; /* DMA pool for transfer descs */
106
107 struct usb_gadget gadget; /* USB slave device */
108 struct ci13xxx_ep ci13xxx_ep[ENDPT_MAX]; /* extended endpts */
109
110 struct usb_gadget_driver *driver; /* 3rd party gadget driver */
111};
112
113/******************************************************************************
114 * REGISTERS
115 *****************************************************************************/
116/* register size */
117#define REG_BITS (32)
118
119/* HCCPARAMS */
120#define HCCPARAMS_LEN BIT(17)
121
122/* DCCPARAMS */
123#define DCCPARAMS_DEN (0x1F << 0)
124#define DCCPARAMS_DC BIT(7)
125
126/* TESTMODE */
127#define TESTMODE_FORCE BIT(0)
128
129/* USBCMD */
130#define USBCMD_RS BIT(0)
131#define USBCMD_RST BIT(1)
132#define USBCMD_SUTW BIT(13)
133
134/* USBSTS & USBINTR */
135#define USBi_UI BIT(0)
136#define USBi_UEI BIT(1)
137#define USBi_PCI BIT(2)
138#define USBi_URI BIT(6)
139#define USBi_SLI BIT(8)
140
141/* DEVICEADDR */
142#define DEVICEADDR_USBADRA BIT(24)
143#define DEVICEADDR_USBADR (0x7FUL << 25)
144
145/* PORTSC */
146#define PORTSC_SUSP BIT(7)
147#define PORTSC_HSP BIT(9)
148#define PORTSC_PTC (0x0FUL << 16)
149
150/* DEVLC */
151#define DEVLC_PSPD (0x03UL << 25)
152#define DEVLC_PSPD_HS (0x02UL << 25)
153
154/* USBMODE */
155#define USBMODE_CM (0x03UL << 0)
156#define USBMODE_CM_IDLE (0x00UL << 0)
157#define USBMODE_CM_DEVICE (0x02UL << 0)
158#define USBMODE_CM_HOST (0x03UL << 0)
159#define USBMODE_SLOM BIT(3)
160
161/* ENDPTCTRL */
162#define ENDPTCTRL_RXS BIT(0)
163#define ENDPTCTRL_RXT (0x03UL << 2)
164#define ENDPTCTRL_RXR BIT(6) /* reserved for port 0 */
165#define ENDPTCTRL_RXE BIT(7)
166#define ENDPTCTRL_TXS BIT(16)
167#define ENDPTCTRL_TXT (0x03UL << 18)
168#define ENDPTCTRL_TXR BIT(22) /* reserved for port 0 */
169#define ENDPTCTRL_TXE BIT(23)
170
171/******************************************************************************
172 * LOGGING
173 *****************************************************************************/
174#define ci13xxx_printk(level, format, args...) \
175do { \
176 if (_udc == NULL) \
177 printk(level "[%s] " format "\n", __func__, ## args); \
178 else \
179 dev_printk(level, _udc->gadget.dev.parent, \
180 "[%s] " format "\n", __func__, ## args); \
181} while (0)
182
183#define err(format, args...) ci13xxx_printk(KERN_ERR, format, ## args)
184#define warn(format, args...) ci13xxx_printk(KERN_WARNING, format, ## args)
185#define info(format, args...) ci13xxx_printk(KERN_INFO, format, ## args)
186
187#ifdef TRACE
188#define trace(format, args...) ci13xxx_printk(KERN_DEBUG, format, ## args)
189#define dbg_trace(format, args...) dev_dbg(dev, format, ##args)
190#else
191#define trace(format, args...) do {} while (0)
192#define dbg_trace(format, args...) do {} while (0)
193#endif
194
195#endif /* _CI13XXX_h_ */
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 9462e30192d8..a36b1175b18d 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -161,7 +161,7 @@ ep_matches (
161 /* report address */ 161 /* report address */
162 desc->bEndpointAddress &= USB_DIR_IN; 162 desc->bEndpointAddress &= USB_DIR_IN;
163 if (isdigit (ep->name [2])) { 163 if (isdigit (ep->name [2])) {
164 u8 num = simple_strtol (&ep->name [2], NULL, 10); 164 u8 num = simple_strtoul (&ep->name [2], NULL, 10);
165 desc->bEndpointAddress |= num; 165 desc->bEndpointAddress |= num;
166#ifdef MANY_ENDPOINTS 166#ifdef MANY_ENDPOINTS
167 } else if (desc->bEndpointAddress & USB_DIR_IN) { 167 } else if (desc->bEndpointAddress & USB_DIR_IN) {
diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index d8fc9b32fe36..c0916c7b217e 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -279,6 +279,13 @@ static int pn_net_mtu(struct net_device *dev, int new_mtu)
279 return err; 279 return err;
280} 280}
281 281
282static const struct net_device_ops pn_netdev_ops = {
283 .ndo_open = pn_net_open,
284 .ndo_stop = pn_net_close,
285 .ndo_start_xmit = pn_net_xmit,
286 .ndo_change_mtu = pn_net_mtu,
287};
288
282static void pn_net_setup(struct net_device *dev) 289static void pn_net_setup(struct net_device *dev)
283{ 290{
284 dev->features = 0; 291 dev->features = 0;
@@ -290,12 +297,9 @@ static void pn_net_setup(struct net_device *dev)
290 dev->addr_len = 1; 297 dev->addr_len = 1;
291 dev->tx_queue_len = 1; 298 dev->tx_queue_len = 1;
292 299
300 dev->netdev_ops = &pn_netdev_ops;
293 dev->destructor = free_netdev; 301 dev->destructor = free_netdev;
294 dev->header_ops = &phonet_header_ops; 302 dev->header_ops = &phonet_header_ops;
295 dev->open = pn_net_open;
296 dev->stop = pn_net_close;
297 dev->hard_start_xmit = pn_net_xmit; /* mandatory */
298 dev->change_mtu = pn_net_mtu;
299} 303}
300 304
301/*-------------------------------------------------------------------------*/ 305/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index 2e71368f45b4..b10fa31cc915 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * file_storage.c -- File-backed USB Storage Gadget, for USB development 2 * file_storage.c -- File-backed USB Storage Gadget, for USB development
3 * 3 *
4 * Copyright (C) 2003-2007 Alan Stern 4 * Copyright (C) 2003-2008 Alan Stern
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
@@ -38,16 +38,17 @@
38 38
39/* 39/*
40 * The File-backed Storage Gadget acts as a USB Mass Storage device, 40 * The File-backed Storage Gadget acts as a USB Mass Storage device,
41 * appearing to the host as a disk drive. In addition to providing an 41 * appearing to the host as a disk drive or as a CD-ROM drive. In addition
42 * example of a genuinely useful gadget driver for a USB device, it also 42 * to providing an example of a genuinely useful gadget driver for a USB
43 * illustrates a technique of double-buffering for increased throughput. 43 * device, it also illustrates a technique of double-buffering for increased
44 * Last but not least, it gives an easy way to probe the behavior of the 44 * throughput. Last but not least, it gives an easy way to probe the
45 * Mass Storage drivers in a USB host. 45 * behavior of the Mass Storage drivers in a USB host.
46 * 46 *
47 * Backing storage is provided by a regular file or a block device, specified 47 * Backing storage is provided by a regular file or a block device, specified
48 * by the "file" module parameter. Access can be limited to read-only by 48 * by the "file" module parameter. Access can be limited to read-only by
49 * setting the optional "ro" module parameter. The gadget will indicate that 49 * setting the optional "ro" module parameter. (For CD-ROM emulation,
50 * it has removable media if the optional "removable" module parameter is set. 50 * access is always read-only.) The gadget will indicate that it has
51 * removable media if the optional "removable" module parameter is set.
51 * 52 *
52 * The gadget supports the Control-Bulk (CB), Control-Bulk-Interrupt (CBI), 53 * The gadget supports the Control-Bulk (CB), Control-Bulk-Interrupt (CBI),
53 * and Bulk-Only (also known as Bulk-Bulk-Bulk or BBB) transports, selected 54 * and Bulk-Only (also known as Bulk-Bulk-Bulk or BBB) transports, selected
@@ -64,7 +65,12 @@
64 * The default number of LUNs is taken from the number of "file" elements; 65 * The default number of LUNs is taken from the number of "file" elements;
65 * it is 1 if "file" is not given. If "removable" is not set then a backing 66 * it is 1 if "file" is not given. If "removable" is not set then a backing
66 * file must be specified for each LUN. If it is set, then an unspecified 67 * file must be specified for each LUN. If it is set, then an unspecified
67 * or empty backing filename means the LUN's medium is not loaded. 68 * or empty backing filename means the LUN's medium is not loaded. Ideally
69 * each LUN would be settable independently as a disk drive or a CD-ROM
70 * drive, but currently all LUNs have to be the same type. The CD-ROM
71 * emulation includes a single data track and no audio tracks; hence there
72 * need be only one backing file per LUN. Note also that the CD-ROM block
73 * length is set to 512 rather than the more common value 2048.
68 * 74 *
69 * Requirements are modest; only a bulk-in and a bulk-out endpoint are 75 * Requirements are modest; only a bulk-in and a bulk-out endpoint are
70 * needed (an interrupt-out endpoint is also needed for CBI). The memory 76 * needed (an interrupt-out endpoint is also needed for CBI). The memory
@@ -91,6 +97,8 @@
91 * USB device controller (usually true), 97 * USB device controller (usually true),
92 * boolean to permit the driver to halt 98 * boolean to permit the driver to halt
93 * bulk endpoints 99 * bulk endpoints
100 * cdrom Default false, boolean for whether to emulate
101 * a CD-ROM drive
94 * transport=XXX Default BBB, transport name (CB, CBI, or BBB) 102 * transport=XXX Default BBB, transport name (CB, CBI, or BBB)
95 * protocol=YYY Default SCSI, protocol name (RBC, 8020 or 103 * protocol=YYY Default SCSI, protocol name (RBC, 8020 or
96 * ATAPI, QIC, UFI, 8070, or SCSI; 104 * ATAPI, QIC, UFI, 8070, or SCSI;
@@ -103,15 +111,16 @@
103 * PAGE_CACHE_SIZE) 111 * PAGE_CACHE_SIZE)
104 * 112 *
105 * If CONFIG_USB_FILE_STORAGE_TEST is not set, only the "file", "ro", 113 * If CONFIG_USB_FILE_STORAGE_TEST is not set, only the "file", "ro",
106 * "removable", "luns", and "stall" options are available; default values 114 * "removable", "luns", "stall", and "cdrom" options are available; default
107 * are used for everything else. 115 * values are used for everything else.
108 * 116 *
109 * The pathnames of the backing files and the ro settings are available in 117 * The pathnames of the backing files and the ro settings are available in
110 * the attribute files "file" and "ro" in the lun<n> subdirectory of the 118 * the attribute files "file" and "ro" in the lun<n> subdirectory of the
111 * gadget's sysfs directory. If the "removable" option is set, writing to 119 * gadget's sysfs directory. If the "removable" option is set, writing to
112 * these files will simulate ejecting/loading the medium (writing an empty 120 * these files will simulate ejecting/loading the medium (writing an empty
113 * line means eject) and adjusting a write-enable tab. Changes to the ro 121 * line means eject) and adjusting a write-enable tab. Changes to the ro
114 * setting are not allowed when the medium is loaded. 122 * setting are not allowed when the medium is loaded or if CD-ROM emulation
123 * is being used.
115 * 124 *
116 * This gadget driver is heavily based on "Gadget Zero" by David Brownell. 125 * This gadget driver is heavily based on "Gadget Zero" by David Brownell.
117 * The driver's SCSI command interface was based on the "Information 126 * The driver's SCSI command interface was based on the "Information
@@ -261,7 +270,7 @@
261 270
262#define DRIVER_DESC "File-backed Storage Gadget" 271#define DRIVER_DESC "File-backed Storage Gadget"
263#define DRIVER_NAME "g_file_storage" 272#define DRIVER_NAME "g_file_storage"
264#define DRIVER_VERSION "7 August 2007" 273#define DRIVER_VERSION "20 November 2008"
265 274
266static const char longname[] = DRIVER_DESC; 275static const char longname[] = DRIVER_DESC;
267static const char shortname[] = DRIVER_NAME; 276static const char shortname[] = DRIVER_NAME;
@@ -341,6 +350,7 @@ static struct {
341 350
342 int removable; 351 int removable;
343 int can_stall; 352 int can_stall;
353 int cdrom;
344 354
345 char *transport_parm; 355 char *transport_parm;
346 char *protocol_parm; 356 char *protocol_parm;
@@ -359,6 +369,7 @@ static struct {
359 .protocol_parm = "SCSI", 369 .protocol_parm = "SCSI",
360 .removable = 0, 370 .removable = 0,
361 .can_stall = 1, 371 .can_stall = 1,
372 .cdrom = 0,
362 .vendor = DRIVER_VENDOR_ID, 373 .vendor = DRIVER_VENDOR_ID,
363 .product = DRIVER_PRODUCT_ID, 374 .product = DRIVER_PRODUCT_ID,
364 .release = 0xffff, // Use controller chip type 375 .release = 0xffff, // Use controller chip type
@@ -382,6 +393,9 @@ MODULE_PARM_DESC(removable, "true to simulate removable media");
382module_param_named(stall, mod_data.can_stall, bool, S_IRUGO); 393module_param_named(stall, mod_data.can_stall, bool, S_IRUGO);
383MODULE_PARM_DESC(stall, "false to prevent bulk stalls"); 394MODULE_PARM_DESC(stall, "false to prevent bulk stalls");
384 395
396module_param_named(cdrom, mod_data.cdrom, bool, S_IRUGO);
397MODULE_PARM_DESC(cdrom, "true to emulate cdrom instead of disk");
398
385 399
386/* In the non-TEST version, only the module parameters listed above 400/* In the non-TEST version, only the module parameters listed above
387 * are available. */ 401 * are available. */
@@ -411,6 +425,10 @@ MODULE_PARM_DESC(buflen, "I/O buffer size");
411 425
412/*-------------------------------------------------------------------------*/ 426/*-------------------------------------------------------------------------*/
413 427
428/* SCSI device types */
429#define TYPE_DISK 0x00
430#define TYPE_CDROM 0x05
431
414/* USB protocol value = the transport method */ 432/* USB protocol value = the transport method */
415#define USB_PR_CBI 0x00 // Control/Bulk/Interrupt 433#define USB_PR_CBI 0x00 // Control/Bulk/Interrupt
416#define USB_PR_CB 0x01 // Control/Bulk w/o interrupt 434#define USB_PR_CB 0x01 // Control/Bulk w/o interrupt
@@ -487,6 +505,8 @@ struct interrupt_data {
487#define SC_READ_12 0xa8 505#define SC_READ_12 0xa8
488#define SC_READ_CAPACITY 0x25 506#define SC_READ_CAPACITY 0x25
489#define SC_READ_FORMAT_CAPACITIES 0x23 507#define SC_READ_FORMAT_CAPACITIES 0x23
508#define SC_READ_HEADER 0x44
509#define SC_READ_TOC 0x43
490#define SC_RELEASE 0x17 510#define SC_RELEASE 0x17
491#define SC_REQUEST_SENSE 0x03 511#define SC_REQUEST_SENSE 0x03
492#define SC_RESERVE 0x16 512#define SC_RESERVE 0x16
@@ -2006,23 +2026,28 @@ static int do_inquiry(struct fsg_dev *fsg, struct fsg_buffhd *bh)
2006 u8 *buf = (u8 *) bh->buf; 2026 u8 *buf = (u8 *) bh->buf;
2007 2027
2008 static char vendor_id[] = "Linux "; 2028 static char vendor_id[] = "Linux ";
2009 static char product_id[] = "File-Stor Gadget"; 2029 static char product_disk_id[] = "File-Stor Gadget";
2030 static char product_cdrom_id[] = "File-CD Gadget ";
2010 2031
2011 if (!fsg->curlun) { // Unsupported LUNs are okay 2032 if (!fsg->curlun) { // Unsupported LUNs are okay
2012 fsg->bad_lun_okay = 1; 2033 fsg->bad_lun_okay = 1;
2013 memset(buf, 0, 36); 2034 memset(buf, 0, 36);
2014 buf[0] = 0x7f; // Unsupported, no device-type 2035 buf[0] = 0x7f; // Unsupported, no device-type
2036 buf[4] = 31; // Additional length
2015 return 36; 2037 return 36;
2016 } 2038 }
2017 2039
2018 memset(buf, 0, 8); // Non-removable, direct-access device 2040 memset(buf, 0, 8);
2041 buf[0] = (mod_data.cdrom ? TYPE_CDROM : TYPE_DISK);
2019 if (mod_data.removable) 2042 if (mod_data.removable)
2020 buf[1] = 0x80; 2043 buf[1] = 0x80;
2021 buf[2] = 2; // ANSI SCSI level 2 2044 buf[2] = 2; // ANSI SCSI level 2
2022 buf[3] = 2; // SCSI-2 INQUIRY data format 2045 buf[3] = 2; // SCSI-2 INQUIRY data format
2023 buf[4] = 31; // Additional length 2046 buf[4] = 31; // Additional length
2024 // No special options 2047 // No special options
2025 sprintf(buf + 8, "%-8s%-16s%04x", vendor_id, product_id, 2048 sprintf(buf + 8, "%-8s%-16s%04x", vendor_id,
2049 (mod_data.cdrom ? product_cdrom_id :
2050 product_disk_id),
2026 mod_data.release); 2051 mod_data.release);
2027 return 36; 2052 return 36;
2028} 2053}
@@ -2101,6 +2126,75 @@ static int do_read_capacity(struct fsg_dev *fsg, struct fsg_buffhd *bh)
2101} 2126}
2102 2127
2103 2128
2129static void store_cdrom_address(u8 *dest, int msf, u32 addr)
2130{
2131 if (msf) {
2132 /* Convert to Minutes-Seconds-Frames */
2133 addr >>= 2; /* Convert to 2048-byte frames */
2134 addr += 2*75; /* Lead-in occupies 2 seconds */
2135 dest[3] = addr % 75; /* Frames */
2136 addr /= 75;
2137 dest[2] = addr % 60; /* Seconds */
2138 addr /= 60;
2139 dest[1] = addr; /* Minutes */
2140 dest[0] = 0; /* Reserved */
2141 } else {
2142 /* Absolute sector */
2143 put_be32(dest, addr);
2144 }
2145}
2146
2147static int do_read_header(struct fsg_dev *fsg, struct fsg_buffhd *bh)
2148{
2149 struct lun *curlun = fsg->curlun;
2150 int msf = fsg->cmnd[1] & 0x02;
2151 u32 lba = get_be32(&fsg->cmnd[2]);
2152 u8 *buf = (u8 *) bh->buf;
2153
2154 if ((fsg->cmnd[1] & ~0x02) != 0) { /* Mask away MSF */
2155 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
2156 return -EINVAL;
2157 }
2158 if (lba >= curlun->num_sectors) {
2159 curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE;
2160 return -EINVAL;
2161 }
2162
2163 memset(buf, 0, 8);
2164 buf[0] = 0x01; /* 2048 bytes of user data, rest is EC */
2165 store_cdrom_address(&buf[4], msf, lba);
2166 return 8;
2167}
2168
2169
2170static int do_read_toc(struct fsg_dev *fsg, struct fsg_buffhd *bh)
2171{
2172 struct lun *curlun = fsg->curlun;
2173 int msf = fsg->cmnd[1] & 0x02;
2174 int start_track = fsg->cmnd[6];
2175 u8 *buf = (u8 *) bh->buf;
2176
2177 if ((fsg->cmnd[1] & ~0x02) != 0 || /* Mask away MSF */
2178 start_track > 1) {
2179 curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
2180 return -EINVAL;
2181 }
2182
2183 memset(buf, 0, 20);
2184 buf[1] = (20-2); /* TOC data length */
2185 buf[2] = 1; /* First track number */
2186 buf[3] = 1; /* Last track number */
2187 buf[5] = 0x16; /* Data track, copying allowed */
2188 buf[6] = 0x01; /* Only track is number 1 */
2189 store_cdrom_address(&buf[8], msf, 0);
2190
2191 buf[13] = 0x16; /* Lead-out track is data */
2192 buf[14] = 0xAA; /* Lead-out track number */
2193 store_cdrom_address(&buf[16], msf, curlun->num_sectors);
2194 return 20;
2195}
2196
2197
2104static int do_mode_sense(struct fsg_dev *fsg, struct fsg_buffhd *bh) 2198static int do_mode_sense(struct fsg_dev *fsg, struct fsg_buffhd *bh)
2105{ 2199{
2106 struct lun *curlun = fsg->curlun; 2200 struct lun *curlun = fsg->curlun;
@@ -2848,6 +2942,26 @@ static int do_scsi_command(struct fsg_dev *fsg)
2848 reply = do_read_capacity(fsg, bh); 2942 reply = do_read_capacity(fsg, bh);
2849 break; 2943 break;
2850 2944
2945 case SC_READ_HEADER:
2946 if (!mod_data.cdrom)
2947 goto unknown_cmnd;
2948 fsg->data_size_from_cmnd = get_be16(&fsg->cmnd[7]);
2949 if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
2950 (3<<7) | (0x1f<<1), 1,
2951 "READ HEADER")) == 0)
2952 reply = do_read_header(fsg, bh);
2953 break;
2954
2955 case SC_READ_TOC:
2956 if (!mod_data.cdrom)
2957 goto unknown_cmnd;
2958 fsg->data_size_from_cmnd = get_be16(&fsg->cmnd[7]);
2959 if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
2960 (7<<6) | (1<<1), 1,
2961 "READ TOC")) == 0)
2962 reply = do_read_toc(fsg, bh);
2963 break;
2964
2851 case SC_READ_FORMAT_CAPACITIES: 2965 case SC_READ_FORMAT_CAPACITIES:
2852 fsg->data_size_from_cmnd = get_be16(&fsg->cmnd[7]); 2966 fsg->data_size_from_cmnd = get_be16(&fsg->cmnd[7]);
2853 if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST, 2967 if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
@@ -2933,6 +3047,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
2933 // Fall through 3047 // Fall through
2934 3048
2935 default: 3049 default:
3050 unknown_cmnd:
2936 fsg->data_size_from_cmnd = 0; 3051 fsg->data_size_from_cmnd = 0;
2937 sprintf(unknown, "Unknown x%02x", fsg->cmnd[0]); 3052 sprintf(unknown, "Unknown x%02x", fsg->cmnd[0]);
2938 if ((reply = check_command(fsg, fsg->cmnd_size, 3053 if ((reply = check_command(fsg, fsg->cmnd_size,
@@ -3498,6 +3613,7 @@ static int open_backing_file(struct lun *curlun, const char *filename)
3498 struct inode *inode = NULL; 3613 struct inode *inode = NULL;
3499 loff_t size; 3614 loff_t size;
3500 loff_t num_sectors; 3615 loff_t num_sectors;
3616 loff_t min_sectors;
3501 3617
3502 /* R/W if we can, R/O if we must */ 3618 /* R/W if we can, R/O if we must */
3503 ro = curlun->ro; 3619 ro = curlun->ro;
@@ -3541,8 +3657,19 @@ static int open_backing_file(struct lun *curlun, const char *filename)
3541 rc = (int) size; 3657 rc = (int) size;
3542 goto out; 3658 goto out;
3543 } 3659 }
3544 num_sectors = size >> 9; // File size in 512-byte sectors 3660 num_sectors = size >> 9; // File size in 512-byte blocks
3545 if (num_sectors == 0) { 3661 min_sectors = 1;
3662 if (mod_data.cdrom) {
3663 num_sectors &= ~3; // Reduce to a multiple of 2048
3664 min_sectors = 300*4; // Smallest track is 300 frames
3665 if (num_sectors >= 256*60*75*4) {
3666 num_sectors = (256*60*75 - 1) * 4;
3667 LINFO(curlun, "file too big: %s\n", filename);
3668 LINFO(curlun, "using only first %d blocks\n",
3669 (int) num_sectors);
3670 }
3671 }
3672 if (num_sectors < min_sectors) {
3546 LINFO(curlun, "file too small: %s\n", filename); 3673 LINFO(curlun, "file too small: %s\n", filename);
3547 rc = -ETOOSMALL; 3674 rc = -ETOOSMALL;
3548 goto out; 3675 goto out;
@@ -3845,9 +3972,12 @@ static int __init fsg_bind(struct usb_gadget *gadget)
3845 goto out; 3972 goto out;
3846 3973
3847 if (mod_data.removable) { // Enable the store_xxx attributes 3974 if (mod_data.removable) { // Enable the store_xxx attributes
3848 dev_attr_ro.attr.mode = dev_attr_file.attr.mode = 0644; 3975 dev_attr_file.attr.mode = 0644;
3849 dev_attr_ro.store = store_ro;
3850 dev_attr_file.store = store_file; 3976 dev_attr_file.store = store_file;
3977 if (!mod_data.cdrom) {
3978 dev_attr_ro.attr.mode = 0644;
3979 dev_attr_ro.store = store_ro;
3980 }
3851 } 3981 }
3852 3982
3853 /* Find out how many LUNs there should be */ 3983 /* Find out how many LUNs there should be */
@@ -3872,6 +4002,8 @@ static int __init fsg_bind(struct usb_gadget *gadget)
3872 for (i = 0; i < fsg->nluns; ++i) { 4002 for (i = 0; i < fsg->nluns; ++i) {
3873 curlun = &fsg->luns[i]; 4003 curlun = &fsg->luns[i];
3874 curlun->ro = mod_data.ro[i]; 4004 curlun->ro = mod_data.ro[i];
4005 if (mod_data.cdrom)
4006 curlun->ro = 1;
3875 curlun->dev.release = lun_release; 4007 curlun->dev.release = lun_release;
3876 curlun->dev.parent = &gadget->dev; 4008 curlun->dev.parent = &gadget->dev;
3877 curlun->dev.driver = &fsg_driver.driver; 4009 curlun->dev.driver = &fsg_driver.driver;
@@ -4031,9 +4163,9 @@ static int __init fsg_bind(struct usb_gadget *gadget)
4031 mod_data.protocol_name, mod_data.protocol_type); 4163 mod_data.protocol_name, mod_data.protocol_type);
4032 DBG(fsg, "VendorID=x%04x, ProductID=x%04x, Release=x%04x\n", 4164 DBG(fsg, "VendorID=x%04x, ProductID=x%04x, Release=x%04x\n",
4033 mod_data.vendor, mod_data.product, mod_data.release); 4165 mod_data.vendor, mod_data.product, mod_data.release);
4034 DBG(fsg, "removable=%d, stall=%d, buflen=%u\n", 4166 DBG(fsg, "removable=%d, stall=%d, cdrom=%d, buflen=%u\n",
4035 mod_data.removable, mod_data.can_stall, 4167 mod_data.removable, mod_data.can_stall,
4036 mod_data.buflen); 4168 mod_data.cdrom, mod_data.buflen);
4037 DBG(fsg, "I/O thread pid: %d\n", task_pid_nr(fsg->thread_task)); 4169 DBG(fsg, "I/O thread pid: %d\n", task_pid_nr(fsg->thread_task));
4038 4170
4039 set_bit(REGISTERED, &fsg->atomic_bitflags); 4171 set_bit(REGISTERED, &fsg->atomic_bitflags);
@@ -4050,6 +4182,7 @@ out:
4050 fsg->state = FSG_STATE_TERMINATED; // The thread is dead 4182 fsg->state = FSG_STATE_TERMINATED; // The thread is dead
4051 fsg_unbind(gadget); 4183 fsg_unbind(gadget);
4052 close_all_backing_files(fsg); 4184 close_all_backing_files(fsg);
4185 complete(&fsg->thread_notifier);
4053 return rc; 4186 return rc;
4054} 4187}
4055 4188
diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c
index f40272565098..d6c5bcd40064 100644
--- a/drivers/usb/gadget/fsl_qe_udc.c
+++ b/drivers/usb/gadget/fsl_qe_udc.c
@@ -26,6 +26,7 @@
26#include <linux/ioport.h> 26#include <linux/ioport.h>
27#include <linux/types.h> 27#include <linux/types.h>
28#include <linux/errno.h> 28#include <linux/errno.h>
29#include <linux/err.h>
29#include <linux/slab.h> 30#include <linux/slab.h>
30#include <linux/list.h> 31#include <linux/list.h>
31#include <linux/interrupt.h> 32#include <linux/interrupt.h>
@@ -370,6 +371,9 @@ static int qe_ep_bd_init(struct qe_udc *udc, unsigned char pipe_num)
370 /* alloc multi-ram for BD rings and set the ep parameters */ 371 /* alloc multi-ram for BD rings and set the ep parameters */
371 tmp_addr = cpm_muram_alloc(sizeof(struct qe_bd) * (bdring_len + 372 tmp_addr = cpm_muram_alloc(sizeof(struct qe_bd) * (bdring_len +
372 USB_BDRING_LEN_TX), QE_ALIGNMENT_OF_BD); 373 USB_BDRING_LEN_TX), QE_ALIGNMENT_OF_BD);
374 if (IS_ERR_VALUE(tmp_addr))
375 return -ENOMEM;
376
373 out_be16(&epparam->rbase, (u16)tmp_addr); 377 out_be16(&epparam->rbase, (u16)tmp_addr);
374 out_be16(&epparam->tbase, (u16)(tmp_addr + 378 out_be16(&epparam->tbase, (u16)(tmp_addr +
375 (sizeof(struct qe_bd) * bdring_len))); 379 (sizeof(struct qe_bd) * bdring_len)));
@@ -689,7 +693,7 @@ en_done2:
689en_done1: 693en_done1:
690 spin_unlock_irqrestore(&udc->lock, flags); 694 spin_unlock_irqrestore(&udc->lock, flags);
691en_done: 695en_done:
692 dev_dbg(udc->dev, "failed to initialize %s\n", ep->ep.name); 696 dev_err(udc->dev, "failed to initialize %s\n", ep->ep.name);
693 return -ENODEV; 697 return -ENODEV;
694} 698}
695 699
@@ -2408,6 +2412,8 @@ static struct qe_udc __devinit *qe_udc_config(struct of_device *ofdev)
2408 tmp_addr = cpm_muram_alloc((USB_MAX_ENDPOINTS * 2412 tmp_addr = cpm_muram_alloc((USB_MAX_ENDPOINTS *
2409 sizeof(struct usb_ep_para)), 2413 sizeof(struct usb_ep_para)),
2410 USB_EP_PARA_ALIGNMENT); 2414 USB_EP_PARA_ALIGNMENT);
2415 if (IS_ERR_VALUE(tmp_addr))
2416 goto cleanup;
2411 2417
2412 for (i = 0; i < USB_MAX_ENDPOINTS; i++) { 2418 for (i = 0; i < USB_MAX_ENDPOINTS; i++) {
2413 out_be16(&usbpram->epptr[i], (u16)tmp_addr); 2419 out_be16(&usbpram->epptr[i], (u16)tmp_addr);
@@ -2513,7 +2519,7 @@ static int __devinit qe_udc_probe(struct of_device *ofdev,
2513 /* Initialize the udc structure including QH member and other member */ 2519 /* Initialize the udc structure including QH member and other member */
2514 udc_controller = qe_udc_config(ofdev); 2520 udc_controller = qe_udc_config(ofdev);
2515 if (!udc_controller) { 2521 if (!udc_controller) {
2516 dev_dbg(&ofdev->dev, "udc_controll is NULL\n"); 2522 dev_err(&ofdev->dev, "failed to initialize\n");
2517 return -ENOMEM; 2523 return -ENOMEM;
2518 } 2524 }
2519 2525
@@ -2568,7 +2574,7 @@ static int __devinit qe_udc_probe(struct of_device *ofdev,
2568 /* create a buf for ZLP send, need to remain zeroed */ 2574 /* create a buf for ZLP send, need to remain zeroed */
2569 udc_controller->nullbuf = kzalloc(256, GFP_KERNEL); 2575 udc_controller->nullbuf = kzalloc(256, GFP_KERNEL);
2570 if (udc_controller->nullbuf == NULL) { 2576 if (udc_controller->nullbuf == NULL) {
2571 dev_dbg(udc_controller->dev, "cannot alloc nullbuf\n"); 2577 dev_err(udc_controller->dev, "cannot alloc nullbuf\n");
2572 ret = -ENOMEM; 2578 ret = -ENOMEM;
2573 goto err3; 2579 goto err3;
2574 } 2580 }
diff --git a/drivers/usb/gadget/gadget_chips.h b/drivers/usb/gadget/gadget_chips.h
index 4e3107dd2f34..ec6d439a2aa5 100644
--- a/drivers/usb/gadget/gadget_chips.h
+++ b/drivers/usb/gadget/gadget_chips.h
@@ -110,7 +110,6 @@
110#define gadget_is_at91(g) 0 110#define gadget_is_at91(g) 0
111#endif 111#endif
112 112
113/* status unclear */
114#ifdef CONFIG_USB_GADGET_IMX 113#ifdef CONFIG_USB_GADGET_IMX
115#define gadget_is_imx(g) !strcmp("imx_udc", (g)->name) 114#define gadget_is_imx(g) !strcmp("imx_udc", (g)->name)
116#else 115#else
@@ -158,6 +157,11 @@
158#define gadget_is_fsl_qe(g) 0 157#define gadget_is_fsl_qe(g) 0
159#endif 158#endif
160 159
160#ifdef CONFIG_USB_GADGET_CI13XXX
161#define gadget_is_ci13xxx(g) (!strcmp("ci13xxx_udc", (g)->name))
162#else
163#define gadget_is_ci13xxx(g) 0
164#endif
161 165
162// CONFIG_USB_GADGET_SX2 166// CONFIG_USB_GADGET_SX2
163// CONFIG_USB_GADGET_AU1X00 167// CONFIG_USB_GADGET_AU1X00
@@ -225,6 +229,8 @@ static inline int usb_gadget_controller_number(struct usb_gadget *gadget)
225 return 0x21; 229 return 0x21;
226 else if (gadget_is_fsl_qe(gadget)) 230 else if (gadget_is_fsl_qe(gadget))
227 return 0x22; 231 return 0x22;
232 else if (gadget_is_ci13xxx(gadget))
233 return 0x23;
228 return -ENOENT; 234 return -ENOENT;
229} 235}
230 236
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index 60aa04847b18..63419c4d503c 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -1349,7 +1349,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1349 int retval; 1349 int retval;
1350 1350
1351 if (!driver 1351 if (!driver
1352 || driver->speed != USB_SPEED_FULL 1352 || driver->speed < USB_SPEED_FULL
1353 || !driver->bind 1353 || !driver->bind
1354 || !driver->disconnect 1354 || !driver->disconnect
1355 || !driver->setup) 1355 || !driver->setup)
diff --git a/drivers/usb/gadget/imx_udc.c b/drivers/usb/gadget/imx_udc.c
new file mode 100644
index 000000000000..cde8fdf15d5b
--- /dev/null
+++ b/drivers/usb/gadget/imx_udc.c
@@ -0,0 +1,1516 @@
1/*
2 * driver/usb/gadget/imx_udc.c
3 *
4 * Copyright (C) 2005 Mike Lee(eemike@gmail.com)
5 * Copyright (C) 2008 Darius Augulis <augulis.darius@gmail.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
18#include <linux/init.h>
19#include <linux/kernel.h>
20#include <linux/platform_device.h>
21#include <linux/module.h>
22#include <linux/errno.h>
23#include <linux/list.h>
24#include <linux/interrupt.h>
25#include <linux/io.h>
26#include <linux/irq.h>
27#include <linux/device.h>
28#include <linux/dma-mapping.h>
29#include <linux/clk.h>
30#include <linux/delay.h>
31
32#include <linux/usb/ch9.h>
33#include <linux/usb/gadget.h>
34
35#include <mach/usb.h>
36#include <mach/hardware.h>
37
38#include "imx_udc.h"
39
40static const char driver_name[] = "imx_udc";
41static const char ep0name[] = "ep0";
42
43void ep0_chg_stat(const char *label, struct imx_udc_struct *imx_usb,
44 enum ep0_state stat);
45
46/*******************************************************************************
47 * IMX UDC hardware related functions
48 *******************************************************************************
49 */
50
51void imx_udc_enable(struct imx_udc_struct *imx_usb)
52{
53 int temp = __raw_readl(imx_usb->base + USB_CTRL);
54 __raw_writel(temp | CTRL_FE_ENA | CTRL_AFE_ENA, imx_usb->base + USB_CTRL);
55 imx_usb->gadget.speed = USB_SPEED_FULL;
56}
57
58void imx_udc_disable(struct imx_udc_struct *imx_usb)
59{
60 int temp = __raw_readl(imx_usb->base + USB_CTRL);
61
62 __raw_writel(temp & ~(CTRL_FE_ENA | CTRL_AFE_ENA),
63 imx_usb->base + USB_CTRL);
64
65 ep0_chg_stat(__func__, imx_usb, EP0_IDLE);
66 imx_usb->gadget.speed = USB_SPEED_UNKNOWN;
67}
68
69void imx_udc_reset(struct imx_udc_struct *imx_usb)
70{
71 int temp = __raw_readl(imx_usb->base + USB_ENAB);
72
73 /* set RST bit */
74 __raw_writel(temp | ENAB_RST, imx_usb->base + USB_ENAB);
75
76 /* wait RST bit to clear */
77 do {} while (__raw_readl(imx_usb->base + USB_ENAB) & ENAB_RST);
78
79 /* wait CFG bit to assert */
80 do {} while (!(__raw_readl(imx_usb->base + USB_DADR) & DADR_CFG));
81
82 /* udc module is now ready */
83}
84
85void imx_udc_config(struct imx_udc_struct *imx_usb)
86{
87 u8 ep_conf[5];
88 u8 i, j, cfg;
89 struct imx_ep_struct *imx_ep;
90
91 /* wait CFG bit to assert */
92 do {} while (!(__raw_readl(imx_usb->base + USB_DADR) & DADR_CFG));
93
94 /* Download the endpoint buffer for endpoint 0. */
95 for (j = 0; j < 5; j++) {
96 i = (j == 2 ? imx_usb->imx_ep[0].fifosize : 0x00);
97 __raw_writeb(i, imx_usb->base + USB_DDAT);
98 do {} while (__raw_readl(imx_usb->base + USB_DADR) & DADR_BSY);
99 }
100
101 /* Download the endpoint buffers for endpoints 1-5.
102 * We specify two configurations, one interface
103 */
104 for (cfg = 1; cfg < 3; cfg++) {
105 for (i = 1; i < IMX_USB_NB_EP; i++) {
106 imx_ep = &imx_usb->imx_ep[i];
107 /* EP no | Config no */
108 ep_conf[0] = (i << 4) | (cfg << 2);
109 /* Type | Direction */
110 ep_conf[1] = (imx_ep->bmAttributes << 3) |
111 (EP_DIR(imx_ep) << 2);
112 /* Max packet size */
113 ep_conf[2] = imx_ep->fifosize;
114 /* TRXTYP */
115 ep_conf[3] = 0xC0;
116 /* FIFO no */
117 ep_conf[4] = i;
118
119 D_INI(imx_usb->dev,
120 "<%s> ep%d_conf[%d]:"
121 "[%02x-%02x-%02x-%02x-%02x]\n",
122 __func__, i, cfg,
123 ep_conf[0], ep_conf[1], ep_conf[2],
124 ep_conf[3], ep_conf[4]);
125
126 for (j = 0; j < 5; j++) {
127 __raw_writeb(ep_conf[j],
128 imx_usb->base + USB_DDAT);
129 do {} while (__raw_readl(imx_usb->base + USB_DADR)
130 & DADR_BSY);
131 }
132 }
133 }
134
135 /* wait CFG bit to clear */
136 do {} while (__raw_readl(imx_usb->base + USB_DADR) & DADR_CFG);
137}
138
139void imx_udc_init_irq(struct imx_udc_struct *imx_usb)
140{
141 int i;
142
143 /* Mask and clear all irqs */
144 __raw_writel(0xFFFFFFFF, imx_usb->base + USB_MASK);
145 __raw_writel(0xFFFFFFFF, imx_usb->base + USB_INTR);
146 for (i = 0; i < IMX_USB_NB_EP; i++) {
147 __raw_writel(0x1FF, imx_usb->base + USB_EP_MASK(i));
148 __raw_writel(0x1FF, imx_usb->base + USB_EP_INTR(i));
149 }
150
151 /* Enable USB irqs */
152 __raw_writel(INTR_MSOF | INTR_FRAME_MATCH, imx_usb->base + USB_MASK);
153
154 /* Enable EP0 irqs */
155 __raw_writel(0x1FF & ~(EPINTR_DEVREQ | EPINTR_MDEVREQ | EPINTR_EOT
156 | EPINTR_EOF | EPINTR_FIFO_EMPTY | EPINTR_FIFO_FULL),
157 imx_usb->base + USB_EP_MASK(0));
158}
159
160void imx_udc_init_ep(struct imx_udc_struct *imx_usb)
161{
162 int i, max, temp;
163 struct imx_ep_struct *imx_ep;
164 for (i = 0; i < IMX_USB_NB_EP; i++) {
165 imx_ep = &imx_usb->imx_ep[i];
166 switch (imx_ep->fifosize) {
167 case 8:
168 max = 0;
169 break;
170 case 16:
171 max = 1;
172 break;
173 case 32:
174 max = 2;
175 break;
176 case 64:
177 max = 3;
178 break;
179 default:
180 max = 1;
181 break;
182 }
183 temp = (EP_DIR(imx_ep) << 7) | (max << 5)
184 | (imx_ep->bmAttributes << 3);
185 __raw_writel(temp, imx_usb->base + USB_EP_STAT(i));
186 __raw_writel(temp | EPSTAT_FLUSH, imx_usb->base + USB_EP_STAT(i));
187 D_INI(imx_usb->dev, "<%s> ep%d_stat %08x\n", __func__, i,
188 __raw_readl(imx_usb->base + USB_EP_STAT(i)));
189 }
190}
191
192void imx_udc_init_fifo(struct imx_udc_struct *imx_usb)
193{
194 int i, temp;
195 struct imx_ep_struct *imx_ep;
196 for (i = 0; i < IMX_USB_NB_EP; i++) {
197 imx_ep = &imx_usb->imx_ep[i];
198
199 /* Fifo control */
200 temp = EP_DIR(imx_ep) ? 0x0B000000 : 0x0F000000;
201 __raw_writel(temp, imx_usb->base + USB_EP_FCTRL(i));
202 D_INI(imx_usb->dev, "<%s> ep%d_fctrl %08x\n", __func__, i,
203 __raw_readl(imx_usb->base + USB_EP_FCTRL(i)));
204
205 /* Fifo alarm */
206 temp = (i ? imx_ep->fifosize / 2 : 0);
207 __raw_writel(temp, imx_usb->base + USB_EP_FALRM(i));
208 D_INI(imx_usb->dev, "<%s> ep%d_falrm %08x\n", __func__, i,
209 __raw_readl(imx_usb->base + USB_EP_FALRM(i)));
210 }
211}
212
213static void imx_udc_init(struct imx_udc_struct *imx_usb)
214{
215 /* Reset UDC */
216 imx_udc_reset(imx_usb);
217
218 /* Download config to enpoint buffer */
219 imx_udc_config(imx_usb);
220
221 /* Setup interrups */
222 imx_udc_init_irq(imx_usb);
223
224 /* Setup endpoints */
225 imx_udc_init_ep(imx_usb);
226
227 /* Setup fifos */
228 imx_udc_init_fifo(imx_usb);
229}
230
231void imx_ep_irq_enable(struct imx_ep_struct *imx_ep)
232{
233
234 int i = EP_NO(imx_ep);
235
236 __raw_writel(0x1FF, imx_ep->imx_usb->base + USB_EP_MASK(i));
237 __raw_writel(0x1FF, imx_ep->imx_usb->base + USB_EP_INTR(i));
238 __raw_writel(0x1FF & ~(EPINTR_EOT | EPINTR_EOF),
239 imx_ep->imx_usb->base + USB_EP_MASK(i));
240}
241
242void imx_ep_irq_disable(struct imx_ep_struct *imx_ep)
243{
244
245 int i = EP_NO(imx_ep);
246
247 __raw_writel(0x1FF, imx_ep->imx_usb->base + USB_EP_MASK(i));
248 __raw_writel(0x1FF, imx_ep->imx_usb->base + USB_EP_INTR(i));
249}
250
251int imx_ep_empty(struct imx_ep_struct *imx_ep)
252{
253 struct imx_udc_struct *imx_usb = imx_ep->imx_usb;
254
255 return __raw_readl(imx_usb->base + USB_EP_FSTAT(EP_NO(imx_ep)))
256 & FSTAT_EMPTY;
257}
258
259unsigned imx_fifo_bcount(struct imx_ep_struct *imx_ep)
260{
261 struct imx_udc_struct *imx_usb = imx_ep->imx_usb;
262
263 return (__raw_readl(imx_usb->base + USB_EP_STAT(EP_NO(imx_ep)))
264 & EPSTAT_BCOUNT) >> 16;
265}
266
267void imx_flush(struct imx_ep_struct *imx_ep)
268{
269 struct imx_udc_struct *imx_usb = imx_ep->imx_usb;
270
271 int temp = __raw_readl(imx_usb->base + USB_EP_STAT(EP_NO(imx_ep)));
272 __raw_writel(temp | EPSTAT_FLUSH,
273 imx_usb->base + USB_EP_STAT(EP_NO(imx_ep)));
274}
275
276void imx_ep_stall(struct imx_ep_struct *imx_ep)
277{
278 struct imx_udc_struct *imx_usb = imx_ep->imx_usb;
279 int temp, i;
280
281 D_ERR(imx_usb->dev, "<%s> Forced stall on %s\n", __func__, imx_ep->ep.name);
282
283 imx_flush(imx_ep);
284
285 /* Special care for ep0 */
286 if (EP_NO(imx_ep)) {
287 temp = __raw_readl(imx_usb->base + USB_CTRL);
288 __raw_writel(temp | CTRL_CMDOVER | CTRL_CMDERROR, imx_usb->base + USB_CTRL);
289 do { } while (__raw_readl(imx_usb->base + USB_CTRL) & CTRL_CMDOVER);
290 temp = __raw_readl(imx_usb->base + USB_CTRL);
291 __raw_writel(temp & ~CTRL_CMDERROR, imx_usb->base + USB_CTRL);
292 }
293 else {
294 temp = __raw_readl(imx_usb->base + USB_EP_STAT(EP_NO(imx_ep)));
295 __raw_writel(temp | EPSTAT_STALL,
296 imx_usb->base + USB_EP_STAT(EP_NO(imx_ep)));
297
298 for (i = 0; i < 100; i ++) {
299 temp = __raw_readl(imx_usb->base + USB_EP_STAT(EP_NO(imx_ep)));
300 if (!temp & EPSTAT_STALL)
301 break;
302 udelay(20);
303 }
304 if (i == 50)
305 D_ERR(imx_usb->dev, "<%s> Non finished stall on %s\n",
306 __func__, imx_ep->ep.name);
307 }
308}
309
310static int imx_udc_get_frame(struct usb_gadget *_gadget)
311{
312 struct imx_udc_struct *imx_usb = container_of(_gadget,
313 struct imx_udc_struct, gadget);
314
315 return __raw_readl(imx_usb->base + USB_FRAME) & 0x7FF;
316}
317
318static int imx_udc_wakeup(struct usb_gadget *_gadget)
319{
320 return 0;
321}
322
323/*******************************************************************************
324 * USB request control functions
325 *******************************************************************************
326 */
327
328static void ep_add_request(struct imx_ep_struct *imx_ep, struct imx_request *req)
329{
330 if (unlikely(!req))
331 return;
332
333 req->in_use = 1;
334 list_add_tail(&req->queue, &imx_ep->queue);
335}
336
337static void ep_del_request(struct imx_ep_struct *imx_ep, struct imx_request *req)
338{
339 if (unlikely(!req))
340 return;
341
342 list_del_init(&req->queue);
343 req->in_use = 0;
344}
345
346static void done(struct imx_ep_struct *imx_ep, struct imx_request *req, int status)
347{
348 ep_del_request(imx_ep, req);
349
350 if (likely(req->req.status == -EINPROGRESS))
351 req->req.status = status;
352 else
353 status = req->req.status;
354
355 if (status && status != -ESHUTDOWN)
356 D_ERR(imx_ep->imx_usb->dev,
357 "<%s> complete %s req %p stat %d len %u/%u\n", __func__,
358 imx_ep->ep.name, &req->req, status,
359 req->req.actual, req->req.length);
360
361 req->req.complete(&imx_ep->ep, &req->req);
362}
363
364static void nuke(struct imx_ep_struct *imx_ep, int status)
365{
366 struct imx_request *req;
367
368 while (!list_empty(&imx_ep->queue)) {
369 req = list_entry(imx_ep->queue.next, struct imx_request, queue);
370 done(imx_ep, req, status);
371 }
372}
373
374/*******************************************************************************
375 * Data tansfer over USB functions
376 *******************************************************************************
377 */
378static int read_packet(struct imx_ep_struct *imx_ep, struct imx_request *req)
379{
380 u8 *buf;
381 int bytes_ep, bufferspace, count, i;
382
383 bytes_ep = imx_fifo_bcount(imx_ep);
384 bufferspace = req->req.length - req->req.actual;
385
386 buf = req->req.buf + req->req.actual;
387 prefetchw(buf);
388
389 if (unlikely(imx_ep_empty(imx_ep)))
390 count = 0; /* zlp */
391 else
392 count = min(bytes_ep, bufferspace);
393
394 for (i = count; i > 0; i--)
395 *buf++ = __raw_readb(imx_ep->imx_usb->base
396 + USB_EP_FDAT0(EP_NO(imx_ep)));
397 req->req.actual += count;
398
399 return count;
400}
401
402static int write_packet(struct imx_ep_struct *imx_ep, struct imx_request *req)
403{
404 u8 *buf;
405 int length, count, temp;
406
407 buf = req->req.buf + req->req.actual;
408 prefetch(buf);
409
410 length = min(req->req.length - req->req.actual, (u32)imx_ep->fifosize);
411
412 if (imx_fifo_bcount(imx_ep) + length > imx_ep->fifosize) {
413 D_TRX(imx_ep->imx_usb->dev, "<%s> packet overfill %s fifo\n",
414 __func__, imx_ep->ep.name);
415 return -1;
416 }
417
418 req->req.actual += length;
419 count = length;
420
421 if (!count && req->req.zero) { /* zlp */
422 temp = __raw_readl(imx_ep->imx_usb->base
423 + USB_EP_STAT(EP_NO(imx_ep)));
424 __raw_writel(temp | EPSTAT_ZLPS, imx_ep->imx_usb->base
425 + USB_EP_STAT(EP_NO(imx_ep)));
426 D_TRX(imx_ep->imx_usb->dev, "<%s> zero packet\n", __func__);
427 return 0;
428 }
429
430 while (count--) {
431 if (count == 0) { /* last byte */
432 temp = __raw_readl(imx_ep->imx_usb->base
433 + USB_EP_FCTRL(EP_NO(imx_ep)));
434 __raw_writel(temp | FCTRL_WFR, imx_ep->imx_usb->base
435 + USB_EP_FCTRL(EP_NO(imx_ep)));
436 }
437 __raw_writeb(*buf++,
438 imx_ep->imx_usb->base + USB_EP_FDAT0(EP_NO(imx_ep)));
439 }
440
441 return length;
442}
443
444static int read_fifo(struct imx_ep_struct *imx_ep, struct imx_request *req)
445{
446 int bytes = 0,
447 count,
448 completed = 0;
449
450 while (__raw_readl(imx_ep->imx_usb->base + USB_EP_FSTAT(EP_NO(imx_ep)))
451 & FSTAT_FR) {
452 count = read_packet(imx_ep, req);
453 bytes += count;
454
455 completed = (count != imx_ep->fifosize);
456 if (completed || req->req.actual == req->req.length) {
457 completed = 1;
458 break;
459 }
460 }
461
462 if (completed || !req->req.length) {
463 done(imx_ep, req, 0);
464 D_REQ(imx_ep->imx_usb->dev, "<%s> %s req<%p> %s\n",
465 __func__, imx_ep->ep.name, req,
466 completed ? "completed" : "not completed");
467 if (!EP_NO(imx_ep))
468 ep0_chg_stat(__func__, imx_ep->imx_usb, EP0_IDLE);
469 }
470
471 D_TRX(imx_ep->imx_usb->dev, "<%s> bytes read: %d\n", __func__, bytes);
472
473 return completed;
474}
475
476static int write_fifo(struct imx_ep_struct *imx_ep, struct imx_request *req)
477{
478 int bytes = 0,
479 count,
480 completed = 0;
481
482 while (!completed) {
483 count = write_packet(imx_ep, req);
484 if (count < 0)
485 break; /* busy */
486 bytes += count;
487
488 /* last packet "must be" short (or a zlp) */
489 completed = (count != imx_ep->fifosize);
490
491 if (unlikely(completed)) {
492 done(imx_ep, req, 0);
493 D_REQ(imx_ep->imx_usb->dev, "<%s> %s req<%p> %s\n",
494 __func__, imx_ep->ep.name, req,
495 completed ? "completed" : "not completed");
496 if (!EP_NO(imx_ep))
497 ep0_chg_stat(__func__, imx_ep->imx_usb, EP0_IDLE);
498 }
499 }
500
501 D_TRX(imx_ep->imx_usb->dev, "<%s> bytes sent: %d\n", __func__, bytes);
502
503 return completed;
504}
505
506/*******************************************************************************
507 * Endpoint handlers
508 *******************************************************************************
509 */
510static int handle_ep(struct imx_ep_struct *imx_ep)
511{
512 struct imx_request *req;
513 int completed = 0;
514
515 do {
516 if (!list_empty(&imx_ep->queue))
517 req = list_entry(imx_ep->queue.next,
518 struct imx_request, queue);
519 else {
520 D_REQ(imx_ep->imx_usb->dev, "<%s> no request on %s\n",
521 __func__, imx_ep->ep.name);
522 return 0;
523 }
524
525 if (EP_DIR(imx_ep)) /* to host */
526 completed = write_fifo(imx_ep, req);
527 else /* to device */
528 completed = read_fifo(imx_ep, req);
529
530 dump_ep_stat(__func__, imx_ep);
531
532 } while (completed);
533
534 return 0;
535}
536
537static int handle_ep0(struct imx_ep_struct *imx_ep)
538{
539 struct imx_request *req = NULL;
540 int ret = 0;
541
542 if (!list_empty(&imx_ep->queue))
543 req = list_entry(imx_ep->queue.next, struct imx_request, queue);
544
545 if (req) {
546 switch (imx_ep->imx_usb->ep0state) {
547
548 case EP0_IN_DATA_PHASE: /* GET_DESCRIPTOR */
549 write_fifo(imx_ep, req);
550 break;
551 case EP0_OUT_DATA_PHASE: /* SET_DESCRIPTOR */
552 read_fifo(imx_ep, req);
553 break;
554 default:
555 D_EP0(imx_ep->imx_usb->dev,
556 "<%s> ep0 i/o, odd state %d\n",
557 __func__, imx_ep->imx_usb->ep0state);
558 ep_del_request(imx_ep, req);
559 ret = -EL2HLT;
560 break;
561 }
562 }
563
564 return ret;
565}
566
567static void handle_ep0_devreq(struct imx_udc_struct *imx_usb)
568{
569 struct imx_ep_struct *imx_ep = &imx_usb->imx_ep[0];
570 union {
571 struct usb_ctrlrequest r;
572 u8 raw[8];
573 u32 word[2];
574 } u;
575 int temp, i;
576
577 nuke(imx_ep, -EPROTO);
578
579 /* read SETUP packet */
580 for (i = 0; i < 2; i++) {
581 if (imx_ep_empty(imx_ep)) {
582 D_ERR(imx_usb->dev,
583 "<%s> no setup packet received\n", __func__);
584 goto stall;
585 }
586 u.word[i] = __raw_readl(imx_usb->base + USB_EP_FDAT(EP_NO(imx_ep)));
587 }
588
589 temp = imx_ep_empty(imx_ep);
590 while (!imx_ep_empty(imx_ep)) {
591 i = __raw_readl(imx_usb->base + USB_EP_FDAT(EP_NO(imx_ep)));
592 D_ERR(imx_usb->dev,
593 "<%s> wrong to have extra bytes for setup : 0x%08x\n",
594 __func__, i);
595 }
596 if (!temp)
597 goto stall;
598
599 le16_to_cpus(&u.r.wValue);
600 le16_to_cpus(&u.r.wIndex);
601 le16_to_cpus(&u.r.wLength);
602
603 D_REQ(imx_usb->dev, "<%s> SETUP %02x.%02x v%04x i%04x l%04x\n",
604 __func__, u.r.bRequestType, u.r.bRequest,
605 u.r.wValue, u.r.wIndex, u.r.wLength);
606
607 if (imx_usb->set_config) {
608 /* NACK the host by using CMDOVER */
609 temp = __raw_readl(imx_usb->base + USB_CTRL);
610 __raw_writel(temp | CTRL_CMDOVER, imx_usb->base + USB_CTRL);
611
612 D_ERR(imx_usb->dev,
613 "<%s> set config req is pending, NACK the host\n",
614 __func__);
615 return;
616 }
617
618 if (u.r.bRequestType & USB_DIR_IN)
619 ep0_chg_stat(__func__, imx_usb, EP0_IN_DATA_PHASE);
620 else
621 ep0_chg_stat(__func__, imx_usb, EP0_OUT_DATA_PHASE);
622
623 i = imx_usb->driver->setup(&imx_usb->gadget, &u.r);
624 if (i < 0) {
625 D_ERR(imx_usb->dev, "<%s> device setup error %d\n",
626 __func__, i);
627 goto stall;
628 }
629
630 return;
631stall:
632 D_ERR(imx_usb->dev, "<%s> protocol STALL\n", __func__);
633 imx_ep_stall(imx_ep);
634 ep0_chg_stat(__func__, imx_usb, EP0_STALL);
635 return;
636}
637
638/*******************************************************************************
639 * USB gadget callback functions
640 *******************************************************************************
641 */
642
643static int imx_ep_enable(struct usb_ep *usb_ep,
644 const struct usb_endpoint_descriptor *desc)
645{
646 struct imx_ep_struct *imx_ep = container_of(usb_ep,
647 struct imx_ep_struct, ep);
648 struct imx_udc_struct *imx_usb = imx_ep->imx_usb;
649 unsigned long flags;
650
651 if (!usb_ep
652 || !desc
653 || !EP_NO(imx_ep)
654 || desc->bDescriptorType != USB_DT_ENDPOINT
655 || imx_ep->bEndpointAddress != desc->bEndpointAddress) {
656 D_ERR(imx_usb->dev,
657 "<%s> bad ep or descriptor\n", __func__);
658 return -EINVAL;
659 }
660
661 if (imx_ep->bmAttributes != desc->bmAttributes) {
662 D_ERR(imx_usb->dev,
663 "<%s> %s type mismatch\n", __func__, usb_ep->name);
664 return -EINVAL;
665 }
666
667 if (imx_ep->fifosize < le16_to_cpu(desc->wMaxPacketSize)) {
668 D_ERR(imx_usb->dev,
669 "<%s> bad %s maxpacket\n", __func__, usb_ep->name);
670 return -ERANGE;
671 }
672
673 if (!imx_usb->driver || imx_usb->gadget.speed == USB_SPEED_UNKNOWN) {
674 D_ERR(imx_usb->dev, "<%s> bogus device state\n", __func__);
675 return -ESHUTDOWN;
676 }
677
678 local_irq_save(flags);
679
680 imx_ep->stopped = 0;
681 imx_flush(imx_ep);
682 imx_ep_irq_enable(imx_ep);
683
684 local_irq_restore(flags);
685
686 D_EPX(imx_usb->dev, "<%s> ENABLED %s\n", __func__, usb_ep->name);
687 return 0;
688}
689
690static int imx_ep_disable(struct usb_ep *usb_ep)
691{
692 struct imx_ep_struct *imx_ep = container_of(usb_ep,
693 struct imx_ep_struct, ep);
694 unsigned long flags;
695
696 if (!usb_ep || !EP_NO(imx_ep) || !list_empty(&imx_ep->queue)) {
697 D_ERR(imx_ep->imx_usb->dev, "<%s> %s can not be disabled\n",
698 __func__, usb_ep ? imx_ep->ep.name : NULL);
699 return -EINVAL;
700 }
701
702 local_irq_save(flags);
703
704 imx_ep->stopped = 1;
705 nuke(imx_ep, -ESHUTDOWN);
706 imx_flush(imx_ep);
707 imx_ep_irq_disable(imx_ep);
708
709 local_irq_restore(flags);
710
711 D_EPX(imx_ep->imx_usb->dev,
712 "<%s> DISABLED %s\n", __func__, usb_ep->name);
713 return 0;
714}
715
716static struct usb_request *imx_ep_alloc_request
717 (struct usb_ep *usb_ep, gfp_t gfp_flags)
718{
719 struct imx_request *req;
720
721 req = kzalloc(sizeof *req, gfp_flags);
722 if (!req || !usb_ep)
723 return 0;
724
725 INIT_LIST_HEAD(&req->queue);
726 req->in_use = 0;
727
728 return &req->req;
729}
730
731static void imx_ep_free_request
732 (struct usb_ep *usb_ep, struct usb_request *usb_req)
733{
734 struct imx_request *req;
735
736 req = container_of(usb_req, struct imx_request, req);
737 WARN_ON(!list_empty(&req->queue));
738 kfree(req);
739}
740
741static int imx_ep_queue
742 (struct usb_ep *usb_ep, struct usb_request *usb_req, gfp_t gfp_flags)
743{
744 struct imx_ep_struct *imx_ep;
745 struct imx_udc_struct *imx_usb;
746 struct imx_request *req;
747 unsigned long flags;
748 int ret = 0;
749
750 imx_ep = container_of(usb_ep, struct imx_ep_struct, ep);
751 imx_usb = imx_ep->imx_usb;
752 req = container_of(usb_req, struct imx_request, req);
753
754 /*
755 Special care on IMX udc.
756 Ignore enqueue when after set configuration from the
757 host. This assume all gadget drivers reply set
758 configuration with the next ep0 req enqueue.
759 */
760 if (imx_usb->set_config && !EP_NO(imx_ep)) {
761 imx_usb->set_config = 0;
762 D_EPX(imx_usb->dev,
763 "<%s> gadget reply set config\n", __func__);
764 return 0;
765 }
766
767 if (unlikely(!usb_req || !req || !usb_req->complete || !usb_req->buf)) {
768 D_ERR(imx_usb->dev, "<%s> bad params\n", __func__);
769 return -EINVAL;
770 }
771
772 if (unlikely(!usb_ep || !imx_ep)) {
773 D_ERR(imx_usb->dev, "<%s> bad ep\n", __func__);
774 return -EINVAL;
775 }
776
777 if (!imx_usb->driver || imx_usb->gadget.speed == USB_SPEED_UNKNOWN) {
778 D_ERR(imx_usb->dev, "<%s> bogus device state\n", __func__);
779 return -ESHUTDOWN;
780 }
781
782 local_irq_save(flags);
783
784 /* Debug */
785 D_REQ(imx_usb->dev, "<%s> ep%d %s request for [%d] bytes\n",
786 __func__, EP_NO(imx_ep),
787 ((!EP_NO(imx_ep) && imx_ep->imx_usb->ep0state == EP0_IN_DATA_PHASE)
788 || (EP_NO(imx_ep) && EP_DIR(imx_ep))) ? "IN" : "OUT", usb_req->length);
789 dump_req(__func__, imx_ep, usb_req);
790
791 if (imx_ep->stopped) {
792 usb_req->status = -ESHUTDOWN;
793 ret = -ESHUTDOWN;
794 goto out;
795 }
796
797 if (req->in_use) {
798 D_ERR(imx_usb->dev,
799 "<%s> refusing to queue req %p (already queued)\n",
800 __func__, req);
801 goto out;
802 }
803
804 usb_req->status = -EINPROGRESS;
805 usb_req->actual = 0;
806
807 ep_add_request(imx_ep, req);
808
809 if (!EP_NO(imx_ep))
810 ret = handle_ep0(imx_ep);
811 else
812 ret = handle_ep(imx_ep);
813out:
814 local_irq_restore(flags);
815 return ret;
816}
817
818static int imx_ep_dequeue(struct usb_ep *usb_ep, struct usb_request *usb_req)
819{
820
821 struct imx_ep_struct *imx_ep = container_of
822 (usb_ep, struct imx_ep_struct, ep);
823 struct imx_request *req;
824 unsigned long flags;
825
826 if (unlikely(!usb_ep || !EP_NO(imx_ep))) {
827 D_ERR(imx_ep->imx_usb->dev, "<%s> bad ep\n", __func__);
828 return -EINVAL;
829 }
830
831 local_irq_save(flags);
832
833 /* make sure it's actually queued on this endpoint */
834 list_for_each_entry(req, &imx_ep->queue, queue) {
835 if (&req->req == usb_req)
836 break;
837 }
838 if (&req->req != usb_req) {
839 local_irq_restore(flags);
840 return -EINVAL;
841 }
842
843 done(imx_ep, req, -ECONNRESET);
844
845 local_irq_restore(flags);
846 return 0;
847}
848
849static int imx_ep_set_halt(struct usb_ep *usb_ep, int value)
850{
851 struct imx_ep_struct *imx_ep = container_of
852 (usb_ep, struct imx_ep_struct, ep);
853 unsigned long flags;
854
855 if (unlikely(!usb_ep || !EP_NO(imx_ep))) {
856 D_ERR(imx_ep->imx_usb->dev, "<%s> bad ep\n", __func__);
857 return -EINVAL;
858 }
859
860 local_irq_save(flags);
861
862 if ((imx_ep->bEndpointAddress & USB_DIR_IN)
863 && !list_empty(&imx_ep->queue)) {
864 local_irq_restore(flags);
865 return -EAGAIN;
866 }
867
868 imx_ep_stall(imx_ep);
869
870 local_irq_restore(flags);
871
872 D_EPX(imx_ep->imx_usb->dev, "<%s> %s halt\n", __func__, usb_ep->name);
873 return 0;
874}
875
876static int imx_ep_fifo_status(struct usb_ep *usb_ep)
877{
878 struct imx_ep_struct *imx_ep = container_of
879 (usb_ep, struct imx_ep_struct, ep);
880
881 if (!usb_ep) {
882 D_ERR(imx_ep->imx_usb->dev, "<%s> bad ep\n", __func__);
883 return -ENODEV;
884 }
885
886 if (imx_ep->imx_usb->gadget.speed == USB_SPEED_UNKNOWN)
887 return 0;
888 else
889 return imx_fifo_bcount(imx_ep);
890}
891
892static void imx_ep_fifo_flush(struct usb_ep *usb_ep)
893{
894 struct imx_ep_struct *imx_ep = container_of
895 (usb_ep, struct imx_ep_struct, ep);
896 unsigned long flags;
897
898 local_irq_save(flags);
899
900 if (!usb_ep || !EP_NO(imx_ep) || !list_empty(&imx_ep->queue)) {
901 D_ERR(imx_ep->imx_usb->dev, "<%s> bad ep\n", __func__);
902 local_irq_restore(flags);
903 return;
904 }
905
906 /* toggle and halt bits stay unchanged */
907 imx_flush(imx_ep);
908
909 local_irq_restore(flags);
910}
911
912static struct usb_ep_ops imx_ep_ops = {
913 .enable = imx_ep_enable,
914 .disable = imx_ep_disable,
915
916 .alloc_request = imx_ep_alloc_request,
917 .free_request = imx_ep_free_request,
918
919 .queue = imx_ep_queue,
920 .dequeue = imx_ep_dequeue,
921
922 .set_halt = imx_ep_set_halt,
923 .fifo_status = imx_ep_fifo_status,
924 .fifo_flush = imx_ep_fifo_flush,
925};
926
927/*******************************************************************************
928 * USB endpoint control functions
929 *******************************************************************************
930 */
931
932void ep0_chg_stat(const char *label,
933 struct imx_udc_struct *imx_usb, enum ep0_state stat)
934{
935 D_EP0(imx_usb->dev, "<%s> from %15s to %15s\n",
936 label, state_name[imx_usb->ep0state], state_name[stat]);
937
938 if (imx_usb->ep0state == stat)
939 return;
940
941 imx_usb->ep0state = stat;
942}
943
944static void usb_init_data(struct imx_udc_struct *imx_usb)
945{
946 struct imx_ep_struct *imx_ep;
947 u8 i;
948
949 /* device/ep0 records init */
950 INIT_LIST_HEAD(&imx_usb->gadget.ep_list);
951 INIT_LIST_HEAD(&imx_usb->gadget.ep0->ep_list);
952 ep0_chg_stat(__func__, imx_usb, EP0_IDLE);
953
954 /* basic endpoint records init */
955 for (i = 0; i < IMX_USB_NB_EP; i++) {
956 imx_ep = &imx_usb->imx_ep[i];
957
958 if (i) {
959 list_add_tail(&imx_ep->ep.ep_list,
960 &imx_usb->gadget.ep_list);
961 imx_ep->stopped = 1;
962 } else
963 imx_ep->stopped = 0;
964
965 INIT_LIST_HEAD(&imx_ep->queue);
966 }
967}
968
969static void udc_stop_activity(struct imx_udc_struct *imx_usb,
970 struct usb_gadget_driver *driver)
971{
972 struct imx_ep_struct *imx_ep;
973 int i;
974
975 if (imx_usb->gadget.speed == USB_SPEED_UNKNOWN)
976 driver = NULL;
977
978 /* prevent new request submissions, kill any outstanding requests */
979 for (i = 1; i < IMX_USB_NB_EP; i++) {
980 imx_ep = &imx_usb->imx_ep[i];
981 imx_flush(imx_ep);
982 imx_ep->stopped = 1;
983 imx_ep_irq_disable(imx_ep);
984 nuke(imx_ep, -ESHUTDOWN);
985 }
986
987 imx_usb->cfg = 0;
988 imx_usb->intf = 0;
989 imx_usb->alt = 0;
990
991 if (driver)
992 driver->disconnect(&imx_usb->gadget);
993}
994
995/*******************************************************************************
996 * Interrupt handlers
997 *******************************************************************************
998 */
999
1000static irqreturn_t imx_udc_irq(int irq, void *dev)
1001{
1002 struct imx_udc_struct *imx_usb = dev;
1003 struct usb_ctrlrequest u;
1004 int temp, cfg, intf, alt;
1005 int intr = __raw_readl(imx_usb->base + USB_INTR);
1006
1007 if (intr & (INTR_WAKEUP | INTR_SUSPEND | INTR_RESUME | INTR_RESET_START
1008 | INTR_RESET_STOP | INTR_CFG_CHG)) {
1009 dump_intr(__func__, intr, imx_usb->dev);
1010 dump_usb_stat(__func__, imx_usb);
1011 }
1012
1013 if (!imx_usb->driver) {
1014 /*imx_udc_disable(imx_usb);*/
1015 goto end_irq;
1016 }
1017
1018 if (intr & INTR_WAKEUP) {
1019 if (imx_usb->gadget.speed == USB_SPEED_UNKNOWN
1020 && imx_usb->driver && imx_usb->driver->resume)
1021 imx_usb->driver->resume(&imx_usb->gadget);
1022 imx_usb->set_config = 0;
1023 imx_usb->gadget.speed = USB_SPEED_FULL;
1024 }
1025
1026 if (intr & INTR_SUSPEND) {
1027 if (imx_usb->gadget.speed != USB_SPEED_UNKNOWN
1028 && imx_usb->driver && imx_usb->driver->suspend)
1029 imx_usb->driver->suspend(&imx_usb->gadget);
1030 imx_usb->set_config = 0;
1031 imx_usb->gadget.speed = USB_SPEED_UNKNOWN;
1032 }
1033
1034 if (intr & INTR_RESET_START) {
1035 __raw_writel(intr, imx_usb->base + USB_INTR);
1036 udc_stop_activity(imx_usb, imx_usb->driver);
1037 imx_usb->set_config = 0;
1038 imx_usb->gadget.speed = USB_SPEED_UNKNOWN;
1039 }
1040
1041 if (intr & INTR_RESET_STOP)
1042 imx_usb->gadget.speed = USB_SPEED_FULL;
1043
1044 if (intr & INTR_CFG_CHG) {
1045 __raw_writel(INTR_CFG_CHG, imx_usb->base + USB_INTR);
1046 temp = __raw_readl(imx_usb->base + USB_STAT);
1047 cfg = (temp & STAT_CFG) >> 5;
1048 intf = (temp & STAT_INTF) >> 3;
1049 alt = temp & STAT_ALTSET;
1050
1051 D_REQ(imx_usb->dev,
1052 "<%s> orig config C=%d, I=%d, A=%d / "
1053 "req config C=%d, I=%d, A=%d\n",
1054 __func__, imx_usb->cfg, imx_usb->intf, imx_usb->alt,
1055 cfg, intf, alt);
1056
1057 if (cfg != 1 && cfg != 2)
1058 goto end_irq;
1059
1060 imx_usb->set_config = 0;
1061
1062 /* Config setup */
1063 if (imx_usb->cfg != cfg) {
1064 D_REQ(imx_usb->dev, "<%s> Change config start\n",__func__);
1065 u.bRequest = USB_REQ_SET_CONFIGURATION;
1066 u.bRequestType = USB_DIR_OUT |
1067 USB_TYPE_STANDARD |
1068 USB_RECIP_DEVICE;
1069 u.wValue = cfg;
1070 u.wIndex = 0;
1071 u.wLength = 0;
1072 imx_usb->cfg = cfg;
1073 imx_usb->set_config = 1;
1074 imx_usb->driver->setup(&imx_usb->gadget, &u);
1075 imx_usb->set_config = 0;
1076 D_REQ(imx_usb->dev, "<%s> Change config done\n",__func__);
1077
1078 }
1079 if (imx_usb->intf != intf || imx_usb->alt != alt) {
1080 D_REQ(imx_usb->dev, "<%s> Change interface start\n",__func__);
1081 u.bRequest = USB_REQ_SET_INTERFACE;
1082 u.bRequestType = USB_DIR_OUT |
1083 USB_TYPE_STANDARD |
1084 USB_RECIP_INTERFACE;
1085 u.wValue = alt;
1086 u.wIndex = intf;
1087 u.wLength = 0;
1088 imx_usb->intf = intf;
1089 imx_usb->alt = alt;
1090 imx_usb->set_config = 1;
1091 imx_usb->driver->setup(&imx_usb->gadget, &u);
1092 imx_usb->set_config = 0;
1093 D_REQ(imx_usb->dev, "<%s> Change interface done\n",__func__);
1094 }
1095 }
1096
1097 if (intr & INTR_SOF) {
1098 if (imx_usb->ep0state == EP0_IDLE) {
1099 temp = __raw_readl(imx_usb->base + USB_CTRL);
1100 __raw_writel(temp | CTRL_CMDOVER, imx_usb->base + USB_CTRL);
1101 }
1102 }
1103
1104end_irq:
1105 __raw_writel(intr, imx_usb->base + USB_INTR);
1106 return IRQ_HANDLED;
1107}
1108
1109static irqreturn_t imx_udc_ctrl_irq(int irq, void *dev)
1110{
1111 struct imx_udc_struct *imx_usb = dev;
1112 int intr = __raw_readl(imx_usb->base + USB_EP_INTR(0));
1113
1114 dump_ep_intr(__func__, 0, intr, imx_usb->dev);
1115
1116 if (!imx_usb->driver) {
1117 __raw_writel(intr, imx_usb->base + USB_EP_INTR(0));
1118 return IRQ_HANDLED;
1119 }
1120
1121 /* DEVREQ IRQ has highest priority */
1122 if (intr & (EPINTR_DEVREQ | EPINTR_MDEVREQ))
1123 handle_ep0_devreq(imx_usb);
1124 /* Seem i.MX is missing EOF interrupt sometimes.
1125 * Therefore we monitor both EOF and FIFO_EMPTY interrups
1126 * when transmiting, and both EOF and FIFO_FULL when
1127 * receiving data.
1128 */
1129 else if (intr & (EPINTR_EOF | EPINTR_FIFO_EMPTY | EPINTR_FIFO_FULL))
1130 handle_ep0(&imx_usb->imx_ep[0]);
1131
1132 __raw_writel(intr, imx_usb->base + USB_EP_INTR(0));
1133
1134 return IRQ_HANDLED;
1135}
1136
1137static irqreturn_t imx_udc_bulk_irq(int irq, void *dev)
1138{
1139 struct imx_udc_struct *imx_usb = dev;
1140 struct imx_ep_struct *imx_ep = &imx_usb->imx_ep[irq - USBD_INT0];
1141 int intr = __raw_readl(imx_usb->base + USB_EP_INTR(EP_NO(imx_ep)));
1142
1143 dump_ep_intr(__func__, irq - USBD_INT0, intr, imx_usb->dev);
1144
1145 if (!imx_usb->driver) {
1146 __raw_writel(intr, imx_usb->base + USB_EP_INTR(EP_NO(imx_ep)));
1147 return IRQ_HANDLED;
1148 }
1149
1150 handle_ep(imx_ep);
1151
1152 __raw_writel(intr, imx_usb->base + USB_EP_INTR(EP_NO(imx_ep)));
1153
1154 return IRQ_HANDLED;
1155}
1156
1157irq_handler_t intr_handler(int i)
1158{
1159 switch (i) {
1160 case 0:
1161 return imx_udc_ctrl_irq;
1162 case 1:
1163 case 2:
1164 case 3:
1165 case 4:
1166 case 5:
1167 return imx_udc_bulk_irq;
1168 default:
1169 return imx_udc_irq;
1170 }
1171}
1172
1173/*******************************************************************************
1174 * Static defined IMX UDC structure
1175 *******************************************************************************
1176 */
1177
1178static const struct usb_gadget_ops imx_udc_ops = {
1179 .get_frame = imx_udc_get_frame,
1180 .wakeup = imx_udc_wakeup,
1181};
1182
1183static struct imx_udc_struct controller = {
1184 .gadget = {
1185 .ops = &imx_udc_ops,
1186 .ep0 = &controller.imx_ep[0].ep,
1187 .name = driver_name,
1188 .dev = {
1189 .bus_id = "gadget",
1190 },
1191 },
1192
1193 .imx_ep[0] = {
1194 .ep = {
1195 .name = ep0name,
1196 .ops = &imx_ep_ops,
1197 .maxpacket = 32,
1198 },
1199 .imx_usb = &controller,
1200 .fifosize = 32,
1201 .bEndpointAddress = 0,
1202 .bmAttributes = USB_ENDPOINT_XFER_CONTROL,
1203 },
1204 .imx_ep[1] = {
1205 .ep = {
1206 .name = "ep1in-bulk",
1207 .ops = &imx_ep_ops,
1208 .maxpacket = 64,
1209 },
1210 .imx_usb = &controller,
1211 .fifosize = 64,
1212 .bEndpointAddress = USB_DIR_IN | 1,
1213 .bmAttributes = USB_ENDPOINT_XFER_BULK,
1214 },
1215 .imx_ep[2] = {
1216 .ep = {
1217 .name = "ep2out-bulk",
1218 .ops = &imx_ep_ops,
1219 .maxpacket = 64,
1220 },
1221 .imx_usb = &controller,
1222 .fifosize = 64,
1223 .bEndpointAddress = USB_DIR_OUT | 2,
1224 .bmAttributes = USB_ENDPOINT_XFER_BULK,
1225 },
1226 .imx_ep[3] = {
1227 .ep = {
1228 .name = "ep3out-bulk",
1229 .ops = &imx_ep_ops,
1230 .maxpacket = 32,
1231 },
1232 .imx_usb = &controller,
1233 .fifosize = 32,
1234 .bEndpointAddress = USB_DIR_OUT | 3,
1235 .bmAttributes = USB_ENDPOINT_XFER_BULK,
1236 },
1237 .imx_ep[4] = {
1238 .ep = {
1239 .name = "ep4in-int",
1240 .ops = &imx_ep_ops,
1241 .maxpacket = 32,
1242 },
1243 .imx_usb = &controller,
1244 .fifosize = 32,
1245 .bEndpointAddress = USB_DIR_IN | 4,
1246 .bmAttributes = USB_ENDPOINT_XFER_INT,
1247 },
1248 .imx_ep[5] = {
1249 .ep = {
1250 .name = "ep5out-int",
1251 .ops = &imx_ep_ops,
1252 .maxpacket = 32,
1253 },
1254 .imx_usb = &controller,
1255 .fifosize = 32,
1256 .bEndpointAddress = USB_DIR_OUT | 5,
1257 .bmAttributes = USB_ENDPOINT_XFER_INT,
1258 },
1259};
1260
1261/*******************************************************************************
1262 * USB gadged driver functions
1263 *******************************************************************************
1264 */
1265int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1266{
1267 struct imx_udc_struct *imx_usb = &controller;
1268 int retval;
1269
1270 if (!driver
1271 || driver->speed < USB_SPEED_FULL
1272 || !driver->bind
1273 || !driver->disconnect
1274 || !driver->setup)
1275 return -EINVAL;
1276 if (!imx_usb)
1277 return -ENODEV;
1278 if (imx_usb->driver)
1279 return -EBUSY;
1280
1281 /* first hook up the driver ... */
1282 imx_usb->driver = driver;
1283 imx_usb->gadget.dev.driver = &driver->driver;
1284
1285 retval = device_add(&imx_usb->gadget.dev);
1286 if (retval)
1287 goto fail;
1288 retval = driver->bind(&imx_usb->gadget);
1289 if (retval) {
1290 D_ERR(imx_usb->dev, "<%s> bind to driver %s --> error %d\n",
1291 __func__, driver->driver.name, retval);
1292 device_del(&imx_usb->gadget.dev);
1293
1294 goto fail;
1295 }
1296
1297 D_INI(imx_usb->dev, "<%s> registered gadget driver '%s'\n",
1298 __func__, driver->driver.name);
1299
1300 imx_udc_enable(imx_usb);
1301
1302 return 0;
1303fail:
1304 imx_usb->driver = NULL;
1305 imx_usb->gadget.dev.driver = NULL;
1306 return retval;
1307}
1308EXPORT_SYMBOL(usb_gadget_register_driver);
1309
1310int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1311{
1312 struct imx_udc_struct *imx_usb = &controller;
1313
1314 if (!imx_usb)
1315 return -ENODEV;
1316 if (!driver || driver != imx_usb->driver || !driver->unbind)
1317 return -EINVAL;
1318
1319 udc_stop_activity(imx_usb, driver);
1320 imx_udc_disable(imx_usb);
1321
1322 driver->unbind(&imx_usb->gadget);
1323 imx_usb->gadget.dev.driver = NULL;
1324 imx_usb->driver = NULL;
1325
1326 device_del(&imx_usb->gadget.dev);
1327
1328 D_INI(imx_usb->dev, "<%s> unregistered gadget driver '%s'\n",
1329 __func__, driver->driver.name);
1330
1331 return 0;
1332}
1333EXPORT_SYMBOL(usb_gadget_unregister_driver);
1334
1335/*******************************************************************************
1336 * Module functions
1337 *******************************************************************************
1338 */
1339
1340static int __init imx_udc_probe(struct platform_device *pdev)
1341{
1342 struct imx_udc_struct *imx_usb = &controller;
1343 struct resource *res;
1344 struct imxusb_platform_data *pdata;
1345 struct clk *clk;
1346 void __iomem *base;
1347 int ret = 0;
1348 int i, res_size;
1349
1350 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1351 if (!res) {
1352 dev_err(&pdev->dev, "can't get device resources\n");
1353 return -ENODEV;
1354 }
1355
1356 pdata = pdev->dev.platform_data;
1357 if (!pdata) {
1358 dev_err(&pdev->dev, "driver needs platform data\n");
1359 return -ENODEV;
1360 }
1361
1362 res_size = res->end - res->start + 1;
1363 if (!request_mem_region(res->start, res_size, res->name)) {
1364 dev_err(&pdev->dev, "can't allocate %d bytes at %d address\n",
1365 res_size, res->start);
1366 return -ENOMEM;
1367 }
1368
1369 if (pdata->init) {
1370 ret = pdata->init(&pdev->dev);
1371 if (ret)
1372 goto fail0;
1373 }
1374
1375 base = ioremap(res->start, res_size);
1376 if (!base) {
1377 dev_err(&pdev->dev, "ioremap failed\n");
1378 ret = -EIO;
1379 goto fail1;
1380 }
1381
1382 clk = clk_get(NULL, "usbd_clk");
1383 if (IS_ERR(clk)) {
1384 ret = PTR_ERR(clk);
1385 dev_err(&pdev->dev, "can't get USB clock\n");
1386 goto fail2;
1387 }
1388 clk_enable(clk);
1389
1390 if (clk_get_rate(clk) != 48000000) {
1391 D_INI(&pdev->dev,
1392 "Bad USB clock (%d Hz), changing to 48000000 Hz\n",
1393 (int)clk_get_rate(clk));
1394 if (clk_set_rate(clk, 48000000)) {
1395 dev_err(&pdev->dev,
1396 "Unable to set correct USB clock (48MHz)\n");
1397 ret = -EIO;
1398 goto fail3;
1399 }
1400 }
1401
1402 for (i = 0; i < IMX_USB_NB_EP + 1; i++) {
1403 imx_usb->usbd_int[i] = platform_get_irq(pdev, i);
1404 if (imx_usb->usbd_int[i] < 0) {
1405 dev_err(&pdev->dev, "can't get irq number\n");
1406 ret = -ENODEV;
1407 goto fail3;
1408 }
1409 }
1410
1411 for (i = 0; i < IMX_USB_NB_EP + 1; i++) {
1412 ret = request_irq(imx_usb->usbd_int[i], intr_handler(i),
1413 IRQF_DISABLED, driver_name, imx_usb);
1414 if (ret) {
1415 dev_err(&pdev->dev, "can't get irq %i, err %d\n",
1416 imx_usb->usbd_int[i], ret);
1417 for (--i; i >= 0; i--)
1418 free_irq(imx_usb->usbd_int[i], imx_usb);
1419 goto fail3;
1420 }
1421 }
1422
1423 imx_usb->res = res;
1424 imx_usb->base = base;
1425 imx_usb->clk = clk;
1426 imx_usb->dev = &pdev->dev;
1427
1428 device_initialize(&imx_usb->gadget.dev);
1429
1430 imx_usb->gadget.dev.parent = &pdev->dev;
1431 imx_usb->gadget.dev.dma_mask = pdev->dev.dma_mask;
1432
1433 platform_set_drvdata(pdev, imx_usb);
1434
1435 usb_init_data(imx_usb);
1436 imx_udc_init(imx_usb);
1437
1438 return 0;
1439
1440fail3:
1441 clk_put(clk);
1442 clk_disable(clk);
1443fail2:
1444 iounmap(base);
1445fail1:
1446 if (pdata->exit)
1447 pdata->exit(&pdev->dev);
1448fail0:
1449 release_mem_region(res->start, res_size);
1450 return ret;
1451}
1452
1453static int __exit imx_udc_remove(struct platform_device *pdev)
1454{
1455 struct imx_udc_struct *imx_usb = platform_get_drvdata(pdev);
1456 struct imxusb_platform_data *pdata = pdev->dev.platform_data;
1457 int i;
1458
1459 imx_udc_disable(imx_usb);
1460
1461 for (i = 0; i < IMX_USB_NB_EP + 1; i++)
1462 free_irq(imx_usb->usbd_int[i], imx_usb);
1463
1464 clk_put(imx_usb->clk);
1465 clk_disable(imx_usb->clk);
1466 iounmap(imx_usb->base);
1467
1468 release_mem_region(imx_usb->res->start,
1469 imx_usb->res->end - imx_usb->res->start + 1);
1470
1471 if (pdata->exit)
1472 pdata->exit(&pdev->dev);
1473
1474 platform_set_drvdata(pdev, NULL);
1475
1476 return 0;
1477}
1478
1479/*----------------------------------------------------------------------------*/
1480
1481#ifdef CONFIG_PM
1482#define imx_udc_suspend NULL
1483#define imx_udc_resume NULL
1484#else
1485#define imx_udc_suspend NULL
1486#define imx_udc_resume NULL
1487#endif
1488
1489/*----------------------------------------------------------------------------*/
1490
1491static struct platform_driver udc_driver = {
1492 .driver = {
1493 .name = driver_name,
1494 .owner = THIS_MODULE,
1495 },
1496 .remove = __exit_p(imx_udc_remove),
1497 .suspend = imx_udc_suspend,
1498 .resume = imx_udc_resume,
1499};
1500
1501static int __init udc_init(void)
1502{
1503 return platform_driver_probe(&udc_driver, imx_udc_probe);
1504}
1505module_init(udc_init);
1506
1507static void __exit udc_exit(void)
1508{
1509 platform_driver_unregister(&udc_driver);
1510}
1511module_exit(udc_exit);
1512
1513MODULE_DESCRIPTION("IMX USB Device Controller driver");
1514MODULE_AUTHOR("Darius Augulis <augulis.darius@gmail.com>");
1515MODULE_LICENSE("GPL");
1516MODULE_ALIAS("platform:imx_udc");
diff --git a/drivers/usb/gadget/imx_udc.h b/drivers/usb/gadget/imx_udc.h
new file mode 100644
index 000000000000..850076937d8d
--- /dev/null
+++ b/drivers/usb/gadget/imx_udc.h
@@ -0,0 +1,344 @@
1/*
2 * Copyright (C) 2005 Mike Lee(eemike@gmail.com)
3 *
4 * This udc driver is now under testing and code is based on pxa2xx_udc.h
5 * Please use it with your own risk!
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
18#ifndef __LINUX_USB_GADGET_IMX_H
19#define __LINUX_USB_GADGET_IMX_H
20
21#include <linux/types.h>
22
23/* Helper macros */
24#define EP_NO(ep) ((ep->bEndpointAddress) & ~USB_DIR_IN) /* IN:1, OUT:0 */
25#define EP_DIR(ep) ((ep->bEndpointAddress) & USB_DIR_IN ? 1 : 0)
26#define irq_to_ep(irq) (((irq) >= USBD_INT0) || ((irq) <= USBD_INT6) ? ((irq) - USBD_INT0) : (USBD_INT6)) /*should not happen*/
27#define ep_to_irq(ep) (EP_NO((ep)) + USBD_INT0)
28#define IMX_USB_NB_EP 6
29
30/* Driver structures */
31struct imx_request {
32 struct usb_request req;
33 struct list_head queue;
34 unsigned int in_use;
35};
36
37enum ep0_state {
38 EP0_IDLE,
39 EP0_IN_DATA_PHASE,
40 EP0_OUT_DATA_PHASE,
41 EP0_CONFIG,
42 EP0_STALL,
43};
44
45struct imx_ep_struct {
46 struct usb_ep ep;
47 struct imx_udc_struct *imx_usb;
48 struct list_head queue;
49 unsigned char stopped;
50 unsigned char fifosize;
51 unsigned char bEndpointAddress;
52 unsigned char bmAttributes;
53};
54
55struct imx_udc_struct {
56 struct usb_gadget gadget;
57 struct usb_gadget_driver *driver;
58 struct device *dev;
59 struct imx_ep_struct imx_ep[IMX_USB_NB_EP];
60 struct clk *clk;
61 enum ep0_state ep0state;
62 struct resource *res;
63 void __iomem *base;
64 unsigned char set_config;
65 int cfg,
66 intf,
67 alt,
68 usbd_int[7];
69};
70
71/* USB registers */
72#define USB_FRAME (0x00) /* USB frame */
73#define USB_SPEC (0x04) /* USB Spec */
74#define USB_STAT (0x08) /* USB Status */
75#define USB_CTRL (0x0C) /* USB Control */
76#define USB_DADR (0x10) /* USB Desc RAM addr */
77#define USB_DDAT (0x14) /* USB Desc RAM/EP buffer data */
78#define USB_INTR (0x18) /* USB interrupt */
79#define USB_MASK (0x1C) /* USB Mask */
80#define USB_ENAB (0x24) /* USB Enable */
81#define USB_EP_STAT(x) (0x30 + (x*0x30)) /* USB status/control */
82#define USB_EP_INTR(x) (0x34 + (x*0x30)) /* USB interrupt */
83#define USB_EP_MASK(x) (0x38 + (x*0x30)) /* USB mask */
84#define USB_EP_FDAT(x) (0x3C + (x*0x30)) /* USB FIFO data */
85#define USB_EP_FDAT0(x) (0x3C + (x*0x30)) /* USB FIFO data */
86#define USB_EP_FDAT1(x) (0x3D + (x*0x30)) /* USB FIFO data */
87#define USB_EP_FDAT2(x) (0x3E + (x*0x30)) /* USB FIFO data */
88#define USB_EP_FDAT3(x) (0x3F + (x*0x30)) /* USB FIFO data */
89#define USB_EP_FSTAT(x) (0x40 + (x*0x30)) /* USB FIFO status */
90#define USB_EP_FCTRL(x) (0x44 + (x*0x30)) /* USB FIFO control */
91#define USB_EP_LRFP(x) (0x48 + (x*0x30)) /* USB last read frame pointer */
92#define USB_EP_LWFP(x) (0x4C + (x*0x30)) /* USB last write frame pointer */
93#define USB_EP_FALRM(x) (0x50 + (x*0x30)) /* USB FIFO alarm */
94#define USB_EP_FRDP(x) (0x54 + (x*0x30)) /* USB FIFO read pointer */
95#define USB_EP_FWRP(x) (0x58 + (x*0x30)) /* USB FIFO write pointer */
96/* USB Control Register Bit Fields.*/
97#define CTRL_CMDOVER (1<<6) /* UDC status */
98#define CTRL_CMDERROR (1<<5) /* UDC status */
99#define CTRL_FE_ENA (1<<3) /* Enable Font End logic */
100#define CTRL_UDC_RST (1<<2) /* UDC reset */
101#define CTRL_AFE_ENA (1<<1) /* Analog Font end enable */
102#define CTRL_RESUME (1<<0) /* UDC resume */
103/* USB Status Register Bit Fields.*/
104#define STAT_RST (1<<8)
105#define STAT_SUSP (1<<7)
106#define STAT_CFG (3<<5)
107#define STAT_INTF (3<<3)
108#define STAT_ALTSET (7<<0)
109/* USB Interrupt Status/Mask Registers Bit fields */
110#define INTR_WAKEUP (1<<31) /* Wake up Interrupt */
111#define INTR_MSOF (1<<7) /* Missed Start of Frame */
112#define INTR_SOF (1<<6) /* Start of Frame */
113#define INTR_RESET_STOP (1<<5) /* Reset Signaling stop */
114#define INTR_RESET_START (1<<4) /* Reset Signaling start */
115#define INTR_RESUME (1<<3) /* Suspend to resume */
116#define INTR_SUSPEND (1<<2) /* Active to suspend */
117#define INTR_FRAME_MATCH (1<<1) /* Frame matched */
118#define INTR_CFG_CHG (1<<0) /* Configuration change occurred */
119/* USB Enable Register Bit Fields.*/
120#define ENAB_RST (1<<31) /* Reset USB modules */
121#define ENAB_ENAB (1<<30) /* Enable USB modules*/
122#define ENAB_SUSPEND (1<<29) /* Suspend USB modules */
123#define ENAB_ENDIAN (1<<28) /* Endian of USB modules */
124#define ENAB_PWRMD (1<<0) /* Power mode of USB modules */
125/* USB Descriptor Ram Address Register bit fields */
126#define DADR_CFG (1<<31) /* Configuration */
127#define DADR_BSY (1<<30) /* Busy status */
128#define DADR_DADR (0x1FF) /* Descriptor Ram Address */
129/* USB Descriptor RAM/Endpoint Buffer Data Register bit fields */
130#define DDAT_DDAT (0xFF) /* Descriptor Endpoint Buffer */
131/* USB Endpoint Status Register bit fields */
132#define EPSTAT_BCOUNT (0x7F<<16) /* Endpoint FIFO byte count */
133#define EPSTAT_SIP (1<<8) /* Endpoint setup in progress */
134#define EPSTAT_DIR (1<<7) /* Endpoint transfer direction */
135#define EPSTAT_MAX (3<<5) /* Endpoint Max packet size */
136#define EPSTAT_TYP (3<<3) /* Endpoint type */
137#define EPSTAT_ZLPS (1<<2) /* Send zero length packet */
138#define EPSTAT_FLUSH (1<<1) /* Endpoint FIFO Flush */
139#define EPSTAT_STALL (1<<0) /* Force stall */
140/* USB Endpoint FIFO Status Register bit fields */
141#define FSTAT_FRAME_STAT (0xF<<24) /* Frame status bit [0-3] */
142#define FSTAT_ERR (1<<22) /* FIFO error */
143#define FSTAT_UF (1<<21) /* FIFO underflow */
144#define FSTAT_OF (1<<20) /* FIFO overflow */
145#define FSTAT_FR (1<<19) /* FIFO frame ready */
146#define FSTAT_FULL (1<<18) /* FIFO full */
147#define FSTAT_ALRM (1<<17) /* FIFO alarm */
148#define FSTAT_EMPTY (1<<16) /* FIFO empty */
149/* USB Endpoint FIFO Control Register bit fields */
150#define FCTRL_WFR (1<<29) /* Write frame end */
151/* USB Endpoint Interrupt Status Regsiter bit fields */
152#define EPINTR_FIFO_FULL (1<<8) /* fifo full */
153#define EPINTR_FIFO_EMPTY (1<<7) /* fifo empty */
154#define EPINTR_FIFO_ERROR (1<<6) /* fifo error */
155#define EPINTR_FIFO_HIGH (1<<5) /* fifo high */
156#define EPINTR_FIFO_LOW (1<<4) /* fifo low */
157#define EPINTR_MDEVREQ (1<<3) /* multi Device request */
158#define EPINTR_EOT (1<<2) /* fifo end of transfer */
159#define EPINTR_DEVREQ (1<<1) /* Device request */
160#define EPINTR_EOF (1<<0) /* fifo end of frame */
161
162/* Debug macros */
163#ifdef DEBUG
164
165/* #define DEBUG_REQ */
166/* #define DEBUG_TRX */
167/* #define DEBUG_INIT */
168/* #define DEBUG_EP0 */
169/* #define DEBUG_EPX */
170/* #define DEBUG_IRQ */
171/* #define DEBUG_EPIRQ */
172/* #define DEBUG_DUMP */
173#define DEBUG_ERR
174
175#ifdef DEBUG_REQ
176 #define D_REQ(dev, args...) dev_dbg(dev, ## args)
177#else
178 #define D_REQ(dev, args...) do {} while (0)
179#endif /* DEBUG_REQ */
180
181#ifdef DEBUG_TRX
182 #define D_TRX(dev, args...) dev_dbg(dev, ## args)
183#else
184 #define D_TRX(dev, args...) do {} while (0)
185#endif /* DEBUG_TRX */
186
187#ifdef DEBUG_INIT
188 #define D_INI(dev, args...) dev_dbg(dev, ## args)
189#else
190 #define D_INI(dev, args...) do {} while (0)
191#endif /* DEBUG_INIT */
192
193#ifdef DEBUG_EP0
194 static const char *state_name[] = {
195 "EP0_IDLE",
196 "EP0_IN_DATA_PHASE",
197 "EP0_OUT_DATA_PHASE",
198 "EP0_CONFIG",
199 "EP0_STALL"
200 };
201 #define D_EP0(dev, args...) dev_dbg(dev, ## args)
202#else
203 #define D_EP0(dev, args...) do {} while (0)
204#endif /* DEBUG_EP0 */
205
206#ifdef DEBUG_EPX
207 #define D_EPX(dev, args...) dev_dbg(dev, ## args)
208#else
209 #define D_EPX(dev, args...) do {} while (0)
210#endif /* DEBUG_EP0 */
211
212#ifdef DEBUG_IRQ
213 static void dump_intr(const char *label, int irqreg, struct device *dev)
214 {
215 dev_dbg(dev, "<%s> USB_INTR=[%s%s%s%s%s%s%s%s%s]\n", label,
216 (irqreg & INTR_WAKEUP) ? " wake" : "",
217 (irqreg & INTR_MSOF) ? " msof" : "",
218 (irqreg & INTR_SOF) ? " sof" : "",
219 (irqreg & INTR_RESUME) ? " resume" : "",
220 (irqreg & INTR_SUSPEND) ? " suspend" : "",
221 (irqreg & INTR_RESET_STOP) ? " noreset" : "",
222 (irqreg & INTR_RESET_START) ? " reset" : "",
223 (irqreg & INTR_FRAME_MATCH) ? " fmatch" : "",
224 (irqreg & INTR_CFG_CHG) ? " config" : "");
225 }
226#else
227 #define dump_intr(x, y, z) do {} while (0)
228#endif /* DEBUG_IRQ */
229
230#ifdef DEBUG_EPIRQ
231 static void dump_ep_intr(const char *label, int nr, int irqreg, struct device *dev)
232 {
233 dev_dbg(dev, "<%s> EP%d_INTR=[%s%s%s%s%s%s%s%s%s]\n", label, nr,
234 (irqreg & EPINTR_FIFO_FULL) ? " full" : "",
235 (irqreg & EPINTR_FIFO_EMPTY) ? " fempty" : "",
236 (irqreg & EPINTR_FIFO_ERROR) ? " ferr" : "",
237 (irqreg & EPINTR_FIFO_HIGH) ? " fhigh" : "",
238 (irqreg & EPINTR_FIFO_LOW) ? " flow" : "",
239 (irqreg & EPINTR_MDEVREQ) ? " mreq" : "",
240 (irqreg & EPINTR_EOF) ? " eof" : "",
241 (irqreg & EPINTR_DEVREQ) ? " devreq" : "",
242 (irqreg & EPINTR_EOT) ? " eot" : "");
243 }
244#else
245 #define dump_ep_intr(x, y, z, i) do {} while (0)
246#endif /* DEBUG_IRQ */
247
248#ifdef DEBUG_DUMP
249 static void dump_usb_stat(const char *label, struct imx_udc_struct *imx_usb)
250 {
251 int temp = __raw_readl(imx_usb->base + USB_STAT);
252
253 dev_dbg(imx_usb->dev,
254 "<%s> USB_STAT=[%s%s CFG=%d, INTF=%d, ALTR=%d]\n", label,
255 (temp & STAT_RST) ? " reset" : "",
256 (temp & STAT_SUSP) ? " suspend" : "",
257 (temp & STAT_CFG) >> 5,
258 (temp & STAT_INTF) >> 3,
259 (temp & STAT_ALTSET));
260 }
261
262 static void dump_ep_stat(const char *label, struct imx_ep_struct *imx_ep)
263 {
264 int temp = __raw_readl(imx_ep->imx_usb->base + USB_EP_INTR(EP_NO(imx_ep)));
265
266 dev_dbg(imx_ep->imx_usb->dev,
267 "<%s> EP%d_INTR=[%s%s%s%s%s%s%s%s%s]\n", label, EP_NO(imx_ep),
268 (temp & EPINTR_FIFO_FULL) ? " full" : "",
269 (temp & EPINTR_FIFO_EMPTY) ? " fempty" : "",
270 (temp & EPINTR_FIFO_ERROR) ? " ferr" : "",
271 (temp & EPINTR_FIFO_HIGH) ? " fhigh" : "",
272 (temp & EPINTR_FIFO_LOW) ? " flow" : "",
273 (temp & EPINTR_MDEVREQ) ? " mreq" : "",
274 (temp & EPINTR_EOF) ? " eof" : "",
275 (temp & EPINTR_DEVREQ) ? " devreq" : "",
276 (temp & EPINTR_EOT) ? " eot" : "");
277
278 temp = __raw_readl(imx_ep->imx_usb->base + USB_EP_STAT(EP_NO(imx_ep)));
279
280 dev_dbg(imx_ep->imx_usb->dev,
281 "<%s> EP%d_STAT=[%s%s bcount=%d]\n", label, EP_NO(imx_ep),
282 (temp & EPSTAT_SIP) ? " sip" : "",
283 (temp & EPSTAT_STALL) ? " stall" : "",
284 (temp & EPSTAT_BCOUNT) >> 16);
285
286 temp = __raw_readl(imx_ep->imx_usb->base + USB_EP_FSTAT(EP_NO(imx_ep)));
287
288 dev_dbg(imx_ep->imx_usb->dev,
289 "<%s> EP%d_FSTAT=[%s%s%s%s%s%s%s]\n", label, EP_NO(imx_ep),
290 (temp & FSTAT_ERR) ? " ferr" : "",
291 (temp & FSTAT_UF) ? " funder" : "",
292 (temp & FSTAT_OF) ? " fover" : "",
293 (temp & FSTAT_FR) ? " fready" : "",
294 (temp & FSTAT_FULL) ? " ffull" : "",
295 (temp & FSTAT_ALRM) ? " falarm" : "",
296 (temp & FSTAT_EMPTY) ? " fempty" : "");
297 }
298
299 static void dump_req(const char *label, struct imx_ep_struct *imx_ep, struct usb_request *req)
300 {
301 int i;
302
303 if (!req || !req->buf) {
304 dev_dbg(imx_ep->imx_usb->dev, "<%s> req or req buf is free\n", label);
305 return;
306 }
307
308 if ((!EP_NO(imx_ep) && imx_ep->imx_usb->ep0state == EP0_IN_DATA_PHASE)
309 || (EP_NO(imx_ep) && EP_DIR(imx_ep))) {
310
311 dev_dbg(imx_ep->imx_usb->dev, "<%s> request dump <", label);
312 for (i = 0; i < req->length; i++)
313 printk("%02x-", *((u8 *)req->buf + i));
314 printk(">\n");
315 }
316 }
317
318#else
319 #define dump_ep_stat(x, y) do {} while (0)
320 #define dump_usb_stat(x, y) do {} while (0)
321 #define dump_req(x, y, z) do {} while (0)
322#endif /* DEBUG_DUMP */
323
324#ifdef DEBUG_ERR
325 #define D_ERR(dev, args...) dev_dbg(dev, ## args)
326#else
327 #define D_ERR(dev, args...) do {} while (0)
328#endif
329
330#else
331 #define D_REQ(dev, args...) do {} while (0)
332 #define D_TRX(dev, args...) do {} while (0)
333 #define D_INI(dev, args...) do {} while (0)
334 #define D_EP0(dev, args...) do {} while (0)
335 #define D_EPX(dev, args...) do {} while (0)
336 #define dump_ep_intr(x, y, z, i) do {} while (0)
337 #define dump_intr(x, y, z) do {} while (0)
338 #define dump_ep_stat(x, y) do {} while (0)
339 #define dump_usb_stat(x, y) do {} while (0)
340 #define dump_req(x, y, z) do {} while (0)
341 #define D_ERR(dev, args...) do {} while (0)
342#endif /* DEBUG */
343
344#endif /* __LINUX_USB_GADGET_IMX_H */
diff --git a/drivers/usb/gadget/m66592-udc.c b/drivers/usb/gadget/m66592-udc.c
index 3a8879ec2061..43dcf9e1af6b 100644
--- a/drivers/usb/gadget/m66592-udc.c
+++ b/drivers/usb/gadget/m66592-udc.c
@@ -1546,8 +1546,6 @@ static void nop_completion(struct usb_ep *ep, struct usb_request *r)
1546{ 1546{
1547} 1547}
1548 1548
1549#define resource_len(r) (((r)->end - (r)->start) + 1)
1550
1551static int __init m66592_probe(struct platform_device *pdev) 1549static int __init m66592_probe(struct platform_device *pdev)
1552{ 1550{
1553 struct resource *res; 1551 struct resource *res;
@@ -1560,11 +1558,10 @@ static int __init m66592_probe(struct platform_device *pdev)
1560 int ret = 0; 1558 int ret = 0;
1561 int i; 1559 int i;
1562 1560
1563 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, 1561 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1564 (char *)udc_name);
1565 if (!res) { 1562 if (!res) {
1566 ret = -ENODEV; 1563 ret = -ENODEV;
1567 pr_err("platform_get_resource_byname error.\n"); 1564 pr_err("platform_get_resource error.\n");
1568 goto clean_up; 1565 goto clean_up;
1569 } 1566 }
1570 1567
@@ -1575,7 +1572,7 @@ static int __init m66592_probe(struct platform_device *pdev)
1575 goto clean_up; 1572 goto clean_up;
1576 } 1573 }
1577 1574
1578 reg = ioremap(res->start, resource_len(res)); 1575 reg = ioremap(res->start, resource_size(res));
1579 if (reg == NULL) { 1576 if (reg == NULL) {
1580 ret = -ENOMEM; 1577 ret = -ENOMEM;
1581 pr_err("ioremap error.\n"); 1578 pr_err("ioremap error.\n");
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 8ae70de2c37d..12c6d83b218c 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -669,7 +669,7 @@ fill_dma_desc (struct net2280_ep *ep, struct net2280_request *req, int valid)
669 669
670 /* 2280 may be polling VALID_BIT through ep->dma->dmadesc */ 670 /* 2280 may be polling VALID_BIT through ep->dma->dmadesc */
671 wmb (); 671 wmb ();
672 td->dmacount = cpu_to_le32p (&dmacount); 672 td->dmacount = cpu_to_le32(dmacount);
673} 673}
674 674
675static const u32 dmactl_default = 675static const u32 dmactl_default =
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index 34e9e393f929..57d9641c6bf8 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -3006,7 +3006,7 @@ cleanup1:
3006 3006
3007cleanup0: 3007cleanup0:
3008 if (xceiv) 3008 if (xceiv)
3009 put_device(xceiv->dev); 3009 otg_put_transceiver(xceiv);
3010 3010
3011 if (cpu_is_omap16xx() || cpu_is_omap24xx()) { 3011 if (cpu_is_omap16xx() || cpu_is_omap24xx()) {
3012 clk_disable(hhc_clk); 3012 clk_disable(hhc_clk);
@@ -3034,7 +3034,7 @@ static int __exit omap_udc_remove(struct platform_device *pdev)
3034 3034
3035 pullup_disable(udc); 3035 pullup_disable(udc);
3036 if (udc->transceiver) { 3036 if (udc->transceiver) {
3037 put_device(udc->transceiver->dev); 3037 otg_put_transceiver(udc->transceiver);
3038 udc->transceiver = NULL; 3038 udc->transceiver = NULL;
3039 } 3039 }
3040 omap_writew(0, UDC_SYSCON1); 3040 omap_writew(0, UDC_SYSCON1);
diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c
index 697a0ca349bf..9b36205c5759 100644
--- a/drivers/usb/gadget/pxa25x_udc.c
+++ b/drivers/usb/gadget/pxa25x_udc.c
@@ -2198,7 +2198,7 @@ static int __init pxa25x_udc_probe(struct platform_device *pdev)
2198 udc_disable(dev); 2198 udc_disable(dev);
2199 udc_reinit(dev); 2199 udc_reinit(dev);
2200 2200
2201 dev->vbus = is_vbus_present(); 2201 dev->vbus = !!is_vbus_present();
2202 2202
2203 /* irq setup after old hardware state is cleaned up */ 2203 /* irq setup after old hardware state is cleaned up */
2204 retval = request_irq(irq, pxa25x_udc_irq, 2204 retval = request_irq(irq, pxa25x_udc_irq,
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 65110d02a206..990f40f988d4 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -430,7 +430,6 @@ static void pio_irq_enable(struct pxa_ep *ep)
430/** 430/**
431 * pio_irq_disable - Disables irq generation for one endpoint 431 * pio_irq_disable - Disables irq generation for one endpoint
432 * @ep: udc endpoint 432 * @ep: udc endpoint
433 * @index: endpoint number
434 */ 433 */
435static void pio_irq_disable(struct pxa_ep *ep) 434static void pio_irq_disable(struct pxa_ep *ep)
436{ 435{
@@ -586,7 +585,6 @@ static void inc_ep_stats_reqs(struct pxa_ep *ep, int is_in)
586 * inc_ep_stats_bytes - Update ep stats counts 585 * inc_ep_stats_bytes - Update ep stats counts
587 * @ep: physical endpoint 586 * @ep: physical endpoint
588 * @count: bytes transfered on endpoint 587 * @count: bytes transfered on endpoint
589 * @req: usb request
590 * @is_in: ep direction (USB_DIR_IN or 0) 588 * @is_in: ep direction (USB_DIR_IN or 0)
591 */ 589 */
592static void inc_ep_stats_bytes(struct pxa_ep *ep, int count, int is_in) 590static void inc_ep_stats_bytes(struct pxa_ep *ep, int count, int is_in)
diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c
index c7e255636803..9a2b8920532d 100644
--- a/drivers/usb/gadget/s3c2410_udc.c
+++ b/drivers/usb/gadget/s3c2410_udc.c
@@ -36,6 +36,7 @@
36#include <linux/interrupt.h> 36#include <linux/interrupt.h>
37#include <linux/platform_device.h> 37#include <linux/platform_device.h>
38#include <linux/clk.h> 38#include <linux/clk.h>
39#include <linux/gpio.h>
39 40
40#include <linux/debugfs.h> 41#include <linux/debugfs.h>
41#include <linux/seq_file.h> 42#include <linux/seq_file.h>
@@ -51,7 +52,6 @@
51#include <mach/irqs.h> 52#include <mach/irqs.h>
52 53
53#include <mach/hardware.h> 54#include <mach/hardware.h>
54#include <mach/regs-gpio.h>
55 55
56#include <plat/regs-udc.h> 56#include <plat/regs-udc.h>
57#include <plat/udc.h> 57#include <plat/udc.h>
@@ -1510,11 +1510,7 @@ static irqreturn_t s3c2410_udc_vbus_irq(int irq, void *_dev)
1510 1510
1511 dprintk(DEBUG_NORMAL, "%s()\n", __func__); 1511 dprintk(DEBUG_NORMAL, "%s()\n", __func__);
1512 1512
1513 /* some cpus cannot read from an line configured to IRQ! */ 1513 value = gpio_get_value(udc_info->vbus_pin) ? 1 : 0;
1514 s3c2410_gpio_cfgpin(udc_info->vbus_pin, S3C2410_GPIO_INPUT);
1515 value = s3c2410_gpio_getpin(udc_info->vbus_pin);
1516 s3c2410_gpio_cfgpin(udc_info->vbus_pin, S3C2410_GPIO_SFN2);
1517
1518 if (udc_info->vbus_pin_inverted) 1514 if (udc_info->vbus_pin_inverted)
1519 value = !value; 1515 value = !value;
1520 1516
@@ -1802,7 +1798,7 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
1802 struct s3c2410_udc *udc = &memory; 1798 struct s3c2410_udc *udc = &memory;
1803 struct device *dev = &pdev->dev; 1799 struct device *dev = &pdev->dev;
1804 int retval; 1800 int retval;
1805 unsigned int irq; 1801 int irq;
1806 1802
1807 dev_dbg(dev, "%s()\n", __func__); 1803 dev_dbg(dev, "%s()\n", __func__);
1808 1804
@@ -1861,7 +1857,7 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
1861 1857
1862 /* irq setup after old hardware state is cleaned up */ 1858 /* irq setup after old hardware state is cleaned up */
1863 retval = request_irq(IRQ_USBD, s3c2410_udc_irq, 1859 retval = request_irq(IRQ_USBD, s3c2410_udc_irq,
1864 IRQF_DISABLED, gadget_name, udc); 1860 IRQF_DISABLED, gadget_name, udc);
1865 1861
1866 if (retval != 0) { 1862 if (retval != 0) {
1867 dev_err(dev, "cannot get irq %i, err %d\n", IRQ_USBD, retval); 1863 dev_err(dev, "cannot get irq %i, err %d\n", IRQ_USBD, retval);
@@ -1872,17 +1868,28 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
1872 dev_dbg(dev, "got irq %i\n", IRQ_USBD); 1868 dev_dbg(dev, "got irq %i\n", IRQ_USBD);
1873 1869
1874 if (udc_info && udc_info->vbus_pin > 0) { 1870 if (udc_info && udc_info->vbus_pin > 0) {
1875 irq = s3c2410_gpio_getirq(udc_info->vbus_pin); 1871 retval = gpio_request(udc_info->vbus_pin, "udc vbus");
1872 if (retval < 0) {
1873 dev_err(dev, "cannot claim vbus pin\n");
1874 goto err_int;
1875 }
1876
1877 irq = gpio_to_irq(udc_info->vbus_pin);
1878 if (irq < 0) {
1879 dev_err(dev, "no irq for gpio vbus pin\n");
1880 goto err_gpio_claim;
1881 }
1882
1876 retval = request_irq(irq, s3c2410_udc_vbus_irq, 1883 retval = request_irq(irq, s3c2410_udc_vbus_irq,
1877 IRQF_DISABLED | IRQF_TRIGGER_RISING 1884 IRQF_DISABLED | IRQF_TRIGGER_RISING
1878 | IRQF_TRIGGER_FALLING | IRQF_SHARED, 1885 | IRQF_TRIGGER_FALLING | IRQF_SHARED,
1879 gadget_name, udc); 1886 gadget_name, udc);
1880 1887
1881 if (retval != 0) { 1888 if (retval != 0) {
1882 dev_err(dev, "can't get vbus irq %i, err %d\n", 1889 dev_err(dev, "can't get vbus irq %d, err %d\n",
1883 irq, retval); 1890 irq, retval);
1884 retval = -EBUSY; 1891 retval = -EBUSY;
1885 goto err_int; 1892 goto err_gpio_claim;
1886 } 1893 }
1887 1894
1888 dev_dbg(dev, "got irq %i\n", irq); 1895 dev_dbg(dev, "got irq %i\n", irq);
@@ -1902,6 +1909,9 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
1902 1909
1903 return 0; 1910 return 0;
1904 1911
1912err_gpio_claim:
1913 if (udc_info && udc_info->vbus_pin > 0)
1914 gpio_free(udc_info->vbus_pin);
1905err_int: 1915err_int:
1906 free_irq(IRQ_USBD, udc); 1916 free_irq(IRQ_USBD, udc);
1907err_map: 1917err_map:
@@ -1927,7 +1937,7 @@ static int s3c2410_udc_remove(struct platform_device *pdev)
1927 debugfs_remove(udc->regs_info); 1937 debugfs_remove(udc->regs_info);
1928 1938
1929 if (udc_info && udc_info->vbus_pin > 0) { 1939 if (udc_info && udc_info->vbus_pin > 0) {
1930 irq = s3c2410_gpio_getirq(udc_info->vbus_pin); 1940 irq = gpio_to_irq(udc_info->vbus_pin);
1931 free_irq(irq, udc); 1941 free_irq(irq, udc);
1932 } 1942 }
1933 1943
diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c
index d9739d52f8f5..96d65ca06ecd 100644
--- a/drivers/usb/gadget/u_ether.c
+++ b/drivers/usb/gadget/u_ether.c
@@ -716,6 +716,14 @@ static int __init get_ether_addr(const char *str, u8 *dev_addr)
716 716
717static struct eth_dev *the_dev; 717static struct eth_dev *the_dev;
718 718
719static const struct net_device_ops eth_netdev_ops = {
720 .ndo_open = eth_open,
721 .ndo_stop = eth_stop,
722 .ndo_start_xmit = eth_start_xmit,
723 .ndo_change_mtu = ueth_change_mtu,
724 .ndo_set_mac_address = eth_mac_addr,
725 .ndo_validate_addr = eth_validate_addr,
726};
719 727
720/** 728/**
721 * gether_setup - initialize one ethernet-over-usb link 729 * gether_setup - initialize one ethernet-over-usb link
@@ -764,12 +772,8 @@ int __init gether_setup(struct usb_gadget *g, u8 ethaddr[ETH_ALEN])
764 if (ethaddr) 772 if (ethaddr)
765 memcpy(ethaddr, dev->host_mac, ETH_ALEN); 773 memcpy(ethaddr, dev->host_mac, ETH_ALEN);
766 774
767 net->change_mtu = ueth_change_mtu; 775 net->netdev_ops = &eth_netdev_ops;
768 net->hard_start_xmit = eth_start_xmit; 776
769 net->open = eth_open;
770 net->stop = eth_stop;
771 /* watchdog_timeo, tx_timeout ... */
772 /* set_multicast_list */
773 SET_ETHTOOL_OPS(net, &ops); 777 SET_ETHTOOL_OPS(net, &ops);
774 778
775 /* two kinds of host-initiated state changes: 779 /* two kinds of host-initiated state changes:
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index f3a75a929e0a..2b476b6b3d4d 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -96,6 +96,19 @@ config USB_EHCI_HCD_PPC_OF
96 Enables support for the USB controller present on the PowerPC 96 Enables support for the USB controller present on the PowerPC
97 OpenFirmware platform bus. 97 OpenFirmware platform bus.
98 98
99config USB_OXU210HP_HCD
100 tristate "OXU210HP HCD support"
101 depends on USB
102 ---help---
103 The OXU210HP is an USB host/OTG/device controller. Enable this
104 option if your board has this chip. If unsure, say N.
105
106 This driver does not support isochronous transfers and doesn't
107 implement OTG nor USB device controllers.
108
109 To compile this driver as a module, choose M here: the
110 module will be called oxu210hp-hcd.
111
99config USB_ISP116X_HCD 112config USB_ISP116X_HCD
100 tristate "ISP116X HCD support" 113 tristate "ISP116X HCD support"
101 depends on USB 114 depends on USB
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 23be22224044..e5f3f20787e4 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_USB_WHCI_HCD) += whci/
13obj-$(CONFIG_PCI) += pci-quirks.o 13obj-$(CONFIG_PCI) += pci-quirks.o
14 14
15obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o 15obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o
16obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o
16obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o 17obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o
17obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o 18obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o
18obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o 19obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 0cb53ca8d343..7f4ace73d44a 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -455,9 +455,7 @@ static void qh_lines (
455 (scratch >> 16) & 0x7fff, 455 (scratch >> 16) & 0x7fff,
456 scratch, 456 scratch,
457 td->urb); 457 td->urb);
458 if (temp < 0) 458 if (size < temp)
459 temp = 0;
460 else if (size < temp)
461 temp = size; 459 temp = size;
462 size -= temp; 460 size -= temp;
463 next += temp; 461 next += temp;
@@ -466,9 +464,7 @@ static void qh_lines (
466 } 464 }
467 465
468 temp = snprintf (next, size, "\n"); 466 temp = snprintf (next, size, "\n");
469 if (temp < 0) 467 if (size < temp)
470 temp = 0;
471 else if (size < temp)
472 temp = size; 468 temp = size;
473 size -= temp; 469 size -= temp;
474 next += temp; 470 next += temp;
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 218f9660d7ee..97a53a48a3d8 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -194,6 +194,7 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
194 u32 temp; 194 u32 temp;
195 u32 power_okay; 195 u32 power_okay;
196 int i; 196 int i;
197 u8 resume_needed = 0;
197 198
198 if (time_before (jiffies, ehci->next_statechange)) 199 if (time_before (jiffies, ehci->next_statechange))
199 msleep(5); 200 msleep(5);
@@ -228,7 +229,9 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
228 229
229 /* Some controller/firmware combinations need a delay during which 230 /* Some controller/firmware combinations need a delay during which
230 * they set up the port statuses. See Bugzilla #8190. */ 231 * they set up the port statuses. See Bugzilla #8190. */
231 mdelay(8); 232 spin_unlock_irq(&ehci->lock);
233 msleep(8);
234 spin_lock_irq(&ehci->lock);
232 235
233 /* manually resume the ports we suspended during bus_suspend() */ 236 /* manually resume the ports we suspended during bus_suspend() */
234 i = HCS_N_PORTS (ehci->hcs_params); 237 i = HCS_N_PORTS (ehci->hcs_params);
@@ -236,12 +239,21 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
236 temp = ehci_readl(ehci, &ehci->regs->port_status [i]); 239 temp = ehci_readl(ehci, &ehci->regs->port_status [i]);
237 temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS); 240 temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS);
238 if (test_bit(i, &ehci->bus_suspended) && 241 if (test_bit(i, &ehci->bus_suspended) &&
239 (temp & PORT_SUSPEND)) 242 (temp & PORT_SUSPEND)) {
240 temp |= PORT_RESUME; 243 temp |= PORT_RESUME;
244 resume_needed = 1;
245 }
241 ehci_writel(ehci, temp, &ehci->regs->port_status [i]); 246 ehci_writel(ehci, temp, &ehci->regs->port_status [i]);
242 } 247 }
248
249 /* msleep for 20ms only if code is trying to resume port */
250 if (resume_needed) {
251 spin_unlock_irq(&ehci->lock);
252 msleep(20);
253 spin_lock_irq(&ehci->lock);
254 }
255
243 i = HCS_N_PORTS (ehci->hcs_params); 256 i = HCS_N_PORTS (ehci->hcs_params);
244 mdelay (20);
245 while (i--) { 257 while (i--) {
246 temp = ehci_readl(ehci, &ehci->regs->port_status [i]); 258 temp = ehci_readl(ehci, &ehci->regs->port_status [i]);
247 if (test_bit(i, &ehci->bus_suspended) && 259 if (test_bit(i, &ehci->bus_suspended) &&
@@ -422,8 +434,15 @@ static int check_reset_complete (
422 port_status &= ~PORT_RWC_BITS; 434 port_status &= ~PORT_RWC_BITS;
423 ehci_writel(ehci, port_status, status_reg); 435 ehci_writel(ehci, port_status, status_reg);
424 436
425 } else 437 /* ensure 440EPX ohci controller state is operational */
438 if (ehci->has_amcc_usb23)
439 set_ohci_hcfs(ehci, 1);
440 } else {
426 ehci_dbg (ehci, "port %d high speed\n", index + 1); 441 ehci_dbg (ehci, "port %d high speed\n", index + 1);
442 /* ensure 440EPx ohci controller state is suspended */
443 if (ehci->has_amcc_usb23)
444 set_ohci_hcfs(ehci, 0);
445 }
427 446
428 return port_status; 447 return port_status;
429} 448}
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 36864f958444..bdc6e86e1f8b 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -219,15 +219,19 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
219 /* Serial Bus Release Number is at PCI 0x60 offset */ 219 /* Serial Bus Release Number is at PCI 0x60 offset */
220 pci_read_config_byte(pdev, 0x60, &ehci->sbrn); 220 pci_read_config_byte(pdev, 0x60, &ehci->sbrn);
221 221
222 /* Workaround current PCI init glitch: wakeup bits aren't 222 /* Keep this around for a while just in case some EHCI
223 * being set from PCI PM capability. 223 * implementation uses legacy PCI PM support. This test
224 * can be removed on 17 Dec 2009 if the dev_warn() hasn't
225 * been triggered by then.
224 */ 226 */
225 if (!device_can_wakeup(&pdev->dev)) { 227 if (!device_can_wakeup(&pdev->dev)) {
226 u16 port_wake; 228 u16 port_wake;
227 229
228 pci_read_config_word(pdev, 0x62, &port_wake); 230 pci_read_config_word(pdev, 0x62, &port_wake);
229 if (port_wake & 0x0001) 231 if (port_wake & 0x0001) {
232 dev_warn(&pdev->dev, "Enabling legacy PCI PM\n");
230 device_init_wakeup(&pdev->dev, 1); 233 device_init_wakeup(&pdev->dev, 1);
234 }
231 } 235 }
232 236
233#ifdef CONFIG_USB_SUSPEND 237#ifdef CONFIG_USB_SUSPEND
@@ -428,6 +432,8 @@ static struct pci_driver ehci_pci_driver = {
428 432
429#ifdef CONFIG_PM 433#ifdef CONFIG_PM
430 .suspend = usb_hcd_pci_suspend, 434 .suspend = usb_hcd_pci_suspend,
435 .suspend_late = usb_hcd_pci_suspend_late,
436 .resume_early = usb_hcd_pci_resume_early,
431 .resume = usb_hcd_pci_resume, 437 .resume = usb_hcd_pci_resume,
432#endif 438#endif
433 .shutdown = usb_hcd_pci_shutdown, 439 .shutdown = usb_hcd_pci_shutdown,
diff --git a/drivers/usb/host/ehci-ppc-of.c b/drivers/usb/host/ehci-ppc-of.c
index b018deed2e8f..ef732b704f53 100644
--- a/drivers/usb/host/ehci-ppc-of.c
+++ b/drivers/usb/host/ehci-ppc-of.c
@@ -107,11 +107,13 @@ ehci_hcd_ppc_of_probe(struct of_device *op, const struct of_device_id *match)
107{ 107{
108 struct device_node *dn = op->node; 108 struct device_node *dn = op->node;
109 struct usb_hcd *hcd; 109 struct usb_hcd *hcd;
110 struct ehci_hcd *ehci; 110 struct ehci_hcd *ehci = NULL;
111 struct resource res; 111 struct resource res;
112 int irq; 112 int irq;
113 int rv; 113 int rv;
114 114
115 struct device_node *np;
116
115 if (usb_disabled()) 117 if (usb_disabled())
116 return -ENODEV; 118 return -ENODEV;
117 119
@@ -149,6 +151,20 @@ ehci_hcd_ppc_of_probe(struct of_device *op, const struct of_device_id *match)
149 } 151 }
150 152
151 ehci = hcd_to_ehci(hcd); 153 ehci = hcd_to_ehci(hcd);
154 np = of_find_compatible_node(NULL, NULL, "ibm,usb-ohci-440epx");
155 if (np != NULL) {
156 /* claim we really affected by usb23 erratum */
157 if (!of_address_to_resource(np, 0, &res))
158 ehci->ohci_hcctrl_reg = ioremap(res.start +
159 OHCI_HCCTRL_OFFSET, OHCI_HCCTRL_LEN);
160 else
161 pr_debug(__FILE__ ": no ohci offset in fdt\n");
162 if (!ehci->ohci_hcctrl_reg) {
163 pr_debug(__FILE__ ": ioremap for ohci hcctrl failed\n");
164 } else {
165 ehci->has_amcc_usb23 = 1;
166 }
167 }
152 168
153 if (of_get_property(dn, "big-endian", NULL)) { 169 if (of_get_property(dn, "big-endian", NULL)) {
154 ehci->big_endian_mmio = 1; 170 ehci->big_endian_mmio = 1;
@@ -181,6 +197,9 @@ err_ioremap:
181 irq_dispose_mapping(irq); 197 irq_dispose_mapping(irq);
182err_irq: 198err_irq:
183 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 199 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
200
201 if (ehci->has_amcc_usb23)
202 iounmap(ehci->ohci_hcctrl_reg);
184err_rmr: 203err_rmr:
185 usb_put_hcd(hcd); 204 usb_put_hcd(hcd);
186 205
@@ -191,6 +210,11 @@ err_rmr:
191static int ehci_hcd_ppc_of_remove(struct of_device *op) 210static int ehci_hcd_ppc_of_remove(struct of_device *op)
192{ 211{
193 struct usb_hcd *hcd = dev_get_drvdata(&op->dev); 212 struct usb_hcd *hcd = dev_get_drvdata(&op->dev);
213 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
214
215 struct device_node *np;
216 struct resource res;
217
194 dev_set_drvdata(&op->dev, NULL); 218 dev_set_drvdata(&op->dev, NULL);
195 219
196 dev_dbg(&op->dev, "stopping PPC-OF USB Controller\n"); 220 dev_dbg(&op->dev, "stopping PPC-OF USB Controller\n");
@@ -201,6 +225,25 @@ static int ehci_hcd_ppc_of_remove(struct of_device *op)
201 irq_dispose_mapping(hcd->irq); 225 irq_dispose_mapping(hcd->irq);
202 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 226 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
203 227
228 /* use request_mem_region to test if the ohci driver is loaded. if so
229 * ensure the ohci core is operational.
230 */
231 if (ehci->has_amcc_usb23) {
232 np = of_find_compatible_node(NULL, NULL, "ibm,usb-ohci-440epx");
233 if (np != NULL) {
234 if (!of_address_to_resource(np, 0, &res))
235 if (!request_mem_region(res.start,
236 0x4, hcd_name))
237 set_ohci_hcfs(ehci, 1);
238 else
239 release_mem_region(res.start, 0x4);
240 else
241 pr_debug(__FILE__ ": no ohci offset in fdt\n");
242 of_node_put(np);
243 }
244
245 iounmap(ehci->ohci_hcctrl_reg);
246 }
204 usb_put_hcd(hcd); 247 usb_put_hcd(hcd);
205 248
206 return 0; 249 return 0;
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index c7d4b5a06bdb..fb7054ccf4fc 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -120,6 +120,16 @@ struct ehci_hcd { /* one per controller */
120 unsigned has_fsl_port_bug:1; /* FreeScale */ 120 unsigned has_fsl_port_bug:1; /* FreeScale */
121 unsigned big_endian_mmio:1; 121 unsigned big_endian_mmio:1;
122 unsigned big_endian_desc:1; 122 unsigned big_endian_desc:1;
123 unsigned has_amcc_usb23:1;
124
125 /* required for usb32 quirk */
126 #define OHCI_CTRL_HCFS (3 << 6)
127 #define OHCI_USB_OPER (2 << 6)
128 #define OHCI_USB_SUSPEND (3 << 6)
129
130 #define OHCI_HCCTRL_OFFSET 0x4
131 #define OHCI_HCCTRL_LEN 0x4
132 __hc32 *ohci_hcctrl_reg;
123 133
124 u8 sbrn; /* packed release number */ 134 u8 sbrn; /* packed release number */
125 135
@@ -636,6 +646,30 @@ static inline void ehci_writel(const struct ehci_hcd *ehci,
636#endif 646#endif
637} 647}
638 648
649/*
650 * On certain ppc-44x SoC there is a HW issue, that could only worked around with
651 * explicit suspend/operate of OHCI. This function hereby makes sense only on that arch.
652 * Other common bits are dependant on has_amcc_usb23 quirk flag.
653 */
654#ifdef CONFIG_44x
655static inline void set_ohci_hcfs(struct ehci_hcd *ehci, int operational)
656{
657 u32 hc_control;
658
659 hc_control = (readl_be(ehci->ohci_hcctrl_reg) & ~OHCI_CTRL_HCFS);
660 if (operational)
661 hc_control |= OHCI_USB_OPER;
662 else
663 hc_control |= OHCI_USB_SUSPEND;
664
665 writel_be(hc_control, ehci->ohci_hcctrl_reg);
666 (void) readl_be(ehci->ohci_hcctrl_reg);
667}
668#else
669static inline void set_ohci_hcfs(struct ehci_hcd *ehci, int operational)
670{ }
671#endif
672
639/*-------------------------------------------------------------------------*/ 673/*-------------------------------------------------------------------------*/
640 674
641/* 675/*
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c
index 8017f1cf78e2..b899f1a59c26 100644
--- a/drivers/usb/host/isp1760-hcd.c
+++ b/drivers/usb/host/isp1760-hcd.c
@@ -435,14 +435,13 @@ static int isp1760_hc_setup(struct usb_hcd *hcd)
435 435
436 /* 436 /*
437 * PORT 1 Control register of the ISP1760 is the OTG control 437 * PORT 1 Control register of the ISP1760 is the OTG control
438 * register on ISP1761. 438 * register on ISP1761. Since there is no OTG or device controller
439 * support in this driver, we use port 1 as a "normal" USB host port on
440 * both chips.
439 */ 441 */
440 if (!(priv->devflags & ISP1760_FLAG_ISP1761) && 442 isp1760_writel(PORT1_POWER | PORT1_INIT2,
441 !(priv->devflags & ISP1760_FLAG_PORT1_DIS)) { 443 hcd->regs + HC_PORT1_CTRL);
442 isp1760_writel(PORT1_POWER | PORT1_INIT2, 444 mdelay(10);
443 hcd->regs + HC_PORT1_CTRL);
444 mdelay(10);
445 }
446 445
447 priv->hcs_params = isp1760_readl(hcd->regs + HC_HCSPARAMS); 446 priv->hcs_params = isp1760_readl(hcd->regs + HC_HCSPARAMS);
448 447
diff --git a/drivers/usb/host/isp1760-hcd.h b/drivers/usb/host/isp1760-hcd.h
index 4377277667d9..a9daea587962 100644
--- a/drivers/usb/host/isp1760-hcd.h
+++ b/drivers/usb/host/isp1760-hcd.h
@@ -135,7 +135,6 @@ typedef void (packet_enqueue)(struct usb_hcd *hcd, struct isp1760_qh *qh,
135 * indicate the most "atypical" case, so that a devflags of 0 is 135 * indicate the most "atypical" case, so that a devflags of 0 is
136 * a sane default configuration. 136 * a sane default configuration.
137 */ 137 */
138#define ISP1760_FLAG_PORT1_DIS 0x00000001 /* Port 1 disabled */
139#define ISP1760_FLAG_BUS_WIDTH_16 0x00000002 /* 16-bit data bus width */ 138#define ISP1760_FLAG_BUS_WIDTH_16 0x00000002 /* 16-bit data bus width */
140#define ISP1760_FLAG_OTG_EN 0x00000004 /* Port 1 supports OTG */ 139#define ISP1760_FLAG_OTG_EN 0x00000004 /* Port 1 supports OTG */
141#define ISP1760_FLAG_ANALOG_OC 0x00000008 /* Analog overcurrent */ 140#define ISP1760_FLAG_ANALOG_OC 0x00000008 /* Analog overcurrent */
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c
index b87ca7cf4b37..4cf7ca428b33 100644
--- a/drivers/usb/host/isp1760-if.c
+++ b/drivers/usb/host/isp1760-if.c
@@ -60,9 +60,6 @@ static int of_isp1760_probe(struct of_device *dev,
60 if (of_device_is_compatible(dp, "nxp,usb-isp1761")) 60 if (of_device_is_compatible(dp, "nxp,usb-isp1761"))
61 devflags |= ISP1760_FLAG_ISP1761; 61 devflags |= ISP1760_FLAG_ISP1761;
62 62
63 if (of_get_property(dp, "port1-disable", NULL) != NULL)
64 devflags |= ISP1760_FLAG_PORT1_DIS;
65
66 /* Some systems wire up only 16 of the 32 data lines */ 63 /* Some systems wire up only 16 of the 32 data lines */
67 prop = of_get_property(dp, "bus-width", NULL); 64 prop = of_get_property(dp, "bus-width", NULL);
68 if (prop && *prop == 16) 65 if (prop && *prop == 16)
@@ -129,23 +126,23 @@ static struct of_platform_driver isp1760_of_driver = {
129#endif 126#endif
130 127
131#ifdef CONFIG_PCI 128#ifdef CONFIG_PCI
132static u32 nxp_pci_io_base;
133static u32 iolength;
134static u32 pci_mem_phy0;
135static u32 length;
136static u8 __iomem *chip_addr;
137static u8 __iomem *iobase;
138
139static int __devinit isp1761_pci_probe(struct pci_dev *dev, 129static int __devinit isp1761_pci_probe(struct pci_dev *dev,
140 const struct pci_device_id *id) 130 const struct pci_device_id *id)
141{ 131{
142 u8 latency, limit; 132 u8 latency, limit;
143 __u32 reg_data; 133 __u32 reg_data;
144 int retry_count; 134 int retry_count;
145 int length;
146 int status = 1;
147 struct usb_hcd *hcd; 135 struct usb_hcd *hcd;
148 unsigned int devflags = 0; 136 unsigned int devflags = 0;
137 int ret_status = 0;
138
139 resource_size_t pci_mem_phy0;
140 resource_size_t memlength;
141
142 u8 __iomem *chip_addr;
143 u8 __iomem *iobase;
144 resource_size_t nxp_pci_io_base;
145 resource_size_t iolength;
149 146
150 if (usb_disabled()) 147 if (usb_disabled())
151 return -ENODEV; 148 return -ENODEV;
@@ -168,26 +165,30 @@ static int __devinit isp1761_pci_probe(struct pci_dev *dev,
168 iobase = ioremap_nocache(nxp_pci_io_base, iolength); 165 iobase = ioremap_nocache(nxp_pci_io_base, iolength);
169 if (!iobase) { 166 if (!iobase) {
170 printk(KERN_ERR "ioremap #1\n"); 167 printk(KERN_ERR "ioremap #1\n");
171 release_mem_region(nxp_pci_io_base, iolength); 168 ret_status = -ENOMEM;
172 return -ENOMEM; 169 goto cleanup1;
173 } 170 }
174 /* Grab the PLX PCI shared memory of the ISP 1761 we need */ 171 /* Grab the PLX PCI shared memory of the ISP 1761 we need */
175 pci_mem_phy0 = pci_resource_start(dev, 3); 172 pci_mem_phy0 = pci_resource_start(dev, 3);
176 length = pci_resource_len(dev, 3); 173 memlength = pci_resource_len(dev, 3);
177 174 if (memlength < 0xffff) {
178 if (length < 0xffff) { 175 printk(KERN_ERR "memory length for this resource is wrong\n");
179 printk(KERN_ERR "memory length for this resource is less than " 176 ret_status = -ENOMEM;
180 "required\n"); 177 goto cleanup2;
181 release_mem_region(nxp_pci_io_base, iolength);
182 iounmap(iobase);
183 return -ENOMEM;
184 } 178 }
185 179
186 if (!request_mem_region(pci_mem_phy0, length, "ISP-PCI")) { 180 if (!request_mem_region(pci_mem_phy0, memlength, "ISP-PCI")) {
187 printk(KERN_ERR "host controller already in use\n"); 181 printk(KERN_ERR "host controller already in use\n");
188 release_mem_region(nxp_pci_io_base, iolength); 182 ret_status = -EBUSY;
189 iounmap(iobase); 183 goto cleanup2;
190 return -EBUSY; 184 }
185
186 /* map available memory */
187 chip_addr = ioremap_nocache(pci_mem_phy0,memlength);
188 if (!chip_addr) {
189 printk(KERN_ERR "Error ioremap failed\n");
190 ret_status = -ENOMEM;
191 goto cleanup3;
191 } 192 }
192 193
193 /* bad pci latencies can contribute to overruns */ 194 /* bad pci latencies can contribute to overruns */
@@ -210,39 +211,54 @@ static int __devinit isp1761_pci_probe(struct pci_dev *dev,
210 * */ 211 * */
211 writel(0xface, chip_addr + HC_SCRATCH_REG); 212 writel(0xface, chip_addr + HC_SCRATCH_REG);
212 udelay(100); 213 udelay(100);
213 reg_data = readl(chip_addr + HC_SCRATCH_REG); 214 reg_data = readl(chip_addr + HC_SCRATCH_REG) & 0x0000ffff;
214 retry_count--; 215 retry_count--;
215 } 216 }
216 217
218 iounmap(chip_addr);
219
217 /* Host Controller presence is detected by writing to scratch register 220 /* Host Controller presence is detected by writing to scratch register
218 * and reading back and checking the contents are same or not 221 * and reading back and checking the contents are same or not
219 */ 222 */
220 if (reg_data != 0xFACE) { 223 if (reg_data != 0xFACE) {
221 dev_err(&dev->dev, "scratch register mismatch %x\n", reg_data); 224 dev_err(&dev->dev, "scratch register mismatch %x\n", reg_data);
222 goto clean; 225 ret_status = -ENOMEM;
226 goto cleanup3;
223 } 227 }
224 228
225 pci_set_master(dev); 229 pci_set_master(dev);
226 230
227 status = readl(iobase + 0x68); 231 /* configure PLX PCI chip to pass interrupts */
228 status |= 0x900; 232#define PLX_INT_CSR_REG 0x68
229 writel(status, iobase + 0x68); 233 reg_data = readl(iobase + PLX_INT_CSR_REG);
234 reg_data |= 0x900;
235 writel(reg_data, iobase + PLX_INT_CSR_REG);
230 236
231 dev->dev.dma_mask = NULL; 237 dev->dev.dma_mask = NULL;
232 hcd = isp1760_register(pci_mem_phy0, length, dev->irq, 238 hcd = isp1760_register(pci_mem_phy0, memlength, dev->irq,
233 IRQF_SHARED | IRQF_DISABLED, &dev->dev, dev_name(&dev->dev), 239 IRQF_SHARED | IRQF_DISABLED, &dev->dev, dev_name(&dev->dev),
234 devflags); 240 devflags);
235 if (!IS_ERR(hcd)) { 241 if (IS_ERR(hcd)) {
236 pci_set_drvdata(dev, hcd); 242 ret_status = -ENODEV;
237 return 0; 243 goto cleanup3;
238 } 244 }
239clean: 245
240 status = -ENODEV; 246 /* done with PLX IO access */
247 iounmap(iobase);
248 release_mem_region(nxp_pci_io_base, iolength);
249
250 pci_set_drvdata(dev, hcd);
251 return 0;
252
253cleanup3:
254 release_mem_region(pci_mem_phy0, memlength);
255cleanup2:
241 iounmap(iobase); 256 iounmap(iobase);
242 release_mem_region(pci_mem_phy0, length); 257cleanup1:
243 release_mem_region(nxp_pci_io_base, iolength); 258 release_mem_region(nxp_pci_io_base, iolength);
244 return status; 259 return ret_status;
245} 260}
261
246static void isp1761_pci_remove(struct pci_dev *dev) 262static void isp1761_pci_remove(struct pci_dev *dev)
247{ 263{
248 struct usb_hcd *hcd; 264 struct usb_hcd *hcd;
@@ -255,12 +271,6 @@ static void isp1761_pci_remove(struct pci_dev *dev)
255 usb_put_hcd(hcd); 271 usb_put_hcd(hcd);
256 272
257 pci_disable_device(dev); 273 pci_disable_device(dev);
258
259 iounmap(iobase);
260 iounmap(chip_addr);
261
262 release_mem_region(nxp_pci_io_base, iolength);
263 release_mem_region(pci_mem_phy0, length);
264} 274}
265 275
266static void isp1761_pci_shutdown(struct pci_dev *dev) 276static void isp1761_pci_shutdown(struct pci_dev *dev)
@@ -268,12 +278,16 @@ static void isp1761_pci_shutdown(struct pci_dev *dev)
268 printk(KERN_ERR "ips1761_pci_shutdown\n"); 278 printk(KERN_ERR "ips1761_pci_shutdown\n");
269} 279}
270 280
271static const struct pci_device_id isp1760_plx [] = { { 281static const struct pci_device_id isp1760_plx [] = {
272 /* handle any USB 2.0 EHCI controller */ 282 {
273 PCI_DEVICE_CLASS(((PCI_CLASS_BRIDGE_OTHER << 8) | (0x06 << 16)), ~0), 283 .class = PCI_CLASS_BRIDGE_OTHER << 8,
274 .driver_data = 0, 284 .class_mask = ~0,
275}, 285 .vendor = PCI_VENDOR_ID_PLX,
276{ /* end: all zeroes */ } 286 .device = 0x5406,
287 .subvendor = PCI_VENDOR_ID_PLX,
288 .subdevice = 0x9054,
289 },
290 { }
277}; 291};
278MODULE_DEVICE_TABLE(pci, isp1760_plx); 292MODULE_DEVICE_TABLE(pci, isp1760_plx);
279 293
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 8aa3f4556a32..65a9609f4ad6 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -589,13 +589,15 @@ static int ohci_run (struct ohci_hcd *ohci)
589 /* also: power/overcurrent flags in roothub.a */ 589 /* also: power/overcurrent flags in roothub.a */
590 } 590 }
591 591
592 /* Reset USB nearly "by the book". RemoteWakeupConnected was 592 /* Reset USB nearly "by the book". RemoteWakeupConnected has
593 * saved if boot firmware (BIOS/SMM/...) told us it's connected, 593 * to be checked in case boot firmware (BIOS/SMM/...) has set up
594 * or if bus glue did the same (e.g. for PCI add-in cards with 594 * wakeup in a way the bus isn't aware of (e.g., legacy PCI PM).
595 * PCI PM support). 595 * If the bus glue detected wakeup capability then it should
596 * already be enabled. Either way, if wakeup should be enabled
597 * but isn't, we'll enable it now.
596 */ 598 */
597 if ((ohci->hc_control & OHCI_CTRL_RWC) != 0 599 if ((ohci->hc_control & OHCI_CTRL_RWC) != 0
598 && !device_may_wakeup(hcd->self.controller)) 600 && !device_can_wakeup(hcd->self.controller))
599 device_init_wakeup(hcd->self.controller, 1); 601 device_init_wakeup(hcd->self.controller, 1);
600 602
601 switch (ohci->hc_control & OHCI_CTRL_HCFS) { 603 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index a9c2ae36c7ad..8b28ae7865ba 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -355,9 +355,9 @@ static int __devinit ohci_pci_start (struct usb_hcd *hcd)
355 355
356 /* RWC may not be set for add-in PCI cards, since boot 356 /* RWC may not be set for add-in PCI cards, since boot
357 * firmware probably ignored them. This transfers PCI 357 * firmware probably ignored them. This transfers PCI
358 * PM wakeup capabilities (once the PCI layer is fixed). 358 * PM wakeup capabilities.
359 */ 359 */
360 if (device_may_wakeup(&pdev->dev)) 360 if (device_can_wakeup(&pdev->dev))
361 ohci->hc_control |= OHCI_CTRL_RWC; 361 ohci->hc_control |= OHCI_CTRL_RWC;
362 } 362 }
363#endif /* CONFIG_PM */ 363#endif /* CONFIG_PM */
@@ -487,6 +487,8 @@ static struct pci_driver ohci_pci_driver = {
487 487
488#ifdef CONFIG_PM 488#ifdef CONFIG_PM
489 .suspend = usb_hcd_pci_suspend, 489 .suspend = usb_hcd_pci_suspend,
490 .suspend_late = usb_hcd_pci_suspend_late,
491 .resume_early = usb_hcd_pci_resume_early,
490 .resume = usb_hcd_pci_resume, 492 .resume = usb_hcd_pci_resume,
491#endif 493#endif
492 494
diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c
index e306ca6aef3d..100bf3d8437c 100644
--- a/drivers/usb/host/ohci-pnx4008.c
+++ b/drivers/usb/host/ohci-pnx4008.c
@@ -106,65 +106,34 @@ extern int ocpi_enable(void);
106 106
107static struct clk *usb_clk; 107static struct clk *usb_clk;
108 108
109static int isp1301_probe(struct i2c_adapter *adap);
110static int isp1301_detach(struct i2c_client *client);
111
112static const unsigned short normal_i2c[] = 109static const unsigned short normal_i2c[] =
113 { ISP1301_I2C_ADDR, ISP1301_I2C_ADDR + 1, I2C_CLIENT_END }; 110 { ISP1301_I2C_ADDR, ISP1301_I2C_ADDR + 1, I2C_CLIENT_END };
114static const unsigned short dummy_i2c_addrlist[] = { I2C_CLIENT_END };
115
116static struct i2c_client_address_data addr_data = {
117 .normal_i2c = normal_i2c,
118 .probe = dummy_i2c_addrlist,
119 .ignore = dummy_i2c_addrlist,
120};
121
122struct i2c_driver isp1301_driver = {
123 .driver = {
124 .name = "isp1301_pnx",
125 },
126 .attach_adapter = isp1301_probe,
127 .detach_client = isp1301_detach,
128};
129 111
130static int isp1301_attach(struct i2c_adapter *adap, int addr, int kind) 112static int isp1301_probe(struct i2c_client *client,
113 const struct i2c_device_id *id)
131{ 114{
132 struct i2c_client *c;
133 int err;
134
135 c = kzalloc(sizeof(*c), GFP_KERNEL);
136 if (!c)
137 return -ENOMEM;
138
139 strlcpy(c->name, "isp1301_pnx", I2C_NAME_SIZE);
140 c->flags = 0;
141 c->addr = addr;
142 c->adapter = adap;
143 c->driver = &isp1301_driver;
144
145 err = i2c_attach_client(c);
146 if (err) {
147 kfree(c);
148 return err;
149 }
150
151 isp1301_i2c_client = c;
152
153 return 0; 115 return 0;
154} 116}
155 117
156static int isp1301_probe(struct i2c_adapter *adap) 118static int isp1301_remove(struct i2c_client *client)
157{ 119{
158 return i2c_probe(adap, &addr_data, isp1301_attach);
159}
160
161static int isp1301_detach(struct i2c_client *client)
162{
163 i2c_detach_client(client);
164 kfree(isp1301_i2c_client);
165 return 0; 120 return 0;
166} 121}
167 122
123const struct i2c_device_id isp1301_id[] = {
124 { "isp1301_pnx", 0 },
125 { }
126};
127
128struct i2c_driver isp1301_driver = {
129 .driver = {
130 .name = "isp1301_pnx",
131 },
132 .probe = isp1301_probe,
133 .remove = isp1301_remove,
134 .id_table = isp1301_id,
135};
136
168static void i2c_write(u8 buf, u8 subaddr) 137static void i2c_write(u8 buf, u8 subaddr)
169{ 138{
170 char tmpbuf[2]; 139 char tmpbuf[2];
@@ -328,6 +297,8 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev)
328 struct usb_hcd *hcd = 0; 297 struct usb_hcd *hcd = 0;
329 struct ohci_hcd *ohci; 298 struct ohci_hcd *ohci;
330 const struct hc_driver *driver = &ohci_pnx4008_hc_driver; 299 const struct hc_driver *driver = &ohci_pnx4008_hc_driver;
300 struct i2c_adapter *i2c_adap;
301 struct i2c_board_info i2c_info;
331 302
332 int ret = 0, irq; 303 int ret = 0, irq;
333 304
@@ -351,9 +322,20 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev)
351 322
352 ret = i2c_add_driver(&isp1301_driver); 323 ret = i2c_add_driver(&isp1301_driver);
353 if (ret < 0) { 324 if (ret < 0) {
354 err("failed to connect I2C to ISP1301 USB Transceiver"); 325 err("failed to add ISP1301 driver");
355 goto out; 326 goto out;
356 } 327 }
328 i2c_adap = i2c_get_adapter(2);
329 memset(&i2c_info, 0, sizeof(struct i2c_board_info));
330 strlcpy(i2c_info.name, "isp1301_pnx", I2C_NAME_SIZE);
331 isp1301_i2c_client = i2c_new_probed_device(i2c_adap, &i2c_info,
332 normal_i2c);
333 i2c_put_adapter(i2c_adap);
334 if (!isp1301_i2c_client) {
335 err("failed to connect I2C to ISP1301 USB Transceiver");
336 ret = -ENODEV;
337 goto out_i2c_driver;
338 }
357 339
358 isp1301_configure(); 340 isp1301_configure();
359 341
@@ -429,6 +411,9 @@ out3:
429out2: 411out2:
430 clk_put(usb_clk); 412 clk_put(usb_clk);
431out1: 413out1:
414 i2c_unregister_client(isp1301_i2c_client);
415 isp1301_i2c_client = NULL;
416out_i2c_driver:
432 i2c_del_driver(&isp1301_driver); 417 i2c_del_driver(&isp1301_driver);
433out: 418out:
434 return ret; 419 return ret;
@@ -445,6 +430,8 @@ static int usb_hcd_pnx4008_remove(struct platform_device *pdev)
445 pnx4008_unset_usb_bits(); 430 pnx4008_unset_usb_bits();
446 clk_disable(usb_clk); 431 clk_disable(usb_clk);
447 clk_put(usb_clk); 432 clk_put(usb_clk);
433 i2c_unregister_client(isp1301_i2c_client);
434 isp1301_i2c_client = NULL;
448 i2c_del_driver(&isp1301_driver); 435 i2c_del_driver(&isp1301_driver);
449 436
450 platform_set_drvdata(pdev, NULL); 437 platform_set_drvdata(pdev, NULL);
diff --git a/drivers/usb/host/ohci-ppc-of.c b/drivers/usb/host/ohci-ppc-of.c
index 7ac53264ead3..68a301710297 100644
--- a/drivers/usb/host/ohci-ppc-of.c
+++ b/drivers/usb/host/ohci-ppc-of.c
@@ -91,6 +91,7 @@ ohci_hcd_ppc_of_probe(struct of_device *op, const struct of_device_id *match)
91 91
92 int rv; 92 int rv;
93 int is_bigendian; 93 int is_bigendian;
94 struct device_node *np;
94 95
95 if (usb_disabled()) 96 if (usb_disabled())
96 return -ENODEV; 97 return -ENODEV;
@@ -147,6 +148,30 @@ ohci_hcd_ppc_of_probe(struct of_device *op, const struct of_device_id *match)
147 if (rv == 0) 148 if (rv == 0)
148 return 0; 149 return 0;
149 150
151 /* by now, 440epx is known to show usb_23 erratum */
152 np = of_find_compatible_node(NULL, NULL, "ibm,usb-ehci-440epx");
153
154 /* Work around - At this point ohci_run has executed, the
155 * controller is running, everything, the root ports, etc., is
156 * set up. If the ehci driver is loaded, put the ohci core in
157 * the suspended state. The ehci driver will bring it out of
158 * suspended state when / if a non-high speed USB device is
159 * attached to the USB Host port. If the ehci driver is not
160 * loaded, do nothing. request_mem_region is used to test if
161 * the ehci driver is loaded.
162 */
163 if (np != NULL) {
164 if (!of_address_to_resource(np, 0, &res)) {
165 if (!request_mem_region(res.start, 0x4, hcd_name)) {
166 writel_be((readl_be(&ohci->regs->control) |
167 OHCI_USB_SUSPEND), &ohci->regs->control);
168 (void) readl_be(&ohci->regs->control);
169 } else
170 release_mem_region(res.start, 0x4);
171 } else
172 pr_debug(__FILE__ ": cannot get ehci offset from fdt\n");
173 }
174
150 iounmap(hcd->regs); 175 iounmap(hcd->regs);
151err_ioremap: 176err_ioremap:
152 irq_dispose_mapping(irq); 177 irq_dispose_mapping(irq);
diff --git a/drivers/usb/host/ohci-tmio.c b/drivers/usb/host/ohci-tmio.c
index f9f134af0bd1..8dabe8e31d8c 100644
--- a/drivers/usb/host/ohci-tmio.c
+++ b/drivers/usb/host/ohci-tmio.c
@@ -201,7 +201,7 @@ static int __devinit ohci_hcd_tmio_drv_probe(struct platform_device *dev)
201 if (!cell) 201 if (!cell)
202 return -EINVAL; 202 return -EINVAL;
203 203
204 hcd = usb_create_hcd(&ohci_tmio_hc_driver, &dev->dev, dev->dev.bus_id); 204 hcd = usb_create_hcd(&ohci_tmio_hc_driver, &dev->dev, dev_name(&dev->dev));
205 if (!hcd) { 205 if (!hcd) {
206 ret = -ENOMEM; 206 ret = -ENOMEM;
207 goto err_usb_create_hcd; 207 goto err_usb_create_hcd;
diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c
new file mode 100644
index 000000000000..75548f7c716b
--- /dev/null
+++ b/drivers/usb/host/oxu210hp-hcd.c
@@ -0,0 +1,3985 @@
1/*
2 * Copyright (c) 2008 Rodolfo Giometti <giometti@linux.it>
3 * Copyright (c) 2008 Eurotech S.p.A. <info@eurtech.it>
4 *
5 * This code is *strongly* based on EHCI-HCD code by David Brownell since
6 * the chip is a quasi-EHCI compatible.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#include <linux/module.h>
24#include <linux/pci.h>
25#include <linux/dmapool.h>
26#include <linux/kernel.h>
27#include <linux/delay.h>
28#include <linux/ioport.h>
29#include <linux/sched.h>
30#include <linux/slab.h>
31#include <linux/errno.h>
32#include <linux/init.h>
33#include <linux/timer.h>
34#include <linux/list.h>
35#include <linux/interrupt.h>
36#include <linux/reboot.h>
37#include <linux/usb.h>
38#include <linux/moduleparam.h>
39#include <linux/dma-mapping.h>
40#include <linux/io.h>
41
42#include "../core/hcd.h"
43
44#include <asm/irq.h>
45#include <asm/system.h>
46#include <asm/unaligned.h>
47
48#include <linux/irq.h>
49#include <linux/platform_device.h>
50
51#include "oxu210hp.h"
52
53#define DRIVER_VERSION "0.0.50"
54
55/*
56 * Main defines
57 */
58
59#define oxu_dbg(oxu, fmt, args...) \
60 dev_dbg(oxu_to_hcd(oxu)->self.controller , fmt , ## args)
61#define oxu_err(oxu, fmt, args...) \
62 dev_err(oxu_to_hcd(oxu)->self.controller , fmt , ## args)
63#define oxu_info(oxu, fmt, args...) \
64 dev_info(oxu_to_hcd(oxu)->self.controller , fmt , ## args)
65
66static inline struct usb_hcd *oxu_to_hcd(struct oxu_hcd *oxu)
67{
68 return container_of((void *) oxu, struct usb_hcd, hcd_priv);
69}
70
71static inline struct oxu_hcd *hcd_to_oxu(struct usb_hcd *hcd)
72{
73 return (struct oxu_hcd *) (hcd->hcd_priv);
74}
75
76/*
77 * Debug stuff
78 */
79
80#undef OXU_URB_TRACE
81#undef OXU_VERBOSE_DEBUG
82
83#ifdef OXU_VERBOSE_DEBUG
84#define oxu_vdbg oxu_dbg
85#else
86#define oxu_vdbg(oxu, fmt, args...) /* Nop */
87#endif
88
89#ifdef DEBUG
90
91static int __attribute__((__unused__))
92dbg_status_buf(char *buf, unsigned len, const char *label, u32 status)
93{
94 return scnprintf(buf, len, "%s%sstatus %04x%s%s%s%s%s%s%s%s%s%s",
95 label, label[0] ? " " : "", status,
96 (status & STS_ASS) ? " Async" : "",
97 (status & STS_PSS) ? " Periodic" : "",
98 (status & STS_RECL) ? " Recl" : "",
99 (status & STS_HALT) ? " Halt" : "",
100 (status & STS_IAA) ? " IAA" : "",
101 (status & STS_FATAL) ? " FATAL" : "",
102 (status & STS_FLR) ? " FLR" : "",
103 (status & STS_PCD) ? " PCD" : "",
104 (status & STS_ERR) ? " ERR" : "",
105 (status & STS_INT) ? " INT" : ""
106 );
107}
108
109static int __attribute__((__unused__))
110dbg_intr_buf(char *buf, unsigned len, const char *label, u32 enable)
111{
112 return scnprintf(buf, len, "%s%sintrenable %02x%s%s%s%s%s%s",
113 label, label[0] ? " " : "", enable,
114 (enable & STS_IAA) ? " IAA" : "",
115 (enable & STS_FATAL) ? " FATAL" : "",
116 (enable & STS_FLR) ? " FLR" : "",
117 (enable & STS_PCD) ? " PCD" : "",
118 (enable & STS_ERR) ? " ERR" : "",
119 (enable & STS_INT) ? " INT" : ""
120 );
121}
122
123static const char *const fls_strings[] =
124 { "1024", "512", "256", "??" };
125
126static int dbg_command_buf(char *buf, unsigned len,
127 const char *label, u32 command)
128{
129 return scnprintf(buf, len,
130 "%s%scommand %06x %s=%d ithresh=%d%s%s%s%s period=%s%s %s",
131 label, label[0] ? " " : "", command,
132 (command & CMD_PARK) ? "park" : "(park)",
133 CMD_PARK_CNT(command),
134 (command >> 16) & 0x3f,
135 (command & CMD_LRESET) ? " LReset" : "",
136 (command & CMD_IAAD) ? " IAAD" : "",
137 (command & CMD_ASE) ? " Async" : "",
138 (command & CMD_PSE) ? " Periodic" : "",
139 fls_strings[(command >> 2) & 0x3],
140 (command & CMD_RESET) ? " Reset" : "",
141 (command & CMD_RUN) ? "RUN" : "HALT"
142 );
143}
144
145static int dbg_port_buf(char *buf, unsigned len, const char *label,
146 int port, u32 status)
147{
148 char *sig;
149
150 /* signaling state */
151 switch (status & (3 << 10)) {
152 case 0 << 10:
153 sig = "se0";
154 break;
155 case 1 << 10:
156 sig = "k"; /* low speed */
157 break;
158 case 2 << 10:
159 sig = "j";
160 break;
161 default:
162 sig = "?";
163 break;
164 }
165
166 return scnprintf(buf, len,
167 "%s%sport %d status %06x%s%s sig=%s%s%s%s%s%s%s%s%s%s",
168 label, label[0] ? " " : "", port, status,
169 (status & PORT_POWER) ? " POWER" : "",
170 (status & PORT_OWNER) ? " OWNER" : "",
171 sig,
172 (status & PORT_RESET) ? " RESET" : "",
173 (status & PORT_SUSPEND) ? " SUSPEND" : "",
174 (status & PORT_RESUME) ? " RESUME" : "",
175 (status & PORT_OCC) ? " OCC" : "",
176 (status & PORT_OC) ? " OC" : "",
177 (status & PORT_PEC) ? " PEC" : "",
178 (status & PORT_PE) ? " PE" : "",
179 (status & PORT_CSC) ? " CSC" : "",
180 (status & PORT_CONNECT) ? " CONNECT" : ""
181 );
182}
183
184#else
185
186static inline int __attribute__((__unused__))
187dbg_status_buf(char *buf, unsigned len, const char *label, u32 status)
188{ return 0; }
189
190static inline int __attribute__((__unused__))
191dbg_command_buf(char *buf, unsigned len, const char *label, u32 command)
192{ return 0; }
193
194static inline int __attribute__((__unused__))
195dbg_intr_buf(char *buf, unsigned len, const char *label, u32 enable)
196{ return 0; }
197
198static inline int __attribute__((__unused__))
199dbg_port_buf(char *buf, unsigned len, const char *label, int port, u32 status)
200{ return 0; }
201
202#endif /* DEBUG */
203
204/* functions have the "wrong" filename when they're output... */
205#define dbg_status(oxu, label, status) { \
206 char _buf[80]; \
207 dbg_status_buf(_buf, sizeof _buf, label, status); \
208 oxu_dbg(oxu, "%s\n", _buf); \
209}
210
211#define dbg_cmd(oxu, label, command) { \
212 char _buf[80]; \
213 dbg_command_buf(_buf, sizeof _buf, label, command); \
214 oxu_dbg(oxu, "%s\n", _buf); \
215}
216
217#define dbg_port(oxu, label, port, status) { \
218 char _buf[80]; \
219 dbg_port_buf(_buf, sizeof _buf, label, port, status); \
220 oxu_dbg(oxu, "%s\n", _buf); \
221}
222
223/*
224 * Module parameters
225 */
226
227/* Initial IRQ latency: faster than hw default */
228static int log2_irq_thresh; /* 0 to 6 */
229module_param(log2_irq_thresh, int, S_IRUGO);
230MODULE_PARM_DESC(log2_irq_thresh, "log2 IRQ latency, 1-64 microframes");
231
232/* Initial park setting: slower than hw default */
233static unsigned park;
234module_param(park, uint, S_IRUGO);
235MODULE_PARM_DESC(park, "park setting; 1-3 back-to-back async packets");
236
237/* For flakey hardware, ignore overcurrent indicators */
238static int ignore_oc;
239module_param(ignore_oc, bool, S_IRUGO);
240MODULE_PARM_DESC(ignore_oc, "ignore bogus hardware overcurrent indications");
241
242
243static void ehci_work(struct oxu_hcd *oxu);
244static int oxu_hub_control(struct usb_hcd *hcd,
245 u16 typeReq, u16 wValue, u16 wIndex,
246 char *buf, u16 wLength);
247
248/*
249 * Local functions
250 */
251
252/* Low level read/write registers functions */
253static inline u32 oxu_readl(void *base, u32 reg)
254{
255 return readl(base + reg);
256}
257
258static inline void oxu_writel(void *base, u32 reg, u32 val)
259{
260 writel(val, base + reg);
261}
262
263static inline void timer_action_done(struct oxu_hcd *oxu,
264 enum ehci_timer_action action)
265{
266 clear_bit(action, &oxu->actions);
267}
268
269static inline void timer_action(struct oxu_hcd *oxu,
270 enum ehci_timer_action action)
271{
272 if (!test_and_set_bit(action, &oxu->actions)) {
273 unsigned long t;
274
275 switch (action) {
276 case TIMER_IAA_WATCHDOG:
277 t = EHCI_IAA_JIFFIES;
278 break;
279 case TIMER_IO_WATCHDOG:
280 t = EHCI_IO_JIFFIES;
281 break;
282 case TIMER_ASYNC_OFF:
283 t = EHCI_ASYNC_JIFFIES;
284 break;
285 case TIMER_ASYNC_SHRINK:
286 default:
287 t = EHCI_SHRINK_JIFFIES;
288 break;
289 }
290 t += jiffies;
291 /* all timings except IAA watchdog can be overridden.
292 * async queue SHRINK often precedes IAA. while it's ready
293 * to go OFF neither can matter, and afterwards the IO
294 * watchdog stops unless there's still periodic traffic.
295 */
296 if (action != TIMER_IAA_WATCHDOG
297 && t > oxu->watchdog.expires
298 && timer_pending(&oxu->watchdog))
299 return;
300 mod_timer(&oxu->watchdog, t);
301 }
302}
303
304/*
305 * handshake - spin reading hc until handshake completes or fails
306 * @ptr: address of hc register to be read
307 * @mask: bits to look at in result of read
308 * @done: value of those bits when handshake succeeds
309 * @usec: timeout in microseconds
310 *
311 * Returns negative errno, or zero on success
312 *
313 * Success happens when the "mask" bits have the specified value (hardware
314 * handshake done). There are two failure modes: "usec" have passed (major
315 * hardware flakeout), or the register reads as all-ones (hardware removed).
316 *
317 * That last failure should_only happen in cases like physical cardbus eject
318 * before driver shutdown. But it also seems to be caused by bugs in cardbus
319 * bridge shutdown: shutting down the bridge before the devices using it.
320 */
321static int handshake(struct oxu_hcd *oxu, void __iomem *ptr,
322 u32 mask, u32 done, int usec)
323{
324 u32 result;
325
326 do {
327 result = readl(ptr);
328 if (result == ~(u32)0) /* card removed */
329 return -ENODEV;
330 result &= mask;
331 if (result == done)
332 return 0;
333 udelay(1);
334 usec--;
335 } while (usec > 0);
336 return -ETIMEDOUT;
337}
338
339/* Force HC to halt state from unknown (EHCI spec section 2.3) */
340static int ehci_halt(struct oxu_hcd *oxu)
341{
342 u32 temp = readl(&oxu->regs->status);
343
344 /* disable any irqs left enabled by previous code */
345 writel(0, &oxu->regs->intr_enable);
346
347 if ((temp & STS_HALT) != 0)
348 return 0;
349
350 temp = readl(&oxu->regs->command);
351 temp &= ~CMD_RUN;
352 writel(temp, &oxu->regs->command);
353 return handshake(oxu, &oxu->regs->status,
354 STS_HALT, STS_HALT, 16 * 125);
355}
356
357/* Put TDI/ARC silicon into EHCI mode */
358static void tdi_reset(struct oxu_hcd *oxu)
359{
360 u32 __iomem *reg_ptr;
361 u32 tmp;
362
363 reg_ptr = (u32 __iomem *)(((u8 __iomem *)oxu->regs) + 0x68);
364 tmp = readl(reg_ptr);
365 tmp |= 0x3;
366 writel(tmp, reg_ptr);
367}
368
369/* Reset a non-running (STS_HALT == 1) controller */
370static int ehci_reset(struct oxu_hcd *oxu)
371{
372 int retval;
373 u32 command = readl(&oxu->regs->command);
374
375 command |= CMD_RESET;
376 dbg_cmd(oxu, "reset", command);
377 writel(command, &oxu->regs->command);
378 oxu_to_hcd(oxu)->state = HC_STATE_HALT;
379 oxu->next_statechange = jiffies;
380 retval = handshake(oxu, &oxu->regs->command,
381 CMD_RESET, 0, 250 * 1000);
382
383 if (retval)
384 return retval;
385
386 tdi_reset(oxu);
387
388 return retval;
389}
390
391/* Idle the controller (from running) */
392static void ehci_quiesce(struct oxu_hcd *oxu)
393{
394 u32 temp;
395
396#ifdef DEBUG
397 if (!HC_IS_RUNNING(oxu_to_hcd(oxu)->state))
398 BUG();
399#endif
400
401 /* wait for any schedule enables/disables to take effect */
402 temp = readl(&oxu->regs->command) << 10;
403 temp &= STS_ASS | STS_PSS;
404 if (handshake(oxu, &oxu->regs->status, STS_ASS | STS_PSS,
405 temp, 16 * 125) != 0) {
406 oxu_to_hcd(oxu)->state = HC_STATE_HALT;
407 return;
408 }
409
410 /* then disable anything that's still active */
411 temp = readl(&oxu->regs->command);
412 temp &= ~(CMD_ASE | CMD_IAAD | CMD_PSE);
413 writel(temp, &oxu->regs->command);
414
415 /* hardware can take 16 microframes to turn off ... */
416 if (handshake(oxu, &oxu->regs->status, STS_ASS | STS_PSS,
417 0, 16 * 125) != 0) {
418 oxu_to_hcd(oxu)->state = HC_STATE_HALT;
419 return;
420 }
421}
422
423static int check_reset_complete(struct oxu_hcd *oxu, int index,
424 u32 __iomem *status_reg, int port_status)
425{
426 if (!(port_status & PORT_CONNECT)) {
427 oxu->reset_done[index] = 0;
428 return port_status;
429 }
430
431 /* if reset finished and it's still not enabled -- handoff */
432 if (!(port_status & PORT_PE)) {
433 oxu_dbg(oxu, "Failed to enable port %d on root hub TT\n",
434 index+1);
435 return port_status;
436 } else
437 oxu_dbg(oxu, "port %d high speed\n", index + 1);
438
439 return port_status;
440}
441
442static void ehci_hub_descriptor(struct oxu_hcd *oxu,
443 struct usb_hub_descriptor *desc)
444{
445 int ports = HCS_N_PORTS(oxu->hcs_params);
446 u16 temp;
447
448 desc->bDescriptorType = 0x29;
449 desc->bPwrOn2PwrGood = 10; /* oxu 1.0, 2.3.9 says 20ms max */
450 desc->bHubContrCurrent = 0;
451
452 desc->bNbrPorts = ports;
453 temp = 1 + (ports / 8);
454 desc->bDescLength = 7 + 2 * temp;
455
456 /* two bitmaps: ports removable, and usb 1.0 legacy PortPwrCtrlMask */
457 memset(&desc->bitmap[0], 0, temp);
458 memset(&desc->bitmap[temp], 0xff, temp);
459
460 temp = 0x0008; /* per-port overcurrent reporting */
461 if (HCS_PPC(oxu->hcs_params))
462 temp |= 0x0001; /* per-port power control */
463 else
464 temp |= 0x0002; /* no power switching */
465 desc->wHubCharacteristics = (__force __u16)cpu_to_le16(temp);
466}
467
468
469/* Allocate an OXU210HP on-chip memory data buffer
470 *
471 * An on-chip memory data buffer is required for each OXU210HP USB transfer.
472 * Each transfer descriptor has one or more on-chip memory data buffers.
473 *
474 * Data buffers are allocated from a fix sized pool of data blocks.
475 * To minimise fragmentation and give reasonable memory utlisation,
476 * data buffers are allocated with sizes the power of 2 multiples of
477 * the block size, starting on an address a multiple of the allocated size.
478 *
479 * FIXME: callers of this function require a buffer to be allocated for
480 * len=0. This is a waste of on-chip memory and should be fix. Then this
481 * function should be changed to not allocate a buffer for len=0.
482 */
483static int oxu_buf_alloc(struct oxu_hcd *oxu, struct ehci_qtd *qtd, int len)
484{
485 int n_blocks; /* minium blocks needed to hold len */
486 int a_blocks; /* blocks allocated */
487 int i, j;
488
489 /* Don't allocte bigger than supported */
490 if (len > BUFFER_SIZE * BUFFER_NUM) {
491 oxu_err(oxu, "buffer too big (%d)\n", len);
492 return -ENOMEM;
493 }
494
495 spin_lock(&oxu->mem_lock);
496
497 /* Number of blocks needed to hold len */
498 n_blocks = (len + BUFFER_SIZE - 1) / BUFFER_SIZE;
499
500 /* Round the number of blocks up to the power of 2 */
501 for (a_blocks = 1; a_blocks < n_blocks; a_blocks <<= 1)
502 ;
503
504 /* Find a suitable available data buffer */
505 for (i = 0; i < BUFFER_NUM;
506 i += max(a_blocks, (int)oxu->db_used[i])) {
507
508 /* Check all the required blocks are available */
509 for (j = 0; j < a_blocks; j++)
510 if (oxu->db_used[i + j])
511 break;
512
513 if (j != a_blocks)
514 continue;
515
516 /* Allocate blocks found! */
517 qtd->buffer = (void *) &oxu->mem->db_pool[i];
518 qtd->buffer_dma = virt_to_phys(qtd->buffer);
519
520 qtd->qtd_buffer_len = BUFFER_SIZE * a_blocks;
521 oxu->db_used[i] = a_blocks;
522
523 spin_unlock(&oxu->mem_lock);
524
525 return 0;
526 }
527
528 /* Failed */
529
530 spin_unlock(&oxu->mem_lock);
531
532 return -ENOMEM;
533}
534
535static void oxu_buf_free(struct oxu_hcd *oxu, struct ehci_qtd *qtd)
536{
537 int index;
538
539 spin_lock(&oxu->mem_lock);
540
541 index = (qtd->buffer - (void *) &oxu->mem->db_pool[0])
542 / BUFFER_SIZE;
543 oxu->db_used[index] = 0;
544 qtd->qtd_buffer_len = 0;
545 qtd->buffer_dma = 0;
546 qtd->buffer = NULL;
547
548 spin_unlock(&oxu->mem_lock);
549
550 return;
551}
552
553static inline void ehci_qtd_init(struct ehci_qtd *qtd, dma_addr_t dma)
554{
555 memset(qtd, 0, sizeof *qtd);
556 qtd->qtd_dma = dma;
557 qtd->hw_token = cpu_to_le32(QTD_STS_HALT);
558 qtd->hw_next = EHCI_LIST_END;
559 qtd->hw_alt_next = EHCI_LIST_END;
560 INIT_LIST_HEAD(&qtd->qtd_list);
561}
562
563static inline void oxu_qtd_free(struct oxu_hcd *oxu, struct ehci_qtd *qtd)
564{
565 int index;
566
567 if (qtd->buffer)
568 oxu_buf_free(oxu, qtd);
569
570 spin_lock(&oxu->mem_lock);
571
572 index = qtd - &oxu->mem->qtd_pool[0];
573 oxu->qtd_used[index] = 0;
574
575 spin_unlock(&oxu->mem_lock);
576
577 return;
578}
579
580static struct ehci_qtd *ehci_qtd_alloc(struct oxu_hcd *oxu)
581{
582 int i;
583 struct ehci_qtd *qtd = NULL;
584
585 spin_lock(&oxu->mem_lock);
586
587 for (i = 0; i < QTD_NUM; i++)
588 if (!oxu->qtd_used[i])
589 break;
590
591 if (i < QTD_NUM) {
592 qtd = (struct ehci_qtd *) &oxu->mem->qtd_pool[i];
593 memset(qtd, 0, sizeof *qtd);
594
595 qtd->hw_token = cpu_to_le32(QTD_STS_HALT);
596 qtd->hw_next = EHCI_LIST_END;
597 qtd->hw_alt_next = EHCI_LIST_END;
598 INIT_LIST_HEAD(&qtd->qtd_list);
599
600 qtd->qtd_dma = virt_to_phys(qtd);
601
602 oxu->qtd_used[i] = 1;
603 }
604
605 spin_unlock(&oxu->mem_lock);
606
607 return qtd;
608}
609
610static void oxu_qh_free(struct oxu_hcd *oxu, struct ehci_qh *qh)
611{
612 int index;
613
614 spin_lock(&oxu->mem_lock);
615
616 index = qh - &oxu->mem->qh_pool[0];
617 oxu->qh_used[index] = 0;
618
619 spin_unlock(&oxu->mem_lock);
620
621 return;
622}
623
624static void qh_destroy(struct kref *kref)
625{
626 struct ehci_qh *qh = container_of(kref, struct ehci_qh, kref);
627 struct oxu_hcd *oxu = qh->oxu;
628
629 /* clean qtds first, and know this is not linked */
630 if (!list_empty(&qh->qtd_list) || qh->qh_next.ptr) {
631 oxu_dbg(oxu, "unused qh not empty!\n");
632 BUG();
633 }
634 if (qh->dummy)
635 oxu_qtd_free(oxu, qh->dummy);
636 oxu_qh_free(oxu, qh);
637}
638
639static struct ehci_qh *oxu_qh_alloc(struct oxu_hcd *oxu)
640{
641 int i;
642 struct ehci_qh *qh = NULL;
643
644 spin_lock(&oxu->mem_lock);
645
646 for (i = 0; i < QHEAD_NUM; i++)
647 if (!oxu->qh_used[i])
648 break;
649
650 if (i < QHEAD_NUM) {
651 qh = (struct ehci_qh *) &oxu->mem->qh_pool[i];
652 memset(qh, 0, sizeof *qh);
653
654 kref_init(&qh->kref);
655 qh->oxu = oxu;
656 qh->qh_dma = virt_to_phys(qh);
657 INIT_LIST_HEAD(&qh->qtd_list);
658
659 /* dummy td enables safe urb queuing */
660 qh->dummy = ehci_qtd_alloc(oxu);
661 if (qh->dummy == NULL) {
662 oxu_dbg(oxu, "no dummy td\n");
663 oxu->qh_used[i] = 0;
664
665 return NULL;
666 }
667
668 oxu->qh_used[i] = 1;
669 }
670
671 spin_unlock(&oxu->mem_lock);
672
673 return qh;
674}
675
676/* to share a qh (cpu threads, or hc) */
677static inline struct ehci_qh *qh_get(struct ehci_qh *qh)
678{
679 kref_get(&qh->kref);
680 return qh;
681}
682
683static inline void qh_put(struct ehci_qh *qh)
684{
685 kref_put(&qh->kref, qh_destroy);
686}
687
688static void oxu_murb_free(struct oxu_hcd *oxu, struct oxu_murb *murb)
689{
690 int index;
691
692 spin_lock(&oxu->mem_lock);
693
694 index = murb - &oxu->murb_pool[0];
695 oxu->murb_used[index] = 0;
696
697 spin_unlock(&oxu->mem_lock);
698
699 return;
700}
701
702static struct oxu_murb *oxu_murb_alloc(struct oxu_hcd *oxu)
703
704{
705 int i;
706 struct oxu_murb *murb = NULL;
707
708 spin_lock(&oxu->mem_lock);
709
710 for (i = 0; i < MURB_NUM; i++)
711 if (!oxu->murb_used[i])
712 break;
713
714 if (i < MURB_NUM) {
715 murb = &(oxu->murb_pool)[i];
716
717 oxu->murb_used[i] = 1;
718 }
719
720 spin_unlock(&oxu->mem_lock);
721
722 return murb;
723}
724
725/* The queue heads and transfer descriptors are managed from pools tied
726 * to each of the "per device" structures.
727 * This is the initialisation and cleanup code.
728 */
729static void ehci_mem_cleanup(struct oxu_hcd *oxu)
730{
731 kfree(oxu->murb_pool);
732 oxu->murb_pool = NULL;
733
734 if (oxu->async)
735 qh_put(oxu->async);
736 oxu->async = NULL;
737
738 del_timer(&oxu->urb_timer);
739
740 oxu->periodic = NULL;
741
742 /* shadow periodic table */
743 kfree(oxu->pshadow);
744 oxu->pshadow = NULL;
745}
746
747/* Remember to add cleanup code (above) if you add anything here.
748 */
749static int ehci_mem_init(struct oxu_hcd *oxu, gfp_t flags)
750{
751 int i;
752
753 for (i = 0; i < oxu->periodic_size; i++)
754 oxu->mem->frame_list[i] = EHCI_LIST_END;
755 for (i = 0; i < QHEAD_NUM; i++)
756 oxu->qh_used[i] = 0;
757 for (i = 0; i < QTD_NUM; i++)
758 oxu->qtd_used[i] = 0;
759
760 oxu->murb_pool = kcalloc(MURB_NUM, sizeof(struct oxu_murb), flags);
761 if (!oxu->murb_pool)
762 goto fail;
763
764 for (i = 0; i < MURB_NUM; i++)
765 oxu->murb_used[i] = 0;
766
767 oxu->async = oxu_qh_alloc(oxu);
768 if (!oxu->async)
769 goto fail;
770
771 oxu->periodic = (__le32 *) &oxu->mem->frame_list;
772 oxu->periodic_dma = virt_to_phys(oxu->periodic);
773
774 for (i = 0; i < oxu->periodic_size; i++)
775 oxu->periodic[i] = EHCI_LIST_END;
776
777 /* software shadow of hardware table */
778 oxu->pshadow = kcalloc(oxu->periodic_size, sizeof(void *), flags);
779 if (oxu->pshadow != NULL)
780 return 0;
781
782fail:
783 oxu_dbg(oxu, "couldn't init memory\n");
784 ehci_mem_cleanup(oxu);
785 return -ENOMEM;
786}
787
788/* Fill a qtd, returning how much of the buffer we were able to queue up.
789 */
790static int qtd_fill(struct ehci_qtd *qtd, dma_addr_t buf, size_t len,
791 int token, int maxpacket)
792{
793 int i, count;
794 u64 addr = buf;
795
796 /* one buffer entry per 4K ... first might be short or unaligned */
797 qtd->hw_buf[0] = cpu_to_le32((u32)addr);
798 qtd->hw_buf_hi[0] = cpu_to_le32((u32)(addr >> 32));
799 count = 0x1000 - (buf & 0x0fff); /* rest of that page */
800 if (likely(len < count)) /* ... iff needed */
801 count = len;
802 else {
803 buf += 0x1000;
804 buf &= ~0x0fff;
805
806 /* per-qtd limit: from 16K to 20K (best alignment) */
807 for (i = 1; count < len && i < 5; i++) {
808 addr = buf;
809 qtd->hw_buf[i] = cpu_to_le32((u32)addr);
810 qtd->hw_buf_hi[i] = cpu_to_le32((u32)(addr >> 32));
811 buf += 0x1000;
812 if ((count + 0x1000) < len)
813 count += 0x1000;
814 else
815 count = len;
816 }
817
818 /* short packets may only terminate transfers */
819 if (count != len)
820 count -= (count % maxpacket);
821 }
822 qtd->hw_token = cpu_to_le32((count << 16) | token);
823 qtd->length = count;
824
825 return count;
826}
827
828static inline void qh_update(struct oxu_hcd *oxu,
829 struct ehci_qh *qh, struct ehci_qtd *qtd)
830{
831 /* writes to an active overlay are unsafe */
832 BUG_ON(qh->qh_state != QH_STATE_IDLE);
833
834 qh->hw_qtd_next = QTD_NEXT(qtd->qtd_dma);
835 qh->hw_alt_next = EHCI_LIST_END;
836
837 /* Except for control endpoints, we make hardware maintain data
838 * toggle (like OHCI) ... here (re)initialize the toggle in the QH,
839 * and set the pseudo-toggle in udev. Only usb_clear_halt() will
840 * ever clear it.
841 */
842 if (!(qh->hw_info1 & cpu_to_le32(1 << 14))) {
843 unsigned is_out, epnum;
844
845 is_out = !(qtd->hw_token & cpu_to_le32(1 << 8));
846 epnum = (le32_to_cpup(&qh->hw_info1) >> 8) & 0x0f;
847 if (unlikely(!usb_gettoggle(qh->dev, epnum, is_out))) {
848 qh->hw_token &= ~__constant_cpu_to_le32(QTD_TOGGLE);
849 usb_settoggle(qh->dev, epnum, is_out, 1);
850 }
851 }
852
853 /* HC must see latest qtd and qh data before we clear ACTIVE+HALT */
854 wmb();
855 qh->hw_token &= __constant_cpu_to_le32(QTD_TOGGLE | QTD_STS_PING);
856}
857
858/* If it weren't for a common silicon quirk (writing the dummy into the qh
859 * overlay, so qh->hw_token wrongly becomes inactive/halted), only fault
860 * recovery (including urb dequeue) would need software changes to a QH...
861 */
862static void qh_refresh(struct oxu_hcd *oxu, struct ehci_qh *qh)
863{
864 struct ehci_qtd *qtd;
865
866 if (list_empty(&qh->qtd_list))
867 qtd = qh->dummy;
868 else {
869 qtd = list_entry(qh->qtd_list.next,
870 struct ehci_qtd, qtd_list);
871 /* first qtd may already be partially processed */
872 if (cpu_to_le32(qtd->qtd_dma) == qh->hw_current)
873 qtd = NULL;
874 }
875
876 if (qtd)
877 qh_update(oxu, qh, qtd);
878}
879
880static void qtd_copy_status(struct oxu_hcd *oxu, struct urb *urb,
881 size_t length, u32 token)
882{
883 /* count IN/OUT bytes, not SETUP (even short packets) */
884 if (likely(QTD_PID(token) != 2))
885 urb->actual_length += length - QTD_LENGTH(token);
886
887 /* don't modify error codes */
888 if (unlikely(urb->status != -EINPROGRESS))
889 return;
890
891 /* force cleanup after short read; not always an error */
892 if (unlikely(IS_SHORT_READ(token)))
893 urb->status = -EREMOTEIO;
894
895 /* serious "can't proceed" faults reported by the hardware */
896 if (token & QTD_STS_HALT) {
897 if (token & QTD_STS_BABBLE) {
898 /* FIXME "must" disable babbling device's port too */
899 urb->status = -EOVERFLOW;
900 } else if (token & QTD_STS_MMF) {
901 /* fs/ls interrupt xfer missed the complete-split */
902 urb->status = -EPROTO;
903 } else if (token & QTD_STS_DBE) {
904 urb->status = (QTD_PID(token) == 1) /* IN ? */
905 ? -ENOSR /* hc couldn't read data */
906 : -ECOMM; /* hc couldn't write data */
907 } else if (token & QTD_STS_XACT) {
908 /* timeout, bad crc, wrong PID, etc; retried */
909 if (QTD_CERR(token))
910 urb->status = -EPIPE;
911 else {
912 oxu_dbg(oxu, "devpath %s ep%d%s 3strikes\n",
913 urb->dev->devpath,
914 usb_pipeendpoint(urb->pipe),
915 usb_pipein(urb->pipe) ? "in" : "out");
916 urb->status = -EPROTO;
917 }
918 /* CERR nonzero + no errors + halt --> stall */
919 } else if (QTD_CERR(token))
920 urb->status = -EPIPE;
921 else /* unknown */
922 urb->status = -EPROTO;
923
924 oxu_vdbg(oxu, "dev%d ep%d%s qtd token %08x --> status %d\n",
925 usb_pipedevice(urb->pipe),
926 usb_pipeendpoint(urb->pipe),
927 usb_pipein(urb->pipe) ? "in" : "out",
928 token, urb->status);
929 }
930}
931
932static void ehci_urb_done(struct oxu_hcd *oxu, struct urb *urb)
933__releases(oxu->lock)
934__acquires(oxu->lock)
935{
936 if (likely(urb->hcpriv != NULL)) {
937 struct ehci_qh *qh = (struct ehci_qh *) urb->hcpriv;
938
939 /* S-mask in a QH means it's an interrupt urb */
940 if ((qh->hw_info2 & __constant_cpu_to_le32(QH_SMASK)) != 0) {
941
942 /* ... update hc-wide periodic stats (for usbfs) */
943 oxu_to_hcd(oxu)->self.bandwidth_int_reqs--;
944 }
945 qh_put(qh);
946 }
947
948 urb->hcpriv = NULL;
949 switch (urb->status) {
950 case -EINPROGRESS: /* success */
951 urb->status = 0;
952 default: /* fault */
953 break;
954 case -EREMOTEIO: /* fault or normal */
955 if (!(urb->transfer_flags & URB_SHORT_NOT_OK))
956 urb->status = 0;
957 break;
958 case -ECONNRESET: /* canceled */
959 case -ENOENT:
960 break;
961 }
962
963#ifdef OXU_URB_TRACE
964 oxu_dbg(oxu, "%s %s urb %p ep%d%s status %d len %d/%d\n",
965 __func__, urb->dev->devpath, urb,
966 usb_pipeendpoint(urb->pipe),
967 usb_pipein(urb->pipe) ? "in" : "out",
968 urb->status,
969 urb->actual_length, urb->transfer_buffer_length);
970#endif
971
972 /* complete() can reenter this HCD */
973 spin_unlock(&oxu->lock);
974 usb_hcd_giveback_urb(oxu_to_hcd(oxu), urb, urb->status);
975 spin_lock(&oxu->lock);
976}
977
978static void start_unlink_async(struct oxu_hcd *oxu, struct ehci_qh *qh);
979static void unlink_async(struct oxu_hcd *oxu, struct ehci_qh *qh);
980
981static void intr_deschedule(struct oxu_hcd *oxu, struct ehci_qh *qh);
982static int qh_schedule(struct oxu_hcd *oxu, struct ehci_qh *qh);
983
984#define HALT_BIT __constant_cpu_to_le32(QTD_STS_HALT)
985
986/* Process and free completed qtds for a qh, returning URBs to drivers.
987 * Chases up to qh->hw_current. Returns number of completions called,
988 * indicating how much "real" work we did.
989 */
990static unsigned qh_completions(struct oxu_hcd *oxu, struct ehci_qh *qh)
991{
992 struct ehci_qtd *last = NULL, *end = qh->dummy;
993 struct list_head *entry, *tmp;
994 int stopped;
995 unsigned count = 0;
996 int do_status = 0;
997 u8 state;
998 struct oxu_murb *murb = NULL;
999
1000 if (unlikely(list_empty(&qh->qtd_list)))
1001 return count;
1002
1003 /* completions (or tasks on other cpus) must never clobber HALT
1004 * till we've gone through and cleaned everything up, even when
1005 * they add urbs to this qh's queue or mark them for unlinking.
1006 *
1007 * NOTE: unlinking expects to be done in queue order.
1008 */
1009 state = qh->qh_state;
1010 qh->qh_state = QH_STATE_COMPLETING;
1011 stopped = (state == QH_STATE_IDLE);
1012
1013 /* remove de-activated QTDs from front of queue.
1014 * after faults (including short reads), cleanup this urb
1015 * then let the queue advance.
1016 * if queue is stopped, handles unlinks.
1017 */
1018 list_for_each_safe(entry, tmp, &qh->qtd_list) {
1019 struct ehci_qtd *qtd;
1020 struct urb *urb;
1021 u32 token = 0;
1022
1023 qtd = list_entry(entry, struct ehci_qtd, qtd_list);
1024 urb = qtd->urb;
1025
1026 /* Clean up any state from previous QTD ...*/
1027 if (last) {
1028 if (likely(last->urb != urb)) {
1029 if (last->urb->complete == NULL) {
1030 murb = (struct oxu_murb *) last->urb;
1031 last->urb = murb->main;
1032 if (murb->last) {
1033 ehci_urb_done(oxu, last->urb);
1034 count++;
1035 }
1036 oxu_murb_free(oxu, murb);
1037 } else {
1038 ehci_urb_done(oxu, last->urb);
1039 count++;
1040 }
1041 }
1042 oxu_qtd_free(oxu, last);
1043 last = NULL;
1044 }
1045
1046 /* ignore urbs submitted during completions we reported */
1047 if (qtd == end)
1048 break;
1049
1050 /* hardware copies qtd out of qh overlay */
1051 rmb();
1052 token = le32_to_cpu(qtd->hw_token);
1053
1054 /* always clean up qtds the hc de-activated */
1055 if ((token & QTD_STS_ACTIVE) == 0) {
1056
1057 if ((token & QTD_STS_HALT) != 0) {
1058 stopped = 1;
1059
1060 /* magic dummy for some short reads; qh won't advance.
1061 * that silicon quirk can kick in with this dummy too.
1062 */
1063 } else if (IS_SHORT_READ(token) &&
1064 !(qtd->hw_alt_next & EHCI_LIST_END)) {
1065 stopped = 1;
1066 goto halt;
1067 }
1068
1069 /* stop scanning when we reach qtds the hc is using */
1070 } else if (likely(!stopped &&
1071 HC_IS_RUNNING(oxu_to_hcd(oxu)->state))) {
1072 break;
1073
1074 } else {
1075 stopped = 1;
1076
1077 if (unlikely(!HC_IS_RUNNING(oxu_to_hcd(oxu)->state)))
1078 urb->status = -ESHUTDOWN;
1079
1080 /* ignore active urbs unless some previous qtd
1081 * for the urb faulted (including short read) or
1082 * its urb was canceled. we may patch qh or qtds.
1083 */
1084 if (likely(urb->status == -EINPROGRESS))
1085 continue;
1086
1087 /* issue status after short control reads */
1088 if (unlikely(do_status != 0)
1089 && QTD_PID(token) == 0 /* OUT */) {
1090 do_status = 0;
1091 continue;
1092 }
1093
1094 /* token in overlay may be most current */
1095 if (state == QH_STATE_IDLE
1096 && cpu_to_le32(qtd->qtd_dma)
1097 == qh->hw_current)
1098 token = le32_to_cpu(qh->hw_token);
1099
1100 /* force halt for unlinked or blocked qh, so we'll
1101 * patch the qh later and so that completions can't
1102 * activate it while we "know" it's stopped.
1103 */
1104 if ((HALT_BIT & qh->hw_token) == 0) {
1105halt:
1106 qh->hw_token |= HALT_BIT;
1107 wmb();
1108 }
1109 }
1110
1111 /* Remove it from the queue */
1112 qtd_copy_status(oxu, urb->complete ?
1113 urb : ((struct oxu_murb *) urb)->main,
1114 qtd->length, token);
1115 if ((usb_pipein(qtd->urb->pipe)) &&
1116 (NULL != qtd->transfer_buffer))
1117 memcpy(qtd->transfer_buffer, qtd->buffer, qtd->length);
1118 do_status = (urb->status == -EREMOTEIO)
1119 && usb_pipecontrol(urb->pipe);
1120
1121 if (stopped && qtd->qtd_list.prev != &qh->qtd_list) {
1122 last = list_entry(qtd->qtd_list.prev,
1123 struct ehci_qtd, qtd_list);
1124 last->hw_next = qtd->hw_next;
1125 }
1126 list_del(&qtd->qtd_list);
1127 last = qtd;
1128 }
1129
1130 /* last urb's completion might still need calling */
1131 if (likely(last != NULL)) {
1132 if (last->urb->complete == NULL) {
1133 murb = (struct oxu_murb *) last->urb;
1134 last->urb = murb->main;
1135 if (murb->last) {
1136 ehci_urb_done(oxu, last->urb);
1137 count++;
1138 }
1139 oxu_murb_free(oxu, murb);
1140 } else {
1141 ehci_urb_done(oxu, last->urb);
1142 count++;
1143 }
1144 oxu_qtd_free(oxu, last);
1145 }
1146
1147 /* restore original state; caller must unlink or relink */
1148 qh->qh_state = state;
1149
1150 /* be sure the hardware's done with the qh before refreshing
1151 * it after fault cleanup, or recovering from silicon wrongly
1152 * overlaying the dummy qtd (which reduces DMA chatter).
1153 */
1154 if (stopped != 0 || qh->hw_qtd_next == EHCI_LIST_END) {
1155 switch (state) {
1156 case QH_STATE_IDLE:
1157 qh_refresh(oxu, qh);
1158 break;
1159 case QH_STATE_LINKED:
1160 /* should be rare for periodic transfers,
1161 * except maybe high bandwidth ...
1162 */
1163 if ((__constant_cpu_to_le32(QH_SMASK)
1164 & qh->hw_info2) != 0) {
1165 intr_deschedule(oxu, qh);
1166 (void) qh_schedule(oxu, qh);
1167 } else
1168 unlink_async(oxu, qh);
1169 break;
1170 /* otherwise, unlink already started */
1171 }
1172 }
1173
1174 return count;
1175}
1176
1177/* High bandwidth multiplier, as encoded in highspeed endpoint descriptors */
1178#define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03))
1179/* ... and packet size, for any kind of endpoint descriptor */
1180#define max_packet(wMaxPacketSize) ((wMaxPacketSize) & 0x07ff)
1181
1182/* Reverse of qh_urb_transaction: free a list of TDs.
1183 * used for cleanup after errors, before HC sees an URB's TDs.
1184 */
1185static void qtd_list_free(struct oxu_hcd *oxu,
1186 struct urb *urb, struct list_head *qtd_list)
1187{
1188 struct list_head *entry, *temp;
1189
1190 list_for_each_safe(entry, temp, qtd_list) {
1191 struct ehci_qtd *qtd;
1192
1193 qtd = list_entry(entry, struct ehci_qtd, qtd_list);
1194 list_del(&qtd->qtd_list);
1195 oxu_qtd_free(oxu, qtd);
1196 }
1197}
1198
1199/* Create a list of filled qtds for this URB; won't link into qh.
1200 */
1201static struct list_head *qh_urb_transaction(struct oxu_hcd *oxu,
1202 struct urb *urb,
1203 struct list_head *head,
1204 gfp_t flags)
1205{
1206 struct ehci_qtd *qtd, *qtd_prev;
1207 dma_addr_t buf;
1208 int len, maxpacket;
1209 int is_input;
1210 u32 token;
1211 void *transfer_buf = NULL;
1212 int ret;
1213
1214 /*
1215 * URBs map to sequences of QTDs: one logical transaction
1216 */
1217 qtd = ehci_qtd_alloc(oxu);
1218 if (unlikely(!qtd))
1219 return NULL;
1220 list_add_tail(&qtd->qtd_list, head);
1221 qtd->urb = urb;
1222
1223 token = QTD_STS_ACTIVE;
1224 token |= (EHCI_TUNE_CERR << 10);
1225 /* for split transactions, SplitXState initialized to zero */
1226
1227 len = urb->transfer_buffer_length;
1228 is_input = usb_pipein(urb->pipe);
1229 if (!urb->transfer_buffer && urb->transfer_buffer_length && is_input)
1230 urb->transfer_buffer = phys_to_virt(urb->transfer_dma);
1231
1232 if (usb_pipecontrol(urb->pipe)) {
1233 /* SETUP pid */
1234 ret = oxu_buf_alloc(oxu, qtd, sizeof(struct usb_ctrlrequest));
1235 if (ret)
1236 goto cleanup;
1237
1238 qtd_fill(qtd, qtd->buffer_dma, sizeof(struct usb_ctrlrequest),
1239 token | (2 /* "setup" */ << 8), 8);
1240 memcpy(qtd->buffer, qtd->urb->setup_packet,
1241 sizeof(struct usb_ctrlrequest));
1242
1243 /* ... and always at least one more pid */
1244 token ^= QTD_TOGGLE;
1245 qtd_prev = qtd;
1246 qtd = ehci_qtd_alloc(oxu);
1247 if (unlikely(!qtd))
1248 goto cleanup;
1249 qtd->urb = urb;
1250 qtd_prev->hw_next = QTD_NEXT(qtd->qtd_dma);
1251 list_add_tail(&qtd->qtd_list, head);
1252
1253 /* for zero length DATA stages, STATUS is always IN */
1254 if (len == 0)
1255 token |= (1 /* "in" */ << 8);
1256 }
1257
1258 /*
1259 * Data transfer stage: buffer setup
1260 */
1261
1262 ret = oxu_buf_alloc(oxu, qtd, len);
1263 if (ret)
1264 goto cleanup;
1265
1266 buf = qtd->buffer_dma;
1267 transfer_buf = urb->transfer_buffer;
1268
1269 if (!is_input)
1270 memcpy(qtd->buffer, qtd->urb->transfer_buffer, len);
1271
1272 if (is_input)
1273 token |= (1 /* "in" */ << 8);
1274 /* else it's already initted to "out" pid (0 << 8) */
1275
1276 maxpacket = max_packet(usb_maxpacket(urb->dev, urb->pipe, !is_input));
1277
1278 /*
1279 * buffer gets wrapped in one or more qtds;
1280 * last one may be "short" (including zero len)
1281 * and may serve as a control status ack
1282 */
1283 for (;;) {
1284 int this_qtd_len;
1285
1286 this_qtd_len = qtd_fill(qtd, buf, len, token, maxpacket);
1287 qtd->transfer_buffer = transfer_buf;
1288 len -= this_qtd_len;
1289 buf += this_qtd_len;
1290 transfer_buf += this_qtd_len;
1291 if (is_input)
1292 qtd->hw_alt_next = oxu->async->hw_alt_next;
1293
1294 /* qh makes control packets use qtd toggle; maybe switch it */
1295 if ((maxpacket & (this_qtd_len + (maxpacket - 1))) == 0)
1296 token ^= QTD_TOGGLE;
1297
1298 if (likely(len <= 0))
1299 break;
1300
1301 qtd_prev = qtd;
1302 qtd = ehci_qtd_alloc(oxu);
1303 if (unlikely(!qtd))
1304 goto cleanup;
1305 if (likely(len > 0)) {
1306 ret = oxu_buf_alloc(oxu, qtd, len);
1307 if (ret)
1308 goto cleanup;
1309 }
1310 qtd->urb = urb;
1311 qtd_prev->hw_next = QTD_NEXT(qtd->qtd_dma);
1312 list_add_tail(&qtd->qtd_list, head);
1313 }
1314
1315 /* unless the bulk/interrupt caller wants a chance to clean
1316 * up after short reads, hc should advance qh past this urb
1317 */
1318 if (likely((urb->transfer_flags & URB_SHORT_NOT_OK) == 0
1319 || usb_pipecontrol(urb->pipe)))
1320 qtd->hw_alt_next = EHCI_LIST_END;
1321
1322 /*
1323 * control requests may need a terminating data "status" ack;
1324 * bulk ones may need a terminating short packet (zero length).
1325 */
1326 if (likely(urb->transfer_buffer_length != 0)) {
1327 int one_more = 0;
1328
1329 if (usb_pipecontrol(urb->pipe)) {
1330 one_more = 1;
1331 token ^= 0x0100; /* "in" <--> "out" */
1332 token |= QTD_TOGGLE; /* force DATA1 */
1333 } else if (usb_pipebulk(urb->pipe)
1334 && (urb->transfer_flags & URB_ZERO_PACKET)
1335 && !(urb->transfer_buffer_length % maxpacket)) {
1336 one_more = 1;
1337 }
1338 if (one_more) {
1339 qtd_prev = qtd;
1340 qtd = ehci_qtd_alloc(oxu);
1341 if (unlikely(!qtd))
1342 goto cleanup;
1343 qtd->urb = urb;
1344 qtd_prev->hw_next = QTD_NEXT(qtd->qtd_dma);
1345 list_add_tail(&qtd->qtd_list, head);
1346
1347 /* never any data in such packets */
1348 qtd_fill(qtd, 0, 0, token, 0);
1349 }
1350 }
1351
1352 /* by default, enable interrupt on urb completion */
1353 qtd->hw_token |= __constant_cpu_to_le32(QTD_IOC);
1354 return head;
1355
1356cleanup:
1357 qtd_list_free(oxu, urb, head);
1358 return NULL;
1359}
1360
1361/* Each QH holds a qtd list; a QH is used for everything except iso.
1362 *
1363 * For interrupt urbs, the scheduler must set the microframe scheduling
1364 * mask(s) each time the QH gets scheduled. For highspeed, that's
1365 * just one microframe in the s-mask. For split interrupt transactions
1366 * there are additional complications: c-mask, maybe FSTNs.
1367 */
1368static struct ehci_qh *qh_make(struct oxu_hcd *oxu,
1369 struct urb *urb, gfp_t flags)
1370{
1371 struct ehci_qh *qh = oxu_qh_alloc(oxu);
1372 u32 info1 = 0, info2 = 0;
1373 int is_input, type;
1374 int maxp = 0;
1375
1376 if (!qh)
1377 return qh;
1378
1379 /*
1380 * init endpoint/device data for this QH
1381 */
1382 info1 |= usb_pipeendpoint(urb->pipe) << 8;
1383 info1 |= usb_pipedevice(urb->pipe) << 0;
1384
1385 is_input = usb_pipein(urb->pipe);
1386 type = usb_pipetype(urb->pipe);
1387 maxp = usb_maxpacket(urb->dev, urb->pipe, !is_input);
1388
1389 /* Compute interrupt scheduling parameters just once, and save.
1390 * - allowing for high bandwidth, how many nsec/uframe are used?
1391 * - split transactions need a second CSPLIT uframe; same question
1392 * - splits also need a schedule gap (for full/low speed I/O)
1393 * - qh has a polling interval
1394 *
1395 * For control/bulk requests, the HC or TT handles these.
1396 */
1397 if (type == PIPE_INTERRUPT) {
1398 qh->usecs = NS_TO_US(usb_calc_bus_time(USB_SPEED_HIGH,
1399 is_input, 0,
1400 hb_mult(maxp) * max_packet(maxp)));
1401 qh->start = NO_FRAME;
1402
1403 if (urb->dev->speed == USB_SPEED_HIGH) {
1404 qh->c_usecs = 0;
1405 qh->gap_uf = 0;
1406
1407 qh->period = urb->interval >> 3;
1408 if (qh->period == 0 && urb->interval != 1) {
1409 /* NOTE interval 2 or 4 uframes could work.
1410 * But interval 1 scheduling is simpler, and
1411 * includes high bandwidth.
1412 */
1413 dbg("intr period %d uframes, NYET!",
1414 urb->interval);
1415 goto done;
1416 }
1417 } else {
1418 struct usb_tt *tt = urb->dev->tt;
1419 int think_time;
1420
1421 /* gap is f(FS/LS transfer times) */
1422 qh->gap_uf = 1 + usb_calc_bus_time(urb->dev->speed,
1423 is_input, 0, maxp) / (125 * 1000);
1424
1425 /* FIXME this just approximates SPLIT/CSPLIT times */
1426 if (is_input) { /* SPLIT, gap, CSPLIT+DATA */
1427 qh->c_usecs = qh->usecs + HS_USECS(0);
1428 qh->usecs = HS_USECS(1);
1429 } else { /* SPLIT+DATA, gap, CSPLIT */
1430 qh->usecs += HS_USECS(1);
1431 qh->c_usecs = HS_USECS(0);
1432 }
1433
1434 think_time = tt ? tt->think_time : 0;
1435 qh->tt_usecs = NS_TO_US(think_time +
1436 usb_calc_bus_time(urb->dev->speed,
1437 is_input, 0, max_packet(maxp)));
1438 qh->period = urb->interval;
1439 }
1440 }
1441
1442 /* support for tt scheduling, and access to toggles */
1443 qh->dev = urb->dev;
1444
1445 /* using TT? */
1446 switch (urb->dev->speed) {
1447 case USB_SPEED_LOW:
1448 info1 |= (1 << 12); /* EPS "low" */
1449 /* FALL THROUGH */
1450
1451 case USB_SPEED_FULL:
1452 /* EPS 0 means "full" */
1453 if (type != PIPE_INTERRUPT)
1454 info1 |= (EHCI_TUNE_RL_TT << 28);
1455 if (type == PIPE_CONTROL) {
1456 info1 |= (1 << 27); /* for TT */
1457 info1 |= 1 << 14; /* toggle from qtd */
1458 }
1459 info1 |= maxp << 16;
1460
1461 info2 |= (EHCI_TUNE_MULT_TT << 30);
1462 info2 |= urb->dev->ttport << 23;
1463
1464 /* NOTE: if (PIPE_INTERRUPT) { scheduler sets c-mask } */
1465
1466 break;
1467
1468 case USB_SPEED_HIGH: /* no TT involved */
1469 info1 |= (2 << 12); /* EPS "high" */
1470 if (type == PIPE_CONTROL) {
1471 info1 |= (EHCI_TUNE_RL_HS << 28);
1472 info1 |= 64 << 16; /* usb2 fixed maxpacket */
1473 info1 |= 1 << 14; /* toggle from qtd */
1474 info2 |= (EHCI_TUNE_MULT_HS << 30);
1475 } else if (type == PIPE_BULK) {
1476 info1 |= (EHCI_TUNE_RL_HS << 28);
1477 info1 |= 512 << 16; /* usb2 fixed maxpacket */
1478 info2 |= (EHCI_TUNE_MULT_HS << 30);
1479 } else { /* PIPE_INTERRUPT */
1480 info1 |= max_packet(maxp) << 16;
1481 info2 |= hb_mult(maxp) << 30;
1482 }
1483 break;
1484 default:
1485 dbg("bogus dev %p speed %d", urb->dev, urb->dev->speed);
1486done:
1487 qh_put(qh);
1488 return NULL;
1489 }
1490
1491 /* NOTE: if (PIPE_INTERRUPT) { scheduler sets s-mask } */
1492
1493 /* init as live, toggle clear, advance to dummy */
1494 qh->qh_state = QH_STATE_IDLE;
1495 qh->hw_info1 = cpu_to_le32(info1);
1496 qh->hw_info2 = cpu_to_le32(info2);
1497 usb_settoggle(urb->dev, usb_pipeendpoint(urb->pipe), !is_input, 1);
1498 qh_refresh(oxu, qh);
1499 return qh;
1500}
1501
1502/* Move qh (and its qtds) onto async queue; maybe enable queue.
1503 */
1504static void qh_link_async(struct oxu_hcd *oxu, struct ehci_qh *qh)
1505{
1506 __le32 dma = QH_NEXT(qh->qh_dma);
1507 struct ehci_qh *head;
1508
1509 /* (re)start the async schedule? */
1510 head = oxu->async;
1511 timer_action_done(oxu, TIMER_ASYNC_OFF);
1512 if (!head->qh_next.qh) {
1513 u32 cmd = readl(&oxu->regs->command);
1514
1515 if (!(cmd & CMD_ASE)) {
1516 /* in case a clear of CMD_ASE didn't take yet */
1517 (void)handshake(oxu, &oxu->regs->status,
1518 STS_ASS, 0, 150);
1519 cmd |= CMD_ASE | CMD_RUN;
1520 writel(cmd, &oxu->regs->command);
1521 oxu_to_hcd(oxu)->state = HC_STATE_RUNNING;
1522 /* posted write need not be known to HC yet ... */
1523 }
1524 }
1525
1526 /* clear halt and/or toggle; and maybe recover from silicon quirk */
1527 if (qh->qh_state == QH_STATE_IDLE)
1528 qh_refresh(oxu, qh);
1529
1530 /* splice right after start */
1531 qh->qh_next = head->qh_next;
1532 qh->hw_next = head->hw_next;
1533 wmb();
1534
1535 head->qh_next.qh = qh;
1536 head->hw_next = dma;
1537
1538 qh->qh_state = QH_STATE_LINKED;
1539 /* qtd completions reported later by interrupt */
1540}
1541
1542#define QH_ADDR_MASK __constant_cpu_to_le32(0x7f)
1543
1544/*
1545 * For control/bulk/interrupt, return QH with these TDs appended.
1546 * Allocates and initializes the QH if necessary.
1547 * Returns null if it can't allocate a QH it needs to.
1548 * If the QH has TDs (urbs) already, that's great.
1549 */
1550static struct ehci_qh *qh_append_tds(struct oxu_hcd *oxu,
1551 struct urb *urb, struct list_head *qtd_list,
1552 int epnum, void **ptr)
1553{
1554 struct ehci_qh *qh = NULL;
1555
1556 qh = (struct ehci_qh *) *ptr;
1557 if (unlikely(qh == NULL)) {
1558 /* can't sleep here, we have oxu->lock... */
1559 qh = qh_make(oxu, urb, GFP_ATOMIC);
1560 *ptr = qh;
1561 }
1562 if (likely(qh != NULL)) {
1563 struct ehci_qtd *qtd;
1564
1565 if (unlikely(list_empty(qtd_list)))
1566 qtd = NULL;
1567 else
1568 qtd = list_entry(qtd_list->next, struct ehci_qtd,
1569 qtd_list);
1570
1571 /* control qh may need patching ... */
1572 if (unlikely(epnum == 0)) {
1573
1574 /* usb_reset_device() briefly reverts to address 0 */
1575 if (usb_pipedevice(urb->pipe) == 0)
1576 qh->hw_info1 &= ~QH_ADDR_MASK;
1577 }
1578
1579 /* just one way to queue requests: swap with the dummy qtd.
1580 * only hc or qh_refresh() ever modify the overlay.
1581 */
1582 if (likely(qtd != NULL)) {
1583 struct ehci_qtd *dummy;
1584 dma_addr_t dma;
1585 __le32 token;
1586
1587 /* to avoid racing the HC, use the dummy td instead of
1588 * the first td of our list (becomes new dummy). both
1589 * tds stay deactivated until we're done, when the
1590 * HC is allowed to fetch the old dummy (4.10.2).
1591 */
1592 token = qtd->hw_token;
1593 qtd->hw_token = HALT_BIT;
1594 wmb();
1595 dummy = qh->dummy;
1596
1597 dma = dummy->qtd_dma;
1598 *dummy = *qtd;
1599 dummy->qtd_dma = dma;
1600
1601 list_del(&qtd->qtd_list);
1602 list_add(&dummy->qtd_list, qtd_list);
1603 list_splice(qtd_list, qh->qtd_list.prev);
1604
1605 ehci_qtd_init(qtd, qtd->qtd_dma);
1606 qh->dummy = qtd;
1607
1608 /* hc must see the new dummy at list end */
1609 dma = qtd->qtd_dma;
1610 qtd = list_entry(qh->qtd_list.prev,
1611 struct ehci_qtd, qtd_list);
1612 qtd->hw_next = QTD_NEXT(dma);
1613
1614 /* let the hc process these next qtds */
1615 dummy->hw_token = (token & ~(0x80));
1616 wmb();
1617 dummy->hw_token = token;
1618
1619 urb->hcpriv = qh_get(qh);
1620 }
1621 }
1622 return qh;
1623}
1624
1625static int submit_async(struct oxu_hcd *oxu, struct urb *urb,
1626 struct list_head *qtd_list, gfp_t mem_flags)
1627{
1628 struct ehci_qtd *qtd;
1629 int epnum;
1630 unsigned long flags;
1631 struct ehci_qh *qh = NULL;
1632 int rc = 0;
1633
1634 qtd = list_entry(qtd_list->next, struct ehci_qtd, qtd_list);
1635 epnum = urb->ep->desc.bEndpointAddress;
1636
1637#ifdef OXU_URB_TRACE
1638 oxu_dbg(oxu, "%s %s urb %p ep%d%s len %d, qtd %p [qh %p]\n",
1639 __func__, urb->dev->devpath, urb,
1640 epnum & 0x0f, (epnum & USB_DIR_IN) ? "in" : "out",
1641 urb->transfer_buffer_length,
1642 qtd, urb->ep->hcpriv);
1643#endif
1644
1645 spin_lock_irqsave(&oxu->lock, flags);
1646 if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE,
1647 &oxu_to_hcd(oxu)->flags))) {
1648 rc = -ESHUTDOWN;
1649 goto done;
1650 }
1651
1652 qh = qh_append_tds(oxu, urb, qtd_list, epnum, &urb->ep->hcpriv);
1653 if (unlikely(qh == NULL)) {
1654 rc = -ENOMEM;
1655 goto done;
1656 }
1657
1658 /* Control/bulk operations through TTs don't need scheduling,
1659 * the HC and TT handle it when the TT has a buffer ready.
1660 */
1661 if (likely(qh->qh_state == QH_STATE_IDLE))
1662 qh_link_async(oxu, qh_get(qh));
1663done:
1664 spin_unlock_irqrestore(&oxu->lock, flags);
1665 if (unlikely(qh == NULL))
1666 qtd_list_free(oxu, urb, qtd_list);
1667 return rc;
1668}
1669
1670/* The async qh for the qtds being reclaimed are now unlinked from the HC */
1671
1672static void end_unlink_async(struct oxu_hcd *oxu)
1673{
1674 struct ehci_qh *qh = oxu->reclaim;
1675 struct ehci_qh *next;
1676
1677 timer_action_done(oxu, TIMER_IAA_WATCHDOG);
1678
1679 qh->qh_state = QH_STATE_IDLE;
1680 qh->qh_next.qh = NULL;
1681 qh_put(qh); /* refcount from reclaim */
1682
1683 /* other unlink(s) may be pending (in QH_STATE_UNLINK_WAIT) */
1684 next = qh->reclaim;
1685 oxu->reclaim = next;
1686 oxu->reclaim_ready = 0;
1687 qh->reclaim = NULL;
1688
1689 qh_completions(oxu, qh);
1690
1691 if (!list_empty(&qh->qtd_list)
1692 && HC_IS_RUNNING(oxu_to_hcd(oxu)->state))
1693 qh_link_async(oxu, qh);
1694 else {
1695 qh_put(qh); /* refcount from async list */
1696
1697 /* it's not free to turn the async schedule on/off; leave it
1698 * active but idle for a while once it empties.
1699 */
1700 if (HC_IS_RUNNING(oxu_to_hcd(oxu)->state)
1701 && oxu->async->qh_next.qh == NULL)
1702 timer_action(oxu, TIMER_ASYNC_OFF);
1703 }
1704
1705 if (next) {
1706 oxu->reclaim = NULL;
1707 start_unlink_async(oxu, next);
1708 }
1709}
1710
1711/* makes sure the async qh will become idle */
1712/* caller must own oxu->lock */
1713
1714static void start_unlink_async(struct oxu_hcd *oxu, struct ehci_qh *qh)
1715{
1716 int cmd = readl(&oxu->regs->command);
1717 struct ehci_qh *prev;
1718
1719#ifdef DEBUG
1720 assert_spin_locked(&oxu->lock);
1721 if (oxu->reclaim || (qh->qh_state != QH_STATE_LINKED
1722 && qh->qh_state != QH_STATE_UNLINK_WAIT))
1723 BUG();
1724#endif
1725
1726 /* stop async schedule right now? */
1727 if (unlikely(qh == oxu->async)) {
1728 /* can't get here without STS_ASS set */
1729 if (oxu_to_hcd(oxu)->state != HC_STATE_HALT
1730 && !oxu->reclaim) {
1731 /* ... and CMD_IAAD clear */
1732 writel(cmd & ~CMD_ASE, &oxu->regs->command);
1733 wmb();
1734 /* handshake later, if we need to */
1735 timer_action_done(oxu, TIMER_ASYNC_OFF);
1736 }
1737 return;
1738 }
1739
1740 qh->qh_state = QH_STATE_UNLINK;
1741 oxu->reclaim = qh = qh_get(qh);
1742
1743 prev = oxu->async;
1744 while (prev->qh_next.qh != qh)
1745 prev = prev->qh_next.qh;
1746
1747 prev->hw_next = qh->hw_next;
1748 prev->qh_next = qh->qh_next;
1749 wmb();
1750
1751 if (unlikely(oxu_to_hcd(oxu)->state == HC_STATE_HALT)) {
1752 /* if (unlikely(qh->reclaim != 0))
1753 * this will recurse, probably not much
1754 */
1755 end_unlink_async(oxu);
1756 return;
1757 }
1758
1759 oxu->reclaim_ready = 0;
1760 cmd |= CMD_IAAD;
1761 writel(cmd, &oxu->regs->command);
1762 (void) readl(&oxu->regs->command);
1763 timer_action(oxu, TIMER_IAA_WATCHDOG);
1764}
1765
1766static void scan_async(struct oxu_hcd *oxu)
1767{
1768 struct ehci_qh *qh;
1769 enum ehci_timer_action action = TIMER_IO_WATCHDOG;
1770
1771 if (!++(oxu->stamp))
1772 oxu->stamp++;
1773 timer_action_done(oxu, TIMER_ASYNC_SHRINK);
1774rescan:
1775 qh = oxu->async->qh_next.qh;
1776 if (likely(qh != NULL)) {
1777 do {
1778 /* clean any finished work for this qh */
1779 if (!list_empty(&qh->qtd_list)
1780 && qh->stamp != oxu->stamp) {
1781 int temp;
1782
1783 /* unlinks could happen here; completion
1784 * reporting drops the lock. rescan using
1785 * the latest schedule, but don't rescan
1786 * qhs we already finished (no looping).
1787 */
1788 qh = qh_get(qh);
1789 qh->stamp = oxu->stamp;
1790 temp = qh_completions(oxu, qh);
1791 qh_put(qh);
1792 if (temp != 0)
1793 goto rescan;
1794 }
1795
1796 /* unlink idle entries, reducing HC PCI usage as well
1797 * as HCD schedule-scanning costs. delay for any qh
1798 * we just scanned, there's a not-unusual case that it
1799 * doesn't stay idle for long.
1800 * (plus, avoids some kind of re-activation race.)
1801 */
1802 if (list_empty(&qh->qtd_list)) {
1803 if (qh->stamp == oxu->stamp)
1804 action = TIMER_ASYNC_SHRINK;
1805 else if (!oxu->reclaim
1806 && qh->qh_state == QH_STATE_LINKED)
1807 start_unlink_async(oxu, qh);
1808 }
1809
1810 qh = qh->qh_next.qh;
1811 } while (qh);
1812 }
1813 if (action == TIMER_ASYNC_SHRINK)
1814 timer_action(oxu, TIMER_ASYNC_SHRINK);
1815}
1816
1817/*
1818 * periodic_next_shadow - return "next" pointer on shadow list
1819 * @periodic: host pointer to qh/itd/sitd
1820 * @tag: hardware tag for type of this record
1821 */
1822static union ehci_shadow *periodic_next_shadow(union ehci_shadow *periodic,
1823 __le32 tag)
1824{
1825 switch (tag) {
1826 default:
1827 case Q_TYPE_QH:
1828 return &periodic->qh->qh_next;
1829 }
1830}
1831
1832/* caller must hold oxu->lock */
1833static void periodic_unlink(struct oxu_hcd *oxu, unsigned frame, void *ptr)
1834{
1835 union ehci_shadow *prev_p = &oxu->pshadow[frame];
1836 __le32 *hw_p = &oxu->periodic[frame];
1837 union ehci_shadow here = *prev_p;
1838
1839 /* find predecessor of "ptr"; hw and shadow lists are in sync */
1840 while (here.ptr && here.ptr != ptr) {
1841 prev_p = periodic_next_shadow(prev_p, Q_NEXT_TYPE(*hw_p));
1842 hw_p = here.hw_next;
1843 here = *prev_p;
1844 }
1845 /* an interrupt entry (at list end) could have been shared */
1846 if (!here.ptr)
1847 return;
1848
1849 /* update shadow and hardware lists ... the old "next" pointers
1850 * from ptr may still be in use, the caller updates them.
1851 */
1852 *prev_p = *periodic_next_shadow(&here, Q_NEXT_TYPE(*hw_p));
1853 *hw_p = *here.hw_next;
1854}
1855
1856/* how many of the uframe's 125 usecs are allocated? */
1857static unsigned short periodic_usecs(struct oxu_hcd *oxu,
1858 unsigned frame, unsigned uframe)
1859{
1860 __le32 *hw_p = &oxu->periodic[frame];
1861 union ehci_shadow *q = &oxu->pshadow[frame];
1862 unsigned usecs = 0;
1863
1864 while (q->ptr) {
1865 switch (Q_NEXT_TYPE(*hw_p)) {
1866 case Q_TYPE_QH:
1867 default:
1868 /* is it in the S-mask? */
1869 if (q->qh->hw_info2 & cpu_to_le32(1 << uframe))
1870 usecs += q->qh->usecs;
1871 /* ... or C-mask? */
1872 if (q->qh->hw_info2 & cpu_to_le32(1 << (8 + uframe)))
1873 usecs += q->qh->c_usecs;
1874 hw_p = &q->qh->hw_next;
1875 q = &q->qh->qh_next;
1876 break;
1877 }
1878 }
1879#ifdef DEBUG
1880 if (usecs > 100)
1881 oxu_err(oxu, "uframe %d sched overrun: %d usecs\n",
1882 frame * 8 + uframe, usecs);
1883#endif
1884 return usecs;
1885}
1886
1887static int enable_periodic(struct oxu_hcd *oxu)
1888{
1889 u32 cmd;
1890 int status;
1891
1892 /* did clearing PSE did take effect yet?
1893 * takes effect only at frame boundaries...
1894 */
1895 status = handshake(oxu, &oxu->regs->status, STS_PSS, 0, 9 * 125);
1896 if (status != 0) {
1897 oxu_to_hcd(oxu)->state = HC_STATE_HALT;
1898 return status;
1899 }
1900
1901 cmd = readl(&oxu->regs->command) | CMD_PSE;
1902 writel(cmd, &oxu->regs->command);
1903 /* posted write ... PSS happens later */
1904 oxu_to_hcd(oxu)->state = HC_STATE_RUNNING;
1905
1906 /* make sure ehci_work scans these */
1907 oxu->next_uframe = readl(&oxu->regs->frame_index)
1908 % (oxu->periodic_size << 3);
1909 return 0;
1910}
1911
1912static int disable_periodic(struct oxu_hcd *oxu)
1913{
1914 u32 cmd;
1915 int status;
1916
1917 /* did setting PSE not take effect yet?
1918 * takes effect only at frame boundaries...
1919 */
1920 status = handshake(oxu, &oxu->regs->status, STS_PSS, STS_PSS, 9 * 125);
1921 if (status != 0) {
1922 oxu_to_hcd(oxu)->state = HC_STATE_HALT;
1923 return status;
1924 }
1925
1926 cmd = readl(&oxu->regs->command) & ~CMD_PSE;
1927 writel(cmd, &oxu->regs->command);
1928 /* posted write ... */
1929
1930 oxu->next_uframe = -1;
1931 return 0;
1932}
1933
1934/* periodic schedule slots have iso tds (normal or split) first, then a
1935 * sparse tree for active interrupt transfers.
1936 *
1937 * this just links in a qh; caller guarantees uframe masks are set right.
1938 * no FSTN support (yet; oxu 0.96+)
1939 */
1940static int qh_link_periodic(struct oxu_hcd *oxu, struct ehci_qh *qh)
1941{
1942 unsigned i;
1943 unsigned period = qh->period;
1944
1945 dev_dbg(&qh->dev->dev,
1946 "link qh%d-%04x/%p start %d [%d/%d us]\n",
1947 period, le32_to_cpup(&qh->hw_info2) & (QH_CMASK | QH_SMASK),
1948 qh, qh->start, qh->usecs, qh->c_usecs);
1949
1950 /* high bandwidth, or otherwise every microframe */
1951 if (period == 0)
1952 period = 1;
1953
1954 for (i = qh->start; i < oxu->periodic_size; i += period) {
1955 union ehci_shadow *prev = &oxu->pshadow[i];
1956 __le32 *hw_p = &oxu->periodic[i];
1957 union ehci_shadow here = *prev;
1958 __le32 type = 0;
1959
1960 /* skip the iso nodes at list head */
1961 while (here.ptr) {
1962 type = Q_NEXT_TYPE(*hw_p);
1963 if (type == Q_TYPE_QH)
1964 break;
1965 prev = periodic_next_shadow(prev, type);
1966 hw_p = &here.qh->hw_next;
1967 here = *prev;
1968 }
1969
1970 /* sorting each branch by period (slow-->fast)
1971 * enables sharing interior tree nodes
1972 */
1973 while (here.ptr && qh != here.qh) {
1974 if (qh->period > here.qh->period)
1975 break;
1976 prev = &here.qh->qh_next;
1977 hw_p = &here.qh->hw_next;
1978 here = *prev;
1979 }
1980 /* link in this qh, unless some earlier pass did that */
1981 if (qh != here.qh) {
1982 qh->qh_next = here;
1983 if (here.qh)
1984 qh->hw_next = *hw_p;
1985 wmb();
1986 prev->qh = qh;
1987 *hw_p = QH_NEXT(qh->qh_dma);
1988 }
1989 }
1990 qh->qh_state = QH_STATE_LINKED;
1991 qh_get(qh);
1992
1993 /* update per-qh bandwidth for usbfs */
1994 oxu_to_hcd(oxu)->self.bandwidth_allocated += qh->period
1995 ? ((qh->usecs + qh->c_usecs) / qh->period)
1996 : (qh->usecs * 8);
1997
1998 /* maybe enable periodic schedule processing */
1999 if (!oxu->periodic_sched++)
2000 return enable_periodic(oxu);
2001
2002 return 0;
2003}
2004
2005static void qh_unlink_periodic(struct oxu_hcd *oxu, struct ehci_qh *qh)
2006{
2007 unsigned i;
2008 unsigned period;
2009
2010 /* FIXME:
2011 * IF this isn't high speed
2012 * and this qh is active in the current uframe
2013 * (and overlay token SplitXstate is false?)
2014 * THEN
2015 * qh->hw_info1 |= __constant_cpu_to_le32(1 << 7 "ignore");
2016 */
2017
2018 /* high bandwidth, or otherwise part of every microframe */
2019 period = qh->period;
2020 if (period == 0)
2021 period = 1;
2022
2023 for (i = qh->start; i < oxu->periodic_size; i += period)
2024 periodic_unlink(oxu, i, qh);
2025
2026 /* update per-qh bandwidth for usbfs */
2027 oxu_to_hcd(oxu)->self.bandwidth_allocated -= qh->period
2028 ? ((qh->usecs + qh->c_usecs) / qh->period)
2029 : (qh->usecs * 8);
2030
2031 dev_dbg(&qh->dev->dev,
2032 "unlink qh%d-%04x/%p start %d [%d/%d us]\n",
2033 qh->period,
2034 le32_to_cpup(&qh->hw_info2) & (QH_CMASK | QH_SMASK),
2035 qh, qh->start, qh->usecs, qh->c_usecs);
2036
2037 /* qh->qh_next still "live" to HC */
2038 qh->qh_state = QH_STATE_UNLINK;
2039 qh->qh_next.ptr = NULL;
2040 qh_put(qh);
2041
2042 /* maybe turn off periodic schedule */
2043 oxu->periodic_sched--;
2044 if (!oxu->periodic_sched)
2045 (void) disable_periodic(oxu);
2046}
2047
2048static void intr_deschedule(struct oxu_hcd *oxu, struct ehci_qh *qh)
2049{
2050 unsigned wait;
2051
2052 qh_unlink_periodic(oxu, qh);
2053
2054 /* simple/paranoid: always delay, expecting the HC needs to read
2055 * qh->hw_next or finish a writeback after SPLIT/CSPLIT ... and
2056 * expect khubd to clean up after any CSPLITs we won't issue.
2057 * active high speed queues may need bigger delays...
2058 */
2059 if (list_empty(&qh->qtd_list)
2060 || (__constant_cpu_to_le32(QH_CMASK) & qh->hw_info2) != 0)
2061 wait = 2;
2062 else
2063 wait = 55; /* worst case: 3 * 1024 */
2064
2065 udelay(wait);
2066 qh->qh_state = QH_STATE_IDLE;
2067 qh->hw_next = EHCI_LIST_END;
2068 wmb();
2069}
2070
2071static int check_period(struct oxu_hcd *oxu,
2072 unsigned frame, unsigned uframe,
2073 unsigned period, unsigned usecs)
2074{
2075 int claimed;
2076
2077 /* complete split running into next frame?
2078 * given FSTN support, we could sometimes check...
2079 */
2080 if (uframe >= 8)
2081 return 0;
2082
2083 /*
2084 * 80% periodic == 100 usec/uframe available
2085 * convert "usecs we need" to "max already claimed"
2086 */
2087 usecs = 100 - usecs;
2088
2089 /* we "know" 2 and 4 uframe intervals were rejected; so
2090 * for period 0, check _every_ microframe in the schedule.
2091 */
2092 if (unlikely(period == 0)) {
2093 do {
2094 for (uframe = 0; uframe < 7; uframe++) {
2095 claimed = periodic_usecs(oxu, frame, uframe);
2096 if (claimed > usecs)
2097 return 0;
2098 }
2099 } while ((frame += 1) < oxu->periodic_size);
2100
2101 /* just check the specified uframe, at that period */
2102 } else {
2103 do {
2104 claimed = periodic_usecs(oxu, frame, uframe);
2105 if (claimed > usecs)
2106 return 0;
2107 } while ((frame += period) < oxu->periodic_size);
2108 }
2109
2110 return 1;
2111}
2112
2113static int check_intr_schedule(struct oxu_hcd *oxu,
2114 unsigned frame, unsigned uframe,
2115 const struct ehci_qh *qh, __le32 *c_maskp)
2116{
2117 int retval = -ENOSPC;
2118
2119 if (qh->c_usecs && uframe >= 6) /* FSTN territory? */
2120 goto done;
2121
2122 if (!check_period(oxu, frame, uframe, qh->period, qh->usecs))
2123 goto done;
2124 if (!qh->c_usecs) {
2125 retval = 0;
2126 *c_maskp = 0;
2127 goto done;
2128 }
2129
2130done:
2131 return retval;
2132}
2133
2134/* "first fit" scheduling policy used the first time through,
2135 * or when the previous schedule slot can't be re-used.
2136 */
2137static int qh_schedule(struct oxu_hcd *oxu, struct ehci_qh *qh)
2138{
2139 int status;
2140 unsigned uframe;
2141 __le32 c_mask;
2142 unsigned frame; /* 0..(qh->period - 1), or NO_FRAME */
2143
2144 qh_refresh(oxu, qh);
2145 qh->hw_next = EHCI_LIST_END;
2146 frame = qh->start;
2147
2148 /* reuse the previous schedule slots, if we can */
2149 if (frame < qh->period) {
2150 uframe = ffs(le32_to_cpup(&qh->hw_info2) & QH_SMASK);
2151 status = check_intr_schedule(oxu, frame, --uframe,
2152 qh, &c_mask);
2153 } else {
2154 uframe = 0;
2155 c_mask = 0;
2156 status = -ENOSPC;
2157 }
2158
2159 /* else scan the schedule to find a group of slots such that all
2160 * uframes have enough periodic bandwidth available.
2161 */
2162 if (status) {
2163 /* "normal" case, uframing flexible except with splits */
2164 if (qh->period) {
2165 frame = qh->period - 1;
2166 do {
2167 for (uframe = 0; uframe < 8; uframe++) {
2168 status = check_intr_schedule(oxu,
2169 frame, uframe, qh,
2170 &c_mask);
2171 if (status == 0)
2172 break;
2173 }
2174 } while (status && frame--);
2175
2176 /* qh->period == 0 means every uframe */
2177 } else {
2178 frame = 0;
2179 status = check_intr_schedule(oxu, 0, 0, qh, &c_mask);
2180 }
2181 if (status)
2182 goto done;
2183 qh->start = frame;
2184
2185 /* reset S-frame and (maybe) C-frame masks */
2186 qh->hw_info2 &= __constant_cpu_to_le32(~(QH_CMASK | QH_SMASK));
2187 qh->hw_info2 |= qh->period
2188 ? cpu_to_le32(1 << uframe)
2189 : __constant_cpu_to_le32(QH_SMASK);
2190 qh->hw_info2 |= c_mask;
2191 } else
2192 oxu_dbg(oxu, "reused qh %p schedule\n", qh);
2193
2194 /* stuff into the periodic schedule */
2195 status = qh_link_periodic(oxu, qh);
2196done:
2197 return status;
2198}
2199
2200static int intr_submit(struct oxu_hcd *oxu, struct urb *urb,
2201 struct list_head *qtd_list, gfp_t mem_flags)
2202{
2203 unsigned epnum;
2204 unsigned long flags;
2205 struct ehci_qh *qh;
2206 int status = 0;
2207 struct list_head empty;
2208
2209 /* get endpoint and transfer/schedule data */
2210 epnum = urb->ep->desc.bEndpointAddress;
2211
2212 spin_lock_irqsave(&oxu->lock, flags);
2213
2214 if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE,
2215 &oxu_to_hcd(oxu)->flags))) {
2216 status = -ESHUTDOWN;
2217 goto done;
2218 }
2219
2220 /* get qh and force any scheduling errors */
2221 INIT_LIST_HEAD(&empty);
2222 qh = qh_append_tds(oxu, urb, &empty, epnum, &urb->ep->hcpriv);
2223 if (qh == NULL) {
2224 status = -ENOMEM;
2225 goto done;
2226 }
2227 if (qh->qh_state == QH_STATE_IDLE) {
2228 status = qh_schedule(oxu, qh);
2229 if (status != 0)
2230 goto done;
2231 }
2232
2233 /* then queue the urb's tds to the qh */
2234 qh = qh_append_tds(oxu, urb, qtd_list, epnum, &urb->ep->hcpriv);
2235 BUG_ON(qh == NULL);
2236
2237 /* ... update usbfs periodic stats */
2238 oxu_to_hcd(oxu)->self.bandwidth_int_reqs++;
2239
2240done:
2241 spin_unlock_irqrestore(&oxu->lock, flags);
2242 if (status)
2243 qtd_list_free(oxu, urb, qtd_list);
2244
2245 return status;
2246}
2247
2248static inline int itd_submit(struct oxu_hcd *oxu, struct urb *urb,
2249 gfp_t mem_flags)
2250{
2251 oxu_dbg(oxu, "iso support is missing!\n");
2252 return -ENOSYS;
2253}
2254
2255static inline int sitd_submit(struct oxu_hcd *oxu, struct urb *urb,
2256 gfp_t mem_flags)
2257{
2258 oxu_dbg(oxu, "split iso support is missing!\n");
2259 return -ENOSYS;
2260}
2261
2262static void scan_periodic(struct oxu_hcd *oxu)
2263{
2264 unsigned frame, clock, now_uframe, mod;
2265 unsigned modified;
2266
2267 mod = oxu->periodic_size << 3;
2268
2269 /*
2270 * When running, scan from last scan point up to "now"
2271 * else clean up by scanning everything that's left.
2272 * Touches as few pages as possible: cache-friendly.
2273 */
2274 now_uframe = oxu->next_uframe;
2275 if (HC_IS_RUNNING(oxu_to_hcd(oxu)->state))
2276 clock = readl(&oxu->regs->frame_index);
2277 else
2278 clock = now_uframe + mod - 1;
2279 clock %= mod;
2280
2281 for (;;) {
2282 union ehci_shadow q, *q_p;
2283 __le32 type, *hw_p;
2284 unsigned uframes;
2285
2286 /* don't scan past the live uframe */
2287 frame = now_uframe >> 3;
2288 if (frame == (clock >> 3))
2289 uframes = now_uframe & 0x07;
2290 else {
2291 /* safe to scan the whole frame at once */
2292 now_uframe |= 0x07;
2293 uframes = 8;
2294 }
2295
2296restart:
2297 /* scan each element in frame's queue for completions */
2298 q_p = &oxu->pshadow[frame];
2299 hw_p = &oxu->periodic[frame];
2300 q.ptr = q_p->ptr;
2301 type = Q_NEXT_TYPE(*hw_p);
2302 modified = 0;
2303
2304 while (q.ptr != NULL) {
2305 union ehci_shadow temp;
2306 int live;
2307
2308 live = HC_IS_RUNNING(oxu_to_hcd(oxu)->state);
2309 switch (type) {
2310 case Q_TYPE_QH:
2311 /* handle any completions */
2312 temp.qh = qh_get(q.qh);
2313 type = Q_NEXT_TYPE(q.qh->hw_next);
2314 q = q.qh->qh_next;
2315 modified = qh_completions(oxu, temp.qh);
2316 if (unlikely(list_empty(&temp.qh->qtd_list)))
2317 intr_deschedule(oxu, temp.qh);
2318 qh_put(temp.qh);
2319 break;
2320 default:
2321 dbg("corrupt type %d frame %d shadow %p",
2322 type, frame, q.ptr);
2323 q.ptr = NULL;
2324 }
2325
2326 /* assume completion callbacks modify the queue */
2327 if (unlikely(modified))
2328 goto restart;
2329 }
2330
2331 /* Stop when we catch up to the HC */
2332
2333 /* FIXME: this assumes we won't get lapped when
2334 * latencies climb; that should be rare, but...
2335 * detect it, and just go all the way around.
2336 * FLR might help detect this case, so long as latencies
2337 * don't exceed periodic_size msec (default 1.024 sec).
2338 */
2339
2340 /* FIXME: likewise assumes HC doesn't halt mid-scan */
2341
2342 if (now_uframe == clock) {
2343 unsigned now;
2344
2345 if (!HC_IS_RUNNING(oxu_to_hcd(oxu)->state))
2346 break;
2347 oxu->next_uframe = now_uframe;
2348 now = readl(&oxu->regs->frame_index) % mod;
2349 if (now_uframe == now)
2350 break;
2351
2352 /* rescan the rest of this frame, then ... */
2353 clock = now;
2354 } else {
2355 now_uframe++;
2356 now_uframe %= mod;
2357 }
2358 }
2359}
2360
2361/* On some systems, leaving remote wakeup enabled prevents system shutdown.
2362 * The firmware seems to think that powering off is a wakeup event!
2363 * This routine turns off remote wakeup and everything else, on all ports.
2364 */
2365static void ehci_turn_off_all_ports(struct oxu_hcd *oxu)
2366{
2367 int port = HCS_N_PORTS(oxu->hcs_params);
2368
2369 while (port--)
2370 writel(PORT_RWC_BITS, &oxu->regs->port_status[port]);
2371}
2372
2373static void ehci_port_power(struct oxu_hcd *oxu, int is_on)
2374{
2375 unsigned port;
2376
2377 if (!HCS_PPC(oxu->hcs_params))
2378 return;
2379
2380 oxu_dbg(oxu, "...power%s ports...\n", is_on ? "up" : "down");
2381 for (port = HCS_N_PORTS(oxu->hcs_params); port > 0; )
2382 (void) oxu_hub_control(oxu_to_hcd(oxu),
2383 is_on ? SetPortFeature : ClearPortFeature,
2384 USB_PORT_FEAT_POWER,
2385 port--, NULL, 0);
2386 msleep(20);
2387}
2388
2389/* Called from some interrupts, timers, and so on.
2390 * It calls driver completion functions, after dropping oxu->lock.
2391 */
2392static void ehci_work(struct oxu_hcd *oxu)
2393{
2394 timer_action_done(oxu, TIMER_IO_WATCHDOG);
2395 if (oxu->reclaim_ready)
2396 end_unlink_async(oxu);
2397
2398 /* another CPU may drop oxu->lock during a schedule scan while
2399 * it reports urb completions. this flag guards against bogus
2400 * attempts at re-entrant schedule scanning.
2401 */
2402 if (oxu->scanning)
2403 return;
2404 oxu->scanning = 1;
2405 scan_async(oxu);
2406 if (oxu->next_uframe != -1)
2407 scan_periodic(oxu);
2408 oxu->scanning = 0;
2409
2410 /* the IO watchdog guards against hardware or driver bugs that
2411 * misplace IRQs, and should let us run completely without IRQs.
2412 * such lossage has been observed on both VT6202 and VT8235.
2413 */
2414 if (HC_IS_RUNNING(oxu_to_hcd(oxu)->state) &&
2415 (oxu->async->qh_next.ptr != NULL ||
2416 oxu->periodic_sched != 0))
2417 timer_action(oxu, TIMER_IO_WATCHDOG);
2418}
2419
2420static void unlink_async(struct oxu_hcd *oxu, struct ehci_qh *qh)
2421{
2422 /* if we need to use IAA and it's busy, defer */
2423 if (qh->qh_state == QH_STATE_LINKED
2424 && oxu->reclaim
2425 && HC_IS_RUNNING(oxu_to_hcd(oxu)->state)) {
2426 struct ehci_qh *last;
2427
2428 for (last = oxu->reclaim;
2429 last->reclaim;
2430 last = last->reclaim)
2431 continue;
2432 qh->qh_state = QH_STATE_UNLINK_WAIT;
2433 last->reclaim = qh;
2434
2435 /* bypass IAA if the hc can't care */
2436 } else if (!HC_IS_RUNNING(oxu_to_hcd(oxu)->state) && oxu->reclaim)
2437 end_unlink_async(oxu);
2438
2439 /* something else might have unlinked the qh by now */
2440 if (qh->qh_state == QH_STATE_LINKED)
2441 start_unlink_async(oxu, qh);
2442}
2443
2444/*
2445 * USB host controller methods
2446 */
2447
2448static irqreturn_t oxu210_hcd_irq(struct usb_hcd *hcd)
2449{
2450 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
2451 u32 status, pcd_status = 0;
2452 int bh;
2453
2454 spin_lock(&oxu->lock);
2455
2456 status = readl(&oxu->regs->status);
2457
2458 /* e.g. cardbus physical eject */
2459 if (status == ~(u32) 0) {
2460 oxu_dbg(oxu, "device removed\n");
2461 goto dead;
2462 }
2463
2464 status &= INTR_MASK;
2465 if (!status) { /* irq sharing? */
2466 spin_unlock(&oxu->lock);
2467 return IRQ_NONE;
2468 }
2469
2470 /* clear (just) interrupts */
2471 writel(status, &oxu->regs->status);
2472 readl(&oxu->regs->command); /* unblock posted write */
2473 bh = 0;
2474
2475#ifdef OXU_VERBOSE_DEBUG
2476 /* unrequested/ignored: Frame List Rollover */
2477 dbg_status(oxu, "irq", status);
2478#endif
2479
2480 /* INT, ERR, and IAA interrupt rates can be throttled */
2481
2482 /* normal [4.15.1.2] or error [4.15.1.1] completion */
2483 if (likely((status & (STS_INT|STS_ERR)) != 0))
2484 bh = 1;
2485
2486 /* complete the unlinking of some qh [4.15.2.3] */
2487 if (status & STS_IAA) {
2488 oxu->reclaim_ready = 1;
2489 bh = 1;
2490 }
2491
2492 /* remote wakeup [4.3.1] */
2493 if (status & STS_PCD) {
2494 unsigned i = HCS_N_PORTS(oxu->hcs_params);
2495 pcd_status = status;
2496
2497 /* resume root hub? */
2498 if (!(readl(&oxu->regs->command) & CMD_RUN))
2499 usb_hcd_resume_root_hub(hcd);
2500
2501 while (i--) {
2502 int pstatus = readl(&oxu->regs->port_status[i]);
2503
2504 if (pstatus & PORT_OWNER)
2505 continue;
2506 if (!(pstatus & PORT_RESUME)
2507 || oxu->reset_done[i] != 0)
2508 continue;
2509
2510 /* start 20 msec resume signaling from this port,
2511 * and make khubd collect PORT_STAT_C_SUSPEND to
2512 * stop that signaling.
2513 */
2514 oxu->reset_done[i] = jiffies + msecs_to_jiffies(20);
2515 oxu_dbg(oxu, "port %d remote wakeup\n", i + 1);
2516 mod_timer(&hcd->rh_timer, oxu->reset_done[i]);
2517 }
2518 }
2519
2520 /* PCI errors [4.15.2.4] */
2521 if (unlikely((status & STS_FATAL) != 0)) {
2522 /* bogus "fatal" IRQs appear on some chips... why? */
2523 status = readl(&oxu->regs->status);
2524 dbg_cmd(oxu, "fatal", readl(&oxu->regs->command));
2525 dbg_status(oxu, "fatal", status);
2526 if (status & STS_HALT) {
2527 oxu_err(oxu, "fatal error\n");
2528dead:
2529 ehci_reset(oxu);
2530 writel(0, &oxu->regs->configured_flag);
2531 /* generic layer kills/unlinks all urbs, then
2532 * uses oxu_stop to clean up the rest
2533 */
2534 bh = 1;
2535 }
2536 }
2537
2538 if (bh)
2539 ehci_work(oxu);
2540 spin_unlock(&oxu->lock);
2541 if (pcd_status & STS_PCD)
2542 usb_hcd_poll_rh_status(hcd);
2543 return IRQ_HANDLED;
2544}
2545
2546static irqreturn_t oxu_irq(struct usb_hcd *hcd)
2547{
2548 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
2549 int ret = IRQ_HANDLED;
2550
2551 u32 status = oxu_readl(hcd->regs, OXU_CHIPIRQSTATUS);
2552 u32 enable = oxu_readl(hcd->regs, OXU_CHIPIRQEN_SET);
2553
2554 /* Disable all interrupt */
2555 oxu_writel(hcd->regs, OXU_CHIPIRQEN_CLR, enable);
2556
2557 if ((oxu->is_otg && (status & OXU_USBOTGI)) ||
2558 (!oxu->is_otg && (status & OXU_USBSPHI)))
2559 oxu210_hcd_irq(hcd);
2560 else
2561 ret = IRQ_NONE;
2562
2563 /* Enable all interrupt back */
2564 oxu_writel(hcd->regs, OXU_CHIPIRQEN_SET, enable);
2565
2566 return ret;
2567}
2568
2569static void oxu_watchdog(unsigned long param)
2570{
2571 struct oxu_hcd *oxu = (struct oxu_hcd *) param;
2572 unsigned long flags;
2573
2574 spin_lock_irqsave(&oxu->lock, flags);
2575
2576 /* lost IAA irqs wedge things badly; seen with a vt8235 */
2577 if (oxu->reclaim) {
2578 u32 status = readl(&oxu->regs->status);
2579 if (status & STS_IAA) {
2580 oxu_vdbg(oxu, "lost IAA\n");
2581 writel(STS_IAA, &oxu->regs->status);
2582 oxu->reclaim_ready = 1;
2583 }
2584 }
2585
2586 /* stop async processing after it's idled a bit */
2587 if (test_bit(TIMER_ASYNC_OFF, &oxu->actions))
2588 start_unlink_async(oxu, oxu->async);
2589
2590 /* oxu could run by timer, without IRQs ... */
2591 ehci_work(oxu);
2592
2593 spin_unlock_irqrestore(&oxu->lock, flags);
2594}
2595
2596/* One-time init, only for memory state.
2597 */
2598static int oxu_hcd_init(struct usb_hcd *hcd)
2599{
2600 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
2601 u32 temp;
2602 int retval;
2603 u32 hcc_params;
2604
2605 spin_lock_init(&oxu->lock);
2606
2607 init_timer(&oxu->watchdog);
2608 oxu->watchdog.function = oxu_watchdog;
2609 oxu->watchdog.data = (unsigned long) oxu;
2610
2611 /*
2612 * hw default: 1K periodic list heads, one per frame.
2613 * periodic_size can shrink by USBCMD update if hcc_params allows.
2614 */
2615 oxu->periodic_size = DEFAULT_I_TDPS;
2616 retval = ehci_mem_init(oxu, GFP_KERNEL);
2617 if (retval < 0)
2618 return retval;
2619
2620 /* controllers may cache some of the periodic schedule ... */
2621 hcc_params = readl(&oxu->caps->hcc_params);
2622 if (HCC_ISOC_CACHE(hcc_params)) /* full frame cache */
2623 oxu->i_thresh = 8;
2624 else /* N microframes cached */
2625 oxu->i_thresh = 2 + HCC_ISOC_THRES(hcc_params);
2626
2627 oxu->reclaim = NULL;
2628 oxu->reclaim_ready = 0;
2629 oxu->next_uframe = -1;
2630
2631 /*
2632 * dedicate a qh for the async ring head, since we couldn't unlink
2633 * a 'real' qh without stopping the async schedule [4.8]. use it
2634 * as the 'reclamation list head' too.
2635 * its dummy is used in hw_alt_next of many tds, to prevent the qh
2636 * from automatically advancing to the next td after short reads.
2637 */
2638 oxu->async->qh_next.qh = NULL;
2639 oxu->async->hw_next = QH_NEXT(oxu->async->qh_dma);
2640 oxu->async->hw_info1 = cpu_to_le32(QH_HEAD);
2641 oxu->async->hw_token = cpu_to_le32(QTD_STS_HALT);
2642 oxu->async->hw_qtd_next = EHCI_LIST_END;
2643 oxu->async->qh_state = QH_STATE_LINKED;
2644 oxu->async->hw_alt_next = QTD_NEXT(oxu->async->dummy->qtd_dma);
2645
2646 /* clear interrupt enables, set irq latency */
2647 if (log2_irq_thresh < 0 || log2_irq_thresh > 6)
2648 log2_irq_thresh = 0;
2649 temp = 1 << (16 + log2_irq_thresh);
2650 if (HCC_CANPARK(hcc_params)) {
2651 /* HW default park == 3, on hardware that supports it (like
2652 * NVidia and ALI silicon), maximizes throughput on the async
2653 * schedule by avoiding QH fetches between transfers.
2654 *
2655 * With fast usb storage devices and NForce2, "park" seems to
2656 * make problems: throughput reduction (!), data errors...
2657 */
2658 if (park) {
2659 park = min(park, (unsigned) 3);
2660 temp |= CMD_PARK;
2661 temp |= park << 8;
2662 }
2663 oxu_dbg(oxu, "park %d\n", park);
2664 }
2665 if (HCC_PGM_FRAMELISTLEN(hcc_params)) {
2666 /* periodic schedule size can be smaller than default */
2667 temp &= ~(3 << 2);
2668 temp |= (EHCI_TUNE_FLS << 2);
2669 }
2670 oxu->command = temp;
2671
2672 return 0;
2673}
2674
2675/* Called during probe() after chip reset completes.
2676 */
2677static int oxu_reset(struct usb_hcd *hcd)
2678{
2679 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
2680 int ret;
2681
2682 spin_lock_init(&oxu->mem_lock);
2683 INIT_LIST_HEAD(&oxu->urb_list);
2684 oxu->urb_len = 0;
2685
2686 /* FIMXE */
2687 hcd->self.controller->dma_mask = 0UL;
2688
2689 if (oxu->is_otg) {
2690 oxu->caps = hcd->regs + OXU_OTG_CAP_OFFSET;
2691 oxu->regs = hcd->regs + OXU_OTG_CAP_OFFSET + \
2692 HC_LENGTH(readl(&oxu->caps->hc_capbase));
2693
2694 oxu->mem = hcd->regs + OXU_SPH_MEM;
2695 } else {
2696 oxu->caps = hcd->regs + OXU_SPH_CAP_OFFSET;
2697 oxu->regs = hcd->regs + OXU_SPH_CAP_OFFSET + \
2698 HC_LENGTH(readl(&oxu->caps->hc_capbase));
2699
2700 oxu->mem = hcd->regs + OXU_OTG_MEM;
2701 }
2702
2703 oxu->hcs_params = readl(&oxu->caps->hcs_params);
2704 oxu->sbrn = 0x20;
2705
2706 ret = oxu_hcd_init(hcd);
2707 if (ret)
2708 return ret;
2709
2710 return 0;
2711}
2712
2713static int oxu_run(struct usb_hcd *hcd)
2714{
2715 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
2716 int retval;
2717 u32 temp, hcc_params;
2718
2719 hcd->uses_new_polling = 1;
2720 hcd->poll_rh = 0;
2721
2722 /* EHCI spec section 4.1 */
2723 retval = ehci_reset(oxu);
2724 if (retval != 0) {
2725 ehci_mem_cleanup(oxu);
2726 return retval;
2727 }
2728 writel(oxu->periodic_dma, &oxu->regs->frame_list);
2729 writel((u32) oxu->async->qh_dma, &oxu->regs->async_next);
2730
2731 /* hcc_params controls whether oxu->regs->segment must (!!!)
2732 * be used; it constrains QH/ITD/SITD and QTD locations.
2733 * pci_pool consistent memory always uses segment zero.
2734 * streaming mappings for I/O buffers, like pci_map_single(),
2735 * can return segments above 4GB, if the device allows.
2736 *
2737 * NOTE: the dma mask is visible through dma_supported(), so
2738 * drivers can pass this info along ... like NETIF_F_HIGHDMA,
2739 * Scsi_Host.highmem_io, and so forth. It's readonly to all
2740 * host side drivers though.
2741 */
2742 hcc_params = readl(&oxu->caps->hcc_params);
2743 if (HCC_64BIT_ADDR(hcc_params))
2744 writel(0, &oxu->regs->segment);
2745
2746 oxu->command &= ~(CMD_LRESET | CMD_IAAD | CMD_PSE |
2747 CMD_ASE | CMD_RESET);
2748 oxu->command |= CMD_RUN;
2749 writel(oxu->command, &oxu->regs->command);
2750 dbg_cmd(oxu, "init", oxu->command);
2751
2752 /*
2753 * Start, enabling full USB 2.0 functionality ... usb 1.1 devices
2754 * are explicitly handed to companion controller(s), so no TT is
2755 * involved with the root hub. (Except where one is integrated,
2756 * and there's no companion controller unless maybe for USB OTG.)
2757 */
2758 hcd->state = HC_STATE_RUNNING;
2759 writel(FLAG_CF, &oxu->regs->configured_flag);
2760 readl(&oxu->regs->command); /* unblock posted writes */
2761
2762 temp = HC_VERSION(readl(&oxu->caps->hc_capbase));
2763 oxu_info(oxu, "USB %x.%x started, quasi-EHCI %x.%02x, driver %s%s\n",
2764 ((oxu->sbrn & 0xf0)>>4), (oxu->sbrn & 0x0f),
2765 temp >> 8, temp & 0xff, DRIVER_VERSION,
2766 ignore_oc ? ", overcurrent ignored" : "");
2767
2768 writel(INTR_MASK, &oxu->regs->intr_enable); /* Turn On Interrupts */
2769
2770 return 0;
2771}
2772
2773static void oxu_stop(struct usb_hcd *hcd)
2774{
2775 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
2776
2777 /* Turn off port power on all root hub ports. */
2778 ehci_port_power(oxu, 0);
2779
2780 /* no more interrupts ... */
2781 del_timer_sync(&oxu->watchdog);
2782
2783 spin_lock_irq(&oxu->lock);
2784 if (HC_IS_RUNNING(hcd->state))
2785 ehci_quiesce(oxu);
2786
2787 ehci_reset(oxu);
2788 writel(0, &oxu->regs->intr_enable);
2789 spin_unlock_irq(&oxu->lock);
2790
2791 /* let companion controllers work when we aren't */
2792 writel(0, &oxu->regs->configured_flag);
2793
2794 /* root hub is shut down separately (first, when possible) */
2795 spin_lock_irq(&oxu->lock);
2796 if (oxu->async)
2797 ehci_work(oxu);
2798 spin_unlock_irq(&oxu->lock);
2799 ehci_mem_cleanup(oxu);
2800
2801 dbg_status(oxu, "oxu_stop completed", readl(&oxu->regs->status));
2802}
2803
2804/* Kick in for silicon on any bus (not just pci, etc).
2805 * This forcibly disables dma and IRQs, helping kexec and other cases
2806 * where the next system software may expect clean state.
2807 */
2808static void oxu_shutdown(struct usb_hcd *hcd)
2809{
2810 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
2811
2812 (void) ehci_halt(oxu);
2813 ehci_turn_off_all_ports(oxu);
2814
2815 /* make BIOS/etc use companion controller during reboot */
2816 writel(0, &oxu->regs->configured_flag);
2817
2818 /* unblock posted writes */
2819 readl(&oxu->regs->configured_flag);
2820}
2821
2822/* Non-error returns are a promise to giveback() the urb later
2823 * we drop ownership so next owner (or urb unlink) can get it
2824 *
2825 * urb + dev is in hcd.self.controller.urb_list
2826 * we're queueing TDs onto software and hardware lists
2827 *
2828 * hcd-specific init for hcpriv hasn't been done yet
2829 *
2830 * NOTE: control, bulk, and interrupt share the same code to append TDs
2831 * to a (possibly active) QH, and the same QH scanning code.
2832 */
2833static int __oxu_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
2834 gfp_t mem_flags)
2835{
2836 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
2837 struct list_head qtd_list;
2838
2839 INIT_LIST_HEAD(&qtd_list);
2840
2841 switch (usb_pipetype(urb->pipe)) {
2842 case PIPE_CONTROL:
2843 case PIPE_BULK:
2844 default:
2845 if (!qh_urb_transaction(oxu, urb, &qtd_list, mem_flags))
2846 return -ENOMEM;
2847 return submit_async(oxu, urb, &qtd_list, mem_flags);
2848
2849 case PIPE_INTERRUPT:
2850 if (!qh_urb_transaction(oxu, urb, &qtd_list, mem_flags))
2851 return -ENOMEM;
2852 return intr_submit(oxu, urb, &qtd_list, mem_flags);
2853
2854 case PIPE_ISOCHRONOUS:
2855 if (urb->dev->speed == USB_SPEED_HIGH)
2856 return itd_submit(oxu, urb, mem_flags);
2857 else
2858 return sitd_submit(oxu, urb, mem_flags);
2859 }
2860}
2861
2862/* This function is responsible for breaking URBs with big data size
2863 * into smaller size and processing small urbs in sequence.
2864 */
2865static int oxu_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
2866 gfp_t mem_flags)
2867{
2868 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
2869 int num, rem;
2870 int transfer_buffer_length;
2871 void *transfer_buffer;
2872 struct urb *murb;
2873 int i, ret;
2874
2875 /* If not bulk pipe just enqueue the URB */
2876 if (!usb_pipebulk(urb->pipe))
2877 return __oxu_urb_enqueue(hcd, urb, mem_flags);
2878
2879 /* Otherwise we should verify the USB transfer buffer size! */
2880 transfer_buffer = urb->transfer_buffer;
2881 transfer_buffer_length = urb->transfer_buffer_length;
2882
2883 num = urb->transfer_buffer_length / 4096;
2884 rem = urb->transfer_buffer_length % 4096;
2885 if (rem != 0)
2886 num++;
2887
2888 /* If URB is smaller than 4096 bytes just enqueue it! */
2889 if (num == 1)
2890 return __oxu_urb_enqueue(hcd, urb, mem_flags);
2891
2892 /* Ok, we have more job to do! :) */
2893
2894 for (i = 0; i < num - 1; i++) {
2895 /* Get free micro URB poll till a free urb is recieved */
2896
2897 do {
2898 murb = (struct urb *) oxu_murb_alloc(oxu);
2899 if (!murb)
2900 schedule();
2901 } while (!murb);
2902
2903 /* Coping the urb */
2904 memcpy(murb, urb, sizeof(struct urb));
2905
2906 murb->transfer_buffer_length = 4096;
2907 murb->transfer_buffer = transfer_buffer + i * 4096;
2908
2909 /* Null pointer for the encodes that this is a micro urb */
2910 murb->complete = NULL;
2911
2912 ((struct oxu_murb *) murb)->main = urb;
2913 ((struct oxu_murb *) murb)->last = 0;
2914
2915 /* This loop is to guarantee urb to be processed when there's
2916 * not enough resources at a particular time by retrying.
2917 */
2918 do {
2919 ret = __oxu_urb_enqueue(hcd, murb, mem_flags);
2920 if (ret)
2921 schedule();
2922 } while (ret);
2923 }
2924
2925 /* Last urb requires special handling */
2926
2927 /* Get free micro URB poll till a free urb is recieved */
2928 do {
2929 murb = (struct urb *) oxu_murb_alloc(oxu);
2930 if (!murb)
2931 schedule();
2932 } while (!murb);
2933
2934 /* Coping the urb */
2935 memcpy(murb, urb, sizeof(struct urb));
2936
2937 murb->transfer_buffer_length = rem > 0 ? rem : 4096;
2938 murb->transfer_buffer = transfer_buffer + (num - 1) * 4096;
2939
2940 /* Null pointer for the encodes that this is a micro urb */
2941 murb->complete = NULL;
2942
2943 ((struct oxu_murb *) murb)->main = urb;
2944 ((struct oxu_murb *) murb)->last = 1;
2945
2946 do {
2947 ret = __oxu_urb_enqueue(hcd, murb, mem_flags);
2948 if (ret)
2949 schedule();
2950 } while (ret);
2951
2952 return ret;
2953}
2954
2955/* Remove from hardware lists.
2956 * Completions normally happen asynchronously
2957 */
2958static int oxu_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
2959{
2960 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
2961 struct ehci_qh *qh;
2962 unsigned long flags;
2963
2964 spin_lock_irqsave(&oxu->lock, flags);
2965 switch (usb_pipetype(urb->pipe)) {
2966 case PIPE_CONTROL:
2967 case PIPE_BULK:
2968 default:
2969 qh = (struct ehci_qh *) urb->hcpriv;
2970 if (!qh)
2971 break;
2972 unlink_async(oxu, qh);
2973 break;
2974
2975 case PIPE_INTERRUPT:
2976 qh = (struct ehci_qh *) urb->hcpriv;
2977 if (!qh)
2978 break;
2979 switch (qh->qh_state) {
2980 case QH_STATE_LINKED:
2981 intr_deschedule(oxu, qh);
2982 /* FALL THROUGH */
2983 case QH_STATE_IDLE:
2984 qh_completions(oxu, qh);
2985 break;
2986 default:
2987 oxu_dbg(oxu, "bogus qh %p state %d\n",
2988 qh, qh->qh_state);
2989 goto done;
2990 }
2991
2992 /* reschedule QH iff another request is queued */
2993 if (!list_empty(&qh->qtd_list)
2994 && HC_IS_RUNNING(hcd->state)) {
2995 int status;
2996
2997 status = qh_schedule(oxu, qh);
2998 spin_unlock_irqrestore(&oxu->lock, flags);
2999
3000 if (status != 0) {
3001 /* shouldn't happen often, but ...
3002 * FIXME kill those tds' urbs
3003 */
3004 err("can't reschedule qh %p, err %d",
3005 qh, status);
3006 }
3007 return status;
3008 }
3009 break;
3010 }
3011done:
3012 spin_unlock_irqrestore(&oxu->lock, flags);
3013 return 0;
3014}
3015
3016/* Bulk qh holds the data toggle */
3017static void oxu_endpoint_disable(struct usb_hcd *hcd,
3018 struct usb_host_endpoint *ep)
3019{
3020 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
3021 unsigned long flags;
3022 struct ehci_qh *qh, *tmp;
3023
3024 /* ASSERT: any requests/urbs are being unlinked */
3025 /* ASSERT: nobody can be submitting urbs for this any more */
3026
3027rescan:
3028 spin_lock_irqsave(&oxu->lock, flags);
3029 qh = ep->hcpriv;
3030 if (!qh)
3031 goto done;
3032
3033 /* endpoints can be iso streams. for now, we don't
3034 * accelerate iso completions ... so spin a while.
3035 */
3036 if (qh->hw_info1 == 0) {
3037 oxu_vdbg(oxu, "iso delay\n");
3038 goto idle_timeout;
3039 }
3040
3041 if (!HC_IS_RUNNING(hcd->state))
3042 qh->qh_state = QH_STATE_IDLE;
3043 switch (qh->qh_state) {
3044 case QH_STATE_LINKED:
3045 for (tmp = oxu->async->qh_next.qh;
3046 tmp && tmp != qh;
3047 tmp = tmp->qh_next.qh)
3048 continue;
3049 /* periodic qh self-unlinks on empty */
3050 if (!tmp)
3051 goto nogood;
3052 unlink_async(oxu, qh);
3053 /* FALL THROUGH */
3054 case QH_STATE_UNLINK: /* wait for hw to finish? */
3055idle_timeout:
3056 spin_unlock_irqrestore(&oxu->lock, flags);
3057 schedule_timeout_uninterruptible(1);
3058 goto rescan;
3059 case QH_STATE_IDLE: /* fully unlinked */
3060 if (list_empty(&qh->qtd_list)) {
3061 qh_put(qh);
3062 break;
3063 }
3064 /* else FALL THROUGH */
3065 default:
3066nogood:
3067 /* caller was supposed to have unlinked any requests;
3068 * that's not our job. just leak this memory.
3069 */
3070 oxu_err(oxu, "qh %p (#%02x) state %d%s\n",
3071 qh, ep->desc.bEndpointAddress, qh->qh_state,
3072 list_empty(&qh->qtd_list) ? "" : "(has tds)");
3073 break;
3074 }
3075 ep->hcpriv = NULL;
3076done:
3077 spin_unlock_irqrestore(&oxu->lock, flags);
3078 return;
3079}
3080
3081static int oxu_get_frame(struct usb_hcd *hcd)
3082{
3083 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
3084
3085 return (readl(&oxu->regs->frame_index) >> 3) %
3086 oxu->periodic_size;
3087}
3088
3089/* Build "status change" packet (one or two bytes) from HC registers */
3090static int oxu_hub_status_data(struct usb_hcd *hcd, char *buf)
3091{
3092 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
3093 u32 temp, mask, status = 0;
3094 int ports, i, retval = 1;
3095 unsigned long flags;
3096
3097 /* if !USB_SUSPEND, root hub timers won't get shut down ... */
3098 if (!HC_IS_RUNNING(hcd->state))
3099 return 0;
3100
3101 /* init status to no-changes */
3102 buf[0] = 0;
3103 ports = HCS_N_PORTS(oxu->hcs_params);
3104 if (ports > 7) {
3105 buf[1] = 0;
3106 retval++;
3107 }
3108
3109 /* Some boards (mostly VIA?) report bogus overcurrent indications,
3110 * causing massive log spam unless we completely ignore them. It
3111 * may be relevant that VIA VT8235 controlers, where PORT_POWER is
3112 * always set, seem to clear PORT_OCC and PORT_CSC when writing to
3113 * PORT_POWER; that's surprising, but maybe within-spec.
3114 */
3115 if (!ignore_oc)
3116 mask = PORT_CSC | PORT_PEC | PORT_OCC;
3117 else
3118 mask = PORT_CSC | PORT_PEC;
3119
3120 /* no hub change reports (bit 0) for now (power, ...) */
3121
3122 /* port N changes (bit N)? */
3123 spin_lock_irqsave(&oxu->lock, flags);
3124 for (i = 0; i < ports; i++) {
3125 temp = readl(&oxu->regs->port_status[i]);
3126
3127 /*
3128 * Return status information even for ports with OWNER set.
3129 * Otherwise khubd wouldn't see the disconnect event when a
3130 * high-speed device is switched over to the companion
3131 * controller by the user.
3132 */
3133
3134 if (!(temp & PORT_CONNECT))
3135 oxu->reset_done[i] = 0;
3136 if ((temp & mask) != 0 || ((temp & PORT_RESUME) != 0 &&
3137 time_after_eq(jiffies, oxu->reset_done[i]))) {
3138 if (i < 7)
3139 buf[0] |= 1 << (i + 1);
3140 else
3141 buf[1] |= 1 << (i - 7);
3142 status = STS_PCD;
3143 }
3144 }
3145 /* FIXME autosuspend idle root hubs */
3146 spin_unlock_irqrestore(&oxu->lock, flags);
3147 return status ? retval : 0;
3148}
3149
3150/* Returns the speed of a device attached to a port on the root hub. */
3151static inline unsigned int oxu_port_speed(struct oxu_hcd *oxu,
3152 unsigned int portsc)
3153{
3154 switch ((portsc >> 26) & 3) {
3155 case 0:
3156 return 0;
3157 case 1:
3158 return 1 << USB_PORT_FEAT_LOWSPEED;
3159 case 2:
3160 default:
3161 return 1 << USB_PORT_FEAT_HIGHSPEED;
3162 }
3163}
3164
3165#define PORT_WAKE_BITS (PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E)
3166static int oxu_hub_control(struct usb_hcd *hcd, u16 typeReq,
3167 u16 wValue, u16 wIndex, char *buf, u16 wLength)
3168{
3169 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
3170 int ports = HCS_N_PORTS(oxu->hcs_params);
3171 u32 __iomem *status_reg = &oxu->regs->port_status[wIndex - 1];
3172 u32 temp, status;
3173 unsigned long flags;
3174 int retval = 0;
3175 unsigned selector;
3176
3177 /*
3178 * FIXME: support SetPortFeatures USB_PORT_FEAT_INDICATOR.
3179 * HCS_INDICATOR may say we can change LEDs to off/amber/green.
3180 * (track current state ourselves) ... blink for diagnostics,
3181 * power, "this is the one", etc. EHCI spec supports this.
3182 */
3183
3184 spin_lock_irqsave(&oxu->lock, flags);
3185 switch (typeReq) {
3186 case ClearHubFeature:
3187 switch (wValue) {
3188 case C_HUB_LOCAL_POWER:
3189 case C_HUB_OVER_CURRENT:
3190 /* no hub-wide feature/status flags */
3191 break;
3192 default:
3193 goto error;
3194 }
3195 break;
3196 case ClearPortFeature:
3197 if (!wIndex || wIndex > ports)
3198 goto error;
3199 wIndex--;
3200 temp = readl(status_reg);
3201
3202 /*
3203 * Even if OWNER is set, so the port is owned by the
3204 * companion controller, khubd needs to be able to clear
3205 * the port-change status bits (especially
3206 * USB_PORT_FEAT_C_CONNECTION).
3207 */
3208
3209 switch (wValue) {
3210 case USB_PORT_FEAT_ENABLE:
3211 writel(temp & ~PORT_PE, status_reg);
3212 break;
3213 case USB_PORT_FEAT_C_ENABLE:
3214 writel((temp & ~PORT_RWC_BITS) | PORT_PEC, status_reg);
3215 break;
3216 case USB_PORT_FEAT_SUSPEND:
3217 if (temp & PORT_RESET)
3218 goto error;
3219 if (temp & PORT_SUSPEND) {
3220 if ((temp & PORT_PE) == 0)
3221 goto error;
3222 /* resume signaling for 20 msec */
3223 temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS);
3224 writel(temp | PORT_RESUME, status_reg);
3225 oxu->reset_done[wIndex] = jiffies
3226 + msecs_to_jiffies(20);
3227 }
3228 break;
3229 case USB_PORT_FEAT_C_SUSPEND:
3230 /* we auto-clear this feature */
3231 break;
3232 case USB_PORT_FEAT_POWER:
3233 if (HCS_PPC(oxu->hcs_params))
3234 writel(temp & ~(PORT_RWC_BITS | PORT_POWER),
3235 status_reg);
3236 break;
3237 case USB_PORT_FEAT_C_CONNECTION:
3238 writel((temp & ~PORT_RWC_BITS) | PORT_CSC, status_reg);
3239 break;
3240 case USB_PORT_FEAT_C_OVER_CURRENT:
3241 writel((temp & ~PORT_RWC_BITS) | PORT_OCC, status_reg);
3242 break;
3243 case USB_PORT_FEAT_C_RESET:
3244 /* GetPortStatus clears reset */
3245 break;
3246 default:
3247 goto error;
3248 }
3249 readl(&oxu->regs->command); /* unblock posted write */
3250 break;
3251 case GetHubDescriptor:
3252 ehci_hub_descriptor(oxu, (struct usb_hub_descriptor *)
3253 buf);
3254 break;
3255 case GetHubStatus:
3256 /* no hub-wide feature/status flags */
3257 memset(buf, 0, 4);
3258 break;
3259 case GetPortStatus:
3260 if (!wIndex || wIndex > ports)
3261 goto error;
3262 wIndex--;
3263 status = 0;
3264 temp = readl(status_reg);
3265
3266 /* wPortChange bits */
3267 if (temp & PORT_CSC)
3268 status |= 1 << USB_PORT_FEAT_C_CONNECTION;
3269 if (temp & PORT_PEC)
3270 status |= 1 << USB_PORT_FEAT_C_ENABLE;
3271 if ((temp & PORT_OCC) && !ignore_oc)
3272 status |= 1 << USB_PORT_FEAT_C_OVER_CURRENT;
3273
3274 /* whoever resumes must GetPortStatus to complete it!! */
3275 if (temp & PORT_RESUME) {
3276
3277 /* Remote Wakeup received? */
3278 if (!oxu->reset_done[wIndex]) {
3279 /* resume signaling for 20 msec */
3280 oxu->reset_done[wIndex] = jiffies
3281 + msecs_to_jiffies(20);
3282 /* check the port again */
3283 mod_timer(&oxu_to_hcd(oxu)->rh_timer,
3284 oxu->reset_done[wIndex]);
3285 }
3286
3287 /* resume completed? */
3288 else if (time_after_eq(jiffies,
3289 oxu->reset_done[wIndex])) {
3290 status |= 1 << USB_PORT_FEAT_C_SUSPEND;
3291 oxu->reset_done[wIndex] = 0;
3292
3293 /* stop resume signaling */
3294 temp = readl(status_reg);
3295 writel(temp & ~(PORT_RWC_BITS | PORT_RESUME),
3296 status_reg);
3297 retval = handshake(oxu, status_reg,
3298 PORT_RESUME, 0, 2000 /* 2msec */);
3299 if (retval != 0) {
3300 oxu_err(oxu,
3301 "port %d resume error %d\n",
3302 wIndex + 1, retval);
3303 goto error;
3304 }
3305 temp &= ~(PORT_SUSPEND|PORT_RESUME|(3<<10));
3306 }
3307 }
3308
3309 /* whoever resets must GetPortStatus to complete it!! */
3310 if ((temp & PORT_RESET)
3311 && time_after_eq(jiffies,
3312 oxu->reset_done[wIndex])) {
3313 status |= 1 << USB_PORT_FEAT_C_RESET;
3314 oxu->reset_done[wIndex] = 0;
3315
3316 /* force reset to complete */
3317 writel(temp & ~(PORT_RWC_BITS | PORT_RESET),
3318 status_reg);
3319 /* REVISIT: some hardware needs 550+ usec to clear
3320 * this bit; seems too long to spin routinely...
3321 */
3322 retval = handshake(oxu, status_reg,
3323 PORT_RESET, 0, 750);
3324 if (retval != 0) {
3325 oxu_err(oxu, "port %d reset error %d\n",
3326 wIndex + 1, retval);
3327 goto error;
3328 }
3329
3330 /* see what we found out */
3331 temp = check_reset_complete(oxu, wIndex, status_reg,
3332 readl(status_reg));
3333 }
3334
3335 /* transfer dedicated ports to the companion hc */
3336 if ((temp & PORT_CONNECT) &&
3337 test_bit(wIndex, &oxu->companion_ports)) {
3338 temp &= ~PORT_RWC_BITS;
3339 temp |= PORT_OWNER;
3340 writel(temp, status_reg);
3341 oxu_dbg(oxu, "port %d --> companion\n", wIndex + 1);
3342 temp = readl(status_reg);
3343 }
3344
3345 /*
3346 * Even if OWNER is set, there's no harm letting khubd
3347 * see the wPortStatus values (they should all be 0 except
3348 * for PORT_POWER anyway).
3349 */
3350
3351 if (temp & PORT_CONNECT) {
3352 status |= 1 << USB_PORT_FEAT_CONNECTION;
3353 /* status may be from integrated TT */
3354 status |= oxu_port_speed(oxu, temp);
3355 }
3356 if (temp & PORT_PE)
3357 status |= 1 << USB_PORT_FEAT_ENABLE;
3358 if (temp & (PORT_SUSPEND|PORT_RESUME))
3359 status |= 1 << USB_PORT_FEAT_SUSPEND;
3360 if (temp & PORT_OC)
3361 status |= 1 << USB_PORT_FEAT_OVER_CURRENT;
3362 if (temp & PORT_RESET)
3363 status |= 1 << USB_PORT_FEAT_RESET;
3364 if (temp & PORT_POWER)
3365 status |= 1 << USB_PORT_FEAT_POWER;
3366
3367#ifndef OXU_VERBOSE_DEBUG
3368 if (status & ~0xffff) /* only if wPortChange is interesting */
3369#endif
3370 dbg_port(oxu, "GetStatus", wIndex + 1, temp);
3371 put_unaligned(cpu_to_le32(status), (__le32 *) buf);
3372 break;
3373 case SetHubFeature:
3374 switch (wValue) {
3375 case C_HUB_LOCAL_POWER:
3376 case C_HUB_OVER_CURRENT:
3377 /* no hub-wide feature/status flags */
3378 break;
3379 default:
3380 goto error;
3381 }
3382 break;
3383 case SetPortFeature:
3384 selector = wIndex >> 8;
3385 wIndex &= 0xff;
3386 if (!wIndex || wIndex > ports)
3387 goto error;
3388 wIndex--;
3389 temp = readl(status_reg);
3390 if (temp & PORT_OWNER)
3391 break;
3392
3393 temp &= ~PORT_RWC_BITS;
3394 switch (wValue) {
3395 case USB_PORT_FEAT_SUSPEND:
3396 if ((temp & PORT_PE) == 0
3397 || (temp & PORT_RESET) != 0)
3398 goto error;
3399 if (device_may_wakeup(&hcd->self.root_hub->dev))
3400 temp |= PORT_WAKE_BITS;
3401 writel(temp | PORT_SUSPEND, status_reg);
3402 break;
3403 case USB_PORT_FEAT_POWER:
3404 if (HCS_PPC(oxu->hcs_params))
3405 writel(temp | PORT_POWER, status_reg);
3406 break;
3407 case USB_PORT_FEAT_RESET:
3408 if (temp & PORT_RESUME)
3409 goto error;
3410 /* line status bits may report this as low speed,
3411 * which can be fine if this root hub has a
3412 * transaction translator built in.
3413 */
3414 oxu_vdbg(oxu, "port %d reset\n", wIndex + 1);
3415 temp |= PORT_RESET;
3416 temp &= ~PORT_PE;
3417
3418 /*
3419 * caller must wait, then call GetPortStatus
3420 * usb 2.0 spec says 50 ms resets on root
3421 */
3422 oxu->reset_done[wIndex] = jiffies
3423 + msecs_to_jiffies(50);
3424 writel(temp, status_reg);
3425 break;
3426
3427 /* For downstream facing ports (these): one hub port is put
3428 * into test mode according to USB2 11.24.2.13, then the hub
3429 * must be reset (which for root hub now means rmmod+modprobe,
3430 * or else system reboot). See EHCI 2.3.9 and 4.14 for info
3431 * about the EHCI-specific stuff.
3432 */
3433 case USB_PORT_FEAT_TEST:
3434 if (!selector || selector > 5)
3435 goto error;
3436 ehci_quiesce(oxu);
3437 ehci_halt(oxu);
3438 temp |= selector << 16;
3439 writel(temp, status_reg);
3440 break;
3441
3442 default:
3443 goto error;
3444 }
3445 readl(&oxu->regs->command); /* unblock posted writes */
3446 break;
3447
3448 default:
3449error:
3450 /* "stall" on error */
3451 retval = -EPIPE;
3452 }
3453 spin_unlock_irqrestore(&oxu->lock, flags);
3454 return retval;
3455}
3456
3457#ifdef CONFIG_PM
3458
3459static int oxu_bus_suspend(struct usb_hcd *hcd)
3460{
3461 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
3462 int port;
3463 int mask;
3464
3465 oxu_dbg(oxu, "suspend root hub\n");
3466
3467 if (time_before(jiffies, oxu->next_statechange))
3468 msleep(5);
3469
3470 port = HCS_N_PORTS(oxu->hcs_params);
3471 spin_lock_irq(&oxu->lock);
3472
3473 /* stop schedules, clean any completed work */
3474 if (HC_IS_RUNNING(hcd->state)) {
3475 ehci_quiesce(oxu);
3476 hcd->state = HC_STATE_QUIESCING;
3477 }
3478 oxu->command = readl(&oxu->regs->command);
3479 if (oxu->reclaim)
3480 oxu->reclaim_ready = 1;
3481 ehci_work(oxu);
3482
3483 /* Unlike other USB host controller types, EHCI doesn't have
3484 * any notion of "global" or bus-wide suspend. The driver has
3485 * to manually suspend all the active unsuspended ports, and
3486 * then manually resume them in the bus_resume() routine.
3487 */
3488 oxu->bus_suspended = 0;
3489 while (port--) {
3490 u32 __iomem *reg = &oxu->regs->port_status[port];
3491 u32 t1 = readl(reg) & ~PORT_RWC_BITS;
3492 u32 t2 = t1;
3493
3494 /* keep track of which ports we suspend */
3495 if ((t1 & PORT_PE) && !(t1 & PORT_OWNER) &&
3496 !(t1 & PORT_SUSPEND)) {
3497 t2 |= PORT_SUSPEND;
3498 set_bit(port, &oxu->bus_suspended);
3499 }
3500
3501 /* enable remote wakeup on all ports */
3502 if (device_may_wakeup(&hcd->self.root_hub->dev))
3503 t2 |= PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E;
3504 else
3505 t2 &= ~(PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E);
3506
3507 if (t1 != t2) {
3508 oxu_vdbg(oxu, "port %d, %08x -> %08x\n",
3509 port + 1, t1, t2);
3510 writel(t2, reg);
3511 }
3512 }
3513
3514 /* turn off now-idle HC */
3515 del_timer_sync(&oxu->watchdog);
3516 ehci_halt(oxu);
3517 hcd->state = HC_STATE_SUSPENDED;
3518
3519 /* allow remote wakeup */
3520 mask = INTR_MASK;
3521 if (!device_may_wakeup(&hcd->self.root_hub->dev))
3522 mask &= ~STS_PCD;
3523 writel(mask, &oxu->regs->intr_enable);
3524 readl(&oxu->regs->intr_enable);
3525
3526 oxu->next_statechange = jiffies + msecs_to_jiffies(10);
3527 spin_unlock_irq(&oxu->lock);
3528 return 0;
3529}
3530
3531/* Caller has locked the root hub, and should reset/reinit on error */
3532static int oxu_bus_resume(struct usb_hcd *hcd)
3533{
3534 struct oxu_hcd *oxu = hcd_to_oxu(hcd);
3535 u32 temp;
3536 int i;
3537
3538 if (time_before(jiffies, oxu->next_statechange))
3539 msleep(5);
3540 spin_lock_irq(&oxu->lock);
3541
3542 /* Ideally and we've got a real resume here, and no port's power
3543 * was lost. (For PCI, that means Vaux was maintained.) But we
3544 * could instead be restoring a swsusp snapshot -- so that BIOS was
3545 * the last user of the controller, not reset/pm hardware keeping
3546 * state we gave to it.
3547 */
3548 temp = readl(&oxu->regs->intr_enable);
3549 oxu_dbg(oxu, "resume root hub%s\n", temp ? "" : " after power loss");
3550
3551 /* at least some APM implementations will try to deliver
3552 * IRQs right away, so delay them until we're ready.
3553 */
3554 writel(0, &oxu->regs->intr_enable);
3555
3556 /* re-init operational registers */
3557 writel(0, &oxu->regs->segment);
3558 writel(oxu->periodic_dma, &oxu->regs->frame_list);
3559 writel((u32) oxu->async->qh_dma, &oxu->regs->async_next);
3560
3561 /* restore CMD_RUN, framelist size, and irq threshold */
3562 writel(oxu->command, &oxu->regs->command);
3563
3564 /* Some controller/firmware combinations need a delay during which
3565 * they set up the port statuses. See Bugzilla #8190. */
3566 mdelay(8);
3567
3568 /* manually resume the ports we suspended during bus_suspend() */
3569 i = HCS_N_PORTS(oxu->hcs_params);
3570 while (i--) {
3571 temp = readl(&oxu->regs->port_status[i]);
3572 temp &= ~(PORT_RWC_BITS
3573 | PORT_WKOC_E | PORT_WKDISC_E | PORT_WKCONN_E);
3574 if (test_bit(i, &oxu->bus_suspended) && (temp & PORT_SUSPEND)) {
3575 oxu->reset_done[i] = jiffies + msecs_to_jiffies(20);
3576 temp |= PORT_RESUME;
3577 }
3578 writel(temp, &oxu->regs->port_status[i]);
3579 }
3580 i = HCS_N_PORTS(oxu->hcs_params);
3581 mdelay(20);
3582 while (i--) {
3583 temp = readl(&oxu->regs->port_status[i]);
3584 if (test_bit(i, &oxu->bus_suspended) && (temp & PORT_SUSPEND)) {
3585 temp &= ~(PORT_RWC_BITS | PORT_RESUME);
3586 writel(temp, &oxu->regs->port_status[i]);
3587 oxu_vdbg(oxu, "resumed port %d\n", i + 1);
3588 }
3589 }
3590 (void) readl(&oxu->regs->command);
3591
3592 /* maybe re-activate the schedule(s) */
3593 temp = 0;
3594 if (oxu->async->qh_next.qh)
3595 temp |= CMD_ASE;
3596 if (oxu->periodic_sched)
3597 temp |= CMD_PSE;
3598 if (temp) {
3599 oxu->command |= temp;
3600 writel(oxu->command, &oxu->regs->command);
3601 }
3602
3603 oxu->next_statechange = jiffies + msecs_to_jiffies(5);
3604 hcd->state = HC_STATE_RUNNING;
3605
3606 /* Now we can safely re-enable irqs */
3607 writel(INTR_MASK, &oxu->regs->intr_enable);
3608
3609 spin_unlock_irq(&oxu->lock);
3610 return 0;
3611}
3612
3613#else
3614
3615static int oxu_bus_suspend(struct usb_hcd *hcd)
3616{
3617 return 0;
3618}
3619
3620static int oxu_bus_resume(struct usb_hcd *hcd)
3621{
3622 return 0;
3623}
3624
3625#endif /* CONFIG_PM */
3626
3627static const struct hc_driver oxu_hc_driver = {
3628 .description = "oxu210hp_hcd",
3629 .product_desc = "oxu210hp HCD",
3630 .hcd_priv_size = sizeof(struct oxu_hcd),
3631
3632 /*
3633 * Generic hardware linkage
3634 */
3635 .irq = oxu_irq,
3636 .flags = HCD_MEMORY | HCD_USB2,
3637
3638 /*
3639 * Basic lifecycle operations
3640 */
3641 .reset = oxu_reset,
3642 .start = oxu_run,
3643 .stop = oxu_stop,
3644 .shutdown = oxu_shutdown,
3645
3646 /*
3647 * Managing i/o requests and associated device resources
3648 */
3649 .urb_enqueue = oxu_urb_enqueue,
3650 .urb_dequeue = oxu_urb_dequeue,
3651 .endpoint_disable = oxu_endpoint_disable,
3652
3653 /*
3654 * Scheduling support
3655 */
3656 .get_frame_number = oxu_get_frame,
3657
3658 /*
3659 * Root hub support
3660 */
3661 .hub_status_data = oxu_hub_status_data,
3662 .hub_control = oxu_hub_control,
3663 .bus_suspend = oxu_bus_suspend,
3664 .bus_resume = oxu_bus_resume,
3665};
3666
3667/*
3668 * Module stuff
3669 */
3670
3671static void oxu_configuration(struct platform_device *pdev, void *base)
3672{
3673 u32 tmp;
3674
3675 /* Initialize top level registers.
3676 * First write ever
3677 */
3678 oxu_writel(base, OXU_HOSTIFCONFIG, 0x0000037D);
3679 oxu_writel(base, OXU_SOFTRESET, OXU_SRESET);
3680 oxu_writel(base, OXU_HOSTIFCONFIG, 0x0000037D);
3681
3682 tmp = oxu_readl(base, OXU_PIOBURSTREADCTRL);
3683 oxu_writel(base, OXU_PIOBURSTREADCTRL, tmp | 0x0040);
3684
3685 oxu_writel(base, OXU_ASO, OXU_SPHPOEN | OXU_OVRCCURPUPDEN |
3686 OXU_COMPARATOR | OXU_ASO_OP);
3687
3688 tmp = oxu_readl(base, OXU_CLKCTRL_SET);
3689 oxu_writel(base, OXU_CLKCTRL_SET, tmp | OXU_SYSCLKEN | OXU_USBOTGCLKEN);
3690
3691 /* Clear all top interrupt enable */
3692 oxu_writel(base, OXU_CHIPIRQEN_CLR, 0xff);
3693
3694 /* Clear all top interrupt status */
3695 oxu_writel(base, OXU_CHIPIRQSTATUS, 0xff);
3696
3697 /* Enable all needed top interrupt except OTG SPH core */
3698 oxu_writel(base, OXU_CHIPIRQEN_SET, OXU_USBSPHLPWUI | OXU_USBOTGLPWUI);
3699}
3700
3701static int oxu_verify_id(struct platform_device *pdev, void *base)
3702{
3703 u32 id;
3704 char *bo[] = {
3705 "reserved",
3706 "128-pin LQFP",
3707 "84-pin TFBGA",
3708 "reserved",
3709 };
3710
3711 /* Read controller signature register to find a match */
3712 id = oxu_readl(base, OXU_DEVICEID);
3713 dev_info(&pdev->dev, "device ID %x\n", id);
3714 if ((id & OXU_REV_MASK) != (OXU_REV_2100 << OXU_REV_SHIFT))
3715 return -1;
3716
3717 dev_info(&pdev->dev, "found device %x %s (%04x:%04x)\n",
3718 id >> OXU_REV_SHIFT,
3719 bo[(id & OXU_BO_MASK) >> OXU_BO_SHIFT],
3720 (id & OXU_MAJ_REV_MASK) >> OXU_MAJ_REV_SHIFT,
3721 (id & OXU_MIN_REV_MASK) >> OXU_MIN_REV_SHIFT);
3722
3723 return 0;
3724}
3725
3726static const struct hc_driver oxu_hc_driver;
3727static struct usb_hcd *oxu_create(struct platform_device *pdev,
3728 unsigned long memstart, unsigned long memlen,
3729 void *base, int irq, int otg)
3730{
3731 struct device *dev = &pdev->dev;
3732
3733 struct usb_hcd *hcd;
3734 struct oxu_hcd *oxu;
3735 int ret;
3736
3737 /* Set endian mode and host mode */
3738 oxu_writel(base + (otg ? OXU_OTG_CORE_OFFSET : OXU_SPH_CORE_OFFSET),
3739 OXU_USBMODE,
3740 OXU_CM_HOST_ONLY | OXU_ES_LITTLE | OXU_VBPS);
3741
3742 hcd = usb_create_hcd(&oxu_hc_driver, dev,
3743 otg ? "oxu210hp_otg" : "oxu210hp_sph");
3744 if (!hcd)
3745 return ERR_PTR(-ENOMEM);
3746
3747 hcd->rsrc_start = memstart;
3748 hcd->rsrc_len = memlen;
3749 hcd->regs = base;
3750 hcd->irq = irq;
3751 hcd->state = HC_STATE_HALT;
3752
3753 oxu = hcd_to_oxu(hcd);
3754 oxu->is_otg = otg;
3755
3756 ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
3757 if (ret < 0)
3758 return ERR_PTR(ret);
3759
3760 return hcd;
3761}
3762
3763static int oxu_init(struct platform_device *pdev,
3764 unsigned long memstart, unsigned long memlen,
3765 void *base, int irq)
3766{
3767 struct oxu_info *info = platform_get_drvdata(pdev);
3768 struct usb_hcd *hcd;
3769 int ret;
3770
3771 /* First time configuration at start up */
3772 oxu_configuration(pdev, base);
3773
3774 ret = oxu_verify_id(pdev, base);
3775 if (ret) {
3776 dev_err(&pdev->dev, "no devices found!\n");
3777 return -ENODEV;
3778 }
3779
3780 /* Create the OTG controller */
3781 hcd = oxu_create(pdev, memstart, memlen, base, irq, 1);
3782 if (IS_ERR(hcd)) {
3783 dev_err(&pdev->dev, "cannot create OTG controller!\n");
3784 ret = PTR_ERR(hcd);
3785 goto error_create_otg;
3786 }
3787 info->hcd[0] = hcd;
3788
3789 /* Create the SPH host controller */
3790 hcd = oxu_create(pdev, memstart, memlen, base, irq, 0);
3791 if (IS_ERR(hcd)) {
3792 dev_err(&pdev->dev, "cannot create SPH controller!\n");
3793 ret = PTR_ERR(hcd);
3794 goto error_create_sph;
3795 }
3796 info->hcd[1] = hcd;
3797
3798 oxu_writel(base, OXU_CHIPIRQEN_SET,
3799 oxu_readl(base, OXU_CHIPIRQEN_SET) | 3);
3800
3801 return 0;
3802
3803error_create_sph:
3804 usb_remove_hcd(info->hcd[0]);
3805 usb_put_hcd(info->hcd[0]);
3806
3807error_create_otg:
3808 return ret;
3809}
3810
3811static int oxu_drv_probe(struct platform_device *pdev)
3812{
3813 struct resource *res;
3814 void *base;
3815 unsigned long memstart, memlen;
3816 int irq, ret;
3817 struct oxu_info *info;
3818
3819 if (usb_disabled())
3820 return -ENODEV;
3821
3822 /*
3823 * Get the platform resources
3824 */
3825 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
3826 if (!res) {
3827 dev_err(&pdev->dev,
3828 "no IRQ! Check %s setup!\n", dev_name(&pdev->dev));
3829 return -ENODEV;
3830 }
3831 irq = res->start;
3832 dev_dbg(&pdev->dev, "IRQ resource %d\n", irq);
3833
3834 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
3835 if (!res) {
3836 dev_err(&pdev->dev, "no registers address! Check %s setup!\n",
3837 dev_name(&pdev->dev));
3838 return -ENODEV;
3839 }
3840 memstart = res->start;
3841 memlen = res->end - res->start + 1;
3842 dev_dbg(&pdev->dev, "MEM resource %lx-%lx\n", memstart, memlen);
3843 if (!request_mem_region(memstart, memlen,
3844 oxu_hc_driver.description)) {
3845 dev_dbg(&pdev->dev, "memory area already in use\n");
3846 return -EBUSY;
3847 }
3848
3849 ret = set_irq_type(irq, IRQF_TRIGGER_FALLING);
3850 if (ret) {
3851 dev_err(&pdev->dev, "error setting irq type\n");
3852 ret = -EFAULT;
3853 goto error_set_irq_type;
3854 }
3855
3856 base = ioremap(memstart, memlen);
3857 if (!base) {
3858 dev_dbg(&pdev->dev, "error mapping memory\n");
3859 ret = -EFAULT;
3860 goto error_ioremap;
3861 }
3862
3863 /* Allocate a driver data struct to hold useful info for both
3864 * SPH & OTG devices
3865 */
3866 info = kzalloc(sizeof(struct oxu_info), GFP_KERNEL);
3867 if (!info) {
3868 dev_dbg(&pdev->dev, "error allocating memory\n");
3869 ret = -EFAULT;
3870 goto error_alloc;
3871 }
3872 platform_set_drvdata(pdev, info);
3873
3874 ret = oxu_init(pdev, memstart, memlen, base, irq);
3875 if (ret < 0) {
3876 dev_dbg(&pdev->dev, "cannot init USB devices\n");
3877 goto error_init;
3878 }
3879
3880 dev_info(&pdev->dev, "devices enabled and running\n");
3881 platform_set_drvdata(pdev, info);
3882
3883 return 0;
3884
3885error_init:
3886 kfree(info);
3887 platform_set_drvdata(pdev, NULL);
3888
3889error_alloc:
3890 iounmap(base);
3891
3892error_set_irq_type:
3893error_ioremap:
3894 release_mem_region(memstart, memlen);
3895
3896 dev_err(&pdev->dev, "init %s fail, %d\n", dev_name(&pdev->dev), ret);
3897 return ret;
3898}
3899
3900static void oxu_remove(struct platform_device *pdev, struct usb_hcd *hcd)
3901{
3902 usb_remove_hcd(hcd);
3903 usb_put_hcd(hcd);
3904}
3905
3906static int oxu_drv_remove(struct platform_device *pdev)
3907{
3908 struct oxu_info *info = platform_get_drvdata(pdev);
3909 unsigned long memstart = info->hcd[0]->rsrc_start,
3910 memlen = info->hcd[0]->rsrc_len;
3911 void *base = info->hcd[0]->regs;
3912
3913 oxu_remove(pdev, info->hcd[0]);
3914 oxu_remove(pdev, info->hcd[1]);
3915
3916 iounmap(base);
3917 release_mem_region(memstart, memlen);
3918
3919 kfree(info);
3920 platform_set_drvdata(pdev, NULL);
3921
3922 return 0;
3923}
3924
3925static void oxu_drv_shutdown(struct platform_device *pdev)
3926{
3927 oxu_drv_remove(pdev);
3928}
3929
3930#if 0
3931/* FIXME: TODO */
3932static int oxu_drv_suspend(struct device *dev)
3933{
3934 struct platform_device *pdev = to_platform_device(dev);
3935 struct usb_hcd *hcd = dev_get_drvdata(dev);
3936
3937 return 0;
3938}
3939
3940static int oxu_drv_resume(struct device *dev)
3941{
3942 struct platform_device *pdev = to_platform_device(dev);
3943 struct usb_hcd *hcd = dev_get_drvdata(dev);
3944
3945 return 0;
3946}
3947#else
3948#define oxu_drv_suspend NULL
3949#define oxu_drv_resume NULL
3950#endif
3951
3952static struct platform_driver oxu_driver = {
3953 .probe = oxu_drv_probe,
3954 .remove = oxu_drv_remove,
3955 .shutdown = oxu_drv_shutdown,
3956 .suspend = oxu_drv_suspend,
3957 .resume = oxu_drv_resume,
3958 .driver = {
3959 .name = "oxu210hp-hcd",
3960 .bus = &platform_bus_type
3961 }
3962};
3963
3964static int __init oxu_module_init(void)
3965{
3966 int retval = 0;
3967
3968 retval = platform_driver_register(&oxu_driver);
3969 if (retval < 0)
3970 return retval;
3971
3972 return retval;
3973}
3974
3975static void __exit oxu_module_cleanup(void)
3976{
3977 platform_driver_unregister(&oxu_driver);
3978}
3979
3980module_init(oxu_module_init);
3981module_exit(oxu_module_cleanup);
3982
3983MODULE_DESCRIPTION("Oxford OXU210HP HCD driver - ver. " DRIVER_VERSION);
3984MODULE_AUTHOR("Rodolfo Giometti <giometti@linux.it>");
3985MODULE_LICENSE("GPL");
diff --git a/drivers/usb/host/oxu210hp.h b/drivers/usb/host/oxu210hp.h
new file mode 100644
index 000000000000..8910e271cc7d
--- /dev/null
+++ b/drivers/usb/host/oxu210hp.h
@@ -0,0 +1,447 @@
1/*
2 * Host interface registers
3 */
4
5#define OXU_DEVICEID 0x00
6 #define OXU_REV_MASK 0xffff0000
7 #define OXU_REV_SHIFT 16
8 #define OXU_REV_2100 0x2100
9 #define OXU_BO_SHIFT 8
10 #define OXU_BO_MASK (0x3 << OXU_BO_SHIFT)
11 #define OXU_MAJ_REV_SHIFT 4
12 #define OXU_MAJ_REV_MASK (0xf << OXU_MAJ_REV_SHIFT)
13 #define OXU_MIN_REV_SHIFT 0
14 #define OXU_MIN_REV_MASK (0xf << OXU_MIN_REV_SHIFT)
15#define OXU_HOSTIFCONFIG 0x04
16#define OXU_SOFTRESET 0x08
17 #define OXU_SRESET (1 << 0)
18
19#define OXU_PIOBURSTREADCTRL 0x0C
20
21#define OXU_CHIPIRQSTATUS 0x10
22#define OXU_CHIPIRQEN_SET 0x14
23#define OXU_CHIPIRQEN_CLR 0x18
24 #define OXU_USBSPHLPWUI 0x00000080
25 #define OXU_USBOTGLPWUI 0x00000040
26 #define OXU_USBSPHI 0x00000002
27 #define OXU_USBOTGI 0x00000001
28
29#define OXU_CLKCTRL_SET 0x1C
30 #define OXU_SYSCLKEN 0x00000008
31 #define OXU_USBSPHCLKEN 0x00000002
32 #define OXU_USBOTGCLKEN 0x00000001
33
34#define OXU_ASO 0x68
35 #define OXU_SPHPOEN 0x00000100
36 #define OXU_OVRCCURPUPDEN 0x00000800
37 #define OXU_ASO_OP (1 << 10)
38 #define OXU_COMPARATOR 0x000004000
39
40#define OXU_USBMODE 0x1A8
41 #define OXU_VBPS 0x00000020
42 #define OXU_ES_LITTLE 0x00000000
43 #define OXU_CM_HOST_ONLY 0x00000003
44
45/*
46 * Proper EHCI structs & defines
47 */
48
49/* Magic numbers that can affect system performance */
50#define EHCI_TUNE_CERR 3 /* 0-3 qtd retries; 0 == don't stop */
51#define EHCI_TUNE_RL_HS 4 /* nak throttle; see 4.9 */
52#define EHCI_TUNE_RL_TT 0
53#define EHCI_TUNE_MULT_HS 1 /* 1-3 transactions/uframe; 4.10.3 */
54#define EHCI_TUNE_MULT_TT 1
55#define EHCI_TUNE_FLS 2 /* (small) 256 frame schedule */
56
57struct oxu_hcd;
58
59/* EHCI register interface, corresponds to EHCI Revision 0.95 specification */
60
61/* Section 2.2 Host Controller Capability Registers */
62struct ehci_caps {
63 /* these fields are specified as 8 and 16 bit registers,
64 * but some hosts can't perform 8 or 16 bit PCI accesses.
65 */
66 u32 hc_capbase;
67#define HC_LENGTH(p) (((p)>>00)&0x00ff) /* bits 7:0 */
68#define HC_VERSION(p) (((p)>>16)&0xffff) /* bits 31:16 */
69 u32 hcs_params; /* HCSPARAMS - offset 0x4 */
70#define HCS_DEBUG_PORT(p) (((p)>>20)&0xf) /* bits 23:20, debug port? */
71#define HCS_INDICATOR(p) ((p)&(1 << 16)) /* true: has port indicators */
72#define HCS_N_CC(p) (((p)>>12)&0xf) /* bits 15:12, #companion HCs */
73#define HCS_N_PCC(p) (((p)>>8)&0xf) /* bits 11:8, ports per CC */
74#define HCS_PORTROUTED(p) ((p)&(1 << 7)) /* true: port routing */
75#define HCS_PPC(p) ((p)&(1 << 4)) /* true: port power control */
76#define HCS_N_PORTS(p) (((p)>>0)&0xf) /* bits 3:0, ports on HC */
77
78 u32 hcc_params; /* HCCPARAMS - offset 0x8 */
79#define HCC_EXT_CAPS(p) (((p)>>8)&0xff) /* for pci extended caps */
80#define HCC_ISOC_CACHE(p) ((p)&(1 << 7)) /* true: can cache isoc frame */
81#define HCC_ISOC_THRES(p) (((p)>>4)&0x7) /* bits 6:4, uframes cached */
82#define HCC_CANPARK(p) ((p)&(1 << 2)) /* true: can park on async qh */
83#define HCC_PGM_FRAMELISTLEN(p) ((p)&(1 << 1)) /* true: periodic_size changes*/
84#define HCC_64BIT_ADDR(p) ((p)&(1)) /* true: can use 64-bit addr */
85 u8 portroute[8]; /* nibbles for routing - offset 0xC */
86} __attribute__ ((packed));
87
88
89/* Section 2.3 Host Controller Operational Registers */
90struct ehci_regs {
91 /* USBCMD: offset 0x00 */
92 u32 command;
93/* 23:16 is r/w intr rate, in microframes; default "8" == 1/msec */
94#define CMD_PARK (1<<11) /* enable "park" on async qh */
95#define CMD_PARK_CNT(c) (((c)>>8)&3) /* how many transfers to park for */
96#define CMD_LRESET (1<<7) /* partial reset (no ports, etc) */
97#define CMD_IAAD (1<<6) /* "doorbell" interrupt async advance */
98#define CMD_ASE (1<<5) /* async schedule enable */
99#define CMD_PSE (1<<4) /* periodic schedule enable */
100/* 3:2 is periodic frame list size */
101#define CMD_RESET (1<<1) /* reset HC not bus */
102#define CMD_RUN (1<<0) /* start/stop HC */
103
104 /* USBSTS: offset 0x04 */
105 u32 status;
106#define STS_ASS (1<<15) /* Async Schedule Status */
107#define STS_PSS (1<<14) /* Periodic Schedule Status */
108#define STS_RECL (1<<13) /* Reclamation */
109#define STS_HALT (1<<12) /* Not running (any reason) */
110/* some bits reserved */
111 /* these STS_* flags are also intr_enable bits (USBINTR) */
112#define STS_IAA (1<<5) /* Interrupted on async advance */
113#define STS_FATAL (1<<4) /* such as some PCI access errors */
114#define STS_FLR (1<<3) /* frame list rolled over */
115#define STS_PCD (1<<2) /* port change detect */
116#define STS_ERR (1<<1) /* "error" completion (overflow, ...) */
117#define STS_INT (1<<0) /* "normal" completion (short, ...) */
118
119#define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT)
120
121 /* USBINTR: offset 0x08 */
122 u32 intr_enable;
123
124 /* FRINDEX: offset 0x0C */
125 u32 frame_index; /* current microframe number */
126 /* CTRLDSSEGMENT: offset 0x10 */
127 u32 segment; /* address bits 63:32 if needed */
128 /* PERIODICLISTBASE: offset 0x14 */
129 u32 frame_list; /* points to periodic list */
130 /* ASYNCLISTADDR: offset 0x18 */
131 u32 async_next; /* address of next async queue head */
132
133 u32 reserved[9];
134
135 /* CONFIGFLAG: offset 0x40 */
136 u32 configured_flag;
137#define FLAG_CF (1<<0) /* true: we'll support "high speed" */
138
139 /* PORTSC: offset 0x44 */
140 u32 port_status[0]; /* up to N_PORTS */
141/* 31:23 reserved */
142#define PORT_WKOC_E (1<<22) /* wake on overcurrent (enable) */
143#define PORT_WKDISC_E (1<<21) /* wake on disconnect (enable) */
144#define PORT_WKCONN_E (1<<20) /* wake on connect (enable) */
145/* 19:16 for port testing */
146#define PORT_LED_OFF (0<<14)
147#define PORT_LED_AMBER (1<<14)
148#define PORT_LED_GREEN (2<<14)
149#define PORT_LED_MASK (3<<14)
150#define PORT_OWNER (1<<13) /* true: companion hc owns this port */
151#define PORT_POWER (1<<12) /* true: has power (see PPC) */
152#define PORT_USB11(x) (((x)&(3<<10)) == (1<<10)) /* USB 1.1 device */
153/* 11:10 for detecting lowspeed devices (reset vs release ownership) */
154/* 9 reserved */
155#define PORT_RESET (1<<8) /* reset port */
156#define PORT_SUSPEND (1<<7) /* suspend port */
157#define PORT_RESUME (1<<6) /* resume it */
158#define PORT_OCC (1<<5) /* over current change */
159#define PORT_OC (1<<4) /* over current active */
160#define PORT_PEC (1<<3) /* port enable change */
161#define PORT_PE (1<<2) /* port enable */
162#define PORT_CSC (1<<1) /* connect status change */
163#define PORT_CONNECT (1<<0) /* device connected */
164#define PORT_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC)
165} __attribute__ ((packed));
166
167/* Appendix C, Debug port ... intended for use with special "debug devices"
168 * that can help if there's no serial console. (nonstandard enumeration.)
169 */
170struct ehci_dbg_port {
171 u32 control;
172#define DBGP_OWNER (1<<30)
173#define DBGP_ENABLED (1<<28)
174#define DBGP_DONE (1<<16)
175#define DBGP_INUSE (1<<10)
176#define DBGP_ERRCODE(x) (((x)>>7)&0x07)
177# define DBGP_ERR_BAD 1
178# define DBGP_ERR_SIGNAL 2
179#define DBGP_ERROR (1<<6)
180#define DBGP_GO (1<<5)
181#define DBGP_OUT (1<<4)
182#define DBGP_LEN(x) (((x)>>0)&0x0f)
183 u32 pids;
184#define DBGP_PID_GET(x) (((x)>>16)&0xff)
185#define DBGP_PID_SET(data, tok) (((data)<<8)|(tok))
186 u32 data03;
187 u32 data47;
188 u32 address;
189#define DBGP_EPADDR(dev, ep) (((dev)<<8)|(ep))
190} __attribute__ ((packed));
191
192
193#define QTD_NEXT(dma) cpu_to_le32((u32)dma)
194
195/*
196 * EHCI Specification 0.95 Section 3.5
197 * QTD: describe data transfer components (buffer, direction, ...)
198 * See Fig 3-6 "Queue Element Transfer Descriptor Block Diagram".
199 *
200 * These are associated only with "QH" (Queue Head) structures,
201 * used with control, bulk, and interrupt transfers.
202 */
203struct ehci_qtd {
204 /* first part defined by EHCI spec */
205 __le32 hw_next; /* see EHCI 3.5.1 */
206 __le32 hw_alt_next; /* see EHCI 3.5.2 */
207 __le32 hw_token; /* see EHCI 3.5.3 */
208#define QTD_TOGGLE (1 << 31) /* data toggle */
209#define QTD_LENGTH(tok) (((tok)>>16) & 0x7fff)
210#define QTD_IOC (1 << 15) /* interrupt on complete */
211#define QTD_CERR(tok) (((tok)>>10) & 0x3)
212#define QTD_PID(tok) (((tok)>>8) & 0x3)
213#define QTD_STS_ACTIVE (1 << 7) /* HC may execute this */
214#define QTD_STS_HALT (1 << 6) /* halted on error */
215#define QTD_STS_DBE (1 << 5) /* data buffer error (in HC) */
216#define QTD_STS_BABBLE (1 << 4) /* device was babbling (qtd halted) */
217#define QTD_STS_XACT (1 << 3) /* device gave illegal response */
218#define QTD_STS_MMF (1 << 2) /* incomplete split transaction */
219#define QTD_STS_STS (1 << 1) /* split transaction state */
220#define QTD_STS_PING (1 << 0) /* issue PING? */
221 __le32 hw_buf[5]; /* see EHCI 3.5.4 */
222 __le32 hw_buf_hi[5]; /* Appendix B */
223
224 /* the rest is HCD-private */
225 dma_addr_t qtd_dma; /* qtd address */
226 struct list_head qtd_list; /* sw qtd list */
227 struct urb *urb; /* qtd's urb */
228 size_t length; /* length of buffer */
229
230 u32 qtd_buffer_len;
231 void *buffer;
232 dma_addr_t buffer_dma;
233 void *transfer_buffer;
234 void *transfer_dma;
235} __attribute__ ((aligned(32)));
236
237/* mask NakCnt+T in qh->hw_alt_next */
238#define QTD_MASK __constant_cpu_to_le32 (~0x1f)
239
240#define IS_SHORT_READ(token) (QTD_LENGTH(token) != 0 && QTD_PID(token) == 1)
241
242/* Type tag from {qh, itd, sitd, fstn}->hw_next */
243#define Q_NEXT_TYPE(dma) ((dma) & __constant_cpu_to_le32 (3 << 1))
244
245/* values for that type tag */
246#define Q_TYPE_QH __constant_cpu_to_le32 (1 << 1)
247
248/* next async queue entry, or pointer to interrupt/periodic QH */
249#define QH_NEXT(dma) (cpu_to_le32(((u32)dma)&~0x01f)|Q_TYPE_QH)
250
251/* for periodic/async schedules and qtd lists, mark end of list */
252#define EHCI_LIST_END __constant_cpu_to_le32(1) /* "null pointer" to hw */
253
254/*
255 * Entries in periodic shadow table are pointers to one of four kinds
256 * of data structure. That's dictated by the hardware; a type tag is
257 * encoded in the low bits of the hardware's periodic schedule. Use
258 * Q_NEXT_TYPE to get the tag.
259 *
260 * For entries in the async schedule, the type tag always says "qh".
261 */
262union ehci_shadow {
263 struct ehci_qh *qh; /* Q_TYPE_QH */
264 __le32 *hw_next; /* (all types) */
265 void *ptr;
266};
267
268/*
269 * EHCI Specification 0.95 Section 3.6
270 * QH: describes control/bulk/interrupt endpoints
271 * See Fig 3-7 "Queue Head Structure Layout".
272 *
273 * These appear in both the async and (for interrupt) periodic schedules.
274 */
275
276struct ehci_qh {
277 /* first part defined by EHCI spec */
278 __le32 hw_next; /* see EHCI 3.6.1 */
279 __le32 hw_info1; /* see EHCI 3.6.2 */
280#define QH_HEAD 0x00008000
281 __le32 hw_info2; /* see EHCI 3.6.2 */
282#define QH_SMASK 0x000000ff
283#define QH_CMASK 0x0000ff00
284#define QH_HUBADDR 0x007f0000
285#define QH_HUBPORT 0x3f800000
286#define QH_MULT 0xc0000000
287 __le32 hw_current; /* qtd list - see EHCI 3.6.4 */
288
289 /* qtd overlay (hardware parts of a struct ehci_qtd) */
290 __le32 hw_qtd_next;
291 __le32 hw_alt_next;
292 __le32 hw_token;
293 __le32 hw_buf[5];
294 __le32 hw_buf_hi[5];
295
296 /* the rest is HCD-private */
297 dma_addr_t qh_dma; /* address of qh */
298 union ehci_shadow qh_next; /* ptr to qh; or periodic */
299 struct list_head qtd_list; /* sw qtd list */
300 struct ehci_qtd *dummy;
301 struct ehci_qh *reclaim; /* next to reclaim */
302
303 struct oxu_hcd *oxu;
304 struct kref kref;
305 unsigned stamp;
306
307 u8 qh_state;
308#define QH_STATE_LINKED 1 /* HC sees this */
309#define QH_STATE_UNLINK 2 /* HC may still see this */
310#define QH_STATE_IDLE 3 /* HC doesn't see this */
311#define QH_STATE_UNLINK_WAIT 4 /* LINKED and on reclaim q */
312#define QH_STATE_COMPLETING 5 /* don't touch token.HALT */
313
314 /* periodic schedule info */
315 u8 usecs; /* intr bandwidth */
316 u8 gap_uf; /* uframes split/csplit gap */
317 u8 c_usecs; /* ... split completion bw */
318 u16 tt_usecs; /* tt downstream bandwidth */
319 unsigned short period; /* polling interval */
320 unsigned short start; /* where polling starts */
321#define NO_FRAME ((unsigned short)~0) /* pick new start */
322 struct usb_device *dev; /* access to TT */
323} __attribute__ ((aligned(32)));
324
325/*
326 * Proper OXU210HP structs
327 */
328
329#define OXU_OTG_CORE_OFFSET 0x00400
330#define OXU_OTG_CAP_OFFSET (OXU_OTG_CORE_OFFSET + 0x100)
331#define OXU_SPH_CORE_OFFSET 0x00800
332#define OXU_SPH_CAP_OFFSET (OXU_SPH_CORE_OFFSET + 0x100)
333
334#define OXU_OTG_MEM 0xE000
335#define OXU_SPH_MEM 0x16000
336
337/* Only how many elements & element structure are specifies here. */
338/* 2 host controllers are enabled - total size <= 28 kbytes */
339#define DEFAULT_I_TDPS 1024
340#define QHEAD_NUM 16
341#define QTD_NUM 32
342#define SITD_NUM 8
343#define MURB_NUM 8
344
345#define BUFFER_NUM 8
346#define BUFFER_SIZE 512
347
348struct oxu_info {
349 struct usb_hcd *hcd[2];
350};
351
352struct oxu_buf {
353 u8 buffer[BUFFER_SIZE];
354} __attribute__ ((aligned(BUFFER_SIZE)));
355
356struct oxu_onchip_mem {
357 struct oxu_buf db_pool[BUFFER_NUM];
358
359 u32 frame_list[DEFAULT_I_TDPS];
360 struct ehci_qh qh_pool[QHEAD_NUM];
361 struct ehci_qtd qtd_pool[QTD_NUM];
362} __attribute__ ((aligned(4 << 10)));
363
364#define EHCI_MAX_ROOT_PORTS 15 /* see HCS_N_PORTS */
365
366struct oxu_murb {
367 struct urb urb;
368 struct urb *main;
369 u8 last;
370};
371
372struct oxu_hcd { /* one per controller */
373 unsigned int is_otg:1;
374
375 u8 qh_used[QHEAD_NUM];
376 u8 qtd_used[QTD_NUM];
377 u8 db_used[BUFFER_NUM];
378 u8 murb_used[MURB_NUM];
379
380 struct oxu_onchip_mem __iomem *mem;
381 spinlock_t mem_lock;
382
383 struct timer_list urb_timer;
384
385 struct ehci_caps __iomem *caps;
386 struct ehci_regs __iomem *regs;
387
388 __u32 hcs_params; /* cached register copy */
389 spinlock_t lock;
390
391 /* async schedule support */
392 struct ehci_qh *async;
393 struct ehci_qh *reclaim;
394 unsigned reclaim_ready:1;
395 unsigned scanning:1;
396
397 /* periodic schedule support */
398 unsigned periodic_size;
399 __le32 *periodic; /* hw periodic table */
400 dma_addr_t periodic_dma;
401 unsigned i_thresh; /* uframes HC might cache */
402
403 union ehci_shadow *pshadow; /* mirror hw periodic table */
404 int next_uframe; /* scan periodic, start here */
405 unsigned periodic_sched; /* periodic activity count */
406
407 /* per root hub port */
408 unsigned long reset_done[EHCI_MAX_ROOT_PORTS];
409 /* bit vectors (one bit per port) */
410 unsigned long bus_suspended; /* which ports were
411 * already suspended at the
412 * start of a bus suspend
413 */
414 unsigned long companion_ports;/* which ports are dedicated
415 * to the companion controller
416 */
417
418 struct timer_list watchdog;
419 unsigned long actions;
420 unsigned stamp;
421 unsigned long next_statechange;
422 u32 command;
423
424 /* SILICON QUIRKS */
425 struct list_head urb_list; /* this is the head to urb
426 * queue that didn't get enough
427 * resources
428 */
429 struct oxu_murb *murb_pool; /* murb per split big urb */
430 unsigned urb_len;
431
432 u8 sbrn; /* packed release number */
433};
434
435#define EHCI_IAA_JIFFIES (HZ/100) /* arbitrary; ~10 msec */
436#define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */
437#define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */
438#define EHCI_SHRINK_JIFFIES (HZ/200) /* async qh unlink delay */
439
440enum ehci_timer_action {
441 TIMER_IO_WATCHDOG,
442 TIMER_IAA_WATCHDOG,
443 TIMER_ASYNC_SHRINK,
444 TIMER_ASYNC_OFF,
445};
446
447#include <linux/oxu210hp.h>
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index ae6e70edd745..75b69847918e 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -172,9 +172,9 @@ static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev)
172 if (!mmio_resource_enabled(pdev, 0)) 172 if (!mmio_resource_enabled(pdev, 0))
173 return; 173 return;
174 174
175 base = ioremap_nocache(pci_resource_start(pdev, 0), 175 base = pci_ioremap_bar(pdev, 0);
176 pci_resource_len(pdev, 0)); 176 if (base == NULL)
177 if (base == NULL) return; 177 return;
178 178
179/* On PA-RISC, PDC can leave IR set incorrectly; ignore it there. */ 179/* On PA-RISC, PDC can leave IR set incorrectly; ignore it there. */
180#ifndef __hppa__ 180#ifndef __hppa__
@@ -221,9 +221,9 @@ static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev)
221 if (!mmio_resource_enabled(pdev, 0)) 221 if (!mmio_resource_enabled(pdev, 0))
222 return; 222 return;
223 223
224 base = ioremap_nocache(pci_resource_start(pdev, 0), 224 base = pci_ioremap_bar(pdev, 0);
225 pci_resource_len(pdev, 0)); 225 if (base == NULL)
226 if (base == NULL) return; 226 return;
227 227
228 cap_length = readb(base); 228 cap_length = readb(base);
229 op_reg_base = base + cap_length; 229 op_reg_base = base + cap_length;
@@ -271,7 +271,7 @@ static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev)
271 /* if boot firmware now owns EHCI, spin till 271 /* if boot firmware now owns EHCI, spin till
272 * it hands it over. 272 * it hands it over.
273 */ 273 */
274 msec = 5000; 274 msec = 1000;
275 while ((cap & EHCI_USBLEGSUP_BIOS) && (msec > 0)) { 275 while ((cap & EHCI_USBLEGSUP_BIOS) && (msec > 0)) {
276 tried_handoff = 1; 276 tried_handoff = 1;
277 msleep(10); 277 msleep(10);
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index c21f14e0666a..319041205b57 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -2275,7 +2275,6 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev)
2275 return 0; 2275 return 0;
2276} 2276}
2277 2277
2278#define resource_len(r) (((r)->end - (r)->start) + 1)
2279static int __init r8a66597_probe(struct platform_device *pdev) 2278static int __init r8a66597_probe(struct platform_device *pdev)
2280{ 2279{
2281#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK) 2280#if defined(CONFIG_SUPERH_ON_CHIP_R8A66597) && defined(CONFIG_HAVE_CLK)
@@ -2296,11 +2295,10 @@ static int __init r8a66597_probe(struct platform_device *pdev)
2296 goto clean_up; 2295 goto clean_up;
2297 } 2296 }
2298 2297
2299 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, 2298 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2300 (char *)hcd_name);
2301 if (!res) { 2299 if (!res) {
2302 ret = -ENODEV; 2300 ret = -ENODEV;
2303 dev_err(&pdev->dev, "platform_get_resource_byname error.\n"); 2301 dev_err(&pdev->dev, "platform_get_resource error.\n");
2304 goto clean_up; 2302 goto clean_up;
2305 } 2303 }
2306 2304
@@ -2315,7 +2313,7 @@ static int __init r8a66597_probe(struct platform_device *pdev)
2315 irq = ires->start; 2313 irq = ires->start;
2316 irq_trigger = ires->flags & IRQF_TRIGGER_MASK; 2314 irq_trigger = ires->flags & IRQF_TRIGGER_MASK;
2317 2315
2318 reg = ioremap(res->start, resource_len(res)); 2316 reg = ioremap(res->start, resource_size(res));
2319 if (reg == NULL) { 2317 if (reg == NULL) {
2320 ret = -ENOMEM; 2318 ret = -ENOMEM;
2321 dev_err(&pdev->dev, "ioremap error.\n"); 2319 dev_err(&pdev->dev, "ioremap error.\n");
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index cf5e4cf7ea42..4e221060f58c 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -942,6 +942,8 @@ static struct pci_driver uhci_pci_driver = {
942 942
943#ifdef CONFIG_PM 943#ifdef CONFIG_PM
944 .suspend = usb_hcd_pci_suspend, 944 .suspend = usb_hcd_pci_suspend,
945 .suspend_late = usb_hcd_pci_suspend_late,
946 .resume_early = usb_hcd_pci_resume_early,
945 .resume = usb_hcd_pci_resume, 947 .resume = usb_hcd_pci_resume,
946#endif /* PM */ 948#endif /* PM */
947}; 949};
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index 885867a86de8..4541dfcea88f 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -350,17 +350,16 @@ static int mts_scsi_abort(struct scsi_cmnd *srb)
350static int mts_scsi_host_reset(struct scsi_cmnd *srb) 350static int mts_scsi_host_reset(struct scsi_cmnd *srb)
351{ 351{
352 struct mts_desc* desc = (struct mts_desc*)(srb->device->host->hostdata[0]); 352 struct mts_desc* desc = (struct mts_desc*)(srb->device->host->hostdata[0]);
353 int result, rc; 353 int result;
354 354
355 MTS_DEBUG_GOT_HERE(); 355 MTS_DEBUG_GOT_HERE();
356 mts_debug_dump(desc); 356 mts_debug_dump(desc);
357 357
358 rc = usb_lock_device_for_reset(desc->usb_dev, desc->usb_intf); 358 result = usb_lock_device_for_reset(desc->usb_dev, desc->usb_intf);
359 if (rc < 0) 359 if (result == 0) {
360 return FAILED; 360 result = usb_reset_device(desc->usb_dev);
361 result = usb_reset_device(desc->usb_dev);
362 if (rc)
363 usb_unlock_device(desc->usb_dev); 361 usb_unlock_device(desc->usb_dev);
362 }
364 return result ? FAILED : SUCCESS; 363 return result ? FAILED : SUCCESS;
365} 364}
366 365
diff --git a/drivers/usb/misc/berry_charge.c b/drivers/usb/misc/berry_charge.c
index 24e2dc3148a4..c05a85bc5925 100644
--- a/drivers/usb/misc/berry_charge.c
+++ b/drivers/usb/misc/berry_charge.c
@@ -123,6 +123,11 @@ static int berry_probe(struct usb_interface *intf,
123{ 123{
124 struct usb_device *udev = interface_to_usbdev(intf); 124 struct usb_device *udev = interface_to_usbdev(intf);
125 125
126 if (udev->bus_mA < 500) {
127 dbg(&udev->dev, "Not enough power to charge available\n");
128 return -ENODEV;
129 }
130
126 dbg(&udev->dev, "Power is set to %dmA\n", 131 dbg(&udev->dev, "Power is set to %dmA\n",
127 udev->actconfig->desc.bMaxPower * 2); 132 udev->actconfig->desc.bMaxPower * 2);
128 133
diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c
index e762beb5f3c6..879a980ca8c4 100644
--- a/drivers/usb/misc/emi26.c
+++ b/drivers/usb/misc/emi26.c
@@ -160,7 +160,7 @@ static int emi26_load_firmware (struct usb_device *dev)
160 err("%s - error loading firmware: error = %d", __func__, err); 160 err("%s - error loading firmware: error = %d", __func__, err);
161 goto wraperr; 161 goto wraperr;
162 } 162 }
163 } while (i > 0); 163 } while (rec);
164 164
165 /* Assert reset (stop the CPU in the EMI) */ 165 /* Assert reset (stop the CPU in the EMI) */
166 err = emi26_set_reset(dev,1); 166 err = emi26_set_reset(dev,1);
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 444c69c447be..5f1a19d1497d 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -192,8 +192,6 @@ static struct urb *simple_alloc_urb (
192{ 192{
193 struct urb *urb; 193 struct urb *urb;
194 194
195 if (bytes < 0)
196 return NULL;
197 urb = usb_alloc_urb (0, GFP_KERNEL); 195 urb = usb_alloc_urb (0, GFP_KERNEL);
198 if (!urb) 196 if (!urb)
199 return urb; 197 return urb;
diff --git a/drivers/usb/mon/Kconfig b/drivers/usb/mon/Kconfig
index deb9ddffa402..f28f350cd96a 100644
--- a/drivers/usb/mon/Kconfig
+++ b/drivers/usb/mon/Kconfig
@@ -3,14 +3,13 @@
3# 3#
4 4
5config USB_MON 5config USB_MON
6 bool "USB Monitor" 6 tristate "USB Monitor"
7 depends on USB!=n 7 depends on USB
8 default y 8 default y if USB=y
9 default m if USB=m
9 help 10 help
10 If you say Y here, a component which captures the USB traffic 11 If you select this option, a component which captures the USB traffic
11 between peripheral-specific drivers and HC drivers will be built. 12 between peripheral-specific drivers and HC drivers will be built.
12 For more information, see <file:Documentation/usb/usbmon.txt>. 13 For more information, see <file:Documentation/usb/usbmon.txt>.
13 14
14 This is somewhat experimental at this time, but it should be safe. 15 If unsure, say Y (if allowed), otherwise M.
15
16 If unsure, say Y.
diff --git a/drivers/usb/mon/Makefile b/drivers/usb/mon/Makefile
index 0f76ed5e1617..c6516b566731 100644
--- a/drivers/usb/mon/Makefile
+++ b/drivers/usb/mon/Makefile
@@ -4,5 +4,4 @@
4 4
5usbmon-objs := mon_main.o mon_stat.o mon_text.o mon_bin.o mon_dma.o 5usbmon-objs := mon_main.o mon_stat.o mon_text.o mon_bin.o mon_dma.o
6 6
7# This does not use CONFIG_USB_MON because we want this to use a tristate. 7obj-$(CONFIG_USB_MON) += usbmon.o
8obj-$(CONFIG_USB) += usbmon.o
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 4b9542bbb35c..5af7379cd9a3 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -11,7 +11,7 @@ config USB_MUSB_HDRC
11 depends on (USB || USB_GADGET) && HAVE_CLK 11 depends on (USB || USB_GADGET) && HAVE_CLK
12 depends on !SUPERH 12 depends on !SUPERH
13 select TWL4030_USB if MACH_OMAP_3430SDP 13 select TWL4030_USB if MACH_OMAP_3430SDP
14 tristate 'Inventra Highspeed Dual Role Controller (TI, ...)' 14 tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)'
15 help 15 help
16 Say Y here if your system has a dual role high speed USB 16 Say Y here if your system has a dual role high speed USB
17 controller based on the Mentor Graphics silicon IP. Then 17 controller based on the Mentor Graphics silicon IP. Then
@@ -22,6 +22,9 @@ config USB_MUSB_HDRC
22 Texas Instruments parts using this IP include DaVinci 644x, 22 Texas Instruments parts using this IP include DaVinci 644x,
23 OMAP 243x, OMAP 343x, and TUSB 6010. 23 OMAP 243x, OMAP 343x, and TUSB 6010.
24 24
25 Analog Devices parts using this IP include Blackfin BF54x,
26 BF525 and BF527.
27
25 If you do not know what this is, please say N. 28 If you do not know what this is, please say N.
26 29
27 To compile this driver as a module, choose M here; the 30 To compile this driver as a module, choose M here; the
@@ -33,6 +36,8 @@ config USB_MUSB_SOC
33 default y if ARCH_DAVINCI 36 default y if ARCH_DAVINCI
34 default y if ARCH_OMAP2430 37 default y if ARCH_OMAP2430
35 default y if ARCH_OMAP34XX 38 default y if ARCH_OMAP34XX
39 default y if (BF54x && !BF544)
40 default y if (BF52x && !BF522 && !BF523)
36 41
37comment "DaVinci 644x USB support" 42comment "DaVinci 644x USB support"
38 depends on USB_MUSB_HDRC && ARCH_DAVINCI 43 depends on USB_MUSB_HDRC && ARCH_DAVINCI
@@ -43,6 +48,9 @@ comment "OMAP 243x high speed USB support"
43comment "OMAP 343x high speed USB support" 48comment "OMAP 343x high speed USB support"
44 depends on USB_MUSB_HDRC && ARCH_OMAP34XX 49 depends on USB_MUSB_HDRC && ARCH_OMAP34XX
45 50
51comment "Blackfin high speed USB Support"
52 depends on USB_MUSB_HDRC && (BF54x && !BF544) || (BF52x && !BF522 && !BF523)
53
46config USB_TUSB6010 54config USB_TUSB6010
47 boolean "TUSB 6010 support" 55 boolean "TUSB 6010 support"
48 depends on USB_MUSB_HDRC && !USB_MUSB_SOC 56 depends on USB_MUSB_HDRC && !USB_MUSB_SOC
@@ -142,7 +150,7 @@ config MUSB_PIO_ONLY
142config USB_INVENTRA_DMA 150config USB_INVENTRA_DMA
143 bool 151 bool
144 depends on USB_MUSB_HDRC && !MUSB_PIO_ONLY 152 depends on USB_MUSB_HDRC && !MUSB_PIO_ONLY
145 default ARCH_OMAP2430 || ARCH_OMAP34XX 153 default ARCH_OMAP2430 || ARCH_OMAP34XX || BLACKFIN
146 help 154 help
147 Enable DMA transfers using Mentor's engine. 155 Enable DMA transfers using Mentor's engine.
148 156
diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile
index b6af0d687a73..85710ccc1887 100644
--- a/drivers/usb/musb/Makefile
+++ b/drivers/usb/musb/Makefile
@@ -22,6 +22,14 @@ ifeq ($(CONFIG_ARCH_OMAP3430),y)
22 musb_hdrc-objs += omap2430.o 22 musb_hdrc-objs += omap2430.o
23endif 23endif
24 24
25ifeq ($(CONFIG_BF54x),y)
26 musb_hdrc-objs += blackfin.o
27endif
28
29ifeq ($(CONFIG_BF52x),y)
30 musb_hdrc-objs += blackfin.o
31endif
32
25ifeq ($(CONFIG_USB_GADGET_MUSB_HDRC),y) 33ifeq ($(CONFIG_USB_GADGET_MUSB_HDRC),y)
26 musb_hdrc-objs += musb_gadget_ep0.o musb_gadget.o 34 musb_hdrc-objs += musb_gadget_ep0.o musb_gadget.o
27endif 35endif
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
new file mode 100644
index 000000000000..786134852092
--- /dev/null
+++ b/drivers/usb/musb/blackfin.c
@@ -0,0 +1,320 @@
1/*
2 * MUSB OTG controller driver for Blackfin Processors
3 *
4 * Copyright 2006-2008 Analog Devices Inc.
5 *
6 * Enter bugs at http://blackfin.uclinux.org/
7 *
8 * Licensed under the GPL-2 or later.
9 */
10
11#include <linux/module.h>
12#include <linux/kernel.h>
13#include <linux/sched.h>
14#include <linux/slab.h>
15#include <linux/init.h>
16#include <linux/list.h>
17#include <linux/clk.h>
18#include <linux/gpio.h>
19#include <linux/io.h>
20
21#include <asm/cacheflush.h>
22
23#include "musb_core.h"
24#include "blackfin.h"
25
26/*
27 * Load an endpoint's FIFO
28 */
29void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src)
30{
31 void __iomem *fifo = hw_ep->fifo;
32 void __iomem *epio = hw_ep->regs;
33
34 prefetch((u8 *)src);
35
36 musb_writew(epio, MUSB_TXCOUNT, len);
37
38 DBG(4, "TX ep%d fifo %p count %d buf %p, epio %p\n",
39 hw_ep->epnum, fifo, len, src, epio);
40
41 dump_fifo_data(src, len);
42
43 if (unlikely((unsigned long)src & 0x01))
44 outsw_8((unsigned long)fifo, src,
45 len & 0x01 ? (len >> 1) + 1 : len >> 1);
46 else
47 outsw((unsigned long)fifo, src,
48 len & 0x01 ? (len >> 1) + 1 : len >> 1);
49}
50
51/*
52 * Unload an endpoint's FIFO
53 */
54void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
55{
56 void __iomem *fifo = hw_ep->fifo;
57 u8 epnum = hw_ep->epnum;
58 u16 dma_reg = 0;
59
60 DBG(4, "%cX ep%d fifo %p count %d buf %p\n",
61 'R', hw_ep->epnum, fifo, len, dst);
62
63#ifdef CONFIG_BF52x
64 invalidate_dcache_range((unsigned int)dst,
65 (unsigned int)(dst + len));
66
67 /* Setup DMA address register */
68 dma_reg = (u16) ((u32) dst & 0xFFFF);
69 bfin_write16(USB_DMA_REG(epnum, USB_DMAx_ADDR_LOW), dma_reg);
70 SSYNC();
71
72 dma_reg = (u16) (((u32) dst >> 16) & 0xFFFF);
73 bfin_write16(USB_DMA_REG(epnum, USB_DMAx_ADDR_HIGH), dma_reg);
74 SSYNC();
75
76 /* Setup DMA count register */
77 bfin_write16(USB_DMA_REG(epnum, USB_DMAx_COUNT_LOW), len);
78 bfin_write16(USB_DMA_REG(epnum, USB_DMAx_COUNT_HIGH), 0);
79 SSYNC();
80
81 /* Enable the DMA */
82 dma_reg = (epnum << 4) | DMA_ENA | INT_ENA;
83 bfin_write16(USB_DMA_REG(epnum, USB_DMAx_CTRL), dma_reg);
84 SSYNC();
85
86 /* Wait for compelete */
87 while (!(bfin_read_USB_DMA_INTERRUPT() & (1 << epnum)))
88 cpu_relax();
89
90 /* acknowledge dma interrupt */
91 bfin_write_USB_DMA_INTERRUPT(1 << epnum);
92 SSYNC();
93
94 /* Reset DMA */
95 bfin_write16(USB_DMA_REG(epnum, USB_DMAx_CTRL), 0);
96 SSYNC();
97#else
98 if (unlikely((unsigned long)dst & 0x01))
99 insw_8((unsigned long)fifo, dst,
100 len & 0x01 ? (len >> 1) + 1 : len >> 1);
101 else
102 insw((unsigned long)fifo, dst,
103 len & 0x01 ? (len >> 1) + 1 : len >> 1);
104#endif
105
106 dump_fifo_data(dst, len);
107}
108
109static irqreturn_t blackfin_interrupt(int irq, void *__hci)
110{
111 unsigned long flags;
112 irqreturn_t retval = IRQ_NONE;
113 struct musb *musb = __hci;
114
115 spin_lock_irqsave(&musb->lock, flags);
116
117 musb->int_usb = musb_readb(musb->mregs, MUSB_INTRUSB);
118 musb->int_tx = musb_readw(musb->mregs, MUSB_INTRTX);
119 musb->int_rx = musb_readw(musb->mregs, MUSB_INTRRX);
120
121 if (musb->int_usb || musb->int_tx || musb->int_rx) {
122 musb_writeb(musb->mregs, MUSB_INTRUSB, musb->int_usb);
123 musb_writew(musb->mregs, MUSB_INTRTX, musb->int_tx);
124 musb_writew(musb->mregs, MUSB_INTRRX, musb->int_rx);
125 retval = musb_interrupt(musb);
126 }
127
128 spin_unlock_irqrestore(&musb->lock, flags);
129
130 /* REVISIT we sometimes get spurious IRQs on g_ep0
131 * not clear why... fall in BF54x too.
132 */
133 if (retval != IRQ_HANDLED)
134 DBG(5, "spurious?\n");
135
136 return IRQ_HANDLED;
137}
138
139static void musb_conn_timer_handler(unsigned long _musb)
140{
141 struct musb *musb = (void *)_musb;
142 unsigned long flags;
143 u16 val;
144
145 spin_lock_irqsave(&musb->lock, flags);
146 switch (musb->xceiv.state) {
147 case OTG_STATE_A_IDLE:
148 case OTG_STATE_A_WAIT_BCON:
149 /* Start a new session */
150 val = musb_readw(musb->mregs, MUSB_DEVCTL);
151 val |= MUSB_DEVCTL_SESSION;
152 musb_writew(musb->mregs, MUSB_DEVCTL, val);
153
154 val = musb_readw(musb->mregs, MUSB_DEVCTL);
155 if (!(val & MUSB_DEVCTL_BDEVICE)) {
156 gpio_set_value(musb->config->gpio_vrsel, 1);
157 musb->xceiv.state = OTG_STATE_A_WAIT_BCON;
158 } else {
159 gpio_set_value(musb->config->gpio_vrsel, 0);
160
161 /* Ignore VBUSERROR and SUSPEND IRQ */
162 val = musb_readb(musb->mregs, MUSB_INTRUSBE);
163 val &= ~MUSB_INTR_VBUSERROR;
164 musb_writeb(musb->mregs, MUSB_INTRUSBE, val);
165
166 val = MUSB_INTR_SUSPEND | MUSB_INTR_VBUSERROR;
167 musb_writeb(musb->mregs, MUSB_INTRUSB, val);
168
169 val = MUSB_POWER_HSENAB;
170 musb_writeb(musb->mregs, MUSB_POWER, val);
171 }
172 mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
173 break;
174
175 default:
176 DBG(1, "%s state not handled\n", otg_state_string(musb));
177 break;
178 }
179 spin_unlock_irqrestore(&musb->lock, flags);
180
181 DBG(4, "state is %s\n", otg_state_string(musb));
182}
183
184void musb_platform_enable(struct musb *musb)
185{
186 if (is_host_enabled(musb)) {
187 mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
188 musb->a_wait_bcon = TIMER_DELAY;
189 }
190}
191
192void musb_platform_disable(struct musb *musb)
193{
194}
195
196static void bfin_vbus_power(struct musb *musb, int is_on, int sleeping)
197{
198}
199
200static void bfin_set_vbus(struct musb *musb, int is_on)
201{
202 if (is_on)
203 gpio_set_value(musb->config->gpio_vrsel, 1);
204 else
205 gpio_set_value(musb->config->gpio_vrsel, 0);
206
207 DBG(1, "VBUS %s, devctl %02x "
208 /* otg %3x conf %08x prcm %08x */ "\n",
209 otg_state_string(musb),
210 musb_readb(musb->mregs, MUSB_DEVCTL));
211}
212
213static int bfin_set_power(struct otg_transceiver *x, unsigned mA)
214{
215 return 0;
216}
217
218void musb_platform_try_idle(struct musb *musb, unsigned long timeout)
219{
220 if (is_host_enabled(musb))
221 mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
222}
223
224int musb_platform_get_vbus_status(struct musb *musb)
225{
226 return 0;
227}
228
229void musb_platform_set_mode(struct musb *musb, u8 musb_mode)
230{
231}
232
233int __init musb_platform_init(struct musb *musb)
234{
235
236 /*
237 * Rev 1.0 BF549 EZ-KITs require PE7 to be high for both DEVICE
238 * and OTG HOST modes, while rev 1.1 and greater require PE7 to
239 * be low for DEVICE mode and high for HOST mode. We set it high
240 * here because we are in host mode
241 */
242
243 if (gpio_request(musb->config->gpio_vrsel, "USB_VRSEL")) {
244 printk(KERN_ERR "Failed ro request USB_VRSEL GPIO_%d \n",
245 musb->config->gpio_vrsel);
246 return -ENODEV;
247 }
248 gpio_direction_output(musb->config->gpio_vrsel, 0);
249
250 if (ANOMALY_05000346) {
251 bfin_write_USB_APHY_CALIB(ANOMALY_05000346_value);
252 SSYNC();
253 }
254
255 if (ANOMALY_05000347) {
256 bfin_write_USB_APHY_CNTRL(0x0);
257 SSYNC();
258 }
259
260 /* TODO
261 * Set SIC-IVG register
262 */
263
264 /* Configure PLL oscillator register */
265 bfin_write_USB_PLLOSC_CTRL(0x30a8);
266 SSYNC();
267
268 bfin_write_USB_SRP_CLKDIV((get_sclk()/1000) / 32 - 1);
269 SSYNC();
270
271 bfin_write_USB_EP_NI0_RXMAXP(64);
272 SSYNC();
273
274 bfin_write_USB_EP_NI0_TXMAXP(64);
275 SSYNC();
276
277 /* Route INTRUSB/INTR_RX/INTR_TX to USB_INT0*/
278 bfin_write_USB_GLOBINTR(0x7);
279 SSYNC();
280
281 bfin_write_USB_GLOBAL_CTL(GLOBAL_ENA | EP1_TX_ENA | EP2_TX_ENA |
282 EP3_TX_ENA | EP4_TX_ENA | EP5_TX_ENA |
283 EP6_TX_ENA | EP7_TX_ENA | EP1_RX_ENA |
284 EP2_RX_ENA | EP3_RX_ENA | EP4_RX_ENA |
285 EP5_RX_ENA | EP6_RX_ENA | EP7_RX_ENA);
286 SSYNC();
287
288 if (is_host_enabled(musb)) {
289 musb->board_set_vbus = bfin_set_vbus;
290 setup_timer(&musb_conn_timer,
291 musb_conn_timer_handler, (unsigned long) musb);
292 }
293 if (is_peripheral_enabled(musb))
294 musb->xceiv.set_power = bfin_set_power;
295
296 musb->isr = blackfin_interrupt;
297
298 return 0;
299}
300
301int musb_platform_suspend(struct musb *musb)
302{
303 return 0;
304}
305
306int musb_platform_resume(struct musb *musb)
307{
308 return 0;
309}
310
311
312int musb_platform_exit(struct musb *musb)
313{
314
315 bfin_vbus_power(musb, 0 /*off*/, 1);
316 gpio_free(musb->config->gpio_vrsel);
317 musb_platform_suspend(musb);
318
319 return 0;
320}
diff --git a/drivers/usb/musb/blackfin.h b/drivers/usb/musb/blackfin.h
new file mode 100644
index 000000000000..a240c1e53d16
--- /dev/null
+++ b/drivers/usb/musb/blackfin.h
@@ -0,0 +1,52 @@
1/*
2 * Copyright (C) 2007 by Analog Devices, Inc.
3 *
4 * The Inventra Controller Driver for Linux is free software; you
5 * can redistribute it and/or modify it under the terms of the GNU
6 * General Public License version 2 as published by the Free Software
7 * Foundation.
8 */
9
10#ifndef __MUSB_BLACKFIN_H__
11#define __MUSB_BLACKFIN_H__
12
13/*
14 * Blackfin specific definitions
15 */
16
17#undef DUMP_FIFO_DATA
18#ifdef DUMP_FIFO_DATA
19static void dump_fifo_data(u8 *buf, u16 len)
20{
21 u8 *tmp = buf;
22 int i;
23
24 for (i = 0; i < len; i++) {
25 if (!(i % 16) && i)
26 pr_debug("\n");
27 pr_debug("%02x ", *tmp++);
28 }
29 pr_debug("\n");
30}
31#else
32#define dump_fifo_data(buf, len) do {} while (0)
33#endif
34
35#ifdef CONFIG_BF52x
36
37#define USB_DMA_BASE USB_DMA_INTERRUPT
38#define USB_DMAx_CTRL 0x04
39#define USB_DMAx_ADDR_LOW 0x08
40#define USB_DMAx_ADDR_HIGH 0x0C
41#define USB_DMAx_COUNT_LOW 0x10
42#define USB_DMAx_COUNT_HIGH 0x14
43
44#define USB_DMA_REG(ep, reg) (USB_DMA_BASE + 0x20 * ep + reg)
45#endif
46
47/* Almost 1 second */
48#define TIMER_DELAY (1 * HZ)
49
50static struct timer_list musb_conn_timer;
51
52#endif /* __MUSB_BLACKFIN_H__ */
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
index dfb3bcbe00fc..0d566dc5ce06 100644
--- a/drivers/usb/musb/davinci.c
+++ b/drivers/usb/musb/davinci.c
@@ -32,9 +32,9 @@
32#include <linux/io.h> 32#include <linux/io.h>
33#include <linux/gpio.h> 33#include <linux/gpio.h>
34 34
35#include <asm/arch/hardware.h> 35#include <mach/arch/hardware.h>
36#include <asm/arch/memory.h> 36#include <mach/arch/memory.h>
37#include <asm/arch/gpio.h> 37#include <mach/arch/gpio.h>
38#include <asm/mach-types.h> 38#include <asm/mach-types.h>
39 39
40#include "musb_core.h" 40#include "musb_core.h"
@@ -364,6 +364,18 @@ static irqreturn_t davinci_interrupt(int irq, void *__hci)
364 return IRQ_HANDLED; 364 return IRQ_HANDLED;
365} 365}
366 366
367int musb_platform_set_mode(struct musb *musb, u8 mode)
368{
369 /* EVM can't do this (right?) */
370 return -EIO;
371}
372
373int musb_platform_set_mode(struct musb *musb, u8 mode)
374{
375 /* EVM can't do this (right?) */
376 return -EIO;
377}
378
367int __init musb_platform_init(struct musb *musb) 379int __init musb_platform_init(struct musb *musb)
368{ 380{
369 void __iomem *tibase = musb->ctrl_base; 381 void __iomem *tibase = musb->ctrl_base;
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 5280dba9b1fb..6c7faacfb535 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -148,7 +148,8 @@ static inline struct musb *dev_to_musb(struct device *dev)
148 148
149/*-------------------------------------------------------------------------*/ 149/*-------------------------------------------------------------------------*/
150 150
151#ifndef CONFIG_USB_TUSB6010 151#if !defined(CONFIG_USB_TUSB6010) && !defined(CONFIG_BLACKFIN)
152
152/* 153/*
153 * Load an endpoint's FIFO 154 * Load an endpoint's FIFO
154 */ 155 */
@@ -1124,25 +1125,25 @@ fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep,
1124#endif 1125#endif
1125 switch (cfg->style) { 1126 switch (cfg->style) {
1126 case FIFO_TX: 1127 case FIFO_TX:
1127 musb_writeb(mbase, MUSB_TXFIFOSZ, c_size); 1128 musb_write_txfifosz(mbase, c_size);
1128 musb_writew(mbase, MUSB_TXFIFOADD, c_off); 1129 musb_write_txfifoadd(mbase, c_off);
1129 hw_ep->tx_double_buffered = !!(c_size & MUSB_FIFOSZ_DPB); 1130 hw_ep->tx_double_buffered = !!(c_size & MUSB_FIFOSZ_DPB);
1130 hw_ep->max_packet_sz_tx = maxpacket; 1131 hw_ep->max_packet_sz_tx = maxpacket;
1131 break; 1132 break;
1132 case FIFO_RX: 1133 case FIFO_RX:
1133 musb_writeb(mbase, MUSB_RXFIFOSZ, c_size); 1134 musb_write_rxfifosz(mbase, c_size);
1134 musb_writew(mbase, MUSB_RXFIFOADD, c_off); 1135 musb_write_rxfifoadd(mbase, c_off);
1135 hw_ep->rx_double_buffered = !!(c_size & MUSB_FIFOSZ_DPB); 1136 hw_ep->rx_double_buffered = !!(c_size & MUSB_FIFOSZ_DPB);
1136 hw_ep->max_packet_sz_rx = maxpacket; 1137 hw_ep->max_packet_sz_rx = maxpacket;
1137 break; 1138 break;
1138 case FIFO_RXTX: 1139 case FIFO_RXTX:
1139 musb_writeb(mbase, MUSB_TXFIFOSZ, c_size); 1140 musb_write_txfifosz(mbase, c_size);
1140 musb_writew(mbase, MUSB_TXFIFOADD, c_off); 1141 musb_write_txfifoadd(mbase, c_off);
1141 hw_ep->rx_double_buffered = !!(c_size & MUSB_FIFOSZ_DPB); 1142 hw_ep->rx_double_buffered = !!(c_size & MUSB_FIFOSZ_DPB);
1142 hw_ep->max_packet_sz_rx = maxpacket; 1143 hw_ep->max_packet_sz_rx = maxpacket;
1143 1144
1144 musb_writeb(mbase, MUSB_RXFIFOSZ, c_size); 1145 musb_write_rxfifosz(mbase, c_size);
1145 musb_writew(mbase, MUSB_RXFIFOADD, c_off); 1146 musb_write_rxfifoadd(mbase, c_off);
1146 hw_ep->tx_double_buffered = hw_ep->rx_double_buffered; 1147 hw_ep->tx_double_buffered = hw_ep->rx_double_buffered;
1147 hw_ep->max_packet_sz_tx = maxpacket; 1148 hw_ep->max_packet_sz_tx = maxpacket;
1148 1149
@@ -1212,7 +1213,7 @@ static int __init ep_config_from_table(struct musb *musb)
1212 if (epn >= musb->config->num_eps) { 1213 if (epn >= musb->config->num_eps) {
1213 pr_debug("%s: invalid ep %d\n", 1214 pr_debug("%s: invalid ep %d\n",
1214 musb_driver_name, epn); 1215 musb_driver_name, epn);
1215 continue; 1216 return -EINVAL;
1216 } 1217 }
1217 offset = fifo_setup(musb, hw_ep + epn, cfg++, offset); 1218 offset = fifo_setup(musb, hw_ep + epn, cfg++, offset);
1218 if (offset < 0) { 1219 if (offset < 0) {
@@ -1246,9 +1247,10 @@ static int __init ep_config_from_table(struct musb *musb)
1246 */ 1247 */
1247static int __init ep_config_from_hw(struct musb *musb) 1248static int __init ep_config_from_hw(struct musb *musb)
1248{ 1249{
1249 u8 epnum = 0, reg; 1250 u8 epnum = 0;
1250 struct musb_hw_ep *hw_ep; 1251 struct musb_hw_ep *hw_ep;
1251 void *mbase = musb->mregs; 1252 void *mbase = musb->mregs;
1253 int ret = 0;
1252 1254
1253 DBG(2, "<== static silicon ep config\n"); 1255 DBG(2, "<== static silicon ep config\n");
1254 1256
@@ -1258,26 +1260,9 @@ static int __init ep_config_from_hw(struct musb *musb)
1258 musb_ep_select(mbase, epnum); 1260 musb_ep_select(mbase, epnum);
1259 hw_ep = musb->endpoints + epnum; 1261 hw_ep = musb->endpoints + epnum;
1260 1262
1261 /* read from core using indexed model */ 1263 ret = musb_read_fifosize(musb, hw_ep, epnum);
1262 reg = musb_readb(hw_ep->regs, 0x10 + MUSB_FIFOSIZE); 1264 if (ret < 0)
1263 if (!reg) {
1264 /* 0's returned when no more endpoints */
1265 break; 1265 break;
1266 }
1267 musb->nr_endpoints++;
1268 musb->epmask |= (1 << epnum);
1269
1270 hw_ep->max_packet_sz_tx = 1 << (reg & 0x0f);
1271
1272 /* shared TX/RX FIFO? */
1273 if ((reg & 0xf0) == 0xf0) {
1274 hw_ep->max_packet_sz_rx = hw_ep->max_packet_sz_tx;
1275 hw_ep->is_shared_fifo = true;
1276 continue;
1277 } else {
1278 hw_ep->max_packet_sz_rx = 1 << ((reg & 0xf0) >> 4);
1279 hw_ep->is_shared_fifo = false;
1280 }
1281 1266
1282 /* FIXME set up hw_ep->{rx,tx}_double_buffered */ 1267 /* FIXME set up hw_ep->{rx,tx}_double_buffered */
1283 1268
@@ -1326,7 +1311,7 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb)
1326 1311
1327 /* log core options (read using indexed model) */ 1312 /* log core options (read using indexed model) */
1328 musb_ep_select(mbase, 0); 1313 musb_ep_select(mbase, 0);
1329 reg = musb_readb(mbase, 0x10 + MUSB_CONFIGDATA); 1314 reg = musb_read_configdata(mbase);
1330 1315
1331 strcpy(aInfo, (reg & MUSB_CONFIGDATA_UTMIDW) ? "UTMI-16" : "UTMI-8"); 1316 strcpy(aInfo, (reg & MUSB_CONFIGDATA_UTMIDW) ? "UTMI-16" : "UTMI-8");
1332 if (reg & MUSB_CONFIGDATA_DYNFIFO) 1317 if (reg & MUSB_CONFIGDATA_DYNFIFO)
@@ -1391,7 +1376,7 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb)
1391 } 1376 }
1392 1377
1393 /* log release info */ 1378 /* log release info */
1394 hwvers = musb_readw(mbase, MUSB_HWVERS); 1379 hwvers = musb_read_hwvers(mbase);
1395 rev_major = (hwvers >> 10) & 0x1f; 1380 rev_major = (hwvers >> 10) & 0x1f;
1396 rev_minor = hwvers & 0x3ff; 1381 rev_minor = hwvers & 0x3ff;
1397 snprintf(aRevision, 32, "%d.%d%s", rev_major, 1382 snprintf(aRevision, 32, "%d.%d%s", rev_major,
@@ -1400,8 +1385,7 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb)
1400 musb_driver_name, type, aRevision, aDate); 1385 musb_driver_name, type, aRevision, aDate);
1401 1386
1402 /* configure ep0 */ 1387 /* configure ep0 */
1403 musb->endpoints[0].max_packet_sz_tx = MUSB_EP0_FIFOSIZE; 1388 musb_configure_ep0(musb);
1404 musb->endpoints[0].max_packet_sz_rx = MUSB_EP0_FIFOSIZE;
1405 1389
1406 /* discover endpoint configuration */ 1390 /* discover endpoint configuration */
1407 musb->nr_endpoints = 1; 1391 musb->nr_endpoints = 1;
@@ -1445,7 +1429,7 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb)
1445 1429
1446 hw_ep->regs = MUSB_EP_OFFSET(i, 0) + mbase; 1430 hw_ep->regs = MUSB_EP_OFFSET(i, 0) + mbase;
1447#ifdef CONFIG_USB_MUSB_HDRC_HCD 1431#ifdef CONFIG_USB_MUSB_HDRC_HCD
1448 hw_ep->target_regs = MUSB_BUSCTL_OFFSET(i, 0) + mbase; 1432 hw_ep->target_regs = musb_read_target_reg_base(i, mbase);
1449 hw_ep->rx_reinit = 1; 1433 hw_ep->rx_reinit = 1;
1450 hw_ep->tx_reinit = 1; 1434 hw_ep->tx_reinit = 1;
1451#endif 1435#endif
@@ -1671,17 +1655,20 @@ musb_mode_store(struct device *dev, struct device_attribute *attr,
1671{ 1655{
1672 struct musb *musb = dev_to_musb(dev); 1656 struct musb *musb = dev_to_musb(dev);
1673 unsigned long flags; 1657 unsigned long flags;
1658 int status;
1674 1659
1675 spin_lock_irqsave(&musb->lock, flags); 1660 spin_lock_irqsave(&musb->lock, flags);
1676 if (!strncmp(buf, "host", 4)) 1661 if (sysfs_streq(buf, "host"))
1677 musb_platform_set_mode(musb, MUSB_HOST); 1662 status = musb_platform_set_mode(musb, MUSB_HOST);
1678 if (!strncmp(buf, "peripheral", 10)) 1663 else if (sysfs_streq(buf, "peripheral"))
1679 musb_platform_set_mode(musb, MUSB_PERIPHERAL); 1664 status = musb_platform_set_mode(musb, MUSB_PERIPHERAL);
1680 if (!strncmp(buf, "otg", 3)) 1665 else if (sysfs_streq(buf, "otg"))
1681 musb_platform_set_mode(musb, MUSB_OTG); 1666 status = musb_platform_set_mode(musb, MUSB_OTG);
1667 else
1668 status = -EINVAL;
1682 spin_unlock_irqrestore(&musb->lock, flags); 1669 spin_unlock_irqrestore(&musb->lock, flags);
1683 1670
1684 return n; 1671 return (status == 0) ? n : status;
1685} 1672}
1686static DEVICE_ATTR(mode, 0644, musb_mode_show, musb_mode_store); 1673static DEVICE_ATTR(mode, 0644, musb_mode_show, musb_mode_store);
1687 1674
@@ -1781,7 +1768,7 @@ allocate_instance(struct device *dev,
1781#ifdef CONFIG_USB_MUSB_HDRC_HCD 1768#ifdef CONFIG_USB_MUSB_HDRC_HCD
1782 struct usb_hcd *hcd; 1769 struct usb_hcd *hcd;
1783 1770
1784 hcd = usb_create_hcd(&musb_hc_driver, dev, dev->bus_id); 1771 hcd = usb_create_hcd(&musb_hc_driver, dev, dev_name(dev));
1785 if (!hcd) 1772 if (!hcd)
1786 return NULL; 1773 return NULL;
1787 /* usbcore sets dev->driver_data to hcd, and sometimes uses that... */ 1774 /* usbcore sets dev->driver_data to hcd, and sometimes uses that... */
@@ -1810,7 +1797,6 @@ allocate_instance(struct device *dev,
1810 for (epnum = 0, ep = musb->endpoints; 1797 for (epnum = 0, ep = musb->endpoints;
1811 epnum < musb->config->num_eps; 1798 epnum < musb->config->num_eps;
1812 epnum++, ep++) { 1799 epnum++, ep++) {
1813
1814 ep->musb = musb; 1800 ep->musb = musb;
1815 ep->epnum = epnum; 1801 ep->epnum = epnum;
1816 } 1802 }
@@ -1838,7 +1824,7 @@ static void musb_free(struct musb *musb)
1838 musb_gadget_cleanup(musb); 1824 musb_gadget_cleanup(musb);
1839#endif 1825#endif
1840 1826
1841 if (musb->nIrq >= 0) { 1827 if (musb->nIrq >= 0 && musb->irq_wake) {
1842 disable_irq_wake(musb->nIrq); 1828 disable_irq_wake(musb->nIrq);
1843 free_irq(musb->nIrq, musb); 1829 free_irq(musb->nIrq, musb);
1844 } 1830 }
@@ -1984,15 +1970,19 @@ bad_config:
1984 INIT_WORK(&musb->irq_work, musb_irq_work); 1970 INIT_WORK(&musb->irq_work, musb_irq_work);
1985 1971
1986 /* attach to the IRQ */ 1972 /* attach to the IRQ */
1987 if (request_irq(nIrq, musb->isr, 0, dev->bus_id, musb)) { 1973 if (request_irq(nIrq, musb->isr, 0, dev_name(dev), musb)) {
1988 dev_err(dev, "request_irq %d failed!\n", nIrq); 1974 dev_err(dev, "request_irq %d failed!\n", nIrq);
1989 status = -ENODEV; 1975 status = -ENODEV;
1990 goto fail2; 1976 goto fail2;
1991 } 1977 }
1992 musb->nIrq = nIrq; 1978 musb->nIrq = nIrq;
1993/* FIXME this handles wakeup irqs wrong */ 1979/* FIXME this handles wakeup irqs wrong */
1994 if (enable_irq_wake(nIrq) == 0) 1980 if (enable_irq_wake(nIrq) == 0) {
1981 musb->irq_wake = 1;
1995 device_init_wakeup(dev, 1); 1982 device_init_wakeup(dev, 1);
1983 } else {
1984 musb->irq_wake = 0;
1985 }
1996 1986
1997 pr_info("%s: USB %s mode controller at %p using %s, IRQ %d\n", 1987 pr_info("%s: USB %s mode controller at %p using %s, IRQ %d\n",
1998 musb_driver_name, 1988 musb_driver_name,
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 82227251931b..630946a2d9fc 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -191,7 +191,7 @@ enum musb_g_ep0_state {
191 */ 191 */
192 192
193#if defined(CONFIG_ARCH_DAVINCI) || defined(CONFIG_ARCH_OMAP2430) \ 193#if defined(CONFIG_ARCH_DAVINCI) || defined(CONFIG_ARCH_OMAP2430) \
194 || defined(CONFIG_ARCH_OMAP3430) 194 || defined(CONFIG_ARCH_OMAP3430) || defined(CONFIG_BLACKFIN)
195/* REVISIT indexed access seemed to 195/* REVISIT indexed access seemed to
196 * misbehave (on DaVinci) for at least peripheral IN ... 196 * misbehave (on DaVinci) for at least peripheral IN ...
197 */ 197 */
@@ -359,6 +359,7 @@ struct musb {
359 struct otg_transceiver xceiv; 359 struct otg_transceiver xceiv;
360 360
361 int nIrq; 361 int nIrq;
362 unsigned irq_wake:1;
362 363
363 struct musb_hw_ep endpoints[MUSB_C_NUM_EPS]; 364 struct musb_hw_ep endpoints[MUSB_C_NUM_EPS];
364#define control_ep endpoints 365#define control_ep endpoints
@@ -447,6 +448,70 @@ static inline struct musb *gadget_to_musb(struct usb_gadget *g)
447} 448}
448#endif 449#endif
449 450
451#ifdef CONFIG_BLACKFIN
452static inline int musb_read_fifosize(struct musb *musb,
453 struct musb_hw_ep *hw_ep, u8 epnum)
454{
455 musb->nr_endpoints++;
456 musb->epmask |= (1 << epnum);
457
458 if (epnum < 5) {
459 hw_ep->max_packet_sz_tx = 128;
460 hw_ep->max_packet_sz_rx = 128;
461 } else {
462 hw_ep->max_packet_sz_tx = 1024;
463 hw_ep->max_packet_sz_rx = 1024;
464 }
465 hw_ep->is_shared_fifo = false;
466
467 return 0;
468}
469
470static inline void musb_configure_ep0(struct musb *musb)
471{
472 musb->endpoints[0].max_packet_sz_tx = MUSB_EP0_FIFOSIZE;
473 musb->endpoints[0].max_packet_sz_rx = MUSB_EP0_FIFOSIZE;
474 musb->endpoints[0].is_shared_fifo = true;
475}
476
477#else
478
479static inline int musb_read_fifosize(struct musb *musb,
480 struct musb_hw_ep *hw_ep, u8 epnum)
481{
482 u8 reg = 0;
483
484 /* read from core using indexed model */
485 reg = musb_readb(hw_ep->regs, 0x10 + MUSB_FIFOSIZE);
486 /* 0's returned when no more endpoints */
487 if (!reg)
488 return -ENODEV;
489
490 musb->nr_endpoints++;
491 musb->epmask |= (1 << epnum);
492
493 hw_ep->max_packet_sz_tx = 1 << (reg & 0x0f);
494
495 /* shared TX/RX FIFO? */
496 if ((reg & 0xf0) == 0xf0) {
497 hw_ep->max_packet_sz_rx = hw_ep->max_packet_sz_tx;
498 hw_ep->is_shared_fifo = true;
499 return 0;
500 } else {
501 hw_ep->max_packet_sz_rx = 1 << ((reg & 0xf0) >> 4);
502 hw_ep->is_shared_fifo = false;
503 }
504
505 return 0;
506}
507
508static inline void musb_configure_ep0(struct musb *musb)
509{
510 musb->endpoints[0].max_packet_sz_tx = MUSB_EP0_FIFOSIZE;
511 musb->endpoints[0].max_packet_sz_rx = MUSB_EP0_FIFOSIZE;
512}
513#endif /* CONFIG_BLACKFIN */
514
450 515
451/***************************** Glue it together *****************************/ 516/***************************** Glue it together *****************************/
452 517
@@ -467,16 +532,16 @@ extern void musb_platform_disable(struct musb *musb);
467 532
468extern void musb_hnp_stop(struct musb *musb); 533extern void musb_hnp_stop(struct musb *musb);
469 534
470extern void musb_platform_set_mode(struct musb *musb, u8 musb_mode); 535extern int musb_platform_set_mode(struct musb *musb, u8 musb_mode);
471 536
472#if defined(CONFIG_USB_TUSB6010) || \ 537#if defined(CONFIG_USB_TUSB6010) || defined(CONFIG_BLACKFIN) || \
473 defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP34XX) 538 defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP34XX)
474extern void musb_platform_try_idle(struct musb *musb, unsigned long timeout); 539extern void musb_platform_try_idle(struct musb *musb, unsigned long timeout);
475#else 540#else
476#define musb_platform_try_idle(x, y) do {} while (0) 541#define musb_platform_try_idle(x, y) do {} while (0)
477#endif 542#endif
478 543
479#ifdef CONFIG_USB_TUSB6010 544#if defined(CONFIG_USB_TUSB6010) || defined(CONFIG_BLACKFIN)
480extern int musb_platform_get_vbus_status(struct musb *musb); 545extern int musb_platform_get_vbus_status(struct musb *musb);
481#else 546#else
482#define musb_platform_get_vbus_status(x) 0 547#define musb_platform_get_vbus_status(x) 0
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index d6a802c224fa..6197daeab8f9 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1633,7 +1633,7 @@ int __init musb_gadget_setup(struct musb *musb)
1633 musb->g.speed = USB_SPEED_UNKNOWN; 1633 musb->g.speed = USB_SPEED_UNKNOWN;
1634 1634
1635 /* this "gadget" abstracts/virtualizes the controller */ 1635 /* this "gadget" abstracts/virtualizes the controller */
1636 strcpy(musb->g.dev.bus_id, "gadget"); 1636 dev_set_name(&musb->g.dev, "gadget");
1637 musb->g.dev.parent = musb->controller; 1637 musb->g.dev.parent = musb->controller;
1638 musb->g.dev.dma_mask = musb->controller->dma_mask; 1638 musb->g.dev.dma_mask = musb->controller->dma_mask;
1639 musb->g.dev.release = musb_gadget_release; 1639 musb->g.dev.release = musb_gadget_release;
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index cc64462d4c4e..99fa61234876 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -112,18 +112,21 @@ static void musb_h_tx_flush_fifo(struct musb_hw_ep *ep)
112{ 112{
113 void __iomem *epio = ep->regs; 113 void __iomem *epio = ep->regs;
114 u16 csr; 114 u16 csr;
115 u16 lastcsr = 0;
115 int retries = 1000; 116 int retries = 1000;
116 117
117 csr = musb_readw(epio, MUSB_TXCSR); 118 csr = musb_readw(epio, MUSB_TXCSR);
118 while (csr & MUSB_TXCSR_FIFONOTEMPTY) { 119 while (csr & MUSB_TXCSR_FIFONOTEMPTY) {
119 DBG(5, "Host TX FIFONOTEMPTY csr: %02x\n", csr); 120 if (csr != lastcsr)
121 DBG(3, "Host TX FIFONOTEMPTY csr: %02x\n", csr);
122 lastcsr = csr;
120 csr |= MUSB_TXCSR_FLUSHFIFO; 123 csr |= MUSB_TXCSR_FLUSHFIFO;
121 musb_writew(epio, MUSB_TXCSR, csr); 124 musb_writew(epio, MUSB_TXCSR, csr);
122 csr = musb_readw(epio, MUSB_TXCSR); 125 csr = musb_readw(epio, MUSB_TXCSR);
123 if (retries-- < 1) { 126 if (WARN(retries-- < 1,
124 ERR("Could not flush host TX fifo: csr: %04x\n", csr); 127 "Could not flush host TX%d fifo: csr: %04x\n",
128 ep->epnum, csr))
125 return; 129 return;
126 }
127 mdelay(1); 130 mdelay(1);
128 } 131 }
129} 132}
@@ -268,7 +271,7 @@ __musb_giveback(struct musb *musb, struct urb *urb, int status)
268__releases(musb->lock) 271__releases(musb->lock)
269__acquires(musb->lock) 272__acquires(musb->lock)
270{ 273{
271 DBG(({ int level; switch (urb->status) { 274 DBG(({ int level; switch (status) {
272 case 0: 275 case 0:
273 level = 4; 276 level = 4;
274 break; 277 break;
@@ -283,8 +286,8 @@ __acquires(musb->lock)
283 level = 2; 286 level = 2;
284 break; 287 break;
285 }; level; }), 288 }; level; }),
286 "complete %p (%d), dev%d ep%d%s, %d/%d\n", 289 "complete %p %pF (%d), dev%d ep%d%s, %d/%d\n",
287 urb, urb->status, 290 urb, urb->complete, status,
288 usb_pipedevice(urb->pipe), 291 usb_pipedevice(urb->pipe),
289 usb_pipeendpoint(urb->pipe), 292 usb_pipeendpoint(urb->pipe),
290 usb_pipein(urb->pipe) ? "in" : "out", 293 usb_pipein(urb->pipe) ? "in" : "out",
@@ -593,12 +596,10 @@ musb_rx_reinit(struct musb *musb, struct musb_qh *qh, struct musb_hw_ep *ep)
593 596
594 /* target addr and (for multipoint) hub addr/port */ 597 /* target addr and (for multipoint) hub addr/port */
595 if (musb->is_multipoint) { 598 if (musb->is_multipoint) {
596 musb_writeb(ep->target_regs, MUSB_RXFUNCADDR, 599 musb_write_rxfunaddr(ep->target_regs, qh->addr_reg);
597 qh->addr_reg); 600 musb_write_rxhubaddr(ep->target_regs, qh->h_addr_reg);
598 musb_writeb(ep->target_regs, MUSB_RXHUBADDR, 601 musb_write_rxhubport(ep->target_regs, qh->h_port_reg);
599 qh->h_addr_reg); 602
600 musb_writeb(ep->target_regs, MUSB_RXHUBPORT,
601 qh->h_port_reg);
602 } else 603 } else
603 musb_writeb(musb->mregs, MUSB_FADDR, qh->addr_reg); 604 musb_writeb(musb->mregs, MUSB_FADDR, qh->addr_reg);
604 605
@@ -712,15 +713,9 @@ static void musb_ep_program(struct musb *musb, u8 epnum,
712 713
713 /* target addr and (for multipoint) hub addr/port */ 714 /* target addr and (for multipoint) hub addr/port */
714 if (musb->is_multipoint) { 715 if (musb->is_multipoint) {
715 musb_writeb(mbase, 716 musb_write_txfunaddr(mbase, epnum, qh->addr_reg);
716 MUSB_BUSCTL_OFFSET(epnum, MUSB_TXFUNCADDR), 717 musb_write_txhubaddr(mbase, epnum, qh->h_addr_reg);
717 qh->addr_reg); 718 musb_write_txhubport(mbase, epnum, qh->h_port_reg);
718 musb_writeb(mbase,
719 MUSB_BUSCTL_OFFSET(epnum, MUSB_TXHUBADDR),
720 qh->h_addr_reg);
721 musb_writeb(mbase,
722 MUSB_BUSCTL_OFFSET(epnum, MUSB_TXHUBPORT),
723 qh->h_port_reg);
724/* FIXME if !epnum, do the same for RX ... */ 719/* FIXME if !epnum, do the same for RX ... */
725 } else 720 } else
726 musb_writeb(mbase, MUSB_FADDR, qh->addr_reg); 721 musb_writeb(mbase, MUSB_FADDR, qh->addr_reg);
@@ -988,8 +983,10 @@ static bool musb_h_ep0_continue(struct musb *musb, u16 len, struct urb *urb)
988 if (fifo_count) { 983 if (fifo_count) {
989 fifo_dest = (u8 *) (urb->transfer_buffer 984 fifo_dest = (u8 *) (urb->transfer_buffer
990 + urb->actual_length); 985 + urb->actual_length);
991 DBG(3, "Sending %d bytes to %p\n", 986 DBG(3, "Sending %d byte%s to ep0 fifo %p\n",
992 fifo_count, fifo_dest); 987 fifo_count,
988 (fifo_count == 1) ? "" : "s",
989 fifo_dest);
993 musb_write_fifo(hw_ep, fifo_count, fifo_dest); 990 musb_write_fifo(hw_ep, fifo_count, fifo_dest);
994 991
995 urb->actual_length += fifo_count; 992 urb->actual_length += fifo_count;
diff --git a/drivers/usb/musb/musb_io.h b/drivers/usb/musb/musb_io.h
index 223f0a514094..b06e9ef00cfc 100644
--- a/drivers/usb/musb/musb_io.h
+++ b/drivers/usb/musb/musb_io.h
@@ -39,7 +39,7 @@
39 39
40#if !defined(CONFIG_ARM) && !defined(CONFIG_SUPERH) \ 40#if !defined(CONFIG_ARM) && !defined(CONFIG_SUPERH) \
41 && !defined(CONFIG_AVR32) && !defined(CONFIG_PPC32) \ 41 && !defined(CONFIG_AVR32) && !defined(CONFIG_PPC32) \
42 && !defined(CONFIG_PPC64) 42 && !defined(CONFIG_PPC64) && !defined(CONFIG_BLACKFIN)
43static inline void readsl(const void __iomem *addr, void *buf, int len) 43static inline void readsl(const void __iomem *addr, void *buf, int len)
44 { insl((unsigned long)addr, buf, len); } 44 { insl((unsigned long)addr, buf, len); }
45static inline void readsw(const void __iomem *addr, void *buf, int len) 45static inline void readsw(const void __iomem *addr, void *buf, int len)
@@ -56,6 +56,8 @@ static inline void writesb(const void __iomem *addr, const void *buf, int len)
56 56
57#endif 57#endif
58 58
59#ifndef CONFIG_BLACKFIN
60
59/* NOTE: these offsets are all in bytes */ 61/* NOTE: these offsets are all in bytes */
60 62
61static inline u16 musb_readw(const void __iomem *addr, unsigned offset) 63static inline u16 musb_readw(const void __iomem *addr, unsigned offset)
@@ -114,4 +116,26 @@ static inline void musb_writeb(void __iomem *addr, unsigned offset, u8 data)
114 116
115#endif /* CONFIG_USB_TUSB6010 */ 117#endif /* CONFIG_USB_TUSB6010 */
116 118
119#else
120
121static inline u8 musb_readb(const void __iomem *addr, unsigned offset)
122 { return (u8) (bfin_read16(addr + offset)); }
123
124static inline u16 musb_readw(const void __iomem *addr, unsigned offset)
125 { return bfin_read16(addr + offset); }
126
127static inline u32 musb_readl(const void __iomem *addr, unsigned offset)
128 { return (u32) (bfin_read16(addr + offset)); }
129
130static inline void musb_writeb(void __iomem *addr, unsigned offset, u8 data)
131 { bfin_write16(addr + offset, (u16) data); }
132
133static inline void musb_writew(void __iomem *addr, unsigned offset, u16 data)
134 { bfin_write16(addr + offset, data); }
135
136static inline void musb_writel(void __iomem *addr, unsigned offset, u32 data)
137 { bfin_write16(addr + offset, (u16) data); }
138
139#endif /* CONFIG_BLACKFIN */
140
117#endif 141#endif
diff --git a/drivers/usb/musb/musb_regs.h b/drivers/usb/musb/musb_regs.h
index 9c228661aa5a..de3b2f18db44 100644
--- a/drivers/usb/musb/musb_regs.h
+++ b/drivers/usb/musb/musb_regs.h
@@ -38,97 +38,6 @@
38#define MUSB_EP0_FIFOSIZE 64 /* This is non-configurable */ 38#define MUSB_EP0_FIFOSIZE 64 /* This is non-configurable */
39 39
40/* 40/*
41 * Common USB registers
42 */
43
44#define MUSB_FADDR 0x00 /* 8-bit */
45#define MUSB_POWER 0x01 /* 8-bit */
46
47#define MUSB_INTRTX 0x02 /* 16-bit */
48#define MUSB_INTRRX 0x04
49#define MUSB_INTRTXE 0x06
50#define MUSB_INTRRXE 0x08
51#define MUSB_INTRUSB 0x0A /* 8 bit */
52#define MUSB_INTRUSBE 0x0B /* 8 bit */
53#define MUSB_FRAME 0x0C
54#define MUSB_INDEX 0x0E /* 8 bit */
55#define MUSB_TESTMODE 0x0F /* 8 bit */
56
57/* Get offset for a given FIFO from musb->mregs */
58#ifdef CONFIG_USB_TUSB6010
59#define MUSB_FIFO_OFFSET(epnum) (0x200 + ((epnum) * 0x20))
60#else
61#define MUSB_FIFO_OFFSET(epnum) (0x20 + ((epnum) * 4))
62#endif
63
64/*
65 * Additional Control Registers
66 */
67
68#define MUSB_DEVCTL 0x60 /* 8 bit */
69
70/* These are always controlled through the INDEX register */
71#define MUSB_TXFIFOSZ 0x62 /* 8-bit (see masks) */
72#define MUSB_RXFIFOSZ 0x63 /* 8-bit (see masks) */
73#define MUSB_TXFIFOADD 0x64 /* 16-bit offset shifted right 3 */
74#define MUSB_RXFIFOADD 0x66 /* 16-bit offset shifted right 3 */
75
76/* REVISIT: vctrl/vstatus: optional vendor utmi+phy register at 0x68 */
77#define MUSB_HWVERS 0x6C /* 8 bit */
78
79#define MUSB_EPINFO 0x78 /* 8 bit */
80#define MUSB_RAMINFO 0x79 /* 8 bit */
81#define MUSB_LINKINFO 0x7a /* 8 bit */
82#define MUSB_VPLEN 0x7b /* 8 bit */
83#define MUSB_HS_EOF1 0x7c /* 8 bit */
84#define MUSB_FS_EOF1 0x7d /* 8 bit */
85#define MUSB_LS_EOF1 0x7e /* 8 bit */
86
87/* Offsets to endpoint registers */
88#define MUSB_TXMAXP 0x00
89#define MUSB_TXCSR 0x02
90#define MUSB_CSR0 MUSB_TXCSR /* Re-used for EP0 */
91#define MUSB_RXMAXP 0x04
92#define MUSB_RXCSR 0x06
93#define MUSB_RXCOUNT 0x08
94#define MUSB_COUNT0 MUSB_RXCOUNT /* Re-used for EP0 */
95#define MUSB_TXTYPE 0x0A
96#define MUSB_TYPE0 MUSB_TXTYPE /* Re-used for EP0 */
97#define MUSB_TXINTERVAL 0x0B
98#define MUSB_NAKLIMIT0 MUSB_TXINTERVAL /* Re-used for EP0 */
99#define MUSB_RXTYPE 0x0C
100#define MUSB_RXINTERVAL 0x0D
101#define MUSB_FIFOSIZE 0x0F
102#define MUSB_CONFIGDATA MUSB_FIFOSIZE /* Re-used for EP0 */
103
104/* Offsets to endpoint registers in indexed model (using INDEX register) */
105#define MUSB_INDEXED_OFFSET(_epnum, _offset) \
106 (0x10 + (_offset))
107
108/* Offsets to endpoint registers in flat models */
109#define MUSB_FLAT_OFFSET(_epnum, _offset) \
110 (0x100 + (0x10*(_epnum)) + (_offset))
111
112#ifdef CONFIG_USB_TUSB6010
113/* TUSB6010 EP0 configuration register is special */
114#define MUSB_TUSB_OFFSET(_epnum, _offset) \
115 (0x10 + _offset)
116#include "tusb6010.h" /* Needed "only" for TUSB_EP0_CONF */
117#endif
118
119/* "bus control"/target registers, for host side multipoint (external hubs) */
120#define MUSB_TXFUNCADDR 0x00
121#define MUSB_TXHUBADDR 0x02
122#define MUSB_TXHUBPORT 0x03
123
124#define MUSB_RXFUNCADDR 0x04
125#define MUSB_RXHUBADDR 0x06
126#define MUSB_RXHUBPORT 0x07
127
128#define MUSB_BUSCTL_OFFSET(_epnum, _offset) \
129 (0x80 + (8*(_epnum)) + (_offset))
130
131/*
132 * MUSB Register bits 41 * MUSB Register bits
133 */ 42 */
134 43
@@ -228,7 +137,6 @@
228 137
229/* TXCSR in Peripheral and Host mode */ 138/* TXCSR in Peripheral and Host mode */
230#define MUSB_TXCSR_AUTOSET 0x8000 139#define MUSB_TXCSR_AUTOSET 0x8000
231#define MUSB_TXCSR_MODE 0x2000
232#define MUSB_TXCSR_DMAENAB 0x1000 140#define MUSB_TXCSR_DMAENAB 0x1000
233#define MUSB_TXCSR_FRCDATATOG 0x0800 141#define MUSB_TXCSR_FRCDATATOG 0x0800
234#define MUSB_TXCSR_DMAMODE 0x0400 142#define MUSB_TXCSR_DMAMODE 0x0400
@@ -297,4 +205,309 @@
297/* HUBADDR */ 205/* HUBADDR */
298#define MUSB_HUBADDR_MULTI_TT 0x80 206#define MUSB_HUBADDR_MULTI_TT 0x80
299 207
208
209#ifndef CONFIG_BLACKFIN
210
211/*
212 * Common USB registers
213 */
214
215#define MUSB_FADDR 0x00 /* 8-bit */
216#define MUSB_POWER 0x01 /* 8-bit */
217
218#define MUSB_INTRTX 0x02 /* 16-bit */
219#define MUSB_INTRRX 0x04
220#define MUSB_INTRTXE 0x06
221#define MUSB_INTRRXE 0x08
222#define MUSB_INTRUSB 0x0A /* 8 bit */
223#define MUSB_INTRUSBE 0x0B /* 8 bit */
224#define MUSB_FRAME 0x0C
225#define MUSB_INDEX 0x0E /* 8 bit */
226#define MUSB_TESTMODE 0x0F /* 8 bit */
227
228/* Get offset for a given FIFO from musb->mregs */
229#ifdef CONFIG_USB_TUSB6010
230#define MUSB_FIFO_OFFSET(epnum) (0x200 + ((epnum) * 0x20))
231#else
232#define MUSB_FIFO_OFFSET(epnum) (0x20 + ((epnum) * 4))
233#endif
234
235/*
236 * Additional Control Registers
237 */
238
239#define MUSB_DEVCTL 0x60 /* 8 bit */
240
241/* These are always controlled through the INDEX register */
242#define MUSB_TXFIFOSZ 0x62 /* 8-bit (see masks) */
243#define MUSB_RXFIFOSZ 0x63 /* 8-bit (see masks) */
244#define MUSB_TXFIFOADD 0x64 /* 16-bit offset shifted right 3 */
245#define MUSB_RXFIFOADD 0x66 /* 16-bit offset shifted right 3 */
246
247/* REVISIT: vctrl/vstatus: optional vendor utmi+phy register at 0x68 */
248#define MUSB_HWVERS 0x6C /* 8 bit */
249
250#define MUSB_EPINFO 0x78 /* 8 bit */
251#define MUSB_RAMINFO 0x79 /* 8 bit */
252#define MUSB_LINKINFO 0x7a /* 8 bit */
253#define MUSB_VPLEN 0x7b /* 8 bit */
254#define MUSB_HS_EOF1 0x7c /* 8 bit */
255#define MUSB_FS_EOF1 0x7d /* 8 bit */
256#define MUSB_LS_EOF1 0x7e /* 8 bit */
257
258/* Offsets to endpoint registers */
259#define MUSB_TXMAXP 0x00
260#define MUSB_TXCSR 0x02
261#define MUSB_CSR0 MUSB_TXCSR /* Re-used for EP0 */
262#define MUSB_RXMAXP 0x04
263#define MUSB_RXCSR 0x06
264#define MUSB_RXCOUNT 0x08
265#define MUSB_COUNT0 MUSB_RXCOUNT /* Re-used for EP0 */
266#define MUSB_TXTYPE 0x0A
267#define MUSB_TYPE0 MUSB_TXTYPE /* Re-used for EP0 */
268#define MUSB_TXINTERVAL 0x0B
269#define MUSB_NAKLIMIT0 MUSB_TXINTERVAL /* Re-used for EP0 */
270#define MUSB_RXTYPE 0x0C
271#define MUSB_RXINTERVAL 0x0D
272#define MUSB_FIFOSIZE 0x0F
273#define MUSB_CONFIGDATA MUSB_FIFOSIZE /* Re-used for EP0 */
274
275/* Offsets to endpoint registers in indexed model (using INDEX register) */
276#define MUSB_INDEXED_OFFSET(_epnum, _offset) \
277 (0x10 + (_offset))
278
279/* Offsets to endpoint registers in flat models */
280#define MUSB_FLAT_OFFSET(_epnum, _offset) \
281 (0x100 + (0x10*(_epnum)) + (_offset))
282
283#ifdef CONFIG_USB_TUSB6010
284/* TUSB6010 EP0 configuration register is special */
285#define MUSB_TUSB_OFFSET(_epnum, _offset) \
286 (0x10 + _offset)
287#include "tusb6010.h" /* Needed "only" for TUSB_EP0_CONF */
288#endif
289
290#define MUSB_TXCSR_MODE 0x2000
291
292/* "bus control"/target registers, for host side multipoint (external hubs) */
293#define MUSB_TXFUNCADDR 0x00
294#define MUSB_TXHUBADDR 0x02
295#define MUSB_TXHUBPORT 0x03
296
297#define MUSB_RXFUNCADDR 0x04
298#define MUSB_RXHUBADDR 0x06
299#define MUSB_RXHUBPORT 0x07
300
301#define MUSB_BUSCTL_OFFSET(_epnum, _offset) \
302 (0x80 + (8*(_epnum)) + (_offset))
303
304static inline void musb_write_txfifosz(void __iomem *mbase, u8 c_size)
305{
306 musb_writeb(mbase, MUSB_TXFIFOSZ, c_size);
307}
308
309static inline void musb_write_txfifoadd(void __iomem *mbase, u16 c_off)
310{
311 musb_writew(mbase, MUSB_TXFIFOADD, c_off);
312}
313
314static inline void musb_write_rxfifosz(void __iomem *mbase, u8 c_size)
315{
316 musb_writeb(mbase, MUSB_RXFIFOSZ, c_size);
317}
318
319static inline void musb_write_rxfifoadd(void __iomem *mbase, u16 c_off)
320{
321 musb_writew(mbase, MUSB_RXFIFOADD, c_off);
322}
323
324static inline u8 musb_read_configdata(void __iomem *mbase)
325{
326 return musb_readb(mbase, 0x10 + MUSB_CONFIGDATA);
327}
328
329static inline u16 musb_read_hwvers(void __iomem *mbase)
330{
331 return musb_readw(mbase, MUSB_HWVERS);
332}
333
334static inline void __iomem *musb_read_target_reg_base(u8 i, void __iomem *mbase)
335{
336 return (MUSB_BUSCTL_OFFSET(i, 0) + mbase);
337}
338
339static inline void musb_write_rxfunaddr(void __iomem *ep_target_regs,
340 u8 qh_addr_reg)
341{
342 musb_writeb(ep_target_regs, MUSB_RXFUNCADDR, qh_addr_reg);
343}
344
345static inline void musb_write_rxhubaddr(void __iomem *ep_target_regs,
346 u8 qh_h_addr_reg)
347{
348 musb_writeb(ep_target_regs, MUSB_RXHUBADDR, qh_h_addr_reg);
349}
350
351static inline void musb_write_rxhubport(void __iomem *ep_target_regs,
352 u8 qh_h_port_reg)
353{
354 musb_writeb(ep_target_regs, MUSB_RXHUBPORT, qh_h_port_reg);
355}
356
357static inline void musb_write_txfunaddr(void __iomem *mbase, u8 epnum,
358 u8 qh_addr_reg)
359{
360 musb_writeb(mbase, MUSB_BUSCTL_OFFSET(epnum, MUSB_TXFUNCADDR),
361 qh_addr_reg);
362}
363
364static inline void musb_write_txhubaddr(void __iomem *mbase, u8 epnum,
365 u8 qh_addr_reg)
366{
367 musb_writeb(mbase, MUSB_BUSCTL_OFFSET(epnum, MUSB_TXHUBADDR),
368 qh_addr_reg);
369}
370
371static inline void musb_write_txhubport(void __iomem *mbase, u8 epnum,
372 u8 qh_h_port_reg)
373{
374 musb_writeb(mbase, MUSB_BUSCTL_OFFSET(epnum, MUSB_TXHUBPORT),
375 qh_h_port_reg);
376}
377
378#else /* CONFIG_BLACKFIN */
379
380#define USB_BASE USB_FADDR
381#define USB_OFFSET(reg) (reg - USB_BASE)
382
383/*
384 * Common USB registers
385 */
386#define MUSB_FADDR USB_OFFSET(USB_FADDR) /* 8-bit */
387#define MUSB_POWER USB_OFFSET(USB_POWER) /* 8-bit */
388#define MUSB_INTRTX USB_OFFSET(USB_INTRTX) /* 16-bit */
389#define MUSB_INTRRX USB_OFFSET(USB_INTRRX)
390#define MUSB_INTRTXE USB_OFFSET(USB_INTRTXE)
391#define MUSB_INTRRXE USB_OFFSET(USB_INTRRXE)
392#define MUSB_INTRUSB USB_OFFSET(USB_INTRUSB) /* 8 bit */
393#define MUSB_INTRUSBE USB_OFFSET(USB_INTRUSBE)/* 8 bit */
394#define MUSB_FRAME USB_OFFSET(USB_FRAME)
395#define MUSB_INDEX USB_OFFSET(USB_INDEX) /* 8 bit */
396#define MUSB_TESTMODE USB_OFFSET(USB_TESTMODE)/* 8 bit */
397
398/* Get offset for a given FIFO from musb->mregs */
399#define MUSB_FIFO_OFFSET(epnum) \
400 (USB_OFFSET(USB_EP0_FIFO) + ((epnum) * 8))
401
402/*
403 * Additional Control Registers
404 */
405
406#define MUSB_DEVCTL USB_OFFSET(USB_OTG_DEV_CTL) /* 8 bit */
407
408#define MUSB_LINKINFO USB_OFFSET(USB_LINKINFO)/* 8 bit */
409#define MUSB_VPLEN USB_OFFSET(USB_VPLEN) /* 8 bit */
410#define MUSB_HS_EOF1 USB_OFFSET(USB_HS_EOF1) /* 8 bit */
411#define MUSB_FS_EOF1 USB_OFFSET(USB_FS_EOF1) /* 8 bit */
412#define MUSB_LS_EOF1 USB_OFFSET(USB_LS_EOF1) /* 8 bit */
413
414/* Offsets to endpoint registers */
415#define MUSB_TXMAXP 0x00
416#define MUSB_TXCSR 0x04
417#define MUSB_CSR0 MUSB_TXCSR /* Re-used for EP0 */
418#define MUSB_RXMAXP 0x08
419#define MUSB_RXCSR 0x0C
420#define MUSB_RXCOUNT 0x10
421#define MUSB_COUNT0 MUSB_RXCOUNT /* Re-used for EP0 */
422#define MUSB_TXTYPE 0x14
423#define MUSB_TYPE0 MUSB_TXTYPE /* Re-used for EP0 */
424#define MUSB_TXINTERVAL 0x18
425#define MUSB_NAKLIMIT0 MUSB_TXINTERVAL /* Re-used for EP0 */
426#define MUSB_RXTYPE 0x1C
427#define MUSB_RXINTERVAL 0x20
428#define MUSB_TXCOUNT 0x28
429
430/* Offsets to endpoint registers in indexed model (using INDEX register) */
431#define MUSB_INDEXED_OFFSET(_epnum, _offset) \
432 (0x40 + (_offset))
433
434/* Offsets to endpoint registers in flat models */
435#define MUSB_FLAT_OFFSET(_epnum, _offset) \
436 (USB_OFFSET(USB_EP_NI0_TXMAXP) + (0x40 * (_epnum)) + (_offset))
437
438/* Not implemented - HW has seperate Tx/Rx FIFO */
439#define MUSB_TXCSR_MODE 0x0000
440
441/*
442 * Dummy stub for clk framework, it will be removed
443 * until Blackfin supports clk framework
444 */
445#define clk_get(dev, id) NULL
446#define clk_put(clock) do {} while (0)
447#define clk_enable(clock) do {} while (0)
448#define clk_disable(clock) do {} while (0)
449
450static inline void musb_write_txfifosz(void __iomem *mbase, u8 c_size)
451{
452}
453
454static inline void musb_write_txfifoadd(void __iomem *mbase, u16 c_off)
455{
456}
457
458static inline void musb_write_rxfifosz(void __iomem *mbase, u8 c_size)
459{
460}
461
462static inline void musb_write_rxfifoadd(void __iomem *mbase, u16 c_off)
463{
464}
465
466static inline u8 musb_read_configdata(void __iomem *mbase)
467{
468 return 0;
469}
470
471static inline u16 musb_read_hwvers(void __iomem *mbase)
472{
473 return 0;
474}
475
476static inline u16 musb_read_target_reg_base(u8 i, void __iomem *mbase)
477{
478 return 0;
479}
480
481static inline void musb_write_rxfunaddr(void __iomem *ep_target_regs,
482 u8 qh_addr_req)
483{
484}
485
486static inline void musb_write_rxhubaddr(void __iomem *ep_target_regs,
487 u8 qh_h_addr_reg)
488{
489}
490
491static inline void musb_write_rxhubport(void __iomem *ep_target_regs,
492 u8 qh_h_port_reg)
493{
494}
495
496static inline void musb_write_txfunaddr(void __iomem *mbase, u8 epnum,
497 u8 qh_addr_reg)
498{
499}
500
501static inline void musb_write_txhubaddr(void __iomem *mbase, u8 epnum,
502 u8 qh_addr_reg)
503{
504}
505
506static inline void musb_write_txhubport(void __iomem *mbase, u8 epnum,
507 u8 qh_h_port_reg)
508{
509}
510
511#endif /* CONFIG_BLACKFIN */
512
300#endif /* __MUSB_REGS_H__ */ 513#endif /* __MUSB_REGS_H__ */
diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c
index 8c734ef2c1ed..8662e9e159c3 100644
--- a/drivers/usb/musb/musbhsdma.c
+++ b/drivers/usb/musb/musbhsdma.c
@@ -34,58 +34,7 @@
34#include <linux/interrupt.h> 34#include <linux/interrupt.h>
35#include <linux/platform_device.h> 35#include <linux/platform_device.h>
36#include "musb_core.h" 36#include "musb_core.h"
37 37#include "musbhsdma.h"
38#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
39#include "omap2430.h"
40#endif
41
42#define MUSB_HSDMA_BASE 0x200
43#define MUSB_HSDMA_INTR (MUSB_HSDMA_BASE + 0)
44#define MUSB_HSDMA_CONTROL 0x4
45#define MUSB_HSDMA_ADDRESS 0x8
46#define MUSB_HSDMA_COUNT 0xc
47
48#define MUSB_HSDMA_CHANNEL_OFFSET(_bchannel, _offset) \
49 (MUSB_HSDMA_BASE + (_bchannel << 4) + _offset)
50
51/* control register (16-bit): */
52#define MUSB_HSDMA_ENABLE_SHIFT 0
53#define MUSB_HSDMA_TRANSMIT_SHIFT 1
54#define MUSB_HSDMA_MODE1_SHIFT 2
55#define MUSB_HSDMA_IRQENABLE_SHIFT 3
56#define MUSB_HSDMA_ENDPOINT_SHIFT 4
57#define MUSB_HSDMA_BUSERROR_SHIFT 8
58#define MUSB_HSDMA_BURSTMODE_SHIFT 9
59#define MUSB_HSDMA_BURSTMODE (3 << MUSB_HSDMA_BURSTMODE_SHIFT)
60#define MUSB_HSDMA_BURSTMODE_UNSPEC 0
61#define MUSB_HSDMA_BURSTMODE_INCR4 1
62#define MUSB_HSDMA_BURSTMODE_INCR8 2
63#define MUSB_HSDMA_BURSTMODE_INCR16 3
64
65#define MUSB_HSDMA_CHANNELS 8
66
67struct musb_dma_controller;
68
69struct musb_dma_channel {
70 struct dma_channel channel;
71 struct musb_dma_controller *controller;
72 u32 start_addr;
73 u32 len;
74 u16 max_packet_sz;
75 u8 idx;
76 u8 epnum;
77 u8 transmit;
78};
79
80struct musb_dma_controller {
81 struct dma_controller controller;
82 struct musb_dma_channel channel[MUSB_HSDMA_CHANNELS];
83 void *private_data;
84 void __iomem *base;
85 u8 channel_count;
86 u8 used_channels;
87 u8 irq;
88};
89 38
90static int dma_controller_start(struct dma_controller *c) 39static int dma_controller_start(struct dma_controller *c)
91{ 40{
@@ -203,12 +152,8 @@ static void configure_channel(struct dma_channel *channel,
203 : 0); 152 : 0);
204 153
205 /* address/count */ 154 /* address/count */
206 musb_writel(mbase, 155 musb_write_hsdma_addr(mbase, bchannel, dma_addr);
207 MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_ADDRESS), 156 musb_write_hsdma_count(mbase, bchannel, len);
208 dma_addr);
209 musb_writel(mbase,
210 MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT),
211 len);
212 157
213 /* control (this should start things) */ 158 /* control (this should start things) */
214 musb_writew(mbase, 159 musb_writew(mbase,
@@ -279,13 +224,8 @@ static int dma_channel_abort(struct dma_channel *channel)
279 musb_writew(mbase, 224 musb_writew(mbase,
280 MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_CONTROL), 225 MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_CONTROL),
281 0); 226 0);
282 musb_writel(mbase, 227 musb_write_hsdma_addr(mbase, bchannel, 0);
283 MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_ADDRESS), 228 musb_write_hsdma_count(mbase, bchannel, 0);
284 0);
285 musb_writel(mbase,
286 MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT),
287 0);
288
289 channel->status = MUSB_DMA_STATUS_FREE; 229 channel->status = MUSB_DMA_STATUS_FREE;
290 } 230 }
291 231
@@ -333,10 +273,8 @@ static irqreturn_t dma_controller_irq(int irq, void *private_data)
333 } else { 273 } else {
334 u8 devctl; 274 u8 devctl;
335 275
336 addr = musb_readl(mbase, 276 addr = musb_read_hsdma_addr(mbase,
337 MUSB_HSDMA_CHANNEL_OFFSET( 277 bchannel);
338 bchannel,
339 MUSB_HSDMA_ADDRESS));
340 channel->actual_len = addr 278 channel->actual_len = addr
341 - musb_channel->start_addr; 279 - musb_channel->start_addr;
342 280
@@ -375,6 +313,12 @@ static irqreturn_t dma_controller_irq(int irq, void *private_data)
375 } 313 }
376 } 314 }
377 } 315 }
316
317#ifdef CONFIG_BLACKFIN
318 /* Clear DMA interrup flags */
319 musb_writeb(mbase, MUSB_HSDMA_INTR, int_hsdma);
320#endif
321
378 retval = IRQ_HANDLED; 322 retval = IRQ_HANDLED;
379done: 323done:
380 spin_unlock_irqrestore(&musb->lock, flags); 324 spin_unlock_irqrestore(&musb->lock, flags);
@@ -424,7 +368,7 @@ dma_controller_create(struct musb *musb, void __iomem *base)
424 controller->controller.channel_abort = dma_channel_abort; 368 controller->controller.channel_abort = dma_channel_abort;
425 369
426 if (request_irq(irq, dma_controller_irq, IRQF_DISABLED, 370 if (request_irq(irq, dma_controller_irq, IRQF_DISABLED,
427 musb->controller->bus_id, &controller->controller)) { 371 dev_name(musb->controller), &controller->controller)) {
428 dev_err(dev, "request_irq %d failed!\n", irq); 372 dev_err(dev, "request_irq %d failed!\n", irq);
429 dma_controller_destroy(&controller->controller); 373 dma_controller_destroy(&controller->controller);
430 374
diff --git a/drivers/usb/musb/musbhsdma.h b/drivers/usb/musb/musbhsdma.h
new file mode 100644
index 000000000000..1299d92dc83f
--- /dev/null
+++ b/drivers/usb/musb/musbhsdma.h
@@ -0,0 +1,149 @@
1/*
2 * MUSB OTG driver - support for Mentor's DMA controller
3 *
4 * Copyright 2005 Mentor Graphics Corporation
5 * Copyright (C) 2005-2007 by Texas Instruments
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301 USA
20 *
21 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
22 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
24 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
27 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
34#if defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3430)
35#include "omap2430.h"
36#endif
37
38#ifndef CONFIG_BLACKFIN
39
40#define MUSB_HSDMA_BASE 0x200
41#define MUSB_HSDMA_INTR (MUSB_HSDMA_BASE + 0)
42#define MUSB_HSDMA_CONTROL 0x4
43#define MUSB_HSDMA_ADDRESS 0x8
44#define MUSB_HSDMA_COUNT 0xc
45
46#define MUSB_HSDMA_CHANNEL_OFFSET(_bchannel, _offset) \
47 (MUSB_HSDMA_BASE + (_bchannel << 4) + _offset)
48
49#define musb_read_hsdma_addr(mbase, bchannel) \
50 musb_readl(mbase, \
51 MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_ADDRESS))
52
53#define musb_write_hsdma_addr(mbase, bchannel, addr) \
54 musb_writel(mbase, \
55 MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_ADDRESS), \
56 addr)
57
58#define musb_write_hsdma_count(mbase, bchannel, len) \
59 musb_writel(mbase, \
60 MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT), \
61 len)
62#else
63
64#define MUSB_HSDMA_BASE 0x400
65#define MUSB_HSDMA_INTR (MUSB_HSDMA_BASE + 0)
66#define MUSB_HSDMA_CONTROL 0x04
67#define MUSB_HSDMA_ADDR_LOW 0x08
68#define MUSB_HSDMA_ADDR_HIGH 0x0C
69#define MUSB_HSDMA_COUNT_LOW 0x10
70#define MUSB_HSDMA_COUNT_HIGH 0x14
71
72#define MUSB_HSDMA_CHANNEL_OFFSET(_bchannel, _offset) \
73 (MUSB_HSDMA_BASE + (_bchannel * 0x20) + _offset)
74
75static inline u32 musb_read_hsdma_addr(void __iomem *mbase, u8 bchannel)
76{
77 u32 addr = musb_readw(mbase,
78 MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_ADDR_HIGH));
79
80 addr = addr << 16;
81
82 addr |= musb_readw(mbase,
83 MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_ADDR_LOW));
84
85 return addr;
86}
87
88static inline void musb_write_hsdma_addr(void __iomem *mbase,
89 u8 bchannel, dma_addr_t dma_addr)
90{
91 musb_writew(mbase,
92 MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_ADDR_LOW),
93 ((u16)((u32) dma_addr & 0xFFFF)));
94 musb_writew(mbase,
95 MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_ADDR_HIGH),
96 ((u16)(((u32) dma_addr >> 16) & 0xFFFF)));
97}
98
99static inline void musb_write_hsdma_count(void __iomem *mbase,
100 u8 bchannel, u32 len)
101{
102 musb_writew(mbase,
103 MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT_LOW),
104 ((u16)((u32) len & 0xFFFF)));
105 musb_writew(mbase,
106 MUSB_HSDMA_CHANNEL_OFFSET(bchannel, MUSB_HSDMA_COUNT_HIGH),
107 ((u16)(((u32) len >> 16) & 0xFFFF)));
108}
109
110#endif /* CONFIG_BLACKFIN */
111
112/* control register (16-bit): */
113#define MUSB_HSDMA_ENABLE_SHIFT 0
114#define MUSB_HSDMA_TRANSMIT_SHIFT 1
115#define MUSB_HSDMA_MODE1_SHIFT 2
116#define MUSB_HSDMA_IRQENABLE_SHIFT 3
117#define MUSB_HSDMA_ENDPOINT_SHIFT 4
118#define MUSB_HSDMA_BUSERROR_SHIFT 8
119#define MUSB_HSDMA_BURSTMODE_SHIFT 9
120#define MUSB_HSDMA_BURSTMODE (3 << MUSB_HSDMA_BURSTMODE_SHIFT)
121#define MUSB_HSDMA_BURSTMODE_UNSPEC 0
122#define MUSB_HSDMA_BURSTMODE_INCR4 1
123#define MUSB_HSDMA_BURSTMODE_INCR8 2
124#define MUSB_HSDMA_BURSTMODE_INCR16 3
125
126#define MUSB_HSDMA_CHANNELS 8
127
128struct musb_dma_controller;
129
130struct musb_dma_channel {
131 struct dma_channel channel;
132 struct musb_dma_controller *controller;
133 u32 start_addr;
134 u32 len;
135 u16 max_packet_sz;
136 u8 idx;
137 u8 epnum;
138 u8 transmit;
139};
140
141struct musb_dma_controller {
142 struct dma_controller controller;
143 struct musb_dma_channel channel[MUSB_HSDMA_CHANNELS];
144 void *private_data;
145 void __iomem *base;
146 u8 channel_count;
147 u8 used_channels;
148 u8 irq;
149};
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index ce6c162920f7..901dffdf23b1 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -58,10 +58,10 @@ static void musb_do_idle(unsigned long _musb)
58#endif 58#endif
59 u8 devctl; 59 u8 devctl;
60 60
61 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
62
63 spin_lock_irqsave(&musb->lock, flags); 61 spin_lock_irqsave(&musb->lock, flags);
64 62
63 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
64
65 switch (musb->xceiv.state) { 65 switch (musb->xceiv.state) {
66 case OTG_STATE_A_WAIT_BCON: 66 case OTG_STATE_A_WAIT_BCON:
67 devctl &= ~MUSB_DEVCTL_SESSION; 67 devctl &= ~MUSB_DEVCTL_SESSION;
@@ -196,7 +196,7 @@ static int omap_set_power(struct otg_transceiver *x, unsigned mA)
196 196
197static int musb_platform_resume(struct musb *musb); 197static int musb_platform_resume(struct musb *musb);
198 198
199void musb_platform_set_mode(struct musb *musb, u8 musb_mode) 199int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
200{ 200{
201 u8 devctl = musb_readb(musb->mregs, MUSB_DEVCTL); 201 u8 devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
202 202
@@ -204,15 +204,24 @@ void musb_platform_set_mode(struct musb *musb, u8 musb_mode)
204 musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); 204 musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
205 205
206 switch (musb_mode) { 206 switch (musb_mode) {
207#ifdef CONFIG_USB_MUSB_HDRC_HCD
207 case MUSB_HOST: 208 case MUSB_HOST:
208 otg_set_host(&musb->xceiv, musb->xceiv.host); 209 otg_set_host(&musb->xceiv, musb->xceiv.host);
209 break; 210 break;
211#endif
212#ifdef CONFIG_USB_GADGET_MUSB_HDRC
210 case MUSB_PERIPHERAL: 213 case MUSB_PERIPHERAL:
211 otg_set_peripheral(&musb->xceiv, musb->xceiv.gadget); 214 otg_set_peripheral(&musb->xceiv, musb->xceiv.gadget);
212 break; 215 break;
216#endif
217#ifdef CONFIG_USB_MUSB_OTG
213 case MUSB_OTG: 218 case MUSB_OTG:
214 break; 219 break;
220#endif
221 default:
222 return -EINVAL;
215 } 223 }
224 return 0;
216} 225}
217 226
218int __init musb_platform_init(struct musb *musb) 227int __init musb_platform_init(struct musb *musb)
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index ee8fca92a4ac..9e20fd070d71 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -598,7 +598,7 @@ static void tusb_source_power(struct musb *musb, int is_on)
598 * and peripheral modes in non-OTG configurations by reconfiguring hardware 598 * and peripheral modes in non-OTG configurations by reconfiguring hardware
599 * and then setting musb->board_mode. For now, only support OTG mode. 599 * and then setting musb->board_mode. For now, only support OTG mode.
600 */ 600 */
601void musb_platform_set_mode(struct musb *musb, u8 musb_mode) 601int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
602{ 602{
603 void __iomem *tbase = musb->ctrl_base; 603 void __iomem *tbase = musb->ctrl_base;
604 u32 otg_stat, phy_otg_ctrl, phy_otg_ena, dev_conf; 604 u32 otg_stat, phy_otg_ctrl, phy_otg_ena, dev_conf;
@@ -641,7 +641,8 @@ void musb_platform_set_mode(struct musb *musb, u8 musb_mode)
641#endif 641#endif
642 642
643 default: 643 default:
644 DBG(2, "Trying to set unknown mode %i\n", musb_mode); 644 DBG(2, "Trying to set mode %i\n", musb_mode);
645 return -EINVAL;
645 } 646 }
646 647
647 musb_writel(tbase, TUSB_PHY_OTG_CTRL, 648 musb_writel(tbase, TUSB_PHY_OTG_CTRL,
@@ -655,6 +656,8 @@ void musb_platform_set_mode(struct musb *musb, u8 musb_mode)
655 !(otg_stat & TUSB_DEV_OTG_STAT_ID_STATUS)) 656 !(otg_stat & TUSB_DEV_OTG_STAT_ID_STATUS))
656 INFO("Cannot be peripheral with mini-A cable " 657 INFO("Cannot be peripheral with mini-A cable "
657 "otg_stat: %08x\n", otg_stat); 658 "otg_stat: %08x\n", otg_stat);
659
660 return 0;
658} 661}
659 662
660static inline unsigned long 663static inline unsigned long
diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig
new file mode 100644
index 000000000000..8e8dbdb9b39b
--- /dev/null
+++ b/drivers/usb/otg/Kconfig
@@ -0,0 +1,54 @@
1#
2# USB OTG infrastructure may be needed for peripheral-only, host-only,
3# or OTG-capable configurations when OTG transceivers or controllers
4# are used.
5#
6
7comment "OTG and related infrastructure"
8
9if USB || USB_GADGET
10
11config USB_OTG_UTILS
12 bool
13 help
14 Select this to make sure the build includes objects from
15 the OTG infrastructure directory.
16
17#
18# USB Transceiver Drivers
19#
20config USB_GPIO_VBUS
21 tristate "GPIO based peripheral-only VBUS sensing 'transceiver'"
22 depends on GENERIC_GPIO
23 select USB_OTG_UTILS
24 help
25 Provides simple GPIO VBUS sensing for controllers with an
26 internal transceiver via the otg_transceiver interface, and
27 optionally control of a D+ pullup GPIO as well as a VBUS
28 current limit regulator.
29
30config ISP1301_OMAP
31 tristate "Philips ISP1301 with OMAP OTG"
32 depends on I2C && ARCH_OMAP_OTG
33 select USB_OTG_UTILS
34 help
35 If you say yes here you get support for the Philips ISP1301
36 USB-On-The-Go transceiver working with the OMAP OTG controller.
37 The ISP1301 is a full speed USB transceiver which is used in
38 products including H2, H3, and H4 development boards for Texas
39 Instruments OMAP processors.
40
41 This driver can also be built as a module. If so, the module
42 will be called isp1301_omap.
43
44config TWL4030_USB
45 tristate "TWL4030 USB Transceiver Driver"
46 depends on TWL4030_CORE
47 select USB_OTG_UTILS
48 help
49 Enable this to support the USB OTG transceiver on TWL4030
50 family chips (including the TWL5030 and TPS659x0 devices).
51 This transceiver supports high and full speed devices plus,
52 in host mode, low speed.
53
54endif # USB || OTG
diff --git a/drivers/usb/otg/Makefile b/drivers/usb/otg/Makefile
new file mode 100644
index 000000000000..d73c7cf5e2f7
--- /dev/null
+++ b/drivers/usb/otg/Makefile
@@ -0,0 +1,15 @@
1#
2# OTG infrastructure and transceiver drivers
3#
4
5# infrastructure
6obj-$(CONFIG_USB_OTG_UTILS) += otg.o
7
8# transceiver drivers
9obj-$(CONFIG_USB_GPIO_VBUS) += gpio_vbus.o
10obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o
11obj-$(CONFIG_TWL4030_USB) += twl4030-usb.o
12
13ccflags-$(CONFIG_USB_DEBUG) += -DDEBUG
14ccflags-$(CONFIG_USB_GADGET_DEBUG) += -DDEBUG
15
diff --git a/drivers/usb/otg/gpio_vbus.c b/drivers/usb/otg/gpio_vbus.c
new file mode 100644
index 000000000000..63a6036f04be
--- /dev/null
+++ b/drivers/usb/otg/gpio_vbus.c
@@ -0,0 +1,335 @@
1/*
2 * gpio-vbus.c - simple GPIO VBUS sensing driver for B peripheral devices
3 *
4 * Copyright (c) 2008 Philipp Zabel <philipp.zabel@gmail.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 version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/kernel.h>
12#include <linux/platform_device.h>
13#include <linux/gpio.h>
14#include <linux/interrupt.h>
15#include <linux/usb.h>
16
17#include <linux/regulator/consumer.h>
18
19#include <linux/usb/gadget.h>
20#include <linux/usb/gpio_vbus.h>
21#include <linux/usb/otg.h>
22
23
24/*
25 * A simple GPIO VBUS sensing driver for B peripheral only devices
26 * with internal transceivers. It can control a D+ pullup GPIO and
27 * a regulator to limit the current drawn from VBUS.
28 *
29 * Needs to be loaded before the UDC driver that will use it.
30 */
31struct gpio_vbus_data {
32 struct otg_transceiver otg;
33 struct device *dev;
34 struct regulator *vbus_draw;
35 int vbus_draw_enabled;
36 unsigned mA;
37};
38
39
40/*
41 * This driver relies on "both edges" triggering. VBUS has 100 msec to
42 * stabilize, so the peripheral controller driver may need to cope with
43 * some bouncing due to current surges (e.g. charging local capacitance)
44 * and contact chatter.
45 *
46 * REVISIT in desperate straits, toggling between rising and falling
47 * edges might be workable.
48 */
49#define VBUS_IRQ_FLAGS \
50 ( IRQF_SAMPLE_RANDOM | IRQF_SHARED \
51 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING )
52
53
54/* interface to regulator framework */
55static void set_vbus_draw(struct gpio_vbus_data *gpio_vbus, unsigned mA)
56{
57 struct regulator *vbus_draw = gpio_vbus->vbus_draw;
58 int enabled;
59
60 if (!vbus_draw)
61 return;
62
63 enabled = gpio_vbus->vbus_draw_enabled;
64 if (mA) {
65 regulator_set_current_limit(vbus_draw, 0, 1000 * mA);
66 if (!enabled) {
67 regulator_enable(vbus_draw);
68 gpio_vbus->vbus_draw_enabled = 1;
69 }
70 } else {
71 if (enabled) {
72 regulator_disable(vbus_draw);
73 gpio_vbus->vbus_draw_enabled = 0;
74 }
75 }
76 gpio_vbus->mA = mA;
77}
78
79/* VBUS change IRQ handler */
80static irqreturn_t gpio_vbus_irq(int irq, void *data)
81{
82 struct platform_device *pdev = data;
83 struct gpio_vbus_mach_info *pdata = pdev->dev.platform_data;
84 struct gpio_vbus_data *gpio_vbus = platform_get_drvdata(pdev);
85 int gpio, vbus;
86
87 vbus = gpio_get_value(pdata->gpio_vbus);
88 if (pdata->gpio_vbus_inverted)
89 vbus = !vbus;
90
91 dev_dbg(&pdev->dev, "VBUS %s (gadget: %s)\n",
92 vbus ? "supplied" : "inactive",
93 gpio_vbus->otg.gadget ? gpio_vbus->otg.gadget->name : "none");
94
95 if (!gpio_vbus->otg.gadget)
96 return IRQ_HANDLED;
97
98 /* Peripheral controllers which manage the pullup themselves won't have
99 * gpio_pullup configured here. If it's configured here, we'll do what
100 * isp1301_omap::b_peripheral() does and enable the pullup here... although
101 * that may complicate usb_gadget_{,dis}connect() support.
102 */
103 gpio = pdata->gpio_pullup;
104 if (vbus) {
105 gpio_vbus->otg.state = OTG_STATE_B_PERIPHERAL;
106 usb_gadget_vbus_connect(gpio_vbus->otg.gadget);
107
108 /* drawing a "unit load" is *always* OK, except for OTG */
109 set_vbus_draw(gpio_vbus, 100);
110
111 /* optionally enable D+ pullup */
112 if (gpio_is_valid(gpio))
113 gpio_set_value(gpio, !pdata->gpio_pullup_inverted);
114 } else {
115 /* optionally disable D+ pullup */
116 if (gpio_is_valid(gpio))
117 gpio_set_value(gpio, pdata->gpio_pullup_inverted);
118
119 set_vbus_draw(gpio_vbus, 0);
120
121 usb_gadget_vbus_disconnect(gpio_vbus->otg.gadget);
122 gpio_vbus->otg.state = OTG_STATE_B_IDLE;
123 }
124
125 return IRQ_HANDLED;
126}
127
128/* OTG transceiver interface */
129
130/* bind/unbind the peripheral controller */
131static int gpio_vbus_set_peripheral(struct otg_transceiver *otg,
132 struct usb_gadget *gadget)
133{
134 struct gpio_vbus_data *gpio_vbus;
135 struct gpio_vbus_mach_info *pdata;
136 struct platform_device *pdev;
137 int gpio, irq;
138
139 gpio_vbus = container_of(otg, struct gpio_vbus_data, otg);
140 pdev = to_platform_device(gpio_vbus->dev);
141 pdata = gpio_vbus->dev->platform_data;
142 irq = gpio_to_irq(pdata->gpio_vbus);
143 gpio = pdata->gpio_pullup;
144
145 if (!gadget) {
146 dev_dbg(&pdev->dev, "unregistering gadget '%s'\n",
147 otg->gadget->name);
148
149 /* optionally disable D+ pullup */
150 if (gpio_is_valid(gpio))
151 gpio_set_value(gpio, pdata->gpio_pullup_inverted);
152
153 set_vbus_draw(gpio_vbus, 0);
154
155 usb_gadget_vbus_disconnect(otg->gadget);
156 otg->state = OTG_STATE_UNDEFINED;
157
158 otg->gadget = NULL;
159 return 0;
160 }
161
162 otg->gadget = gadget;
163 dev_dbg(&pdev->dev, "registered gadget '%s'\n", gadget->name);
164
165 /* initialize connection state */
166 gpio_vbus_irq(irq, pdev);
167 return 0;
168}
169
170/* effective for B devices, ignored for A-peripheral */
171static int gpio_vbus_set_power(struct otg_transceiver *otg, unsigned mA)
172{
173 struct gpio_vbus_data *gpio_vbus;
174
175 gpio_vbus = container_of(otg, struct gpio_vbus_data, otg);
176
177 if (otg->state == OTG_STATE_B_PERIPHERAL)
178 set_vbus_draw(gpio_vbus, mA);
179 return 0;
180}
181
182/* for non-OTG B devices: set/clear transceiver suspend mode */
183static int gpio_vbus_set_suspend(struct otg_transceiver *otg, int suspend)
184{
185 struct gpio_vbus_data *gpio_vbus;
186
187 gpio_vbus = container_of(otg, struct gpio_vbus_data, otg);
188
189 /* draw max 0 mA from vbus in suspend mode; or the previously
190 * recorded amount of current if not suspended
191 *
192 * NOTE: high powered configs (mA > 100) may draw up to 2.5 mA
193 * if they're wake-enabled ... we don't handle that yet.
194 */
195 return gpio_vbus_set_power(otg, suspend ? 0 : gpio_vbus->mA);
196}
197
198/* platform driver interface */
199
200static int __init gpio_vbus_probe(struct platform_device *pdev)
201{
202 struct gpio_vbus_mach_info *pdata = pdev->dev.platform_data;
203 struct gpio_vbus_data *gpio_vbus;
204 struct resource *res;
205 int err, gpio, irq;
206
207 if (!pdata || !gpio_is_valid(pdata->gpio_vbus))
208 return -EINVAL;
209 gpio = pdata->gpio_vbus;
210
211 gpio_vbus = kzalloc(sizeof(struct gpio_vbus_data), GFP_KERNEL);
212 if (!gpio_vbus)
213 return -ENOMEM;
214
215 platform_set_drvdata(pdev, gpio_vbus);
216 gpio_vbus->dev = &pdev->dev;
217 gpio_vbus->otg.label = "gpio-vbus";
218 gpio_vbus->otg.state = OTG_STATE_UNDEFINED;
219 gpio_vbus->otg.set_peripheral = gpio_vbus_set_peripheral;
220 gpio_vbus->otg.set_power = gpio_vbus_set_power;
221 gpio_vbus->otg.set_suspend = gpio_vbus_set_suspend;
222
223 err = gpio_request(gpio, "vbus_detect");
224 if (err) {
225 dev_err(&pdev->dev, "can't request vbus gpio %d, err: %d\n",
226 gpio, err);
227 goto err_gpio;
228 }
229 gpio_direction_input(gpio);
230
231 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
232 if (res) {
233 irq = res->start;
234 res->flags &= IRQF_TRIGGER_MASK;
235 res->flags |= IRQF_SAMPLE_RANDOM | IRQF_SHARED;
236 } else
237 irq = gpio_to_irq(gpio);
238
239 /* if data line pullup is in use, initialize it to "not pulling up" */
240 gpio = pdata->gpio_pullup;
241 if (gpio_is_valid(gpio)) {
242 err = gpio_request(gpio, "udc_pullup");
243 if (err) {
244 dev_err(&pdev->dev,
245 "can't request pullup gpio %d, err: %d\n",
246 gpio, err);
247 gpio_free(pdata->gpio_vbus);
248 goto err_gpio;
249 }
250 gpio_direction_output(gpio, pdata->gpio_pullup_inverted);
251 }
252
253 err = request_irq(irq, gpio_vbus_irq, VBUS_IRQ_FLAGS,
254 "vbus_detect", pdev);
255 if (err) {
256 dev_err(&pdev->dev, "can't request irq %i, err: %d\n",
257 irq, err);
258 goto err_irq;
259 }
260
261 /* only active when a gadget is registered */
262 err = otg_set_transceiver(&gpio_vbus->otg);
263 if (err) {
264 dev_err(&pdev->dev, "can't register transceiver, err: %d\n",
265 err);
266 goto err_otg;
267 }
268
269 gpio_vbus->vbus_draw = regulator_get(&pdev->dev, "vbus_draw");
270 if (IS_ERR(gpio_vbus->vbus_draw)) {
271 dev_dbg(&pdev->dev, "can't get vbus_draw regulator, err: %ld\n",
272 PTR_ERR(gpio_vbus->vbus_draw));
273 gpio_vbus->vbus_draw = NULL;
274 }
275
276 return 0;
277err_otg:
278 free_irq(irq, &pdev->dev);
279err_irq:
280 if (gpio_is_valid(pdata->gpio_pullup))
281 gpio_free(pdata->gpio_pullup);
282 gpio_free(pdata->gpio_vbus);
283err_gpio:
284 platform_set_drvdata(pdev, NULL);
285 kfree(gpio_vbus);
286 return err;
287}
288
289static int __exit gpio_vbus_remove(struct platform_device *pdev)
290{
291 struct gpio_vbus_data *gpio_vbus = platform_get_drvdata(pdev);
292 struct gpio_vbus_mach_info *pdata = pdev->dev.platform_data;
293 int gpio = pdata->gpio_vbus;
294
295 regulator_put(gpio_vbus->vbus_draw);
296
297 otg_set_transceiver(NULL);
298
299 free_irq(gpio_to_irq(gpio), &pdev->dev);
300 if (gpio_is_valid(pdata->gpio_pullup))
301 gpio_free(pdata->gpio_pullup);
302 gpio_free(gpio);
303 platform_set_drvdata(pdev, NULL);
304 kfree(gpio_vbus);
305
306 return 0;
307}
308
309/* NOTE: the gpio-vbus device may *NOT* be hotplugged */
310
311MODULE_ALIAS("platform:gpio-vbus");
312
313static struct platform_driver gpio_vbus_driver = {
314 .driver = {
315 .name = "gpio-vbus",
316 .owner = THIS_MODULE,
317 },
318 .remove = __exit_p(gpio_vbus_remove),
319};
320
321static int __init gpio_vbus_init(void)
322{
323 return platform_driver_probe(&gpio_vbus_driver, gpio_vbus_probe);
324}
325module_init(gpio_vbus_init);
326
327static void __exit gpio_vbus_exit(void)
328{
329 platform_driver_unregister(&gpio_vbus_driver);
330}
331module_exit(gpio_vbus_exit);
332
333MODULE_DESCRIPTION("simple GPIO controlled OTG transceiver driver");
334MODULE_AUTHOR("Philipp Zabel");
335MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/usb/otg/isp1301_omap.c
index e0d56ef2bcb0..e0d56ef2bcb0 100644
--- a/drivers/i2c/chips/isp1301_omap.c
+++ b/drivers/usb/otg/isp1301_omap.c
diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c
new file mode 100644
index 000000000000..ff318fae7d4d
--- /dev/null
+++ b/drivers/usb/otg/otg.c
@@ -0,0 +1,65 @@
1/*
2 * otg.c -- USB OTG utility code
3 *
4 * Copyright (C) 2004 Texas Instruments
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
12#include <linux/kernel.h>
13#include <linux/device.h>
14
15#include <linux/usb/otg.h>
16
17static struct otg_transceiver *xceiv;
18
19/**
20 * otg_get_transceiver - find the (single) OTG transceiver
21 *
22 * Returns the transceiver driver, after getting a refcount to it; or
23 * null if there is no such transceiver. The caller is responsible for
24 * calling otg_put_transceiver() to release that count.
25 *
26 * For use by USB host and peripheral drivers.
27 */
28struct otg_transceiver *otg_get_transceiver(void)
29{
30 if (xceiv)
31 get_device(xceiv->dev);
32 return xceiv;
33}
34EXPORT_SYMBOL(otg_get_transceiver);
35
36/**
37 * otg_put_transceiver - release the (single) OTG transceiver
38 * @x: the transceiver returned by otg_get_transceiver()
39 *
40 * Releases a refcount the caller received from otg_get_transceiver().
41 *
42 * For use by USB host and peripheral drivers.
43 */
44void otg_put_transceiver(struct otg_transceiver *x)
45{
46 put_device(x->dev);
47}
48EXPORT_SYMBOL(otg_put_transceiver);
49
50/**
51 * otg_set_transceiver - declare the (single) OTG transceiver
52 * @x: the USB OTG transceiver to be used; or NULL
53 *
54 * This call is exclusively for use by transceiver drivers, which
55 * coordinate the activities of drivers for host and peripheral
56 * controllers, and in some cases for VBUS current regulation.
57 */
58int otg_set_transceiver(struct otg_transceiver *x)
59{
60 if (xceiv && x)
61 return -EBUSY;
62 xceiv = x;
63 return 0;
64}
65EXPORT_SYMBOL(otg_set_transceiver);
diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c
new file mode 100644
index 000000000000..416e4410be02
--- /dev/null
+++ b/drivers/usb/otg/twl4030-usb.c
@@ -0,0 +1,721 @@
1/*
2 * twl4030_usb - TWL4030 USB transceiver, talking to OMAP OTG controller
3 *
4 * Copyright (C) 2004-2007 Texas Instruments
5 * Copyright (C) 2008 Nokia Corporation
6 * Contact: Felipe Balbi <felipe.balbi@nokia.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 * Current status:
23 * - HS USB ULPI mode works.
24 * - 3-pin mode support may be added in future.
25 */
26
27#include <linux/module.h>
28#include <linux/init.h>
29#include <linux/interrupt.h>
30#include <linux/platform_device.h>
31#include <linux/spinlock.h>
32#include <linux/workqueue.h>
33#include <linux/io.h>
34#include <linux/delay.h>
35#include <linux/usb/otg.h>
36#include <linux/i2c/twl4030.h>
37
38
39/* Register defines */
40
41#define VENDOR_ID_LO 0x00
42#define VENDOR_ID_HI 0x01
43#define PRODUCT_ID_LO 0x02
44#define PRODUCT_ID_HI 0x03
45
46#define FUNC_CTRL 0x04
47#define FUNC_CTRL_SET 0x05
48#define FUNC_CTRL_CLR 0x06
49#define FUNC_CTRL_SUSPENDM (1 << 6)
50#define FUNC_CTRL_RESET (1 << 5)
51#define FUNC_CTRL_OPMODE_MASK (3 << 3) /* bits 3 and 4 */
52#define FUNC_CTRL_OPMODE_NORMAL (0 << 3)
53#define FUNC_CTRL_OPMODE_NONDRIVING (1 << 3)
54#define FUNC_CTRL_OPMODE_DISABLE_BIT_NRZI (2 << 3)
55#define FUNC_CTRL_TERMSELECT (1 << 2)
56#define FUNC_CTRL_XCVRSELECT_MASK (3 << 0) /* bits 0 and 1 */
57#define FUNC_CTRL_XCVRSELECT_HS (0 << 0)
58#define FUNC_CTRL_XCVRSELECT_FS (1 << 0)
59#define FUNC_CTRL_XCVRSELECT_LS (2 << 0)
60#define FUNC_CTRL_XCVRSELECT_FS4LS (3 << 0)
61
62#define IFC_CTRL 0x07
63#define IFC_CTRL_SET 0x08
64#define IFC_CTRL_CLR 0x09
65#define IFC_CTRL_INTERFACE_PROTECT_DISABLE (1 << 7)
66#define IFC_CTRL_AUTORESUME (1 << 4)
67#define IFC_CTRL_CLOCKSUSPENDM (1 << 3)
68#define IFC_CTRL_CARKITMODE (1 << 2)
69#define IFC_CTRL_FSLSSERIALMODE_3PIN (1 << 1)
70
71#define TWL4030_OTG_CTRL 0x0A
72#define TWL4030_OTG_CTRL_SET 0x0B
73#define TWL4030_OTG_CTRL_CLR 0x0C
74#define TWL4030_OTG_CTRL_DRVVBUS (1 << 5)
75#define TWL4030_OTG_CTRL_CHRGVBUS (1 << 4)
76#define TWL4030_OTG_CTRL_DISCHRGVBUS (1 << 3)
77#define TWL4030_OTG_CTRL_DMPULLDOWN (1 << 2)
78#define TWL4030_OTG_CTRL_DPPULLDOWN (1 << 1)
79#define TWL4030_OTG_CTRL_IDPULLUP (1 << 0)
80
81#define USB_INT_EN_RISE 0x0D
82#define USB_INT_EN_RISE_SET 0x0E
83#define USB_INT_EN_RISE_CLR 0x0F
84#define USB_INT_EN_FALL 0x10
85#define USB_INT_EN_FALL_SET 0x11
86#define USB_INT_EN_FALL_CLR 0x12
87#define USB_INT_STS 0x13
88#define USB_INT_LATCH 0x14
89#define USB_INT_IDGND (1 << 4)
90#define USB_INT_SESSEND (1 << 3)
91#define USB_INT_SESSVALID (1 << 2)
92#define USB_INT_VBUSVALID (1 << 1)
93#define USB_INT_HOSTDISCONNECT (1 << 0)
94
95#define CARKIT_CTRL 0x19
96#define CARKIT_CTRL_SET 0x1A
97#define CARKIT_CTRL_CLR 0x1B
98#define CARKIT_CTRL_MICEN (1 << 6)
99#define CARKIT_CTRL_SPKRIGHTEN (1 << 5)
100#define CARKIT_CTRL_SPKLEFTEN (1 << 4)
101#define CARKIT_CTRL_RXDEN (1 << 3)
102#define CARKIT_CTRL_TXDEN (1 << 2)
103#define CARKIT_CTRL_IDGNDDRV (1 << 1)
104#define CARKIT_CTRL_CARKITPWR (1 << 0)
105#define CARKIT_PLS_CTRL 0x22
106#define CARKIT_PLS_CTRL_SET 0x23
107#define CARKIT_PLS_CTRL_CLR 0x24
108#define CARKIT_PLS_CTRL_SPKRRIGHT_BIASEN (1 << 3)
109#define CARKIT_PLS_CTRL_SPKRLEFT_BIASEN (1 << 2)
110#define CARKIT_PLS_CTRL_RXPLSEN (1 << 1)
111#define CARKIT_PLS_CTRL_TXPLSEN (1 << 0)
112
113#define MCPC_CTRL 0x30
114#define MCPC_CTRL_SET 0x31
115#define MCPC_CTRL_CLR 0x32
116#define MCPC_CTRL_RTSOL (1 << 7)
117#define MCPC_CTRL_EXTSWR (1 << 6)
118#define MCPC_CTRL_EXTSWC (1 << 5)
119#define MCPC_CTRL_VOICESW (1 << 4)
120#define MCPC_CTRL_OUT64K (1 << 3)
121#define MCPC_CTRL_RTSCTSSW (1 << 2)
122#define MCPC_CTRL_HS_UART (1 << 0)
123
124#define MCPC_IO_CTRL 0x33
125#define MCPC_IO_CTRL_SET 0x34
126#define MCPC_IO_CTRL_CLR 0x35
127#define MCPC_IO_CTRL_MICBIASEN (1 << 5)
128#define MCPC_IO_CTRL_CTS_NPU (1 << 4)
129#define MCPC_IO_CTRL_RXD_PU (1 << 3)
130#define MCPC_IO_CTRL_TXDTYP (1 << 2)
131#define MCPC_IO_CTRL_CTSTYP (1 << 1)
132#define MCPC_IO_CTRL_RTSTYP (1 << 0)
133
134#define MCPC_CTRL2 0x36
135#define MCPC_CTRL2_SET 0x37
136#define MCPC_CTRL2_CLR 0x38
137#define MCPC_CTRL2_MCPC_CK_EN (1 << 0)
138
139#define OTHER_FUNC_CTRL 0x80
140#define OTHER_FUNC_CTRL_SET 0x81
141#define OTHER_FUNC_CTRL_CLR 0x82
142#define OTHER_FUNC_CTRL_BDIS_ACON_EN (1 << 4)
143#define OTHER_FUNC_CTRL_FIVEWIRE_MODE (1 << 2)
144
145#define OTHER_IFC_CTRL 0x83
146#define OTHER_IFC_CTRL_SET 0x84
147#define OTHER_IFC_CTRL_CLR 0x85
148#define OTHER_IFC_CTRL_OE_INT_EN (1 << 6)
149#define OTHER_IFC_CTRL_CEA2011_MODE (1 << 5)
150#define OTHER_IFC_CTRL_FSLSSERIALMODE_4PIN (1 << 4)
151#define OTHER_IFC_CTRL_HIZ_ULPI_60MHZ_OUT (1 << 3)
152#define OTHER_IFC_CTRL_HIZ_ULPI (1 << 2)
153#define OTHER_IFC_CTRL_ALT_INT_REROUTE (1 << 0)
154
155#define OTHER_INT_EN_RISE 0x86
156#define OTHER_INT_EN_RISE_SET 0x87
157#define OTHER_INT_EN_RISE_CLR 0x88
158#define OTHER_INT_EN_FALL 0x89
159#define OTHER_INT_EN_FALL_SET 0x8A
160#define OTHER_INT_EN_FALL_CLR 0x8B
161#define OTHER_INT_STS 0x8C
162#define OTHER_INT_LATCH 0x8D
163#define OTHER_INT_VB_SESS_VLD (1 << 7)
164#define OTHER_INT_DM_HI (1 << 6) /* not valid for "latch" reg */
165#define OTHER_INT_DP_HI (1 << 5) /* not valid for "latch" reg */
166#define OTHER_INT_BDIS_ACON (1 << 3) /* not valid for "fall" regs */
167#define OTHER_INT_MANU (1 << 1)
168#define OTHER_INT_ABNORMAL_STRESS (1 << 0)
169
170#define ID_STATUS 0x96
171#define ID_RES_FLOAT (1 << 4)
172#define ID_RES_440K (1 << 3)
173#define ID_RES_200K (1 << 2)
174#define ID_RES_102K (1 << 1)
175#define ID_RES_GND (1 << 0)
176
177#define POWER_CTRL 0xAC
178#define POWER_CTRL_SET 0xAD
179#define POWER_CTRL_CLR 0xAE
180#define POWER_CTRL_OTG_ENAB (1 << 5)
181
182#define OTHER_IFC_CTRL2 0xAF
183#define OTHER_IFC_CTRL2_SET 0xB0
184#define OTHER_IFC_CTRL2_CLR 0xB1
185#define OTHER_IFC_CTRL2_ULPI_STP_LOW (1 << 4)
186#define OTHER_IFC_CTRL2_ULPI_TXEN_POL (1 << 3)
187#define OTHER_IFC_CTRL2_ULPI_4PIN_2430 (1 << 2)
188#define OTHER_IFC_CTRL2_USB_INT_OUTSEL_MASK (3 << 0) /* bits 0 and 1 */
189#define OTHER_IFC_CTRL2_USB_INT_OUTSEL_INT1N (0 << 0)
190#define OTHER_IFC_CTRL2_USB_INT_OUTSEL_INT2N (1 << 0)
191
192#define REG_CTRL_EN 0xB2
193#define REG_CTRL_EN_SET 0xB3
194#define REG_CTRL_EN_CLR 0xB4
195#define REG_CTRL_ERROR 0xB5
196#define ULPI_I2C_CONFLICT_INTEN (1 << 0)
197
198#define OTHER_FUNC_CTRL2 0xB8
199#define OTHER_FUNC_CTRL2_SET 0xB9
200#define OTHER_FUNC_CTRL2_CLR 0xBA
201#define OTHER_FUNC_CTRL2_VBAT_TIMER_EN (1 << 0)
202
203/* following registers do not have separate _clr and _set registers */
204#define VBUS_DEBOUNCE 0xC0
205#define ID_DEBOUNCE 0xC1
206#define VBAT_TIMER 0xD3
207#define PHY_PWR_CTRL 0xFD
208#define PHY_PWR_PHYPWD (1 << 0)
209#define PHY_CLK_CTRL 0xFE
210#define PHY_CLK_CTRL_CLOCKGATING_EN (1 << 2)
211#define PHY_CLK_CTRL_CLK32K_EN (1 << 1)
212#define REQ_PHY_DPLL_CLK (1 << 0)
213#define PHY_CLK_CTRL_STS 0xFF
214#define PHY_DPLL_CLK (1 << 0)
215
216/* In module TWL4030_MODULE_PM_MASTER */
217#define PROTECT_KEY 0x0E
218
219/* In module TWL4030_MODULE_PM_RECEIVER */
220#define VUSB_DEDICATED1 0x7D
221#define VUSB_DEDICATED2 0x7E
222#define VUSB1V5_DEV_GRP 0x71
223#define VUSB1V5_TYPE 0x72
224#define VUSB1V5_REMAP 0x73
225#define VUSB1V8_DEV_GRP 0x74
226#define VUSB1V8_TYPE 0x75
227#define VUSB1V8_REMAP 0x76
228#define VUSB3V1_DEV_GRP 0x77
229#define VUSB3V1_TYPE 0x78
230#define VUSB3V1_REMAP 0x79
231
232/* In module TWL4030_MODULE_INTBR */
233#define PMBR1 0x0D
234#define GPIO_USB_4PIN_ULPI_2430C (3 << 0)
235
236
237
238enum linkstat {
239 USB_LINK_UNKNOWN = 0,
240 USB_LINK_NONE,
241 USB_LINK_VBUS,
242 USB_LINK_ID,
243};
244
245struct twl4030_usb {
246 struct otg_transceiver otg;
247 struct device *dev;
248
249 /* for vbus reporting with irqs disabled */
250 spinlock_t lock;
251
252 /* pin configuration */
253 enum twl4030_usb_mode usb_mode;
254
255 int irq;
256 u8 linkstat;
257 u8 asleep;
258 bool irq_enabled;
259};
260
261/* internal define on top of container_of */
262#define xceiv_to_twl(x) container_of((x), struct twl4030_usb, otg);
263
264/*-------------------------------------------------------------------------*/
265
266static int twl4030_i2c_write_u8_verify(struct twl4030_usb *twl,
267 u8 module, u8 data, u8 address)
268{
269 u8 check;
270
271 if ((twl4030_i2c_write_u8(module, data, address) >= 0) &&
272 (twl4030_i2c_read_u8(module, &check, address) >= 0) &&
273 (check == data))
274 return 0;
275 dev_dbg(twl->dev, "Write%d[%d,0x%x] wrote %02x but read %02x\n",
276 1, module, address, check, data);
277
278 /* Failed once: Try again */
279 if ((twl4030_i2c_write_u8(module, data, address) >= 0) &&
280 (twl4030_i2c_read_u8(module, &check, address) >= 0) &&
281 (check == data))
282 return 0;
283 dev_dbg(twl->dev, "Write%d[%d,0x%x] wrote %02x but read %02x\n",
284 2, module, address, check, data);
285
286 /* Failed again: Return error */
287 return -EBUSY;
288}
289
290#define twl4030_usb_write_verify(twl, address, data) \
291 twl4030_i2c_write_u8_verify(twl, TWL4030_MODULE_USB, (data), (address))
292
293static inline int twl4030_usb_write(struct twl4030_usb *twl,
294 u8 address, u8 data)
295{
296 int ret = 0;
297
298 ret = twl4030_i2c_write_u8(TWL4030_MODULE_USB, data, address);
299 if (ret < 0)
300 dev_dbg(twl->dev,
301 "TWL4030:USB:Write[0x%x] Error %d\n", address, ret);
302 return ret;
303}
304
305static inline int twl4030_readb(struct twl4030_usb *twl, u8 module, u8 address)
306{
307 u8 data;
308 int ret = 0;
309
310 ret = twl4030_i2c_read_u8(module, &data, address);
311 if (ret >= 0)
312 ret = data;
313 else
314 dev_dbg(twl->dev,
315 "TWL4030:readb[0x%x,0x%x] Error %d\n",
316 module, address, ret);
317
318 return ret;
319}
320
321static inline int twl4030_usb_read(struct twl4030_usb *twl, u8 address)
322{
323 return twl4030_readb(twl, TWL4030_MODULE_USB, address);
324}
325
326/*-------------------------------------------------------------------------*/
327
328static inline int
329twl4030_usb_set_bits(struct twl4030_usb *twl, u8 reg, u8 bits)
330{
331 return twl4030_usb_write(twl, reg + 1, bits);
332}
333
334static inline int
335twl4030_usb_clear_bits(struct twl4030_usb *twl, u8 reg, u8 bits)
336{
337 return twl4030_usb_write(twl, reg + 2, bits);
338}
339
340/*-------------------------------------------------------------------------*/
341
342static enum linkstat twl4030_usb_linkstat(struct twl4030_usb *twl)
343{
344 int status;
345 int linkstat = USB_LINK_UNKNOWN;
346
347 /* STS_HW_CONDITIONS */
348 status = twl4030_readb(twl, TWL4030_MODULE_PM_MASTER, 0x0f);
349 if (status < 0)
350 dev_err(twl->dev, "USB link status err %d\n", status);
351 else if (status & BIT(7))
352 linkstat = USB_LINK_VBUS;
353 else if (status & BIT(2))
354 linkstat = USB_LINK_ID;
355 else
356 linkstat = USB_LINK_NONE;
357
358 dev_dbg(twl->dev, "HW_CONDITIONS 0x%02x/%d; link %d\n",
359 status, status, linkstat);
360
361 /* REVISIT this assumes host and peripheral controllers
362 * are registered, and that both are active...
363 */
364
365 spin_lock_irq(&twl->lock);
366 twl->linkstat = linkstat;
367 if (linkstat == USB_LINK_ID) {
368 twl->otg.default_a = true;
369 twl->otg.state = OTG_STATE_A_IDLE;
370 } else {
371 twl->otg.default_a = false;
372 twl->otg.state = OTG_STATE_B_IDLE;
373 }
374 spin_unlock_irq(&twl->lock);
375
376 return linkstat;
377}
378
379static void twl4030_usb_set_mode(struct twl4030_usb *twl, int mode)
380{
381 twl->usb_mode = mode;
382
383 switch (mode) {
384 case T2_USB_MODE_ULPI:
385 twl4030_usb_clear_bits(twl, IFC_CTRL, IFC_CTRL_CARKITMODE);
386 twl4030_usb_set_bits(twl, POWER_CTRL, POWER_CTRL_OTG_ENAB);
387 twl4030_usb_clear_bits(twl, FUNC_CTRL,
388 FUNC_CTRL_XCVRSELECT_MASK |
389 FUNC_CTRL_OPMODE_MASK);
390 break;
391 case -1:
392 /* FIXME: power on defaults */
393 break;
394 default:
395 dev_err(twl->dev, "unsupported T2 transceiver mode %d\n",
396 mode);
397 break;
398 };
399}
400
401static void twl4030_i2c_access(struct twl4030_usb *twl, int on)
402{
403 unsigned long timeout;
404 int val = twl4030_usb_read(twl, PHY_CLK_CTRL);
405
406 if (val >= 0) {
407 if (on) {
408 /* enable DPLL to access PHY registers over I2C */
409 val |= REQ_PHY_DPLL_CLK;
410 WARN_ON(twl4030_usb_write_verify(twl, PHY_CLK_CTRL,
411 (u8)val) < 0);
412
413 timeout = jiffies + HZ;
414 while (!(twl4030_usb_read(twl, PHY_CLK_CTRL_STS) &
415 PHY_DPLL_CLK)
416 && time_before(jiffies, timeout))
417 udelay(10);
418 if (!(twl4030_usb_read(twl, PHY_CLK_CTRL_STS) &
419 PHY_DPLL_CLK))
420 dev_err(twl->dev, "Timeout setting T2 HSUSB "
421 "PHY DPLL clock\n");
422 } else {
423 /* let ULPI control the DPLL clock */
424 val &= ~REQ_PHY_DPLL_CLK;
425 WARN_ON(twl4030_usb_write_verify(twl, PHY_CLK_CTRL,
426 (u8)val) < 0);
427 }
428 }
429}
430
431static void twl4030_phy_power(struct twl4030_usb *twl, int on)
432{
433 u8 pwr;
434
435 pwr = twl4030_usb_read(twl, PHY_PWR_CTRL);
436 if (on) {
437 pwr &= ~PHY_PWR_PHYPWD;
438 WARN_ON(twl4030_usb_write_verify(twl, PHY_PWR_CTRL, pwr) < 0);
439 twl4030_usb_write(twl, PHY_CLK_CTRL,
440 twl4030_usb_read(twl, PHY_CLK_CTRL) |
441 (PHY_CLK_CTRL_CLOCKGATING_EN |
442 PHY_CLK_CTRL_CLK32K_EN));
443 } else {
444 pwr |= PHY_PWR_PHYPWD;
445 WARN_ON(twl4030_usb_write_verify(twl, PHY_PWR_CTRL, pwr) < 0);
446 }
447}
448
449static void twl4030_phy_suspend(struct twl4030_usb *twl, int controller_off)
450{
451 if (twl->asleep)
452 return;
453
454 twl4030_phy_power(twl, 0);
455 twl->asleep = 1;
456}
457
458static void twl4030_phy_resume(struct twl4030_usb *twl)
459{
460 if (!twl->asleep)
461 return;
462
463 twl4030_phy_power(twl, 1);
464 twl4030_i2c_access(twl, 1);
465 twl4030_usb_set_mode(twl, twl->usb_mode);
466 if (twl->usb_mode == T2_USB_MODE_ULPI)
467 twl4030_i2c_access(twl, 0);
468 twl->asleep = 0;
469}
470
471static void twl4030_usb_ldo_init(struct twl4030_usb *twl)
472{
473 /* Enable writing to power configuration registers */
474 twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0xC0, PROTECT_KEY);
475 twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0x0C, PROTECT_KEY);
476
477 /* put VUSB3V1 LDO in active state */
478 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);
479
480 /* input to VUSB3V1 LDO is from VBAT, not VBUS */
481 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x14, VUSB_DEDICATED1);
482
483 /* turn on 3.1V regulator */
484 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x20, VUSB3V1_DEV_GRP);
485 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB3V1_TYPE);
486
487 /* turn on 1.5V regulator */
488 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x20, VUSB1V5_DEV_GRP);
489 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V5_TYPE);
490
491 /* turn on 1.8V regulator */
492 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x20, VUSB1V8_DEV_GRP);
493 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V8_TYPE);
494
495 /* disable access to power configuration registers */
496 twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, PROTECT_KEY);
497}
498
499static ssize_t twl4030_usb_vbus_show(struct device *dev,
500 struct device_attribute *attr, char *buf)
501{
502 struct twl4030_usb *twl = dev_get_drvdata(dev);
503 unsigned long flags;
504 int ret = -EINVAL;
505
506 spin_lock_irqsave(&twl->lock, flags);
507 ret = sprintf(buf, "%s\n",
508 (twl->linkstat == USB_LINK_VBUS) ? "on" : "off");
509 spin_unlock_irqrestore(&twl->lock, flags);
510
511 return ret;
512}
513static DEVICE_ATTR(vbus, 0444, twl4030_usb_vbus_show, NULL);
514
515static irqreturn_t twl4030_usb_irq(int irq, void *_twl)
516{
517 struct twl4030_usb *twl = _twl;
518 int status;
519
520#ifdef CONFIG_LOCKDEP
521 /* WORKAROUND for lockdep forcing IRQF_DISABLED on us, which
522 * we don't want and can't tolerate. Although it might be
523 * friendlier not to borrow this thread context...
524 */
525 local_irq_enable();
526#endif
527
528 status = twl4030_usb_linkstat(twl);
529 if (status != USB_LINK_UNKNOWN) {
530
531 /* FIXME add a set_power() method so that B-devices can
532 * configure the charger appropriately. It's not always
533 * correct to consume VBUS power, and how much current to
534 * consume is a function of the USB configuration chosen
535 * by the host.
536 *
537 * REVISIT usb_gadget_vbus_connect(...) as needed, ditto
538 * its disconnect() sibling, when changing to/from the
539 * USB_LINK_VBUS state. musb_hdrc won't care until it
540 * starts to handle softconnect right.
541 */
542 twl4030charger_usb_en(status == USB_LINK_VBUS);
543
544 if (status == USB_LINK_NONE)
545 twl4030_phy_suspend(twl, 0);
546 else
547 twl4030_phy_resume(twl);
548 }
549 sysfs_notify(&twl->dev->kobj, NULL, "vbus");
550
551 return IRQ_HANDLED;
552}
553
554static int twl4030_set_suspend(struct otg_transceiver *x, int suspend)
555{
556 struct twl4030_usb *twl = xceiv_to_twl(x);
557
558 if (suspend)
559 twl4030_phy_suspend(twl, 1);
560 else
561 twl4030_phy_resume(twl);
562
563 return 0;
564}
565
566static int twl4030_set_peripheral(struct otg_transceiver *x,
567 struct usb_gadget *gadget)
568{
569 struct twl4030_usb *twl;
570
571 if (!x)
572 return -ENODEV;
573
574 twl = xceiv_to_twl(x);
575 twl->otg.gadget = gadget;
576 if (!gadget)
577 twl->otg.state = OTG_STATE_UNDEFINED;
578
579 return 0;
580}
581
582static int twl4030_set_host(struct otg_transceiver *x, struct usb_bus *host)
583{
584 struct twl4030_usb *twl;
585
586 if (!x)
587 return -ENODEV;
588
589 twl = xceiv_to_twl(x);
590 twl->otg.host = host;
591 if (!host)
592 twl->otg.state = OTG_STATE_UNDEFINED;
593
594 return 0;
595}
596
597static int __init twl4030_usb_probe(struct platform_device *pdev)
598{
599 struct twl4030_usb_data *pdata = pdev->dev.platform_data;
600 struct twl4030_usb *twl;
601 int status;
602
603 if (!pdata) {
604 dev_dbg(&pdev->dev, "platform_data not available\n");
605 return -EINVAL;
606 }
607
608 twl = kzalloc(sizeof *twl, GFP_KERNEL);
609 if (!twl)
610 return -ENOMEM;
611
612 twl->dev = &pdev->dev;
613 twl->irq = platform_get_irq(pdev, 0);
614 twl->otg.dev = twl->dev;
615 twl->otg.label = "twl4030";
616 twl->otg.set_host = twl4030_set_host;
617 twl->otg.set_peripheral = twl4030_set_peripheral;
618 twl->otg.set_suspend = twl4030_set_suspend;
619 twl->usb_mode = pdata->usb_mode;
620 twl->asleep = 1;
621
622 /* init spinlock for workqueue */
623 spin_lock_init(&twl->lock);
624
625 twl4030_usb_ldo_init(twl);
626 otg_set_transceiver(&twl->otg);
627
628 platform_set_drvdata(pdev, twl);
629 if (device_create_file(&pdev->dev, &dev_attr_vbus))
630 dev_warn(&pdev->dev, "could not create sysfs file\n");
631
632 /* Our job is to use irqs and status from the power module
633 * to keep the transceiver disabled when nothing's connected.
634 *
635 * FIXME we actually shouldn't start enabling it until the
636 * USB controller drivers have said they're ready, by calling
637 * set_host() and/or set_peripheral() ... OTG_capable boards
638 * need both handles, otherwise just one suffices.
639 */
640 twl->irq_enabled = true;
641 status = request_irq(twl->irq, twl4030_usb_irq,
642 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
643 "twl4030_usb", twl);
644 if (status < 0) {
645 dev_dbg(&pdev->dev, "can't get IRQ %d, err %d\n",
646 twl->irq, status);
647 kfree(twl);
648 return status;
649 }
650
651 /* The IRQ handler just handles changes from the previous states
652 * of the ID and VBUS pins ... in probe() we must initialize that
653 * previous state. The easy way: fake an IRQ.
654 *
655 * REVISIT: a real IRQ might have happened already, if PREEMPT is
656 * enabled. Else the IRQ may not yet be configured or enabled,
657 * because of scheduling delays.
658 */
659 twl4030_usb_irq(twl->irq, twl);
660
661 dev_info(&pdev->dev, "Initialized TWL4030 USB module\n");
662 return 0;
663}
664
665static int __exit twl4030_usb_remove(struct platform_device *pdev)
666{
667 struct twl4030_usb *twl = platform_get_drvdata(pdev);
668 int val;
669
670 free_irq(twl->irq, twl);
671 device_remove_file(twl->dev, &dev_attr_vbus);
672
673 /* set transceiver mode to power on defaults */
674 twl4030_usb_set_mode(twl, -1);
675
676 /* autogate 60MHz ULPI clock,
677 * clear dpll clock request for i2c access,
678 * disable 32KHz
679 */
680 val = twl4030_usb_read(twl, PHY_CLK_CTRL);
681 if (val >= 0) {
682 val |= PHY_CLK_CTRL_CLOCKGATING_EN;
683 val &= ~(PHY_CLK_CTRL_CLK32K_EN | REQ_PHY_DPLL_CLK);
684 twl4030_usb_write(twl, PHY_CLK_CTRL, (u8)val);
685 }
686
687 /* disable complete OTG block */
688 twl4030_usb_clear_bits(twl, POWER_CTRL, POWER_CTRL_OTG_ENAB);
689
690 twl4030_phy_power(twl, 0);
691
692 kfree(twl);
693
694 return 0;
695}
696
697static struct platform_driver twl4030_usb_driver = {
698 .probe = twl4030_usb_probe,
699 .remove = __exit_p(twl4030_usb_remove),
700 .driver = {
701 .name = "twl4030_usb",
702 .owner = THIS_MODULE,
703 },
704};
705
706static int __init twl4030_usb_init(void)
707{
708 return platform_driver_register(&twl4030_usb_driver);
709}
710subsys_initcall(twl4030_usb_init);
711
712static void __exit twl4030_usb_exit(void)
713{
714 platform_driver_unregister(&twl4030_usb_driver);
715}
716module_exit(twl4030_usb_exit);
717
718MODULE_ALIAS("platform:twl4030_usb");
719MODULE_AUTHOR("Texas Instruments, Inc, Nokia Corporation");
720MODULE_DESCRIPTION("TWL4030 USB transceiver driver");
721MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index 70338f4ec918..b361f05cafac 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -496,6 +496,14 @@ config USB_SERIAL_SAFE_PADDED
496 bool "USB Secure Encapsulated Driver - Padded" 496 bool "USB Secure Encapsulated Driver - Padded"
497 depends on USB_SERIAL_SAFE 497 depends on USB_SERIAL_SAFE
498 498
499config USB_SERIAL_SIEMENS_MPI
500 tristate "USB Siemens MPI driver"
501 help
502 Say M here if you want to use a Siemens USB/MPI adapter.
503
504 To compile this driver as a module, choose M here: the
505 module will be called siemens_mpi.
506
499config USB_SERIAL_SIERRAWIRELESS 507config USB_SERIAL_SIERRAWIRELESS
500 tristate "USB Sierra Wireless Driver" 508 tristate "USB Sierra Wireless Driver"
501 help 509 help
@@ -565,6 +573,15 @@ config USB_SERIAL_OMNINET
565 To compile this driver as a module, choose M here: the 573 To compile this driver as a module, choose M here: the
566 module will be called omninet. 574 module will be called omninet.
567 575
576config USB_SERIAL_OPTICON
577 tristate "USB Opticon Barcode driver (serial mode)"
578 help
579 Say Y here if you want to use a Opticon USB Barcode device
580 in serial emulation mode.
581
582 To compile this driver as a module, choose M here: the
583 module will be called opticon.
584
568config USB_SERIAL_DEBUG 585config USB_SERIAL_DEBUG
569 tristate "USB Debugging Device" 586 tristate "USB Debugging Device"
570 help 587 help
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 6047f818adfe..b75be91eb8f1 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -41,10 +41,12 @@ obj-$(CONFIG_USB_SERIAL_MOS7840) += mos7840.o
41obj-$(CONFIG_USB_SERIAL_MOTOROLA) += moto_modem.o 41obj-$(CONFIG_USB_SERIAL_MOTOROLA) += moto_modem.o
42obj-$(CONFIG_USB_SERIAL_NAVMAN) += navman.o 42obj-$(CONFIG_USB_SERIAL_NAVMAN) += navman.o
43obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o 43obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o
44obj-$(CONFIG_USB_SERIAL_OPTICON) += opticon.o
44obj-$(CONFIG_USB_SERIAL_OPTION) += option.o 45obj-$(CONFIG_USB_SERIAL_OPTION) += option.o
45obj-$(CONFIG_USB_SERIAL_OTI6858) += oti6858.o 46obj-$(CONFIG_USB_SERIAL_OTI6858) += oti6858.o
46obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o 47obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o
47obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o 48obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o
49obj-$(CONFIG_USB_SERIAL_SIEMENS_MPI) += siemens_mpi.o
48obj-$(CONFIG_USB_SERIAL_SIERRAWIRELESS) += sierra.o 50obj-$(CONFIG_USB_SERIAL_SIERRAWIRELESS) += sierra.o
49obj-$(CONFIG_USB_SERIAL_SPCP8X5) += spcp8x5.o 51obj-$(CONFIG_USB_SERIAL_SPCP8X5) += spcp8x5.o
50obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o 52obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index 69f84f0ea6fe..38ba4ea8b6bf 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -635,8 +635,7 @@ static int digi_write_oob_command(struct usb_serial_port *port,
635 635
636 spin_lock_irqsave(&oob_priv->dp_port_lock, flags); 636 spin_lock_irqsave(&oob_priv->dp_port_lock, flags);
637 while (count > 0) { 637 while (count > 0) {
638 while (oob_port->write_urb->status == -EINPROGRESS 638 while (oob_priv->dp_write_urb_in_use) {
639 || oob_priv->dp_write_urb_in_use) {
640 cond_wait_interruptible_timeout_irqrestore( 639 cond_wait_interruptible_timeout_irqrestore(
641 &oob_port->write_wait, DIGI_RETRY_TIMEOUT, 640 &oob_port->write_wait, DIGI_RETRY_TIMEOUT,
642 &oob_priv->dp_port_lock, flags); 641 &oob_priv->dp_port_lock, flags);
@@ -699,9 +698,8 @@ static int digi_write_inb_command(struct usb_serial_port *port,
699 698
700 spin_lock_irqsave(&priv->dp_port_lock, flags); 699 spin_lock_irqsave(&priv->dp_port_lock, flags);
701 while (count > 0 && ret == 0) { 700 while (count > 0 && ret == 0) {
702 while ((port->write_urb->status == -EINPROGRESS 701 while (priv->dp_write_urb_in_use &&
703 || priv->dp_write_urb_in_use) 702 time_before(jiffies, timeout)) {
704 && time_before(jiffies, timeout)) {
705 cond_wait_interruptible_timeout_irqrestore( 703 cond_wait_interruptible_timeout_irqrestore(
706 &port->write_wait, DIGI_RETRY_TIMEOUT, 704 &port->write_wait, DIGI_RETRY_TIMEOUT,
707 &priv->dp_port_lock, flags); 705 &priv->dp_port_lock, flags);
@@ -779,8 +777,7 @@ static int digi_set_modem_signals(struct usb_serial_port *port,
779 spin_lock_irqsave(&oob_priv->dp_port_lock, flags); 777 spin_lock_irqsave(&oob_priv->dp_port_lock, flags);
780 spin_lock(&port_priv->dp_port_lock); 778 spin_lock(&port_priv->dp_port_lock);
781 779
782 while (oob_port->write_urb->status == -EINPROGRESS || 780 while (oob_priv->dp_write_urb_in_use) {
783 oob_priv->dp_write_urb_in_use) {
784 spin_unlock(&port_priv->dp_port_lock); 781 spin_unlock(&port_priv->dp_port_lock);
785 cond_wait_interruptible_timeout_irqrestore( 782 cond_wait_interruptible_timeout_irqrestore(
786 &oob_port->write_wait, DIGI_RETRY_TIMEOUT, 783 &oob_port->write_wait, DIGI_RETRY_TIMEOUT,
@@ -1168,12 +1165,10 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port,
1168 1165
1169 /* be sure only one write proceeds at a time */ 1166 /* be sure only one write proceeds at a time */
1170 /* there are races on the port private buffer */ 1167 /* there are races on the port private buffer */
1171 /* and races to check write_urb->status */
1172 spin_lock_irqsave(&priv->dp_port_lock, flags); 1168 spin_lock_irqsave(&priv->dp_port_lock, flags);
1173 1169
1174 /* wait for urb status clear to submit another urb */ 1170 /* wait for urb status clear to submit another urb */
1175 if (port->write_urb->status == -EINPROGRESS || 1171 if (priv->dp_write_urb_in_use) {
1176 priv->dp_write_urb_in_use) {
1177 /* buffer data if count is 1 (probably put_char) if possible */ 1172 /* buffer data if count is 1 (probably put_char) if possible */
1178 if (count == 1 && priv->dp_out_buf_len < DIGI_OUT_BUF_SIZE) { 1173 if (count == 1 && priv->dp_out_buf_len < DIGI_OUT_BUF_SIZE) {
1179 priv->dp_out_buf[priv->dp_out_buf_len++] = *buf; 1174 priv->dp_out_buf[priv->dp_out_buf_len++] = *buf;
@@ -1236,7 +1231,7 @@ static void digi_write_bulk_callback(struct urb *urb)
1236 int ret = 0; 1231 int ret = 0;
1237 int status = urb->status; 1232 int status = urb->status;
1238 1233
1239 dbg("digi_write_bulk_callback: TOP, urb->status=%d", status); 1234 dbg("digi_write_bulk_callback: TOP, status=%d", status);
1240 1235
1241 /* port and serial sanity check */ 1236 /* port and serial sanity check */
1242 if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) { 1237 if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) {
@@ -1266,8 +1261,7 @@ static void digi_write_bulk_callback(struct urb *urb)
1266 /* try to send any buffered data on this port, if it is open */ 1261 /* try to send any buffered data on this port, if it is open */
1267 spin_lock(&priv->dp_port_lock); 1262 spin_lock(&priv->dp_port_lock);
1268 priv->dp_write_urb_in_use = 0; 1263 priv->dp_write_urb_in_use = 0;
1269 if (port->port.count && port->write_urb->status != -EINPROGRESS 1264 if (port->port.count && priv->dp_out_buf_len > 0) {
1270 && priv->dp_out_buf_len > 0) {
1271 *((unsigned char *)(port->write_urb->transfer_buffer)) 1265 *((unsigned char *)(port->write_urb->transfer_buffer))
1272 = (unsigned char)DIGI_CMD_SEND_DATA; 1266 = (unsigned char)DIGI_CMD_SEND_DATA;
1273 *((unsigned char *)(port->write_urb->transfer_buffer) + 1) 1267 *((unsigned char *)(port->write_urb->transfer_buffer) + 1)
@@ -1305,8 +1299,7 @@ static int digi_write_room(struct tty_struct *tty)
1305 1299
1306 spin_lock_irqsave(&priv->dp_port_lock, flags); 1300 spin_lock_irqsave(&priv->dp_port_lock, flags);
1307 1301
1308 if (port->write_urb->status == -EINPROGRESS || 1302 if (priv->dp_write_urb_in_use)
1309 priv->dp_write_urb_in_use)
1310 room = 0; 1303 room = 0;
1311 else 1304 else
1312 room = port->bulk_out_size - 2 - priv->dp_out_buf_len; 1305 room = port->bulk_out_size - 2 - priv->dp_out_buf_len;
@@ -1322,8 +1315,7 @@ static int digi_chars_in_buffer(struct tty_struct *tty)
1322 struct usb_serial_port *port = tty->driver_data; 1315 struct usb_serial_port *port = tty->driver_data;
1323 struct digi_port *priv = usb_get_serial_port_data(port); 1316 struct digi_port *priv = usb_get_serial_port_data(port);
1324 1317
1325 if (port->write_urb->status == -EINPROGRESS 1318 if (priv->dp_write_urb_in_use) {
1326 || priv->dp_write_urb_in_use) {
1327 dbg("digi_chars_in_buffer: port=%d, chars=%d", 1319 dbg("digi_chars_in_buffer: port=%d, chars=%d",
1328 priv->dp_port_num, port->bulk_out_size - 2); 1320 priv->dp_port_num, port->bulk_out_size - 2);
1329 /* return(port->bulk_out_size - 2); */ 1321 /* return(port->bulk_out_size - 2); */
@@ -1702,7 +1694,7 @@ static int digi_read_inb_callback(struct urb *urb)
1702 /* short/multiple packet check */ 1694 /* short/multiple packet check */
1703 if (urb->actual_length != len + 2) { 1695 if (urb->actual_length != len + 2) {
1704 dev_err(&port->dev, "%s: INCOMPLETE OR MULTIPLE PACKET, " 1696 dev_err(&port->dev, "%s: INCOMPLETE OR MULTIPLE PACKET, "
1705 "urb->status=%d, port=%d, opcode=%d, len=%d, " 1697 "status=%d, port=%d, opcode=%d, len=%d, "
1706 "actual_length=%d, status=%d\n", __func__, status, 1698 "actual_length=%d, status=%d\n", __func__, status,
1707 priv->dp_port_num, opcode, len, urb->actual_length, 1699 priv->dp_port_num, opcode, len, urb->actual_length,
1708 port_status); 1700 port_status);
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index ef6cfa5a447f..c70a8f667d85 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -2030,7 +2030,7 @@ static void ftdi_process_read(struct work_struct *work)
2030 spin_unlock_irqrestore(&priv->rx_lock, flags); 2030 spin_unlock_irqrestore(&priv->rx_lock, flags);
2031 dbg("%s - deferring remainder until unthrottled", 2031 dbg("%s - deferring remainder until unthrottled",
2032 __func__); 2032 __func__);
2033 return; 2033 goto out;
2034 } 2034 }
2035 spin_unlock_irqrestore(&priv->rx_lock, flags); 2035 spin_unlock_irqrestore(&priv->rx_lock, flags);
2036 /* if the port is closed stop trying to read */ 2036 /* if the port is closed stop trying to read */
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 8e6a66e38db2..a26a0e2cdb4a 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -1056,7 +1056,7 @@ static void garmin_write_bulk_callback(struct urb *urb)
1056 1056
1057 if (status) { 1057 if (status) {
1058 dbg("%s - nonzero write bulk status received: %d", 1058 dbg("%s - nonzero write bulk status received: %d",
1059 __func__, urb->status); 1059 __func__, status);
1060 spin_lock_irqsave(&garmin_data_p->lock, flags); 1060 spin_lock_irqsave(&garmin_data_p->lock, flags);
1061 garmin_data_p->flags |= CLEAR_HALT_REQUIRED; 1061 garmin_data_p->flags |= CLEAR_HALT_REQUIRED;
1062 spin_unlock_irqrestore(&garmin_data_p->lock, flags); 1062 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c
index 3ac59a8a980f..f530032ed93d 100644
--- a/drivers/usb/serial/ipw.c
+++ b/drivers/usb/serial/ipw.c
@@ -473,7 +473,7 @@ static struct usb_serial_driver ipw_device = {
473 473
474 474
475 475
476static int usb_ipw_init(void) 476static int __init usb_ipw_init(void)
477{ 477{
478 int retval; 478 int retval;
479 479
@@ -490,7 +490,7 @@ static int usb_ipw_init(void)
490 return 0; 490 return 0;
491} 491}
492 492
493static void usb_ipw_exit(void) 493static void __exit usb_ipw_exit(void)
494{ 494{
495 usb_deregister(&usb_ipw_driver); 495 usb_deregister(&usb_ipw_driver);
496 usb_serial_deregister(&ipw_device); 496 usb_serial_deregister(&ipw_device);
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index e320972cb227..2314c6ae4fc2 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -190,10 +190,12 @@ static void iuu_rxcmd(struct urb *urb)
190{ 190{
191 struct usb_serial_port *port = urb->context; 191 struct usb_serial_port *port = urb->context;
192 int result; 192 int result;
193 int status = urb->status;
194
193 dbg("%s - enter", __func__); 195 dbg("%s - enter", __func__);
194 196
195 if (urb->status) { 197 if (status) {
196 dbg("%s - urb->status = %d", __func__, urb->status); 198 dbg("%s - status = %d", __func__, status);
197 /* error stop all */ 199 /* error stop all */
198 return; 200 return;
199 } 201 }
@@ -245,10 +247,12 @@ static void iuu_update_status_callback(struct urb *urb)
245 struct usb_serial_port *port = urb->context; 247 struct usb_serial_port *port = urb->context;
246 struct iuu_private *priv = usb_get_serial_port_data(port); 248 struct iuu_private *priv = usb_get_serial_port_data(port);
247 u8 *st; 249 u8 *st;
250 int status = urb->status;
251
248 dbg("%s - enter", __func__); 252 dbg("%s - enter", __func__);
249 253
250 if (urb->status) { 254 if (status) {
251 dbg("%s - urb->status = %d", __func__, urb->status); 255 dbg("%s - status = %d", __func__, status);
252 /* error stop all */ 256 /* error stop all */
253 return; 257 return;
254 } 258 }
@@ -274,9 +278,9 @@ static void iuu_status_callback(struct urb *urb)
274{ 278{
275 struct usb_serial_port *port = urb->context; 279 struct usb_serial_port *port = urb->context;
276 int result; 280 int result;
277 dbg("%s - enter", __func__); 281 int status = urb->status;
278 282
279 dbg("%s - urb->status = %d", __func__, urb->status); 283 dbg("%s - status = %d", __func__, status);
280 usb_fill_bulk_urb(port->read_urb, port->serial->dev, 284 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
281 usb_rcvbulkpipe(port->serial->dev, 285 usb_rcvbulkpipe(port->serial->dev,
282 port->bulk_in_endpointAddress), 286 port->bulk_in_endpointAddress),
@@ -618,11 +622,12 @@ static void read_buf_callback(struct urb *urb)
618 struct usb_serial_port *port = urb->context; 622 struct usb_serial_port *port = urb->context;
619 unsigned char *data = urb->transfer_buffer; 623 unsigned char *data = urb->transfer_buffer;
620 struct tty_struct *tty; 624 struct tty_struct *tty;
621 dbg("%s - urb->status = %d", __func__, urb->status); 625 int status = urb->status;
622 626
623 if (urb->status) { 627 dbg("%s - status = %d", __func__, status);
624 dbg("%s - urb->status = %d", __func__, urb->status); 628
625 if (urb->status == -EPROTO) { 629 if (status) {
630 if (status == -EPROTO) {
626 /* reschedule needed */ 631 /* reschedule needed */
627 } 632 }
628 return; 633 return;
@@ -695,7 +700,7 @@ static void iuu_uart_read_callback(struct urb *urb)
695 struct usb_serial_port *port = urb->context; 700 struct usb_serial_port *port = urb->context;
696 struct iuu_private *priv = usb_get_serial_port_data(port); 701 struct iuu_private *priv = usb_get_serial_port_data(port);
697 unsigned long flags; 702 unsigned long flags;
698 int status; 703 int status = urb->status;
699 int error = 0; 704 int error = 0;
700 int len = 0; 705 int len = 0;
701 unsigned char *data = urb->transfer_buffer; 706 unsigned char *data = urb->transfer_buffer;
@@ -703,8 +708,8 @@ static void iuu_uart_read_callback(struct urb *urb)
703 708
704 dbg("%s - enter", __func__); 709 dbg("%s - enter", __func__);
705 710
706 if (urb->status) { 711 if (status) {
707 dbg("%s - urb->status = %d", __func__, urb->status); 712 dbg("%s - status = %d", __func__, status);
708 /* error stop all */ 713 /* error stop all */
709 return; 714 return;
710 } 715 }
@@ -782,12 +787,11 @@ static void read_rxcmd_callback(struct urb *urb)
782{ 787{
783 struct usb_serial_port *port = urb->context; 788 struct usb_serial_port *port = urb->context;
784 int result; 789 int result;
785 dbg("%s - enter", __func__); 790 int status = urb->status;
786 791
787 dbg("%s - urb->status = %d", __func__, urb->status); 792 dbg("%s - status = %d", __func__, status);
788 793
789 if (urb->status) { 794 if (status) {
790 dbg("%s - urb->status = %d", __func__, urb->status);
791 /* error stop all */ 795 /* error stop all */
792 return; 796 return;
793 } 797 }
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 96a8c7713212..2c20e88a91b3 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -214,6 +214,7 @@ struct moschip_port {
214 spinlock_t pool_lock; 214 spinlock_t pool_lock;
215 struct urb *write_urb_pool[NUM_URBS]; 215 struct urb *write_urb_pool[NUM_URBS];
216 char busy[NUM_URBS]; 216 char busy[NUM_URBS];
217 bool read_urb_busy;
217}; 218};
218 219
219 220
@@ -679,26 +680,30 @@ static void mos7840_bulk_in_callback(struct urb *urb)
679 struct tty_struct *tty; 680 struct tty_struct *tty;
680 int status = urb->status; 681 int status = urb->status;
681 682
682 if (status) {
683 dbg("nonzero read bulk status received: %d", status);
684 return;
685 }
686
687 mos7840_port = urb->context; 683 mos7840_port = urb->context;
688 if (!mos7840_port) { 684 if (!mos7840_port) {
689 dbg("%s", "NULL mos7840_port pointer \n"); 685 dbg("%s", "NULL mos7840_port pointer \n");
686 mos7840_port->read_urb_busy = false;
687 return;
688 }
689
690 if (status) {
691 dbg("nonzero read bulk status received: %d", status);
692 mos7840_port->read_urb_busy = false;
690 return; 693 return;
691 } 694 }
692 695
693 port = (struct usb_serial_port *)mos7840_port->port; 696 port = (struct usb_serial_port *)mos7840_port->port;
694 if (mos7840_port_paranoia_check(port, __func__)) { 697 if (mos7840_port_paranoia_check(port, __func__)) {
695 dbg("%s", "Port Paranoia failed \n"); 698 dbg("%s", "Port Paranoia failed \n");
699 mos7840_port->read_urb_busy = false;
696 return; 700 return;
697 } 701 }
698 702
699 serial = mos7840_get_usb_serial(port, __func__); 703 serial = mos7840_get_usb_serial(port, __func__);
700 if (!serial) { 704 if (!serial) {
701 dbg("%s\n", "Bad serial pointer "); 705 dbg("%s\n", "Bad serial pointer ");
706 mos7840_port->read_urb_busy = false;
702 return; 707 return;
703 } 708 }
704 709
@@ -725,17 +730,19 @@ static void mos7840_bulk_in_callback(struct urb *urb)
725 730
726 if (!mos7840_port->read_urb) { 731 if (!mos7840_port->read_urb) {
727 dbg("%s", "URB KILLED !!!\n"); 732 dbg("%s", "URB KILLED !!!\n");
733 mos7840_port->read_urb_busy = false;
728 return; 734 return;
729 } 735 }
730 736
731 737
732 mos7840_port->read_urb->dev = serial->dev; 738 mos7840_port->read_urb->dev = serial->dev;
733 739
740 mos7840_port->read_urb_busy = true;
734 retval = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); 741 retval = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC);
735 742
736 if (retval) { 743 if (retval) {
737 dbg(" usb_submit_urb(read bulk) failed, retval = %d", 744 dbg("usb_submit_urb(read bulk) failed, retval = %d", retval);
738 retval); 745 mos7840_port->read_urb_busy = false;
739 } 746 }
740} 747}
741 748
@@ -1055,10 +1062,12 @@ static int mos7840_open(struct tty_struct *tty,
1055 1062
1056 dbg("mos7840_open: bulkin endpoint is %d\n", 1063 dbg("mos7840_open: bulkin endpoint is %d\n",
1057 port->bulk_in_endpointAddress); 1064 port->bulk_in_endpointAddress);
1065 mos7840_port->read_urb_busy = true;
1058 response = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL); 1066 response = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL);
1059 if (response) { 1067 if (response) {
1060 dev_err(&port->dev, "%s - Error %d submitting control urb\n", 1068 dev_err(&port->dev, "%s - Error %d submitting control urb\n",
1061 __func__, response); 1069 __func__, response);
1070 mos7840_port->read_urb_busy = false;
1062 } 1071 }
1063 1072
1064 /* initialize our wait queues */ 1073 /* initialize our wait queues */
@@ -1227,6 +1236,7 @@ static void mos7840_close(struct tty_struct *tty,
1227 if (mos7840_port->read_urb) { 1236 if (mos7840_port->read_urb) {
1228 dbg("%s", "Shutdown bulk read\n"); 1237 dbg("%s", "Shutdown bulk read\n");
1229 usb_kill_urb(mos7840_port->read_urb); 1238 usb_kill_urb(mos7840_port->read_urb);
1239 mos7840_port->read_urb_busy = false;
1230 } 1240 }
1231 if ((&mos7840_port->control_urb)) { 1241 if ((&mos7840_port->control_urb)) {
1232 dbg("%s", "Shutdown control read\n"); 1242 dbg("%s", "Shutdown control read\n");
@@ -2043,14 +2053,14 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
2043 Data = 0x0c; 2053 Data = 0x0c;
2044 mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); 2054 mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data);
2045 2055
2046 if (mos7840_port->read_urb->status != -EINPROGRESS) { 2056 if (mos7840_port->read_urb_busy == false) {
2047 mos7840_port->read_urb->dev = serial->dev; 2057 mos7840_port->read_urb->dev = serial->dev;
2048 2058 mos7840_port->read_urb_busy = true;
2049 status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); 2059 status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC);
2050
2051 if (status) { 2060 if (status) {
2052 dbg(" usb_submit_urb(read bulk) failed, status = %d", 2061 dbg("usb_submit_urb(read bulk) failed, status = %d",
2053 status); 2062 status);
2063 mos7840_port->read_urb_busy = false;
2054 } 2064 }
2055 } 2065 }
2056 wake_up(&mos7840_port->delta_msr_wait); 2066 wake_up(&mos7840_port->delta_msr_wait);
@@ -2117,12 +2127,14 @@ static void mos7840_set_termios(struct tty_struct *tty,
2117 return; 2127 return;
2118 } 2128 }
2119 2129
2120 if (mos7840_port->read_urb->status != -EINPROGRESS) { 2130 if (mos7840_port->read_urb_busy == false) {
2121 mos7840_port->read_urb->dev = serial->dev; 2131 mos7840_port->read_urb->dev = serial->dev;
2132 mos7840_port->read_urb_busy = true;
2122 status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); 2133 status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC);
2123 if (status) { 2134 if (status) {
2124 dbg(" usb_submit_urb(read bulk) failed, status = %d", 2135 dbg("usb_submit_urb(read bulk) failed, status = %d",
2125 status); 2136 status);
2137 mos7840_port->read_urb_busy = false;
2126 } 2138 }
2127 } 2139 }
2128 return; 2140 return;
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
new file mode 100644
index 000000000000..cea326f1f105
--- /dev/null
+++ b/drivers/usb/serial/opticon.c
@@ -0,0 +1,358 @@
1/*
2 * Opticon USB barcode to serial driver
3 *
4 * Copyright (C) 2008 Greg Kroah-Hartman <gregkh@suse.de>
5 * Copyright (C) 2008 Novell 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 version
9 * 2 as published by the Free Software Foundation.
10 */
11
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/tty.h>
15#include <linux/tty_driver.h>
16#include <linux/tty_flip.h>
17#include <linux/module.h>
18#include <linux/usb.h>
19#include <linux/usb/serial.h>
20#include <linux/uaccess.h>
21
22static int debug;
23
24static struct usb_device_id id_table[] = {
25 { USB_DEVICE(0x065a, 0x0009) },
26 { },
27};
28MODULE_DEVICE_TABLE(usb, id_table);
29
30/* This structure holds all of the individual device information */
31struct opticon_private {
32 struct usb_device *udev;
33 struct usb_serial *serial;
34 struct usb_serial_port *port;
35 unsigned char *bulk_in_buffer;
36 struct urb *bulk_read_urb;
37 int buffer_size;
38 u8 bulk_address;
39 spinlock_t lock; /* protects the following flags */
40 bool throttled;
41 bool actually_throttled;
42 bool rts;
43};
44
45static void opticon_bulk_callback(struct urb *urb)
46{
47 struct opticon_private *priv = urb->context;
48 unsigned char *data = urb->transfer_buffer;
49 struct usb_serial_port *port = priv->port;
50 int status = urb->status;
51 struct tty_struct *tty;
52 int result;
53 int available_room = 0;
54 int data_length;
55
56 dbg("%s - port %d", __func__, port->number);
57
58 switch (status) {
59 case 0:
60 /* success */
61 break;
62 case -ECONNRESET:
63 case -ENOENT:
64 case -ESHUTDOWN:
65 /* this urb is terminated, clean up */
66 dbg("%s - urb shutting down with status: %d",
67 __func__, status);
68 return;
69 default:
70 dbg("%s - nonzero urb status received: %d",
71 __func__, status);
72 goto exit;
73 }
74
75 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length,
76 data);
77
78 if (urb->actual_length > 2) {
79 data_length = urb->actual_length - 2;
80
81 /*
82 * Data from the device comes with a 2 byte header:
83 *
84 * <0x00><0x00>data...
85 * This is real data to be sent to the tty layer
86 * <0x00><0x01)level
87 * This is a RTS level change, the third byte is the RTS
88 * value (0 for low, 1 for high).
89 */
90 if ((data[0] == 0x00) && (data[1] == 0x00)) {
91 /* real data, send it to the tty layer */
92 tty = tty_port_tty_get(&port->port);
93 if (tty) {
94 available_room = tty_buffer_request_room(tty,
95 data_length);
96 if (available_room) {
97 tty_insert_flip_string(tty, data,
98 available_room);
99 tty_flip_buffer_push(tty);
100 }
101 tty_kref_put(tty);
102 }
103 } else {
104 if ((data[0] == 0x00) && (data[1] == 0x01)) {
105 if (data[2] == 0x00)
106 priv->rts = false;
107 else
108 priv->rts = true;
109 /* FIXME change the RTS level */
110 } else {
111 dev_dbg(&priv->udev->dev,
112 "Unknown data packet received from the device:"
113 " %2x %2x\n",
114 data[0], data[1]);
115 }
116 }
117 } else {
118 dev_dbg(&priv->udev->dev,
119 "Improper ammount of data received from the device, "
120 "%d bytes", urb->actual_length);
121 }
122
123exit:
124 spin_lock(&priv->lock);
125
126 /* Continue trying to always read if we should */
127 if (!priv->throttled) {
128 usb_fill_bulk_urb(priv->bulk_read_urb, priv->udev,
129 usb_rcvbulkpipe(priv->udev,
130 priv->bulk_address),
131 priv->bulk_in_buffer, priv->buffer_size,
132 opticon_bulk_callback, priv);
133 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
134 if (result)
135 dev_err(&port->dev,
136 "%s - failed resubmitting read urb, error %d\n",
137 __func__, result);
138 } else
139 priv->actually_throttled = true;
140 spin_unlock(&priv->lock);
141}
142
143static int opticon_open(struct tty_struct *tty, struct usb_serial_port *port,
144 struct file *filp)
145{
146 struct opticon_private *priv = usb_get_serial_data(port->serial);
147 unsigned long flags;
148 int result = 0;
149
150 dbg("%s - port %d", __func__, port->number);
151
152 spin_lock_irqsave(&priv->lock, flags);
153 priv->throttled = false;
154 priv->actually_throttled = false;
155 priv->port = port;
156 spin_unlock_irqrestore(&priv->lock, flags);
157
158 /*
159 * Force low_latency on so that our tty_push actually forces the data
160 * through, otherwise it is scheduled, and with high data rates (like
161 * with OHCI) data can get lost.
162 */
163 if (tty)
164 tty->low_latency = 1;
165
166 /* Start reading from the device */
167 usb_fill_bulk_urb(priv->bulk_read_urb, priv->udev,
168 usb_rcvbulkpipe(priv->udev,
169 priv->bulk_address),
170 priv->bulk_in_buffer, priv->buffer_size,
171 opticon_bulk_callback, priv);
172 result = usb_submit_urb(priv->bulk_read_urb, GFP_KERNEL);
173 if (result)
174 dev_err(&port->dev,
175 "%s - failed resubmitting read urb, error %d\n",
176 __func__, result);
177 return result;
178}
179
180static void opticon_close(struct tty_struct *tty, struct usb_serial_port *port,
181 struct file *filp)
182{
183 struct opticon_private *priv = usb_get_serial_data(port->serial);
184
185 dbg("%s - port %d", __func__, port->number);
186
187 /* shutdown our urbs */
188 usb_kill_urb(priv->bulk_read_urb);
189}
190
191static void opticon_throttle(struct tty_struct *tty)
192{
193 struct usb_serial_port *port = tty->driver_data;
194 struct opticon_private *priv = usb_get_serial_data(port->serial);
195 unsigned long flags;
196
197 dbg("%s - port %d", __func__, port->number);
198 spin_lock_irqsave(&priv->lock, flags);
199 priv->throttled = true;
200 spin_unlock_irqrestore(&priv->lock, flags);
201}
202
203
204static void opticon_unthrottle(struct tty_struct *tty)
205{
206 struct usb_serial_port *port = tty->driver_data;
207 struct opticon_private *priv = usb_get_serial_data(port->serial);
208 unsigned long flags;
209 int result;
210
211 dbg("%s - port %d", __func__, port->number);
212
213 spin_lock_irqsave(&priv->lock, flags);
214 priv->throttled = false;
215 priv->actually_throttled = false;
216 spin_unlock_irqrestore(&priv->lock, flags);
217
218 priv->bulk_read_urb->dev = port->serial->dev;
219 result = usb_submit_urb(priv->bulk_read_urb, GFP_ATOMIC);
220 if (result)
221 dev_err(&port->dev,
222 "%s - failed submitting read urb, error %d\n",
223 __func__, result);
224}
225
226static int opticon_startup(struct usb_serial *serial)
227{
228 struct opticon_private *priv;
229 struct usb_host_interface *intf;
230 int i;
231 int retval = -ENOMEM;
232 bool bulk_in_found = false;
233
234 /* create our private serial structure */
235 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
236 if (priv == NULL) {
237 dev_err(&serial->dev->dev, "%s - Out of memory\n", __func__);
238 return -ENOMEM;
239 }
240 spin_lock_init(&priv->lock);
241 priv->serial = serial;
242 priv->port = serial->port[0];
243 priv->udev = serial->dev;
244
245 /* find our bulk endpoint */
246 intf = serial->interface->altsetting;
247 for (i = 0; i < intf->desc.bNumEndpoints; ++i) {
248 struct usb_endpoint_descriptor *endpoint;
249
250 endpoint = &intf->endpoint[i].desc;
251 if (!usb_endpoint_is_bulk_in(endpoint))
252 continue;
253
254 priv->bulk_read_urb = usb_alloc_urb(0, GFP_KERNEL);
255 if (!priv->bulk_read_urb) {
256 dev_err(&priv->udev->dev, "out of memory\n");
257 goto error;
258 }
259
260 priv->buffer_size = le16_to_cpu(endpoint->wMaxPacketSize) * 2;
261 priv->bulk_in_buffer = kmalloc(priv->buffer_size, GFP_KERNEL);
262 if (!priv->bulk_in_buffer) {
263 dev_err(&priv->udev->dev, "out of memory\n");
264 goto error;
265 }
266
267 priv->bulk_address = endpoint->bEndpointAddress;
268
269 /* set up our bulk urb */
270 usb_fill_bulk_urb(priv->bulk_read_urb, priv->udev,
271 usb_rcvbulkpipe(priv->udev,
272 endpoint->bEndpointAddress),
273 priv->bulk_in_buffer, priv->buffer_size,
274 opticon_bulk_callback, priv);
275
276 bulk_in_found = true;
277 break;
278 }
279
280 if (!bulk_in_found) {
281 dev_err(&priv->udev->dev,
282 "Error - the proper endpoints were not found!\n");
283 goto error;
284 }
285
286 usb_set_serial_data(serial, priv);
287 return 0;
288
289error:
290 usb_free_urb(priv->bulk_read_urb);
291 kfree(priv->bulk_in_buffer);
292 kfree(priv);
293 return retval;
294}
295
296static void opticon_shutdown(struct usb_serial *serial)
297{
298 struct opticon_private *priv = usb_get_serial_data(serial);
299
300 dbg("%s", __func__);
301
302 usb_kill_urb(priv->bulk_read_urb);
303 usb_free_urb(priv->bulk_read_urb);
304 kfree(priv->bulk_in_buffer);
305 kfree(priv);
306 usb_set_serial_data(serial, NULL);
307}
308
309
310static struct usb_driver opticon_driver = {
311 .name = "opticon",
312 .probe = usb_serial_probe,
313 .disconnect = usb_serial_disconnect,
314 .id_table = id_table,
315 .no_dynamic_id = 1,
316};
317
318static struct usb_serial_driver opticon_device = {
319 .driver = {
320 .owner = THIS_MODULE,
321 .name = "opticon",
322 },
323 .id_table = id_table,
324 .usb_driver = &opticon_driver,
325 .num_ports = 1,
326 .attach = opticon_startup,
327 .open = opticon_open,
328 .close = opticon_close,
329 .shutdown = opticon_shutdown,
330 .throttle = opticon_throttle,
331 .unthrottle = opticon_unthrottle,
332};
333
334static int __init opticon_init(void)
335{
336 int retval;
337
338 retval = usb_serial_register(&opticon_device);
339 if (retval)
340 return retval;
341 retval = usb_register(&opticon_driver);
342 if (retval)
343 usb_serial_deregister(&opticon_device);
344 return retval;
345}
346
347static void __exit opticon_exit(void)
348{
349 usb_deregister(&opticon_driver);
350 usb_serial_deregister(&opticon_device);
351}
352
353module_init(opticon_init);
354module_exit(opticon_exit);
355MODULE_LICENSE("GPL");
356
357module_param(debug, bool, S_IRUGO | S_IWUSR);
358MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 809697b3c7fc..5ed183477aaf 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -522,9 +522,9 @@ static int debug;
522/* per port private data */ 522/* per port private data */
523 523
524#define N_IN_URB 4 524#define N_IN_URB 4
525#define N_OUT_URB 1 525#define N_OUT_URB 4
526#define IN_BUFLEN 4096 526#define IN_BUFLEN 4096
527#define OUT_BUFLEN 128 527#define OUT_BUFLEN 4096
528 528
529struct option_port_private { 529struct option_port_private {
530 /* Input endpoints and buffer for this port */ 530 /* Input endpoints and buffer for this port */
@@ -654,10 +654,6 @@ static int option_write(struct tty_struct *tty, struct usb_serial_port *port,
654 usb_unlink_urb(this_urb); 654 usb_unlink_urb(this_urb);
655 continue; 655 continue;
656 } 656 }
657 if (this_urb->status != 0)
658 dbg("usb_write %p failed (err=%d)",
659 this_urb, this_urb->status);
660
661 dbg("%s: endpoint %d buf %d", __func__, 657 dbg("%s: endpoint %d buf %d", __func__,
662 usb_pipeendpoint(this_urb->pipe), i); 658 usb_pipeendpoint(this_urb->pipe), i);
663 659
@@ -669,8 +665,7 @@ static int option_write(struct tty_struct *tty, struct usb_serial_port *port,
669 err = usb_submit_urb(this_urb, GFP_ATOMIC); 665 err = usb_submit_urb(this_urb, GFP_ATOMIC);
670 if (err) { 666 if (err) {
671 dbg("usb_submit_urb %p (write bulk) failed " 667 dbg("usb_submit_urb %p (write bulk) failed "
672 "(%d, has %d)", this_urb, 668 "(%d)", this_urb, err);
673 err, this_urb->status);
674 clear_bit(i, &portdata->out_busy); 669 clear_bit(i, &portdata->out_busy);
675 continue; 670 continue;
676 } 671 }
diff --git a/drivers/usb/serial/siemens_mpi.c b/drivers/usb/serial/siemens_mpi.c
new file mode 100644
index 000000000000..951ea0c6ba77
--- /dev/null
+++ b/drivers/usb/serial/siemens_mpi.c
@@ -0,0 +1,77 @@
1/*
2 * Siemens USB-MPI Serial USB driver
3 *
4 * Copyright (C) 2005 Thomas Hergenhahn <thomas.hergenhahn@suse.de>
5 * Copyright (C) 2005,2008 Greg Kroah-Hartman <gregkh@suse.de>
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 version
9 * 2 as published by the Free Software Foundation.
10 */
11
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/tty.h>
15#include <linux/module.h>
16#include <linux/usb.h>
17#include <linux/usb/serial.h>
18
19/* Version Information */
20#define DRIVER_VERSION "Version 0.1 09/26/2005"
21#define DRIVER_AUTHOR "Thomas Hergenhahn@web.de http://libnodave.sf.net"
22#define DRIVER_DESC "Driver for Siemens USB/MPI adapter"
23
24
25static struct usb_device_id id_table[] = {
26 /* Vendor and product id for 6ES7-972-0CB20-0XA0 */
27 { USB_DEVICE(0x908, 0x0004) },
28 { },
29};
30MODULE_DEVICE_TABLE(usb, id_table);
31
32static struct usb_driver siemens_usb_mpi_driver = {
33 .name = "siemens_mpi",
34 .probe = usb_serial_probe,
35 .disconnect = usb_serial_disconnect,
36 .id_table = id_table,
37};
38
39static struct usb_serial_driver siemens_usb_mpi_device = {
40 .driver = {
41 .owner = THIS_MODULE,
42 .name = "siemens_mpi",
43 },
44 .id_table = id_table,
45 .num_ports = 1,
46};
47
48static int __init siemens_usb_mpi_init(void)
49{
50 int retval;
51
52 retval = usb_serial_register(&siemens_usb_mpi_device);
53 if (retval)
54 goto failed_usb_serial_register;
55 retval = usb_register(&siemens_usb_mpi_driver);
56 if (retval)
57 goto failed_usb_register;
58 printk(KERN_INFO DRIVER_DESC "\n");
59 printk(KERN_INFO DRIVER_VERSION " " DRIVER_AUTHOR "\n");
60 return retval;
61failed_usb_register:
62 usb_serial_deregister(&siemens_usb_mpi_device);
63failed_usb_serial_register:
64 return retval;
65}
66
67static void __exit siemens_usb_mpi_exit(void)
68{
69 usb_deregister(&siemens_usb_mpi_driver);
70 usb_serial_deregister(&siemens_usb_mpi_device);
71}
72
73module_init(siemens_usb_mpi_init);
74module_exit(siemens_usb_mpi_exit);
75MODULE_AUTHOR(DRIVER_AUTHOR);
76MODULE_DESCRIPTION(DRIVER_DESC);
77MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
index a65bc2bd8e71..5e7528cc81a8 100644
--- a/drivers/usb/serial/spcp8x5.c
+++ b/drivers/usb/serial/spcp8x5.c
@@ -709,21 +709,20 @@ static void spcp8x5_read_bulk_callback(struct urb *urb)
709 unsigned char *data = urb->transfer_buffer; 709 unsigned char *data = urb->transfer_buffer;
710 unsigned long flags; 710 unsigned long flags;
711 int i; 711 int i;
712 int result; 712 int result = urb->status;
713 u8 status = 0; 713 u8 status;
714 char tty_flag; 714 char tty_flag;
715 715
716 dev_dbg(&port->dev, "start, urb->status = %d, " 716 dev_dbg(&port->dev, "start, result = %d, urb->actual_length = %d\n,",
717 "urb->actual_length = %d\n,", urb->status, urb->actual_length); 717 result, urb->actual_length);
718 718
719 /* check the urb status */ 719 /* check the urb status */
720 if (urb->status) { 720 if (result) {
721 if (!port->port.count) 721 if (!port->port.count)
722 return; 722 return;
723 if (urb->status == -EPROTO) { 723 if (result == -EPROTO) {
724 /* spcp8x5 mysteriously fails with -EPROTO */ 724 /* spcp8x5 mysteriously fails with -EPROTO */
725 /* reschedule the read */ 725 /* reschedule the read */
726 urb->status = 0;
727 urb->dev = port->serial->dev; 726 urb->dev = port->serial->dev;
728 result = usb_submit_urb(urb , GFP_ATOMIC); 727 result = usb_submit_urb(urb , GFP_ATOMIC);
729 if (result) 728 if (result)
@@ -833,8 +832,9 @@ static void spcp8x5_write_bulk_callback(struct urb *urb)
833 struct usb_serial_port *port = urb->context; 832 struct usb_serial_port *port = urb->context;
834 struct spcp8x5_private *priv = usb_get_serial_port_data(port); 833 struct spcp8x5_private *priv = usb_get_serial_port_data(port);
835 int result; 834 int result;
835 int status = urb->status;
836 836
837 switch (urb->status) { 837 switch (status) {
838 case 0: 838 case 0:
839 /* success */ 839 /* success */
840 break; 840 break;
@@ -843,14 +843,14 @@ static void spcp8x5_write_bulk_callback(struct urb *urb)
843 case -ESHUTDOWN: 843 case -ESHUTDOWN:
844 /* this urb is terminated, clean up */ 844 /* this urb is terminated, clean up */
845 dev_dbg(&port->dev, "urb shutting down with status: %d\n", 845 dev_dbg(&port->dev, "urb shutting down with status: %d\n",
846 urb->status); 846 status);
847 priv->write_urb_in_use = 0; 847 priv->write_urb_in_use = 0;
848 return; 848 return;
849 default: 849 default:
850 /* error in the urb, so we have to resubmit it */ 850 /* error in the urb, so we have to resubmit it */
851 dbg("%s - Overflow in write", __func__); 851 dbg("%s - Overflow in write", __func__);
852 dbg("%s - nonzero write bulk status received: %d", 852 dbg("%s - nonzero write bulk status received: %d",
853 __func__, urb->status); 853 __func__, status);
854 port->write_urb->transfer_buffer_length = 1; 854 port->write_urb->transfer_buffer_length = 1;
855 port->write_urb->dev = port->serial->dev; 855 port->write_urb->dev = port->serial->dev;
856 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 856 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 01d0c70d60e9..3cf41df302d7 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -145,7 +145,7 @@ static int ti_command_in_sync(struct ti_device *tdev, __u8 command,
145static int ti_write_byte(struct ti_device *tdev, unsigned long addr, 145static int ti_write_byte(struct ti_device *tdev, unsigned long addr,
146 __u8 mask, __u8 byte); 146 __u8 mask, __u8 byte);
147 147
148static int ti_download_firmware(struct ti_device *tdev, int type); 148static int ti_download_firmware(struct ti_device *tdev);
149 149
150/* circular buffer */ 150/* circular buffer */
151static struct circ_buf *ti_buf_alloc(void); 151static struct circ_buf *ti_buf_alloc(void);
@@ -176,9 +176,14 @@ static unsigned int product_5052_count;
176/* the array dimension is the number of default entries plus */ 176/* the array dimension is the number of default entries plus */
177/* TI_EXTRA_VID_PID_COUNT user defined entries plus 1 terminating */ 177/* TI_EXTRA_VID_PID_COUNT user defined entries plus 1 terminating */
178/* null entry */ 178/* null entry */
179static struct usb_device_id ti_id_table_3410[1+TI_EXTRA_VID_PID_COUNT+1] = { 179static struct usb_device_id ti_id_table_3410[7+TI_EXTRA_VID_PID_COUNT+1] = {
180 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) }, 180 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
181 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) }, 181 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
182 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
183 { USB_DEVICE(MTS_VENDOR_ID, MTS_CDMA_NO_FW_PRODUCT_ID) },
184 { USB_DEVICE(MTS_VENDOR_ID, MTS_CDMA_PRODUCT_ID) },
185 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_PRODUCT_ID) },
186 { USB_DEVICE(MTS_VENDOR_ID, MTS_EDGE_PRODUCT_ID) },
182}; 187};
183 188
184static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = { 189static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = {
@@ -188,9 +193,14 @@ static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = {
188 { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) }, 193 { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) },
189}; 194};
190 195
191static struct usb_device_id ti_id_table_combined[] = { 196static struct usb_device_id ti_id_table_combined[6+2*TI_EXTRA_VID_PID_COUNT+1] = {
192 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) }, 197 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
193 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) }, 198 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
199 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
200 { USB_DEVICE(MTS_VENDOR_ID, MTS_CDMA_NO_FW_PRODUCT_ID) },
201 { USB_DEVICE(MTS_VENDOR_ID, MTS_CDMA_PRODUCT_ID) },
202 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_PRODUCT_ID) },
203 { USB_DEVICE(MTS_VENDOR_ID, MTS_EDGE_PRODUCT_ID) },
194 { USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) }, 204 { USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) },
195 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) }, 205 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) },
196 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) }, 206 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) },
@@ -272,6 +282,9 @@ MODULE_LICENSE("GPL");
272 282
273MODULE_FIRMWARE("ti_3410.fw"); 283MODULE_FIRMWARE("ti_3410.fw");
274MODULE_FIRMWARE("ti_5052.fw"); 284MODULE_FIRMWARE("ti_5052.fw");
285MODULE_FIRMWARE("mts_cdma.fw");
286MODULE_FIRMWARE("mts_gsm.fw");
287MODULE_FIRMWARE("mts_edge.fw");
275 288
276module_param(debug, bool, S_IRUGO | S_IWUSR); 289module_param(debug, bool, S_IRUGO | S_IWUSR);
277MODULE_PARM_DESC(debug, "Enable debugging, 0=no, 1=yes"); 290MODULE_PARM_DESC(debug, "Enable debugging, 0=no, 1=yes");
@@ -304,21 +317,28 @@ MODULE_DEVICE_TABLE(usb, ti_id_table_combined);
304 317
305static int __init ti_init(void) 318static int __init ti_init(void)
306{ 319{
307 int i, j; 320 int i, j, c;
308 int ret; 321 int ret;
309 322
310 /* insert extra vendor and product ids */ 323 /* insert extra vendor and product ids */
324 c = ARRAY_SIZE(ti_id_table_combined) - 2 * TI_EXTRA_VID_PID_COUNT - 1;
311 j = ARRAY_SIZE(ti_id_table_3410) - TI_EXTRA_VID_PID_COUNT - 1; 325 j = ARRAY_SIZE(ti_id_table_3410) - TI_EXTRA_VID_PID_COUNT - 1;
312 for (i = 0; i < min(vendor_3410_count, product_3410_count); i++, j++) { 326 for (i = 0; i < min(vendor_3410_count, product_3410_count); i++, j++, c++) {
313 ti_id_table_3410[j].idVendor = vendor_3410[i]; 327 ti_id_table_3410[j].idVendor = vendor_3410[i];
314 ti_id_table_3410[j].idProduct = product_3410[i]; 328 ti_id_table_3410[j].idProduct = product_3410[i];
315 ti_id_table_3410[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE; 329 ti_id_table_3410[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
330 ti_id_table_combined[c].idVendor = vendor_3410[i];
331 ti_id_table_combined[c].idProduct = product_3410[i];
332 ti_id_table_combined[c].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
316 } 333 }
317 j = ARRAY_SIZE(ti_id_table_5052) - TI_EXTRA_VID_PID_COUNT - 1; 334 j = ARRAY_SIZE(ti_id_table_5052) - TI_EXTRA_VID_PID_COUNT - 1;
318 for (i = 0; i < min(vendor_5052_count, product_5052_count); i++, j++) { 335 for (i = 0; i < min(vendor_5052_count, product_5052_count); i++, j++, c++) {
319 ti_id_table_5052[j].idVendor = vendor_5052[i]; 336 ti_id_table_5052[j].idVendor = vendor_5052[i];
320 ti_id_table_5052[j].idProduct = product_5052[i]; 337 ti_id_table_5052[j].idProduct = product_5052[i];
321 ti_id_table_5052[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE; 338 ti_id_table_5052[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
339 ti_id_table_combined[c].idVendor = vendor_5052[i];
340 ti_id_table_combined[c].idProduct = product_5052[i];
341 ti_id_table_combined[c].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
322 } 342 }
323 343
324 ret = usb_serial_register(&ti_1port_device); 344 ret = usb_serial_register(&ti_1port_device);
@@ -390,11 +410,7 @@ static int ti_startup(struct usb_serial *serial)
390 410
391 /* if we have only 1 configuration, download firmware */ 411 /* if we have only 1 configuration, download firmware */
392 if (dev->descriptor.bNumConfigurations == 1) { 412 if (dev->descriptor.bNumConfigurations == 1) {
393 if (tdev->td_is_3410) 413 if ((status = ti_download_firmware(tdev)) != 0)
394 status = ti_download_firmware(tdev, 3410);
395 else
396 status = ti_download_firmware(tdev, 5052);
397 if (status)
398 goto free_tdev; 414 goto free_tdev;
399 415
400 /* 3410 must be reset, 5052 resets itself */ 416 /* 3410 must be reset, 5052 resets itself */
@@ -1671,9 +1687,9 @@ static int ti_do_download(struct usb_device *dev, int pipe,
1671 return status; 1687 return status;
1672} 1688}
1673 1689
1674static int ti_download_firmware(struct ti_device *tdev, int type) 1690static int ti_download_firmware(struct ti_device *tdev)
1675{ 1691{
1676 int status = -ENOMEM; 1692 int status;
1677 int buffer_size; 1693 int buffer_size;
1678 __u8 *buffer; 1694 __u8 *buffer;
1679 struct usb_device *dev = tdev->td_serial->dev; 1695 struct usb_device *dev = tdev->td_serial->dev;
@@ -1681,9 +1697,34 @@ static int ti_download_firmware(struct ti_device *tdev, int type)
1681 tdev->td_serial->port[0]->bulk_out_endpointAddress); 1697 tdev->td_serial->port[0]->bulk_out_endpointAddress);
1682 const struct firmware *fw_p; 1698 const struct firmware *fw_p;
1683 char buf[32]; 1699 char buf[32];
1684 sprintf(buf, "ti_usb-%d.bin", type);
1685 1700
1686 if (request_firmware(&fw_p, buf, &dev->dev)) { 1701 /* try ID specific firmware first, then try generic firmware */
1702 sprintf(buf, "ti_usb-v%04x-p%04x.fw", dev->descriptor.idVendor,
1703 dev->descriptor.idProduct);
1704 if ((status = request_firmware(&fw_p, buf, &dev->dev)) != 0) {
1705 buf[0] = '\0';
1706 if (dev->descriptor.idVendor == MTS_VENDOR_ID) {
1707 switch (dev->descriptor.idProduct) {
1708 case MTS_CDMA_PRODUCT_ID:
1709 strcpy(buf, "mts_cdma.fw");
1710 break;
1711 case MTS_GSM_PRODUCT_ID:
1712 strcpy(buf, "mts_gsm.fw");
1713 break;
1714 case MTS_EDGE_PRODUCT_ID:
1715 strcpy(buf, "mts_edge.fw");
1716 break;
1717 }
1718 }
1719 if (buf[0] == '\0') {
1720 if (tdev->td_is_3410)
1721 strcpy(buf, "ti_3410.fw");
1722 else
1723 strcpy(buf, "ti_5052.fw");
1724 }
1725 status = request_firmware(&fw_p, buf, &dev->dev);
1726 }
1727 if (status) {
1687 dev_err(&dev->dev, "%s - firmware not found\n", __func__); 1728 dev_err(&dev->dev, "%s - firmware not found\n", __func__);
1688 return -ENOENT; 1729 return -ENOENT;
1689 } 1730 }
@@ -1699,6 +1740,8 @@ static int ti_download_firmware(struct ti_device *tdev, int type)
1699 memset(buffer + fw_p->size, 0xff, buffer_size - fw_p->size); 1740 memset(buffer + fw_p->size, 0xff, buffer_size - fw_p->size);
1700 status = ti_do_download(dev, pipe, buffer, fw_p->size); 1741 status = ti_do_download(dev, pipe, buffer, fw_p->size);
1701 kfree(buffer); 1742 kfree(buffer);
1743 } else {
1744 status = -ENOMEM;
1702 } 1745 }
1703 release_firmware(fw_p); 1746 release_firmware(fw_p);
1704 if (status) { 1747 if (status) {
diff --git a/drivers/usb/serial/ti_usb_3410_5052.h b/drivers/usb/serial/ti_usb_3410_5052.h
index b5541bf991ba..7e4752fbf232 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.h
+++ b/drivers/usb/serial/ti_usb_3410_5052.h
@@ -34,6 +34,14 @@
34#define TI_5052_EEPROM_PRODUCT_ID 0x505A /* EEPROM, no firmware */ 34#define TI_5052_EEPROM_PRODUCT_ID 0x505A /* EEPROM, no firmware */
35#define TI_5052_FIRMWARE_PRODUCT_ID 0x505F /* firmware is running */ 35#define TI_5052_FIRMWARE_PRODUCT_ID 0x505F /* firmware is running */
36 36
37/* Multi-Tech vendor and product ids */
38#define MTS_VENDOR_ID 0x06E0
39#define MTS_GSM_NO_FW_PRODUCT_ID 0xF108
40#define MTS_CDMA_NO_FW_PRODUCT_ID 0xF109
41#define MTS_CDMA_PRODUCT_ID 0xF110
42#define MTS_GSM_PRODUCT_ID 0xF111
43#define MTS_EDGE_PRODUCT_ID 0xF112
44
37/* Commands */ 45/* Commands */
38#define TI_GET_VERSION 0x01 46#define TI_GET_VERSION 0x01
39#define TI_GET_PORT_STATUS 0x02 47#define TI_GET_PORT_STATUS 0x02
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 080ade223d53..cfcfd5ab06ce 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -511,9 +511,6 @@ static void usb_serial_port_work(struct work_struct *work)
511 511
512 dbg("%s - port %d", __func__, port->number); 512 dbg("%s - port %d", __func__, port->number);
513 513
514 if (!port)
515 return;
516
517 tty = tty_port_tty_get(&port->port); 514 tty = tty_port_tty_get(&port->port);
518 if (!tty) 515 if (!tty)
519 return; 516 return;
diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c
index fc5d9952b03b..6c9cbb59552a 100644
--- a/drivers/usb/serial/usb_debug.c
+++ b/drivers/usb/serial/usb_debug.c
@@ -31,7 +31,7 @@ static struct usb_driver debug_driver = {
31 .no_dynamic_id = 1, 31 .no_dynamic_id = 1,
32}; 32};
33 33
34int usb_debug_open(struct tty_struct *tty, struct usb_serial_port *port, 34static int usb_debug_open(struct tty_struct *tty, struct usb_serial_port *port,
35 struct file *filp) 35 struct file *filp)
36{ 36{
37 port->bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE; 37 port->bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE;
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig
index c68b738900bd..9df6887b91f6 100644
--- a/drivers/usb/storage/Kconfig
+++ b/drivers/usb/storage/Kconfig
@@ -61,13 +61,6 @@ config USB_STORAGE_ISD200
61 - CyQ've CQ8060A CDRW drive 61 - CyQ've CQ8060A CDRW drive
62 - Planex eXtreme Drive RX-25HU USB-IDE cable (not model RX-25U) 62 - Planex eXtreme Drive RX-25HU USB-IDE cable (not model RX-25U)
63 63
64config USB_STORAGE_DPCM
65 bool "Microtech/ZiO! CompactFlash/SmartMedia support"
66 depends on USB_STORAGE
67 help
68 Say Y here to support the Microtech/ZiO! CompactFlash reader.
69 There is a web page at <http://www.ziocorp.com/products/>.
70
71config USB_STORAGE_USBAT 64config USB_STORAGE_USBAT
72 bool "USBAT/USBAT02-based storage support" 65 bool "USBAT/USBAT02-based storage support"
73 depends on USB_STORAGE 66 depends on USB_STORAGE
@@ -90,12 +83,12 @@ config USB_STORAGE_USBAT
90 - Sandisk ImageMate SDDR-05b 83 - Sandisk ImageMate SDDR-05b
91 84
92config USB_STORAGE_SDDR09 85config USB_STORAGE_SDDR09
93 bool "SanDisk SDDR-09 (and other SmartMedia) support" 86 bool "SanDisk SDDR-09 (and other SmartMedia, including DPCM) support"
94 depends on USB_STORAGE 87 depends on USB_STORAGE
95 help 88 help
96 Say Y here to include additional code to support the Sandisk SDDR-09 89 Say Y here to include additional code to support the Sandisk SDDR-09
97 SmartMedia reader in the USB Mass Storage driver. 90 SmartMedia reader in the USB Mass Storage driver.
98 Also works for the Microtech Zio! SmartMedia reader. 91 Also works for the Microtech Zio! CompactFlash/SmartMedia reader.
99 92
100config USB_STORAGE_SDDR55 93config USB_STORAGE_SDDR55
101 bool "SanDisk SDDR-55 SmartMedia support" 94 bool "SanDisk SDDR-55 SmartMedia support"
diff --git a/drivers/usb/storage/Makefile b/drivers/usb/storage/Makefile
index 7f8beb5366ae..b32069313390 100644
--- a/drivers/usb/storage/Makefile
+++ b/drivers/usb/storage/Makefile
@@ -14,7 +14,6 @@ usb-storage-obj-$(CONFIG_USB_STORAGE_USBAT) += shuttle_usbat.o
14usb-storage-obj-$(CONFIG_USB_STORAGE_SDDR09) += sddr09.o 14usb-storage-obj-$(CONFIG_USB_STORAGE_SDDR09) += sddr09.o
15usb-storage-obj-$(CONFIG_USB_STORAGE_SDDR55) += sddr55.o 15usb-storage-obj-$(CONFIG_USB_STORAGE_SDDR55) += sddr55.o
16usb-storage-obj-$(CONFIG_USB_STORAGE_FREECOM) += freecom.o 16usb-storage-obj-$(CONFIG_USB_STORAGE_FREECOM) += freecom.o
17usb-storage-obj-$(CONFIG_USB_STORAGE_DPCM) += dpcm.o
18usb-storage-obj-$(CONFIG_USB_STORAGE_ISD200) += isd200.o 17usb-storage-obj-$(CONFIG_USB_STORAGE_ISD200) += isd200.o
19usb-storage-obj-$(CONFIG_USB_STORAGE_DATAFAB) += datafab.o 18usb-storage-obj-$(CONFIG_USB_STORAGE_DATAFAB) += datafab.o
20usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += jumpshot.o 19usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += jumpshot.o
@@ -24,7 +23,7 @@ usb-storage-obj-$(CONFIG_USB_STORAGE_KARMA) += karma.o
24usb-storage-obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += cypress_atacb.o 23usb-storage-obj-$(CONFIG_USB_STORAGE_CYPRESS_ATACB) += cypress_atacb.o
25 24
26usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \ 25usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \
27 initializers.o sierra_ms.o $(usb-storage-obj-y) 26 initializers.o sierra_ms.o option_ms.o $(usb-storage-obj-y)
28 27
29ifneq ($(CONFIG_USB_LIBUSUAL),) 28ifneq ($(CONFIG_USB_LIBUSUAL),)
30 obj-$(CONFIG_USB) += libusual.o 29 obj-$(CONFIG_USB) += libusual.o
diff --git a/drivers/usb/storage/dpcm.c b/drivers/usb/storage/dpcm.c
deleted file mode 100644
index 939923471af4..000000000000
--- a/drivers/usb/storage/dpcm.c
+++ /dev/null
@@ -1,86 +0,0 @@
1/* Driver for Microtech DPCM-USB CompactFlash/SmartMedia reader
2 *
3 * DPCM driver v0.1:
4 *
5 * First release
6 *
7 * Current development and maintenance by:
8 * (c) 2000 Brian Webb (webbb@earthlink.net)
9 *
10 * This device contains both a CompactFlash card reader, which
11 * uses the Control/Bulk w/o Interrupt protocol and
12 * a SmartMedia card reader that uses the same protocol
13 * as the SDDR09.
14 *
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the
17 * Free Software Foundation; either version 2, or (at your option) any
18 * later version.
19 *
20 * This program is distributed in the hope that it will be useful, but
21 * WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License along
26 * with this program; if not, write to the Free Software Foundation, Inc.,
27 * 675 Mass Ave, Cambridge, MA 02139, USA.
28 */
29
30#include <scsi/scsi.h>
31#include <scsi/scsi_cmnd.h>
32#include <scsi/scsi_device.h>
33
34#include "usb.h"
35#include "transport.h"
36#include "protocol.h"
37#include "debug.h"
38#include "dpcm.h"
39#include "sddr09.h"
40
41/*
42 * Transport for the Microtech DPCM-USB
43 *
44 */
45int dpcm_transport(struct scsi_cmnd *srb, struct us_data *us)
46{
47 int ret;
48
49 if (srb == NULL)
50 return USB_STOR_TRANSPORT_ERROR;
51
52 US_DEBUGP("dpcm_transport: LUN=%d\n", srb->device->lun);
53
54 switch (srb->device->lun) {
55 case 0:
56
57 /*
58 * LUN 0 corresponds to the CompactFlash card reader.
59 */
60 ret = usb_stor_CB_transport(srb, us);
61 break;
62
63#ifdef CONFIG_USB_STORAGE_SDDR09
64 case 1:
65
66 /*
67 * LUN 1 corresponds to the SmartMedia card reader.
68 */
69
70 /*
71 * Set the LUN to 0 (just in case).
72 */
73 srb->device->lun = 0; us->srb->device->lun = 0;
74 ret = sddr09_transport(srb, us);
75 srb->device->lun = 1; us->srb->device->lun = 1;
76 break;
77
78#endif
79
80 default:
81 US_DEBUGP("dpcm_transport: Invalid LUN %d\n", srb->device->lun);
82 ret = USB_STOR_TRANSPORT_ERROR;
83 break;
84 }
85 return ret;
86}
diff --git a/drivers/usb/storage/dpcm.h b/drivers/usb/storage/dpcm.h
deleted file mode 100644
index e7b7b0f120d7..000000000000
--- a/drivers/usb/storage/dpcm.h
+++ /dev/null
@@ -1,32 +0,0 @@
1/* Driver for Microtech DPCM-USB CompactFlash/SmartMedia reader
2 *
3 * DPCM driver v0.1:
4 *
5 * First release
6 *
7 * Current development and maintenance by:
8 * (c) 2000 Brian Webb (webbb@earthlink.net)
9 *
10 * See dpcm.c for more explanation
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2, or (at your option) any
15 * later version.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 675 Mass Ave, Cambridge, MA 02139, USA.
25 */
26
27#ifndef _MICROTECH_DPCM_USB_H
28#define _MICROTECH_DPCM_USB_H
29
30extern int dpcm_transport(struct scsi_cmnd *srb, struct us_data *us);
31
32#endif
diff --git a/drivers/usb/storage/libusual.c b/drivers/usb/storage/libusual.c
index d617e8ae6b00..f970b27ba308 100644
--- a/drivers/usb/storage/libusual.c
+++ b/drivers/usb/storage/libusual.c
@@ -46,6 +46,12 @@ static int usu_probe_thread(void *arg);
46{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin,bcdDeviceMax), \ 46{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin,bcdDeviceMax), \
47 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } 47 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
48 48
49#define COMPLIANT_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
50 vendorName, productName, useProtocol, useTransport, \
51 initFunction, flags) \
52{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
53 .driver_info = (flags) }
54
49#define USUAL_DEV(useProto, useTrans, useType) \ 55#define USUAL_DEV(useProto, useTrans, useType) \
50{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans), \ 56{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans), \
51 .driver_info = ((useType)<<24) } 57 .driver_info = ((useType)<<24) }
@@ -57,6 +63,7 @@ struct usb_device_id storage_usb_ids [] = {
57 63
58#undef USUAL_DEV 64#undef USUAL_DEV
59#undef UNUSUAL_DEV 65#undef UNUSUAL_DEV
66#undef COMPLIANT_DEV
60 67
61MODULE_DEVICE_TABLE(usb, storage_usb_ids); 68MODULE_DEVICE_TABLE(usb, storage_usb_ids);
62EXPORT_SYMBOL_GPL(storage_usb_ids); 69EXPORT_SYMBOL_GPL(storage_usb_ids);
diff --git a/drivers/usb/storage/option_ms.c b/drivers/usb/storage/option_ms.c
new file mode 100644
index 000000000000..353f922939a4
--- /dev/null
+++ b/drivers/usb/storage/option_ms.c
@@ -0,0 +1,147 @@
1/*
2 * Driver for Option High Speed Mobile Devices.
3 *
4 * (c) 2008 Dan Williams <dcbw@redhat.com>
5 *
6 * Inspiration taken from sierra_ms.c by Kevin Lloyd <klloyd@sierrawireless.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#include <linux/usb.h>
24
25#include "usb.h"
26#include "transport.h"
27#include "option_ms.h"
28#include "debug.h"
29
30#define ZCD_FORCE_MODEM 0x01
31#define ZCD_ALLOW_MS 0x02
32
33static unsigned int option_zero_cd = ZCD_FORCE_MODEM;
34module_param(option_zero_cd, uint, S_IRUGO | S_IWUSR);
35MODULE_PARM_DESC(option_zero_cd, "ZeroCD mode (1=Force Modem (default),"
36 " 2=Allow CD-Rom");
37
38#define RESPONSE_LEN 1024
39
40static int option_rezero(struct us_data *us, int ep_in, int ep_out)
41{
42 const unsigned char rezero_msg[] = {
43 0x55, 0x53, 0x42, 0x43, 0x78, 0x56, 0x34, 0x12,
44 0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x06, 0x01,
45 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
47 };
48 char *buffer;
49 int result;
50
51 US_DEBUGP("Option MS: %s", "DEVICE MODE SWITCH\n");
52
53 buffer = kzalloc(RESPONSE_LEN, GFP_KERNEL);
54 if (buffer == NULL)
55 return USB_STOR_TRANSPORT_ERROR;
56
57 memcpy(buffer, rezero_msg, sizeof (rezero_msg));
58 result = usb_stor_bulk_transfer_buf(us,
59 usb_sndbulkpipe(us->pusb_dev, ep_out),
60 buffer, sizeof (rezero_msg), NULL);
61 if (result != USB_STOR_XFER_GOOD) {
62 result = USB_STOR_XFER_ERROR;
63 goto out;
64 }
65
66 /* Some of the devices need to be asked for a response, but we don't
67 * care what that response is.
68 */
69 result = usb_stor_bulk_transfer_buf(us,
70 usb_sndbulkpipe(us->pusb_dev, ep_out),
71 buffer, RESPONSE_LEN, NULL);
72 result = USB_STOR_XFER_GOOD;
73
74out:
75 kfree(buffer);
76 return result;
77}
78
79int option_ms_init(struct us_data *us)
80{
81 struct usb_device *udev;
82 struct usb_interface *intf;
83 struct usb_host_interface *iface_desc;
84 struct usb_endpoint_descriptor *endpoint = NULL;
85 u8 ep_in = 0, ep_out = 0;
86 int ep_in_size = 0, ep_out_size = 0;
87 int i, result;
88
89 udev = us->pusb_dev;
90 intf = us->pusb_intf;
91
92 /* Ensure it's really a ZeroCD device; devices that are already
93 * in modem mode return 0xFF for class, subclass, and protocol.
94 */
95 if (udev->descriptor.bDeviceClass != 0 ||
96 udev->descriptor.bDeviceSubClass != 0 ||
97 udev->descriptor.bDeviceProtocol != 0)
98 return USB_STOR_TRANSPORT_GOOD;
99
100 US_DEBUGP("Option MS: option_ms_init called\n");
101
102 /* Find the right mass storage interface */
103 iface_desc = intf->cur_altsetting;
104 if (iface_desc->desc.bInterfaceClass != 0x8 ||
105 iface_desc->desc.bInterfaceSubClass != 0x6 ||
106 iface_desc->desc.bInterfaceProtocol != 0x50) {
107 US_DEBUGP("Option MS: mass storage interface not found, no action "
108 "required\n");
109 return USB_STOR_TRANSPORT_GOOD;
110 }
111
112 /* Find the mass storage bulk endpoints */
113 for (i = 0; i < iface_desc->desc.bNumEndpoints && (!ep_in_size || !ep_out_size); ++i) {
114 endpoint = &iface_desc->endpoint[i].desc;
115
116 if (usb_endpoint_is_bulk_in(endpoint)) {
117 ep_in = usb_endpoint_num(endpoint);
118 ep_in_size = le16_to_cpu(endpoint->wMaxPacketSize);
119 } else if (usb_endpoint_is_bulk_out(endpoint)) {
120 ep_out = usb_endpoint_num(endpoint);
121 ep_out_size = le16_to_cpu(endpoint->wMaxPacketSize);
122 }
123 }
124
125 /* Can't find the mass storage endpoints */
126 if (!ep_in_size || !ep_out_size) {
127 US_DEBUGP("Option MS: mass storage endpoints not found, no action "
128 "required\n");
129 return USB_STOR_TRANSPORT_GOOD;
130 }
131
132 /* Force Modem mode */
133 if (option_zero_cd == ZCD_FORCE_MODEM) {
134 US_DEBUGP("Option MS: %s", "Forcing Modem Mode\n");
135 result = option_rezero(us, ep_in, ep_out);
136 if (result != USB_STOR_XFER_GOOD)
137 US_DEBUGP("Option MS: Failed to switch to modem mode.\n");
138 return -EIO;
139 } else if (option_zero_cd == ZCD_ALLOW_MS) {
140 /* Allow Mass Storage mode (keep CD-Rom) */
141 US_DEBUGP("Option MS: %s", "Allowing Mass Storage Mode if device"
142 " requests it\n");
143 }
144
145 return USB_STOR_TRANSPORT_GOOD;
146}
147
diff --git a/drivers/usb/storage/option_ms.h b/drivers/usb/storage/option_ms.h
new file mode 100644
index 000000000000..b6e448cab039
--- /dev/null
+++ b/drivers/usb/storage/option_ms.h
@@ -0,0 +1,4 @@
1#ifndef _OPTION_MS_H_
2#define _OPTION_MS_H_
3extern int option_ms_init(struct us_data *us);
4#endif
diff --git a/drivers/usb/storage/protocol.c b/drivers/usb/storage/protocol.c
index 3b3357e20ea7..be441d84bc64 100644
--- a/drivers/usb/storage/protocol.c
+++ b/drivers/usb/storage/protocol.c
@@ -56,9 +56,9 @@
56 * Protocol routines 56 * Protocol routines
57 ***********************************************************************/ 57 ***********************************************************************/
58 58
59void usb_stor_qic157_command(struct scsi_cmnd *srb, struct us_data *us) 59void usb_stor_pad12_command(struct scsi_cmnd *srb, struct us_data *us)
60{ 60{
61 /* Pad the ATAPI command with zeros 61 /* Pad the SCSI command with zeros out to 12 bytes
62 * 62 *
63 * NOTE: This only works because a scsi_cmnd struct field contains 63 * NOTE: This only works because a scsi_cmnd struct field contains
64 * a unsigned char cmnd[16], so we know we have storage available 64 * a unsigned char cmnd[16], so we know we have storage available
@@ -73,26 +73,6 @@ void usb_stor_qic157_command(struct scsi_cmnd *srb, struct us_data *us)
73 usb_stor_invoke_transport(srb, us); 73 usb_stor_invoke_transport(srb, us);
74} 74}
75 75
76void usb_stor_ATAPI_command(struct scsi_cmnd *srb, struct us_data *us)
77{
78 /* Pad the ATAPI command with zeros
79 *
80 * NOTE: This only works because a scsi_cmnd struct field contains
81 * a unsigned char cmnd[16], so we know we have storage available
82 */
83
84 /* Pad the ATAPI command with zeros */
85 for (; srb->cmd_len<12; srb->cmd_len++)
86 srb->cmnd[srb->cmd_len] = 0;
87
88 /* set command length to 12 bytes */
89 srb->cmd_len = 12;
90
91 /* send the command to the transport layer */
92 usb_stor_invoke_transport(srb, us);
93}
94
95
96void usb_stor_ufi_command(struct scsi_cmnd *srb, struct us_data *us) 76void usb_stor_ufi_command(struct scsi_cmnd *srb, struct us_data *us)
97{ 77{
98 /* fix some commands -- this is a form of mode translation 78 /* fix some commands -- this is a form of mode translation
diff --git a/drivers/usb/storage/protocol.h b/drivers/usb/storage/protocol.h
index 487056ffb516..ffc3e2af0156 100644
--- a/drivers/usb/storage/protocol.h
+++ b/drivers/usb/storage/protocol.h
@@ -40,8 +40,7 @@
40#define _PROTOCOL_H_ 40#define _PROTOCOL_H_
41 41
42/* Protocol handling routines */ 42/* Protocol handling routines */
43extern void usb_stor_ATAPI_command(struct scsi_cmnd*, struct us_data*); 43extern void usb_stor_pad12_command(struct scsi_cmnd*, struct us_data*);
44extern void usb_stor_qic157_command(struct scsi_cmnd*, struct us_data*);
45extern void usb_stor_ufi_command(struct scsi_cmnd*, struct us_data*); 44extern void usb_stor_ufi_command(struct scsi_cmnd*, struct us_data*);
46extern void usb_stor_transparent_scsi_command(struct scsi_cmnd*, 45extern void usb_stor_transparent_scsi_command(struct scsi_cmnd*,
47 struct us_data*); 46 struct us_data*);
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 09779f6a8179..2a42b862aa9f 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -59,6 +59,13 @@
59#include "transport.h" 59#include "transport.h"
60#include "protocol.h" 60#include "protocol.h"
61 61
62/* Vendor IDs for companies that seem to include the READ CAPACITY bug
63 * in all their devices
64 */
65#define VENDOR_ID_NOKIA 0x0421
66#define VENDOR_ID_NIKON 0x04b0
67#define VENDOR_ID_MOTOROLA 0x22b8
68
62/*********************************************************************** 69/***********************************************************************
63 * Host functions 70 * Host functions
64 ***********************************************************************/ 71 ***********************************************************************/
@@ -129,11 +136,35 @@ static int slave_configure(struct scsi_device *sdev)
129 max_sectors); 136 max_sectors);
130 } 137 }
131 138
139 /* Some USB host controllers can't do DMA; they have to use PIO.
140 * They indicate this by setting their dma_mask to NULL. For
141 * such controllers we need to make sure the block layer sets
142 * up bounce buffers in addressable memory.
143 */
144 if (!us->pusb_dev->bus->controller->dma_mask)
145 blk_queue_bounce_limit(sdev->request_queue, BLK_BOUNCE_HIGH);
146
132 /* We can't put these settings in slave_alloc() because that gets 147 /* We can't put these settings in slave_alloc() because that gets
133 * called before the device type is known. Consequently these 148 * called before the device type is known. Consequently these
134 * settings can't be overridden via the scsi devinfo mechanism. */ 149 * settings can't be overridden via the scsi devinfo mechanism. */
135 if (sdev->type == TYPE_DISK) { 150 if (sdev->type == TYPE_DISK) {
136 151
152 /* Some vendors seem to put the READ CAPACITY bug into
153 * all their devices -- primarily makers of cell phones
154 * and digital cameras. Since these devices always use
155 * flash media and can be expected to have an even number
156 * of sectors, we will always enable the CAPACITY_HEURISTICS
157 * flag unless told otherwise. */
158 switch (le16_to_cpu(us->pusb_dev->descriptor.idVendor)) {
159 case VENDOR_ID_NOKIA:
160 case VENDOR_ID_NIKON:
161 case VENDOR_ID_MOTOROLA:
162 if (!(us->fflags & (US_FL_FIX_CAPACITY |
163 US_FL_CAPACITY_OK)))
164 us->fflags |= US_FL_CAPACITY_HEURISTICS;
165 break;
166 }
167
137 /* Disk-type devices use MODE SENSE(6) if the protocol 168 /* Disk-type devices use MODE SENSE(6) if the protocol
138 * (SubClass) is Transparent SCSI, otherwise they use 169 * (SubClass) is Transparent SCSI, otherwise they use
139 * MODE SENSE(10). */ 170 * MODE SENSE(10). */
@@ -170,6 +201,10 @@ static int slave_configure(struct scsi_device *sdev)
170 if (us->fflags & US_FL_CAPACITY_HEURISTICS) 201 if (us->fflags & US_FL_CAPACITY_HEURISTICS)
171 sdev->guess_capacity = 1; 202 sdev->guess_capacity = 1;
172 203
204 /* assume SPC3 or latter devices support sense size > 18 */
205 if (sdev->scsi_level > SCSI_SPC_2)
206 us->fflags |= US_FL_SANE_SENSE;
207
173 /* Some devices report a SCSI revision level above 2 but are 208 /* Some devices report a SCSI revision level above 2 but are
174 * unable to handle the REPORT LUNS command (for which 209 * unable to handle the REPORT LUNS command (for which
175 * support is mandatory at level 3). Since we already have 210 * support is mandatory at level 3). Since we already have
@@ -196,6 +231,14 @@ static int slave_configure(struct scsi_device *sdev)
196 * sector in a larger then 1 sector read, since the performance 231 * sector in a larger then 1 sector read, since the performance
197 * impact is negible we set this flag for all USB disks */ 232 * impact is negible we set this flag for all USB disks */
198 sdev->last_sector_bug = 1; 233 sdev->last_sector_bug = 1;
234
235 /* Enable last-sector hacks for single-target devices using
236 * the Bulk-only transport, unless we already know the
237 * capacity will be decremented or is correct. */
238 if (!(us->fflags & (US_FL_FIX_CAPACITY | US_FL_CAPACITY_OK |
239 US_FL_SCM_MULT_TARG)) &&
240 us->protocol == US_PR_BULK)
241 us->use_last_sector_hacks = 1;
199 } else { 242 } else {
200 243
201 /* Non-disk-type devices don't need to blacklist any pages 244 /* Non-disk-type devices don't need to blacklist any pages
diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c
index c5a54b872c24..531ae5c5abf3 100644
--- a/drivers/usb/storage/sddr09.c
+++ b/drivers/usb/storage/sddr09.c
@@ -45,6 +45,7 @@
45 45
46#include <scsi/scsi.h> 46#include <scsi/scsi.h>
47#include <scsi/scsi_cmnd.h> 47#include <scsi/scsi_cmnd.h>
48#include <scsi/scsi_device.h>
48 49
49#include "usb.h" 50#include "usb.h"
50#include "transport.h" 51#include "transport.h"
@@ -1446,6 +1447,48 @@ usb_stor_sddr09_dpcm_init(struct us_data *us) {
1446} 1447}
1447 1448
1448/* 1449/*
1450 * Transport for the Microtech DPCM-USB
1451 */
1452int dpcm_transport(struct scsi_cmnd *srb, struct us_data *us)
1453{
1454 int ret;
1455
1456 US_DEBUGP("dpcm_transport: LUN=%d\n", srb->device->lun);
1457
1458 switch (srb->device->lun) {
1459 case 0:
1460
1461 /*
1462 * LUN 0 corresponds to the CompactFlash card reader.
1463 */
1464 ret = usb_stor_CB_transport(srb, us);
1465 break;
1466
1467 case 1:
1468
1469 /*
1470 * LUN 1 corresponds to the SmartMedia card reader.
1471 */
1472
1473 /*
1474 * Set the LUN to 0 (just in case).
1475 */
1476 srb->device->lun = 0;
1477 ret = sddr09_transport(srb, us);
1478 srb->device->lun = 1;
1479 break;
1480
1481 default:
1482 US_DEBUGP("dpcm_transport: Invalid LUN %d\n",
1483 srb->device->lun);
1484 ret = USB_STOR_TRANSPORT_ERROR;
1485 break;
1486 }
1487 return ret;
1488}
1489
1490
1491/*
1449 * Transport for the Sandisk SDDR-09 1492 * Transport for the Sandisk SDDR-09
1450 */ 1493 */
1451int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us) 1494int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us)
diff --git a/drivers/usb/storage/sddr09.h b/drivers/usb/storage/sddr09.h
index e50033ad7b19..b701172e12e3 100644
--- a/drivers/usb/storage/sddr09.h
+++ b/drivers/usb/storage/sddr09.h
@@ -28,8 +28,11 @@
28/* Sandisk SDDR-09 stuff */ 28/* Sandisk SDDR-09 stuff */
29 29
30extern int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us); 30extern int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us);
31extern int usb_stor_sddr09_init(struct us_data *us);
32
33/* Microtech DPCM-USB stuff */
31 34
35extern int dpcm_transport(struct scsi_cmnd *srb, struct us_data *us);
32extern int usb_stor_sddr09_dpcm_init(struct us_data *us); 36extern int usb_stor_sddr09_dpcm_init(struct us_data *us);
33extern int usb_stor_sddr09_init(struct us_data *us);
34 37
35#endif 38#endif
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 79108d5d3171..1d5438e6363b 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -57,6 +57,9 @@
57#include "scsiglue.h" 57#include "scsiglue.h"
58#include "debug.h" 58#include "debug.h"
59 59
60#include <linux/blkdev.h>
61#include "../../scsi/sd.h"
62
60 63
61/*********************************************************************** 64/***********************************************************************
62 * Data transfer routines 65 * Data transfer routines
@@ -511,6 +514,110 @@ int usb_stor_bulk_transfer_sg(struct us_data* us, unsigned int pipe,
511 * Transport routines 514 * Transport routines
512 ***********************************************************************/ 515 ***********************************************************************/
513 516
517/* There are so many devices that report the capacity incorrectly,
518 * this routine was written to counteract some of the resulting
519 * problems.
520 */
521static void last_sector_hacks(struct us_data *us, struct scsi_cmnd *srb)
522{
523 struct gendisk *disk;
524 struct scsi_disk *sdkp;
525 u32 sector;
526
527 /* To Report "Medium Error: Record Not Found */
528 static unsigned char record_not_found[18] = {
529 [0] = 0x70, /* current error */
530 [2] = MEDIUM_ERROR, /* = 0x03 */
531 [7] = 0x0a, /* additional length */
532 [12] = 0x14 /* Record Not Found */
533 };
534
535 /* If last-sector problems can't occur, whether because the
536 * capacity was already decremented or because the device is
537 * known to report the correct capacity, then we don't need
538 * to do anything.
539 */
540 if (!us->use_last_sector_hacks)
541 return;
542
543 /* Was this command a READ(10) or a WRITE(10)? */
544 if (srb->cmnd[0] != READ_10 && srb->cmnd[0] != WRITE_10)
545 goto done;
546
547 /* Did this command access the last sector? */
548 sector = (srb->cmnd[2] << 24) | (srb->cmnd[3] << 16) |
549 (srb->cmnd[4] << 8) | (srb->cmnd[5]);
550 disk = srb->request->rq_disk;
551 if (!disk)
552 goto done;
553 sdkp = scsi_disk(disk);
554 if (!sdkp)
555 goto done;
556 if (sector + 1 != sdkp->capacity)
557 goto done;
558
559 if (srb->result == SAM_STAT_GOOD && scsi_get_resid(srb) == 0) {
560
561 /* The command succeeded. If the capacity is odd
562 * (i.e., if the sector number is even) then the
563 * "always-even" heuristic would be wrong for this
564 * device. Issue a WARN() so that the kerneloops.org
565 * project will be notified and we will then know to
566 * mark the device with a CAPACITY_OK flag. Hopefully
567 * this will occur for only a few devices.
568 *
569 * Use the sign of us->last_sector_hacks to tell whether
570 * the warning has already been issued; we don't need
571 * more than one warning per device.
572 */
573 if (!(sector & 1) && us->use_last_sector_hacks > 0) {
574 unsigned vid = le16_to_cpu(
575 us->pusb_dev->descriptor.idVendor);
576 unsigned pid = le16_to_cpu(
577 us->pusb_dev->descriptor.idProduct);
578 unsigned rev = le16_to_cpu(
579 us->pusb_dev->descriptor.bcdDevice);
580
581 WARN(1, "%s: Successful last sector success at %u, "
582 "device %04x:%04x:%04x\n",
583 sdkp->disk->disk_name, sector,
584 vid, pid, rev);
585 us->use_last_sector_hacks = -1;
586 }
587
588 } else {
589 /* The command failed. Allow up to 3 retries in case this
590 * is some normal sort of failure. After that, assume the
591 * capacity is wrong and we're trying to access the sector
592 * beyond the end. Replace the result code and sense data
593 * with values that will cause the SCSI core to fail the
594 * command immediately, instead of going into an infinite
595 * (or even just a very long) retry loop.
596 */
597 if (++us->last_sector_retries < 3)
598 return;
599 srb->result = SAM_STAT_CHECK_CONDITION;
600 memcpy(srb->sense_buffer, record_not_found,
601 sizeof(record_not_found));
602
603 /* In theory we might want to issue a WARN() here if the
604 * capacity is even, since it could indicate the device
605 * has the READ CAPACITY bug _and_ the real capacity is
606 * odd. But it could also indicate that the device
607 * simply can't access its last sector, a failure mode
608 * which is surprisingly common. So no warning.
609 */
610 }
611
612 done:
613 /* Don't reset the retry counter for TEST UNIT READY commands,
614 * because they get issued after device resets which might be
615 * caused by a failed last-sector access.
616 */
617 if (srb->cmnd[0] != TEST_UNIT_READY)
618 us->last_sector_retries = 0;
619}
620
514/* Invoke the transport and basic error-handling/recovery methods 621/* Invoke the transport and basic error-handling/recovery methods
515 * 622 *
516 * This is used by the protocol layers to actually send the message to 623 * This is used by the protocol layers to actually send the message to
@@ -544,6 +651,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
544 /* if the transport provided its own sense data, don't auto-sense */ 651 /* if the transport provided its own sense data, don't auto-sense */
545 if (result == USB_STOR_TRANSPORT_NO_SENSE) { 652 if (result == USB_STOR_TRANSPORT_NO_SENSE) {
546 srb->result = SAM_STAT_CHECK_CONDITION; 653 srb->result = SAM_STAT_CHECK_CONDITION;
654 last_sector_hacks(us, srb);
547 return; 655 return;
548 } 656 }
549 657
@@ -579,6 +687,20 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
579 } 687 }
580 688
581 /* 689 /*
690 * Determine if this device is SAT by seeing if the
691 * command executed successfully. Otherwise we'll have
692 * to wait for at least one CHECK_CONDITION to determine
693 * SANE_SENSE support
694 */
695 if ((srb->cmnd[0] == ATA_16 || srb->cmnd[0] == ATA_12) &&
696 result == USB_STOR_TRANSPORT_GOOD &&
697 !(us->fflags & US_FL_SANE_SENSE) &&
698 !(srb->cmnd[2] & 0x20)) {
699 US_DEBUGP("-- SAT supported, increasing auto-sense\n");
700 us->fflags |= US_FL_SANE_SENSE;
701 }
702
703 /*
582 * A short transfer on a command where we don't expect it 704 * A short transfer on a command where we don't expect it
583 * is unusual, but it doesn't mean we need to auto-sense. 705 * is unusual, but it doesn't mean we need to auto-sense.
584 */ 706 */
@@ -595,10 +717,15 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
595 if (need_auto_sense) { 717 if (need_auto_sense) {
596 int temp_result; 718 int temp_result;
597 struct scsi_eh_save ses; 719 struct scsi_eh_save ses;
720 int sense_size = US_SENSE_SIZE;
721
722 /* device supports and needs bigger sense buffer */
723 if (us->fflags & US_FL_SANE_SENSE)
724 sense_size = ~0;
598 725
599 US_DEBUGP("Issuing auto-REQUEST_SENSE\n"); 726 US_DEBUGP("Issuing auto-REQUEST_SENSE\n");
600 727
601 scsi_eh_prep_cmnd(srb, &ses, NULL, 0, US_SENSE_SIZE); 728 scsi_eh_prep_cmnd(srb, &ses, NULL, 0, sense_size);
602 729
603 /* FIXME: we must do the protocol translation here */ 730 /* FIXME: we must do the protocol translation here */
604 if (us->subclass == US_SC_RBC || us->subclass == US_SC_SCSI || 731 if (us->subclass == US_SC_RBC || us->subclass == US_SC_SCSI ||
@@ -632,6 +759,25 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
632 return; 759 return;
633 } 760 }
634 761
762 /* If the sense data returned is larger than 18-bytes then we
763 * assume this device supports requesting more in the future.
764 * The response code must be 70h through 73h inclusive.
765 */
766 if (srb->sense_buffer[7] > (US_SENSE_SIZE - 8) &&
767 !(us->fflags & US_FL_SANE_SENSE) &&
768 (srb->sense_buffer[0] & 0x7C) == 0x70) {
769 US_DEBUGP("-- SANE_SENSE support enabled\n");
770 us->fflags |= US_FL_SANE_SENSE;
771
772 /* Indicate to the user that we truncated their sense
773 * because we didn't know it supported larger sense.
774 */
775 US_DEBUGP("-- Sense data truncated to %i from %i\n",
776 US_SENSE_SIZE,
777 srb->sense_buffer[7] + 8);
778 srb->sense_buffer[7] = (US_SENSE_SIZE - 8);
779 }
780
635 US_DEBUGP("-- Result from auto-sense is %d\n", temp_result); 781 US_DEBUGP("-- Result from auto-sense is %d\n", temp_result);
636 US_DEBUGP("-- code: 0x%x, key: 0x%x, ASC: 0x%x, ASCQ: 0x%x\n", 782 US_DEBUGP("-- code: 0x%x, key: 0x%x, ASC: 0x%x, ASCQ: 0x%x\n",
637 srb->sense_buffer[0], 783 srb->sense_buffer[0],
@@ -667,6 +813,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
667 scsi_bufflen(srb) - scsi_get_resid(srb) < srb->underflow) 813 scsi_bufflen(srb) - scsi_get_resid(srb) < srb->underflow)
668 srb->result = (DID_ERROR << 16) | (SUGGEST_RETRY << 24); 814 srb->result = (DID_ERROR << 16) | (SUGGEST_RETRY << 24);
669 815
816 last_sector_hacks(us, srb);
670 return; 817 return;
671 818
672 /* Error and abort processing: try to resynchronize with the device 819 /* Error and abort processing: try to resynchronize with the device
@@ -694,6 +841,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
694 us->transport_reset(us); 841 us->transport_reset(us);
695 } 842 }
696 clear_bit(US_FLIDX_RESETTING, &us->dflags); 843 clear_bit(US_FLIDX_RESETTING, &us->dflags);
844 last_sector_hacks(us, srb);
697} 845}
698 846
699/* Stop the current URB transfer */ 847/* Stop the current URB transfer */
@@ -718,10 +866,10 @@ void usb_stor_stop_transport(struct us_data *us)
718} 866}
719 867
720/* 868/*
721 * Control/Bulk/Interrupt transport 869 * Control/Bulk and Control/Bulk/Interrupt transport
722 */ 870 */
723 871
724int usb_stor_CBI_transport(struct scsi_cmnd *srb, struct us_data *us) 872int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us)
725{ 873{
726 unsigned int transfer_length = scsi_bufflen(srb); 874 unsigned int transfer_length = scsi_bufflen(srb);
727 unsigned int pipe = 0; 875 unsigned int pipe = 0;
@@ -763,6 +911,13 @@ int usb_stor_CBI_transport(struct scsi_cmnd *srb, struct us_data *us)
763 } 911 }
764 912
765 /* STATUS STAGE */ 913 /* STATUS STAGE */
914
915 /* NOTE: CB does not have a status stage. Silly, I know. So
916 * we have to catch this at a higher level.
917 */
918 if (us->protocol != US_PR_CBI)
919 return USB_STOR_TRANSPORT_GOOD;
920
766 result = usb_stor_intr_transfer(us, us->iobuf, 2); 921 result = usb_stor_intr_transfer(us, us->iobuf, 2);
767 US_DEBUGP("Got interrupt data (0x%x, 0x%x)\n", 922 US_DEBUGP("Got interrupt data (0x%x, 0x%x)\n",
768 us->iobuf[0], us->iobuf[1]); 923 us->iobuf[0], us->iobuf[1]);
@@ -817,56 +972,6 @@ int usb_stor_CBI_transport(struct scsi_cmnd *srb, struct us_data *us)
817} 972}
818 973
819/* 974/*
820 * Control/Bulk transport
821 */
822int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us)
823{
824 unsigned int transfer_length = scsi_bufflen(srb);
825 int result;
826
827 /* COMMAND STAGE */
828 /* let's send the command via the control pipe */
829 result = usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
830 US_CBI_ADSC,
831 USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0,
832 us->ifnum, srb->cmnd, srb->cmd_len);
833
834 /* check the return code for the command */
835 US_DEBUGP("Call to usb_stor_ctrl_transfer() returned %d\n", result);
836
837 /* if we stalled the command, it means command failed */
838 if (result == USB_STOR_XFER_STALLED) {
839 return USB_STOR_TRANSPORT_FAILED;
840 }
841
842 /* Uh oh... serious problem here */
843 if (result != USB_STOR_XFER_GOOD) {
844 return USB_STOR_TRANSPORT_ERROR;
845 }
846
847 /* DATA STAGE */
848 /* transfer the data payload for this command, if one exists*/
849 if (transfer_length) {
850 unsigned int pipe = srb->sc_data_direction == DMA_FROM_DEVICE ?
851 us->recv_bulk_pipe : us->send_bulk_pipe;
852 result = usb_stor_bulk_srb(us, pipe, srb);
853 US_DEBUGP("CB data stage result is 0x%x\n", result);
854
855 /* if we stalled the data transfer it means command failed */
856 if (result == USB_STOR_XFER_STALLED)
857 return USB_STOR_TRANSPORT_FAILED;
858 if (result > USB_STOR_XFER_STALLED)
859 return USB_STOR_TRANSPORT_ERROR;
860 }
861
862 /* STATUS STAGE */
863 /* NOTE: CB does not have a status stage. Silly, I know. So
864 * we have to catch this at a higher level.
865 */
866 return USB_STOR_TRANSPORT_GOOD;
867}
868
869/*
870 * Bulk only transport 975 * Bulk only transport
871 */ 976 */
872 977
@@ -1173,10 +1278,9 @@ int usb_stor_Bulk_reset(struct us_data *us)
1173 */ 1278 */
1174int usb_stor_port_reset(struct us_data *us) 1279int usb_stor_port_reset(struct us_data *us)
1175{ 1280{
1176 int result, rc_lock; 1281 int result;
1177 1282
1178 result = rc_lock = 1283 result = usb_lock_device_for_reset(us->pusb_dev, us->pusb_intf);
1179 usb_lock_device_for_reset(us->pusb_dev, us->pusb_intf);
1180 if (result < 0) 1284 if (result < 0)
1181 US_DEBUGP("unable to lock device for reset: %d\n", result); 1285 US_DEBUGP("unable to lock device for reset: %d\n", result);
1182 else { 1286 else {
@@ -1189,8 +1293,7 @@ int usb_stor_port_reset(struct us_data *us)
1189 US_DEBUGP("usb_reset_device returns %d\n", 1293 US_DEBUGP("usb_reset_device returns %d\n",
1190 result); 1294 result);
1191 } 1295 }
1192 if (rc_lock) 1296 usb_unlock_device(us->pusb_dev);
1193 usb_unlock_device(us->pusb_dev);
1194 } 1297 }
1195 return result; 1298 return result;
1196} 1299}
diff --git a/drivers/usb/storage/transport.h b/drivers/usb/storage/transport.h
index e70b88182f0e..242ff5e791a5 100644
--- a/drivers/usb/storage/transport.h
+++ b/drivers/usb/storage/transport.h
@@ -113,8 +113,6 @@ struct bulk_cs_wrap {
113 113
114#define US_CBI_ADSC 0 114#define US_CBI_ADSC 0
115 115
116extern int usb_stor_CBI_transport(struct scsi_cmnd *, struct us_data*);
117
118extern int usb_stor_CB_transport(struct scsi_cmnd *, struct us_data*); 116extern int usb_stor_CB_transport(struct scsi_cmnd *, struct us_data*);
119extern int usb_stor_CB_reset(struct us_data*); 117extern int usb_stor_CB_reset(struct us_data*);
120 118
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index bfcc1fe82518..a7f9513fa19d 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -27,7 +27,8 @@
27 27
28/* IMPORTANT NOTE: This file must be included in another file which does 28/* IMPORTANT NOTE: This file must be included in another file which does
29 * the following thing for it to work: 29 * the following thing for it to work:
30 * The macro UNUSUAL_DEV() must be defined before this file is included 30 * The UNUSUAL_DEV, COMPLIANT_DEV, and USUAL_DEV macros must be defined
31 * before this file is included.
31 */ 32 */
32 33
33/* If you edit this file, please try to keep it sorted first by VendorID, 34/* If you edit this file, please try to keep it sorted first by VendorID,
@@ -46,6 +47,12 @@
46 * <usb-storage@lists.one-eyed-alien.net> 47 * <usb-storage@lists.one-eyed-alien.net>
47 */ 48 */
48 49
50/* Note: If you add an entry only in order to set the CAPACITY_OK flag,
51 * use the COMPLIANT_DEV macro instead of UNUSUAL_DEV. This is
52 * because such entries mark devices which actually work correctly,
53 * as opposed to devices that do something strangely or wrongly.
54 */
55
49/* patch submitted by Vivian Bregier <Vivian.Bregier@imag.fr> 56/* patch submitted by Vivian Bregier <Vivian.Bregier@imag.fr>
50 */ 57 */
51UNUSUAL_DEV( 0x03eb, 0x2002, 0x0100, 0x0100, 58UNUSUAL_DEV( 0x03eb, 0x2002, 0x0100, 0x0100,
@@ -85,6 +92,13 @@ UNUSUAL_DEV( 0x03f0, 0x0307, 0x0001, 0x0001,
85 US_SC_8070, US_PR_USBAT, init_usbat_cd, 0), 92 US_SC_8070, US_PR_USBAT, init_usbat_cd, 0),
86#endif 93#endif
87 94
95/* Reported by Ben Efros <ben@pc-doctor.com> */
96UNUSUAL_DEV( 0x03f0, 0x070c, 0x0000, 0x0000,
97 "HP",
98 "Personal Media Drive",
99 US_SC_DEVICE, US_PR_DEVICE, NULL,
100 US_FL_SANE_SENSE ),
101
88/* Reported by Grant Grundler <grundler@parisc-linux.org> 102/* Reported by Grant Grundler <grundler@parisc-linux.org>
89 * HP r707 camera in "Disk" mode with 2.00.23 or 2.00.24 firmware. 103 * HP r707 camera in "Disk" mode with 2.00.23 or 2.00.24 firmware.
90 */ 104 */
@@ -160,34 +174,6 @@ UNUSUAL_DEV( 0x0421, 0x0019, 0x0592, 0x0592,
160 US_SC_DEVICE, US_PR_DEVICE, NULL, 174 US_SC_DEVICE, US_PR_DEVICE, NULL,
161 US_FL_MAX_SECTORS_64 ), 175 US_FL_MAX_SECTORS_64 ),
162 176
163/* Reported by Filip Joelsson <filip@blueturtle.nu> */
164UNUSUAL_DEV( 0x0421, 0x005d, 0x0001, 0x0600,
165 "Nokia",
166 "Nokia 3110c",
167 US_SC_DEVICE, US_PR_DEVICE, NULL,
168 US_FL_FIX_CAPACITY ),
169
170/* Reported by Ozan Sener <themgzzy@gmail.com> */
171UNUSUAL_DEV( 0x0421, 0x0060, 0x0551, 0x0551,
172 "Nokia",
173 "3500c",
174 US_SC_DEVICE, US_PR_DEVICE, NULL,
175 US_FL_FIX_CAPACITY ),
176
177/* Reported by CSECSY Laszlo <boobaa@frugalware.org> */
178UNUSUAL_DEV( 0x0421, 0x0063, 0x0001, 0x0601,
179 "Nokia",
180 "Nokia 3109c",
181 US_SC_DEVICE, US_PR_DEVICE, NULL,
182 US_FL_FIX_CAPACITY ),
183
184/* Patch for Nokia 5310 capacity */
185UNUSUAL_DEV( 0x0421, 0x006a, 0x0000, 0x0701,
186 "Nokia",
187 "5310",
188 US_SC_DEVICE, US_PR_DEVICE, NULL,
189 US_FL_FIX_CAPACITY ),
190
191/* Reported by Mario Rettig <mariorettig@web.de> */ 177/* Reported by Mario Rettig <mariorettig@web.de> */
192UNUSUAL_DEV( 0x0421, 0x042e, 0x0100, 0x0100, 178UNUSUAL_DEV( 0x0421, 0x042e, 0x0100, 0x0100,
193 "Nokia", 179 "Nokia",
@@ -253,35 +239,6 @@ UNUSUAL_DEV( 0x0421, 0x0495, 0x0370, 0x0370,
253 US_SC_DEVICE, US_PR_DEVICE, NULL, 239 US_SC_DEVICE, US_PR_DEVICE, NULL,
254 US_FL_MAX_SECTORS_64 ), 240 US_FL_MAX_SECTORS_64 ),
255 241
256/* Reported by Cedric Godin <cedric@belbone.be> */
257UNUSUAL_DEV( 0x0421, 0x04b9, 0x0500, 0x0551,
258 "Nokia",
259 "5300",
260 US_SC_DEVICE, US_PR_DEVICE, NULL,
261 US_FL_FIX_CAPACITY ),
262
263/* Reported by Richard Nauber <RichardNauber@web.de> */
264UNUSUAL_DEV( 0x0421, 0x04fa, 0x0550, 0x0660,
265 "Nokia",
266 "6300",
267 US_SC_DEVICE, US_PR_DEVICE, NULL,
268 US_FL_FIX_CAPACITY ),
269
270/* Patch for Nokia 5310 capacity */
271UNUSUAL_DEV( 0x0421, 0x006a, 0x0000, 0x0591,
272 "Nokia",
273 "5310",
274 US_SC_DEVICE, US_PR_DEVICE, NULL,
275 US_FL_FIX_CAPACITY ),
276
277/* Submitted by Ricky Wong Yung Fei <evilbladewarrior@gmail.com> */
278/* Nokia 7610 Supernova - Too many sectors reported in usb storage mode */
279UNUSUAL_DEV( 0x0421, 0x00f5, 0x0000, 0x0470,
280 "Nokia",
281 "7610 Supernova",
282 US_SC_DEVICE, US_PR_DEVICE, NULL,
283 US_FL_FIX_CAPACITY ),
284
285/* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */ 242/* Reported by Olaf Hering <olh@suse.de> from novell bug #105878 */
286UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210, 243UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210,
287 "SMSC", 244 "SMSC",
@@ -289,11 +246,17 @@ UNUSUAL_DEV( 0x0424, 0x0fdc, 0x0210, 0x0210,
289 US_SC_DEVICE, US_PR_DEVICE, NULL, 246 US_SC_DEVICE, US_PR_DEVICE, NULL,
290 US_FL_SINGLE_LUN ), 247 US_FL_SINGLE_LUN ),
291 248
292#ifdef CONFIG_USB_STORAGE_DPCM 249#ifdef CONFIG_USB_STORAGE_SDDR09
293UNUSUAL_DEV( 0x0436, 0x0005, 0x0100, 0x0100, 250UNUSUAL_DEV( 0x0436, 0x0005, 0x0100, 0x0100,
294 "Microtech", 251 "Microtech",
295 "CameraMate (DPCM_USB)", 252 "CameraMate (DPCM_USB)",
296 US_SC_SCSI, US_PR_DPCM_USB, NULL, 0 ), 253 US_SC_SCSI, US_PR_DPCM_USB, NULL, 0 ),
254#else
255UNUSUAL_DEV( 0x0436, 0x0005, 0x0100, 0x0100,
256 "Microtech",
257 "CameraMate",
258 US_SC_SCSI, US_PR_CB, NULL,
259 US_FL_SINGLE_LUN ),
297#endif 260#endif
298 261
299/* Patch submitted by Daniel Drake <dsd@gentoo.org> 262/* Patch submitted by Daniel Drake <dsd@gentoo.org>
@@ -388,6 +351,15 @@ UNUSUAL_DEV( 0x04a4, 0x0004, 0x0001, 0x0001,
388 "DVD-CAM DZ-MV100A Camcorder", 351 "DVD-CAM DZ-MV100A Camcorder",
389 US_SC_SCSI, US_PR_CB, NULL, US_FL_SINGLE_LUN), 352 US_SC_SCSI, US_PR_CB, NULL, US_FL_SINGLE_LUN),
390 353
354/* BENQ DC5330
355 * Reported by Manuel Fombuena <mfombuena@ya.com> and
356 * Frank Copeland <fjc@thingy.apana.org.au> */
357UNUSUAL_DEV( 0x04a5, 0x3010, 0x0100, 0x0100,
358 "Tekom Technologies, Inc",
359 "300_CAMERA",
360 US_SC_DEVICE, US_PR_DEVICE, NULL,
361 US_FL_IGNORE_RESIDUE ),
362
391/* Patch for Nikon coolpix 2000 363/* Patch for Nikon coolpix 2000
392 * Submitted by Fabien Cosse <fabien.cosse@wanadoo.fr>*/ 364 * Submitted by Fabien Cosse <fabien.cosse@wanadoo.fr>*/
393UNUSUAL_DEV( 0x04b0, 0x0301, 0x0010, 0x0010, 365UNUSUAL_DEV( 0x04b0, 0x0301, 0x0010, 0x0010,
@@ -396,83 +368,6 @@ UNUSUAL_DEV( 0x04b0, 0x0301, 0x0010, 0x0010,
396 US_SC_DEVICE, US_PR_DEVICE,NULL, 368 US_SC_DEVICE, US_PR_DEVICE,NULL,
397 US_FL_NOT_LOCKABLE ), 369 US_FL_NOT_LOCKABLE ),
398 370
399/* Reported by Stefan de Konink <skinkie@xs4all.nl> */
400UNUSUAL_DEV( 0x04b0, 0x0401, 0x0200, 0x0200,
401 "NIKON",
402 "NIKON DSC D100",
403 US_SC_DEVICE, US_PR_DEVICE, NULL,
404 US_FL_FIX_CAPACITY),
405
406/* Reported by Tobias Kunze Briseno <t-linux@fictive.com> */
407UNUSUAL_DEV( 0x04b0, 0x0403, 0x0200, 0x0200,
408 "NIKON",
409 "NIKON DSC D2H",
410 US_SC_DEVICE, US_PR_DEVICE, NULL,
411 US_FL_FIX_CAPACITY),
412
413/* Reported by Milinevsky Dmitry <niam.niam@gmail.com> */
414UNUSUAL_DEV( 0x04b0, 0x0409, 0x0100, 0x0100,
415 "NIKON",
416 "NIKON DSC D50",
417 US_SC_DEVICE, US_PR_DEVICE, NULL,
418 US_FL_FIX_CAPACITY),
419
420/* Reported by Andreas Bockhold <andreas@bockionline.de> */
421UNUSUAL_DEV( 0x04b0, 0x0405, 0x0100, 0x0100,
422 "NIKON",
423 "NIKON DSC D70",
424 US_SC_DEVICE, US_PR_DEVICE, NULL,
425 US_FL_FIX_CAPACITY),
426
427/* Reported by Jamie Kitson <jamie@staberinde.fsnet.co.uk> */
428UNUSUAL_DEV( 0x04b0, 0x040d, 0x0100, 0x0100,
429 "NIKON",
430 "NIKON DSC D70s",
431 US_SC_DEVICE, US_PR_DEVICE, NULL,
432 US_FL_FIX_CAPACITY),
433
434/* Reported by Graber and Mike Pagano <mpagano-kernel@mpagano.com> */
435UNUSUAL_DEV( 0x04b0, 0x040f, 0x0100, 0x0200,
436 "NIKON",
437 "NIKON DSC D200",
438 US_SC_DEVICE, US_PR_DEVICE, NULL,
439 US_FL_FIX_CAPACITY),
440
441/* Reported by Emil Larsson <emil@swip.net> */
442UNUSUAL_DEV( 0x04b0, 0x0411, 0x0100, 0x0111,
443 "NIKON",
444 "NIKON DSC D80",
445 US_SC_DEVICE, US_PR_DEVICE, NULL,
446 US_FL_FIX_CAPACITY),
447
448/* Reported by Ortwin Glueck <odi@odi.ch> */
449UNUSUAL_DEV( 0x04b0, 0x0413, 0x0110, 0x0111,
450 "NIKON",
451 "NIKON DSC D40",
452 US_SC_DEVICE, US_PR_DEVICE, NULL,
453 US_FL_FIX_CAPACITY),
454
455/* Reported by Paul Check <paul@openstreet.com> */
456UNUSUAL_DEV( 0x04b0, 0x0415, 0x0100, 0x0100,
457 "NIKON",
458 "NIKON DSC D2Xs",
459 US_SC_DEVICE, US_PR_DEVICE, NULL,
460 US_FL_FIX_CAPACITY),
461
462/* Reported by Shan Destromp (shansan@gmail.com) */
463UNUSUAL_DEV( 0x04b0, 0x0417, 0x0100, 0x0100,
464 "NIKON",
465 "NIKON DSC D40X",
466 US_SC_DEVICE, US_PR_DEVICE, NULL,
467 US_FL_FIX_CAPACITY),
468
469/* Reported by paul ready <lxtwin@homecall.co.uk> */
470UNUSUAL_DEV( 0x04b0, 0x0419, 0x0100, 0x0200,
471 "NIKON",
472 "NIKON DSC D300",
473 US_SC_DEVICE, US_PR_DEVICE, NULL,
474 US_FL_FIX_CAPACITY),
475
476/* Reported by Doug Maxey (dwm@austin.ibm.com) */ 371/* Reported by Doug Maxey (dwm@austin.ibm.com) */
477UNUSUAL_DEV( 0x04b3, 0x4001, 0x0110, 0x0110, 372UNUSUAL_DEV( 0x04b3, 0x4001, 0x0110, 0x0110,
478 "IBM", 373 "IBM",
@@ -480,15 +375,6 @@ UNUSUAL_DEV( 0x04b3, 0x4001, 0x0110, 0x0110,
480 US_SC_DEVICE, US_PR_CB, NULL, 375 US_SC_DEVICE, US_PR_CB, NULL,
481 US_FL_MAX_SECTORS_MIN), 376 US_FL_MAX_SECTORS_MIN),
482 377
483/* BENQ DC5330
484 * Reported by Manuel Fombuena <mfombuena@ya.com> and
485 * Frank Copeland <fjc@thingy.apana.org.au> */
486UNUSUAL_DEV( 0x04a5, 0x3010, 0x0100, 0x0100,
487 "Tekom Technologies, Inc",
488 "300_CAMERA",
489 US_SC_DEVICE, US_PR_DEVICE, NULL,
490 US_FL_IGNORE_RESIDUE ),
491
492#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB 378#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
493/* CY7C68300 : support atacb */ 379/* CY7C68300 : support atacb */
494UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999, 380UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999,
@@ -594,6 +480,12 @@ UNUSUAL_DEV( 0x04e6, 0x0005, 0x0100, 0x0208,
594 "eUSB SmartMedia / CompactFlash Adapter", 480 "eUSB SmartMedia / CompactFlash Adapter",
595 US_SC_SCSI, US_PR_DPCM_USB, usb_stor_sddr09_dpcm_init, 481 US_SC_SCSI, US_PR_DPCM_USB, usb_stor_sddr09_dpcm_init,
596 0), 482 0),
483#else
484UNUSUAL_DEV( 0x04e6, 0x0005, 0x0100, 0x0208,
485 "SCM Microsystems",
486 "eUSB CompactFlash Adapter",
487 US_SC_SCSI, US_PR_CB, NULL,
488 US_FL_SINGLE_LUN),
597#endif 489#endif
598 490
599/* Reported by Markus Demleitner <msdemlei@cl.uni-heidelberg.de> */ 491/* Reported by Markus Demleitner <msdemlei@cl.uni-heidelberg.de> */
@@ -685,6 +577,13 @@ UNUSUAL_DEV( 0x0525, 0xa140, 0x0100, 0x0100,
685 US_SC_8070, US_PR_DEVICE, NULL, 577 US_SC_8070, US_PR_DEVICE, NULL,
686 US_FL_FIX_INQUIRY ), 578 US_FL_FIX_INQUIRY ),
687 579
580/* Added by Alan Stern <stern@rowland.harvard.edu> */
581COMPLIANT_DEV(0x0525, 0xa4a5, 0x0000, 0x9999,
582 "Linux",
583 "File-backed Storage Gadget",
584 US_SC_DEVICE, US_PR_DEVICE, NULL,
585 US_FL_CAPACITY_OK ),
586
688/* Yakumo Mega Image 37 587/* Yakumo Mega Image 37
689 * Submitted by Stephan Fuhrmann <atomenergie@t-online.de> */ 588 * Submitted by Stephan Fuhrmann <atomenergie@t-online.de> */
690UNUSUAL_DEV( 0x052b, 0x1801, 0x0100, 0x0100, 589UNUSUAL_DEV( 0x052b, 0x1801, 0x0100, 0x0100,
@@ -807,15 +706,15 @@ UNUSUAL_DEV( 0x054c, 0x006d, 0x0000, 0x9999,
807 US_SC_DEVICE, US_PR_DEVICE, NULL, 706 US_SC_DEVICE, US_PR_DEVICE, NULL,
808 US_FL_FIX_INQUIRY ), 707 US_FL_FIX_INQUIRY ),
809 708
810/* Submitted by Mike Alborn <malborn@deandra.homeip.net> */ 709/* Submitted by Frank Engel <frankie@cse.unsw.edu.au> */
811UNUSUAL_DEV( 0x054c, 0x016a, 0x0000, 0x9999, 710UNUSUAL_DEV( 0x054c, 0x0099, 0x0000, 0x9999,
812 "Sony", 711 "Sony",
813 "PEG Mass Storage", 712 "PEG Mass Storage",
814 US_SC_DEVICE, US_PR_DEVICE, NULL, 713 US_SC_DEVICE, US_PR_DEVICE, NULL,
815 US_FL_FIX_INQUIRY ), 714 US_FL_FIX_INQUIRY ),
816 715
817/* Submitted by Frank Engel <frankie@cse.unsw.edu.au> */ 716/* Submitted by Mike Alborn <malborn@deandra.homeip.net> */
818UNUSUAL_DEV( 0x054c, 0x0099, 0x0000, 0x9999, 717UNUSUAL_DEV( 0x054c, 0x016a, 0x0000, 0x9999,
819 "Sony", 718 "Sony",
820 "PEG Mass Storage", 719 "PEG Mass Storage",
821 US_SC_DEVICE, US_PR_DEVICE, NULL, 720 US_SC_DEVICE, US_PR_DEVICE, NULL,
@@ -966,6 +865,18 @@ UNUSUAL_DEV( 0x05ac, 0x120a, 0x0000, 0x9999,
966 US_SC_DEVICE, US_PR_DEVICE, NULL, 865 US_SC_DEVICE, US_PR_DEVICE, NULL,
967 US_FL_FIX_CAPACITY ), 866 US_FL_FIX_CAPACITY ),
968 867
868/* Reported by Dan Williams <dcbw@redhat.com>
869 * Option N.V. mobile broadband modems
870 * Ignore driver CD mode and force into modem mode by default.
871 */
872
873/* Globetrotter HSDPA; mass storage shows up as Qualcomm for vendor */
874UNUSUAL_DEV( 0x05c6, 0x1000, 0x0000, 0x9999,
875 "Option N.V.",
876 "Mass Storage",
877 US_SC_DEVICE, US_PR_DEVICE, option_ms_init,
878 0),
879
969#ifdef CONFIG_USB_STORAGE_JUMPSHOT 880#ifdef CONFIG_USB_STORAGE_JUMPSHOT
970UNUSUAL_DEV( 0x05dc, 0x0001, 0x0000, 0x0001, 881UNUSUAL_DEV( 0x05dc, 0x0001, 0x0000, 0x0001,
971 "Lexar", 882 "Lexar",
@@ -1004,6 +915,13 @@ UNUSUAL_DEV( 0x05e3, 0x0702, 0x0000, 0xffff,
1004 US_SC_DEVICE, US_PR_DEVICE, NULL, 915 US_SC_DEVICE, US_PR_DEVICE, NULL,
1005 US_FL_GO_SLOW | US_FL_MAX_SECTORS_64 ), 916 US_FL_GO_SLOW | US_FL_MAX_SECTORS_64 ),
1006 917
918/* Reported by Ben Efros <ben@pc-doctor.com> */
919UNUSUAL_DEV( 0x05e3, 0x0723, 0x9451, 0x9451,
920 "Genesys Logic",
921 "USB to SATA",
922 US_SC_DEVICE, US_PR_DEVICE, NULL,
923 US_FL_SANE_SENSE ),
924
1007/* Reported by Hanno Boeck <hanno@gmx.de> 925/* Reported by Hanno Boeck <hanno@gmx.de>
1008 * Taken from the Lycoris Kernel */ 926 * Taken from the Lycoris Kernel */
1009UNUSUAL_DEV( 0x0636, 0x0003, 0x0000, 0x9999, 927UNUSUAL_DEV( 0x0636, 0x0003, 0x0000, 0x9999,
@@ -1040,7 +958,7 @@ UNUSUAL_DEV( 0x067b, 0x2507, 0x0100, 0x0100,
1040 US_FL_FIX_CAPACITY | US_FL_GO_SLOW ), 958 US_FL_FIX_CAPACITY | US_FL_GO_SLOW ),
1041 959
1042/* Reported by Alex Butcher <alex.butcher@assursys.co.uk> */ 960/* Reported by Alex Butcher <alex.butcher@assursys.co.uk> */
1043UNUSUAL_DEV( 0x067b, 0x3507, 0x0001, 0x0001, 961UNUSUAL_DEV( 0x067b, 0x3507, 0x0001, 0x0101,
1044 "Prolific Technology Inc.", 962 "Prolific Technology Inc.",
1045 "ATAPI-6 Bridge Controller", 963 "ATAPI-6 Bridge Controller",
1046 US_SC_DEVICE, US_PR_DEVICE, NULL, 964 US_SC_DEVICE, US_PR_DEVICE, NULL,
@@ -1161,11 +1079,17 @@ UNUSUAL_DEV( 0x07af, 0x0005, 0x0100, 0x0100,
1161 US_SC_DEVICE, US_PR_DEVICE, usb_stor_euscsi_init, 1079 US_SC_DEVICE, US_PR_DEVICE, usb_stor_euscsi_init,
1162 US_FL_SCM_MULT_TARG ), 1080 US_FL_SCM_MULT_TARG ),
1163 1081
1164#ifdef CONFIG_USB_STORAGE_DPCM 1082#ifdef CONFIG_USB_STORAGE_SDDR09
1165UNUSUAL_DEV( 0x07af, 0x0006, 0x0100, 0x0100, 1083UNUSUAL_DEV( 0x07af, 0x0006, 0x0100, 0x0100,
1166 "Microtech", 1084 "Microtech",
1167 "CameraMate (DPCM_USB)", 1085 "CameraMate (DPCM_USB)",
1168 US_SC_SCSI, US_PR_DPCM_USB, NULL, 0 ), 1086 US_SC_SCSI, US_PR_DPCM_USB, NULL, 0 ),
1087#else
1088UNUSUAL_DEV( 0x07af, 0x0006, 0x0100, 0x0100,
1089 "Microtech",
1090 "CameraMate",
1091 US_SC_SCSI, US_PR_CB, NULL,
1092 US_FL_SINGLE_LUN ),
1169#endif 1093#endif
1170 1094
1171#ifdef CONFIG_USB_STORAGE_ALAUDA 1095#ifdef CONFIG_USB_STORAGE_ALAUDA
@@ -1320,6 +1244,13 @@ UNUSUAL_DEV( 0x0840, 0x0082, 0x0001, 0x0001,
1320 US_SC_DEVICE, US_PR_DEVICE, NULL, 1244 US_SC_DEVICE, US_PR_DEVICE, NULL,
1321 US_FL_FIX_CAPACITY), 1245 US_FL_FIX_CAPACITY),
1322 1246
1247/* Reported and patched by Nguyen Anh Quynh <aquynh@gmail.com> */
1248UNUSUAL_DEV( 0x0840, 0x0084, 0x0001, 0x0001,
1249 "Argosy",
1250 "Storage",
1251 US_SC_DEVICE, US_PR_DEVICE, NULL,
1252 US_FL_FIX_CAPACITY),
1253
1323/* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>. 1254/* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>.
1324 * Flag will support Bulk devices which use a standards-violating 32-byte 1255 * Flag will support Bulk devices which use a standards-violating 32-byte
1325 * Command Block Wrapper. Here, the "DC2MEGA" cameras (several brands) with 1256 * Command Block Wrapper. Here, the "DC2MEGA" cameras (several brands) with
@@ -1343,17 +1274,6 @@ UNUSUAL_DEV( 0x0851, 0x1543, 0x0200, 0x0200,
1343 US_SC_DEVICE, US_PR_DEVICE, NULL, 1274 US_SC_DEVICE, US_PR_DEVICE, NULL,
1344 US_FL_NOT_LOCKABLE), 1275 US_FL_NOT_LOCKABLE),
1345 1276
1346/* Andrew Lunn <andrew@lunn.ch>
1347 * PanDigital Digital Picture Frame. Does not like ALLOW_MEDIUM_REMOVAL
1348 * on LUN 4.
1349 * Note: Vend:Prod clash with "Ltd Maxell WS30 Slim Digital Camera"
1350*/
1351UNUSUAL_DEV( 0x0851, 0x1543, 0x0200, 0x0200,
1352 "PanDigital",
1353 "Photo Frame",
1354 US_SC_DEVICE, US_PR_DEVICE, NULL,
1355 US_FL_NOT_LOCKABLE),
1356
1357/* Submitted by Jan De Luyck <lkml@kcore.org> */ 1277/* Submitted by Jan De Luyck <lkml@kcore.org> */
1358UNUSUAL_DEV( 0x08bd, 0x1100, 0x0000, 0x0000, 1278UNUSUAL_DEV( 0x08bd, 0x1100, 0x0000, 0x0000,
1359 "CITIZEN", 1279 "CITIZEN",
@@ -1425,6 +1345,13 @@ UNUSUAL_DEV( 0x0a17, 0x006, 0x0000, 0xffff,
1425 US_SC_DEVICE, US_PR_DEVICE, NULL, 1345 US_SC_DEVICE, US_PR_DEVICE, NULL,
1426 US_FL_FIX_INQUIRY ), 1346 US_FL_FIX_INQUIRY ),
1427 1347
1348/* Reported by Jaak Ristioja <Ristioja@gmail.com> */
1349UNUSUAL_DEV( 0x0a17, 0x006e, 0x0100, 0x0100,
1350 "Pentax",
1351 "K10D",
1352 US_SC_DEVICE, US_PR_DEVICE, NULL,
1353 US_FL_FIX_CAPACITY ),
1354
1428/* These are virtual windows driver CDs, which the zd1211rw driver 1355/* These are virtual windows driver CDs, which the zd1211rw driver
1429 * automatically converts into WLAN devices. */ 1356 * automatically converts into WLAN devices. */
1430UNUSUAL_DEV( 0x0ace, 0x2011, 0x0101, 0x0101, 1357UNUSUAL_DEV( 0x0ace, 0x2011, 0x0101, 0x0101,
@@ -1439,6 +1366,18 @@ UNUSUAL_DEV( 0x0ace, 0x20ff, 0x0101, 0x0101,
1439 US_SC_DEVICE, US_PR_DEVICE, NULL, 1366 US_SC_DEVICE, US_PR_DEVICE, NULL,
1440 US_FL_IGNORE_DEVICE ), 1367 US_FL_IGNORE_DEVICE ),
1441 1368
1369/* Reported by Dan Williams <dcbw@redhat.com>
1370 * Option N.V. mobile broadband modems
1371 * Ignore driver CD mode and force into modem mode by default.
1372 */
1373
1374/* iCON 225 */
1375UNUSUAL_DEV( 0x0af0, 0x6971, 0x0000, 0x9999,
1376 "Option N.V.",
1377 "Mass Storage",
1378 US_SC_DEVICE, US_PR_DEVICE, option_ms_init,
1379 0),
1380
1442/* Reported by F. Aben <f.aben@option.com> 1381/* Reported by F. Aben <f.aben@option.com>
1443 * This device (wrongly) has a vendor-specific device descriptor. 1382 * This device (wrongly) has a vendor-specific device descriptor.
1444 * The entry is needed so usb-storage can bind to it's mass-storage 1383 * The entry is needed so usb-storage can bind to it's mass-storage
@@ -1449,6 +1388,13 @@ UNUSUAL_DEV( 0x0af0, 0x7401, 0x0000, 0x0000,
1449 US_SC_DEVICE, US_PR_DEVICE, NULL, 1388 US_SC_DEVICE, US_PR_DEVICE, NULL,
1450 0 ), 1389 0 ),
1451 1390
1391/* Reported by Ben Efros <ben@pc-doctor.com> */
1392UNUSUAL_DEV( 0x0bc2, 0x3010, 0x0000, 0x0000,
1393 "Seagate",
1394 "FreeAgent Pro",
1395 US_SC_DEVICE, US_PR_DEVICE, NULL,
1396 US_FL_SANE_SENSE ),
1397
1452#ifdef CONFIG_USB_STORAGE_ISD200 1398#ifdef CONFIG_USB_STORAGE_ISD200
1453UNUSUAL_DEV( 0x0bf6, 0xa001, 0x0100, 0x0110, 1399UNUSUAL_DEV( 0x0bf6, 0xa001, 0x0100, 0x0110,
1454 "ATI", 1400 "ATI",
@@ -1472,6 +1418,22 @@ UNUSUAL_DEV( 0x0c0b, 0xa109, 0x0000, 0xffff,
1472 US_FL_SINGLE_LUN ), 1418 US_FL_SINGLE_LUN ),
1473#endif 1419#endif
1474 1420
1421UNUSUAL_DEV( 0x0d49, 0x7310, 0x0000, 0x9999,
1422 "Maxtor",
1423 "USB to SATA",
1424 US_SC_DEVICE, US_PR_DEVICE, NULL,
1425 US_FL_SANE_SENSE),
1426
1427/*
1428 * Pete Zaitcev <zaitcev@yahoo.com>, bz#164688.
1429 * The device blatantly ignores LUN and returns 1 in GetMaxLUN.
1430 */
1431UNUSUAL_DEV( 0x0c45, 0x1060, 0x0100, 0x0100,
1432 "Unknown",
1433 "Unknown",
1434 US_SC_DEVICE, US_PR_DEVICE, NULL,
1435 US_FL_SINGLE_LUN ),
1436
1475/* Submitted by: Nick Sillik <n.sillik@temple.edu> 1437/* Submitted by: Nick Sillik <n.sillik@temple.edu>
1476 * Needed for OneTouch extension to usb-storage 1438 * Needed for OneTouch extension to usb-storage
1477 * 1439 *
@@ -1489,16 +1451,6 @@ UNUSUAL_DEV( 0x0c0b, 0xa109, 0x0000, 0xffff,
1489 0), 1451 0),
1490#endif 1452#endif
1491 1453
1492/*
1493 * Pete Zaitcev <zaitcev@yahoo.com>, bz#164688.
1494 * The device blatantly ignores LUN and returns 1 in GetMaxLUN.
1495 */
1496UNUSUAL_DEV( 0x0c45, 0x1060, 0x0100, 0x0100,
1497 "Unknown",
1498 "Unknown",
1499 US_SC_DEVICE, US_PR_DEVICE, NULL,
1500 US_FL_SINGLE_LUN ),
1501
1502/* Submitted by Joris Struyve <joris@struyve.be> */ 1454/* Submitted by Joris Struyve <joris@struyve.be> */
1503UNUSUAL_DEV( 0x0d96, 0x410a, 0x0001, 0xffff, 1455UNUSUAL_DEV( 0x0d96, 0x410a, 0x0001, 0xffff,
1504 "Medion", 1456 "Medion",
@@ -1516,6 +1468,13 @@ UNUSUAL_DEV( 0x0d96, 0x5200, 0x0001, 0x0200,
1516 "JD 5200 z3", 1468 "JD 5200 z3",
1517 US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_FIX_INQUIRY), 1469 US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_FIX_INQUIRY),
1518 1470
1471/* Reported by Jason Johnston <killean@shaw.ca> */
1472UNUSUAL_DEV( 0x0dc4, 0x0073, 0x0000, 0x0000,
1473 "Macpower Technology Co.LTD.",
1474 "USB 2.0 3.5\" DEVICE",
1475 US_SC_DEVICE, US_PR_DEVICE, NULL,
1476 US_FL_FIX_CAPACITY),
1477
1519/* Reported by Lubomir Blaha <tritol@trilogic.cz> 1478/* Reported by Lubomir Blaha <tritol@trilogic.cz>
1520 * I _REALLY_ don't know what 3rd, 4th number and all defines mean, but this 1479 * I _REALLY_ don't know what 3rd, 4th number and all defines mean, but this
1521 * works for me. Can anybody correct these values? (I able to test corrected 1480 * works for me. Can anybody correct these values? (I able to test corrected
@@ -1638,13 +1597,6 @@ UNUSUAL_DEV( 0x0fce, 0xe030, 0x0000, 0x0000,
1638 US_SC_DEVICE, US_PR_DEVICE, NULL, 1597 US_SC_DEVICE, US_PR_DEVICE, NULL,
1639 US_FL_FIX_CAPACITY | US_FL_IGNORE_RESIDUE ), 1598 US_FL_FIX_CAPACITY | US_FL_IGNORE_RESIDUE ),
1640 1599
1641/* Reported by Ricardo Barberis <ricardo@dattatec.com> */
1642UNUSUAL_DEV( 0x0fce, 0xe092, 0x0000, 0x0000,
1643 "Sony Ericsson",
1644 "P1i",
1645 US_SC_DEVICE, US_PR_DEVICE, NULL,
1646 US_FL_IGNORE_RESIDUE ),
1647
1648/* Reported by Emmanuel Vasilakis <evas@forthnet.gr> */ 1600/* Reported by Emmanuel Vasilakis <evas@forthnet.gr> */
1649UNUSUAL_DEV( 0x0fce, 0xe031, 0x0000, 0x0000, 1601UNUSUAL_DEV( 0x0fce, 0xe031, 0x0000, 0x0000,
1650 "Sony Ericsson", 1602 "Sony Ericsson",
@@ -1652,6 +1604,13 @@ UNUSUAL_DEV( 0x0fce, 0xe031, 0x0000, 0x0000,
1652 US_SC_DEVICE, US_PR_DEVICE, NULL, 1604 US_SC_DEVICE, US_PR_DEVICE, NULL,
1653 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ), 1605 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ),
1654 1606
1607/* Reported by Ricardo Barberis <ricardo@dattatec.com> */
1608UNUSUAL_DEV( 0x0fce, 0xe092, 0x0000, 0x0000,
1609 "Sony Ericsson",
1610 "P1i",
1611 US_SC_DEVICE, US_PR_DEVICE, NULL,
1612 US_FL_IGNORE_RESIDUE ),
1613
1655/* Reported by Kevin Cernekee <kpc-usbdev@gelato.uiuc.edu> 1614/* Reported by Kevin Cernekee <kpc-usbdev@gelato.uiuc.edu>
1656 * Tested on hardware version 1.10. 1615 * Tested on hardware version 1.10.
1657 * Entry is needed only for the initializer function override. 1616 * Entry is needed only for the initializer function override.
@@ -1664,6 +1623,12 @@ UNUSUAL_DEV( 0x1019, 0x0c55, 0x0000, 0x0110,
1664 US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init, 1623 US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init,
1665 0 ), 1624 0 ),
1666 1625
1626UNUSUAL_DEV( 0x1058, 0x0704, 0x0000, 0x9999,
1627 "Western Digital",
1628 "External HDD",
1629 US_SC_DEVICE, US_PR_DEVICE, NULL,
1630 US_FL_SANE_SENSE),
1631
1667/* Reported by Fabio Venturi <f.venturi@tdnet.it> 1632/* Reported by Fabio Venturi <f.venturi@tdnet.it>
1668 * The device reports a vendor-specific bDeviceClass. 1633 * The device reports a vendor-specific bDeviceClass.
1669 */ 1634 */
@@ -2053,10 +2018,10 @@ UNUSUAL_DEV( 0x14cd, 0x6600, 0x0201, 0x0201,
2053 * JMicron responds to USN and several other SCSI ioctls with a 2018 * JMicron responds to USN and several other SCSI ioctls with a
2054 * residue that causes subsequent I/O requests to fail. */ 2019 * residue that causes subsequent I/O requests to fail. */
2055UNUSUAL_DEV( 0x152d, 0x2329, 0x0100, 0x0100, 2020UNUSUAL_DEV( 0x152d, 0x2329, 0x0100, 0x0100,
2056 "JMicron", 2021 "JMicron",
2057 "USB to ATA/ATAPI Bridge", 2022 "USB to ATA/ATAPI Bridge",
2058 US_SC_DEVICE, US_PR_DEVICE, NULL, 2023 US_SC_DEVICE, US_PR_DEVICE, NULL,
2059 US_FL_IGNORE_RESIDUE ), 2024 US_FL_IGNORE_RESIDUE | US_FL_SANE_SENSE ),
2060 2025
2061/* Reported by Robert Schedel <r.schedel@yahoo.de> 2026/* Reported by Robert Schedel <r.schedel@yahoo.de>
2062 * Note: this is a 'super top' device like the above 14cd/6600 device */ 2027 * Note: this is a 'super top' device like the above 14cd/6600 device */
@@ -2086,27 +2051,6 @@ UNUSUAL_DEV( 0x22b8, 0x3010, 0x0001, 0x0001,
2086 US_FL_FIX_CAPACITY | US_FL_IGNORE_RESIDUE ), 2051 US_FL_FIX_CAPACITY | US_FL_IGNORE_RESIDUE ),
2087 2052
2088/* 2053/*
2089 * Patch by Pete Zaitcev <zaitcev@redhat.com>
2090 * Report by Mark Patton. Red Hat bz#208928.
2091 * Added support for rev 0x0002 (Motorola ROKR W5)
2092 * by Javier Smaldone <javier@smaldone.com.ar>
2093 */
2094UNUSUAL_DEV( 0x22b8, 0x4810, 0x0001, 0x0002,
2095 "Motorola",
2096 "RAZR V3i/ROKR W5",
2097 US_SC_DEVICE, US_PR_DEVICE, NULL,
2098 US_FL_FIX_CAPACITY),
2099
2100/*
2101 * Patch by Jost Diederichs <jost@qdusa.com>
2102 */
2103UNUSUAL_DEV(0x22b8, 0x6410, 0x0001, 0x9999,
2104 "Motorola Inc.",
2105 "Motorola Phone (RAZRV3xx)",
2106 US_SC_DEVICE, US_PR_DEVICE, NULL,
2107 US_FL_FIX_CAPACITY),
2108
2109/*
2110 * Patch by Constantin Baranov <const@tltsu.ru> 2054 * Patch by Constantin Baranov <const@tltsu.ru>
2111 * Report by Andreas Koenecke. 2055 * Report by Andreas Koenecke.
2112 * Motorola ROKR Z6. 2056 * Motorola ROKR Z6.
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 27016fd2cad1..4becf495ca2d 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -75,9 +75,6 @@
75#ifdef CONFIG_USB_STORAGE_SDDR55 75#ifdef CONFIG_USB_STORAGE_SDDR55
76#include "sddr55.h" 76#include "sddr55.h"
77#endif 77#endif
78#ifdef CONFIG_USB_STORAGE_DPCM
79#include "dpcm.h"
80#endif
81#ifdef CONFIG_USB_STORAGE_FREECOM 78#ifdef CONFIG_USB_STORAGE_FREECOM
82#include "freecom.h" 79#include "freecom.h"
83#endif 80#endif
@@ -103,6 +100,7 @@
103#include "cypress_atacb.h" 100#include "cypress_atacb.h"
104#endif 101#endif
105#include "sierra_ms.h" 102#include "sierra_ms.h"
103#include "option_ms.h"
106 104
107/* Some informational data */ 105/* Some informational data */
108MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>"); 106MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>");
@@ -113,6 +111,10 @@ static unsigned int delay_use = 5;
113module_param(delay_use, uint, S_IRUGO | S_IWUSR); 111module_param(delay_use, uint, S_IRUGO | S_IWUSR);
114MODULE_PARM_DESC(delay_use, "seconds to delay before using a new device"); 112MODULE_PARM_DESC(delay_use, "seconds to delay before using a new device");
115 113
114static char quirks[128];
115module_param_string(quirks, quirks, sizeof(quirks), S_IRUGO | S_IWUSR);
116MODULE_PARM_DESC(quirks, "supplemental list of device IDs and their quirks");
117
116 118
117/* 119/*
118 * The entries in this table correspond, line for line, 120 * The entries in this table correspond, line for line,
@@ -126,6 +128,8 @@ MODULE_PARM_DESC(delay_use, "seconds to delay before using a new device");
126{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin,bcdDeviceMax), \ 128{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin,bcdDeviceMax), \
127 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } 129 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
128 130
131#define COMPLIANT_DEV UNUSUAL_DEV
132
129#define USUAL_DEV(useProto, useTrans, useType) \ 133#define USUAL_DEV(useProto, useTrans, useType) \
130{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans), \ 134{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans), \
131 .driver_info = (USB_US_TYPE_STOR<<24) } 135 .driver_info = (USB_US_TYPE_STOR<<24) }
@@ -134,6 +138,7 @@ static struct usb_device_id storage_usb_ids [] = {
134 138
135# include "unusual_devs.h" 139# include "unusual_devs.h"
136#undef UNUSUAL_DEV 140#undef UNUSUAL_DEV
141#undef COMPLIANT_DEV
137#undef USUAL_DEV 142#undef USUAL_DEV
138 /* Terminating entry */ 143 /* Terminating entry */
139 { } 144 { }
@@ -164,6 +169,8 @@ MODULE_DEVICE_TABLE (usb, storage_usb_ids);
164 .initFunction = init_function, \ 169 .initFunction = init_function, \
165} 170}
166 171
172#define COMPLIANT_DEV UNUSUAL_DEV
173
167#define USUAL_DEV(use_protocol, use_transport, use_type) \ 174#define USUAL_DEV(use_protocol, use_transport, use_type) \
168{ \ 175{ \
169 .useProtocol = use_protocol, \ 176 .useProtocol = use_protocol, \
@@ -173,6 +180,7 @@ MODULE_DEVICE_TABLE (usb, storage_usb_ids);
173static struct us_unusual_dev us_unusual_dev_list[] = { 180static struct us_unusual_dev us_unusual_dev_list[] = {
174# include "unusual_devs.h" 181# include "unusual_devs.h"
175# undef UNUSUAL_DEV 182# undef UNUSUAL_DEV
183# undef COMPLIANT_DEV
176# undef USUAL_DEV 184# undef USUAL_DEV
177 185
178 /* Terminating entry */ 186 /* Terminating entry */
@@ -464,13 +472,83 @@ static int associate_dev(struct us_data *us, struct usb_interface *intf)
464 US_DEBUGP("I/O buffer allocation failed\n"); 472 US_DEBUGP("I/O buffer allocation failed\n");
465 return -ENOMEM; 473 return -ENOMEM;
466 } 474 }
475 return 0;
476}
467 477
468 us->sensebuf = kmalloc(US_SENSE_SIZE, GFP_KERNEL); 478/* Works only for digits and letters, but small and fast */
469 if (!us->sensebuf) { 479#define TOLOWER(x) ((x) | 0x20)
470 US_DEBUGP("Sense buffer allocation failed\n"); 480
471 return -ENOMEM; 481/* Adjust device flags based on the "quirks=" module parameter */
482static void adjust_quirks(struct us_data *us)
483{
484 char *p;
485 u16 vid = le16_to_cpu(us->pusb_dev->descriptor.idVendor);
486 u16 pid = le16_to_cpu(us->pusb_dev->descriptor.idProduct);
487 unsigned f = 0;
488 unsigned int mask = (US_FL_SANE_SENSE | US_FL_FIX_CAPACITY |
489 US_FL_CAPACITY_HEURISTICS | US_FL_IGNORE_DEVICE |
490 US_FL_NOT_LOCKABLE | US_FL_MAX_SECTORS_64 |
491 US_FL_CAPACITY_OK | US_FL_IGNORE_RESIDUE |
492 US_FL_SINGLE_LUN | US_FL_NO_WP_DETECT);
493
494 p = quirks;
495 while (*p) {
496 /* Each entry consists of VID:PID:flags */
497 if (vid == simple_strtoul(p, &p, 16) &&
498 *p == ':' &&
499 pid == simple_strtoul(p+1, &p, 16) &&
500 *p == ':')
501 break;
502
503 /* Move forward to the next entry */
504 while (*p) {
505 if (*p++ == ',')
506 break;
507 }
472 } 508 }
473 return 0; 509 if (!*p) /* No match */
510 return;
511
512 /* Collect the flags */
513 while (*++p && *p != ',') {
514 switch (TOLOWER(*p)) {
515 case 'a':
516 f |= US_FL_SANE_SENSE;
517 break;
518 case 'c':
519 f |= US_FL_FIX_CAPACITY;
520 break;
521 case 'h':
522 f |= US_FL_CAPACITY_HEURISTICS;
523 break;
524 case 'i':
525 f |= US_FL_IGNORE_DEVICE;
526 break;
527 case 'l':
528 f |= US_FL_NOT_LOCKABLE;
529 break;
530 case 'm':
531 f |= US_FL_MAX_SECTORS_64;
532 break;
533 case 'o':
534 f |= US_FL_CAPACITY_OK;
535 break;
536 case 'r':
537 f |= US_FL_IGNORE_RESIDUE;
538 break;
539 case 's':
540 f |= US_FL_SINGLE_LUN;
541 break;
542 case 'w':
543 f |= US_FL_NO_WP_DETECT;
544 break;
545 /* Ignore unrecognized flag characters */
546 }
547 }
548 us->fflags = (us->fflags & ~mask) | f;
549 dev_info(&us->pusb_intf->dev, "Quirks match for "
550 "vid %04x pid %04x: %x\n",
551 vid, pid, f);
474} 552}
475 553
476/* Find an unusual_dev descriptor (always succeeds in the current code) */ 554/* Find an unusual_dev descriptor (always succeeds in the current code) */
@@ -497,6 +575,7 @@ static int get_device_info(struct us_data *us, const struct usb_device_id *id)
497 idesc->bInterfaceProtocol : 575 idesc->bInterfaceProtocol :
498 unusual_dev->useTransport; 576 unusual_dev->useTransport;
499 us->fflags = USB_US_ORIG_FLAGS(id->driver_info); 577 us->fflags = USB_US_ORIG_FLAGS(id->driver_info);
578 adjust_quirks(us);
500 579
501 if (us->fflags & US_FL_IGNORE_DEVICE) { 580 if (us->fflags & US_FL_IGNORE_DEVICE) {
502 printk(KERN_INFO USB_STORAGE "device ignored\n"); 581 printk(KERN_INFO USB_STORAGE "device ignored\n");
@@ -562,7 +641,7 @@ static int get_transport(struct us_data *us)
562 641
563 case US_PR_CBI: 642 case US_PR_CBI:
564 us->transport_name = "Control/Bulk/Interrupt"; 643 us->transport_name = "Control/Bulk/Interrupt";
565 us->transport = usb_stor_CBI_transport; 644 us->transport = usb_stor_CB_transport;
566 us->transport_reset = usb_stor_CB_reset; 645 us->transport_reset = usb_stor_CB_reset;
567 us->max_lun = 7; 646 us->max_lun = 7;
568 break; 647 break;
@@ -675,19 +754,19 @@ static int get_protocol(struct us_data *us)
675 754
676 case US_SC_8020: 755 case US_SC_8020:
677 us->protocol_name = "8020i"; 756 us->protocol_name = "8020i";
678 us->proto_handler = usb_stor_ATAPI_command; 757 us->proto_handler = usb_stor_pad12_command;
679 us->max_lun = 0; 758 us->max_lun = 0;
680 break; 759 break;
681 760
682 case US_SC_QIC: 761 case US_SC_QIC:
683 us->protocol_name = "QIC-157"; 762 us->protocol_name = "QIC-157";
684 us->proto_handler = usb_stor_qic157_command; 763 us->proto_handler = usb_stor_pad12_command;
685 us->max_lun = 0; 764 us->max_lun = 0;
686 break; 765 break;
687 766
688 case US_SC_8070: 767 case US_SC_8070:
689 us->protocol_name = "8070i"; 768 us->protocol_name = "8070i";
690 us->proto_handler = usb_stor_ATAPI_command; 769 us->proto_handler = usb_stor_pad12_command;
691 us->max_lun = 0; 770 us->max_lun = 0;
692 break; 771 break;
693 772
@@ -840,8 +919,6 @@ static void dissociate_dev(struct us_data *us)
840{ 919{
841 US_DEBUGP("-- %s\n", __func__); 920 US_DEBUGP("-- %s\n", __func__);
842 921
843 kfree(us->sensebuf);
844
845 /* Free the device-related DMA-mapped buffers */ 922 /* Free the device-related DMA-mapped buffers */
846 if (us->cr) 923 if (us->cr)
847 usb_buffer_free(us->pusb_dev, sizeof(*us->cr), us->cr, 924 usb_buffer_free(us->pusb_dev, sizeof(*us->cr), us->cr,
@@ -1064,6 +1141,7 @@ static struct usb_driver usb_storage_driver = {
1064static int __init usb_stor_init(void) 1141static int __init usb_stor_init(void)
1065{ 1142{
1066 int retval; 1143 int retval;
1144
1067 printk(KERN_INFO "Initializing USB Mass Storage driver...\n"); 1145 printk(KERN_INFO "Initializing USB Mass Storage driver...\n");
1068 1146
1069 /* register the driver, return usb_register return code if error */ 1147 /* register the driver, return usb_register return code if error */
diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
index a4ad73bd832d..65e674e4be99 100644
--- a/drivers/usb/storage/usb.h
+++ b/drivers/usb/storage/usb.h
@@ -138,7 +138,6 @@ struct us_data {
138 struct usb_ctrlrequest *cr; /* control requests */ 138 struct usb_ctrlrequest *cr; /* control requests */
139 struct usb_sg_request current_sg; /* scatter-gather req. */ 139 struct usb_sg_request current_sg; /* scatter-gather req. */
140 unsigned char *iobuf; /* I/O buffer */ 140 unsigned char *iobuf; /* I/O buffer */
141 unsigned char *sensebuf; /* sense data buffer */
142 dma_addr_t cr_dma; /* buffer DMA addresses */ 141 dma_addr_t cr_dma; /* buffer DMA addresses */
143 dma_addr_t iobuf_dma; 142 dma_addr_t iobuf_dma;
144 struct task_struct *ctl_thread; /* the control thread */ 143 struct task_struct *ctl_thread; /* the control thread */
@@ -155,6 +154,10 @@ struct us_data {
155#ifdef CONFIG_PM 154#ifdef CONFIG_PM
156 pm_hook suspend_resume_hook; 155 pm_hook suspend_resume_hook;
157#endif 156#endif
157
158 /* hacks for READ CAPACITY bug handling */
159 int use_last_sector_hacks;
160 int last_sector_retries;
158}; 161};
159 162
160/* Convert between us_data and the corresponding Scsi_Host */ 163/* Convert between us_data and the corresponding Scsi_Host */
diff --git a/drivers/usb/wusbcore/rh.c b/drivers/usb/wusbcore/rh.c
index 407a9fcc89cc..9fe4246cecb9 100644
--- a/drivers/usb/wusbcore/rh.c
+++ b/drivers/usb/wusbcore/rh.c
@@ -329,7 +329,7 @@ static int wusbhc_rh_clear_port_feat(struct wusbhc *wusbhc, u16 feature,
329static int wusbhc_rh_get_port_status(struct wusbhc *wusbhc, u16 port_idx, 329static int wusbhc_rh_get_port_status(struct wusbhc *wusbhc, u16 port_idx,
330 u32 *_buf, u16 wLength) 330 u32 *_buf, u16 wLength)
331{ 331{
332 u16 *buf = (u16 *) _buf; 332 __le16 *buf = (__le16 *)_buf;
333 333
334 if (port_idx > wusbhc->ports_max) 334 if (port_idx > wusbhc->ports_max)
335 return -EINVAL; 335 return -EINVAL;
diff --git a/drivers/uwb/i1480/dfu/usb.c b/drivers/uwb/i1480/dfu/usb.c
index 686795e97195..c7080d497311 100644
--- a/drivers/uwb/i1480/dfu/usb.c
+++ b/drivers/uwb/i1480/dfu/usb.c
@@ -387,7 +387,7 @@ int i1480_usb_probe(struct usb_interface *iface, const struct usb_device_id *id)
387 goto error_create; 387 goto error_create;
388 } 388 }
389 389
390 /* setup the fops and upload the firmare */ 390 /* setup the fops and upload the firmware */
391 i1480->pre_fw_name = "i1480-pre-phy-0.0.bin"; 391 i1480->pre_fw_name = "i1480-pre-phy-0.0.bin";
392 i1480->mac_fw_name = "i1480-usb-0.0.bin"; 392 i1480->mac_fw_name = "i1480-usb-0.0.bin";
393 i1480->mac_fw_name_deprecate = "ptc-0.0.bin"; 393 i1480->mac_fw_name_deprecate = "ptc-0.0.bin";
diff --git a/drivers/uwb/i1480/i1480u-wlp/i1480u-wlp.h b/drivers/uwb/i1480/i1480u-wlp/i1480u-wlp.h
index 5f1b2951bb83..3421d3339d7d 100644
--- a/drivers/uwb/i1480/i1480u-wlp/i1480u-wlp.h
+++ b/drivers/uwb/i1480/i1480u-wlp/i1480u-wlp.h
@@ -221,7 +221,6 @@ struct i1480u {
221 struct net_device *net_dev; 221 struct net_device *net_dev;
222 222
223 spinlock_t lock; 223 spinlock_t lock;
224 struct net_device_stats stats;
225 224
226 /* RX context handling */ 225 /* RX context handling */
227 struct sk_buff *rx_skb; 226 struct sk_buff *rx_skb;
@@ -271,7 +270,6 @@ extern int i1480u_stop(struct net_device *);
271extern int i1480u_hard_start_xmit(struct sk_buff *, struct net_device *); 270extern int i1480u_hard_start_xmit(struct sk_buff *, struct net_device *);
272extern void i1480u_tx_timeout(struct net_device *); 271extern void i1480u_tx_timeout(struct net_device *);
273extern int i1480u_set_config(struct net_device *, struct ifmap *); 272extern int i1480u_set_config(struct net_device *, struct ifmap *);
274extern struct net_device_stats *i1480u_get_stats(struct net_device *);
275extern int i1480u_change_mtu(struct net_device *, int); 273extern int i1480u_change_mtu(struct net_device *, int);
276extern void i1480u_uwb_notifs_cb(void *, struct uwb_dev *, enum uwb_notifs); 274extern void i1480u_uwb_notifs_cb(void *, struct uwb_dev *, enum uwb_notifs);
277 275
diff --git a/drivers/uwb/i1480/i1480u-wlp/lc.c b/drivers/uwb/i1480/i1480u-wlp/lc.c
index 049c05d4cc6a..f272dfe54d49 100644
--- a/drivers/uwb/i1480/i1480u-wlp/lc.c
+++ b/drivers/uwb/i1480/i1480u-wlp/lc.c
@@ -181,6 +181,15 @@ error:
181} 181}
182#endif 182#endif
183 183
184static const struct net_device_ops i1480u_netdev_ops = {
185 .ndo_open = i1480u_open,
186 .ndo_stop = i1480u_stop,
187 .ndo_start_xmit = i1480u_hard_start_xmit,
188 .ndo_tx_timeout = i1480u_tx_timeout,
189 .ndo_set_config = i1480u_set_config,
190 .ndo_change_mtu = i1480u_change_mtu,
191};
192
184static 193static
185int i1480u_add(struct i1480u *i1480u, struct usb_interface *iface) 194int i1480u_add(struct i1480u *i1480u, struct usb_interface *iface)
186{ 195{
@@ -235,13 +244,7 @@ int i1480u_add(struct i1480u *i1480u, struct usb_interface *iface)
235 net_dev->features |= NETIF_F_HIGHDMA; 244 net_dev->features |= NETIF_F_HIGHDMA;
236 net_dev->watchdog_timeo = 5*HZ; /* FIXME: a better default? */ 245 net_dev->watchdog_timeo = 5*HZ; /* FIXME: a better default? */
237 246
238 net_dev->open = i1480u_open; 247 net_dev->netdev_ops = &i1480u_netdev_ops;
239 net_dev->stop = i1480u_stop;
240 net_dev->hard_start_xmit = i1480u_hard_start_xmit;
241 net_dev->tx_timeout = i1480u_tx_timeout;
242 net_dev->get_stats = i1480u_get_stats;
243 net_dev->set_config = i1480u_set_config;
244 net_dev->change_mtu = i1480u_change_mtu;
245 248
246#ifdef i1480u_FLOW_CONTROL 249#ifdef i1480u_FLOW_CONTROL
247 /* Notification endpoint setup (submitted when we open the device) */ 250 /* Notification endpoint setup (submitted when we open the device) */
diff --git a/drivers/uwb/i1480/i1480u-wlp/netdev.c b/drivers/uwb/i1480/i1480u-wlp/netdev.c
index e3873ffb942c..73055530e60f 100644
--- a/drivers/uwb/i1480/i1480u-wlp/netdev.c
+++ b/drivers/uwb/i1480/i1480u-wlp/netdev.c
@@ -262,15 +262,6 @@ int i1480u_stop(struct net_device *net_dev)
262 return 0; 262 return 0;
263} 263}
264 264
265
266/** Report statistics */
267struct net_device_stats *i1480u_get_stats(struct net_device *net_dev)
268{
269 struct i1480u *i1480u = netdev_priv(net_dev);
270 return &i1480u->stats;
271}
272
273
274/** 265/**
275 * 266 *
276 * Change the interface config--we probably don't have to do anything. 267 * Change the interface config--we probably don't have to do anything.
diff --git a/drivers/uwb/i1480/i1480u-wlp/rx.c b/drivers/uwb/i1480/i1480u-wlp/rx.c
index 34f4cf9a7d34..25a2758beb61 100644
--- a/drivers/uwb/i1480/i1480u-wlp/rx.c
+++ b/drivers/uwb/i1480/i1480u-wlp/rx.c
@@ -167,7 +167,7 @@ do { \
167do { \ 167do { \
168 if (printk_ratelimit()) \ 168 if (printk_ratelimit()) \
169 dev_err(&i1480u->usb_iface->dev, msg); \ 169 dev_err(&i1480u->usb_iface->dev, msg); \
170 i1480u->stats.rx_dropped++; \ 170 i1480u->net_dev->stats.rx_dropped++; \
171} while (0) 171} while (0)
172 172
173 173
@@ -193,10 +193,8 @@ void i1480u_skb_deliver(struct i1480u *i1480u)
193 if (!should_parse) 193 if (!should_parse)
194 goto out; 194 goto out;
195 i1480u->rx_skb->protocol = eth_type_trans(i1480u->rx_skb, net_dev); 195 i1480u->rx_skb->protocol = eth_type_trans(i1480u->rx_skb, net_dev);
196 i1480u->stats.rx_packets++; 196 net_dev->stats.rx_packets++;
197 i1480u->stats.rx_bytes += i1480u->rx_untd_pkt_size; 197 net_dev->stats.rx_bytes += i1480u->rx_untd_pkt_size;
198 net_dev->last_rx = jiffies;
199 /* FIXME: flow control: check netif_rx() retval */
200 198
201 netif_rx(i1480u->rx_skb); /* deliver */ 199 netif_rx(i1480u->rx_skb); /* deliver */
202out: 200out:
diff --git a/drivers/uwb/i1480/i1480u-wlp/tx.c b/drivers/uwb/i1480/i1480u-wlp/tx.c
index 39032cc3503e..26bacc009c65 100644
--- a/drivers/uwb/i1480/i1480u-wlp/tx.c
+++ b/drivers/uwb/i1480/i1480u-wlp/tx.c
@@ -117,8 +117,8 @@ void i1480u_tx_cb(struct urb *urb)
117 switch (urb->status) { 117 switch (urb->status) {
118 case 0: 118 case 0:
119 spin_lock_irqsave(&i1480u->lock, flags); 119 spin_lock_irqsave(&i1480u->lock, flags);
120 i1480u->stats.tx_packets++; 120 net_dev->stats.tx_packets++;
121 i1480u->stats.tx_bytes += urb->actual_length; 121 net_dev->stats.tx_bytes += urb->actual_length;
122 spin_unlock_irqrestore(&i1480u->lock, flags); 122 spin_unlock_irqrestore(&i1480u->lock, flags);
123 break; 123 break;
124 case -ECONNRESET: /* Not an error, but a controlled situation; */ 124 case -ECONNRESET: /* Not an error, but a controlled situation; */
@@ -530,7 +530,7 @@ int i1480u_hard_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
530 return NETDEV_TX_OK; 530 return NETDEV_TX_OK;
531error: 531error:
532 dev_kfree_skb_any(skb); 532 dev_kfree_skb_any(skb);
533 i1480u->stats.tx_dropped++; 533 net_dev->stats.tx_dropped++;
534out: 534out:
535 return NETDEV_TX_OK; 535 return NETDEV_TX_OK;
536} 536}
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index e39e33e797da..be2b657546ef 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -28,7 +28,7 @@ obj-$(CONFIG_FB_DDC) += fb_ddc.o
28obj-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o 28obj-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o
29 29
30# Hardware specific drivers go first 30# Hardware specific drivers go first
31obj-$(CONFIG_FB_AMIGA) += amifb.o c2p.o 31obj-$(CONFIG_FB_AMIGA) += amifb.o c2p_planar.o
32obj-$(CONFIG_FB_ARC) += arcfb.o 32obj-$(CONFIG_FB_ARC) += arcfb.o
33obj-$(CONFIG_FB_CLPS711X) += clps711xfb.o 33obj-$(CONFIG_FB_CLPS711X) += clps711xfb.o
34obj-$(CONFIG_FB_CYBER2000) += cyber2000fb.o 34obj-$(CONFIG_FB_CYBER2000) += cyber2000fb.o
@@ -72,7 +72,7 @@ obj-$(CONFIG_FB_TCX) += tcx.o sbuslib.o
72obj-$(CONFIG_FB_LEO) += leo.o sbuslib.o 72obj-$(CONFIG_FB_LEO) += leo.o sbuslib.o
73obj-$(CONFIG_FB_SGIVW) += sgivwfb.o 73obj-$(CONFIG_FB_SGIVW) += sgivwfb.o
74obj-$(CONFIG_FB_ACORN) += acornfb.o 74obj-$(CONFIG_FB_ACORN) += acornfb.o
75obj-$(CONFIG_FB_ATARI) += atafb.o c2p.o atafb_mfb.o \ 75obj-$(CONFIG_FB_ATARI) += atafb.o c2p_iplan2.o atafb_mfb.o \
76 atafb_iplan2p2.o atafb_iplan2p4.o atafb_iplan2p8.o 76 atafb_iplan2p2.o atafb_iplan2p4.o atafb_iplan2p8.o
77obj-$(CONFIG_FB_MAC) += macfb.o 77obj-$(CONFIG_FB_MAC) += macfb.o
78obj-$(CONFIG_FB_HECUBA) += hecubafb.o 78obj-$(CONFIG_FB_HECUBA) += hecubafb.o
diff --git a/drivers/video/amba-clcd.c b/drivers/video/amba-clcd.c
index 2ac52fd8cc11..4e046fed1380 100644
--- a/drivers/video/amba-clcd.c
+++ b/drivers/video/amba-clcd.c
@@ -24,6 +24,7 @@
24#include <linux/amba/bus.h> 24#include <linux/amba/bus.h>
25#include <linux/amba/clcd.h> 25#include <linux/amba/clcd.h>
26#include <linux/clk.h> 26#include <linux/clk.h>
27#include <linux/hardirq.h>
27 28
28#include <asm/sizes.h> 29#include <asm/sizes.h>
29 30
diff --git a/drivers/video/amifb.c b/drivers/video/amifb.c
index b8e9a8682f2d..100f23661465 100644
--- a/drivers/video/amifb.c
+++ b/drivers/video/amifb.c
@@ -2159,9 +2159,9 @@ static void amifb_imageblit(struct fb_info *info, const struct fb_image *image)
2159 src += pitch; 2159 src += pitch;
2160 } 2160 }
2161 } else { 2161 } else {
2162 c2p(info->screen_base, image->data, dx, dy, width, height, 2162 c2p_planar(info->screen_base, image->data, dx, dy, width,
2163 par->next_line, par->next_plane, image->width, 2163 height, par->next_line, par->next_plane,
2164 info->var.bits_per_pixel); 2164 image->width, info->var.bits_per_pixel);
2165 } 2165 }
2166} 2166}
2167 2167
diff --git a/drivers/video/atafb.c b/drivers/video/atafb.c
index 77eb8b34fbfa..8058572a7428 100644
--- a/drivers/video/atafb.c
+++ b/drivers/video/atafb.c
@@ -122,7 +122,6 @@ static struct atafb_par {
122 void *screen_base; 122 void *screen_base;
123 int yres_virtual; 123 int yres_virtual;
124 u_long next_line; 124 u_long next_line;
125 u_long next_plane;
126#if defined ATAFB_TT || defined ATAFB_STE 125#if defined ATAFB_TT || defined ATAFB_STE
127 union { 126 union {
128 struct { 127 struct {
@@ -149,6 +148,7 @@ static struct atafb_par {
149 short mono; 148 short mono;
150 short ste_mode; 149 short ste_mode;
151 short bpp; 150 short bpp;
151 u32 pseudo_palette[16];
152 } falcon; 152 } falcon;
153#endif 153#endif
154 /* Nothing needed for external mode */ 154 /* Nothing needed for external mode */
@@ -614,7 +614,7 @@ static int tt_encode_fix(struct fb_fix_screeninfo *fix, struct atafb_par *par)
614 fix->xpanstep = 0; 614 fix->xpanstep = 0;
615 fix->ypanstep = 1; 615 fix->ypanstep = 1;
616 fix->ywrapstep = 0; 616 fix->ywrapstep = 0;
617 fix->line_length = 0; 617 fix->line_length = par->next_line;
618 fix->accel = FB_ACCEL_ATARIBLITT; 618 fix->accel = FB_ACCEL_ATARIBLITT;
619 return 0; 619 return 0;
620} 620}
@@ -691,6 +691,7 @@ static int tt_decode_var(struct fb_var_screeninfo *var, struct atafb_par *par)
691 return -EINVAL; 691 return -EINVAL;
692 par->yres_virtual = yres_virtual; 692 par->yres_virtual = yres_virtual;
693 par->screen_base = screen_base + var->yoffset * linelen; 693 par->screen_base = screen_base + var->yoffset * linelen;
694 par->next_line = linelen;
694 return 0; 695 return 0;
695} 696}
696 697
@@ -884,10 +885,6 @@ static int vdl_prescale[4][3] = {
884/* Default hsync timing [mon_type] in picoseconds */ 885/* Default hsync timing [mon_type] in picoseconds */
885static long h_syncs[4] = { 3000000, 4875000, 4000000, 4875000 }; 886static long h_syncs[4] = { 3000000, 4875000, 4000000, 4875000 };
886 887
887#ifdef FBCON_HAS_CFB16
888static u16 fbcon_cfb16_cmap[16];
889#endif
890
891static inline int hxx_prescale(struct falcon_hw *hw) 888static inline int hxx_prescale(struct falcon_hw *hw)
892{ 889{
893 return hw->ste_mode ? 16 890 return hw->ste_mode ? 16
@@ -918,7 +915,7 @@ static int falcon_encode_fix(struct fb_fix_screeninfo *fix,
918 fix->visual = FB_VISUAL_TRUECOLOR; 915 fix->visual = FB_VISUAL_TRUECOLOR;
919 fix->xpanstep = 2; 916 fix->xpanstep = 2;
920 } 917 }
921 fix->line_length = 0; 918 fix->line_length = par->next_line;
922 fix->accel = FB_ACCEL_ATARIBLITT; 919 fix->accel = FB_ACCEL_ATARIBLITT;
923 return 0; 920 return 0;
924} 921}
@@ -1394,14 +1391,7 @@ set_screen_base:
1394 par->screen_base = screen_base + var->yoffset * linelen; 1391 par->screen_base = screen_base + var->yoffset * linelen;
1395 par->hw.falcon.xoffset = 0; 1392 par->hw.falcon.xoffset = 0;
1396 1393
1397 // FIXME!!! sort of works, no crash
1398 //par->next_line = linelen;
1399 //par->next_plane = yres_virtual * linelen;
1400 par->next_line = linelen; 1394 par->next_line = linelen;
1401 par->next_plane = 2;
1402 // crashes
1403 //par->next_plane = linelen;
1404 //par->next_line = yres_virtual * linelen;
1405 1395
1406 return 0; 1396 return 0;
1407} 1397}
@@ -1735,10 +1725,10 @@ static int falcon_setcolreg(unsigned int regno, unsigned int red,
1735 (((red & 0xe000) >> 13) | ((red & 0x1000) >> 12) << 8) | 1725 (((red & 0xe000) >> 13) | ((red & 0x1000) >> 12) << 8) |
1736 (((green & 0xe000) >> 13) | ((green & 0x1000) >> 12) << 4) | 1726 (((green & 0xe000) >> 13) | ((green & 0x1000) >> 12) << 4) |
1737 ((blue & 0xe000) >> 13) | ((blue & 0x1000) >> 12); 1727 ((blue & 0xe000) >> 13) | ((blue & 0x1000) >> 12);
1738#ifdef FBCON_HAS_CFB16 1728#ifdef ATAFB_FALCON
1739 fbcon_cfb16_cmap[regno] = ((red & 0xf800) | 1729 ((u32 *)info->pseudo_palette)[regno] = ((red & 0xf800) |
1740 ((green & 0xfc00) >> 5) | 1730 ((green & 0xfc00) >> 5) |
1741 ((blue & 0xf800) >> 11)); 1731 ((blue & 0xf800) >> 11));
1742#endif 1732#endif
1743 } 1733 }
1744 return 0; 1734 return 0;
@@ -1852,7 +1842,7 @@ static int stste_encode_fix(struct fb_fix_screeninfo *fix,
1852 fix->ypanstep = 0; 1842 fix->ypanstep = 0;
1853 } 1843 }
1854 fix->ywrapstep = 0; 1844 fix->ywrapstep = 0;
1855 fix->line_length = 0; 1845 fix->line_length = par->next_line;
1856 fix->accel = FB_ACCEL_ATARIBLITT; 1846 fix->accel = FB_ACCEL_ATARIBLITT;
1857 return 0; 1847 return 0;
1858} 1848}
@@ -1910,6 +1900,7 @@ static int stste_decode_var(struct fb_var_screeninfo *var,
1910 return -EINVAL; 1900 return -EINVAL;
1911 par->yres_virtual = yres_virtual; 1901 par->yres_virtual = yres_virtual;
1912 par->screen_base = screen_base + var->yoffset * linelen; 1902 par->screen_base = screen_base + var->yoffset * linelen;
1903 par->next_line = linelen;
1913 return 0; 1904 return 0;
1914} 1905}
1915 1906
@@ -2169,7 +2160,7 @@ static int ext_encode_fix(struct fb_fix_screeninfo *fix, struct atafb_par *par)
2169 fix->xpanstep = 0; 2160 fix->xpanstep = 0;
2170 fix->ypanstep = 0; 2161 fix->ypanstep = 0;
2171 fix->ywrapstep = 0; 2162 fix->ywrapstep = 0;
2172 fix->line_length = 0; 2163 fix->line_length = par->next_line;
2173 return 0; 2164 return 0;
2174} 2165}
2175 2166
@@ -2184,6 +2175,8 @@ static int ext_decode_var(struct fb_var_screeninfo *var, struct atafb_par *par)
2184 var->xoffset > 0 || 2175 var->xoffset > 0 ||
2185 var->yoffset > 0) 2176 var->yoffset > 0)
2186 return -EINVAL; 2177 return -EINVAL;
2178
2179 par->next_line = external_xres_virtual * external_depth / 8;
2187 return 0; 2180 return 0;
2188} 2181}
2189 2182
@@ -2443,42 +2436,6 @@ static void atafb_set_disp(struct fb_info *info)
2443 atafb_get_fix(&info->fix, info); 2436 atafb_get_fix(&info->fix, info);
2444 2437
2445 info->screen_base = (void *)info->fix.smem_start; 2438 info->screen_base = (void *)info->fix.smem_start;
2446
2447 switch (info->fix.type) {
2448 case FB_TYPE_INTERLEAVED_PLANES:
2449 switch (info->var.bits_per_pixel) {
2450 case 2:
2451 // display->dispsw = &fbcon_iplan2p2;
2452 break;
2453 case 4:
2454 // display->dispsw = &fbcon_iplan2p4;
2455 break;
2456 case 8:
2457 // display->dispsw = &fbcon_iplan2p8;
2458 break;
2459 }
2460 break;
2461 case FB_TYPE_PACKED_PIXELS:
2462 switch (info->var.bits_per_pixel) {
2463#ifdef FBCON_HAS_MFB
2464 case 1:
2465 // display->dispsw = &fbcon_mfb;
2466 break;
2467#endif
2468#ifdef FBCON_HAS_CFB8
2469 case 8:
2470 // display->dispsw = &fbcon_cfb8;
2471 break;
2472#endif
2473#ifdef FBCON_HAS_CFB16
2474 case 16:
2475 // display->dispsw = &fbcon_cfb16;
2476 // display->dispsw_data = fbcon_cfb16_cmap;
2477 break;
2478#endif
2479 }
2480 break;
2481 }
2482} 2439}
2483 2440
2484static int atafb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, 2441static int atafb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
@@ -2549,6 +2506,13 @@ static void atafb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
2549 if (!rect->width || !rect->height) 2506 if (!rect->width || !rect->height)
2550 return; 2507 return;
2551 2508
2509#ifdef ATAFB_FALCON
2510 if (info->var.bits_per_pixel == 16) {
2511 cfb_fillrect(info, rect);
2512 return;
2513 }
2514#endif
2515
2552 /* 2516 /*
2553 * We could use hardware clipping but on many cards you get around 2517 * We could use hardware clipping but on many cards you get around
2554 * hardware clipping by writing to framebuffer directly. 2518 * hardware clipping by writing to framebuffer directly.
@@ -2583,6 +2547,13 @@ static void atafb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
2583 u32 dx, dy, sx, sy, width, height; 2547 u32 dx, dy, sx, sy, width, height;
2584 int rev_copy = 0; 2548 int rev_copy = 0;
2585 2549
2550#ifdef ATAFB_FALCON
2551 if (info->var.bits_per_pixel == 16) {
2552 cfb_copyarea(info, area);
2553 return;
2554 }
2555#endif
2556
2586 /* clip the destination */ 2557 /* clip the destination */
2587 x2 = area->dx + area->width; 2558 x2 = area->dx + area->width;
2588 y2 = area->dy + area->height; 2559 y2 = area->dy + area->height;
@@ -2632,6 +2603,13 @@ static void atafb_imageblit(struct fb_info *info, const struct fb_image *image)
2632 const char *src; 2603 const char *src;
2633 u32 dx, dy, width, height, pitch; 2604 u32 dx, dy, width, height, pitch;
2634 2605
2606#ifdef ATAFB_FALCON
2607 if (info->var.bits_per_pixel == 16) {
2608 cfb_imageblit(info, image);
2609 return;
2610 }
2611#endif
2612
2635 /* 2613 /*
2636 * We could use hardware clipping but on many cards you get around 2614 * We could use hardware clipping but on many cards you get around
2637 * hardware clipping by writing to framebuffer directly like we are 2615 * hardware clipping by writing to framebuffer directly like we are
@@ -2676,10 +2654,9 @@ static void atafb_imageblit(struct fb_info *info, const struct fb_image *image)
2676 src += pitch; 2654 src += pitch;
2677 } 2655 }
2678 } else { 2656 } else {
2679 // only used for logo; broken 2657 c2p_iplan2(info->screen_base, image->data, dx, dy, width,
2680 c2p(info->screen_base, image->data, dx, dy, width, height, 2658 height, par->next_line, image->width,
2681 par->next_line, par->next_plane, image->width, 2659 info->var.bits_per_pixel);
2682 info->var.bits_per_pixel);
2683 } 2660 }
2684} 2661}
2685 2662
@@ -3098,8 +3075,7 @@ int __init atafb_setup(char *options)
3098 3075
3099int __init atafb_init(void) 3076int __init atafb_init(void)
3100{ 3077{
3101 int pad; 3078 int pad, detected_mode, error;
3102 int detected_mode;
3103 unsigned int defmode = 0; 3079 unsigned int defmode = 0;
3104 unsigned long mem_req; 3080 unsigned long mem_req;
3105 3081
@@ -3139,8 +3115,12 @@ int __init atafb_init(void)
3139 printk("atafb_init: initializing Falcon hw\n"); 3115 printk("atafb_init: initializing Falcon hw\n");
3140 fbhw = &falcon_switch; 3116 fbhw = &falcon_switch;
3141 atafb_ops.fb_setcolreg = &falcon_setcolreg; 3117 atafb_ops.fb_setcolreg = &falcon_setcolreg;
3142 request_irq(IRQ_AUTO_4, falcon_vbl_switcher, IRQ_TYPE_PRIO, 3118 error = request_irq(IRQ_AUTO_4, falcon_vbl_switcher,
3143 "framebuffer/modeswitch", falcon_vbl_switcher); 3119 IRQ_TYPE_PRIO,
3120 "framebuffer/modeswitch",
3121 falcon_vbl_switcher);
3122 if (error)
3123 return error;
3144 defmode = DEFMODE_F30; 3124 defmode = DEFMODE_F30;
3145 break; 3125 break;
3146 } 3126 }
@@ -3225,6 +3205,10 @@ int __init atafb_init(void)
3225 // tries to read from HW which may not be initialized yet 3205 // tries to read from HW which may not be initialized yet
3226 // so set sane var first, then call atafb_set_par 3206 // so set sane var first, then call atafb_set_par
3227 atafb_get_var(&fb_info.var, &fb_info); 3207 atafb_get_var(&fb_info.var, &fb_info);
3208
3209#ifdef ATAFB_FALCON
3210 fb_info.pseudo_palette = current_par.hw.falcon.pseudo_palette;
3211#endif
3228 fb_info.flags = FBINFO_FLAG_DEFAULT; 3212 fb_info.flags = FBINFO_FLAG_DEFAULT;
3229 3213
3230 if (!fb_find_mode(&fb_info.var, &fb_info, mode_option, atafb_modedb, 3214 if (!fb_find_mode(&fb_info.var, &fb_info, mode_option, atafb_modedb,
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 4a4dd9adc328..72facb9eb7db 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -52,11 +52,11 @@ config LCD_ILI9320
52 then say y to include a power driver for it. 52 then say y to include a power driver for it.
53 53
54config LCD_TDO24M 54config LCD_TDO24M
55 tristate "Toppoly TDO24M LCD Panels support" 55 tristate "Toppoly TDO24M and TDO35S LCD Panels support"
56 depends on LCD_CLASS_DEVICE && SPI_MASTER 56 depends on LCD_CLASS_DEVICE && SPI_MASTER
57 default n 57 default n
58 help 58 help
59 If you have a Toppoly TDO24M series LCD panel, say y here to 59 If you have a Toppoly TDO24M/TDO35S series LCD panel, say y here to
60 include the support for it. 60 include the support for it.
61 61
62config LCD_VGG2432A4 62config LCD_VGG2432A4
@@ -123,17 +123,14 @@ config BACKLIGHT_ATMEL_PWM
123 To compile this driver as a module, choose M here: the module will be 123 To compile this driver as a module, choose M here: the module will be
124 called atmel-pwm-bl. 124 called atmel-pwm-bl.
125 125
126config BACKLIGHT_CORGI 126config BACKLIGHT_GENERIC
127 tristate "Generic (aka Sharp Corgi) Backlight Driver (DEPRECATED)" 127 tristate "Generic (aka Sharp Corgi) Backlight Driver"
128 depends on BACKLIGHT_CLASS_DEVICE 128 depends on BACKLIGHT_CLASS_DEVICE
129 default n 129 default y
130 help 130 help
131 Say y to enable the generic platform backlight driver previously 131 Say y to enable the generic platform backlight driver previously
132 known as the Corgi backlight driver. If you have a Sharp Zaurus 132 known as the Corgi backlight driver. If you have a Sharp Zaurus
133 SL-C7xx, SL-Cxx00 or SL-6000x say y. Most users can say n. 133 SL-C7xx, SL-Cxx00 or SL-6000x say y.
134
135 Note: this driver is marked as deprecated, try enable SPI and
136 use the new corgi_lcd driver with integrated backlight control
137 134
138config BACKLIGHT_LOCOMO 135config BACKLIGHT_LOCOMO
139 tristate "Sharp LOCOMO LCD/Backlight Driver" 136 tristate "Sharp LOCOMO LCD/Backlight Driver"
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index 103427de6703..363b3cb2f01b 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -11,7 +11,7 @@ obj-$(CONFIG_LCD_TOSA) += tosa_lcd.o
11 11
12obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o 12obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o
13obj-$(CONFIG_BACKLIGHT_ATMEL_PWM) += atmel-pwm-bl.o 13obj-$(CONFIG_BACKLIGHT_ATMEL_PWM) += atmel-pwm-bl.o
14obj-$(CONFIG_BACKLIGHT_CORGI) += corgi_bl.o 14obj-$(CONFIG_BACKLIGHT_GENERIC) += generic_bl.o
15obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o 15obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o
16obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o 16obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o
17obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o 17obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 0664fc032235..157057c79ca3 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -40,6 +40,10 @@ static int fb_notifier_callback(struct notifier_block *self,
40 if (!bd->ops->check_fb || 40 if (!bd->ops->check_fb ||
41 bd->ops->check_fb(evdata->info)) { 41 bd->ops->check_fb(evdata->info)) {
42 bd->props.fb_blank = *(int *)evdata->data; 42 bd->props.fb_blank = *(int *)evdata->data;
43 if (bd->props.fb_blank == FB_BLANK_UNBLANK)
44 bd->props.state &= ~BL_CORE_FBBLANK;
45 else
46 bd->props.state |= BL_CORE_FBBLANK;
43 backlight_update_status(bd); 47 backlight_update_status(bd);
44 } 48 }
45 mutex_unlock(&bd->ops_lock); 49 mutex_unlock(&bd->ops_lock);
@@ -80,20 +84,18 @@ static ssize_t backlight_show_power(struct device *dev,
80static ssize_t backlight_store_power(struct device *dev, 84static ssize_t backlight_store_power(struct device *dev,
81 struct device_attribute *attr, const char *buf, size_t count) 85 struct device_attribute *attr, const char *buf, size_t count)
82{ 86{
83 int rc = -ENXIO; 87 int rc;
84 char *endp;
85 struct backlight_device *bd = to_backlight_device(dev); 88 struct backlight_device *bd = to_backlight_device(dev);
86 int power = simple_strtoul(buf, &endp, 0); 89 unsigned long power;
87 size_t size = endp - buf;
88 90
89 if (*endp && isspace(*endp)) 91 rc = strict_strtoul(buf, 0, &power);
90 size++; 92 if (rc)
91 if (size != count) 93 return rc;
92 return -EINVAL;
93 94
95 rc = -ENXIO;
94 mutex_lock(&bd->ops_lock); 96 mutex_lock(&bd->ops_lock);
95 if (bd->ops) { 97 if (bd->ops) {
96 pr_debug("backlight: set power to %d\n", power); 98 pr_debug("backlight: set power to %lu\n", power);
97 if (bd->props.power != power) { 99 if (bd->props.power != power) {
98 bd->props.power = power; 100 bd->props.power = power;
99 backlight_update_status(bd); 101 backlight_update_status(bd);
@@ -116,28 +118,25 @@ static ssize_t backlight_show_brightness(struct device *dev,
116static ssize_t backlight_store_brightness(struct device *dev, 118static ssize_t backlight_store_brightness(struct device *dev,
117 struct device_attribute *attr, const char *buf, size_t count) 119 struct device_attribute *attr, const char *buf, size_t count)
118{ 120{
119 int rc = -ENXIO; 121 int rc;
120 char *endp;
121 struct backlight_device *bd = to_backlight_device(dev); 122 struct backlight_device *bd = to_backlight_device(dev);
122 int brightness = simple_strtoul(buf, &endp, 0); 123 unsigned long brightness;
123 size_t size = endp - buf; 124
125 rc = strict_strtoul(buf, 0, &brightness);
126 if (rc)
127 return rc;
124 128
125 if (*endp && isspace(*endp)) 129 rc = -ENXIO;
126 size++;
127 if (size != count)
128 return -EINVAL;
129 130
130 mutex_lock(&bd->ops_lock); 131 mutex_lock(&bd->ops_lock);
131 if (bd->ops) { 132 if (bd->ops) {
132 if (brightness > bd->props.max_brightness) 133 if (brightness > bd->props.max_brightness)
133 rc = -EINVAL; 134 rc = -EINVAL;
134 else { 135 else {
135 pr_debug("backlight: set brightness to %d\n", 136 pr_debug("backlight: set brightness to %lu\n",
136 brightness); 137 brightness);
137 if (bd->props.brightness != brightness) { 138 bd->props.brightness = brightness;
138 bd->props.brightness = brightness; 139 backlight_update_status(bd);
139 backlight_update_status(bd);
140 }
141 rc = count; 140 rc = count;
142 } 141 }
143 } 142 }
@@ -170,6 +169,34 @@ static ssize_t backlight_show_actual_brightness(struct device *dev,
170 169
171static struct class *backlight_class; 170static struct class *backlight_class;
172 171
172static int backlight_suspend(struct device *dev, pm_message_t state)
173{
174 struct backlight_device *bd = to_backlight_device(dev);
175
176 if (bd->ops->options & BL_CORE_SUSPENDRESUME) {
177 mutex_lock(&bd->ops_lock);
178 bd->props.state |= BL_CORE_SUSPENDED;
179 backlight_update_status(bd);
180 mutex_unlock(&bd->ops_lock);
181 }
182
183 return 0;
184}
185
186static int backlight_resume(struct device *dev)
187{
188 struct backlight_device *bd = to_backlight_device(dev);
189
190 if (bd->ops->options & BL_CORE_SUSPENDRESUME) {
191 mutex_lock(&bd->ops_lock);
192 bd->props.state &= ~BL_CORE_SUSPENDED;
193 backlight_update_status(bd);
194 mutex_unlock(&bd->ops_lock);
195 }
196
197 return 0;
198}
199
173static void bl_device_release(struct device *dev) 200static void bl_device_release(struct device *dev)
174{ 201{
175 struct backlight_device *bd = to_backlight_device(dev); 202 struct backlight_device *bd = to_backlight_device(dev);
@@ -286,6 +313,8 @@ static int __init backlight_class_init(void)
286 } 313 }
287 314
288 backlight_class->dev_attrs = bl_device_attributes; 315 backlight_class->dev_attrs = bl_device_attributes;
316 backlight_class->suspend = backlight_suspend;
317 backlight_class->resume = backlight_resume;
289 return 0; 318 return 0;
290} 319}
291 320
diff --git a/drivers/video/backlight/corgi_bl.c b/drivers/video/backlight/corgi_bl.c
deleted file mode 100644
index 4d4d037e3ec9..000000000000
--- a/drivers/video/backlight/corgi_bl.c
+++ /dev/null
@@ -1,169 +0,0 @@
1/*
2 * Backlight Driver for Sharp Zaurus Handhelds (various models)
3 *
4 * Copyright (c) 2004-2006 Richard Purdie
5 *
6 * Based on Sharp's 2.4 Backlight Driver
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 */
13
14#include <linux/module.h>
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/platform_device.h>
18#include <linux/mutex.h>
19#include <linux/fb.h>
20#include <linux/backlight.h>
21
22static int corgibl_intensity;
23static struct backlight_properties corgibl_data;
24static struct backlight_device *corgi_backlight_device;
25static struct generic_bl_info *bl_machinfo;
26
27static unsigned long corgibl_flags;
28#define CORGIBL_SUSPENDED 0x01
29#define CORGIBL_BATTLOW 0x02
30
31static int corgibl_send_intensity(struct backlight_device *bd)
32{
33 int intensity = bd->props.brightness;
34
35 if (bd->props.power != FB_BLANK_UNBLANK)
36 intensity = 0;
37 if (bd->props.fb_blank != FB_BLANK_UNBLANK)
38 intensity = 0;
39 if (corgibl_flags & CORGIBL_SUSPENDED)
40 intensity = 0;
41 if (corgibl_flags & CORGIBL_BATTLOW)
42 intensity &= bl_machinfo->limit_mask;
43
44 bl_machinfo->set_bl_intensity(intensity);
45
46 corgibl_intensity = intensity;
47
48 if (bl_machinfo->kick_battery)
49 bl_machinfo->kick_battery();
50
51 return 0;
52}
53
54#ifdef CONFIG_PM
55static int corgibl_suspend(struct platform_device *pdev, pm_message_t state)
56{
57 struct backlight_device *bd = platform_get_drvdata(pdev);
58
59 corgibl_flags |= CORGIBL_SUSPENDED;
60 backlight_update_status(bd);
61 return 0;
62}
63
64static int corgibl_resume(struct platform_device *pdev)
65{
66 struct backlight_device *bd = platform_get_drvdata(pdev);
67
68 corgibl_flags &= ~CORGIBL_SUSPENDED;
69 backlight_update_status(bd);
70 return 0;
71}
72#else
73#define corgibl_suspend NULL
74#define corgibl_resume NULL
75#endif
76
77static int corgibl_get_intensity(struct backlight_device *bd)
78{
79 return corgibl_intensity;
80}
81
82/*
83 * Called when the battery is low to limit the backlight intensity.
84 * If limit==0 clear any limit, otherwise limit the intensity
85 */
86void corgibl_limit_intensity(int limit)
87{
88 if (limit)
89 corgibl_flags |= CORGIBL_BATTLOW;
90 else
91 corgibl_flags &= ~CORGIBL_BATTLOW;
92 backlight_update_status(corgi_backlight_device);
93}
94EXPORT_SYMBOL(corgibl_limit_intensity);
95
96
97static struct backlight_ops corgibl_ops = {
98 .get_brightness = corgibl_get_intensity,
99 .update_status = corgibl_send_intensity,
100};
101
102static int corgibl_probe(struct platform_device *pdev)
103{
104 struct generic_bl_info *machinfo = pdev->dev.platform_data;
105 const char *name = "generic-bl";
106
107 bl_machinfo = machinfo;
108 if (!machinfo->limit_mask)
109 machinfo->limit_mask = -1;
110
111 if (machinfo->name)
112 name = machinfo->name;
113
114 corgi_backlight_device = backlight_device_register (name,
115 &pdev->dev, NULL, &corgibl_ops);
116 if (IS_ERR (corgi_backlight_device))
117 return PTR_ERR (corgi_backlight_device);
118
119 platform_set_drvdata(pdev, corgi_backlight_device);
120
121 corgi_backlight_device->props.max_brightness = machinfo->max_intensity;
122 corgi_backlight_device->props.power = FB_BLANK_UNBLANK;
123 corgi_backlight_device->props.brightness = machinfo->default_intensity;
124 backlight_update_status(corgi_backlight_device);
125
126 printk("Corgi Backlight Driver Initialized.\n");
127 return 0;
128}
129
130static int corgibl_remove(struct platform_device *pdev)
131{
132 struct backlight_device *bd = platform_get_drvdata(pdev);
133
134 corgibl_data.power = 0;
135 corgibl_data.brightness = 0;
136 backlight_update_status(bd);
137
138 backlight_device_unregister(bd);
139
140 printk("Corgi Backlight Driver Unloaded\n");
141 return 0;
142}
143
144static struct platform_driver corgibl_driver = {
145 .probe = corgibl_probe,
146 .remove = corgibl_remove,
147 .suspend = corgibl_suspend,
148 .resume = corgibl_resume,
149 .driver = {
150 .name = "generic-bl",
151 },
152};
153
154static int __init corgibl_init(void)
155{
156 return platform_driver_register(&corgibl_driver);
157}
158
159static void __exit corgibl_exit(void)
160{
161 platform_driver_unregister(&corgibl_driver);
162}
163
164module_init(corgibl_init);
165module_exit(corgibl_exit);
166
167MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
168MODULE_DESCRIPTION("Corgi Backlight Driver");
169MODULE_LICENSE("GPL");
diff --git a/drivers/video/backlight/cr_bllcd.c b/drivers/video/backlight/cr_bllcd.c
index 26add8898605..b9fe62b475c6 100644
--- a/drivers/video/backlight/cr_bllcd.c
+++ b/drivers/video/backlight/cr_bllcd.c
@@ -259,22 +259,18 @@ static int __init cr_backlight_init(void)
259{ 259{
260 int ret = platform_driver_register(&cr_backlight_driver); 260 int ret = platform_driver_register(&cr_backlight_driver);
261 261
262 if (!ret) { 262 if (ret)
263 crp = platform_device_alloc("cr_backlight", -1); 263 return ret;
264 if (!crp)
265 return -ENOMEM;
266 264
267 ret = platform_device_add(crp); 265 crp = platform_device_register_simple("cr_backlight", -1, NULL, 0);
268 266 if (IS_ERR(crp)) {
269 if (ret) { 267 platform_driver_unregister(&cr_backlight_driver);
270 platform_device_put(crp); 268 return PTR_ERR(crp);
271 platform_driver_unregister(&cr_backlight_driver);
272 }
273 } 269 }
274 270
275 printk("Carillo Ranch Backlight Driver Initialized.\n"); 271 printk("Carillo Ranch Backlight Driver Initialized.\n");
276 272
277 return ret; 273 return 0;
278} 274}
279 275
280static void __exit cr_backlight_exit(void) 276static void __exit cr_backlight_exit(void)
diff --git a/drivers/video/backlight/generic_bl.c b/drivers/video/backlight/generic_bl.c
new file mode 100644
index 000000000000..6d27f62fdcd0
--- /dev/null
+++ b/drivers/video/backlight/generic_bl.c
@@ -0,0 +1,147 @@
1/*
2 * Generic Backlight Driver
3 *
4 * Copyright (c) 2004-2008 Richard Purdie
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 */
11
12#include <linux/module.h>
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/platform_device.h>
16#include <linux/mutex.h>
17#include <linux/fb.h>
18#include <linux/backlight.h>
19
20static int genericbl_intensity;
21static struct backlight_device *generic_backlight_device;
22static struct generic_bl_info *bl_machinfo;
23
24/* Flag to signal when the battery is low */
25#define GENERICBL_BATTLOW BL_CORE_DRIVER1
26
27static int genericbl_send_intensity(struct backlight_device *bd)
28{
29 int intensity = bd->props.brightness;
30
31 if (bd->props.power != FB_BLANK_UNBLANK)
32 intensity = 0;
33 if (bd->props.state & BL_CORE_FBBLANK)
34 intensity = 0;
35 if (bd->props.state & BL_CORE_SUSPENDED)
36 intensity = 0;
37 if (bd->props.state & GENERICBL_BATTLOW)
38 intensity &= bl_machinfo->limit_mask;
39
40 bl_machinfo->set_bl_intensity(intensity);
41
42 genericbl_intensity = intensity;
43
44 if (bl_machinfo->kick_battery)
45 bl_machinfo->kick_battery();
46
47 return 0;
48}
49
50static int genericbl_get_intensity(struct backlight_device *bd)
51{
52 return genericbl_intensity;
53}
54
55/*
56 * Called when the battery is low to limit the backlight intensity.
57 * If limit==0 clear any limit, otherwise limit the intensity
58 */
59void corgibl_limit_intensity(int limit)
60{
61 struct backlight_device *bd = generic_backlight_device;
62
63 mutex_lock(&bd->ops_lock);
64 if (limit)
65 bd->props.state |= GENERICBL_BATTLOW;
66 else
67 bd->props.state &= ~GENERICBL_BATTLOW;
68 backlight_update_status(generic_backlight_device);
69 mutex_unlock(&bd->ops_lock);
70}
71EXPORT_SYMBOL(corgibl_limit_intensity);
72
73static struct backlight_ops genericbl_ops = {
74 .options = BL_CORE_SUSPENDRESUME,
75 .get_brightness = genericbl_get_intensity,
76 .update_status = genericbl_send_intensity,
77};
78
79static int genericbl_probe(struct platform_device *pdev)
80{
81 struct generic_bl_info *machinfo = pdev->dev.platform_data;
82 const char *name = "generic-bl";
83 struct backlight_device *bd;
84
85 bl_machinfo = machinfo;
86 if (!machinfo->limit_mask)
87 machinfo->limit_mask = -1;
88
89 if (machinfo->name)
90 name = machinfo->name;
91
92 bd = backlight_device_register (name,
93 &pdev->dev, NULL, &genericbl_ops);
94 if (IS_ERR (bd))
95 return PTR_ERR (bd);
96
97 platform_set_drvdata(pdev, bd);
98
99 bd->props.max_brightness = machinfo->max_intensity;
100 bd->props.power = FB_BLANK_UNBLANK;
101 bd->props.brightness = machinfo->default_intensity;
102 backlight_update_status(bd);
103
104 generic_backlight_device = bd;
105
106 printk("Generic Backlight Driver Initialized.\n");
107 return 0;
108}
109
110static int genericbl_remove(struct platform_device *pdev)
111{
112 struct backlight_device *bd = platform_get_drvdata(pdev);
113
114 bd->props.power = 0;
115 bd->props.brightness = 0;
116 backlight_update_status(bd);
117
118 backlight_device_unregister(bd);
119
120 printk("Generic Backlight Driver Unloaded\n");
121 return 0;
122}
123
124static struct platform_driver genericbl_driver = {
125 .probe = genericbl_probe,
126 .remove = genericbl_remove,
127 .driver = {
128 .name = "generic-bl",
129 },
130};
131
132static int __init genericbl_init(void)
133{
134 return platform_driver_register(&genericbl_driver);
135}
136
137static void __exit genericbl_exit(void)
138{
139 platform_driver_unregister(&genericbl_driver);
140}
141
142module_init(genericbl_init);
143module_exit(genericbl_exit);
144
145MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
146MODULE_DESCRIPTION("Generic Backlight Driver");
147MODULE_LICENSE("GPL");
diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c
index d4cfed0b26d5..5be55a20d8c7 100644
--- a/drivers/video/backlight/hp680_bl.c
+++ b/drivers/video/backlight/hp680_bl.c
@@ -151,19 +151,15 @@ static int __init hp680bl_init(void)
151 int ret; 151 int ret;
152 152
153 ret = platform_driver_register(&hp680bl_driver); 153 ret = platform_driver_register(&hp680bl_driver);
154 if (!ret) { 154 if (ret)
155 hp680bl_device = platform_device_alloc("hp680-bl", -1); 155 return ret;
156 if (!hp680bl_device) 156 hp680bl_device = platform_device_register_simple("hp680-bl", -1,
157 return -ENOMEM; 157 NULL, 0);
158 158 if (IS_ERR(hp680bl_device)) {
159 ret = platform_device_add(hp680bl_device); 159 platform_driver_unregister(&hp680bl_driver);
160 160 return PTR_ERR(hp680bl_device);
161 if (ret) {
162 platform_device_put(hp680bl_device);
163 platform_driver_unregister(&hp680bl_driver);
164 }
165 } 161 }
166 return ret; 162 return 0;
167} 163}
168 164
169static void __exit hp680bl_exit(void) 165static void __exit hp680bl_exit(void)
diff --git a/drivers/video/backlight/mbp_nvidia_bl.c b/drivers/video/backlight/mbp_nvidia_bl.c
index 06964af761c6..65864c500455 100644
--- a/drivers/video/backlight/mbp_nvidia_bl.c
+++ b/drivers/video/backlight/mbp_nvidia_bl.c
@@ -70,6 +70,7 @@ static int mbp_get_intensity(struct backlight_device *bd)
70} 70}
71 71
72static struct backlight_ops mbp_ops = { 72static struct backlight_ops mbp_ops = {
73 .options = BL_CORE_SUSPENDRESUME,
73 .get_brightness = mbp_get_intensity, 74 .get_brightness = mbp_get_intensity,
74 .update_status = mbp_send_intensity, 75 .update_status = mbp_send_intensity,
75}; 76};
diff --git a/drivers/video/backlight/progear_bl.c b/drivers/video/backlight/progear_bl.c
index 15fb4d58b5bc..9edaf24fd82d 100644
--- a/drivers/video/backlight/progear_bl.c
+++ b/drivers/video/backlight/progear_bl.c
@@ -119,20 +119,16 @@ static int __init progearbl_init(void)
119{ 119{
120 int ret = platform_driver_register(&progearbl_driver); 120 int ret = platform_driver_register(&progearbl_driver);
121 121
122 if (!ret) { 122 if (ret)
123 progearbl_device = platform_device_alloc("progear-bl", -1); 123 return ret;
124 if (!progearbl_device) 124 progearbl_device = platform_device_register_simple("progear-bl", -1,
125 return -ENOMEM; 125 NULL, 0);
126 126 if (IS_ERR(progearbl_device)) {
127 ret = platform_device_add(progearbl_device); 127 platform_driver_unregister(&progearbl_driver);
128 128 return PTR_ERR(progearbl_device);
129 if (ret) {
130 platform_device_put(progearbl_device);
131 platform_driver_unregister(&progearbl_driver);
132 }
133 } 129 }
134 130
135 return ret; 131 return 0;
136} 132}
137 133
138static void __exit progearbl_exit(void) 134static void __exit progearbl_exit(void)
diff --git a/drivers/video/backlight/tdo24m.c b/drivers/video/backlight/tdo24m.c
index 8427669162ea..1dae7f8f3c6b 100644
--- a/drivers/video/backlight/tdo24m.c
+++ b/drivers/video/backlight/tdo24m.c
@@ -14,6 +14,7 @@
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/spi/spi.h> 16#include <linux/spi/spi.h>
17#include <linux/spi/tdo24m.h>
17#include <linux/fb.h> 18#include <linux/fb.h>
18#include <linux/lcd.h> 19#include <linux/lcd.h>
19 20
@@ -31,6 +32,9 @@ struct tdo24m {
31 struct spi_transfer xfer; 32 struct spi_transfer xfer;
32 uint8_t *buf; 33 uint8_t *buf;
33 34
35 int (*adj_mode)(struct tdo24m *lcd, int mode);
36 int color_invert;
37
34 int power; 38 int power;
35 int mode; 39 int mode;
36}; 40};
@@ -66,7 +70,7 @@ static uint32_t lcd_panel_off[] = {
66 CMD_NULL, 70 CMD_NULL,
67}; 71};
68 72
69static uint32_t lcd_vga_pass_through[] = { 73static uint32_t lcd_vga_pass_through_tdo24m[] = {
70 CMD1(0xB0, 0x16), 74 CMD1(0xB0, 0x16),
71 CMD1(0xBC, 0x80), 75 CMD1(0xBC, 0x80),
72 CMD1(0xE1, 0x00), 76 CMD1(0xE1, 0x00),
@@ -75,7 +79,7 @@ static uint32_t lcd_vga_pass_through[] = {
75 CMD_NULL, 79 CMD_NULL,
76}; 80};
77 81
78static uint32_t lcd_qvga_pass_through[] = { 82static uint32_t lcd_qvga_pass_through_tdo24m[] = {
79 CMD1(0xB0, 0x16), 83 CMD1(0xB0, 0x16),
80 CMD1(0xBC, 0x81), 84 CMD1(0xBC, 0x81),
81 CMD1(0xE1, 0x00), 85 CMD1(0xE1, 0x00),
@@ -84,7 +88,7 @@ static uint32_t lcd_qvga_pass_through[] = {
84 CMD_NULL, 88 CMD_NULL,
85}; 89};
86 90
87static uint32_t lcd_vga_transfer[] = { 91static uint32_t lcd_vga_transfer_tdo24m[] = {
88 CMD1(0xcf, 0x02), /* Blanking period control (1) */ 92 CMD1(0xcf, 0x02), /* Blanking period control (1) */
89 CMD2(0xd0, 0x08, 0x04), /* Blanking period control (2) */ 93 CMD2(0xd0, 0x08, 0x04), /* Blanking period control (2) */
90 CMD1(0xd1, 0x01), /* CKV timing control on/off */ 94 CMD1(0xd1, 0x01), /* CKV timing control on/off */
@@ -110,6 +114,35 @@ static uint32_t lcd_qvga_transfer[] = {
110 CMD_NULL, 114 CMD_NULL,
111}; 115};
112 116
117static uint32_t lcd_vga_pass_through_tdo35s[] = {
118 CMD1(0xB0, 0x16),
119 CMD1(0xBC, 0x80),
120 CMD1(0xE1, 0x00),
121 CMD1(0x3B, 0x00),
122 CMD_NULL,
123};
124
125static uint32_t lcd_qvga_pass_through_tdo35s[] = {
126 CMD1(0xB0, 0x16),
127 CMD1(0xBC, 0x81),
128 CMD1(0xE1, 0x00),
129 CMD1(0x3B, 0x22),
130 CMD_NULL,
131};
132
133static uint32_t lcd_vga_transfer_tdo35s[] = {
134 CMD1(0xcf, 0x02), /* Blanking period control (1) */
135 CMD2(0xd0, 0x08, 0x04), /* Blanking period control (2) */
136 CMD1(0xd1, 0x01), /* CKV timing control on/off */
137 CMD2(0xd2, 0x00, 0x1e), /* CKV 1,2 timing control */
138 CMD2(0xd3, 0x14, 0x28), /* OEV timing control */
139 CMD2(0xd4, 0x28, 0x64), /* ASW timing control (1) */
140 CMD1(0xd5, 0x28), /* ASW timing control (2) */
141 CMD0(0x21), /* Invert for normally black display */
142 CMD0(0x29), /* Display on */
143 CMD_NULL,
144};
145
113static uint32_t lcd_panel_config[] = { 146static uint32_t lcd_panel_config[] = {
114 CMD2(0xb8, 0xff, 0xf9), /* Output control */ 147 CMD2(0xb8, 0xff, 0xf9), /* Output control */
115 CMD0(0x11), /* sleep out */ 148 CMD0(0x11), /* sleep out */
@@ -148,6 +181,8 @@ static int tdo24m_writes(struct tdo24m *lcd, uint32_t *array)
148 int nparams, err = 0; 181 int nparams, err = 0;
149 182
150 for (; *p != CMD_NULL; p++) { 183 for (; *p != CMD_NULL; p++) {
184 if (!lcd->color_invert && *p == CMD0(0x21))
185 continue;
151 186
152 nparams = (*p >> 30) & 0x3; 187 nparams = (*p >> 30) & 0x3;
153 188
@@ -184,12 +219,33 @@ static int tdo24m_adj_mode(struct tdo24m *lcd, int mode)
184{ 219{
185 switch (mode) { 220 switch (mode) {
186 case MODE_VGA: 221 case MODE_VGA:
187 tdo24m_writes(lcd, lcd_vga_pass_through); 222 tdo24m_writes(lcd, lcd_vga_pass_through_tdo24m);
188 tdo24m_writes(lcd, lcd_panel_config); 223 tdo24m_writes(lcd, lcd_panel_config);
189 tdo24m_writes(lcd, lcd_vga_transfer); 224 tdo24m_writes(lcd, lcd_vga_transfer_tdo24m);
190 break; 225 break;
191 case MODE_QVGA: 226 case MODE_QVGA:
192 tdo24m_writes(lcd, lcd_qvga_pass_through); 227 tdo24m_writes(lcd, lcd_qvga_pass_through_tdo24m);
228 tdo24m_writes(lcd, lcd_panel_config);
229 tdo24m_writes(lcd, lcd_qvga_transfer);
230 break;
231 default:
232 return -EINVAL;
233 }
234
235 lcd->mode = mode;
236 return 0;
237}
238
239static int tdo35s_adj_mode(struct tdo24m *lcd, int mode)
240{
241 switch (mode) {
242 case MODE_VGA:
243 tdo24m_writes(lcd, lcd_vga_pass_through_tdo35s);
244 tdo24m_writes(lcd, lcd_panel_config);
245 tdo24m_writes(lcd, lcd_vga_transfer_tdo35s);
246 break;
247 case MODE_QVGA:
248 tdo24m_writes(lcd, lcd_qvga_pass_through_tdo35s);
193 tdo24m_writes(lcd, lcd_panel_config); 249 tdo24m_writes(lcd, lcd_panel_config);
194 tdo24m_writes(lcd, lcd_qvga_transfer); 250 tdo24m_writes(lcd, lcd_qvga_transfer);
195 break; 251 break;
@@ -213,7 +269,7 @@ static int tdo24m_power_on(struct tdo24m *lcd)
213 if (err) 269 if (err)
214 goto out; 270 goto out;
215 271
216 err = tdo24m_adj_mode(lcd, lcd->mode); 272 err = lcd->adj_mode(lcd, lcd->mode);
217out: 273out:
218 return err; 274 return err;
219} 275}
@@ -262,7 +318,7 @@ static int tdo24m_set_mode(struct lcd_device *ld, struct fb_videomode *m)
262 if (lcd->mode == mode) 318 if (lcd->mode == mode)
263 return 0; 319 return 0;
264 320
265 return tdo24m_adj_mode(lcd, mode); 321 return lcd->adj_mode(lcd, mode);
266} 322}
267 323
268static struct lcd_ops tdo24m_ops = { 324static struct lcd_ops tdo24m_ops = {
@@ -276,8 +332,16 @@ static int __devinit tdo24m_probe(struct spi_device *spi)
276 struct tdo24m *lcd; 332 struct tdo24m *lcd;
277 struct spi_message *m; 333 struct spi_message *m;
278 struct spi_transfer *x; 334 struct spi_transfer *x;
335 struct tdo24m_platform_data *pdata;
336 enum tdo24m_model model;
279 int err; 337 int err;
280 338
339 pdata = spi->dev.platform_data;
340 if (pdata)
341 model = pdata->model;
342 else
343 model = TDO24M;
344
281 spi->bits_per_word = 8; 345 spi->bits_per_word = 8;
282 spi->mode = SPI_MODE_3; 346 spi->mode = SPI_MODE_3;
283 err = spi_setup(spi); 347 err = spi_setup(spi);
@@ -306,6 +370,20 @@ static int __devinit tdo24m_probe(struct spi_device *spi)
306 x->tx_buf = &lcd->buf[0]; 370 x->tx_buf = &lcd->buf[0];
307 spi_message_add_tail(x, m); 371 spi_message_add_tail(x, m);
308 372
373 switch (model) {
374 case TDO24M:
375 lcd->color_invert = 1;
376 lcd->adj_mode = tdo24m_adj_mode;
377 break;
378 case TDO35S:
379 lcd->adj_mode = tdo35s_adj_mode;
380 lcd->color_invert = 0;
381 break;
382 default:
383 dev_err(&spi->dev, "Unsupported model");
384 goto out_free;
385 }
386
309 lcd->lcd_dev = lcd_device_register("tdo24m", &spi->dev, 387 lcd->lcd_dev = lcd_device_register("tdo24m", &spi->dev,
310 lcd, &tdo24m_ops); 388 lcd, &tdo24m_ops);
311 if (IS_ERR(lcd->lcd_dev)) { 389 if (IS_ERR(lcd->lcd_dev)) {
diff --git a/drivers/video/backlight/tosa_lcd.c b/drivers/video/backlight/tosa_lcd.c
index 57a26649f1a5..b7fbc75a62fc 100644
--- a/drivers/video/backlight/tosa_lcd.c
+++ b/drivers/video/backlight/tosa_lcd.c
@@ -39,6 +39,7 @@ struct tosa_lcd_data {
39 struct i2c_client *i2c; 39 struct i2c_client *i2c;
40 40
41 int lcd_power; 41 int lcd_power;
42 bool is_vga;
42}; 43};
43 44
44static int tosa_tg_send(struct spi_device *spi, int adrs, uint8_t data) 45static int tosa_tg_send(struct spi_device *spi, int adrs, uint8_t data)
@@ -81,8 +82,12 @@ static void tosa_lcd_tg_init(struct tosa_lcd_data *data)
81static void tosa_lcd_tg_on(struct tosa_lcd_data *data) 82static void tosa_lcd_tg_on(struct tosa_lcd_data *data)
82{ 83{
83 struct spi_device *spi = data->spi; 84 struct spi_device *spi = data->spi;
84 const int value = TG_REG0_COLOR | TG_REG0_UD | TG_REG0_LR; 85 int value = TG_REG0_COLOR | TG_REG0_UD | TG_REG0_LR;
85 tosa_tg_send(spi, TG_PNLCTL, value | TG_REG0_VQV); /* this depends on mode */ 86
87 if (data->is_vga)
88 value |= TG_REG0_VQV;
89
90 tosa_tg_send(spi, TG_PNLCTL, value);
86 91
87 /* TG LCD pannel power up */ 92 /* TG LCD pannel power up */
88 tosa_tg_send(spi, TG_PINICTL,0x4); 93 tosa_tg_send(spi, TG_PINICTL,0x4);
@@ -142,9 +147,25 @@ static int tosa_lcd_get_power(struct lcd_device *lcd)
142 return data->lcd_power; 147 return data->lcd_power;
143} 148}
144 149
150static int tosa_lcd_set_mode(struct lcd_device *lcd, struct fb_videomode *mode)
151{
152 struct tosa_lcd_data *data = lcd_get_data(lcd);
153
154 if (mode->xres == 320 || mode->yres == 320)
155 data->is_vga = false;
156 else
157 data->is_vga = true;
158
159 if (POWER_IS_ON(data->lcd_power))
160 tosa_lcd_tg_on(data);
161
162 return 0;
163}
164
145static struct lcd_ops tosa_lcd_ops = { 165static struct lcd_ops tosa_lcd_ops = {
146 .set_power = tosa_lcd_set_power, 166 .set_power = tosa_lcd_set_power,
147 .get_power = tosa_lcd_get_power, 167 .get_power = tosa_lcd_get_power,
168 .set_mode = tosa_lcd_set_mode,
148}; 169};
149 170
150static int __devinit tosa_lcd_probe(struct spi_device *spi) 171static int __devinit tosa_lcd_probe(struct spi_device *spi)
@@ -156,6 +177,8 @@ static int __devinit tosa_lcd_probe(struct spi_device *spi)
156 if (!data) 177 if (!data)
157 return -ENOMEM; 178 return -ENOMEM;
158 179
180 data->is_vga = true; /* defaut to VGA mode */
181
159 /* 182 /*
160 * bits_per_word cannot be configured in platform data 183 * bits_per_word cannot be configured in platform data
161 */ 184 */
diff --git a/drivers/video/backlight/vgg2432a4.c b/drivers/video/backlight/vgg2432a4.c
index 593c7687d54a..8e653b8a6f17 100644
--- a/drivers/video/backlight/vgg2432a4.c
+++ b/drivers/video/backlight/vgg2432a4.c
@@ -137,7 +137,7 @@ static int vgg2432a4_lcd_init(struct ili9320 *lcd,
137 137
138 ili9320_write(lcd, ILI9320_RGB_IF1, cfg->rgb_if1); 138 ili9320_write(lcd, ILI9320_RGB_IF1, cfg->rgb_if1);
139 ili9320_write(lcd, ILI9320_FRAMEMAKER, 0x0); 139 ili9320_write(lcd, ILI9320_FRAMEMAKER, 0x0);
140 ili9320_write(lcd, ILI9320_RGB_IF2, ILI9320_RGBIF2_DPL); 140 ili9320_write(lcd, ILI9320_RGB_IF2, cfg->rgb_if2);
141 141
142 ret = ili9320_write_regs(lcd, vgg_init1, ARRAY_SIZE(vgg_init1)); 142 ret = ili9320_write_regs(lcd, vgg_init1, ARRAY_SIZE(vgg_init1));
143 if (ret != 0) 143 if (ret != 0)
diff --git a/drivers/video/bf54x-lq043fb.c b/drivers/video/bf54x-lq043fb.c
index 7644ed249564..37e60b1d2ed9 100644
--- a/drivers/video/bf54x-lq043fb.c
+++ b/drivers/video/bf54x-lq043fb.c
@@ -335,7 +335,20 @@ static int bfin_bf54x_fb_check_var(struct fb_var_screeninfo *var,
335 struct fb_info *info) 335 struct fb_info *info)
336{ 336{
337 337
338 if (var->bits_per_pixel != LCD_BPP) { 338 switch (var->bits_per_pixel) {
339 case 24:/* TRUECOLOUR, 16m */
340 var->red.offset = 16;
341 var->green.offset = 8;
342 var->blue.offset = 0;
343 var->red.length = var->green.length = var->blue.length = 8;
344 var->transp.offset = 0;
345 var->transp.length = 0;
346 var->transp.msb_right = 0;
347 var->red.msb_right = 0;
348 var->green.msb_right = 0;
349 var->blue.msb_right = 0;
350 break;
351 default:
339 pr_debug("%s: depth not supported: %u BPP\n", __func__, 352 pr_debug("%s: depth not supported: %u BPP\n", __func__,
340 var->bits_per_pixel); 353 var->bits_per_pixel);
341 return -EINVAL; 354 return -EINVAL;
diff --git a/drivers/video/bfin-t350mcqb-fb.c b/drivers/video/bfin-t350mcqb-fb.c
index a9b3ada05d99..2a423d3a2a8e 100644
--- a/drivers/video/bfin-t350mcqb-fb.c
+++ b/drivers/video/bfin-t350mcqb-fb.c
@@ -254,7 +254,20 @@ static int bfin_t350mcqb_fb_check_var(struct fb_var_screeninfo *var,
254 struct fb_info *info) 254 struct fb_info *info)
255{ 255{
256 256
257 if (var->bits_per_pixel != LCD_BPP) { 257 switch (var->bits_per_pixel) {
258 case 24:/* TRUECOLOUR, 16m */
259 var->red.offset = 0;
260 var->green.offset = 8;
261 var->blue.offset = 16;
262 var->red.length = var->green.length = var->blue.length = 8;
263 var->transp.offset = 0;
264 var->transp.length = 0;
265 var->transp.msb_right = 0;
266 var->red.msb_right = 0;
267 var->green.msb_right = 0;
268 var->blue.msb_right = 0;
269 break;
270 default:
258 pr_debug("%s: depth not supported: %u BPP\n", __func__, 271 pr_debug("%s: depth not supported: %u BPP\n", __func__,
259 var->bits_per_pixel); 272 var->bits_per_pixel);
260 return -EINVAL; 273 return -EINVAL;
diff --git a/drivers/video/c2p.c b/drivers/video/c2p.c
deleted file mode 100644
index 376bc07ff952..000000000000
--- a/drivers/video/c2p.c
+++ /dev/null
@@ -1,232 +0,0 @@
1/*
2 * Fast C2P (Chunky-to-Planar) Conversion
3 *
4 * Copyright (C) 2003 Geert Uytterhoeven
5 *
6 * NOTES:
7 * - This code was inspired by Scout's C2P tutorial
8 * - It assumes to run on a big endian system
9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file COPYING in the main directory of this archive
12 * for more details.
13 */
14
15#include <linux/module.h>
16#include <linux/string.h>
17#include "c2p.h"
18
19
20 /*
21 * Basic transpose step
22 */
23
24#define _transp(d, i1, i2, shift, mask) \
25 do { \
26 u32 t = (d[i1] ^ (d[i2] >> shift)) & mask; \
27 d[i1] ^= t; \
28 d[i2] ^= t << shift; \
29 } while (0)
30
31static inline u32 get_mask(int n)
32{
33 switch (n) {
34 case 1:
35 return 0x55555555;
36 break;
37
38 case 2:
39 return 0x33333333;
40 break;
41
42 case 4:
43 return 0x0f0f0f0f;
44 break;
45
46 case 8:
47 return 0x00ff00ff;
48 break;
49
50 case 16:
51 return 0x0000ffff;
52 break;
53 }
54 return 0;
55}
56
57#define transp_nx1(d, n) \
58 do { \
59 u32 mask = get_mask(n); \
60 /* First block */ \
61 _transp(d, 0, 1, n, mask); \
62 /* Second block */ \
63 _transp(d, 2, 3, n, mask); \
64 /* Third block */ \
65 _transp(d, 4, 5, n, mask); \
66 /* Fourth block */ \
67 _transp(d, 6, 7, n, mask); \
68 } while (0)
69
70#define transp_nx2(d, n) \
71 do { \
72 u32 mask = get_mask(n); \
73 /* First block */ \
74 _transp(d, 0, 2, n, mask); \
75 _transp(d, 1, 3, n, mask); \
76 /* Second block */ \
77 _transp(d, 4, 6, n, mask); \
78 _transp(d, 5, 7, n, mask); \
79 } while (0)
80
81#define transp_nx4(d, n) \
82 do { \
83 u32 mask = get_mask(n); \
84 _transp(d, 0, 4, n, mask); \
85 _transp(d, 1, 5, n, mask); \
86 _transp(d, 2, 6, n, mask); \
87 _transp(d, 3, 7, n, mask); \
88 } while (0)
89
90#define transp(d, n, m) transp_nx ## m(d, n)
91
92
93 /*
94 * Perform a full C2P step on 32 8-bit pixels, stored in 8 32-bit words
95 * containing
96 * - 32 8-bit chunky pixels on input
97 * - permuted planar data on output
98 */
99
100static void c2p_8bpp(u32 d[8])
101{
102 transp(d, 16, 4);
103 transp(d, 8, 2);
104 transp(d, 4, 1);
105 transp(d, 2, 4);
106 transp(d, 1, 2);
107}
108
109
110 /*
111 * Array containing the permution indices of the planar data after c2p
112 */
113
114static const int perm_c2p_8bpp[8] = { 7, 5, 3, 1, 6, 4, 2, 0 };
115
116
117 /*
118 * Compose two values, using a bitmask as decision value
119 * This is equivalent to (a & mask) | (b & ~mask)
120 */
121
122static inline unsigned long comp(unsigned long a, unsigned long b,
123 unsigned long mask)
124{
125 return ((a ^ b) & mask) ^ b;
126}
127
128
129 /*
130 * Store a full block of planar data after c2p conversion
131 */
132
133static inline void store_planar(char *dst, u32 dst_inc, u32 bpp, u32 d[8])
134{
135 int i;
136
137 for (i = 0; i < bpp; i++, dst += dst_inc)
138 *(u32 *)dst = d[perm_c2p_8bpp[i]];
139}
140
141
142 /*
143 * Store a partial block of planar data after c2p conversion
144 */
145
146static inline void store_planar_masked(char *dst, u32 dst_inc, u32 bpp,
147 u32 d[8], u32 mask)
148{
149 int i;
150
151 for (i = 0; i < bpp; i++, dst += dst_inc)
152 *(u32 *)dst = comp(d[perm_c2p_8bpp[i]], *(u32 *)dst, mask);
153}
154
155
156 /*
157 * c2p - Copy 8-bit chunky image data to a planar frame buffer
158 * @dst: Starting address of the planar frame buffer
159 * @dx: Horizontal destination offset (in pixels)
160 * @dy: Vertical destination offset (in pixels)
161 * @width: Image width (in pixels)
162 * @height: Image height (in pixels)
163 * @dst_nextline: Frame buffer offset to the next line (in bytes)
164 * @dst_nextplane: Frame buffer offset to the next plane (in bytes)
165 * @src_nextline: Image offset to the next line (in bytes)
166 * @bpp: Bits per pixel of the planar frame buffer (1-8)
167 */
168
169void c2p(u8 *dst, const u8 *src, u32 dx, u32 dy, u32 width, u32 height,
170 u32 dst_nextline, u32 dst_nextplane, u32 src_nextline, u32 bpp)
171{
172 int dst_idx;
173 u32 d[8], first, last, w;
174 const u8 *c;
175 u8 *p;
176
177 dst += dy*dst_nextline+(dx & ~31);
178 dst_idx = dx % 32;
179 first = ~0UL >> dst_idx;
180 last = ~(~0UL >> ((dst_idx+width) % 32));
181 while (height--) {
182 c = src;
183 p = dst;
184 w = width;
185 if (dst_idx+width <= 32) {
186 /* Single destination word */
187 first &= last;
188 memset(d, 0, sizeof(d));
189 memcpy((u8 *)d+dst_idx, c, width);
190 c += width;
191 c2p_8bpp(d);
192 store_planar_masked(p, dst_nextplane, bpp, d, first);
193 p += 4;
194 } else {
195 /* Multiple destination words */
196 w = width;
197 /* Leading bits */
198 if (dst_idx) {
199 w = 32 - dst_idx;
200 memset(d, 0, dst_idx);
201 memcpy((u8 *)d+dst_idx, c, w);
202 c += w;
203 c2p_8bpp(d);
204 store_planar_masked(p, dst_nextplane, bpp, d, first);
205 p += 4;
206 w = width-w;
207 }
208 /* Main chunk */
209 while (w >= 32) {
210 memcpy(d, c, 32);
211 c += 32;
212 c2p_8bpp(d);
213 store_planar(p, dst_nextplane, bpp, d);
214 p += 4;
215 w -= 32;
216 }
217 /* Trailing bits */
218 w %= 32;
219 if (w > 0) {
220 memcpy(d, c, w);
221 memset((u8 *)d+w, 0, 32-w);
222 c2p_8bpp(d);
223 store_planar_masked(p, dst_nextplane, bpp, d, last);
224 }
225 }
226 src += src_nextline;
227 dst += dst_nextline;
228 }
229}
230EXPORT_SYMBOL_GPL(c2p);
231
232MODULE_LICENSE("GPL");
diff --git a/drivers/video/c2p.h b/drivers/video/c2p.h
index c77cbf17e043..6c38d40427d8 100644
--- a/drivers/video/c2p.h
+++ b/drivers/video/c2p.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Fast C2P (Chunky-to-Planar) Conversion 2 * Fast C2P (Chunky-to-Planar) Conversion
3 * 3 *
4 * Copyright (C) 2003 Geert Uytterhoeven 4 * Copyright (C) 2003-2008 Geert Uytterhoeven
5 * 5 *
6 * This file is subject to the terms and conditions of the GNU General Public 6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive 7 * License. See the file COPYING in the main directory of this archive
@@ -10,7 +10,10 @@
10 10
11#include <linux/types.h> 11#include <linux/types.h>
12 12
13extern void c2p(u8 *dst, const u8 *src, u32 dx, u32 dy, u32 width, u32 height, 13extern void c2p_planar(void *dst, const void *src, u32 dx, u32 dy, u32 width,
14 u32 dst_nextline, u32 dst_nextplane, u32 src_nextline, 14 u32 height, u32 dst_nextline, u32 dst_nextplane,
15 u32 bpp); 15 u32 src_nextline, u32 bpp);
16 16
17extern void c2p_iplan2(void *dst, const void *src, u32 dx, u32 dy, u32 width,
18 u32 height, u32 dst_nextline, u32 src_nextline,
19 u32 bpp);
diff --git a/drivers/video/c2p_core.h b/drivers/video/c2p_core.h
new file mode 100644
index 000000000000..e1035a865fb9
--- /dev/null
+++ b/drivers/video/c2p_core.h
@@ -0,0 +1,153 @@
1/*
2 * Fast C2P (Chunky-to-Planar) Conversion
3 *
4 * Copyright (C) 2003-2008 Geert Uytterhoeven
5 *
6 * NOTES:
7 * - This code was inspired by Scout's C2P tutorial
8 * - It assumes to run on a big endian system
9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file COPYING in the main directory of this archive
12 * for more details.
13 */
14
15
16 /*
17 * Basic transpose step
18 */
19
20static inline void _transp(u32 d[], unsigned int i1, unsigned int i2,
21 unsigned int shift, u32 mask)
22{
23 u32 t = (d[i1] ^ (d[i2] >> shift)) & mask;
24
25 d[i1] ^= t;
26 d[i2] ^= t << shift;
27}
28
29
30extern void c2p_unsupported(void);
31
32static inline u32 get_mask(unsigned int n)
33{
34 switch (n) {
35 case 1:
36 return 0x55555555;
37
38 case 2:
39 return 0x33333333;
40
41 case 4:
42 return 0x0f0f0f0f;
43
44 case 8:
45 return 0x00ff00ff;
46
47 case 16:
48 return 0x0000ffff;
49 }
50
51 c2p_unsupported();
52 return 0;
53}
54
55
56 /*
57 * Transpose operations on 8 32-bit words
58 */
59
60static inline void transp8(u32 d[], unsigned int n, unsigned int m)
61{
62 u32 mask = get_mask(n);
63
64 switch (m) {
65 case 1:
66 /* First n x 1 block */
67 _transp(d, 0, 1, n, mask);
68 /* Second n x 1 block */
69 _transp(d, 2, 3, n, mask);
70 /* Third n x 1 block */
71 _transp(d, 4, 5, n, mask);
72 /* Fourth n x 1 block */
73 _transp(d, 6, 7, n, mask);
74 return;
75
76 case 2:
77 /* First n x 2 block */
78 _transp(d, 0, 2, n, mask);
79 _transp(d, 1, 3, n, mask);
80 /* Second n x 2 block */
81 _transp(d, 4, 6, n, mask);
82 _transp(d, 5, 7, n, mask);
83 return;
84
85 case 4:
86 /* Single n x 4 block */
87 _transp(d, 0, 4, n, mask);
88 _transp(d, 1, 5, n, mask);
89 _transp(d, 2, 6, n, mask);
90 _transp(d, 3, 7, n, mask);
91 return;
92 }
93
94 c2p_unsupported();
95}
96
97
98 /*
99 * Transpose operations on 4 32-bit words
100 */
101
102static inline void transp4(u32 d[], unsigned int n, unsigned int m)
103{
104 u32 mask = get_mask(n);
105
106 switch (m) {
107 case 1:
108 /* First n x 1 block */
109 _transp(d, 0, 1, n, mask);
110 /* Second n x 1 block */
111 _transp(d, 2, 3, n, mask);
112 return;
113
114 case 2:
115 /* Single n x 2 block */
116 _transp(d, 0, 2, n, mask);
117 _transp(d, 1, 3, n, mask);
118 return;
119 }
120
121 c2p_unsupported();
122}
123
124
125 /*
126 * Transpose operations on 4 32-bit words (reverse order)
127 */
128
129static inline void transp4x(u32 d[], unsigned int n, unsigned int m)
130{
131 u32 mask = get_mask(n);
132
133 switch (m) {
134 case 2:
135 /* Single n x 2 block */
136 _transp(d, 2, 0, n, mask);
137 _transp(d, 3, 1, n, mask);
138 return;
139 }
140
141 c2p_unsupported();
142}
143
144
145 /*
146 * Compose two values, using a bitmask as decision value
147 * This is equivalent to (a & mask) | (b & ~mask)
148 */
149
150static inline u32 comp(u32 a, u32 b, u32 mask)
151{
152 return ((a ^ b) & mask) ^ b;
153}
diff --git a/drivers/video/c2p_iplan2.c b/drivers/video/c2p_iplan2.c
new file mode 100644
index 000000000000..19156dc6158c
--- /dev/null
+++ b/drivers/video/c2p_iplan2.c
@@ -0,0 +1,153 @@
1/*
2 * Fast C2P (Chunky-to-Planar) Conversion
3 *
4 * Copyright (C) 2003-2008 Geert Uytterhoeven
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive
8 * for more details.
9 */
10
11#include <linux/module.h>
12#include <linux/string.h>
13
14#include <asm/unaligned.h>
15
16#include "c2p.h"
17#include "c2p_core.h"
18
19
20 /*
21 * Perform a full C2P step on 16 8-bit pixels, stored in 4 32-bit words
22 * containing
23 * - 16 8-bit chunky pixels on input
24 * - permutated planar data (2 planes per 32-bit word) on output
25 */
26
27static void c2p_16x8(u32 d[4])
28{
29 transp4(d, 8, 2);
30 transp4(d, 1, 2);
31 transp4x(d, 16, 2);
32 transp4x(d, 2, 2);
33 transp4(d, 4, 1);
34}
35
36
37 /*
38 * Array containing the permutation indices of the planar data after c2p
39 */
40
41static const int perm_c2p_16x8[4] = { 1, 3, 0, 2 };
42
43
44 /*
45 * Store a full block of iplan2 data after c2p conversion
46 */
47
48static inline void store_iplan2(void *dst, u32 bpp, u32 d[4])
49{
50 int i;
51
52 for (i = 0; i < bpp/2; i++, dst += 4)
53 put_unaligned_be32(d[perm_c2p_16x8[i]], dst);
54}
55
56
57 /*
58 * Store a partial block of iplan2 data after c2p conversion
59 */
60
61static inline void store_iplan2_masked(void *dst, u32 bpp, u32 d[4], u32 mask)
62{
63 int i;
64
65 for (i = 0; i < bpp/2; i++, dst += 4)
66 put_unaligned_be32(comp(d[perm_c2p_16x8[i]],
67 get_unaligned_be32(dst), mask),
68 dst);
69}
70
71
72 /*
73 * c2p_iplan2 - Copy 8-bit chunky image data to an interleaved planar
74 * frame buffer with 2 bytes of interleave
75 * @dst: Starting address of the planar frame buffer
76 * @dx: Horizontal destination offset (in pixels)
77 * @dy: Vertical destination offset (in pixels)
78 * @width: Image width (in pixels)
79 * @height: Image height (in pixels)
80 * @dst_nextline: Frame buffer offset to the next line (in bytes)
81 * @src_nextline: Image offset to the next line (in bytes)
82 * @bpp: Bits per pixel of the planar frame buffer (2, 4, or 8)
83 */
84
85void c2p_iplan2(void *dst, const void *src, u32 dx, u32 dy, u32 width,
86 u32 height, u32 dst_nextline, u32 src_nextline, u32 bpp)
87{
88 union {
89 u8 pixels[16];
90 u32 words[4];
91 } d;
92 u32 dst_idx, first, last, w;
93 const u8 *c;
94 void *p;
95
96 dst += dy*dst_nextline+(dx & ~15)*bpp;
97 dst_idx = dx % 16;
98 first = 0xffffU >> dst_idx;
99 first |= first << 16;
100 last = 0xffffU ^ (0xffffU >> ((dst_idx+width) % 16));
101 last |= last << 16;
102 while (height--) {
103 c = src;
104 p = dst;
105 w = width;
106 if (dst_idx+width <= 16) {
107 /* Single destination word */
108 first &= last;
109 memset(d.pixels, 0, sizeof(d));
110 memcpy(d.pixels+dst_idx, c, width);
111 c += width;
112 c2p_16x8(d.words);
113 store_iplan2_masked(p, bpp, d.words, first);
114 p += bpp*2;
115 } else {
116 /* Multiple destination words */
117 w = width;
118 /* Leading bits */
119 if (dst_idx) {
120 w = 16 - dst_idx;
121 memset(d.pixels, 0, dst_idx);
122 memcpy(d.pixels+dst_idx, c, w);
123 c += w;
124 c2p_16x8(d.words);
125 store_iplan2_masked(p, bpp, d.words, first);
126 p += bpp*2;
127 w = width-w;
128 }
129 /* Main chunk */
130 while (w >= 16) {
131 memcpy(d.pixels, c, 16);
132 c += 16;
133 c2p_16x8(d.words);
134 store_iplan2(p, bpp, d.words);
135 p += bpp*2;
136 w -= 16;
137 }
138 /* Trailing bits */
139 w %= 16;
140 if (w > 0) {
141 memcpy(d.pixels, c, w);
142 memset(d.pixels+w, 0, 16-w);
143 c2p_16x8(d.words);
144 store_iplan2_masked(p, bpp, d.words, last);
145 }
146 }
147 src += src_nextline;
148 dst += dst_nextline;
149 }
150}
151EXPORT_SYMBOL_GPL(c2p_iplan2);
152
153MODULE_LICENSE("GPL");
diff --git a/drivers/video/c2p_planar.c b/drivers/video/c2p_planar.c
new file mode 100644
index 000000000000..ec7ac8526f06
--- /dev/null
+++ b/drivers/video/c2p_planar.c
@@ -0,0 +1,156 @@
1/*
2 * Fast C2P (Chunky-to-Planar) Conversion
3 *
4 * Copyright (C) 2003-2008 Geert Uytterhoeven
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive
8 * for more details.
9 */
10
11#include <linux/module.h>
12#include <linux/string.h>
13
14#include <asm/unaligned.h>
15
16#include "c2p.h"
17#include "c2p_core.h"
18
19
20 /*
21 * Perform a full C2P step on 32 8-bit pixels, stored in 8 32-bit words
22 * containing
23 * - 32 8-bit chunky pixels on input
24 * - permutated planar data (1 plane per 32-bit word) on output
25 */
26
27static void c2p_32x8(u32 d[8])
28{
29 transp8(d, 16, 4);
30 transp8(d, 8, 2);
31 transp8(d, 4, 1);
32 transp8(d, 2, 4);
33 transp8(d, 1, 2);
34}
35
36
37 /*
38 * Array containing the permutation indices of the planar data after c2p
39 */
40
41static const int perm_c2p_32x8[8] = { 7, 5, 3, 1, 6, 4, 2, 0 };
42
43
44 /*
45 * Store a full block of planar data after c2p conversion
46 */
47
48static inline void store_planar(void *dst, u32 dst_inc, u32 bpp, u32 d[8])
49{
50 int i;
51
52 for (i = 0; i < bpp; i++, dst += dst_inc)
53 put_unaligned_be32(d[perm_c2p_32x8[i]], dst);
54}
55
56
57 /*
58 * Store a partial block of planar data after c2p conversion
59 */
60
61static inline void store_planar_masked(void *dst, u32 dst_inc, u32 bpp,
62 u32 d[8], u32 mask)
63{
64 int i;
65
66 for (i = 0; i < bpp; i++, dst += dst_inc)
67 put_unaligned_be32(comp(d[perm_c2p_32x8[i]],
68 get_unaligned_be32(dst), mask),
69 dst);
70}
71
72
73 /*
74 * c2p_planar - Copy 8-bit chunky image data to a planar frame buffer
75 * @dst: Starting address of the planar frame buffer
76 * @dx: Horizontal destination offset (in pixels)
77 * @dy: Vertical destination offset (in pixels)
78 * @width: Image width (in pixels)
79 * @height: Image height (in pixels)
80 * @dst_nextline: Frame buffer offset to the next line (in bytes)
81 * @dst_nextplane: Frame buffer offset to the next plane (in bytes)
82 * @src_nextline: Image offset to the next line (in bytes)
83 * @bpp: Bits per pixel of the planar frame buffer (1-8)
84 */
85
86void c2p_planar(void *dst, const void *src, u32 dx, u32 dy, u32 width,
87 u32 height, u32 dst_nextline, u32 dst_nextplane,
88 u32 src_nextline, u32 bpp)
89{
90 union {
91 u8 pixels[32];
92 u32 words[8];
93 } d;
94 u32 dst_idx, first, last, w;
95 const u8 *c;
96 void *p;
97
98 dst += dy*dst_nextline+(dx & ~31);
99 dst_idx = dx % 32;
100 first = 0xffffffffU >> dst_idx;
101 last = ~(0xffffffffU >> ((dst_idx+width) % 32));
102 while (height--) {
103 c = src;
104 p = dst;
105 w = width;
106 if (dst_idx+width <= 32) {
107 /* Single destination word */
108 first &= last;
109 memset(d.pixels, 0, sizeof(d));
110 memcpy(d.pixels+dst_idx, c, width);
111 c += width;
112 c2p_32x8(d.words);
113 store_planar_masked(p, dst_nextplane, bpp, d.words,
114 first);
115 p += 4;
116 } else {
117 /* Multiple destination words */
118 w = width;
119 /* Leading bits */
120 if (dst_idx) {
121 w = 32 - dst_idx;
122 memset(d.pixels, 0, dst_idx);
123 memcpy(d.pixels+dst_idx, c, w);
124 c += w;
125 c2p_32x8(d.words);
126 store_planar_masked(p, dst_nextplane, bpp,
127 d.words, first);
128 p += 4;
129 w = width-w;
130 }
131 /* Main chunk */
132 while (w >= 32) {
133 memcpy(d.pixels, c, 32);
134 c += 32;
135 c2p_32x8(d.words);
136 store_planar(p, dst_nextplane, bpp, d.words);
137 p += 4;
138 w -= 32;
139 }
140 /* Trailing bits */
141 w %= 32;
142 if (w > 0) {
143 memcpy(d.pixels, c, w);
144 memset(d.pixels+w, 0, 32-w);
145 c2p_32x8(d.words);
146 store_planar_masked(p, dst_nextplane, bpp,
147 d.words, last);
148 }
149 }
150 src += src_nextline;
151 dst += dst_nextline;
152 }
153}
154EXPORT_SYMBOL_GPL(c2p_planar);
155
156MODULE_LICENSE("GPL");
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 4bcff81b50e0..1657b9608b04 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -78,13 +78,6 @@
78#include <asm/fb.h> 78#include <asm/fb.h>
79#include <asm/irq.h> 79#include <asm/irq.h>
80#include <asm/system.h> 80#include <asm/system.h>
81#ifdef CONFIG_ATARI
82#include <asm/atariints.h>
83#endif
84#if defined(__mc68000__)
85#include <asm/machdep.h>
86#include <asm/setup.h>
87#endif
88 81
89#include "fbcon.h" 82#include "fbcon.h"
90 83
@@ -155,9 +148,6 @@ static int fbcon_set_origin(struct vc_data *);
155 148
156#define CURSOR_DRAW_DELAY (1) 149#define CURSOR_DRAW_DELAY (1)
157 150
158/* # VBL ints between cursor state changes */
159#define ATARI_CURSOR_BLINK_RATE (42)
160
161static int vbl_cursor_cnt; 151static int vbl_cursor_cnt;
162static int fbcon_cursor_noblink; 152static int fbcon_cursor_noblink;
163 153
@@ -403,20 +393,6 @@ static void fb_flashcursor(struct work_struct *work)
403 release_console_sem(); 393 release_console_sem();
404} 394}
405 395
406#ifdef CONFIG_ATARI
407static int cursor_blink_rate;
408static irqreturn_t fb_vbl_handler(int irq, void *dev_id)
409{
410 struct fb_info *info = dev_id;
411
412 if (vbl_cursor_cnt && --vbl_cursor_cnt == 0) {
413 schedule_work(&info->queue);
414 vbl_cursor_cnt = cursor_blink_rate;
415 }
416 return IRQ_HANDLED;
417}
418#endif
419
420static void cursor_timer_handler(unsigned long dev_addr) 396static void cursor_timer_handler(unsigned long dev_addr)
421{ 397{
422 struct fb_info *info = (struct fb_info *) dev_addr; 398 struct fb_info *info = (struct fb_info *) dev_addr;
@@ -1017,15 +993,6 @@ static const char *fbcon_startup(void)
1017 info->var.yres, 993 info->var.yres,
1018 info->var.bits_per_pixel); 994 info->var.bits_per_pixel);
1019 995
1020#ifdef CONFIG_ATARI
1021 if (MACH_IS_ATARI) {
1022 cursor_blink_rate = ATARI_CURSOR_BLINK_RATE;
1023 (void)request_irq(IRQ_AUTO_4, fb_vbl_handler,
1024 IRQ_TYPE_PRIO, "framebuffer vbl",
1025 info);
1026 }
1027#endif /* CONFIG_ATARI */
1028
1029 fbcon_add_cursor_timer(info); 996 fbcon_add_cursor_timer(info);
1030 fbcon_has_exited = 0; 997 fbcon_has_exited = 0;
1031 return display_desc; 998 return display_desc;
@@ -3454,11 +3421,6 @@ static void fbcon_exit(void)
3454 if (fbcon_has_exited) 3421 if (fbcon_has_exited)
3455 return; 3422 return;
3456 3423
3457#ifdef CONFIG_ATARI
3458 if (MACH_IS_ATARI)
3459 free_irq(IRQ_AUTO_4, fb_vbl_handler);
3460#endif
3461
3462 kfree((void *)softback_buf); 3424 kfree((void *)softback_buf);
3463 softback_buf = 0UL; 3425 softback_buf = 0UL;
3464 3426
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index e6210725b9ab..d012edda6d11 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -1332,7 +1332,7 @@ static void vgacon_save_screen(struct vc_data *c)
1332 c->vc_y = screen_info.orig_y; 1332 c->vc_y = screen_info.orig_y;
1333 } 1333 }
1334 1334
1335 /* We can't copy in more then the size of the video buffer, 1335 /* We can't copy in more than the size of the video buffer,
1336 * or we'll be copying in VGA BIOS */ 1336 * or we'll be copying in VGA BIOS */
1337 1337
1338 if (!vga_is_gfx) 1338 if (!vga_is_gfx)
diff --git a/drivers/video/ps3fb.c b/drivers/video/ps3fb.c
index 38ac805db97d..87f826e4c958 100644
--- a/drivers/video/ps3fb.c
+++ b/drivers/video/ps3fb.c
@@ -1006,7 +1006,7 @@ static int ps3fb_xdr_settings(u64 xdr_lpar, struct device *dev)
1006 __func__, status); 1006 __func__, status);
1007 return -ENXIO; 1007 return -ENXIO;
1008 } 1008 }
1009 dev_dbg(dev, "video:%p ioif:%lx lpar:%lx size:%lx\n", 1009 dev_dbg(dev, "video:%p ioif:%lx lpar:%llx size:%lx\n",
1010 ps3fb_videomemory.address, GPU_IOIF, xdr_lpar, 1010 ps3fb_videomemory.address, GPU_IOIF, xdr_lpar,
1011 ps3fb_videomemory.size); 1011 ps3fb_videomemory.size);
1012 1012
@@ -1133,7 +1133,7 @@ static int __devinit ps3fb_probe(struct ps3_system_bus_device *dev)
1133 __func__, status); 1133 __func__, status);
1134 goto err; 1134 goto err;
1135 } 1135 }
1136 dev_dbg(&dev->core, "ddr:lpar:0x%lx\n", ddr_lpar); 1136 dev_dbg(&dev->core, "ddr:lpar:0x%llx\n", ddr_lpar);
1137 1137
1138 status = lv1_gpu_context_allocate(ps3fb.memory_handle, 0, 1138 status = lv1_gpu_context_allocate(ps3fb.memory_handle, 0,
1139 &ps3fb.context_handle, 1139 &ps3fb.context_handle,
diff --git a/drivers/w1/masters/Kconfig b/drivers/w1/masters/Kconfig
index 90616822cd20..96d2f8e4c275 100644
--- a/drivers/w1/masters/Kconfig
+++ b/drivers/w1/masters/Kconfig
@@ -34,6 +34,12 @@ config W1_MASTER_DS2482
34 This driver can also be built as a module. If so, the module 34 This driver can also be built as a module. If so, the module
35 will be called ds2482. 35 will be called ds2482.
36 36
37config W1_MASTER_MXC
38 tristate "Freescale MXC 1-wire busmaster"
39 depends on W1 && ARCH_MXC
40 help
41 Say Y here to enable MXC 1-wire host
42
37config W1_MASTER_DS1WM 43config W1_MASTER_DS1WM
38 tristate "Maxim DS1WM 1-wire busmaster" 44 tristate "Maxim DS1WM 1-wire busmaster"
39 depends on W1 && ARM && HAVE_CLK 45 depends on W1 && ARM && HAVE_CLK
diff --git a/drivers/w1/masters/Makefile b/drivers/w1/masters/Makefile
index bc4714a75f3a..c5a3e96fcbab 100644
--- a/drivers/w1/masters/Makefile
+++ b/drivers/w1/masters/Makefile
@@ -5,6 +5,8 @@
5obj-$(CONFIG_W1_MASTER_MATROX) += matrox_w1.o 5obj-$(CONFIG_W1_MASTER_MATROX) += matrox_w1.o
6obj-$(CONFIG_W1_MASTER_DS2490) += ds2490.o 6obj-$(CONFIG_W1_MASTER_DS2490) += ds2490.o
7obj-$(CONFIG_W1_MASTER_DS2482) += ds2482.o 7obj-$(CONFIG_W1_MASTER_DS2482) += ds2482.o
8obj-$(CONFIG_W1_MASTER_MXC) += mxc_w1.o
9
8obj-$(CONFIG_W1_MASTER_DS1WM) += ds1wm.o 10obj-$(CONFIG_W1_MASTER_DS1WM) += ds1wm.o
9obj-$(CONFIG_W1_MASTER_GPIO) += w1-gpio.o 11obj-$(CONFIG_W1_MASTER_GPIO) += w1-gpio.o
10obj-$(CONFIG_HDQ_MASTER_OMAP) += omap_hdq.o 12obj-$(CONFIG_HDQ_MASTER_OMAP) += omap_hdq.o
diff --git a/drivers/w1/masters/mxc_w1.c b/drivers/w1/masters/mxc_w1.c
new file mode 100644
index 000000000000..b9d74d0b353e
--- /dev/null
+++ b/drivers/w1/masters/mxc_w1.c
@@ -0,0 +1,211 @@
1/*
2 * Copyright 2005-2008 Freescale Semiconductor, Inc. All Rights Reserved.
3 * Copyright 2008 Luotao Fu, kernel@pengutronix.de
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19
20#include <linux/module.h>
21#include <linux/interrupt.h>
22#include <linux/platform_device.h>
23#include <linux/clk.h>
24#include <linux/delay.h>
25#include <linux/io.h>
26
27#include "../w1.h"
28#include "../w1_int.h"
29#include "../w1_log.h"
30
31/* According to the mx27 Datasheet the reset procedure should take up to about
32 * 1350us. We set the timeout to 500*100us = 50ms for sure */
33#define MXC_W1_RESET_TIMEOUT 500
34
35/*
36 * MXC W1 Register offsets
37 */
38#define MXC_W1_CONTROL 0x00
39#define MXC_W1_TIME_DIVIDER 0x02
40#define MXC_W1_RESET 0x04
41#define MXC_W1_COMMAND 0x06
42#define MXC_W1_TXRX 0x08
43#define MXC_W1_INTERRUPT 0x0A
44#define MXC_W1_INTERRUPT_EN 0x0C
45
46struct mxc_w1_device {
47 void __iomem *regs;
48 unsigned int clkdiv;
49 struct clk *clk;
50 struct w1_bus_master bus_master;
51};
52
53/*
54 * this is the low level routine to
55 * reset the device on the One Wire interface
56 * on the hardware
57 */
58static u8 mxc_w1_ds2_reset_bus(void *data)
59{
60 u8 reg_val;
61 unsigned int timeout_cnt = 0;
62 struct mxc_w1_device *dev = data;
63
64 __raw_writeb(0x80, (dev->regs + MXC_W1_CONTROL));
65
66 while (1) {
67 reg_val = __raw_readb(dev->regs + MXC_W1_CONTROL);
68
69 if (((reg_val >> 7) & 0x1) == 0 ||
70 timeout_cnt > MXC_W1_RESET_TIMEOUT)
71 break;
72 else
73 timeout_cnt++;
74
75 udelay(100);
76 }
77 return (reg_val >> 7) & 0x1;
78}
79
80/*
81 * this is the low level routine to read/write a bit on the One Wire
82 * interface on the hardware. It does write 0 if parameter bit is set
83 * to 0, otherwise a write 1/read.
84 */
85static u8 mxc_w1_ds2_touch_bit(void *data, u8 bit)
86{
87 struct mxc_w1_device *mdev = data;
88 void __iomem *ctrl_addr = mdev->regs + MXC_W1_CONTROL;
89 unsigned int timeout_cnt = 400; /* Takes max. 120us according to
90 * datasheet.
91 */
92
93 __raw_writeb((1 << (5 - bit)), ctrl_addr);
94
95 while (timeout_cnt--) {
96 if (!((__raw_readb(ctrl_addr) >> (5 - bit)) & 0x1))
97 break;
98
99 udelay(1);
100 }
101
102 return ((__raw_readb(ctrl_addr)) >> 3) & 0x1;
103}
104
105static int __init mxc_w1_probe(struct platform_device *pdev)
106{
107 struct mxc_w1_device *mdev;
108 struct resource *res;
109 int err = 0;
110
111 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
112 if (!res)
113 return -ENODEV;
114
115 mdev = kzalloc(sizeof(struct mxc_w1_device), GFP_KERNEL);
116 if (!mdev)
117 return -ENOMEM;
118
119 mdev->clk = clk_get(&pdev->dev, "owire_clk");
120 if (!mdev->clk) {
121 err = -ENODEV;
122 goto failed_clk;
123 }
124
125 mdev->clkdiv = (clk_get_rate(mdev->clk) / 1000000) - 1;
126
127 res = request_mem_region(res->start, resource_size(res),
128 "mxc_w1");
129 if (!res) {
130 err = -EBUSY;
131 goto failed_req;
132 }
133
134 mdev->regs = ioremap(res->start, resource_size(res));
135 if (!mdev->regs) {
136 printk(KERN_ERR "Cannot map frame buffer registers\n");
137 goto failed_ioremap;
138 }
139
140 clk_enable(mdev->clk);
141 __raw_writeb(mdev->clkdiv, mdev->regs + MXC_W1_TIME_DIVIDER);
142
143 mdev->bus_master.data = mdev;
144 mdev->bus_master.reset_bus = mxc_w1_ds2_reset_bus;
145 mdev->bus_master.touch_bit = mxc_w1_ds2_touch_bit;
146
147 err = w1_add_master_device(&mdev->bus_master);
148
149 if (err)
150 goto failed_add;
151
152 platform_set_drvdata(pdev, mdev);
153 return 0;
154
155failed_add:
156 iounmap(mdev->regs);
157failed_ioremap:
158 release_mem_region(res->start, resource_size(res));
159failed_req:
160 clk_put(mdev->clk);
161failed_clk:
162 kfree(mdev);
163 return err;
164}
165
166/*
167 * disassociate the w1 device from the driver
168 */
169static int mxc_w1_remove(struct platform_device *pdev)
170{
171 struct mxc_w1_device *mdev = platform_get_drvdata(pdev);
172 struct resource *res;
173
174 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
175
176 w1_remove_master_device(&mdev->bus_master);
177
178 iounmap(mdev->regs);
179 release_mem_region(res->start, resource_size(res));
180 clk_disable(mdev->clk);
181 clk_put(mdev->clk);
182
183 platform_set_drvdata(pdev, NULL);
184
185 return 0;
186}
187
188static struct platform_driver mxc_w1_driver = {
189 .driver = {
190 .name = "mxc_w1",
191 },
192 .probe = mxc_w1_probe,
193 .remove = mxc_w1_remove,
194};
195
196static int __init mxc_w1_init(void)
197{
198 return platform_driver_register(&mxc_w1_driver);
199}
200
201static void mxc_w1_exit(void)
202{
203 platform_driver_unregister(&mxc_w1_driver);
204}
205
206module_init(mxc_w1_init);
207module_exit(mxc_w1_exit);
208
209MODULE_LICENSE("GPL");
210MODULE_AUTHOR("Freescale Semiconductors Inc");
211MODULE_DESCRIPTION("Driver for One-Wire on MXC");
diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h
index 97304bd83ec9..d8a9709f3449 100644
--- a/drivers/w1/w1.h
+++ b/drivers/w1/w1.h
@@ -210,6 +210,7 @@ u8 w1_read_8(struct w1_master *);
210int w1_reset_bus(struct w1_master *); 210int w1_reset_bus(struct w1_master *);
211u8 w1_calc_crc8(u8 *, int); 211u8 w1_calc_crc8(u8 *, int);
212void w1_write_block(struct w1_master *, const u8 *, int); 212void w1_write_block(struct w1_master *, const u8 *, int);
213void w1_touch_block(struct w1_master *, u8 *, int);
213u8 w1_read_block(struct w1_master *, u8 *, int); 214u8 w1_read_block(struct w1_master *, u8 *, int);
214int w1_reset_select_slave(struct w1_slave *sl); 215int w1_reset_select_slave(struct w1_slave *sl);
215void w1_next_pullup(struct w1_master *, int); 216void w1_next_pullup(struct w1_master *, int);
diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c
index 5139c25ca962..442bd8bbd4a5 100644
--- a/drivers/w1/w1_io.c
+++ b/drivers/w1/w1_io.c
@@ -238,7 +238,6 @@ EXPORT_SYMBOL_GPL(w1_read_8);
238 * @param dev the master device 238 * @param dev the master device
239 * @param buf pointer to the data to write 239 * @param buf pointer to the data to write
240 * @param len the number of bytes to write 240 * @param len the number of bytes to write
241 * @return the byte read
242 */ 241 */
243void w1_write_block(struct w1_master *dev, const u8 *buf, int len) 242void w1_write_block(struct w1_master *dev, const u8 *buf, int len)
244{ 243{
@@ -256,6 +255,31 @@ void w1_write_block(struct w1_master *dev, const u8 *buf, int len)
256EXPORT_SYMBOL_GPL(w1_write_block); 255EXPORT_SYMBOL_GPL(w1_write_block);
257 256
258/** 257/**
258 * Touches a series of bytes.
259 *
260 * @param dev the master device
261 * @param buf pointer to the data to write
262 * @param len the number of bytes to write
263 */
264void w1_touch_block(struct w1_master *dev, u8 *buf, int len)
265{
266 int i, j;
267 u8 tmp;
268
269 for (i = 0; i < len; ++i) {
270 tmp = 0;
271 for (j = 0; j < 8; ++j) {
272 if (j == 7)
273 w1_pre_write(dev);
274 tmp |= w1_touch_bit(dev, (buf[i] >> j) & 0x1) << j;
275 }
276
277 buf[i] = tmp;
278 }
279}
280EXPORT_SYMBOL_GPL(w1_touch_block);
281
282/**
259 * Reads a series of bytes. 283 * Reads a series of bytes.
260 * 284 *
261 * @param dev the master device 285 * @param dev the master device
diff --git a/drivers/w1/w1_netlink.c b/drivers/w1/w1_netlink.c
index 65c5ebd0787e..fdf72851c574 100644
--- a/drivers/w1/w1_netlink.c
+++ b/drivers/w1/w1_netlink.c
@@ -47,21 +47,56 @@ void w1_netlink_send(struct w1_master *dev, struct w1_netlink_msg *msg)
47 cn_netlink_send(m, 0, GFP_KERNEL); 47 cn_netlink_send(m, 0, GFP_KERNEL);
48} 48}
49 49
50static int w1_process_command_master(struct w1_master *dev, struct cn_msg *msg, 50static void w1_send_slave(struct w1_master *dev, u64 rn)
51 struct w1_netlink_msg *hdr, struct w1_netlink_cmd *cmd) 51{
52 struct cn_msg *msg = dev->priv;
53 struct w1_netlink_msg *hdr = (struct w1_netlink_msg *)(msg + 1);
54 struct w1_netlink_cmd *cmd = (struct w1_netlink_cmd *)(hdr + 1);
55 int avail;
56
57 avail = dev->priv_size - cmd->len;
58
59 if (avail > 8) {
60 u64 *data = (void *)(cmd + 1) + cmd->len;
61
62 *data = rn;
63 cmd->len += 8;
64 hdr->len += 8;
65 msg->len += 8;
66 return;
67 }
68
69 msg->ack++;
70 cn_netlink_send(msg, 0, GFP_KERNEL);
71
72 msg->len = sizeof(struct w1_netlink_msg) + sizeof(struct w1_netlink_cmd);
73 hdr->len = sizeof(struct w1_netlink_cmd);
74 cmd->len = 0;
75}
76
77static int w1_process_search_command(struct w1_master *dev, struct cn_msg *msg,
78 unsigned int avail)
52{ 79{
53 dev_dbg(&dev->dev, "%s: %s: cmd=%02x, len=%u.\n", 80 struct w1_netlink_msg *hdr = (struct w1_netlink_msg *)(msg + 1);
54 __func__, dev->name, cmd->cmd, cmd->len); 81 struct w1_netlink_cmd *cmd = (struct w1_netlink_cmd *)(hdr + 1);
82 int search_type = (cmd->cmd == W1_CMD_ALARM_SEARCH)?W1_ALARM_SEARCH:W1_SEARCH;
55 83
56 if (cmd->cmd != W1_CMD_SEARCH && cmd->cmd != W1_CMD_ALARM_SEARCH) 84 dev->priv = msg;
57 return -EINVAL; 85 dev->priv_size = avail;
86
87 w1_search_devices(dev, search_type, w1_send_slave);
88
89 msg->ack = 0;
90 cn_netlink_send(msg, 0, GFP_KERNEL);
91
92 dev->priv = NULL;
93 dev->priv_size = 0;
58 94
59 w1_search_process(dev, (cmd->cmd == W1_CMD_ALARM_SEARCH)?W1_ALARM_SEARCH:W1_SEARCH);
60 return 0; 95 return 0;
61} 96}
62 97
63static int w1_send_read_reply(struct w1_slave *sl, struct cn_msg *msg, 98static int w1_send_read_reply(struct cn_msg *msg, struct w1_netlink_msg *hdr,
64 struct w1_netlink_msg *hdr, struct w1_netlink_cmd *cmd) 99 struct w1_netlink_cmd *cmd)
65{ 100{
66 void *data; 101 void *data;
67 struct w1_netlink_msg *h; 102 struct w1_netlink_msg *h;
@@ -85,7 +120,8 @@ static int w1_send_read_reply(struct w1_slave *sl, struct cn_msg *msg,
85 memcpy(c, cmd, sizeof(struct w1_netlink_cmd)); 120 memcpy(c, cmd, sizeof(struct w1_netlink_cmd));
86 121
87 cm->ack = msg->seq+1; 122 cm->ack = msg->seq+1;
88 cm->len = sizeof(struct w1_netlink_msg) + sizeof(struct w1_netlink_cmd) + cmd->len; 123 cm->len = sizeof(struct w1_netlink_msg) +
124 sizeof(struct w1_netlink_cmd) + cmd->len;
89 125
90 h->len = sizeof(struct w1_netlink_cmd) + cmd->len; 126 h->len = sizeof(struct w1_netlink_cmd) + cmd->len;
91 127
@@ -98,36 +134,178 @@ static int w1_send_read_reply(struct w1_slave *sl, struct cn_msg *msg,
98 return err; 134 return err;
99} 135}
100 136
101static int w1_process_command_slave(struct w1_slave *sl, struct cn_msg *msg, 137static int w1_process_command_io(struct w1_master *dev, struct cn_msg *msg,
102 struct w1_netlink_msg *hdr, struct w1_netlink_cmd *cmd) 138 struct w1_netlink_msg *hdr, struct w1_netlink_cmd *cmd)
103{ 139{
104 int err = 0; 140 int err = 0;
105 141
106 dev_dbg(&sl->master->dev, "%s: %02x.%012llx.%02x: cmd=%02x, len=%u.\n", 142 switch (cmd->cmd) {
107 __func__, sl->reg_num.family, (unsigned long long)sl->reg_num.id, sl->reg_num.crc, 143 case W1_CMD_TOUCH:
108 cmd->cmd, cmd->len); 144 w1_touch_block(dev, cmd->data, cmd->len);
145 w1_send_read_reply(msg, hdr, cmd);
146 break;
147 case W1_CMD_READ:
148 w1_read_block(dev, cmd->data, cmd->len);
149 w1_send_read_reply(msg, hdr, cmd);
150 break;
151 case W1_CMD_WRITE:
152 w1_write_block(dev, cmd->data, cmd->len);
153 break;
154 default:
155 err = -EINVAL;
156 break;
157 }
158
159 return err;
160}
161
162static int w1_process_command_master(struct w1_master *dev, struct cn_msg *req_msg,
163 struct w1_netlink_msg *req_hdr, struct w1_netlink_cmd *req_cmd)
164{
165 int err = -EINVAL;
166 struct cn_msg *msg;
167 struct w1_netlink_msg *hdr;
168 struct w1_netlink_cmd *cmd;
169
170 msg = kzalloc(PAGE_SIZE, GFP_KERNEL);
171 if (!msg)
172 return -ENOMEM;
173
174 msg->id = req_msg->id;
175 msg->seq = req_msg->seq;
176 msg->ack = 0;
177 msg->len = sizeof(struct w1_netlink_msg) + sizeof(struct w1_netlink_cmd);
178
179 hdr = (struct w1_netlink_msg *)(msg + 1);
180 cmd = (struct w1_netlink_cmd *)(hdr + 1);
181
182 hdr->type = W1_MASTER_CMD;
183 hdr->id = req_hdr->id;
184 hdr->len = sizeof(struct w1_netlink_cmd);
185
186 cmd->cmd = req_cmd->cmd;
187 cmd->len = 0;
109 188
110 switch (cmd->cmd) { 189 switch (cmd->cmd) {
111 case W1_CMD_READ: 190 case W1_CMD_SEARCH:
112 w1_read_block(sl->master, cmd->data, cmd->len); 191 case W1_CMD_ALARM_SEARCH:
113 w1_send_read_reply(sl, msg, hdr, cmd); 192 err = w1_process_search_command(dev, msg,
114 break; 193 PAGE_SIZE - msg->len - sizeof(struct cn_msg));
115 case W1_CMD_WRITE: 194 break;
116 w1_write_block(sl->master, cmd->data, cmd->len); 195 case W1_CMD_READ:
117 break; 196 case W1_CMD_WRITE:
118 case W1_CMD_SEARCH: 197 case W1_CMD_TOUCH:
119 case W1_CMD_ALARM_SEARCH: 198 err = w1_process_command_io(dev, req_msg, req_hdr, req_cmd);
120 w1_search_process(sl->master, 199 break;
121 (cmd->cmd == W1_CMD_ALARM_SEARCH)?W1_ALARM_SEARCH:W1_SEARCH); 200 case W1_CMD_RESET:
122 break; 201 err = w1_reset_bus(dev);
123 default: 202 break;
124 err = -1; 203 default:
125 break; 204 err = -EINVAL;
205 break;
126 } 206 }
127 207
208 kfree(msg);
128 return err; 209 return err;
129} 210}
130 211
212static int w1_process_command_slave(struct w1_slave *sl, struct cn_msg *msg,
213 struct w1_netlink_msg *hdr, struct w1_netlink_cmd *cmd)
214{
215 dev_dbg(&sl->master->dev, "%s: %02x.%012llx.%02x: cmd=%02x, len=%u.\n",
216 __func__, sl->reg_num.family, (unsigned long long)sl->reg_num.id,
217 sl->reg_num.crc, cmd->cmd, cmd->len);
218
219 return w1_process_command_io(sl->master, msg, hdr, cmd);
220}
221
222static int w1_process_command_root(struct cn_msg *msg, struct w1_netlink_msg *mcmd)
223{
224 struct w1_master *m;
225 struct cn_msg *cn;
226 struct w1_netlink_msg *w;
227 u32 *id;
228
229 if (mcmd->type != W1_LIST_MASTERS) {
230 printk(KERN_NOTICE "%s: msg: %x.%x, wrong type: %u, len: %u.\n",
231 __func__, msg->id.idx, msg->id.val, mcmd->type, mcmd->len);
232 return -EPROTO;
233 }
234
235 cn = kmalloc(PAGE_SIZE, GFP_KERNEL);
236 if (!cn)
237 return -ENOMEM;
238
239 cn->id.idx = CN_W1_IDX;
240 cn->id.val = CN_W1_VAL;
241
242 cn->seq = msg->seq;
243 cn->ack = 1;
244 cn->len = sizeof(struct w1_netlink_msg);
245 w = (struct w1_netlink_msg *)(cn + 1);
246
247 w->type = W1_LIST_MASTERS;
248 w->status = 0;
249 w->len = 0;
250 id = (u32 *)(w + 1);
251
252 mutex_lock(&w1_mlock);
253 list_for_each_entry(m, &w1_masters, w1_master_entry) {
254 if (cn->len + sizeof(*id) > PAGE_SIZE - sizeof(struct cn_msg)) {
255 cn_netlink_send(cn, 0, GFP_KERNEL);
256 cn->ack++;
257 cn->len = sizeof(struct w1_netlink_msg);
258 w->len = 0;
259 id = (u32 *)(w + 1);
260 }
261
262 *id = m->id;
263 w->len += sizeof(*id);
264 cn->len += sizeof(*id);
265 id++;
266 }
267 cn->ack = 0;
268 cn_netlink_send(cn, 0, GFP_KERNEL);
269 mutex_unlock(&w1_mlock);
270
271 kfree(cn);
272 return 0;
273}
274
275static int w1_netlink_send_error(struct cn_msg *rcmsg, struct w1_netlink_msg *rmsg,
276 struct w1_netlink_cmd *rcmd, int error)
277{
278 struct cn_msg *cmsg;
279 struct w1_netlink_msg *msg;
280 struct w1_netlink_cmd *cmd;
281
282 cmsg = kzalloc(sizeof(*msg) + sizeof(*cmd) + sizeof(*cmsg), GFP_KERNEL);
283 if (!cmsg)
284 return -ENOMEM;
285
286 msg = (struct w1_netlink_msg *)(cmsg + 1);
287 cmd = (struct w1_netlink_cmd *)(msg + 1);
288
289 memcpy(cmsg, rcmsg, sizeof(*cmsg));
290 cmsg->len = sizeof(*msg);
291
292 memcpy(msg, rmsg, sizeof(*msg));
293 msg->len = 0;
294 msg->status = (short)-error;
295
296 if (rcmd) {
297 memcpy(cmd, rcmd, sizeof(*cmd));
298 cmd->len = 0;
299 msg->len += sizeof(*cmd);
300 cmsg->len += sizeof(*cmd);
301 }
302
303 error = cn_netlink_send(cmsg, 0, GFP_KERNEL);
304 kfree(cmsg);
305
306 return error;
307}
308
131static void w1_cn_callback(void *data) 309static void w1_cn_callback(void *data)
132{ 310{
133 struct cn_msg *msg = data; 311 struct cn_msg *msg = data;
@@ -144,6 +322,7 @@ static void w1_cn_callback(void *data)
144 322
145 dev = NULL; 323 dev = NULL;
146 sl = NULL; 324 sl = NULL;
325 cmd = NULL;
147 326
148 memcpy(&id, m->id.id, sizeof(id)); 327 memcpy(&id, m->id.id, sizeof(id));
149#if 0 328#if 0
@@ -155,15 +334,15 @@ static void w1_cn_callback(void *data)
155 break; 334 break;
156 } 335 }
157 336
158 if (!mlen)
159 goto out_cont;
160
161 if (m->type == W1_MASTER_CMD) { 337 if (m->type == W1_MASTER_CMD) {
162 dev = w1_search_master_id(m->id.mst.id); 338 dev = w1_search_master_id(m->id.mst.id);
163 } else if (m->type == W1_SLAVE_CMD) { 339 } else if (m->type == W1_SLAVE_CMD) {
164 sl = w1_search_slave(&id); 340 sl = w1_search_slave(&id);
165 if (sl) 341 if (sl)
166 dev = sl->master; 342 dev = sl->master;
343 } else {
344 err = w1_process_command_root(msg, m);
345 goto out_cont;
167 } 346 }
168 347
169 if (!dev) { 348 if (!dev) {
@@ -171,6 +350,10 @@ static void w1_cn_callback(void *data)
171 goto out_cont; 350 goto out_cont;
172 } 351 }
173 352
353 err = 0;
354 if (!mlen)
355 goto out_cont;
356
174 mutex_lock(&dev->mutex); 357 mutex_lock(&dev->mutex);
175 358
176 if (sl && w1_reset_select_slave(sl)) { 359 if (sl && w1_reset_select_slave(sl)) {
@@ -187,9 +370,12 @@ static void w1_cn_callback(void *data)
187 } 370 }
188 371
189 if (sl) 372 if (sl)
190 w1_process_command_slave(sl, msg, m, cmd); 373 err = w1_process_command_slave(sl, msg, m, cmd);
191 else 374 else
192 w1_process_command_master(dev, msg, m, cmd); 375 err = w1_process_command_master(dev, msg, m, cmd);
376
377 w1_netlink_send_error(msg, m, cmd, err);
378 err = 0;
193 379
194 cmd_data += cmd->len + sizeof(struct w1_netlink_cmd); 380 cmd_data += cmd->len + sizeof(struct w1_netlink_cmd);
195 mlen -= cmd->len + sizeof(struct w1_netlink_cmd); 381 mlen -= cmd->len + sizeof(struct w1_netlink_cmd);
@@ -200,6 +386,8 @@ out_up:
200 atomic_dec(&sl->refcnt); 386 atomic_dec(&sl->refcnt);
201 mutex_unlock(&dev->mutex); 387 mutex_unlock(&dev->mutex);
202out_cont: 388out_cont:
389 if (!cmd || err)
390 w1_netlink_send_error(msg, m, cmd, err);
203 msg->len -= sizeof(struct w1_netlink_msg) + m->len; 391 msg->len -= sizeof(struct w1_netlink_msg) + m->len;
204 m = (struct w1_netlink_msg *)(((u8 *)m) + sizeof(struct w1_netlink_msg) + m->len); 392 m = (struct w1_netlink_msg *)(((u8 *)m) + sizeof(struct w1_netlink_msg) + m->len);
205 393
@@ -209,11 +397,6 @@ out_cont:
209 if (err == -ENODEV) 397 if (err == -ENODEV)
210 err = 0; 398 err = 0;
211 } 399 }
212#if 0
213 if (err) {
214 printk("%s: malformed message. Dropping.\n", __func__);
215 }
216#endif
217} 400}
218 401
219int w1_init_netlink(void) 402int w1_init_netlink(void)
diff --git a/drivers/w1/w1_netlink.h b/drivers/w1/w1_netlink.h
index 56122b9e9294..27e950f935b1 100644
--- a/drivers/w1/w1_netlink.h
+++ b/drivers/w1/w1_netlink.h
@@ -34,12 +34,13 @@ enum w1_netlink_message_types {
34 W1_MASTER_REMOVE, 34 W1_MASTER_REMOVE,
35 W1_MASTER_CMD, 35 W1_MASTER_CMD,
36 W1_SLAVE_CMD, 36 W1_SLAVE_CMD,
37 W1_LIST_MASTERS,
37}; 38};
38 39
39struct w1_netlink_msg 40struct w1_netlink_msg
40{ 41{
41 __u8 type; 42 __u8 type;
42 __u8 reserved; 43 __u8 status;
43 __u16 len; 44 __u16 len;
44 union { 45 union {
45 __u8 id[8]; 46 __u8 id[8];
@@ -51,10 +52,15 @@ struct w1_netlink_msg
51 __u8 data[0]; 52 __u8 data[0];
52}; 53};
53 54
54#define W1_CMD_READ 0x0 55enum w1_commands {
55#define W1_CMD_WRITE 0x1 56 W1_CMD_READ = 0,
56#define W1_CMD_SEARCH 0x2 57 W1_CMD_WRITE,
57#define W1_CMD_ALARM_SEARCH 0x3 58 W1_CMD_SEARCH,
59 W1_CMD_ALARM_SEARCH,
60 W1_CMD_TOUCH,
61 W1_CMD_RESET,
62 W1_CMD_MAX,
63};
58 64
59struct w1_netlink_cmd 65struct w1_netlink_cmd
60{ 66{
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index ec68c741b564..3efa12f9ee50 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -770,6 +770,12 @@ config TXX9_WDT
770 770
771# POWERPC Architecture 771# POWERPC Architecture
772 772
773config GEF_WDT
774 tristate "GE Fanuc Watchdog Timer"
775 depends on GEF_SBC610
776 ---help---
777 Watchdog timer found in a number of GE Fanuc single board computers.
778
773config MPC5200_WDT 779config MPC5200_WDT
774 tristate "MPC5200 Watchdog Timer" 780 tristate "MPC5200 Watchdog Timer"
775 depends on PPC_MPC52xx 781 depends on PPC_MPC52xx
@@ -790,6 +796,14 @@ config MV64X60_WDT
790 tristate "MV64X60 (Marvell Discovery) Watchdog Timer" 796 tristate "MV64X60 (Marvell Discovery) Watchdog Timer"
791 depends on MV64X60 797 depends on MV64X60
792 798
799config PIKA_WDT
800 tristate "PIKA FPGA Watchdog"
801 depends on WARP
802 default y
803 help
804 This enables the watchdog in the PIKA FPGA. Currently used on
805 the Warp platform.
806
793config BOOKE_WDT 807config BOOKE_WDT
794 bool "PowerPC Book-E Watchdog Timer" 808 bool "PowerPC Book-E Watchdog Timer"
795 depends on BOOKE || 4xx 809 depends on BOOKE || 4xx
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index c19b866f5ed1..806b3eb08536 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -111,9 +111,11 @@ obj-$(CONFIG_TXX9_WDT) += txx9wdt.o
111# PARISC Architecture 111# PARISC Architecture
112 112
113# POWERPC Architecture 113# POWERPC Architecture
114obj-$(CONFIG_GEF_WDT) += gef_wdt.o
114obj-$(CONFIG_MPC5200_WDT) += mpc5200_wdt.o 115obj-$(CONFIG_MPC5200_WDT) += mpc5200_wdt.o
115obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o 116obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o
116obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o 117obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o
118obj-$(CONFIG_PIKA_WDT) += pika_wdt.o
117obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o 119obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
118 120
119# PPC64 Architecture 121# PPC64 Architecture
diff --git a/drivers/watchdog/gef_wdt.c b/drivers/watchdog/gef_wdt.c
new file mode 100644
index 000000000000..f0c2b7a1a175
--- /dev/null
+++ b/drivers/watchdog/gef_wdt.c
@@ -0,0 +1,330 @@
1/*
2 * GE Fanuc watchdog userspace interface
3 *
4 * Author: Martyn Welch <martyn.welch@gefanuc.com>
5 *
6 * Copyright 2008 GE Fanuc Intelligent Platforms Embedded Systems, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * Based on: mv64x60_wdt.c (MV64X60 watchdog userspace interface)
14 * Author: James Chapman <jchapman@katalix.com>
15 */
16
17/* TODO:
18 * This driver does not provide support for the hardwares capability of sending
19 * an interrupt at a programmable threshold.
20 *
21 * This driver currently can only support 1 watchdog - there are 2 in the
22 * hardware that this driver supports. Thus one could be configured as a
23 * process-based watchdog (via /dev/watchdog), the second (using the interrupt
24 * capabilities) a kernel-based watchdog.
25 */
26
27#include <linux/kernel.h>
28#include <linux/compiler.h>
29#include <linux/init.h>
30#include <linux/module.h>
31#include <linux/miscdevice.h>
32#include <linux/watchdog.h>
33#include <linux/of.h>
34#include <linux/of_platform.h>
35#include <linux/io.h>
36#include <linux/uaccess.h>
37
38#include <sysdev/fsl_soc.h>
39
40/*
41 * The watchdog configuration register contains a pair of 2-bit fields,
42 * 1. a reload field, bits 27-26, which triggers a reload of
43 * the countdown register, and
44 * 2. an enable field, bits 25-24, which toggles between
45 * enabling and disabling the watchdog timer.
46 * Bit 31 is a read-only field which indicates whether the
47 * watchdog timer is currently enabled.
48 *
49 * The low 24 bits contain the timer reload value.
50 */
51#define GEF_WDC_ENABLE_SHIFT 24
52#define GEF_WDC_SERVICE_SHIFT 26
53#define GEF_WDC_ENABLED_SHIFT 31
54
55#define GEF_WDC_ENABLED_TRUE 1
56#define GEF_WDC_ENABLED_FALSE 0
57
58/* Flags bits */
59#define GEF_WDOG_FLAG_OPENED 0
60
61static unsigned long wdt_flags;
62static int wdt_status;
63static void __iomem *gef_wdt_regs;
64static int gef_wdt_timeout;
65static int gef_wdt_count;
66static unsigned int bus_clk;
67static char expect_close;
68static DEFINE_SPINLOCK(gef_wdt_spinlock);
69
70static int nowayout = WATCHDOG_NOWAYOUT;
71module_param(nowayout, int, 0);
72MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
73 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
74
75
76static int gef_wdt_toggle_wdc(int enabled_predicate, int field_shift)
77{
78 u32 data;
79 u32 enabled;
80 int ret = 0;
81
82 spin_lock(&gef_wdt_spinlock);
83 data = ioread32be(gef_wdt_regs);
84 enabled = (data >> GEF_WDC_ENABLED_SHIFT) & 1;
85
86 /* only toggle the requested field if enabled state matches predicate */
87 if ((enabled ^ enabled_predicate) == 0) {
88 /* We write a 1, then a 2 -- to the appropriate field */
89 data = (1 << field_shift) | gef_wdt_count;
90 iowrite32be(data, gef_wdt_regs);
91
92 data = (2 << field_shift) | gef_wdt_count;
93 iowrite32be(data, gef_wdt_regs);
94 ret = 1;
95 }
96 spin_unlock(&gef_wdt_spinlock);
97
98 return ret;
99}
100
101static void gef_wdt_service(void)
102{
103 gef_wdt_toggle_wdc(GEF_WDC_ENABLED_TRUE,
104 GEF_WDC_SERVICE_SHIFT);
105}
106
107static void gef_wdt_handler_enable(void)
108{
109 if (gef_wdt_toggle_wdc(GEF_WDC_ENABLED_FALSE,
110 GEF_WDC_ENABLE_SHIFT)) {
111 gef_wdt_service();
112 printk(KERN_NOTICE "gef_wdt: watchdog activated\n");
113 }
114}
115
116static void gef_wdt_handler_disable(void)
117{
118 if (gef_wdt_toggle_wdc(GEF_WDC_ENABLED_TRUE,
119 GEF_WDC_ENABLE_SHIFT))
120 printk(KERN_NOTICE "gef_wdt: watchdog deactivated\n");
121}
122
123static void gef_wdt_set_timeout(unsigned int timeout)
124{
125 /* maximum bus cycle count is 0xFFFFFFFF */
126 if (timeout > 0xFFFFFFFF / bus_clk)
127 timeout = 0xFFFFFFFF / bus_clk;
128
129 /* Register only holds upper 24 bits, bit shifted into lower 24 */
130 gef_wdt_count = (timeout * bus_clk) >> 8;
131 gef_wdt_timeout = timeout;
132}
133
134
135static ssize_t gef_wdt_write(struct file *file, const char __user *data,
136 size_t len, loff_t *ppos)
137{
138 if (len) {
139 if (!nowayout) {
140 size_t i;
141
142 expect_close = 0;
143
144 for (i = 0; i != len; i++) {
145 char c;
146 if (get_user(c, data + i))
147 return -EFAULT;
148 if (c == 'V')
149 expect_close = 42;
150 }
151 }
152 gef_wdt_service();
153 }
154
155 return len;
156}
157
158static long gef_wdt_ioctl(struct file *file, unsigned int cmd,
159 unsigned long arg)
160{
161 int timeout;
162 int options;
163 void __user *argp = (void __user *)arg;
164 static struct watchdog_info info = {
165 .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE |
166 WDIOF_KEEPALIVEPING,
167 .firmware_version = 0,
168 .identity = "GE Fanuc watchdog",
169 };
170
171 switch (cmd) {
172 case WDIOC_GETSUPPORT:
173 if (copy_to_user(argp, &info, sizeof(info)))
174 return -EFAULT;
175 break;
176
177 case WDIOC_GETSTATUS:
178 case WDIOC_GETBOOTSTATUS:
179 if (put_user(wdt_status, (int __user *)argp))
180 return -EFAULT;
181 wdt_status &= ~WDIOF_KEEPALIVEPING;
182 break;
183
184 case WDIOC_SETOPTIONS:
185 if (get_user(options, (int __user *)argp))
186 return -EFAULT;
187
188 if (options & WDIOS_DISABLECARD)
189 gef_wdt_handler_disable();
190
191 if (options & WDIOS_ENABLECARD)
192 gef_wdt_handler_enable();
193 break;
194
195 case WDIOC_KEEPALIVE:
196 gef_wdt_service();
197 wdt_status |= WDIOF_KEEPALIVEPING;
198 break;
199
200 case WDIOC_SETTIMEOUT:
201 if (get_user(timeout, (int __user *)argp))
202 return -EFAULT;
203 gef_wdt_set_timeout(timeout);
204 /* Fall through */
205
206 case WDIOC_GETTIMEOUT:
207 if (put_user(gef_wdt_timeout, (int __user *)argp))
208 return -EFAULT;
209 break;
210
211 default:
212 return -ENOTTY;
213 }
214
215 return 0;
216}
217
218static int gef_wdt_open(struct inode *inode, struct file *file)
219{
220 if (test_and_set_bit(GEF_WDOG_FLAG_OPENED, &wdt_flags))
221 return -EBUSY;
222
223 if (nowayout)
224 __module_get(THIS_MODULE);
225
226 gef_wdt_handler_enable();
227
228 return nonseekable_open(inode, file);
229}
230
231static int gef_wdt_release(struct inode *inode, struct file *file)
232{
233 if (expect_close == 42)
234 gef_wdt_handler_disable();
235 else {
236 printk(KERN_CRIT
237 "gef_wdt: unexpected close, not stopping timer!\n");
238 gef_wdt_service();
239 }
240 expect_close = 0;
241
242 clear_bit(GEF_WDOG_FLAG_OPENED, &wdt_flags);
243
244 return 0;
245}
246
247static const struct file_operations gef_wdt_fops = {
248 .owner = THIS_MODULE,
249 .llseek = no_llseek,
250 .write = gef_wdt_write,
251 .unlocked_ioctl = gef_wdt_ioctl,
252 .open = gef_wdt_open,
253 .release = gef_wdt_release,
254};
255
256static struct miscdevice gef_wdt_miscdev = {
257 .minor = WATCHDOG_MINOR,
258 .name = "watchdog",
259 .fops = &gef_wdt_fops,
260};
261
262
263static int __devinit gef_wdt_probe(struct of_device *dev,
264 const struct of_device_id *match)
265{
266 int timeout = 10;
267 u32 freq;
268
269 bus_clk = 133; /* in MHz */
270
271 freq = fsl_get_sys_freq();
272 if (freq > 0)
273 bus_clk = freq;
274
275 /* Map devices registers into memory */
276 gef_wdt_regs = of_iomap(dev->node, 0);
277 if (gef_wdt_regs == NULL)
278 return -ENOMEM;
279
280 gef_wdt_set_timeout(timeout);
281
282 gef_wdt_handler_disable(); /* in case timer was already running */
283
284 return misc_register(&gef_wdt_miscdev);
285}
286
287static int __devexit gef_wdt_remove(struct platform_device *dev)
288{
289 misc_deregister(&gef_wdt_miscdev);
290
291 gef_wdt_handler_disable();
292
293 iounmap(gef_wdt_regs);
294
295 return 0;
296}
297
298static const struct of_device_id gef_wdt_ids[] = {
299 {
300 .compatible = "gef,fpga-wdt",
301 },
302 {},
303};
304
305static struct of_platform_driver gef_wdt_driver = {
306 .owner = THIS_MODULE,
307 .name = "gef_wdt",
308 .match_table = gef_wdt_ids,
309 .probe = gef_wdt_probe,
310};
311
312static int __init gef_wdt_init(void)
313{
314 printk(KERN_INFO "GE Fanuc watchdog driver\n");
315 return of_register_platform_driver(&gef_wdt_driver);
316}
317
318static void __exit gef_wdt_exit(void)
319{
320 of_unregister_platform_driver(&gef_wdt_driver);
321}
322
323module_init(gef_wdt_init);
324module_exit(gef_wdt_exit);
325
326MODULE_AUTHOR("Martyn Welch <martyn.welch@gefanuc.com>");
327MODULE_DESCRIPTION("GE Fanuc watchdog driver");
328MODULE_LICENSE("GPL");
329MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
330MODULE_ALIAS("platform: gef_wdt");
diff --git a/drivers/watchdog/pika_wdt.c b/drivers/watchdog/pika_wdt.c
new file mode 100644
index 000000000000..2d22e996e996
--- /dev/null
+++ b/drivers/watchdog/pika_wdt.c
@@ -0,0 +1,301 @@
1/*
2 * PIKA FPGA based Watchdog Timer
3 *
4 * Copyright (c) 2008 PIKA Technologies
5 * Sean MacLennan <smaclennan@pikatech.com>
6 */
7
8#include <linux/init.h>
9#include <linux/errno.h>
10#include <linux/module.h>
11#include <linux/moduleparam.h>
12#include <linux/types.h>
13#include <linux/kernel.h>
14#include <linux/fs.h>
15#include <linux/miscdevice.h>
16#include <linux/watchdog.h>
17#include <linux/reboot.h>
18#include <linux/jiffies.h>
19#include <linux/timer.h>
20#include <linux/bitops.h>
21#include <linux/uaccess.h>
22#include <linux/io.h>
23#include <linux/of_platform.h>
24
25#define DRV_NAME "PIKA-WDT"
26#define PFX DRV_NAME ": "
27
28/* Hardware timeout in seconds */
29#define WDT_HW_TIMEOUT 2
30
31/* Timer heartbeat (500ms) */
32#define WDT_TIMEOUT (HZ/2)
33
34/* User land timeout */
35#define WDT_HEARTBEAT 15
36static int heartbeat = WDT_HEARTBEAT;
37module_param(heartbeat, int, 0);
38MODULE_PARM_DESC(heartbeat, "Watchdog heartbeats in seconds. "
39 "(default = " __MODULE_STRING(WDT_HEARTBEAT) ")");
40
41static int nowayout = WATCHDOG_NOWAYOUT;
42module_param(nowayout, int, 0);
43MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
44 "(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
45
46static struct {
47 void __iomem *fpga;
48 unsigned long next_heartbeat; /* the next_heartbeat for the timer */
49 unsigned long open;
50 char expect_close;
51 int bootstatus;
52 struct timer_list timer; /* The timer that pings the watchdog */
53} pikawdt_private;
54
55static struct watchdog_info ident = {
56 .identity = DRV_NAME,
57 .options = WDIOF_CARDRESET |
58 WDIOF_SETTIMEOUT |
59 WDIOF_KEEPALIVEPING |
60 WDIOF_MAGICCLOSE,
61};
62
63/*
64 * Reload the watchdog timer. (ie, pat the watchdog)
65 */
66static inline void pikawdt_reset(void)
67{
68 /* -- FPGA: Reset Control Register (32bit R/W) (Offset: 0x14) --
69 * Bit 7, WTCHDG_EN: When set to 1, the watchdog timer is enabled.
70 * Once enabled, it cannot be disabled. The watchdog can be
71 * kicked by performing any write access to the reset
72 * control register (this register).
73 * Bit 8-11, WTCHDG_TIMEOUT_SEC: Sets the watchdog timeout value in
74 * seconds. Valid ranges are 1 to 15 seconds. The value can
75 * be modified dynamically.
76 */
77 unsigned reset = in_be32(pikawdt_private.fpga + 0x14);
78 /* enable with max timeout - 15 seconds */
79 reset |= (1 << 7) + (WDT_HW_TIMEOUT << 8);
80 out_be32(pikawdt_private.fpga + 0x14, reset);
81}
82
83/*
84 * Timer tick
85 */
86static void pikawdt_ping(unsigned long data)
87{
88 if (time_before(jiffies, pikawdt_private.next_heartbeat) ||
89 (!nowayout && !pikawdt_private.open)) {
90 pikawdt_reset();
91 mod_timer(&pikawdt_private.timer, jiffies + WDT_TIMEOUT);
92 } else
93 printk(KERN_CRIT PFX "I will reset your machine !\n");
94}
95
96
97static void pikawdt_keepalive(void)
98{
99 pikawdt_private.next_heartbeat = jiffies + heartbeat * HZ;
100}
101
102static void pikawdt_start(void)
103{
104 pikawdt_keepalive();
105 mod_timer(&pikawdt_private.timer, jiffies + WDT_TIMEOUT);
106}
107
108/*
109 * Watchdog device is opened, and watchdog starts running.
110 */
111static int pikawdt_open(struct inode *inode, struct file *file)
112{
113 /* /dev/watchdog can only be opened once */
114 if (test_and_set_bit(0, &pikawdt_private.open))
115 return -EBUSY;
116
117 pikawdt_start();
118
119 return nonseekable_open(inode, file);
120}
121
122/*
123 * Close the watchdog device.
124 */
125static int pikawdt_release(struct inode *inode, struct file *file)
126{
127 /* stop internal ping */
128 if (!pikawdt_private.expect_close)
129 del_timer(&pikawdt_private.timer);
130
131 clear_bit(0, &pikawdt_private.open);
132 pikawdt_private.expect_close = 0;
133 return 0;
134}
135
136/*
137 * Pat the watchdog whenever device is written to.
138 */
139static ssize_t pikawdt_write(struct file *file, const char __user *data,
140 size_t len, loff_t *ppos)
141{
142 if (!len)
143 return 0;
144
145 /* Scan for magic character */
146 if (!nowayout) {
147 size_t i;
148
149 pikawdt_private.expect_close = 0;
150
151 for (i = 0; i < len; i++) {
152 char c;
153 if (get_user(c, data + i))
154 return -EFAULT;
155 if (c == 'V') {
156 pikawdt_private.expect_close = 42;
157 break;
158 }
159 }
160 }
161
162 pikawdt_keepalive();
163
164 return len;
165}
166
167/*
168 * Handle commands from user-space.
169 */
170static long pikawdt_ioctl(struct file *file,
171 unsigned int cmd, unsigned long arg)
172{
173 void __user *argp = (void __user *)arg;
174 int __user *p = argp;
175 int new_value;
176
177 switch (cmd) {
178 case WDIOC_GETSUPPORT:
179 return copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0;
180
181 case WDIOC_GETSTATUS:
182 return put_user(0, p);
183
184 case WDIOC_GETBOOTSTATUS:
185 return put_user(pikawdt_private.bootstatus, p);
186
187 case WDIOC_KEEPALIVE:
188 pikawdt_keepalive();
189 return 0;
190
191 case WDIOC_SETTIMEOUT:
192 if (get_user(new_value, p))
193 return -EFAULT;
194
195 heartbeat = new_value;
196 pikawdt_keepalive();
197
198 return put_user(new_value, p); /* return current value */
199
200 case WDIOC_GETTIMEOUT:
201 return put_user(heartbeat, p);
202 }
203 return -ENOTTY;
204}
205
206
207static const struct file_operations pikawdt_fops = {
208 .owner = THIS_MODULE,
209 .llseek = no_llseek,
210 .open = pikawdt_open,
211 .release = pikawdt_release,
212 .write = pikawdt_write,
213 .unlocked_ioctl = pikawdt_ioctl,
214};
215
216static struct miscdevice pikawdt_miscdev = {
217 .minor = WATCHDOG_MINOR,
218 .name = "watchdog",
219 .fops = &pikawdt_fops,
220};
221
222static int __init pikawdt_init(void)
223{
224 struct device_node *np;
225 void __iomem *fpga;
226 static u32 post1;
227 int ret;
228
229 np = of_find_compatible_node(NULL, NULL, "pika,fpga");
230 if (np == NULL) {
231 printk(KERN_ERR PFX "Unable to find fpga.\n");
232 return -ENOENT;
233 }
234
235 pikawdt_private.fpga = of_iomap(np, 0);
236 of_node_put(np);
237 if (pikawdt_private.fpga == NULL) {
238 printk(KERN_ERR PFX "Unable to map fpga.\n");
239 return -ENOMEM;
240 }
241
242 ident.firmware_version = in_be32(pikawdt_private.fpga + 0x1c) & 0xffff;
243
244 /* POST information is in the sd area. */
245 np = of_find_compatible_node(NULL, NULL, "pika,fpga-sd");
246 if (np == NULL) {
247 printk(KERN_ERR PFX "Unable to find fpga-sd.\n");
248 ret = -ENOENT;
249 goto out;
250 }
251
252 fpga = of_iomap(np, 0);
253 of_node_put(np);
254 if (fpga == NULL) {
255 printk(KERN_ERR PFX "Unable to map fpga-sd.\n");
256 ret = -ENOMEM;
257 goto out;
258 }
259
260 /* -- FPGA: POST Test Results Register 1 (32bit R/W) (Offset: 0x4040) --
261 * Bit 31, WDOG: Set to 1 when the last reset was caused by a watchdog
262 * timeout.
263 */
264 post1 = in_be32(fpga + 0x40);
265 if (post1 & 0x80000000)
266 pikawdt_private.bootstatus = WDIOF_CARDRESET;
267
268 iounmap(fpga);
269
270 setup_timer(&pikawdt_private.timer, pikawdt_ping, 0);
271
272 ret = misc_register(&pikawdt_miscdev);
273 if (ret) {
274 printk(KERN_ERR PFX "Unable to register miscdev.\n");
275 goto out;
276 }
277
278 printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n",
279 heartbeat, nowayout);
280 return 0;
281
282out:
283 iounmap(pikawdt_private.fpga);
284 return ret;
285}
286
287static void __exit pikawdt_exit(void)
288{
289 misc_deregister(&pikawdt_miscdev);
290
291 iounmap(pikawdt_private.fpga);
292}
293
294module_init(pikawdt_init);
295module_exit(pikawdt_exit);
296
297MODULE_AUTHOR("Sean MacLennan <smaclennan@pikatech.com>");
298MODULE_DESCRIPTION("PIKA FPGA based Watchdog Timer");
299MODULE_LICENSE("GPL");
300MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
301
diff --git a/drivers/watchdog/wm8350_wdt.c b/drivers/watchdog/wm8350_wdt.c
index 2bc0d4d4b415..a2d2e8eb2282 100644
--- a/drivers/watchdog/wm8350_wdt.c
+++ b/drivers/watchdog/wm8350_wdt.c
@@ -279,7 +279,7 @@ static struct miscdevice wm8350_wdt_miscdev = {
279 .fops = &wm8350_wdt_fops, 279 .fops = &wm8350_wdt_fops,
280}; 280};
281 281
282static int wm8350_wdt_probe(struct platform_device *pdev) 282static int __devinit wm8350_wdt_probe(struct platform_device *pdev)
283{ 283{
284 struct wm8350 *wm8350 = platform_get_drvdata(pdev); 284 struct wm8350 *wm8350 = platform_get_drvdata(pdev);
285 285
@@ -296,7 +296,7 @@ static int wm8350_wdt_probe(struct platform_device *pdev)
296 return misc_register(&wm8350_wdt_miscdev); 296 return misc_register(&wm8350_wdt_miscdev);
297} 297}
298 298
299static int __exit wm8350_wdt_remove(struct platform_device *pdev) 299static int __devexit wm8350_wdt_remove(struct platform_device *pdev)
300{ 300{
301 misc_deregister(&wm8350_wdt_miscdev); 301 misc_deregister(&wm8350_wdt_miscdev);
302 302
@@ -305,7 +305,7 @@ static int __exit wm8350_wdt_remove(struct platform_device *pdev)
305 305
306static struct platform_driver wm8350_wdt_driver = { 306static struct platform_driver wm8350_wdt_driver = {
307 .probe = wm8350_wdt_probe, 307 .probe = wm8350_wdt_probe,
308 .remove = wm8350_wdt_remove, 308 .remove = __devexit_p(wm8350_wdt_remove),
309 .driver = { 309 .driver = {
310 .name = "wm8350-wdt", 310 .name = "wm8350-wdt",
311 }, 311 },
diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
index 4b75a16de009..526187c8a12d 100644
--- a/drivers/xen/Kconfig
+++ b/drivers/xen/Kconfig
@@ -17,3 +17,27 @@ config XEN_SCRUB_PAGES
17 is not accidentally visible to other domains. Is it more 17 is not accidentally visible to other domains. Is it more
18 secure, but slightly less efficient. 18 secure, but slightly less efficient.
19 If in doubt, say yes. 19 If in doubt, say yes.
20
21config XENFS
22 tristate "Xen filesystem"
23 depends on XEN
24 default y
25 help
26 The xen filesystem provides a way for domains to share
27 information with each other and with the hypervisor.
28 For example, by reading and writing the "xenbus" file, guests
29 may pass arbitrary information to the initial domain.
30 If in doubt, say yes.
31
32config XEN_COMPAT_XENFS
33 bool "Create compatibility mount point /proc/xen"
34 depends on XENFS
35 default y
36 help
37 The old xenstore userspace tools expect to find "xenbus"
38 under /proc/xen, but "xenbus" is now found at the root of the
39 xenfs filesystem. Selecting this causes the kernel to create
40 the compatibilty mount point /proc/xen if it is running on
41 a xen platform.
42 If in doubt, say yes.
43
diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
index d2a8fdf0e191..ff8accc9e103 100644
--- a/drivers/xen/Makefile
+++ b/drivers/xen/Makefile
@@ -1,5 +1,7 @@
1obj-y += grant-table.o features.o events.o manage.o 1obj-y += grant-table.o features.o events.o manage.o
2obj-y += xenbus/ 2obj-y += xenbus/
3
3obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o 4obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o
4obj-$(CONFIG_XEN_XENCOMM) += xencomm.o 5obj-$(CONFIG_XEN_XENCOMM) += xencomm.o
5obj-$(CONFIG_XEN_BALLOON) += balloon.o 6obj-$(CONFIG_XEN_BALLOON) += balloon.o
7obj-$(CONFIG_XENFS) += xenfs/ \ No newline at end of file
diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c
index 9678b3e98c63..92a1ef80a288 100644
--- a/drivers/xen/xenbus/xenbus_client.c
+++ b/drivers/xen/xenbus/xenbus_client.c
@@ -136,7 +136,6 @@ EXPORT_SYMBOL_GPL(xenbus_watch_pathfmt);
136/** 136/**
137 * xenbus_switch_state 137 * xenbus_switch_state
138 * @dev: xenbus device 138 * @dev: xenbus device
139 * @xbt: transaction handle
140 * @state: new state 139 * @state: new state
141 * 140 *
142 * Advertise in the store a change of the given driver to the given new_state. 141 * Advertise in the store a change of the given driver to the given new_state.
@@ -267,7 +266,7 @@ EXPORT_SYMBOL_GPL(xenbus_dev_error);
267 * @fmt: error message format 266 * @fmt: error message format
268 * 267 *
269 * Equivalent to xenbus_dev_error(dev, err, fmt, args), followed by 268 * Equivalent to xenbus_dev_error(dev, err, fmt, args), followed by
270 * xenbus_switch_state(dev, NULL, XenbusStateClosing) to schedule an orderly 269 * xenbus_switch_state(dev, XenbusStateClosing) to schedule an orderly
271 * closedown of this driver and its peer. 270 * closedown of this driver and its peer.
272 */ 271 */
273 272
diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c
index b2a03184a246..773d1cf23283 100644
--- a/drivers/xen/xenbus/xenbus_probe.c
+++ b/drivers/xen/xenbus/xenbus_probe.c
@@ -40,6 +40,7 @@
40#include <linux/ctype.h> 40#include <linux/ctype.h>
41#include <linux/fcntl.h> 41#include <linux/fcntl.h>
42#include <linux/mm.h> 42#include <linux/mm.h>
43#include <linux/proc_fs.h>
43#include <linux/notifier.h> 44#include <linux/notifier.h>
44#include <linux/kthread.h> 45#include <linux/kthread.h>
45#include <linux/mutex.h> 46#include <linux/mutex.h>
@@ -55,7 +56,10 @@
55#include "xenbus_comms.h" 56#include "xenbus_comms.h"
56#include "xenbus_probe.h" 57#include "xenbus_probe.h"
57 58
59
58int xen_store_evtchn; 60int xen_store_evtchn;
61EXPORT_SYMBOL(xen_store_evtchn);
62
59struct xenstore_domain_interface *xen_store_interface; 63struct xenstore_domain_interface *xen_store_interface;
60static unsigned long xen_store_mfn; 64static unsigned long xen_store_mfn;
61 65
@@ -166,6 +170,9 @@ static int read_backend_details(struct xenbus_device *xendev)
166 return read_otherend_details(xendev, "backend-id", "backend"); 170 return read_otherend_details(xendev, "backend-id", "backend");
167} 171}
168 172
173static struct device_attribute xenbus_dev_attrs[] = {
174 __ATTR_NULL
175};
169 176
170/* Bus type for frontend drivers. */ 177/* Bus type for frontend drivers. */
171static struct xen_bus_type xenbus_frontend = { 178static struct xen_bus_type xenbus_frontend = {
@@ -174,12 +181,13 @@ static struct xen_bus_type xenbus_frontend = {
174 .get_bus_id = frontend_bus_id, 181 .get_bus_id = frontend_bus_id,
175 .probe = xenbus_probe_frontend, 182 .probe = xenbus_probe_frontend,
176 .bus = { 183 .bus = {
177 .name = "xen", 184 .name = "xen",
178 .match = xenbus_match, 185 .match = xenbus_match,
179 .uevent = xenbus_uevent, 186 .uevent = xenbus_uevent,
180 .probe = xenbus_dev_probe, 187 .probe = xenbus_dev_probe,
181 .remove = xenbus_dev_remove, 188 .remove = xenbus_dev_remove,
182 .shutdown = xenbus_dev_shutdown, 189 .shutdown = xenbus_dev_shutdown,
190 .dev_attrs = xenbus_dev_attrs,
183 }, 191 },
184}; 192};
185 193
@@ -852,6 +860,14 @@ static int __init xenbus_probe_init(void)
852 if (!xen_initial_domain()) 860 if (!xen_initial_domain())
853 xenbus_probe(NULL); 861 xenbus_probe(NULL);
854 862
863#ifdef CONFIG_XEN_COMPAT_XENFS
864 /*
865 * Create xenfs mountpoint in /proc for compatibility with
866 * utilities that expect to find "xenbus" under "/proc/xen".
867 */
868 proc_mkdir("xen", NULL);
869#endif
870
855 return 0; 871 return 0;
856 872
857 out_unreg_back: 873 out_unreg_back:
diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
index 7f2f91c0e11d..e325eab4724d 100644
--- a/drivers/xen/xenbus/xenbus_xs.c
+++ b/drivers/xen/xenbus/xenbus_xs.c
@@ -184,6 +184,7 @@ void *xenbus_dev_request_and_reply(struct xsd_sockmsg *msg)
184 184
185 return ret; 185 return ret;
186} 186}
187EXPORT_SYMBOL(xenbus_dev_request_and_reply);
187 188
188/* Send message to xs, get kmalloc'ed reply. ERR_PTR() on error. */ 189/* Send message to xs, get kmalloc'ed reply. ERR_PTR() on error. */
189static void *xs_talkv(struct xenbus_transaction t, 190static void *xs_talkv(struct xenbus_transaction t,
diff --git a/drivers/xen/xenfs/Makefile b/drivers/xen/xenfs/Makefile
new file mode 100644
index 000000000000..25275c3bbdff
--- /dev/null
+++ b/drivers/xen/xenfs/Makefile
@@ -0,0 +1,3 @@
1obj-$(CONFIG_XENFS) += xenfs.o
2
3xenfs-objs = super.o xenbus.o \ No newline at end of file
diff --git a/drivers/xen/xenfs/super.c b/drivers/xen/xenfs/super.c
new file mode 100644
index 000000000000..515741a8e6b8
--- /dev/null
+++ b/drivers/xen/xenfs/super.c
@@ -0,0 +1,64 @@
1/*
2 * xenfs.c - a filesystem for passing info between the a domain and
3 * the hypervisor.
4 *
5 * 2008-10-07 Alex Zeffertt Replaced /proc/xen/xenbus with xenfs filesystem
6 * and /proc/xen compatibility mount point.
7 * Turned xenfs into a loadable module.
8 */
9
10#include <linux/kernel.h>
11#include <linux/errno.h>
12#include <linux/module.h>
13#include <linux/fs.h>
14#include <linux/magic.h>
15
16#include "xenfs.h"
17
18#include <asm/xen/hypervisor.h>
19
20MODULE_DESCRIPTION("Xen filesystem");
21MODULE_LICENSE("GPL");
22
23static int xenfs_fill_super(struct super_block *sb, void *data, int silent)
24{
25 static struct tree_descr xenfs_files[] = {
26 [2] = {"xenbus", &xenbus_file_ops, S_IRUSR|S_IWUSR},
27 {""},
28 };
29
30 return simple_fill_super(sb, XENFS_SUPER_MAGIC, xenfs_files);
31}
32
33static int xenfs_get_sb(struct file_system_type *fs_type,
34 int flags, const char *dev_name,
35 void *data, struct vfsmount *mnt)
36{
37 return get_sb_single(fs_type, flags, data, xenfs_fill_super, mnt);
38}
39
40static struct file_system_type xenfs_type = {
41 .owner = THIS_MODULE,
42 .name = "xenfs",
43 .get_sb = xenfs_get_sb,
44 .kill_sb = kill_litter_super,
45};
46
47static int __init xenfs_init(void)
48{
49 if (xen_pv_domain())
50 return register_filesystem(&xenfs_type);
51
52 printk(KERN_INFO "XENFS: not registering filesystem on non-xen platform\n");
53 return 0;
54}
55
56static void __exit xenfs_exit(void)
57{
58 if (xen_pv_domain())
59 unregister_filesystem(&xenfs_type);
60}
61
62module_init(xenfs_init);
63module_exit(xenfs_exit);
64
diff --git a/drivers/xen/xenfs/xenbus.c b/drivers/xen/xenfs/xenbus.c
new file mode 100644
index 000000000000..875a4c59c594
--- /dev/null
+++ b/drivers/xen/xenfs/xenbus.c
@@ -0,0 +1,593 @@
1/*
2 * Driver giving user-space access to the kernel's xenbus connection
3 * to xenstore.
4 *
5 * Copyright (c) 2005, Christian Limpach
6 * Copyright (c) 2005, Rusty Russell, IBM Corporation
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation; or, when distributed
11 * separately from the Linux kernel or incorporated into other
12 * software packages, subject to the following license:
13 *
14 * Permission is hereby granted, free of charge, to any person obtaining a copy
15 * of this source file (the "Software"), to deal in the Software without
16 * restriction, including without limitation the rights to use, copy, modify,
17 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
18 * and to permit persons to whom the Software is furnished to do so, subject to
19 * the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be included in
22 * all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30 * IN THE SOFTWARE.
31 *
32 * Changes:
33 * 2008-10-07 Alex Zeffertt Replaced /proc/xen/xenbus with xenfs filesystem
34 * and /proc/xen compatibility mount point.
35 * Turned xenfs into a loadable module.
36 */
37
38#include <linux/kernel.h>
39#include <linux/errno.h>
40#include <linux/uio.h>
41#include <linux/notifier.h>
42#include <linux/wait.h>
43#include <linux/fs.h>
44#include <linux/poll.h>
45#include <linux/mutex.h>
46#include <linux/spinlock.h>
47#include <linux/mount.h>
48#include <linux/pagemap.h>
49#include <linux/uaccess.h>
50#include <linux/init.h>
51#include <linux/namei.h>
52#include <linux/string.h>
53
54#include "xenfs.h"
55#include "../xenbus/xenbus_comms.h"
56
57#include <xen/xenbus.h>
58#include <asm/xen/hypervisor.h>
59
60/*
61 * An element of a list of outstanding transactions, for which we're
62 * still waiting a reply.
63 */
64struct xenbus_transaction_holder {
65 struct list_head list;
66 struct xenbus_transaction handle;
67};
68
69/*
70 * A buffer of data on the queue.
71 */
72struct read_buffer {
73 struct list_head list;
74 unsigned int cons;
75 unsigned int len;
76 char msg[];
77};
78
79struct xenbus_file_priv {
80 /*
81 * msgbuffer_mutex is held while partial requests are built up
82 * and complete requests are acted on. It therefore protects
83 * the "transactions" and "watches" lists, and the partial
84 * request length and buffer.
85 *
86 * reply_mutex protects the reply being built up to return to
87 * usermode. It nests inside msgbuffer_mutex but may be held
88 * alone during a watch callback.
89 */
90 struct mutex msgbuffer_mutex;
91
92 /* In-progress transactions */
93 struct list_head transactions;
94
95 /* Active watches. */
96 struct list_head watches;
97
98 /* Partial request. */
99 unsigned int len;
100 union {
101 struct xsd_sockmsg msg;
102 char buffer[PAGE_SIZE];
103 } u;
104
105 /* Response queue. */
106 struct mutex reply_mutex;
107 struct list_head read_buffers;
108 wait_queue_head_t read_waitq;
109
110};
111
112/* Read out any raw xenbus messages queued up. */
113static ssize_t xenbus_file_read(struct file *filp,
114 char __user *ubuf,
115 size_t len, loff_t *ppos)
116{
117 struct xenbus_file_priv *u = filp->private_data;
118 struct read_buffer *rb;
119 unsigned i;
120 int ret;
121
122 mutex_lock(&u->reply_mutex);
123 while (list_empty(&u->read_buffers)) {
124 mutex_unlock(&u->reply_mutex);
125 ret = wait_event_interruptible(u->read_waitq,
126 !list_empty(&u->read_buffers));
127 if (ret)
128 return ret;
129 mutex_lock(&u->reply_mutex);
130 }
131
132 rb = list_entry(u->read_buffers.next, struct read_buffer, list);
133 i = 0;
134 while (i < len) {
135 unsigned sz = min((unsigned)len - i, rb->len - rb->cons);
136
137 ret = copy_to_user(ubuf + i, &rb->msg[rb->cons], sz);
138
139 i += sz - ret;
140 rb->cons += sz - ret;
141
142 if (ret != sz) {
143 if (i == 0)
144 i = -EFAULT;
145 goto out;
146 }
147
148 /* Clear out buffer if it has been consumed */
149 if (rb->cons == rb->len) {
150 list_del(&rb->list);
151 kfree(rb);
152 if (list_empty(&u->read_buffers))
153 break;
154 rb = list_entry(u->read_buffers.next,
155 struct read_buffer, list);
156 }
157 }
158
159out:
160 mutex_unlock(&u->reply_mutex);
161 return i;
162}
163
164/*
165 * Add a buffer to the queue. Caller must hold the appropriate lock
166 * if the queue is not local. (Commonly the caller will build up
167 * multiple queued buffers on a temporary local list, and then add it
168 * to the appropriate list under lock once all the buffers have een
169 * successfully allocated.)
170 */
171static int queue_reply(struct list_head *queue, const void *data, size_t len)
172{
173 struct read_buffer *rb;
174
175 if (len == 0)
176 return 0;
177
178 rb = kmalloc(sizeof(*rb) + len, GFP_KERNEL);
179 if (rb == NULL)
180 return -ENOMEM;
181
182 rb->cons = 0;
183 rb->len = len;
184
185 memcpy(rb->msg, data, len);
186
187 list_add_tail(&rb->list, queue);
188 return 0;
189}
190
191/*
192 * Free all the read_buffer s on a list.
193 * Caller must have sole reference to list.
194 */
195static void queue_cleanup(struct list_head *list)
196{
197 struct read_buffer *rb;
198
199 while (!list_empty(list)) {
200 rb = list_entry(list->next, struct read_buffer, list);
201 list_del(list->next);
202 kfree(rb);
203 }
204}
205
206struct watch_adapter {
207 struct list_head list;
208 struct xenbus_watch watch;
209 struct xenbus_file_priv *dev_data;
210 char *token;
211};
212
213static void free_watch_adapter(struct watch_adapter *watch)
214{
215 kfree(watch->watch.node);
216 kfree(watch->token);
217 kfree(watch);
218}
219
220static struct watch_adapter *alloc_watch_adapter(const char *path,
221 const char *token)
222{
223 struct watch_adapter *watch;
224
225 watch = kzalloc(sizeof(*watch), GFP_KERNEL);
226 if (watch == NULL)
227 goto out_fail;
228
229 watch->watch.node = kstrdup(path, GFP_KERNEL);
230 if (watch->watch.node == NULL)
231 goto out_free;
232
233 watch->token = kstrdup(token, GFP_KERNEL);
234 if (watch->token == NULL)
235 goto out_free;
236
237 return watch;
238
239out_free:
240 free_watch_adapter(watch);
241
242out_fail:
243 return NULL;
244}
245
246static void watch_fired(struct xenbus_watch *watch,
247 const char **vec,
248 unsigned int len)
249{
250 struct watch_adapter *adap;
251 struct xsd_sockmsg hdr;
252 const char *path, *token;
253 int path_len, tok_len, body_len, data_len = 0;
254 int ret;
255 LIST_HEAD(staging_q);
256
257 adap = container_of(watch, struct watch_adapter, watch);
258
259 path = vec[XS_WATCH_PATH];
260 token = adap->token;
261
262 path_len = strlen(path) + 1;
263 tok_len = strlen(token) + 1;
264 if (len > 2)
265 data_len = vec[len] - vec[2] + 1;
266 body_len = path_len + tok_len + data_len;
267
268 hdr.type = XS_WATCH_EVENT;
269 hdr.len = body_len;
270
271 mutex_lock(&adap->dev_data->reply_mutex);
272
273 ret = queue_reply(&staging_q, &hdr, sizeof(hdr));
274 if (!ret)
275 ret = queue_reply(&staging_q, path, path_len);
276 if (!ret)
277 ret = queue_reply(&staging_q, token, tok_len);
278 if (!ret && len > 2)
279 ret = queue_reply(&staging_q, vec[2], data_len);
280
281 if (!ret) {
282 /* success: pass reply list onto watcher */
283 list_splice_tail(&staging_q, &adap->dev_data->read_buffers);
284 wake_up(&adap->dev_data->read_waitq);
285 } else
286 queue_cleanup(&staging_q);
287
288 mutex_unlock(&adap->dev_data->reply_mutex);
289}
290
291static int xenbus_write_transaction(unsigned msg_type,
292 struct xenbus_file_priv *u)
293{
294 int rc, ret;
295 void *reply;
296 struct xenbus_transaction_holder *trans = NULL;
297 LIST_HEAD(staging_q);
298
299 if (msg_type == XS_TRANSACTION_START) {
300 trans = kmalloc(sizeof(*trans), GFP_KERNEL);
301 if (!trans) {
302 rc = -ENOMEM;
303 goto out;
304 }
305 }
306
307 reply = xenbus_dev_request_and_reply(&u->u.msg);
308 if (IS_ERR(reply)) {
309 kfree(trans);
310 rc = PTR_ERR(reply);
311 goto out;
312 }
313
314 if (msg_type == XS_TRANSACTION_START) {
315 trans->handle.id = simple_strtoul(reply, NULL, 0);
316
317 list_add(&trans->list, &u->transactions);
318 } else if (msg_type == XS_TRANSACTION_END) {
319 list_for_each_entry(trans, &u->transactions, list)
320 if (trans->handle.id == u->u.msg.tx_id)
321 break;
322 BUG_ON(&trans->list == &u->transactions);
323 list_del(&trans->list);
324
325 kfree(trans);
326 }
327
328 mutex_lock(&u->reply_mutex);
329 ret = queue_reply(&staging_q, &u->u.msg, sizeof(u->u.msg));
330 if (!ret)
331 ret = queue_reply(&staging_q, reply, u->u.msg.len);
332 if (!ret) {
333 list_splice_tail(&staging_q, &u->read_buffers);
334 wake_up(&u->read_waitq);
335 } else {
336 queue_cleanup(&staging_q);
337 rc = ret;
338 }
339 mutex_unlock(&u->reply_mutex);
340
341 kfree(reply);
342
343out:
344 return rc;
345}
346
347static int xenbus_write_watch(unsigned msg_type, struct xenbus_file_priv *u)
348{
349 struct watch_adapter *watch, *tmp_watch;
350 char *path, *token;
351 int err, rc;
352 LIST_HEAD(staging_q);
353
354 path = u->u.buffer + sizeof(u->u.msg);
355 token = memchr(path, 0, u->u.msg.len);
356 if (token == NULL) {
357 rc = -EILSEQ;
358 goto out;
359 }
360 token++;
361
362 if (msg_type == XS_WATCH) {
363 watch = alloc_watch_adapter(path, token);
364 if (watch == NULL) {
365 rc = -ENOMEM;
366 goto out;
367 }
368
369 watch->watch.callback = watch_fired;
370 watch->dev_data = u;
371
372 err = register_xenbus_watch(&watch->watch);
373 if (err) {
374 free_watch_adapter(watch);
375 rc = err;
376 goto out;
377 }
378 list_add(&watch->list, &u->watches);
379 } else {
380 list_for_each_entry_safe(watch, tmp_watch, &u->watches, list) {
381 if (!strcmp(watch->token, token) &&
382 !strcmp(watch->watch.node, path)) {
383 unregister_xenbus_watch(&watch->watch);
384 list_del(&watch->list);
385 free_watch_adapter(watch);
386 break;
387 }
388 }
389 }
390
391 /* Success. Synthesize a reply to say all is OK. */
392 {
393 struct {
394 struct xsd_sockmsg hdr;
395 char body[3];
396 } __packed reply = {
397 {
398 .type = msg_type,
399 .len = sizeof(reply.body)
400 },
401 "OK"
402 };
403
404 mutex_lock(&u->reply_mutex);
405 rc = queue_reply(&u->read_buffers, &reply, sizeof(reply));
406 mutex_unlock(&u->reply_mutex);
407 }
408
409out:
410 return rc;
411}
412
413static ssize_t xenbus_file_write(struct file *filp,
414 const char __user *ubuf,
415 size_t len, loff_t *ppos)
416{
417 struct xenbus_file_priv *u = filp->private_data;
418 uint32_t msg_type;
419 int rc = len;
420 int ret;
421 LIST_HEAD(staging_q);
422
423 /*
424 * We're expecting usermode to be writing properly formed
425 * xenbus messages. If they write an incomplete message we
426 * buffer it up. Once it is complete, we act on it.
427 */
428
429 /*
430 * Make sure concurrent writers can't stomp all over each
431 * other's messages and make a mess of our partial message
432 * buffer. We don't make any attemppt to stop multiple
433 * writers from making a mess of each other's incomplete
434 * messages; we're just trying to guarantee our own internal
435 * consistency and make sure that single writes are handled
436 * atomically.
437 */
438 mutex_lock(&u->msgbuffer_mutex);
439
440 /* Get this out of the way early to avoid confusion */
441 if (len == 0)
442 goto out;
443
444 /* Can't write a xenbus message larger we can buffer */
445 if ((len + u->len) > sizeof(u->u.buffer)) {
446 /* On error, dump existing buffer */
447 u->len = 0;
448 rc = -EINVAL;
449 goto out;
450 }
451
452 ret = copy_from_user(u->u.buffer + u->len, ubuf, len);
453
454 if (ret == len) {
455 rc = -EFAULT;
456 goto out;
457 }
458
459 /* Deal with a partial copy. */
460 len -= ret;
461 rc = len;
462
463 u->len += len;
464
465 /* Return if we haven't got a full message yet */
466 if (u->len < sizeof(u->u.msg))
467 goto out; /* not even the header yet */
468
469 /* If we're expecting a message that's larger than we can
470 possibly send, dump what we have and return an error. */
471 if ((sizeof(u->u.msg) + u->u.msg.len) > sizeof(u->u.buffer)) {
472 rc = -E2BIG;
473 u->len = 0;
474 goto out;
475 }
476
477 if (u->len < (sizeof(u->u.msg) + u->u.msg.len))
478 goto out; /* incomplete data portion */
479
480 /*
481 * OK, now we have a complete message. Do something with it.
482 */
483
484 msg_type = u->u.msg.type;
485
486 switch (msg_type) {
487 case XS_TRANSACTION_START:
488 case XS_TRANSACTION_END:
489 case XS_DIRECTORY:
490 case XS_READ:
491 case XS_GET_PERMS:
492 case XS_RELEASE:
493 case XS_GET_DOMAIN_PATH:
494 case XS_WRITE:
495 case XS_MKDIR:
496 case XS_RM:
497 case XS_SET_PERMS:
498 /* Send out a transaction */
499 ret = xenbus_write_transaction(msg_type, u);
500 break;
501
502 case XS_WATCH:
503 case XS_UNWATCH:
504 /* (Un)Ask for some path to be watched for changes */
505 ret = xenbus_write_watch(msg_type, u);
506 break;
507
508 default:
509 ret = -EINVAL;
510 break;
511 }
512 if (ret != 0)
513 rc = ret;
514
515 /* Buffered message consumed */
516 u->len = 0;
517
518 out:
519 mutex_unlock(&u->msgbuffer_mutex);
520 return rc;
521}
522
523static int xenbus_file_open(struct inode *inode, struct file *filp)
524{
525 struct xenbus_file_priv *u;
526
527 if (xen_store_evtchn == 0)
528 return -ENOENT;
529
530 nonseekable_open(inode, filp);
531
532 u = kzalloc(sizeof(*u), GFP_KERNEL);
533 if (u == NULL)
534 return -ENOMEM;
535
536 INIT_LIST_HEAD(&u->transactions);
537 INIT_LIST_HEAD(&u->watches);
538 INIT_LIST_HEAD(&u->read_buffers);
539 init_waitqueue_head(&u->read_waitq);
540
541 mutex_init(&u->reply_mutex);
542 mutex_init(&u->msgbuffer_mutex);
543
544 filp->private_data = u;
545
546 return 0;
547}
548
549static int xenbus_file_release(struct inode *inode, struct file *filp)
550{
551 struct xenbus_file_priv *u = filp->private_data;
552 struct xenbus_transaction_holder *trans, *tmp;
553 struct watch_adapter *watch, *tmp_watch;
554
555 /*
556 * No need for locking here because there are no other users,
557 * by definition.
558 */
559
560 list_for_each_entry_safe(trans, tmp, &u->transactions, list) {
561 xenbus_transaction_end(trans->handle, 1);
562 list_del(&trans->list);
563 kfree(trans);
564 }
565
566 list_for_each_entry_safe(watch, tmp_watch, &u->watches, list) {
567 unregister_xenbus_watch(&watch->watch);
568 list_del(&watch->list);
569 free_watch_adapter(watch);
570 }
571
572 kfree(u);
573
574 return 0;
575}
576
577static unsigned int xenbus_file_poll(struct file *file, poll_table *wait)
578{
579 struct xenbus_file_priv *u = file->private_data;
580
581 poll_wait(file, &u->read_waitq, wait);
582 if (!list_empty(&u->read_buffers))
583 return POLLIN | POLLRDNORM;
584 return 0;
585}
586
587const struct file_operations xenbus_file_ops = {
588 .read = xenbus_file_read,
589 .write = xenbus_file_write,
590 .open = xenbus_file_open,
591 .release = xenbus_file_release,
592 .poll = xenbus_file_poll,
593};
diff --git a/drivers/xen/xenfs/xenfs.h b/drivers/xen/xenfs/xenfs.h
new file mode 100644
index 000000000000..51f08b2d0bf1
--- /dev/null
+++ b/drivers/xen/xenfs/xenfs.h
@@ -0,0 +1,6 @@
1#ifndef _XENFS_XENBUS_H
2#define _XENFS_XENBUS_H
3
4extern const struct file_operations xenbus_file_ops;
5
6#endif /* _XENFS_XENBUS_H */
diff --git a/drivers/zorro/.gitignore b/drivers/zorro/.gitignore
new file mode 100644
index 000000000000..34f980bd8ff6
--- /dev/null
+++ b/drivers/zorro/.gitignore
@@ -0,0 +1,2 @@
1devlist.h
2gen-devlist
diff --git a/drivers/zorro/zorro-sysfs.c b/drivers/zorro/zorro-sysfs.c
index 5290552d2ef7..1d2a772ea14c 100644
--- a/drivers/zorro/zorro-sysfs.c
+++ b/drivers/zorro/zorro-sysfs.c
@@ -77,17 +77,21 @@ static struct bin_attribute zorro_config_attr = {
77 .read = zorro_read_config, 77 .read = zorro_read_config,
78}; 78};
79 79
80void zorro_create_sysfs_dev_files(struct zorro_dev *z) 80int zorro_create_sysfs_dev_files(struct zorro_dev *z)
81{ 81{
82 struct device *dev = &z->dev; 82 struct device *dev = &z->dev;
83 int error;
83 84
84 /* current configuration's attributes */ 85 /* current configuration's attributes */
85 device_create_file(dev, &dev_attr_id); 86 if ((error = device_create_file(dev, &dev_attr_id)) ||
86 device_create_file(dev, &dev_attr_type); 87 (error = device_create_file(dev, &dev_attr_type)) ||
87 device_create_file(dev, &dev_attr_serial); 88 (error = device_create_file(dev, &dev_attr_serial)) ||
88 device_create_file(dev, &dev_attr_slotaddr); 89 (error = device_create_file(dev, &dev_attr_slotaddr)) ||
89 device_create_file(dev, &dev_attr_slotsize); 90 (error = device_create_file(dev, &dev_attr_slotsize)) ||
90 device_create_file(dev, &dev_attr_resource); 91 (error = device_create_file(dev, &dev_attr_resource)) ||
91 sysfs_create_bin_file(&dev->kobj, &zorro_config_attr); 92 (error = sysfs_create_bin_file(&dev->kobj, &zorro_config_attr)))
93 return error;
94
95 return 0;
92} 96}
93 97
diff --git a/drivers/zorro/zorro.c b/drivers/zorro/zorro.c
index dff16d9767d8..a1585d6f6486 100644
--- a/drivers/zorro/zorro.c
+++ b/drivers/zorro/zorro.c
@@ -130,6 +130,7 @@ static int __init zorro_init(void)
130{ 130{
131 struct zorro_dev *z; 131 struct zorro_dev *z;
132 unsigned int i; 132 unsigned int i;
133 int error;
133 134
134 if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(ZORRO)) 135 if (!MACH_IS_AMIGA || !AMIGAHW_PRESENT(ZORRO))
135 return 0; 136 return 0;
@@ -140,7 +141,11 @@ static int __init zorro_init(void)
140 /* Initialize the Zorro bus */ 141 /* Initialize the Zorro bus */
141 INIT_LIST_HEAD(&zorro_bus.devices); 142 INIT_LIST_HEAD(&zorro_bus.devices);
142 strcpy(zorro_bus.dev.bus_id, "zorro"); 143 strcpy(zorro_bus.dev.bus_id, "zorro");
143 device_register(&zorro_bus.dev); 144 error = device_register(&zorro_bus.dev);
145 if (error) {
146 pr_err("Zorro: Error registering zorro_bus\n");
147 return error;
148 }
144 149
145 /* Request the resources */ 150 /* Request the resources */
146 zorro_bus.num_resources = AMIGAHW_PRESENT(ZORRO3) ? 4 : 2; 151 zorro_bus.num_resources = AMIGAHW_PRESENT(ZORRO3) ? 4 : 2;
@@ -160,15 +165,19 @@ static int __init zorro_init(void)
160 zorro_name_device(z); 165 zorro_name_device(z);
161 z->resource.name = z->name; 166 z->resource.name = z->name;
162 if (request_resource(zorro_find_parent_resource(z), &z->resource)) 167 if (request_resource(zorro_find_parent_resource(z), &z->resource))
163 printk(KERN_ERR "Zorro: Address space collision on device %s " 168 pr_err("Zorro: Address space collision on device %s %pR\n",
164 "[%lx:%lx]\n", 169 z->name, &z->resource);
165 z->name, (unsigned long)zorro_resource_start(z),
166 (unsigned long)zorro_resource_end(z));
167 sprintf(z->dev.bus_id, "%02x", i); 170 sprintf(z->dev.bus_id, "%02x", i);
168 z->dev.parent = &zorro_bus.dev; 171 z->dev.parent = &zorro_bus.dev;
169 z->dev.bus = &zorro_bus_type; 172 z->dev.bus = &zorro_bus_type;
170 device_register(&z->dev); 173 error = device_register(&z->dev);
171 zorro_create_sysfs_dev_files(z); 174 if (error) {
175 pr_err("Zorro: Error registering device %s\n", z->name);
176 continue;
177 }
178 error = zorro_create_sysfs_dev_files(z);
179 if (error)
180 dev_err(&z->dev, "Error creating sysfs files\n");
172 } 181 }
173 182
174 /* Mark all available Zorro II memory */ 183 /* Mark all available Zorro II memory */
diff --git a/drivers/zorro/zorro.h b/drivers/zorro/zorro.h
index 5c91adac4df1..b682d5ccd63f 100644
--- a/drivers/zorro/zorro.h
+++ b/drivers/zorro/zorro.h
@@ -1,4 +1,4 @@
1 1
2extern void zorro_name_device(struct zorro_dev *z); 2extern void zorro_name_device(struct zorro_dev *z);
3extern void zorro_create_sysfs_dev_files(struct zorro_dev *z); 3extern int zorro_create_sysfs_dev_files(struct zorro_dev *z);
4 4